From 1361ff1aa1fd5d4b2bf1ff18d3b5bbf36b8ff734 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 15 Jul 2012 00:37:34 +0300 Subject: Change text buble theming. --- data/graphics/gui/CMakeLists.txt | 1 + data/graphics/gui/Makefile.am | 1 + data/graphics/gui/bubble.png | Bin 407 -> 390 bytes data/graphics/gui/bubble.xml | 18 ++++++++++++ src/defaults.cpp | 1 - src/text.cpp | 58 ++++++++------------------------------- src/text.h | 1 - 7 files changed, 31 insertions(+), 49 deletions(-) create mode 100644 data/graphics/gui/bubble.xml diff --git a/data/graphics/gui/CMakeLists.txt b/data/graphics/gui/CMakeLists.txt index 713c6ffd2..5fda34b34 100644 --- a/data/graphics/gui/CMakeLists.txt +++ b/data/graphics/gui/CMakeLists.txt @@ -1,5 +1,6 @@ SET (FILES bubble.png + bubble.xml button.xml button_disabled.xml button_highlighted.xml diff --git a/data/graphics/gui/Makefile.am b/data/graphics/gui/Makefile.am index 81c7da04f..f058c3bcc 100644 --- a/data/graphics/gui/Makefile.am +++ b/data/graphics/gui/Makefile.am @@ -3,6 +3,7 @@ guidir = $(pkgdatadir)/data/graphics/gui gui_DATA = \ bubble.png \ + bubble.xml \ button.xml \ button_disabled.xml \ button_highlighted.xml \ diff --git a/data/graphics/gui/bubble.png b/data/graphics/gui/bubble.png index 45322eb2e..72ef7ca6a 100644 Binary files a/data/graphics/gui/bubble.png and b/data/graphics/gui/bubble.png differ diff --git a/data/graphics/gui/bubble.xml b/data/graphics/gui/bubble.xml new file mode 100644 index 000000000..916428182 --- /dev/null +++ b/data/graphics/gui/bubble.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/defaults.cpp b/src/defaults.cpp index 13ed6f7c1..d2265c501 100644 --- a/src/defaults.cpp +++ b/src/defaults.cpp @@ -71,7 +71,6 @@ DefaultsData* getConfigDefaults() DefaultsData* configData = new DefaultsData; // Init main config defaults AddDEF(configData, "OverlayDetail", 2); - AddDEF(configData, "speechBubblecolor", "000000"); AddDEF(configData, "speechBubbleAlpha", 1.0f); AddDEF(configData, "MostUsedServerName0", "server.themanaworld.org"); AddDEF(configData, "visiblenames", true); diff --git a/src/text.cpp b/src/text.cpp index 085441d22..6e08a048a 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -41,7 +41,6 @@ int Text::mInstances = 0; ImageRect Text::mBubble; -Image *Text::mBubbleArrow; Text::Text(const std::string &text, int x, int y, gcn::Graphics::Alignment alignment, @@ -59,37 +58,22 @@ Text::Text(const std::string &text, int x, int y, if (!textManager) { textManager = new TextManager; - Image *sbImage = Theme::getImageFromTheme("bubble.png|W:#" - + config.getStringValue("speechBubblecolor")); - if (sbImage) + if (Theme::instance()) { - mBubble.grid[0] = sbImage->getSubImage(0, 0, 5, 5); - mBubble.grid[1] = sbImage->getSubImage(5, 0, 5, 5); - mBubble.grid[2] = sbImage->getSubImage(10, 0, 5, 5); - mBubble.grid[3] = sbImage->getSubImage(0, 5, 5, 5); - mBubble.grid[4] = sbImage->getSubImage(5, 5, 5, 5); - mBubble.grid[5] = sbImage->getSubImage(10, 5, 5, 5); - mBubble.grid[6] = sbImage->getSubImage(0, 10, 5, 5); - mBubble.grid[7] = sbImage->getSubImage(5, 10, 5, 5); - mBubble.grid[8] = sbImage->getSubImage(10, 10, 5, 5); - mBubbleArrow = sbImage->getSubImage(0, 15, 15, 10); + Theme::instance()->loadRect(mBubble, "bubble.xml"); } else { for (int f = 0; f < 9; f ++) mBubble.grid[f] = nullptr; - mBubbleArrow = nullptr; } + const float bubbleAlpha = config.getFloatValue("speechBubbleAlpha"); for (int i = 0; i < 9; i++) { if (mBubble.grid[i]) mBubble.grid[i]->setAlpha(bubbleAlpha); } - if (mBubbleArrow) - mBubbleArrow->setAlpha(bubbleAlpha); - if (sbImage) - sbImage->decRef(); } ++mInstances; mHeight = mFont->getHeight(); @@ -123,26 +107,14 @@ Text::~Text() { delete textManager; textManager = nullptr; - delete mBubble.grid[0]; - mBubble.grid[0] = nullptr; - delete mBubble.grid[1]; - mBubble.grid[1] = nullptr; - delete mBubble.grid[2]; - mBubble.grid[2] = nullptr; - delete mBubble.grid[3]; - mBubble.grid[3] = nullptr; - delete mBubble.grid[4]; - mBubble.grid[4] = nullptr; - delete mBubble.grid[5]; - mBubble.grid[5] = nullptr; - delete mBubble.grid[6]; - mBubble.grid[6] = nullptr; - delete mBubble.grid[7]; - mBubble.grid[7] = nullptr; - delete mBubble.grid[8]; - mBubble.grid[8] = nullptr; - delete mBubbleArrow; - mBubbleArrow = nullptr; + for (int f = 0; f < 9; f ++) + { + if (mBubble.grid[f]) + { + mBubble.grid[f]->decRef(); + mBubble.grid[f] = nullptr; + } + } } } @@ -164,14 +136,6 @@ void Text::draw(gcn::Graphics *graphics, int xOff, int yOff) static_cast(graphics)->drawImageRect( mX - xOff - 5, mY - yOff - 5, mWidth + 10, mHeight + 10, mBubble); - /* - if (mWidth >= 15) - { - static_cast(graphics)->drawImage( - mBubbleArrow, mX - xOff - 7 + mWidth / 2, - mY - yOff + mHeight + 4); - } - */ } TextRenderer::renderText(graphics, mText, diff --git a/src/text.h b/src/text.h index d7d6f0cdd..f585cca36 100644 --- a/src/text.h +++ b/src/text.h @@ -81,7 +81,6 @@ class Text protected: static ImageRect mBubble; /**< Speech bubble graphic */ - static Image *mBubbleArrow; /**< Speech bubble arrow graphic */ }; class FlashText : public Text -- cgit v1.2.3-70-g09d2