summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-18 22:42:34 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-18 22:43:53 +0300
commit4b2cbbeae4acc6b2c94f5455eb0c5d1134b32588 (patch)
treee29d33dd9b293093258b3e4238a00a7169c48e32
parent26bf983ed44960508f318e804e8f2fa515f0df2c (diff)
downloadplus-4b2cbbeae4acc6b2c94f5455eb0c5d1134b32588.tar.gz
plus-4b2cbbeae4acc6b2c94f5455eb0c5d1134b32588.tar.bz2
plus-4b2cbbeae4acc6b2c94f5455eb0c5d1134b32588.tar.xz
plus-4b2cbbeae4acc6b2c94f5455eb0c5d1134b32588.zip
Add support for show images in on screen buttons center.
New theme files: dbutton_image.xml dpad_image.xml
-rw-r--r--data/graphics/gui/CMakeLists.txt2
-rw-r--r--data/graphics/gui/Makefile.am2
-rw-r--r--data/graphics/gui/dpad_image.xml5
-rw-r--r--data/graphics/gui/window.pngbin22519 -> 23006 bytes
-rw-r--r--src/touchactions.cpp1
-rw-r--r--src/touchmanager.cpp41
-rw-r--r--src/touchmanager.h5
7 files changed, 47 insertions, 9 deletions
diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt
index ad033c1fd..d71f54822 100644
--- a/data/graphics/gui/CMakeLists.txt
+++ b/data/graphics/gui/CMakeLists.txt
@@ -15,7 +15,9 @@ SET (FILES
colors.xml
complete_icon.xml
dbutton.xml
+ dbutton_image.xml
dpad.xml
+ dpad_image.xml
dropdown.xml
dropdown_background.xml
dropdown_pressed.xml
diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am
index 45135d8aa..b058a10b5 100644
--- a/data/graphics/gui/Makefile.am
+++ b/data/graphics/gui/Makefile.am
@@ -18,7 +18,9 @@ gui_DATA = \
colors.xml \
complete_icon.xml \
dbutton.xml \
+ dbutton_image.xml \
dpad.xml \
+ dpad_image.xml \
dropdown.xml \
dropdown_background.xml \
dropdown_pressed.xml \
diff --git a/data/graphics/gui/dpad_image.xml b/data/graphics/gui/dpad_image.xml
new file mode 100644
index 000000000..cf43fc29b
--- /dev/null
+++ b/data/graphics/gui/dpad_image.xml
@@ -0,0 +1,5 @@
+<skinset name="Default" image="window.png">
+ <widget type="Window">
+ <part type="standart" xpos="412" ypos="132" width="100" height="100" />
+ </widget>
+</skinset>
diff --git a/data/graphics/gui/window.png b/data/graphics/gui/window.png
index 08b341ba3..dbdd59304 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 84b6e0942..a12f54e99 100644
--- a/src/touchactions.cpp
+++ b/src/touchactions.cpp
@@ -51,7 +51,6 @@ impHandler0(showKeyboard)
void setHalfJoyPad(int s)
{
- logger->log("set size: %d", s);
haldJoyPad = s;
}
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index 38f9c3237..2bfe2c572 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -75,7 +75,7 @@ void TouchManager::init()
setHalfJoyPad(getPadSize() / 2);
#ifdef ANDROID
- loadTouchItem(&mKeyboard, "keyboard_icon.xml", -1, -1, 28, 28, NORMAL,
+ loadTouchItem(&mKeyboard, "keyboard_icon.xml", "", -1, -1, 28, 28, NORMAL,
nullptr, nullptr, &showKeyboard, nullptr);
#endif
@@ -86,6 +86,7 @@ void TouchManager::init()
}
void TouchManager::loadTouchItem(TouchItem **item, std::string name,
+ std::string imageName,
int x, int y, int width, int height, int type,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut)
@@ -98,6 +99,12 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name,
for (int f = 0; f < 9; f ++)
images->grid[f] = nullptr;
+ Image *icon;
+ if (imageName.empty())
+ icon = nullptr;
+ else
+ icon = Theme::getImageFromThemeXml(imageName, "");
+
Skin *const skin = theme->loadSkinRect(*images, name, "");
if (skin)
{
@@ -125,7 +132,7 @@ void TouchManager::loadTouchItem(TouchItem **item, std::string name,
}
*item = new TouchItem(gcn::Rectangle(x, y,
width + pad2, height + pad2), type,
- images, x + pad, y + pad, width, height,
+ images, icon, x + pad, y + pad, width, height,
fAll, fPressed, fReleased, fOut);
mObjects.push_back(*item);
}
@@ -165,6 +172,13 @@ void TouchManager::draw()
{
mainGraphics->calcWindow(mVertexes, item->x, item->y,
item->width, item->height, *item->images);
+ const Image *const icon = item->icon;
+ if (icon)
+ {
+ mainGraphics->calcTile(mVertexes, icon,
+ item->x + (item->width - icon->mBounds.w) / 2,
+ item->y + (item->height - icon->mBounds.h) / 2);
+ }
}
}
}
@@ -181,6 +195,13 @@ void TouchManager::draw()
{
mainGraphics->drawImageRect(item->x, item->y,
item->width, item->height, *item->images);
+ const Image *const icon = item->icon;
+ if (icon)
+ {
+ mainGraphics->drawImage(icon,
+ item->x + (item->width - icon->mBounds.w) / 2,
+ item->y + (item->height - icon->mBounds.h) / 2);
+ }
}
}
}
@@ -284,6 +305,11 @@ void TouchManager::unload(TouchItem *item)
theme->unloadRect(*item->images);
delete item->images;
item->images = nullptr;
+ if (item->icon)
+ {
+ item->icon->decRef();
+ item->icon = nullptr;
+ }
}
delete item;
}
@@ -310,7 +336,7 @@ void TouchManager::unloadTouchItem(TouchItem **unloadItem)
void TouchManager::loadPad()
{
const int sz = (mJoystickSize + 2) * 50;
- loadTouchItem(&mPad, "dpad.xml", -1, -1, sz, sz, LEFT,
+ loadTouchItem(&mPad, "dpad.xml", "dpad_image.xml", -1, -1, sz, sz, LEFT,
&padEvents, &padClick, &padUp, &padOut);
}
@@ -330,11 +356,12 @@ void TouchManager::loadButtons()
const int pad2 = 2 * pad;
const int skipWidth = pad2 + sz + x;
- loadTouchItem(&mAttack, "dbutton.xml", x, y, sz, sz, RIGHT,
- nullptr, &attackClick, nullptr, nullptr);
+ loadTouchItem(&mAttack, "dbutton.xml", "dbutton_image.xml", x, y,
+ sz, sz, RIGHT, nullptr, &attackClick, nullptr, nullptr);
- loadTouchItem(&mCancel, "dbutton.xml", skipWidth, y, sz, sz, RIGHT,
- nullptr, &cancelClick, nullptr, nullptr);
+ loadTouchItem(&mCancel, "dbutton.xml", "dbutton_image.xml",
+ skipWidth, y, sz, sz, RIGHT, nullptr, &cancelClick,
+ nullptr, nullptr);
theme->unload(skin);
}
diff --git a/src/touchmanager.h b/src/touchmanager.h
index cad10f3c6..c9f018b7f 100644
--- a/src/touchmanager.h
+++ b/src/touchmanager.h
@@ -47,12 +47,13 @@ const int actionsSize = Input::KEY_TOTAL;
struct TouchItem final
{
TouchItem(const gcn::Rectangle rect0, int type0, ImageRect *const images0,
- int x0, int y0, int width0, int height0,
+ Image *const icon0, int x0, int y0, int width0, int height0,
TouchFuncPtr ptrAll, TouchFuncPtr ptrPressed,
TouchFuncPtr ptrReleased, TouchFuncPtr ptrOut) :
rect(rect0),
type(type0),
images(images0),
+ icon(icon0),
x(x0),
y(y0),
width(width0),
@@ -69,6 +70,7 @@ struct TouchItem final
gcn::Rectangle rect;
int type;
ImageRect *images;
+ Image *icon;
int x;
int y;
int width;
@@ -102,6 +104,7 @@ class TouchManager final : public ConfigListener
void init();
void loadTouchItem(TouchItem **item, std::string name,
+ std::string imageName,
int type, int x, int y, int width, int height,
TouchFuncPtr fAll, TouchFuncPtr fPressed,
TouchFuncPtr fReleased, TouchFuncPtr fOut);