diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-01-23 22:33:26 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-01-23 22:33:26 +0300 |
commit | c3755c31222a7cd4e90f772eb88a992dd64f6c06 (patch) | |
tree | ca0240e6b8597276a3e761d3ba18d838d8a94bc5 | |
parent | 533e703a2c394b9c4a0c0e2d7367dd5cc48c1502 (diff) | |
download | manaverse-c3755c31222a7cd4e90f772eb88a992dd64f6c06.tar.gz manaverse-c3755c31222a7cd4e90f772eb88a992dd64f6c06.tar.bz2 manaverse-c3755c31222a7cd4e90f772eb88a992dd64f6c06.tar.xz manaverse-c3755c31222a7cd4e90f772eb88a992dd64f6c06.zip |
Use in different listbox derived classes different xml skin.
-rw-r--r-- | src/gui/npcdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/questswindow.cpp | 3 | ||||
-rw-r--r-- | src/gui/serverdialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_colors.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_input.cpp | 2 | ||||
-rw-r--r-- | src/gui/setup_video.cpp | 2 | ||||
-rw-r--r-- | src/gui/skilldialog.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/extendedlistbox.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/listbox.cpp | 17 | ||||
-rw-r--r-- | src/gui/widgets/listbox.h | 7 | ||||
-rw-r--r-- | src/gui/widgets/popuplist.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/shoplistbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/worldselectdialog.cpp | 2 |
15 files changed, 28 insertions, 28 deletions
diff --git a/src/gui/npcdialog.cpp b/src/gui/npcdialog.cpp index 31b13e91f..fa4162f81 100644 --- a/src/gui/npcdialog.cpp +++ b/src/gui/npcdialog.cpp @@ -71,7 +71,7 @@ NpcDialog::NpcDialog(const int npcId) : mTextBox(new BrowserBox(this, BrowserBox::AUTO_WRAP)), mScrollArea(new ScrollArea(mTextBox, getOptionBool("showtextbackground"), "npc_textbackground.xml")), - mItemList(new ExtendedListBox(this, this)), + mItemList(new ExtendedListBox(this, this, "extendedlistbox.xml")), mListScrollArea(new ScrollArea(mItemList, getOptionBool("showlistbackground"), "npc_listbackground.xml")), mItemLinkHandler(new ItemLinkHandler), diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp index 11e93d9e9..dae8d1fca 100644 --- a/src/gui/questswindow.cpp +++ b/src/gui/questswindow.cpp @@ -98,7 +98,8 @@ QuestsWindow::QuestsWindow() : Window(_("Quests"), false, nullptr, "quests.xml"), gcn::ActionListener(), mQuestsModel(new QuestsModel), - mQuestsListBox(new ExtendedListBox(this, mQuestsModel)), + mQuestsListBox(new ExtendedListBox(this, + mQuestsModel, "extendedlistbox.xml")), mQuestScrollArea(new ScrollArea(mQuestsListBox, getOptionBool("showlistbackground"), "quests_list_background.xml")), mItemLinkHandler(new ItemLinkHandler), diff --git a/src/gui/serverdialog.cpp b/src/gui/serverdialog.cpp index e2ef3fb01..d76c5fbd3 100644 --- a/src/gui/serverdialog.cpp +++ b/src/gui/serverdialog.cpp @@ -158,7 +158,7 @@ class ServersListBox final : public ListBox public: ServersListBox(const Widget2 *const widget, ServersListModel *const model) : - ListBox(widget, model), + ListBox(widget, model, "serverslistbox.xml"), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), mNotSupportedColor(getThemeColor(Theme::SERVER_VERSION_NOT_SUPPORTED)) { diff --git a/src/gui/setup_colors.cpp b/src/gui/setup_colors.cpp index c83d5d2a8..880c9082e 100644 --- a/src/gui/setup_colors.cpp +++ b/src/gui/setup_colors.cpp @@ -50,7 +50,7 @@ const std::string Setup_Colors::rawmsg = Setup_Colors::Setup_Colors(const Widget2 *const widget) : SetupTab(widget), gcn::SelectionListener(), - mColorBox(new ListBox(this, userPalette)), + mColorBox(new ListBox(this, userPalette, "")), mScroll(new ScrollArea(mColorBox, true, "setup_colors_background.xml")), mPreview(new BrowserBox(this, BrowserBox::AUTO_WRAP)), mTextPreview(new TextPreview(this, rawmsg)), diff --git a/src/gui/setup_input.cpp b/src/gui/setup_input.cpp index 1b6a7e962..1f1823136 100644 --- a/src/gui/setup_input.cpp +++ b/src/gui/setup_input.cpp @@ -94,7 +94,7 @@ class KeyListModel final : public gcn::ListModel Setup_Input::Setup_Input(const Widget2 *const widget) : SetupTab(widget), mKeyListModel(new KeyListModel), - mKeyList(new ListBox(this, mKeyListModel)), + mKeyList(new ListBox(this, mKeyListModel, "")), mAssignKeyButton(new Button(this, _("Assign"), "assign", this)), mUnassignKeyButton(new Button(this, _("Unassign"), "unassign", this)), mDefaultButton(new Button(this, _("Default"), "default", this)), diff --git a/src/gui/setup_video.cpp b/src/gui/setup_video.cpp index db26bd2c8..3fc4a66e5 100644 --- a/src/gui/setup_video.cpp +++ b/src/gui/setup_video.cpp @@ -218,7 +218,7 @@ Setup_Video::Setup_Video(const Widget2 *const widget) : mEnableResize(config.getBoolValue("enableresize")), mNoFrame(config.getBoolValue("noframe")), mModeListModel(new ModeListModel), - mModeList(new ListBox(widget, mModeListModel)), + mModeList(new ListBox(widget, mModeListModel, "")), mFsCheckBox(new CheckBox(this, _("Full screen"), mFullScreenEnabled)), mCustomCursorCheckBox(new CheckBox(this, #ifdef ANDROID diff --git a/src/gui/skilldialog.cpp b/src/gui/skilldialog.cpp index 6a47a425d..3f5a00e61 100644 --- a/src/gui/skilldialog.cpp +++ b/src/gui/skilldialog.cpp @@ -94,7 +94,7 @@ class SkillListBox final : public ListBox { public: SkillListBox(const Widget2 *const widget, SkillModel *const model) : - ListBox(widget, model), + ListBox(widget, model, "skilllistbox.xml"), mModel(model), mPopup(new TextPopup), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index c28b13753..92a6443be 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -45,7 +45,7 @@ Image *AvatarListBox::offlineIcon = nullptr; AvatarListBox::AvatarListBox(const Widget2 *const widget, AvatarListModel *const model) : - ListBox(widget, model), + ListBox(widget, model, "avatarlistbox.xml"), mShowGender(config.getBoolValue("showgender")), mShowLevel(config.getBoolValue("showlevel")), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)) diff --git a/src/gui/widgets/extendedlistbox.cpp b/src/gui/widgets/extendedlistbox.cpp index 34f4f1a45..d83a2a1ba 100644 --- a/src/gui/widgets/extendedlistbox.cpp +++ b/src/gui/widgets/extendedlistbox.cpp @@ -38,8 +38,9 @@ ExtendedListBox::ExtendedListBox(const Widget2 *const widget, gcn::ListModel *const listModel, + const std::string &skin, int rowHeight) : - ListBox(widget, listModel), + ListBox(widget, listModel, skin), mRowHeight(rowHeight), mImagePadding(mSkin ? mSkin->getOption("imagePadding") : 0), mSpacing(mSkin ? mSkin->getOption("spacing") : 0), diff --git a/src/gui/widgets/extendedlistbox.h b/src/gui/widgets/extendedlistbox.h index 9da77abe7..c5fca2e4c 100644 --- a/src/gui/widgets/extendedlistbox.h +++ b/src/gui/widgets/extendedlistbox.h @@ -31,6 +31,7 @@ class ExtendedListBox final : public ListBox */ ExtendedListBox(const Widget2 *const widget, gcn::ListModel *const listModel, + const std::string &skin, int rowHeight = 13); A_DELETE_COPY(ExtendedListBox) diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index 9eb5f23a2..b89fc9688 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -38,11 +38,10 @@ #include "debug.h" float ListBox::mAlpha = 1.0; -Skin *ListBox::mSkin = nullptr; -int ListBox::mInstances = 0; ListBox::ListBox(const Widget2 *const widget, - gcn::ListModel *const listModel) : + gcn::ListModel *const listModel, + const std::string &skin) : gcn::ListBox(listModel), Widget2(widget), mHighlightColor(getThemeColor(Theme::HIGHLIGHT)), @@ -53,12 +52,9 @@ ListBox::ListBox(const Widget2 *const widget, { mForegroundColor = getThemeColor(Theme::LISTBOX); - if (mInstances == 0) - { - if (Theme::instance()) - mSkin = Theme::instance()->load("listbox.xml", ""); - } - mInstances ++; + Theme *const theme = Theme::instance(); + if (theme) + mSkin = Theme::instance()->load(skin, "listbox.xml"); if (mSkin) mPadding = mSkin->getPadding(); @@ -68,8 +64,7 @@ ListBox::ListBox(const Widget2 *const widget, ListBox::~ListBox() { - mInstances --; - if (mInstances == 0 && Theme::instance()) + if (Theme::instance()) Theme::instance()->unload(mSkin); } diff --git a/src/gui/widgets/listbox.h b/src/gui/widgets/listbox.h index 21f6b00b0..8296d90e4 100644 --- a/src/gui/widgets/listbox.h +++ b/src/gui/widgets/listbox.h @@ -46,7 +46,9 @@ class ListBox : public gcn::ListBox, /** * Constructor. */ - ListBox(const Widget2 *const widget, gcn::ListModel *const listModel); + ListBox(const Widget2 *const widget, + gcn::ListModel *const listModel, + const std::string &skin); A_DELETE_COPY(ListBox) @@ -94,8 +96,7 @@ class ListBox : public gcn::ListBox, int mOldSelected; int mPadding; static float mAlpha; - static Skin *mSkin; - static int mInstances; + Skin *mSkin; }; #endif diff --git a/src/gui/widgets/popuplist.cpp b/src/gui/widgets/popuplist.cpp index ca9ef2c7d..ccd186197 100644 --- a/src/gui/widgets/popuplist.cpp +++ b/src/gui/widgets/popuplist.cpp @@ -36,8 +36,9 @@ PopupList::PopupList(DropDown *const widget, Popup("PopupList", "popuplist.xml"), gcn::FocusListener(), mListModel(listModel), - mListBox(extended ? new ExtendedListBox(widget, listModel, 0) : - new ListBox(widget, listModel)), + mListBox(extended ? new ExtendedListBox( + widget, listModel, "extendedlistbox.xml", 0) : + new ListBox(widget, listModel, "popuplistbox.xml")), mScrollArea(new ScrollArea(mListBox, false)), mDropDown(widget), mModal(modal) diff --git a/src/gui/widgets/shoplistbox.cpp b/src/gui/widgets/shoplistbox.cpp index 4c0738374..5aa91a2c9 100644 --- a/src/gui/widgets/shoplistbox.cpp +++ b/src/gui/widgets/shoplistbox.cpp @@ -44,7 +44,7 @@ float ShopListBox::mAlpha = 1.0; ShopListBox::ShopListBox(const Widget2 *const widget, gcn::ListModel *const listModel) : - ListBox(widget, listModel), + ListBox(widget, listModel, "shoplisbox.xml"), mPlayerMoney(0), mShopItems(nullptr), mItemPopup(new ItemPopup), @@ -60,7 +60,7 @@ ShopListBox::ShopListBox(const Widget2 *const widget, ShopListBox::ShopListBox(const Widget2 *const widget, gcn::ListModel *const listModel, ShopItems *const shopListModel) : - ListBox(widget, listModel), + ListBox(widget, listModel, "shoplisbox.xml"), mPlayerMoney(0), mShopItems(shopListModel), mItemPopup(new ItemPopup), diff --git a/src/gui/worldselectdialog.cpp b/src/gui/worldselectdialog.cpp index 619457b70..51d61fa9c 100644 --- a/src/gui/worldselectdialog.cpp +++ b/src/gui/worldselectdialog.cpp @@ -81,7 +81,7 @@ WorldSelectDialog::WorldSelectDialog(Worlds worlds): gcn::ActionListener(), gcn::KeyListener(), mWorldListModel(new WorldListModel(worlds)), - mWorldList(new ListBox(this, mWorldListModel)), + mWorldList(new ListBox(this, mWorldListModel, "")), mChangeLoginButton(new Button(this, _("Change Login"), "login", this)), mChooseWorld(new Button(this, _("Choose World"), "world", this)) { |