summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-03-16 15:41:51 +0300
committerAndrei Karas <akaras@inbox.ru>2014-03-16 15:41:51 +0300
commit1b75e974088a94cd28d7a48729545904b2cd908b (patch)
treed771752fd0da4c58c8ff2d941c47274ead984e42
parent46087564d4184b28740b0c45c1bac199ab1942ec (diff)
downloadplus-1b75e974088a94cd28d7a48729545904b2cd908b.tar.gz
plus-1b75e974088a94cd28d7a48729545904b2cd908b.tar.bz2
plus-1b75e974088a94cd28d7a48729545904b2cd908b.tar.xz
plus-1b75e974088a94cd28d7a48729545904b2cd908b.zip
Remove some useless static methods from theme.
-rw-r--r--src/being/being.cpp8
-rw-r--r--src/being/localplayer.cpp2
-rw-r--r--src/game.cpp4
-rw-r--r--src/gui/gui.cpp4
-rw-r--r--src/gui/popups/speechbubble.h4
-rw-r--r--src/gui/theme.h22
-rw-r--r--src/gui/widgets/textpreview.cpp2
-rw-r--r--src/gui/widgets/widget2.h8
-rw-r--r--src/gui/windows/inventorywindow.cpp8
-rw-r--r--src/gui/windows/ministatuswindow.cpp13
-rw-r--r--src/gui/windows/statuswindow.cpp37
-rw-r--r--src/gui/windows/statuswindow.h6
-rw-r--r--src/particle/textparticle.cpp2
-rw-r--r--src/text.cpp2
-rw-r--r--src/touchmanager.cpp4
15 files changed, 53 insertions, 73 deletions
diff --git a/src/being/being.cpp b/src/being/being.cpp
index 41c3bc40c..611263dff 100644
--- a/src/being/being.cpp
+++ b/src/being/being.cpp
@@ -1710,8 +1710,8 @@ void Being::drawSpeech(const int offsetX, const int offsetY)
if (!mText && userPalette)
{
mText = new Text(mSpeech, getPixelX(), getPixelY() - getHeight(),
- Graphics::CENTER, &Theme::getThemeColor(
- Theme::BUBBLE_TEXT), true);
+ Graphics::CENTER, &theme->getColor(
+ Theme::BUBBLE_TEXT, 255), true);
}
}
else if (speech == NO_SPEECH)
@@ -1901,11 +1901,11 @@ void Being::updateColors()
else if (this == player_node)
{
mNameColor = &userPalette->getColor(UserPalette::SELF);
- mTextColor = &Theme::getThemeColor(Theme::PLAYER);
+ mTextColor = &theme->getColor(Theme::PLAYER, 255);
}
else
{
- mTextColor = &Theme::getThemeColor(Theme::PLAYER);
+ mTextColor = &theme->getColor(Theme::PLAYER, 255);
if (player_relations.getRelation(mName) != PlayerRelation::ERASED)
mErased = false;
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp
index 889f2b906..55e7baca9 100644
--- a/src/being/localplayer.cpp
+++ b/src/being/localplayer.cpp
@@ -178,7 +178,7 @@ LocalPlayer::LocalPlayer(const int id, const int subtype) :
mAttackRange = 0;
mLevel = 1;
mAdvanced = true;
- mTextColor = &Theme::getThemeColor(Theme::PLAYER);
+ mTextColor = &theme->getColor(Theme::PLAYER, 255);
if (userPalette)
mNameColor = &userPalette->getColor(UserPalette::SELF);
else
diff --git a/src/game.cpp b/src/game.cpp
index e30b7222e..c1e2a757d 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -484,8 +484,8 @@ void Game::addWatermark()
{
if (!boldFont || !config.getBoolValue("addwatermark"))
return;
- mainGraphics->setColorAll(Theme::getThemeColor(Theme::TEXT),
- Theme::getThemeColor(Theme::TEXT_OUTLINE));
+ mainGraphics->setColorAll(theme->getColor(Theme::TEXT, 255),
+ theme->getColor(Theme::TEXT_OUTLINE, 255));
boldFont->drawString(mainGraphics, client->getServerName(), 100, 50);
}
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp
index b17ae3ba8..3805b3968 100644
--- a/src/gui/gui.cpp
+++ b/src/gui/gui.cpp
@@ -162,8 +162,8 @@ Gui::Gui() :
mLastMouseRealY(0),
#endif
mFocusListeners(),
- mForegroundColor(Theme::getThemeColor(Theme::TEXT)),
- mForegroundColor2(Theme::getThemeColor(Theme::TEXT_OUTLINE)),
+ mForegroundColor(theme->getColor(Theme::TEXT, 255)),
+ mForegroundColor2(theme->getColor(Theme::TEXT_OUTLINE, 255)),
mTime(0),
mCustomCursor(false),
mDoubleClick(true)
diff --git a/src/gui/popups/speechbubble.h b/src/gui/popups/speechbubble.h
index 1bc5385a4..fe5cf1bfc 100644
--- a/src/gui/popups/speechbubble.h
+++ b/src/gui/popups/speechbubble.h
@@ -48,9 +48,9 @@ class SpeechBubble final : public Popup
*/
void setCaption(const std::string &name,
const Color *const color1 =
- &Theme::getThemeColor(Theme::BUBBLE_NAME),
+ &theme->getColor(Theme::BUBBLE_NAME, 255),
const Color *const color2 =
- &Theme::getThemeColor(Theme::BUBBLE_NAME_OUTLINE));
+ &theme->getColor(Theme::BUBBLE_NAME_OUTLINE, 255));
/**
* Sets the text to be displayed.
diff --git a/src/gui/theme.h b/src/gui/theme.h
index 5f902e206..c0933f035 100644
--- a/src/gui/theme.h
+++ b/src/gui/theme.h
@@ -444,28 +444,6 @@ class Theme final : public Palette, public ConfigListener
THEME_PROG_END
};
- /**
- * Gets the color associated with the type. Sets the alpha channel
- * before returning.
- *
- * @param type the color type requested
- * @param alpha alpha channel to use
- *
- * @return the requested color
- */
- inline static const Color &getThemeColor(const int type,
- const int alpha = 255)
- A_WARN_UNUSED
- { return theme->getColor(type, alpha); }
-
- static const Color &getThemeCharColor(const signed char c,
- bool &valid) A_WARN_UNUSED
- { return theme->getCharColor(c, valid); }
-
- static int getThemeIdByChar(const signed char c,
- bool &valid) A_WARN_UNUSED
- { return theme->getIdByChar(c, valid); }
-
static Color getProgressColor(const int type,
const float progress) A_WARN_UNUSED;
diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp
index 45e71b800..ff0a647b8 100644
--- a/src/gui/widgets/textpreview.cpp
+++ b/src/gui/widgets/textpreview.cpp
@@ -116,7 +116,7 @@ void TextPreview::draw(Graphics* graphics)
Color(mTextColor2->r, mTextColor2->g, mTextColor2->b, alpha));
if (mOutline && mTextColor != mTextColor2)
- graphics->setColor2(Theme::getThemeColor(Theme::OUTLINE));
+ graphics->setColor2(getThemeColor(Theme::OUTLINE, 255));
mFont->drawString(graphics, mText, mPadding + 1, mPadding + 1);
BLOCK_END("TextPreview::draw")
diff --git a/src/gui/widgets/widget2.h b/src/gui/widgets/widget2.h
index ff565815f..2d73418ba 100644
--- a/src/gui/widgets/widget2.h
+++ b/src/gui/widgets/widget2.h
@@ -36,16 +36,18 @@ class Widget2
const int alpha = 255)
const A_WARN_UNUSED
{
- return Theme::getThemeColor(mPaletteOffset + type, alpha);
+ return theme->getColor(mPaletteOffset + type, alpha);
}
inline const Color &getThemeCharColor(const signed char c,
bool &valid)
const A_WARN_UNUSED
{
- const int colorId = Theme::getThemeIdByChar(c, valid);
+ if (!theme)
+ return Palette::BLACK;
+ const int colorId = theme->getIdByChar(c, valid);;
if (valid)
- return Theme::getThemeColor(mPaletteOffset + colorId);
+ return theme->getColor(mPaletteOffset + colorId, 255);
else
return Palette::BLACK;
}
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 92b21dfd1..b9bdf6ad9 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -98,8 +98,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mCompactMode(false)
{
mTextPopup->postInit();
- mSlotsBar->setColor(Theme::getThemeColor(Theme::SLOTS_BAR),
- Theme::getThemeColor(Theme::SLOTS_BAR_OUTLINE));
+ mSlotsBar->setColor(getThemeColor(Theme::SLOTS_BAR),
+ getThemeColor(Theme::SLOTS_BAR_OUTLINE));
if (inventory)
{
@@ -194,8 +194,8 @@ InventoryWindow::InventoryWindow(Inventory *const inventory):
mEquipmentButton = new Button(this, _("Equipment"), "equipment", this);
mWeightBar = new ProgressBar(this, 0.0F, 100, 0, Theme::PROG_WEIGHT,
"weightprogressbar.xml", "weightprogressbar_fill.xml");
- mWeightBar->setColor(Theme::getThemeColor(Theme::WEIGHT_BAR),
- Theme::getThemeColor(Theme::WEIGHT_BAR_OUTLINE));
+ mWeightBar->setColor(getThemeColor(Theme::WEIGHT_BAR),
+ getThemeColor(Theme::WEIGHT_BAR_OUTLINE));
place(0, 0, mWeightBar, 4);
mSlotsBarCell = &place(4, 0, mSlotsBar, 5);
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 226132652..939bfb619 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -114,8 +114,8 @@ MiniStatusWindow::MiniStatusWindow() :
StatusWindow::updateHPBar(mHpBar);
- if (Net::getGameHandler()->canUseMagicBar())
- StatusWindow::updateMPBar(mMpBar);
+ if (Net::getGameHandler()->canUseMagicBar() && statusWindow)
+ statusWindow->updateMPBar(mMpBar);
const int job = Net::getPlayerHandler()->getJobLocation()
&& serverConfig.getValueBool("showJob", true);
@@ -183,8 +183,7 @@ ProgressBar *MiniStatusWindow::createBar(const float progress,
progress, width, height, backColor, skin, skinFill);
bar->setActionEventId(name);
bar->setId(description);
- bar->setColor(Theme::getThemeColor(textColor),
- Theme::getThemeColor(textColor + 1));
+ bar->setColor(getThemeColor(textColor), getThemeColor(textColor + 1));
mBars.push_back(bar);
mBarNames[name] = bar;
return bar;
@@ -264,7 +263,7 @@ void MiniStatusWindow::processEvent(const Channels channel A_UNUSED,
}
else if (id == PlayerInfo::MP || id == PlayerInfo::MAX_MP)
{
- StatusWindow::updateMPBar(mMpBar);
+ statusWindow->updateMPBar(mMpBar);
}
else if (id == PlayerInfo::EXP || id == PlayerInfo::EXP_NEEDED)
{
@@ -282,14 +281,14 @@ void MiniStatusWindow::processEvent(const Channels channel A_UNUSED,
}
else if (event.getName() == EVENT_UPDATESTAT)
{
- StatusWindow::updateMPBar(mMpBar);
+ statusWindow->updateMPBar(mMpBar);
StatusWindow::updateJobBar(mJobBar);
}
}
void MiniStatusWindow::updateStatus()
{
- StatusWindow::updateStatusBar(mStatusBar);
+ statusWindow->updateStatusBar(mStatusBar);
if (mStatusPopup && mStatusPopup->isPopupVisible())
mStatusPopup->update();
}
diff --git a/src/gui/windows/statuswindow.cpp b/src/gui/windows/statuswindow.cpp
index 05172c9b3..7fb4496cc 100644
--- a/src/gui/windows/statuswindow.cpp
+++ b/src/gui/windows/statuswindow.cpp
@@ -193,16 +193,16 @@ StatusWindow::StatusWindow() :
mHpBar = new ProgressBar(this, static_cast<float>(PlayerInfo::getAttribute(
PlayerInfo::HP)) / static_cast<float>(max), 80, 0, Theme::PROG_HP,
"hpprogressbar.xml", "hpprogressbar_fill.xml");
- mHpBar->setColor(Theme::getThemeColor(Theme::HP_BAR),
- Theme::getThemeColor(Theme::HP_BAR_OUTLINE));
+ mHpBar->setColor(getThemeColor(Theme::HP_BAR),
+ getThemeColor(Theme::HP_BAR_OUTLINE));
max = PlayerInfo::getAttribute(PlayerInfo::EXP_NEEDED);
mXpBar = new ProgressBar(this, max ?
static_cast<float>(PlayerInfo::getAttribute(PlayerInfo::EXP))
/ static_cast<float>(max) : static_cast<float>(0), 80, 0,
Theme::PROG_EXP, "xpprogressbar.xml", "xpprogressbar_fill.xml");
- mXpBar->setColor(Theme::getThemeColor(Theme::XP_BAR),
- Theme::getThemeColor(Theme::XP_BAR_OUTLINE));
+ mXpBar->setColor(getThemeColor(Theme::XP_BAR),
+ getThemeColor(Theme::XP_BAR_OUTLINE));
const bool magicBar = Net::getGameHandler()->canUseMagicBar();
const int job = Net::getPlayerHandler()->getJobLocation()
@@ -222,13 +222,13 @@ StatusWindow::StatusWindow() :
useMagic ? "mpprogressbar_fill.xml" : "nompprogressbar_fill.xml");
if (useMagic)
{
- mMpBar->setColor(Theme::getThemeColor(Theme::MP_BAR),
- Theme::getThemeColor(Theme::MP_BAR_OUTLINE));
+ mMpBar->setColor(getThemeColor(Theme::MP_BAR),
+ getThemeColor(Theme::MP_BAR_OUTLINE));
}
else
{
- mMpBar->setColor(Theme::getThemeColor(Theme::NO_MP_BAR),
- Theme::getThemeColor(Theme::NO_MP_BAR_OUTLINE));
+ mMpBar->setColor(getThemeColor(Theme::NO_MP_BAR),
+ getThemeColor(Theme::NO_MP_BAR_OUTLINE));
}
}
else
@@ -260,8 +260,8 @@ StatusWindow::StatusWindow() :
mJobLabel = new Label(this, _("Job:"));
mJobBar = new ProgressBar(this, 0.0F, 80, 0, Theme::PROG_JOB,
"jobprogressbar.xml", "jobprogressbar_fill.xml");
- mJobBar->setColor(Theme::getThemeColor(Theme::JOB_BAR),
- Theme::getThemeColor(Theme::JOB_BAR_OUTLINE));
+ mJobBar->setColor(getThemeColor(Theme::JOB_BAR),
+ getThemeColor(Theme::JOB_BAR_OUTLINE));
place(3, 0, mJobLvlLabel, 3);
place(5, 2, mJobLabel).setPadding(3);
@@ -524,7 +524,8 @@ void StatusWindow::updateHPBar(ProgressBar *const bar, const bool showMax)
bar->setProgress(prog);
}
-void StatusWindow::updateMPBar(ProgressBar *const bar, const bool showMax)
+void StatusWindow::updateMPBar(ProgressBar *const bar,
+ const bool showMax) const
{
if (!bar)
return;
@@ -542,14 +543,14 @@ void StatusWindow::updateMPBar(ProgressBar *const bar, const bool showMax)
if (Net::getPlayerHandler()->canUseMagic())
{
- bar->setColor(Theme::getThemeColor(Theme::MP_BAR),
- Theme::getThemeColor(Theme::MP_BAR_OUTLINE));
+ bar->setColor(getThemeColor(Theme::MP_BAR),
+ getThemeColor(Theme::MP_BAR_OUTLINE));
bar->setProgressPalette(Theme::PROG_MP);
}
else
{
- bar->setColor(Theme::getThemeColor(Theme::NO_MP_BAR),
- Theme::getThemeColor(Theme::NO_MP_BAR_OUTLINE));
+ bar->setColor(getThemeColor(Theme::NO_MP_BAR),
+ getThemeColor(Theme::NO_MP_BAR_OUTLINE));
bar->setProgressPalette(Theme::PROG_NO_MP);
}
@@ -715,7 +716,7 @@ std::string StatusWindow::translateLetter2(std::string letters)
}
void StatusWindow::updateStatusBar(ProgressBar *const bar,
- const bool percent A_UNUSED)
+ const bool percent A_UNUSED) const
{
if (!player_node || !viewport)
return;
@@ -741,9 +742,9 @@ void StatusWindow::updateStatusBar(ProgressBar *const bar,
bar->setProgress(50);
if (player_node->getDisableGameModifiers())
- bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_ON));
+ bar->setBackgroundColor(getThemeColor(Theme::STATUSBAR_ON));
else
- bar->setBackgroundColor(Theme::getThemeColor(Theme::STATUSBAR_OFF));
+ bar->setBackgroundColor(getThemeColor(Theme::STATUSBAR_OFF));
}
void StatusWindow::action(const ActionEvent &event)
diff --git a/src/gui/windows/statuswindow.h b/src/gui/windows/statuswindow.h
index 3b171a25e..35bba74cd 100644
--- a/src/gui/windows/statuswindow.h
+++ b/src/gui/windows/statuswindow.h
@@ -66,7 +66,7 @@ class StatusWindow final : public Window,
static void updateHPBar(ProgressBar *const bar,
const bool showMax = false);
- static void updateMPBar(ProgressBar *bar, const bool showMax = false);
+ void updateMPBar(ProgressBar *bar, const bool showMax = false) const;
static void updateJobBar(ProgressBar *const bar,
const bool percent = true);
static void updateXPBar(ProgressBar *const bar,
@@ -75,8 +75,8 @@ class StatusWindow final : public Window,
static void updateInvSlotsBar(ProgressBar *const bar);
static void updateMoneyBar(ProgressBar *const bar);
static void updateArrowsBar(ProgressBar *const bar);
- static void updateStatusBar(ProgressBar *const bar,
- const bool percent = true);
+ void updateStatusBar(ProgressBar *const bar,
+ const bool percent = true) const;
static void updateProgressBar(ProgressBar *const bar, const int value,
const int max, const bool percent);
static void updateProgressBar(ProgressBar *const bar,
diff --git a/src/particle/textparticle.cpp b/src/particle/textparticle.cpp
index 41ea683f6..9d37ca73d 100644
--- a/src/particle/textparticle.cpp
+++ b/src/particle/textparticle.cpp
@@ -80,7 +80,7 @@ void TextParticle::draw(Graphics *const graphics,
graphics->setColor(color);
if (mOutline)
{
- graphics->setColor2(Theme::getThemeColor(
+ graphics->setColor2(theme->getColor(
Theme::OUTLINE, static_cast<int>(alpha)));
}
mTextFont->drawString(graphics, mText, screenX - mTextWidth, screenY);
diff --git a/src/text.cpp b/src/text.cpp
index caf5328d6..bf75e80d6 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -49,7 +49,7 @@ Text::Text(const std::string &text, const int x, const int y,
mXOffset(0),
mText(text),
mColor(color),
- mOutlineColor(Theme::getThemeColor(Theme::OUTLINE)),
+ mOutlineColor(theme->getColor(Theme::OUTLINE, 255)),
mIsSpeech(isSpeech)
{
if (!textManager)
diff --git a/src/touchmanager.cpp b/src/touchmanager.cpp
index b9681c337..58aee1d3b 100644
--- a/src/touchmanager.cpp
+++ b/src/touchmanager.cpp
@@ -242,8 +242,8 @@ void TouchManager::draw()
return;
Font *const font = boldFont;
- mainGraphics->setColorAll(Theme::getThemeColor(Theme::TEXT),
- Theme::getThemeColor(Theme::TEXT_OUTLINE));
+ mainGraphics->setColorAll(theme->getColor(Theme::TEXT, 255),
+ theme->getColor(Theme::TEXT_OUTLINE, 255));
FOR_EACH (TouchItemVectorCIter, it, mObjects)
{
const TouchItem *const item = *it;