summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-01 01:13:26 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-01 01:13:26 +0300
commit05e6289b28c26df11b38a71e737017d64d22b029 (patch)
treedd649b8ffe10fab5c5bb777381fb0491cb1c9f72 /src
parent82ace39b426a843382a6a809e7b66487c1412494 (diff)
downloadmv-05e6289b28c26df11b38a71e737017d64d22b029.tar.gz
mv-05e6289b28c26df11b38a71e737017d64d22b029.tar.bz2
mv-05e6289b28c26df11b38a71e737017d64d22b029.tar.xz
mv-05e6289b28c26df11b38a71e737017d64d22b029.zip
Allow select differnt modes for on screen buttons.
Now supported 2x1 and 2x2 modes.
Diffstat (limited to 'src')
-rw-r--r--src/defaults.cpp3
-rw-r--r--src/gui/setup_touch.cpp17
-rw-r--r--src/gui/setup_touch.h1
-rw-r--r--src/touchmanager.cpp56
-rw-r--r--src/touchmanager.h5
5 files changed, 69 insertions, 13 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp
index 37c210811..6b10c4f26 100644
--- a/src/defaults.cpp
+++ b/src/defaults.cpp
@@ -300,6 +300,9 @@ DefaultsData* getConfigDefaults()
AddDEF("screenActionKeyboard", Input::KEY_SHOW_KEYBOARD);
AddDEF("screenActionButton0", Input::KEY_STOP_SIT);
AddDEF("screenActionButton1", Input::KEY_TARGET_ATTACK);
+ AddDEF("screenActionButton2", Input::KEY_PICKUP);
+ AddDEF("screenActionButton3", Input::KEY_PATHFIND);
+ AddDEF("screenButtonsFormat", 0);
return configData;
}
diff --git a/src/gui/setup_touch.cpp b/src/gui/setup_touch.cpp
index 744be43d7..5aea8388d 100644
--- a/src/gui/setup_touch.cpp
+++ b/src/gui/setup_touch.cpp
@@ -37,9 +37,18 @@ static const char *const sizeList[] =
N_("Large")
};
+static const int formatListSize = 2;
+
+static const char *const formatList[] =
+{
+ "2x1",
+ "2x2",
+};
+
Setup_Touch::Setup_Touch(const Widget2 *const widget) :
SetupTabScroll(widget),
mSizeList(new NamesModel),
+ mFormatList(new NamesModel),
mActionsList(new TouchActionsModel)
{
setName(_("Touch"));
@@ -48,6 +57,7 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) :
ContainerPlacer place = h.getPlacer(0, 0);
place(0, 0, mScroll, 10, 10);
mSizeList->fillFromArray(&sizeList[0], sizeListSize);
+ mFormatList->fillFromArray(&formatList[0], formatListSize);
new SetupItemLabel(_("Onscreen keyboard"), "", this);
@@ -73,6 +83,9 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) :
new SetupItemCheckBox(_("Show onscreen buttons"), "",
"showScreenButtons", this, "showScreenButtonsEvent");
+ new SetupItemDropDown(_("Buttons format"), "", "screenButtonsFormat", this,
+ "screenButtonsFormatEvent", mFormatList, 100);
+
new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this,
"screenButtonsSizeEvent", mSizeList, 100);
@@ -91,4 +104,8 @@ Setup_Touch::~Setup_Touch()
{
delete mSizeList;
mSizeList = nullptr;
+ delete mFormatList;
+ mFormatList = nullptr;
+ delete mActionsList;
+ mActionsList = nullptr;
}
diff --git a/src/gui/setup_touch.h b/src/gui/setup_touch.h
index 2dc270abf..444006f48 100644
--- a/src/gui/setup_touch.h
+++ b/src/gui/setup_touch.h
@@ -39,6 +39,7 @@ class Setup_Touch final : public SetupTabScroll
protected:
NamesModel *mSizeList;
+ NamesModel *mFormatList;
TouchActionsModel *mActionsList;
};
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 4d7c78db6..ecbda62c6 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -38,8 +38,6 @@ extern int openGLMode;
TouchManager::TouchManager() :
mKeyboard(nullptr),
mPad(nullptr),
- mAttack(nullptr),
- mCancel(nullptr),
mVertexes(new ImageCollection),
mRedraw(true),
mShowJoystick(false),
@@ -47,12 +45,15 @@ TouchManager::TouchManager() :
mShowKeyboard(false),
mButtonsSize(1),
mJoystickSize(1),
+ mButtonsFormat(0),
mShow(false),
mInGame(false),
mTempHideButtons(false)
{
for (int f = 0; f < actionsSize; f ++)
mActions[f] = false;
+ for (int f = 0; f < buttonsCount; f ++)
+ mButtons[f] = nullptr;
}
TouchManager::~TouchManager()
@@ -74,12 +75,14 @@ void TouchManager::init()
config.addListener("showScreenKeyboard", this);
config.addListener("screenButtonsSize", this);
config.addListener("screenJoystickSize", this);
+ config.addListener("screenButtonsFormat", this);
mShowJoystick = config.getBoolValue("showScreenJoystick");
mShowButtons = config.getBoolValue("showScreenButtons");
mShowKeyboard = config.getBoolValue("showScreenKeyboard");
mButtonsSize = config.getIntValue("screenButtonsSize");
mJoystickSize = config.getIntValue("screenJoystickSize");
+ mButtonsFormat = config.getIntValue("screenButtonsFormat");
setHalfJoyPad(getPadSize() / 2);
@@ -370,16 +373,35 @@ void TouchManager::loadButtons()
const int pad = skin->getPadding();
const int pad2 = 2 * pad;
const int skipWidth = pad2 + sz + x;
+ const int skipHeight = pad2 + sz + y;
- loadTouchItem(&mAttack, "dbutton.xml", "dbutton_image.xml", x, y,
- sz, sz, RIGHT, "screenActionButton1", "");
+ // 2x1
+ if (mButtonsFormat == 0)
+ {
+ loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml", x, y,
+ sz, sz, RIGHT, "screenActionButton1", "");
+
+ loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
+ skipWidth, y, sz, sz, RIGHT, "screenActionButton0", "");
+ }
+ // 2x2
+ else if (mButtonsFormat == 1)
+ {
+ loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml", x, y,
+ sz, sz, RIGHT, "screenActionButton3", "");
- loadTouchItem(&mCancel, "dbutton.xml", "dbutton_image.xml",
- skipWidth, y, sz, sz, RIGHT, "screenActionButton0", "");
+ loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml",
+ skipWidth, y, sz, sz, RIGHT, "screenActionButton2", "");
+ loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml",
+ x, skipHeight, sz, sz, RIGHT, "screenActionButton1", "");
+
+ loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml",
+ skipWidth, skipHeight, sz, sz, RIGHT,
+ "screenActionButton0", "");
+ }
theme->unload(skin);
}
-
}
void TouchManager::loadKeyboard()
@@ -412,8 +434,8 @@ void TouchManager::optionChanged(const std::string &value)
}
else
{
- unloadTouchItem(&mAttack);
- unloadTouchItem(&mCancel);
+ for (int f = 0; f < buttonsCount; f ++)
+ unloadTouchItem(&mButtons[f]);
}
mRedraw = true;
}
@@ -435,8 +457,8 @@ void TouchManager::optionChanged(const std::string &value)
mButtonsSize = config.getIntValue("screenButtonsSize");
if (mShowButtons)
{
- unloadTouchItem(&mAttack);
- unloadTouchItem(&mCancel);
+ for (int f = 0; f < buttonsCount; f ++)
+ unloadTouchItem(&mButtons[f]);
loadButtons();
}
}
@@ -452,6 +474,18 @@ void TouchManager::optionChanged(const std::string &value)
loadPad();
}
}
+ else if (value == "screenButtonsFormat")
+ {
+ if (mButtonsFormat == config.getIntValue("screenButtonsFormat"))
+ return;
+ mButtonsFormat = config.getIntValue("screenButtonsFormat");
+ if (mButtonsFormat)
+ {
+ for (int f = 0; f < buttonsCount; f ++)
+ unloadTouchItem(&mButtons[f]);
+ loadButtons();
+ }
+ }
}
void TouchManager::setInGame(bool b)
diff --git a/src/touchmanager.h b/src/touchmanager.h
index ea8a3a72f..ce972e41b 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -43,6 +43,7 @@ class Skin;
typedef void (*TouchFuncPtr) (const MouseInput &mouseInput);
const int actionsSize = Input::KEY_TOTAL;
+const int buttonsCount = 4;
struct TouchItem final
{
@@ -162,8 +163,7 @@ class TouchManager final : public ConfigListener
private:
TouchItem *mKeyboard;
TouchItem *mPad;
- TouchItem *mAttack;
- TouchItem *mCancel;
+ TouchItem *mButtons[buttonsCount];
TouchItemVector mObjects;
ImageCollection *mVertexes;
bool mActions[actionsSize];
@@ -173,6 +173,7 @@ class TouchManager final : public ConfigListener
bool mShowKeyboard;
int mButtonsSize;
int mJoystickSize;
+ int mButtonsFormat;
bool mShow;
bool mInGame;
bool mTempHideButtons;