diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-08-03 02:11:25 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-08-04 23:57:02 +0300 |
commit | 0647852f65598ef9cb9ebff6dfb508e8b1a98c1c (patch) | |
tree | 4cc9395e820e60f3d511351b78fe187e897a8c7e /src | |
parent | c52472123eb7847b5cee6b1898c42ef25a5466dd (diff) | |
download | plus-0647852f65598ef9cb9ebff6dfb508e8b1a98c1c.tar.gz plus-0647852f65598ef9cb9ebff6dfb508e8b1a98c1c.tar.bz2 plus-0647852f65598ef9cb9ebff6dfb508e8b1a98c1c.tar.xz plus-0647852f65598ef9cb9ebff6dfb508e8b1a98c1c.zip |
Add support for default theme file names.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/questswindow.cpp | 6 | ||||
-rw-r--r-- | src/gui/theme.cpp | 26 | ||||
-rw-r--r-- | src/gui/theme.h | 13 | ||||
-rw-r--r-- | src/gui/widgets/avatarlistbox.cpp | 4 | ||||
-rw-r--r-- | src/gui/widgets/button.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/checkbox.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/dropdown.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/dropshortcutcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/emoteshortcutcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/itemshortcutcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/playerbox.cpp | 3 | ||||
-rw-r--r-- | src/gui/widgets/popup.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/progressbar.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/radiobutton.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/resizegrip.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/scrollarea.cpp | 10 | ||||
-rw-r--r-- | src/gui/widgets/slider.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/spellshortcutcontainer.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/tab.cpp | 5 | ||||
-rw-r--r-- | src/gui/widgets/textfield.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/window.cpp | 2 | ||||
-rw-r--r-- | src/text.cpp | 2 |
23 files changed, 69 insertions, 42 deletions
diff --git a/src/gui/questswindow.cpp b/src/gui/questswindow.cpp index 5ffdf45c5..8969c51e8 100644 --- a/src/gui/questswindow.cpp +++ b/src/gui/questswindow.cpp @@ -93,8 +93,8 @@ QuestsWindow::QuestsWindow() : mTextScrollArea(new ScrollArea(mText, getOptionBool("showtextbackground"))), mCloseButton(new Button(_("Close"), "close", this)), - mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml")), - mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml")) + mCompleteIcon(Theme::getImageFromThemeXml("complete_icon.xml", "")), + mIncompleteIcon(Theme::getImageFromThemeXml("incomplete_icon.xml", "")) { setWindowName("Quests"); setResizable(true); @@ -148,6 +148,8 @@ QuestsWindow::~QuestsWindow() delete *it2; } } + delete mItemLinkHandler; + mItemLinkHandler = nullptr; mQuests.clear(); mQuestLinks.clear(); if (mCompleteIcon) diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 2ea8ba840..44de72cdc 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -230,8 +230,8 @@ gcn::Color Theme::getProgressColor(int type, float progress) return gcn::Color(color[0], color[1], color[2]); } -Skin *Theme::load(const std::string &filename, bool full, - const std::string &defaultPath) +Skin *Theme::load(const std::string &filename, const std::string &filename2, + bool full, const std::string &defaultPath) { // Check if this skin was already loaded @@ -245,7 +245,10 @@ Skin *Theme::load(const std::string &filename, bool full, Skin *skin = readSkin(filename, full); - if (!skin && filename != "window.xml") + if (!skin && !filename2.empty() && filename2 != filename) + skin = readSkin(filename2, full); + + if (!skin && filename2 != "window.xml") skin = readSkin("window.xml", full); if (!skin) @@ -873,9 +876,10 @@ void Theme::loadColors(std::string file) } } -void Theme::loadRect(ImageRect &image, std::string name, int start, int end) +void Theme::loadRect(ImageRect &image, std::string name, std::string name2, + int start, int end) { - Skin *skin = load(name, false); + Skin *skin = load(name, name2, false); if (skin) { const ImageRect &rect = skin->getBorder(); @@ -892,9 +896,9 @@ void Theme::loadRect(ImageRect &image, std::string name, int start, int end) } Skin *Theme::loadSkinRect(ImageRect &image, std::string name, - int start, int end) + std::string name2, int start, int end) { - Skin *skin = load(name); + Skin *skin = load(name, name2); if (skin) { const ImageRect &rect = skin->getBorder(); @@ -919,10 +923,11 @@ void Theme::unloadRect(ImageRect &rect, int start, int end) } } -Image *Theme::getImageFromThemeXml(const std::string &name) +Image *Theme::getImageFromThemeXml(const std::string &name, + const std::string &name2) { Theme *theme = Theme::instance(); - Skin *skin = theme->load(name, false); + Skin *skin = theme->load(name, name2, false); if (skin) { const ImageRect &rect = skin->getBorder(); @@ -939,10 +944,11 @@ Image *Theme::getImageFromThemeXml(const std::string &name) } ImageSet *Theme::getImageSetFromThemeXml(const std::string &name, + const std::string &name2, int w, int h) { Theme *theme = Theme::instance(); - Skin *skin = theme->load(name, false); + Skin *skin = theme->load(name, name2, false); if (skin) { const ImageRect &rect = skin->getBorder(); diff --git a/src/gui/theme.h b/src/gui/theme.h index 216b19802..2a3a4aa2d 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -161,6 +161,7 @@ class Theme : public Palette, public ConfigListener int w, int h); ImageSet *getImageSetFromThemeXml(const std::string &name, + const std::string &name2, int w, int h); enum ThemePalette { @@ -261,11 +262,12 @@ class Theme : public Palette, public ConfigListener /** * Loads a skin. */ - Skin *load(const std::string &filename, bool full = true, - const std::string &defaultPath = getThemePath()); + Skin *load(const std::string &filename, const std::string &filename2, + bool full = true, const std::string + &defaultPath = getThemePath()); Skin *loadSkinRect(ImageRect &image, std::string name, - int start = 0, int end = 8); + std::string name2, int start = 0, int end = 8); void unload(Skin *skin); @@ -288,12 +290,13 @@ class Theme : public Palette, public ConfigListener void optionChanged(const std::string &); - void loadRect(ImageRect &image, std::string name, + void loadRect(ImageRect &image, std::string name, std::string name2, int start = 0, int end = 8); void unloadRect(ImageRect &rect, int start = 0, int end = 8); - static Image *getImageFromThemeXml(const std::string &name); + static Image *getImageFromThemeXml(const std::string &name, + const std::string &name2); private: Theme(); diff --git a/src/gui/widgets/avatarlistbox.cpp b/src/gui/widgets/avatarlistbox.cpp index 914437281..ad139159a 100644 --- a/src/gui/widgets/avatarlistbox.cpp +++ b/src/gui/widgets/avatarlistbox.cpp @@ -58,8 +58,8 @@ AvatarListBox::AvatarListBox(AvatarListModel *model): if (instances == 1) { - onlineIcon = Theme::getImageFromThemeXml("circle-on.xml"); - offlineIcon = Theme::getImageFromThemeXml("circle-off.xml"); + onlineIcon = Theme::getImageFromThemeXml("circle-on.xml", ""); + offlineIcon = Theme::getImageFromThemeXml("circle-off.xml", ""); } setWidth(200); diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 15b4abdc2..51d4efc6c 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -176,7 +176,10 @@ void Button::init() if (Theme::instance()) { for (int mode = 0; mode < BUTTON_COUNT; mode ++) - Theme::instance()->loadRect(button[mode], data[mode]); + { + Theme::instance()->loadRect(button[mode], + data[mode], "button.xml"); + } } updateAlpha(); diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index ab08a95d0..04ac998bf 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -56,7 +56,7 @@ CheckBox::CheckBox(const std::string &caption, bool selected, if (Theme::instance()) { ImageRect rect; - Theme::instance()->loadRect(rect, "checkbox.xml", 0, 5); + Theme::instance()->loadRect(rect, "checkbox.xml", "", 0, 5); checkBoxNormal = rect.grid[0]; checkBoxChecked = rect.grid[1]; checkBoxDisabled = rect.grid[2]; diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index dd9bbb4e5..7e810390a 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -70,7 +70,8 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, // Load the background skin for (int i = 0; i < 2; i ++) { - Skin *skin = Theme::instance()->load(dropdownFiles[i]); + Skin *skin = Theme::instance()->load( + dropdownFiles[i], "dropdown.xml"); if (skin) { const ImageRect &rect = skin->getBorder(); @@ -98,7 +99,10 @@ DropDown::DropDown(gcn::ListModel *listModel, gcn::ActionListener* listener, // get the border skin if (Theme::instance()) - Theme::instance()->loadRect(skinRect, "dropdown_background.xml"); + { + Theme::instance()->loadRect(skinRect, + "dropdown_background.xml", ""); + } } instances++; diff --git a/src/gui/widgets/dropshortcutcontainer.cpp b/src/gui/widgets/dropshortcutcontainer.cpp index d70f153d7..a471ab8ff 100644 --- a/src/gui/widgets/dropshortcutcontainer.cpp +++ b/src/gui/widgets/dropshortcutcontainer.cpp @@ -57,7 +57,7 @@ DropShortcutContainer::DropShortcutContainer(): addWidgetListener(this); mBackgroundImg = Theme::getImageFromThemeXml( - "item_shortcut_background.xml"); + "item_shortcut_background.xml", "background.xml"); if (dropShortcut) mMaxItems = dropShortcut->getItemCount(); else diff --git a/src/gui/widgets/emoteshortcutcontainer.cpp b/src/gui/widgets/emoteshortcutcontainer.cpp index d3de9e8de..17d825909 100644 --- a/src/gui/widgets/emoteshortcutcontainer.cpp +++ b/src/gui/widgets/emoteshortcutcontainer.cpp @@ -57,7 +57,7 @@ EmoteShortcutContainer::EmoteShortcutContainer(): addWidgetListener(this); mBackgroundImg = Theme::getImageFromThemeXml( - "item_shortcut_background.xml"); + "item_shortcut_background.xml", "background.xml"); if (mBackgroundImg) mBackgroundImg->setAlpha(Client::getGuiAlpha()); diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index 6963bad31..e315a336c 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -157,7 +157,7 @@ ItemContainer::ItemContainer(Inventory *inventory, bool forceQuantity): mInventory(inventory), mGridColumns(1), mGridRows(1), - mSelImg(Theme::getImageFromThemeXml("item_selection.xml")), + mSelImg(Theme::getImageFromThemeXml("item_selection.xml", "")), mSelectedIndex(-1), mHighlightedIndex(-1), mLastUsedSlot(-1), diff --git a/src/gui/widgets/itemshortcutcontainer.cpp b/src/gui/widgets/itemshortcutcontainer.cpp index e27d5efd6..50fc0de0f 100644 --- a/src/gui/widgets/itemshortcutcontainer.cpp +++ b/src/gui/widgets/itemshortcutcontainer.cpp @@ -64,7 +64,7 @@ ItemShortcutContainer::ItemShortcutContainer(unsigned number): addWidgetListener(this); mBackgroundImg = Theme::getImageFromThemeXml( - "item_shortcut_background.xml"); + "item_shortcut_background.xml", "background.xml"); if (itemShortcut[mNumber]) mMaxItems = itemShortcut[mNumber]->getItemCount(); else diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index 423f26563..b9f6657a9 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -73,7 +73,8 @@ void PlayerBox::init(std::string skin) { if (skin.empty()) skin = "playerbox_background.xml"; - mSkin = Theme::instance()->loadSkinRect(mBackground, skin); + mSkin = Theme::instance()->loadSkinRect(mBackground, + skin, "background.xml"); if (mSkin) mDrawBackground = (mSkin->getOption("drawbackground") != 0); } diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index e206a3246..34079afb2 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -64,7 +64,7 @@ Popup::Popup(const std::string &name, std::string skin): // Loads the skin if (Theme::instance()) { - mSkin = Theme::instance()->load(skin); + mSkin = Theme::instance()->load(skin, "popup.xml"); if (mSkin) setPadding(mSkin->getPadding()); } diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index 2ddd2b0b9..0d0211bcc 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -75,7 +75,7 @@ ProgressBar::ProgressBar(float progress, mBorder.grid[f] = nullptr; if (Theme::instance()) - Theme::instance()->loadRect(mBorder, "progressbar.xml"); + Theme::instance()->loadRect(mBorder, "progressbar.xml", ""); } mInstances++; diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index e0e01d4ed..6a89b3080 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -54,7 +54,7 @@ RadioButton::RadioButton(const std::string &caption, const std::string &group, if (Theme::instance()) { ImageRect rect; - Theme::instance()->loadRect(rect, "radio.xml", 0, 3); + Theme::instance()->loadRect(rect, "radio.xml", "", 0, 3); radioChecked = rect.grid[0]; radioDisabledChecked = rect.grid[0]; radioCheckedHi = rect.grid[1]; diff --git a/src/gui/widgets/resizegrip.cpp b/src/gui/widgets/resizegrip.cpp index 4b299a5dc..53254193d 100644 --- a/src/gui/widgets/resizegrip.cpp +++ b/src/gui/widgets/resizegrip.cpp @@ -43,7 +43,7 @@ ResizeGrip::ResizeGrip(const std::string &image) if (mInstances == 0) { // Load the grip image - gripImage = Theme::getImageFromThemeXml(image); + gripImage = Theme::getImageFromThemeXml(image, ""); if (gripImage) gripImage->setAlpha(mAlpha); diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index 6bc75d5a2..2906ab641 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -127,7 +127,7 @@ void ScrollArea::init(std::string skinName) if (skinName == "") skinName = "scroll_background.xml"; - Theme::instance()->loadRect(background, skinName); + Theme::instance()->loadRect(background, skinName, "scroll_background.xml"); if (instances == 0) { for (int f = 0; f < 9; f ++) @@ -139,13 +139,15 @@ void ScrollArea::init(std::string skinName) if (Theme::instance()) { - Theme::instance()->loadRect(vMarker, "scroll.xml"); - Theme::instance()->loadRect(vMarkerHi, "scroll_highlighted.xml"); + Theme::instance()->loadRect(vMarker, "scroll.xml", ""); + Theme::instance()->loadRect(vMarkerHi, "scroll_highlighted.xml", + "scroll.xml"); } for (int i = 0; i < 2; i ++) { - Skin *skin = Theme::instance()->load(buttonFiles[i]); + Skin *skin = Theme::instance()->load( + buttonFiles[i], "scrollbuttons.xml"); if (skin) { const ImageRect &rect = skin->getBorder(); diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index d97e3e57d..630bd7e28 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -79,7 +79,10 @@ void Slider::init() if (Theme::instance()) { for (int mode = 0; mode < 2; mode ++) - Theme::instance()->loadRect(buttons[mode], data[mode], 0, 8); + { + Theme::instance()->loadRect(buttons[mode], + data[mode], "slider.xml", 0, 8); + } } updateAlpha(); } diff --git a/src/gui/widgets/spellshortcutcontainer.cpp b/src/gui/widgets/spellshortcutcontainer.cpp index c3e3b1495..25dd3fb6d 100644 --- a/src/gui/widgets/spellshortcutcontainer.cpp +++ b/src/gui/widgets/spellshortcutcontainer.cpp @@ -64,7 +64,7 @@ SpellShortcutContainer::SpellShortcutContainer(unsigned number): mSpellPopup = new SpellPopup; mBackgroundImg = Theme::getImageFromThemeXml( - "item_shortcut_background.xml"); + "item_shortcut_background.xml", "background.xml"); if (spellShortcut) mMaxItems = spellShortcut->getSpellsCount(); else diff --git a/src/gui/widgets/tab.cpp b/src/gui/widgets/tab.cpp index 3faa874ca..81b43445c 100644 --- a/src/gui/widgets/tab.cpp +++ b/src/gui/widgets/tab.cpp @@ -102,7 +102,10 @@ void Tab::init() if (Theme::instance()) { for (int mode = 0; mode < TAB_COUNT; mode ++) - Theme::instance()->loadRect(tabImg[mode], data[mode]); + { + Theme::instance()->loadRect(tabImg[mode], + data[mode], "tab.xml"); + } } updateAlpha(); } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 1c054f04b..d5fb58cb9 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -67,7 +67,7 @@ TextField::TextField(const std::string &text, bool loseFocusOnTab, if (instances == 0) { if (Theme::instance()) - Theme::instance()->loadRect(skin, "textfield_background.xml"); + Theme::instance()->loadRect(skin, "textfield_background.xml", ""); } instances++; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 3fb0649c2..bfb4d883c 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -85,7 +85,7 @@ Window::Window(const std::string &caption, bool modal, Window *parent, // Loads the skin if (Theme::instance()) { - mSkin = Theme::instance()->load(skin); + mSkin = Theme::instance()->load(skin, "window.xml"); if (mSkin) setPadding(mSkin->getPadding()); } diff --git a/src/text.cpp b/src/text.cpp index 6e08a048a..96d493cc5 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -60,7 +60,7 @@ Text::Text(const std::string &text, int x, int y, textManager = new TextManager; if (Theme::instance()) { - Theme::instance()->loadRect(mBubble, "bubble.xml"); + Theme::instance()->loadRect(mBubble, "bubble.xml", ""); } else { |