summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-06 20:11:49 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-06 20:21:25 +0300
commit23d29ec55093cd95c9084965a179ef70da2af150 (patch)
treebc579bc2dcc30fb588926a64d4ef1415e281492c
parent17bb7a5de4b9406f1a02d092ae590ab71b7265ba (diff)
downloadmanaplus-23d29ec55093cd95c9084965a179ef70da2af150.tar.gz
manaplus-23d29ec55093cd95c9084965a179ef70da2af150.tar.bz2
manaplus-23d29ec55093cd95c9084965a179ef70da2af150.tar.xz
manaplus-23d29ec55093cd95c9084965a179ef70da2af150.zip
Add support for draw broders for on screen buttons.
-rw-r--r--data/graphics/gui/dpad.xml19
-rw-r--r--data/graphics/gui/dpad_attack.xml19
-rw-r--r--data/graphics/gui/dpad_cancel.xml19
-rw-r--r--data/graphics/gui/keyboard_icon.xml21
-rw-r--r--data/graphics/gui/window.pngbin22500 -> 22519 bytes
-rw-r--r--data/themes/jewelry/keyboard_icon.xml17
-rw-r--r--src/normalopenglgraphics.cpp2
-rw-r--r--src/touchmanager.cpp66
-rw-r--r--src/touchmanager.h18
9 files changed, 140 insertions, 41 deletions
diff --git a/data/graphics/gui/dpad.xml b/data/graphics/gui/dpad.xml
index 79ba00907..0cd91ef27 100644
--- a/data/graphics/gui/dpad.xml
+++ b/data/graphics/gui/dpad.xml
@@ -1,9 +1,22 @@
<skinset name="Default" image="window.png">
- <widget type="Window">
+ <widget type="Window" xpos="486" ypos="232">
<option name="padding" value="10" />
<option name="x" value="0" />
<option name="y" value="0" />
- <part type="standart" xpos="412" ypos="156" width="100" height="100" />
- </widget>
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="10" height="5" />
+ <part type="top-edge" xpos="9" ypos="0" width="8" height="5" />
+ <part type="top-right-corner" xpos="16" ypos="0" width="10" height="5" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="4" width="10" height="16" />
+ <part type="bg-quad" xpos="9" ypos="4" width="8" height="16" />
+ <part type="right-edge" xpos="16" ypos="4" width="10" height="16" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="19" width="10" height="5" />
+ <part type="bottom-edge" xpos="9" ypos="19" width="8" height="5" />
+ <part type="bottom-right-corner" xpos="16" ypos="19" width="10" height="5" />
+ </widget>
</skinset>
diff --git a/data/graphics/gui/dpad_attack.xml b/data/graphics/gui/dpad_attack.xml
index 675014eed..ebf312aca 100644
--- a/data/graphics/gui/dpad_attack.xml
+++ b/data/graphics/gui/dpad_attack.xml
@@ -1,9 +1,22 @@
<skinset name="Default" image="window.png">
- <widget type="Window">
+ <widget type="Window" xpos="486" ypos="232">
<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>
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="10" height="5" />
+ <part type="top-edge" xpos="9" ypos="0" width="8" height="5" />
+ <part type="top-right-corner" xpos="16" ypos="0" width="10" height="5" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="4" width="10" height="16" />
+ <part type="bg-quad" xpos="9" ypos="4" width="8" height="16" />
+ <part type="right-edge" xpos="16" ypos="4" width="10" height="16" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="19" width="10" height="5" />
+ <part type="bottom-edge" xpos="9" ypos="19" width="8" height="5" />
+ <part type="bottom-right-corner" xpos="16" ypos="19" width="10" height="5" />
+ </widget>
</skinset>
diff --git a/data/graphics/gui/dpad_cancel.xml b/data/graphics/gui/dpad_cancel.xml
index 635d84721..34702c197 100644
--- a/data/graphics/gui/dpad_cancel.xml
+++ b/data/graphics/gui/dpad_cancel.xml
@@ -1,9 +1,22 @@
<skinset name="Default" image="window.png">
- <widget type="Window">
+ <widget type="Window" xpos="486" ypos="232">
<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>
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="10" height="5" />
+ <part type="top-edge" xpos="9" ypos="0" width="8" height="5" />
+ <part type="top-right-corner" xpos="16" ypos="0" width="10" height="5" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="4" width="10" height="16" />
+ <part type="bg-quad" xpos="9" ypos="4" width="8" height="16" />
+ <part type="right-edge" xpos="16" ypos="4" width="10" height="16" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="19" width="10" height="5" />
+ <part type="bottom-edge" xpos="9" ypos="19" width="8" height="5" />
+ <part type="bottom-right-corner" xpos="16" ypos="19" width="10" height="5" />
+ </widget>
</skinset>
diff --git a/data/graphics/gui/keyboard_icon.xml b/data/graphics/gui/keyboard_icon.xml
index 4b157ef10..4cffb4502 100644
--- a/data/graphics/gui/keyboard_icon.xml
+++ b/data/graphics/gui/keyboard_icon.xml
@@ -1,9 +1,24 @@
<skinset name="Default" image="window.png">
- <widget type="Window">
+ <widget type="Window" xpos="169" ypos="220">
<option name="padding" value="5" />
<option name="x" value="10" />
<option name="y" value="10" />
- <part type="standart" xpos="168" ypos="220" width="28" height="28" />
- </widget>
+<!-- <part type="bg-quad" xpos="168" ypos="220" width="28" height="28" />-->
+
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="0" ypos="0" width="28" height="28" />
+ <part type="top-edge" xpos="0" ypos="0" width="0" height="0" />
+ <part type="top-right-corner" xpos="0" ypos="0" width="0" height="0" />
+
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="0" width="0" height="0" />
+ <part type="bg-quad" xpos="0" ypos="0" width="0" height="0" />
+ <part type="right-edge" xpos="0" ypos="0" width="0" height="0" />
+
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="0" width="0" height="0" />
+ <part type="bottom-edge" xpos="0" ypos="0" width="0" height="0" />
+ <part type="bottom-right-corner" xpos="0" ypos="0" width="0" height="0" />
+ </widget>
</skinset>
diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png
index 15f36d826..08b341ba3 100644
--- a/data/graphics/gui/window.png
+++ b/data/graphics/gui/window.png
Binary files differ
diff --git a/data/themes/jewelry/keyboard_icon.xml b/data/themes/jewelry/keyboard_icon.xml
index c31d38c8b..ed5773dda 100644
--- a/data/themes/jewelry/keyboard_icon.xml
+++ b/data/themes/jewelry/keyboard_icon.xml
@@ -1,9 +1,22 @@
<skinset name="Default" image="window.png">
<widget type="Window">
-
<option name="padding" value="6" />
+ <option name="x" value="10" />
+ <option name="y" value="10" />
+
+ <!-- Top Row -->
+ <part type="top-left-corner" xpos="153" ypos="186" width="32" height="32" />
+ <part type="top-edge" xpos="0" ypos="0" width="0" height="0" />
+ <part type="top-right-corner" xpos="0" ypos="0" width="0" height="0" />
- <part type="standart" xpos="153" ypos="186" width="32" height="32" />
+ <!-- Middle Row -->
+ <part type="left-edge" xpos="0" ypos="0" width="0" height="0" />
+ <part type="bg-quad" xpos="0" ypos="0" width="0" height="0" />
+ <part type="right-edge" xpos="0" ypos="0" width="0" height="0" />
+ <!-- Bottom Row -->
+ <part type="bottom-left-corner" xpos="0" ypos="0" width="0" height="0" />
+ <part type="bottom-edge" xpos="0" ypos="0" width="0" height="0" />
+ <part type="bottom-right-corner" xpos="0" ypos="0" width="0" height="0" />
</widget>
</skinset>
diff --git a/src/normalopenglgraphics.cpp b/src/normalopenglgraphics.cpp
index f7ca7b802..d41229442 100644
--- a/src/normalopenglgraphics.cpp
+++ b/src/normalopenglgraphics.cpp
@@ -1150,6 +1150,8 @@ bool NormalOpenGLGraphics::calcWindow(ImageCollection *const vertCol,
{
ImageVertexes *vert = nullptr;
Image *const image = imgRect.grid[4];
+ if (!image)
+ return false;
if (vertCol->currentGLImage != image->mGLImage)
{
vert = new ImageVertexes();
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 3a022afc3..4fc5c57e7 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -55,22 +55,23 @@ TouchManager::~TouchManager()
void TouchManager::init()
{
#ifdef ANDROID
- loadTouchItem(&mKeyboard, "keyboard_icon.xml", NORMAL,
+ loadTouchItem(&mKeyboard, "keyboard_icon.xml", 28, 28, NORMAL,
nullptr, nullptr, &showKeyboard, nullptr);
#endif
if (config.getBoolValue("showScreenJoystick"))
{
- loadTouchItem(&mPad, "dpad.xml", LEFT,
+ loadTouchItem(&mPad, "dpad.xml", 100, 100, LEFT,
&padEvents, &padClick, &padUp, &padOut);
- loadTouchItem(&mAttack, "dpad_attack.xml", RIGHT,
+ loadTouchItem(&mAttack, "dpad_attack.xml", 60, 60, RIGHT,
nullptr, &attackClick, &attackUp, &attackOut);
- loadTouchItem(&mCancel, "dpad_cancel.xml", RIGHT,
+ loadTouchItem(&mCancel, "dpad_cancel.xml", 60, 60, RIGHT,
nullptr, &cancelClick, &cancelUp, &cancelOut);
}
}
-void TouchManager::loadTouchItem(TouchItem **item, std::string name, int type,
+void TouchManager::loadTouchItem(TouchItem **item, std::string name,
+ int width, int height, int type,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut)
{
@@ -78,14 +79,17 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name, int type,
Theme *theme = Theme::instance();
if (!theme)
return;
- Skin *const skin = theme->load(name, "");
+ ImageRect *images = new ImageRect;
+ for (int f = 0; f < 9; f ++)
+ images->grid[f] = nullptr;
+
+ Skin *const skin = theme->loadSkinRect(*images, name, "");
if (skin)
{
- const ImageRect &images = skin->getBorder();
- Image *image = images.grid[0];
+ Image *image = images->grid[0];
if (image)
{
- image->incRef();
+// image->incRef();
int x = skin->getOption("x", 10);
int y = skin->getOption("y", 10);
const int pad = skin->getPadding();
@@ -96,16 +100,17 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name, int type,
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;
+ x = mainGraphics->mWidth - width - pad2 - x;
+ y = mainGraphics->mHeight - height - 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);
+ width + pad2, height + pad2),
+ images, x + pad, y + pad, width, height,
+ fAll, fPressed, fReleased, fOut);
mObjects.push_back(*item);
}
theme->unload(skin);
@@ -118,14 +123,21 @@ void TouchManager::clear()
// unloadTouchItem(&mPad);
// unloadTouchItem(&mKeyboard);
+ Theme *theme = Theme::instance();
+ if (!theme)
+ return;
for (TouchItemVectorCIter it = mObjects.begin(), it_end = mObjects.end();
it != it_end; ++ it)
{
TouchItem *item = *it;
if (item)
{
- if (item->image)
- item->image->decRef();
+ if (item->images)
+ {
+ theme->unloadRect(*item->images);
+ delete item->images;
+ item->images = nullptr;
+ }
delete item;
}
}
@@ -133,18 +145,25 @@ void TouchManager::clear()
mRedraw = true;
}
+/*
void TouchManager::unloadTouchItem(TouchItem **item0)
{
TouchItem *item = *item0;
if (item)
{
- if (item->image)
- item->image->decRef();
+// if (item->image)
+// item->image->decRef();
+ if (item->skin)
+ {
+ theme->unload(skin);
+ item->skin = nullptr;
+ }
delete item;
*item0 = nullptr;
}
mRedraw = true;
}
+*/
void TouchManager::draw()
{
@@ -159,10 +178,10 @@ void TouchManager::draw()
it != it_end; ++ it)
{
const TouchItem *const item = *it;
- if (item && item->image)
+ if (item && item->images)
{
- mainGraphics->calcTile(mVertexes, item->image,
- item->x, item->y);
+ mainGraphics->calcWindow(mVertexes, item->x, item->y,
+ item->width, item->height, *item->images);
}
}
}
@@ -175,8 +194,11 @@ void TouchManager::draw()
it != it_end; ++ it)
{
const TouchItem *const item = *it;
- if (item && item->image)
- mainGraphics->drawImage(item->image, item->x, item->y);
+ if (item && item->images)
+ {
+ mainGraphics->drawImageRect(item->x, item->y,
+ item->width, item->height, *item->images);
+ }
}
}
}
diff --git a/src/touchmanager.h b/src/touchmanager.h
index 4c2339e15..ec4c46bb3 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -35,7 +35,9 @@
#include "localconsts.h"
class ImageCollection;
+class ImageRect;
class MouseInput;
+class Skin;
typedef void (*TouchFuncPtr) (const MouseInput &mouseInput);
@@ -43,13 +45,16 @@ const int actionsSize = Input::KEY_TOTAL;
struct TouchItem final
{
- TouchItem(const gcn::Rectangle rect0, Image *const img, int x0, int y0,
+ TouchItem(const gcn::Rectangle rect0, ImageRect *const images0,
+ int x0, int y0, int width0, int height0,
TouchFuncPtr ptrAll, TouchFuncPtr ptrPressed,
TouchFuncPtr ptrReleased, TouchFuncPtr ptrOut) :
rect(rect0),
- image(img),
+ images(images0),
x(x0),
y(y0),
+ width(width0),
+ height(height0),
funcAll(ptrAll),
funcPressed(ptrPressed),
funcReleased(ptrReleased),
@@ -60,9 +65,11 @@ struct TouchItem final
A_DELETE_COPY(TouchItem)
gcn::Rectangle rect;
- Image *image;
+ ImageRect *images;
int x;
int y;
+ int width;
+ int height;
TouchFuncPtr funcAll;
TouchFuncPtr funcPressed;
TouchFuncPtr funcReleased;
@@ -90,13 +97,14 @@ class TouchManager final
void init();
- void loadTouchItem(TouchItem **item, std::string name, int type,
+ void loadTouchItem(TouchItem **item, std::string name,
+ int type, int width, int height,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut);
void clear();
- void unloadTouchItem(TouchItem **item0);
+// void unloadTouchItem(TouchItem **item0);
void draw();