summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-10-09 01:36:40 +0300
committerAndrei Karas <akaras@inbox.ru>2013-10-09 01:45:28 +0300
commite153ea49f7442a82651e4e35f2be59c459ad32cb (patch)
tree8daace3c1691df379296600af4ce3ab3ba5325d0
parentb2c430f8e0fd67c6529227f8e8bebdc407ef530d (diff)
downloadmv-e153ea49f7442a82651e4e35f2be59c459ad32cb.tar.gz
mv-e153ea49f7442a82651e4e35f2be59c459ad32cb.tar.bz2
mv-e153ea49f7442a82651e4e35f2be59c459ad32cb.tar.xz
mv-e153ea49f7442a82651e4e35f2be59c459ad32cb.zip
Use all parameters in browserbox constructors.
Also load browserbox skin for each instance.
-rw-r--r--src/gui/popups/popupmenu.cpp2
-rw-r--r--src/gui/widgets/browserbox.cpp16
-rw-r--r--src/gui/widgets/browserbox.h6
-rw-r--r--src/gui/widgets/tabs/chattab.cpp2
-rw-r--r--src/gui/widgets/tabs/setup_colors.cpp2
-rw-r--r--src/gui/windows/didyouknowwindow.cpp2
-rw-r--r--src/gui/windows/helpwindow.cpp2
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/gui/windows/questswindow.cpp2
-rw-r--r--src/gui/windows/socialwindow.cpp2
-rw-r--r--src/gui/windows/updaterwindow.cpp2
-rw-r--r--src/gui/windows/whoisonline.cpp2
12 files changed, 24 insertions, 18 deletions
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index 2539ab1b8..fc4c91c8c 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -89,7 +89,7 @@ std::string tradePartnerName;
PopupMenu::PopupMenu() :
Popup("PopupMenu", "popupmenu.xml"),
- mBrowserBox(new BrowserBox(this)),
+ mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true)),
mScrollArea(nullptr),
mBeingId(0),
mFloorItemId(0),
diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp
index 6fd38e4c6..c8edf757b 100644
--- a/src/gui/widgets/browserbox.cpp
+++ b/src/gui/widgets/browserbox.cpp
@@ -44,7 +44,6 @@
#include "debug.h"
-Skin *BrowserBox::mSkin = nullptr;
ImageSet *BrowserBox::mEmotes = nullptr;
int BrowserBox::mInstances = 0;
@@ -58,6 +57,7 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode,
mLineParts(),
mLinks(),
mLinkHandler(nullptr),
+ mSkin(nullptr),
mMode(mode),
mHighMode(UNDERLINE | BACKGROUND),
mSelectedLink(-1),
@@ -84,10 +84,11 @@ BrowserBox::BrowserBox(const Widget2 *const widget, const unsigned int mode,
mBackgroundColor = getThemeColor(Theme::BACKGROUND);
+ Theme *const theme = Theme::instance();
+ if (theme)
+ mSkin = theme->load("browserbox.xml", "");
if (mInstances == 0)
{
- if (Theme::instance())
- mSkin = Theme::instance()->load("browserbox.xml", "");
mEmotes = ResourceManager::getInstance()->getImageSet(
"graphics/sprites/chatemotes.png", 17, 18);
}
@@ -130,11 +131,16 @@ BrowserBox::~BrowserBox()
if (gui)
gui->removeDragged(this);
+ Theme *const theme = Theme::instance();
+ if (theme)
+ {
+ theme->unload(mSkin);
+ mSkin = nullptr;
+ }
+
mInstances --;
if (mInstances == 0)
{
- if (Theme::instance())
- Theme::instance()->unload(mSkin);
if (mEmotes)
{
mEmotes->decRef();
diff --git a/src/gui/widgets/browserbox.h b/src/gui/widgets/browserbox.h
index 91d8233ed..f57519700 100644
--- a/src/gui/widgets/browserbox.h
+++ b/src/gui/widgets/browserbox.h
@@ -111,8 +111,8 @@ class BrowserBox final : public gcn::Widget,
* Constructor.
*/
BrowserBox(const Widget2 *const widget,
- const unsigned int mode = AUTO_SIZE,
- const bool opaque = true);
+ const unsigned int mode,
+ const bool opaque);
A_DELETE_COPY(BrowserBox)
@@ -253,6 +253,7 @@ class BrowserBox final : public gcn::Widget,
Links mLinks;
LinkHandler *mLinkHandler;
+ Skin *mSkin;
unsigned int mMode;
unsigned int mHighMode;
int mSelectedLink;
@@ -277,7 +278,6 @@ class BrowserBox final : public gcn::Widget,
bool mEnableKeys;
bool mEnableTabs;
- static Skin *mSkin;
static ImageSet *mEmotes;
static int mInstances;
};
diff --git a/src/gui/widgets/tabs/chattab.cpp b/src/gui/widgets/tabs/chattab.cpp
index b7f8a1a44..7ad6e303d 100644
--- a/src/gui/widgets/tabs/chattab.cpp
+++ b/src/gui/widgets/tabs/chattab.cpp
@@ -53,7 +53,7 @@ static const unsigned int MAX_WORD_SIZE = 50;
ChatTab::ChatTab(const Widget2 *const widget, const std::string &name,
const std::string &channel) :
Tab(widget),
- mTextOutput(new BrowserBox(this, BrowserBox::AUTO_WRAP)),
+ mTextOutput(new BrowserBox(this, BrowserBox::AUTO_WRAP, true)),
mScrollArea(new ScrollArea(mTextOutput, false)),
mChannelName(channel),
mAllowHightlight(true),
diff --git a/src/gui/widgets/tabs/setup_colors.cpp b/src/gui/widgets/tabs/setup_colors.cpp
index 19139e37f..28b6d39f6 100644
--- a/src/gui/widgets/tabs/setup_colors.cpp
+++ b/src/gui/widgets/tabs/setup_colors.cpp
@@ -50,7 +50,7 @@ Setup_Colors::Setup_Colors(const Widget2 *const widget) :
gcn::SelectionListener(),
mColorBox(new ListBox(this, userPalette, "")),
mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")),
- mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP)),
+ mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP, true)),
mTextPreview(new TextPreview(this, gettext(rawmsg))),
mPreviewBox(new ScrollArea(mPreview, true,
"setup_colors_preview_background.xml")),
diff --git a/src/gui/windows/didyouknowwindow.cpp b/src/gui/windows/didyouknowwindow.cpp
index 88c579d57..f854e58f5 100644
--- a/src/gui/windows/didyouknowwindow.cpp
+++ b/src/gui/windows/didyouknowwindow.cpp
@@ -49,7 +49,7 @@ DidYouKnowWindow::DidYouKnowWindow() :
// TRANSLATORS: did you know window name
Window(_("Did You Know?"), false, nullptr, "didyouknow.xml"),
gcn::ActionListener(),
- mBrowserBox(new BrowserBox(this)),
+ mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true)),
mScrollArea(new ScrollArea(mBrowserBox,
true, "didyouknow_background.xml")),
// TRANSLATORS: did you know window button
diff --git a/src/gui/windows/helpwindow.cpp b/src/gui/windows/helpwindow.cpp
index ae9d783fb..27632517e 100644
--- a/src/gui/windows/helpwindow.cpp
+++ b/src/gui/windows/helpwindow.cpp
@@ -51,7 +51,7 @@ HelpWindow::HelpWindow() :
gcn::ActionListener(),
// TRANSLATORS: help window. button.
mDYKButton(new Button(this, _("Did you know..."), "DYK", this)),
- mBrowserBox(new BrowserBox(this)),
+ mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true)),
mScrollArea(new ScrollArea(mBrowserBox, true, "help_background.xml")),
mTagFileMap()
{
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index a302672f7..f4cecbb88 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -84,7 +84,7 @@ NpcDialog::NpcDialog(const int npcId) :
mNpcId(npcId),
mDefaultInt(0),
mDefaultString(),
- mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP)),
+ mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP, true)),
mScrollArea(new ScrollArea(mTextBox,
getOptionBool("showtextbackground"), "npc_textbackground.xml")),
mText(),
diff --git a/src/gui/windows/questswindow.cpp b/src/gui/windows/questswindow.cpp
index 7f320c18c..ea91dd9b0 100644
--- a/src/gui/windows/questswindow.cpp
+++ b/src/gui/windows/questswindow.cpp
@@ -127,7 +127,7 @@ QuestsWindow::QuestsWindow() :
mQuestScrollArea(new ScrollArea(mQuestsListBox,
getOptionBool("showlistbackground"), "quests_list_background.xml")),
mItemLinkHandler(new ItemLinkHandler),
- mText(new BrowserBox(this, BrowserBox::AUTO_WRAP)),
+ mText(new BrowserBox(this, BrowserBox::AUTO_WRAP, true)),
mTextScrollArea(new ScrollArea(mText,
getOptionBool("showtextbackground"), "quests_text_background.xml")),
// TRANSLATORS: quests window button
diff --git a/src/gui/windows/socialwindow.cpp b/src/gui/windows/socialwindow.cpp
index 23251f427..2847c0d0f 100644
--- a/src/gui/windows/socialwindow.cpp
+++ b/src/gui/windows/socialwindow.cpp
@@ -1207,7 +1207,7 @@ public:
CreatePopup() :
Popup("SocialCreatePopup"),
LinkHandler(),
- mBrowserBox(new BrowserBox(this))
+ mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true))
{
mBrowserBox->setPosition(4, 4);
mBrowserBox->setHighlightMode(BrowserBox::BACKGROUND);
diff --git a/src/gui/windows/updaterwindow.cpp b/src/gui/windows/updaterwindow.cpp
index d025f83b6..e49d858fd 100644
--- a/src/gui/windows/updaterwindow.cpp
+++ b/src/gui/windows/updaterwindow.cpp
@@ -180,7 +180,7 @@ UpdaterWindow::UpdaterWindow(const std::string &updateHost,
// TRANSLATORS: updater window button
mPlayButton(new Button(this, _("Play"), "play", this)),
mProgressBar(new ProgressBar(this, 0.0, 310, 0)),
- mBrowserBox(new BrowserBox(this)),
+ mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true)),
mScrollArea(new ScrollArea(mBrowserBox, true, "update_background.xml")),
mUpdateServerPath(mUpdateHost)
{
diff --git a/src/gui/windows/whoisonline.cpp b/src/gui/windows/whoisonline.cpp
index 40d85f387..2b5bac534 100644
--- a/src/gui/windows/whoisonline.cpp
+++ b/src/gui/windows/whoisonline.cpp
@@ -85,7 +85,7 @@ WhoIsOnline::WhoIsOnline() :
mDownloadedBytes(0),
mMemoryBuffer(nullptr),
mCurlError(new char[CURL_ERROR_SIZE]),
- mBrowserBox(new BrowserBox(this)),
+ mBrowserBox(new BrowserBox(this, BrowserBox::AUTO_SIZE, true)),
mScrollArea(new ScrollArea(mBrowserBox, false)),
mUpdateTimer(0),
mOnlinePlayers(),