diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-10-01 01:41:48 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-10-01 01:42:56 +0300 |
commit | 6915c38ca9c35bfb9a5ea05fe957463d644a75de (patch) | |
tree | 9f7473433b42078dcb2d22b9a04dac1b014c89d0 | |
parent | 251c9cccce6252238797bc4ac782175dd0aeb42e (diff) | |
download | plus-6915c38ca9c35bfb9a5ea05fe957463d644a75de.tar.gz plus-6915c38ca9c35bfb9a5ea05fe957463d644a75de.tar.bz2 plus-6915c38ca9c35bfb9a5ea05fe957463d644a75de.tar.xz plus-6915c38ca9c35bfb9a5ea05fe957463d644a75de.zip |
Add on screen buttons layout 3x3, 4x2, 4x3
-rw-r--r-- | src/defaults.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/tabs/setup_touch.cpp | 32 | ||||
-rw-r--r-- | src/touchmanager.cpp | 152 | ||||
-rw-r--r-- | src/touchmanager.h | 2 |
4 files changed, 145 insertions, 49 deletions
diff --git a/src/defaults.cpp b/src/defaults.cpp index 4b62ca062..6e44aa36f 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -314,6 +314,14 @@ DefaultsData* getConfigDefaults() AddDEF("screenActionButton1", Input::KEY_TARGET_ATTACK); AddDEF("screenActionButton2", Input::KEY_PICKUP); AddDEF("screenActionButton3", Input::KEY_PATHFIND); + AddDEF("screenActionButton4", Input::KEY_STOP_ATTACK); + AddDEF("screenActionButton5", Input::KEY_TALK); + AddDEF("screenActionButton6", Input::KEY_TARGET_NPC); + AddDEF("screenActionButton7", Input::KEY_TARGET_MONSTER); + AddDEF("screenActionButton8", Input::KEY_WINDOW_CHAT); + AddDEF("screenActionButton9", Input::KEY_WINDOW_DEBUG); + AddDEF("screenActionButton10", Input::KEY_TRADE); + AddDEF("screenActionButton11", Input::KEY_DIRECT_DOWN); AddDEF("screenButtonsFormat", 0); AddDEF("autoresizeminimaps", false); AddDEF("showGuildOnline", false); diff --git a/src/gui/widgets/tabs/setup_touch.cpp b/src/gui/widgets/tabs/setup_touch.cpp index e3081427d..6e3c12a02 100644 --- a/src/gui/widgets/tabs/setup_touch.cpp +++ b/src/gui/widgets/tabs/setup_touch.cpp @@ -42,12 +42,15 @@ static const char *const sizeList[] = N_("Large") }; -static const int formatListSize = 2; +static const int formatListSize = 5; static const char *const formatList[] = { "2x1", "2x2", + "3x3", + "4x2", + "4x3" }; Setup_Touch::Setup_Touch(const Widget2 *const widget) : @@ -105,25 +108,14 @@ Setup_Touch::Setup_Touch(const Widget2 *const widget) : new SetupItemDropDown(_("Buttons size"), "", "screenButtonsSize", this, "screenButtonsSizeEvent", mSizeList, 100); - // TRANSLATORS: settings option - new SetupActionDropDown(strprintf(_("Button %u action"), 1U), "", - "screenActionButton0", this, "screenActionButton0Event", - mActionsList, 250); - - // TRANSLATORS: settings option - new SetupActionDropDown(strprintf(_("Button %u action"), 2U), "", - "screenActionButton1", this, "screenActionButton1Event", - mActionsList, 250); - - // TRANSLATORS: settings option - new SetupActionDropDown(strprintf(_("Button %u action"), 3U), "", - "screenActionButton2", this, "screenActionButton2Event", - mActionsList, 250); - - // TRANSLATORS: settings option - new SetupActionDropDown(strprintf(_("Button %u action"), 4U), "", - "screenActionButton3", this, "screenActionButton3Event", - mActionsList, 250); + for (unsigned int f = 0; f < 12; f ++) + { + std::string key = strprintf("screenActionButton%u", f); + std::string event = strprintf("screenActionButton%uEvent", f); + // TRANSLATORS: settings option + new SetupActionDropDown(strprintf(_("Button %u action"), f + 1), "", + key, this, event, mActionsList, 250); + } setDimension(gcn::Rectangle(0, 0, 550, 350)); } diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp index 19dca23f9..ad958ba82 100644 --- a/src/touchmanager.cpp +++ b/src/touchmanager.cpp @@ -374,35 +374,131 @@ void TouchManager::loadButtons() const int x = skin->getOption("x", 10); const int y = skin->getOption("y", 10); const int pad = skin->getPadding(); - const int pad2 = 2 * pad; - const int skipWidth = pad2 + sz + x; - const int skipHeight = pad2 + sz + y; + const int pad2 = 2 * pad + sz; + const int skipWidth = pad2 + x; + const int skipHeight = pad2 + y; - // 2x1 - if (mButtonsFormat == 0) + switch (mButtonsFormat) { - 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(&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", ""); - } + // 2x1 + case 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", ""); + break; + } + // 2x2 + case 1: + { + loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml", + x, y, sz, sz, RIGHT, "screenActionButton3", ""); + 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", ""); + break; + } + // 3x3 + case 2: + { + const int pad4 = pad2 * 2; + const int skipWidth2 = pad4 + x; + const int skipHeight2 = pad4 + y; + loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml", + x, y, sz, sz, RIGHT, "screenActionButton8", ""); + loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml", + skipWidth, y, sz, sz, RIGHT, "screenActionButton7", ""); + loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml", + skipWidth2, y, sz, sz, RIGHT, "screenActionButton6", ""); + loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml", + x, skipHeight, sz, sz, RIGHT, "screenActionButton5", ""); + loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml", + skipWidth, skipHeight, sz, sz, RIGHT, + "screenActionButton4", ""); + loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml", + skipWidth2, skipHeight, sz, sz, RIGHT, + "screenActionButton3", ""); + loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml", + x, skipHeight2, sz, sz, RIGHT, "screenActionButton2", ""); + loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml", + skipWidth, skipHeight2, sz, sz, RIGHT, + "screenActionButton1", ""); + loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml", + skipWidth2, skipHeight2, sz, sz, RIGHT, + "screenActionButton0", ""); + break; + } + // 4x2 + case 3: + { + const int skipWidth2 = pad2 * 2 + x; + const int skipWidth3 = pad2 * 3 + x; + loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml", + x, y, sz, sz, RIGHT, "screenActionButton7", ""); + loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml", + skipWidth, y, sz, sz, RIGHT, "screenActionButton6", ""); + loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml", + skipWidth2, y, sz, sz, RIGHT, "screenActionButton5", ""); + loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml", + skipWidth3, y, sz, sz, RIGHT, "screenActionButton4", ""); + loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml", + x, skipHeight, sz, sz, RIGHT, "screenActionButton3", ""); + loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml", + skipWidth, skipHeight, sz, sz, RIGHT, + "screenActionButton2", ""); + loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml", + skipWidth2, skipHeight, sz, sz, RIGHT, + "screenActionButton1", ""); + loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml", + skipWidth3, skipHeight, sz, sz, RIGHT, + "screenActionButton0", ""); + break; + } + // 4x3 + case 4: + { + const int skipWidth2 = pad2 * 2 + x; + const int skipWidth3 = pad2 * 3 + x; + const int skipHeight2 = pad2 * 2 + y; + loadTouchItem(&mButtons[11], "dbutton.xml", + "dbutton_image.xml", x, y, sz, sz, RIGHT, + "screenActionButton11", ""); + loadTouchItem(&mButtons[10], "dbutton.xml", "dbutton_image.xml", + skipWidth, y, sz, sz, RIGHT, "screenActionButton10", ""); + loadTouchItem(&mButtons[9], "dbutton.xml", "dbutton_image.xml", + skipWidth2, y, sz, sz, RIGHT, "screenActionButton9", ""); + loadTouchItem(&mButtons[8], "dbutton.xml", "dbutton_image.xml", + skipWidth3, y, sz, sz, RIGHT, "screenActionButton8", ""); + loadTouchItem(&mButtons[7], "dbutton.xml", "dbutton_image.xml", + x, skipHeight, sz, sz, RIGHT, "screenActionButton7", ""); + loadTouchItem(&mButtons[6], "dbutton.xml", "dbutton_image.xml", + skipWidth, skipHeight, sz, sz, RIGHT, + "screenActionButton6", ""); + loadTouchItem(&mButtons[5], "dbutton.xml", "dbutton_image.xml", + skipWidth2, skipHeight, sz, sz, RIGHT, + "screenActionButton5", ""); + loadTouchItem(&mButtons[4], "dbutton.xml", "dbutton_image.xml", + skipWidth3, skipHeight, sz, sz, RIGHT, + "screenActionButton4", ""); + loadTouchItem(&mButtons[3], "dbutton.xml", "dbutton_image.xml", + x, skipHeight2, sz, sz, RIGHT, "screenActionButton3", ""); + loadTouchItem(&mButtons[2], "dbutton.xml", "dbutton_image.xml", + skipWidth, skipHeight2, sz, sz, RIGHT, + "screenActionButton2", ""); + loadTouchItem(&mButtons[1], "dbutton.xml", "dbutton_image.xml", + skipWidth2, skipHeight2, sz, sz, RIGHT, + "screenActionButton1", ""); + loadTouchItem(&mButtons[0], "dbutton.xml", "dbutton_image.xml", + skipWidth3, skipHeight2, sz, sz, RIGHT, + "screenActionButton0", ""); + break; + } + }; theme->unload(skin); } } @@ -482,7 +578,7 @@ void TouchManager::optionChanged(const std::string &value) if (mButtonsFormat == config.getIntValue("screenButtonsFormat")) return; mButtonsFormat = config.getIntValue("screenButtonsFormat"); - if (mButtonsFormat) + if (mShowButtons) { for (int f = 0; f < buttonsCount; f ++) unloadTouchItem(&mButtons[f]); diff --git a/src/touchmanager.h b/src/touchmanager.h index 2a7962065..2b2c9cf2d 100644 --- a/src/touchmanager.h +++ b/src/touchmanager.h @@ -41,7 +41,7 @@ class MouseInput; typedef void (*TouchFuncPtr) (const MouseInput &mouseInput); const int actionsSize = Input::KEY_TOTAL; -const int buttonsCount = 4; +const int buttonsCount = 12; struct TouchItem final { |