summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-07-31 00:29:22 +0300
committerAndrei Karas <akaras@inbox.ru>2012-07-31 00:29:22 +0300
commit8cc6679b676103c7c6696947ea43ad439e9754c5 (patch)
treea3cf0f7d9e8eede421956942b4c325e191a9eb31 /src/gui
parent793bcbe5d8308c8c33419f67378df9dc83462445 (diff)
downloadmanaplus-8cc6679b676103c7c6696947ea43ad439e9754c5.tar.gz
manaplus-8cc6679b676103c7c6696947ea43ad439e9754c5.tar.bz2
manaplus-8cc6679b676103c7c6696947ea43ad439e9754c5.tar.xz
manaplus-8cc6679b676103c7c6696947ea43ad439e9754c5.zip
Add theme option to show hide opaque background for some windows.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/inventorywindow.cpp3
-rw-r--r--src/gui/questswindow.cpp8
-rw-r--r--src/gui/widgets/playerbox.cpp29
-rw-r--r--src/gui/widgets/playerbox.h3
-rw-r--r--src/gui/widgets/window.cpp7
-rw-r--r--src/gui/widgets/window.h2
6 files changed, 40 insertions, 12 deletions
diff --git a/src/gui/inventorywindow.cpp b/src/gui/inventorywindow.cpp
index e4a318d69..b448ef80d 100644
--- a/src/gui/inventorywindow.cpp
+++ b/src/gui/inventorywindow.cpp
@@ -135,7 +135,8 @@ InventoryWindow::InventoryWindow(Inventory *inventory):
mItems = new ItemContainer(mInventory);
mItems->addSelectionListener(this);
- gcn::ScrollArea *invenScroll = new ScrollArea(mItems);
+ gcn::ScrollArea *invenScroll = new ScrollArea(
+ mItems, getOptionBool("showbackground"));
invenScroll->setHorizontalScrollPolicy(gcn::ScrollArea::SHOW_NEVER);
mSlotsLabel = new Label(_("Slots:"));
diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp
index a33de32b6..fdda10562 100644
--- a/src/gui/questswindow.cpp
+++ b/src/gui/questswindow.cpp
@@ -82,12 +82,14 @@ class QuestsModel : public ExtendedNamesModel
};
QuestsWindow::QuestsWindow() :
- Window(_("Quests"), false, nullptr, "quest.xml"),
+ Window(_("Quests"), false, nullptr, "quests.xml"),
mQuestsModel(new QuestsModel),
mQuestsListBox(new ExtendedListBox(mQuestsModel)),
- mQuestScrollArea(new ScrollArea(mQuestsListBox)),
+ mQuestScrollArea(new ScrollArea(mQuestsListBox,
+ getOptionBool("showlistbackground"))),
mText(new BrowserBox(BrowserBox::AUTO_WRAP)),
- mTextScrollArea(new ScrollArea(mText)),
+ mTextScrollArea(new ScrollArea(mText,
+ getOptionBool("showtextbackground"))),
mCloseButton(new Button(_("Close"), "close", this)),
mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml")),
mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml"))
diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp
index f0a6a5e89..423f26563 100644
--- a/src/gui/widgets/playerbox.cpp
+++ b/src/gui/widgets/playerbox.cpp
@@ -38,14 +38,18 @@
PlayerBox::PlayerBox(Being *being, std::string skin):
mBeing(being),
- mAlpha(1.0)
+ mAlpha(1.0),
+ mSkin(nullptr),
+ mDrawBackground(false)
{
init(skin);
}
PlayerBox::PlayerBox(std::string skin):
mBeing(nullptr),
- mAlpha(1.0)
+ mAlpha(1.0),
+ mSkin(nullptr),
+ mDrawBackground(false)
{
init(skin);
}
@@ -53,7 +57,10 @@ PlayerBox::PlayerBox(std::string skin):
PlayerBox::~PlayerBox()
{
if (Theme::instance())
+ {
+ Theme::instance()->unload(mSkin);
Theme::instance()->unloadRect(mBackground);
+ }
mBeing = nullptr;
}
@@ -66,7 +73,9 @@ void PlayerBox::init(std::string skin)
{
if (skin.empty())
skin = "playerbox_background.xml";
- Theme::instance()->loadRect(mBackground, skin);
+ mSkin = Theme::instance()->loadSkinRect(mBackground, skin);
+ if (mSkin)
+ mDrawBackground = (mSkin->getOption("drawbackground") != 0);
}
else
{
@@ -98,10 +107,14 @@ void PlayerBox::draw(gcn::Graphics *graphics)
void PlayerBox::drawFrame(gcn::Graphics *graphics)
{
- int w, h, bs;
- bs = getFrameSize();
- w = getWidth() + bs * 2;
- h = getHeight() + bs * 2;
+ if (mDrawBackground)
+ {
+ int w, h, bs;
+ bs = getFrameSize();
+ w = getWidth() + bs * 2;
+ h = getHeight() + bs * 2;
- static_cast<Graphics*>(graphics)->drawImageRect(0, 0, w, h, mBackground);
+ static_cast<Graphics*>(graphics)->drawImageRect(
+ 0, 0, w, h, mBackground);
+ }
}
diff --git a/src/gui/widgets/playerbox.h b/src/gui/widgets/playerbox.h
index 6498e69ec..4f413f23c 100644
--- a/src/gui/widgets/playerbox.h
+++ b/src/gui/widgets/playerbox.h
@@ -31,6 +31,7 @@
class Being;
class ImageRect;
+class Skin;
/**
* A box showing a player character.
@@ -81,6 +82,8 @@ class PlayerBox : public gcn::ScrollArea
float mAlpha;
ImageRect mBackground;
+ Skin *mSkin;
+ bool mDrawBackground;
};
#endif
diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp
index f84376f2d..3fb0649c2 100644
--- a/src/gui/widgets/window.cpp
+++ b/src/gui/widgets/window.cpp
@@ -1029,3 +1029,10 @@ int Window::getOption(std::string name)
return mSkin->getOption(name);
return 0;
}
+
+bool Window::getOptionBool(std::string name)
+{
+ if (mSkin)
+ return mSkin->getOption(name) != 0;
+ return 0;
+}
diff --git a/src/gui/widgets/window.h b/src/gui/widgets/window.h
index ee49f2852..12c40859a 100644
--- a/src/gui/widgets/window.h
+++ b/src/gui/widgets/window.h
@@ -401,6 +401,8 @@ class Window : public gcn::Window, gcn::WidgetListener
int getOption(std::string name);
+ bool getOptionBool(std::string name);
+
protected:
bool canMove();