summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/graphics/gui/CMakeLists.txt2
-rw-r--r--data/graphics/gui/Makefile.am2
-rw-r--r--data/graphics/gui/dpad_attack.xml9
-rw-r--r--data/graphics/gui/dpad_cancel.xml9
-rw-r--r--data/graphics/gui/window.pngbin22491 -> 22500 bytes
-rw-r--r--src/touchactions.cpp29
-rw-r--r--src/touchactions.h8
-rw-r--r--src/touchmanager.cpp29
-rw-r--r--src/touchmanager.h15
9 files changed, 95 insertions, 8 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index 6d1589365..47cfed422 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -15,6 +15,8 @@ SET (FILES
colors.xml
complete_icon.xml
dpad.xml
+ dpad_attack.xml
+ dpad_cancel.xml
dropdown.xml
dropdown_background.xml
dropdown_pressed.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index 181def2cb..ed1b1c59e 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -18,6 +18,8 @@ gui_DATA = \
colors.xml \
complete_icon.xml \
dpad.xml \
+ dpad_attack.xml \
+ dpad_cancel.xml \
dropdown.xml \
dropdown_background.xml \
dropdown_pressed.xml \
diff --git a/data/graphics/gui/dpad_attack.xml b/data/graphics/gui/dpad_attack.xml
new file mode 100644
index 000000000..675014eed
--- /dev/null
+++ b/data/graphics/gui/dpad_attack.xml
@@ -0,0 +1,9 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window">
+ <option name="padding" value="20" />
+ <option name="x" value="0" />
+ <option name="y" value="0" />
+
+ <part type="standart" xpos="452" ypos="96" width="60" height="60" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/dpad_cancel.xml b/data/graphics/gui/dpad_cancel.xml
new file mode 100644
index 000000000..635d84721
--- /dev/null
+++ b/data/graphics/gui/dpad_cancel.xml
@@ -0,0 +1,9 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window">
+ <option name="padding" value="20" />
+ <option name="x" value="100" />
+ <option name="y" value="0" />
+
+ <part type="standart" xpos="452" ypos="96" width="60" height="60" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png
index e98b2aae9..15f36d826 100644
--- a/data/graphics/gui/window.png
+++ b/data/graphics/gui/window.png
Binary files differ
diff --git a/src/touchactions.cpp b/src/touchactions.cpp
index df18fd366..5f236ea4e 100644
--- a/src/touchactions.cpp
+++ b/src/touchactions.cpp
@@ -20,6 +20,7 @@
#include "touchactions.h"
+#include "actionmanager.h"
#include "being.h"
#include "game.h"
#include "keydata.h"
@@ -33,6 +34,7 @@
#include "debug.h"
+InputEvent tempEvent(0, 0);
bool padClicked(false);
#define impHandler(name) void name(const MouseInput &mouseInput)
@@ -137,3 +139,30 @@ impHandler0(padUp)
padClicked = false;
moveChar(50, 50);
}
+
+impHandler(attackClick)
+{
+ ActionManager::targetAttack(tempEvent);
+}
+
+impHandler(attackUp)
+{
+}
+
+impHandler(attackOut)
+{
+}
+
+impHandler(cancelClick)
+{
+ ActionManager::stopAttack(tempEvent);
+}
+
+impHandler(cancelUp)
+{
+}
+
+impHandler(cancelOut)
+{
+}
+
diff --git a/src/touchactions.h b/src/touchactions.h
index 080f02c6f..b16768f5e 100644
--- a/src/touchactions.h
+++ b/src/touchactions.h
@@ -35,6 +35,14 @@ decHandler(padEvents);
decHandler(padOut);
decHandler(padUp);
+decHandler(attackClick);
+decHandler(attackOut);
+decHandler(attackUp);
+
+decHandler(cancelClick);
+decHandler(cancelOut);
+decHandler(cancelUp);
+
#undef decHandler
#endif
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 79acaafb1..3b8c6e21b 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -37,6 +37,7 @@ extern int openGLMode;
TouchManager::TouchManager() :
mKeyboard(nullptr),
mPad(nullptr),
+ mAttack(nullptr),
mVertexes(new ImageCollection),
mRedraw(true)
{
@@ -52,18 +53,22 @@ TouchManager::~TouchManager()
void TouchManager::init()
{
#ifdef ANDROID
- loadTouchItem(&mKeyboard, "keyboard_icon.xml", false,
+ loadTouchItem(&mKeyboard, "keyboard_icon.xml", NORMAL,
nullptr, nullptr, &showKeyboard, nullptr);
#endif
if (config.getBoolValue("showScreenJoystick"))
{
- loadTouchItem(&mPad, "dpad.xml", true,
+ loadTouchItem(&mPad, "dpad.xml", LEFT,
&padEvents, &padClick, &padUp, &padOut);
+ loadTouchItem(&mAttack, "dpad_attack.xml", RIGHT,
+ nullptr, &attackClick, &attackUp, &attackOut);
+ loadTouchItem(&mCancel, "dpad_cancel.xml", RIGHT,
+ nullptr, &cancelClick, &cancelUp, &cancelOut);
}
}
-void TouchManager::loadTouchItem(TouchItem **item, std::string name, bool type,
+void TouchManager::loadTouchItem(TouchItem **item, std::string name, int type,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut)
{
@@ -79,11 +84,23 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name, bool type,
if (image)
{
image->incRef();
- const int x = skin->getOption("x", 10);
- const int y = type ? (mainGraphics->mHeight - image->mBounds.h) / 2
- + skin->getOption("y", 10) : skin->getOption("y", 10);
+ int x = skin->getOption("x", 10);
+ int y = skin->getOption("y", 10);
const int pad = skin->getPadding();
const int pad2 = 2 * pad;
+ switch (type)
+ {
+ case LEFT:
+ y += (mainGraphics->mHeight - image->mBounds.h) / 2;
+ break;
+ case RIGHT:
+ x = mainGraphics->mWidth - image->mBounds.w - pad2 - x;
+ y = mainGraphics->mHeight - image->mBounds.h - pad2 - y;
+ break;
+ case NORMAL:
+ default:
+ break;
+ }
*item = new TouchItem(gcn::Rectangle(x, y,
image->getWidth() + pad2, image->getHeight() + pad2),
image, x + pad, y + pad, fAll, fPressed, fReleased, fOut);
diff --git a/src/touchmanager.h b/src/touchmanager.h
index 8afd78c56..4c2339e15 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -23,6 +23,8 @@
#include "resources/image.h"
+#include "keydata.h"
+
#include <guichan/mouseinput.hpp>
#include <guichan/rectangle.hpp>
@@ -37,7 +39,7 @@ class MouseInput;
typedef void (*TouchFuncPtr) (const MouseInput &mouseInput);
-const int actionsSize = 10;
+const int actionsSize = Input::KEY_TOTAL;
struct TouchItem final
{
@@ -79,9 +81,16 @@ class TouchManager final
A_DELETE_COPY(TouchManager)
+ enum Types
+ {
+ NORMAL = 0,
+ LEFT = 1,
+ RIGHT = 2,
+ };
+
void init();
- void loadTouchItem(TouchItem **item, std::string name, bool type,
+ void loadTouchItem(TouchItem **item, std::string name, int type,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut);
@@ -104,6 +113,8 @@ class TouchManager final
private:
TouchItem *mKeyboard;
TouchItem *mPad;
+ TouchItem *mAttack;
+ TouchItem *mCancel;
TouchItemVector mObjects;
ImageCollection *mVertexes;
bool mActions[actionsSize];