diff options
author | Andrei Karas <akaras@inbox.ru> | 2017-12-27 03:30:58 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2017-12-27 03:30:58 +0300 |
commit | 003043714367009efaf07015cc63a901ae2ee47c (patch) | |
tree | f441091a46ac07419977a0dba4cfd6b5ceab667b | |
parent | 916a3d76da98d078a807044c43d1a70bc146ba70 (diff) | |
download | mv-003043714367009efaf07015cc63a901ae2ee47c.tar.gz mv-003043714367009efaf07015cc63a901ae2ee47c.tar.bz2 mv-003043714367009efaf07015cc63a901ae2ee47c.tar.xz mv-003043714367009efaf07015cc63a901ae2ee47c.zip |
Remove default parameters from theme.
28 files changed, 193 insertions, 63 deletions
diff --git a/src/gui/theme.cpp b/src/gui/theme.cpp index 6d9c572ba..171415ec0 100644 --- a/src/gui/theme.cpp +++ b/src/gui/theme.cpp @@ -1095,7 +1095,10 @@ void Theme::loadRect(ImageRect &image, const int start, const int end) { - Skin *const skin = load(name, name2, false); + Skin *const skin = load(name, + name2, + false, + theme->getThemePath()); if (skin != nullptr) { loadGrid(); @@ -1109,7 +1112,10 @@ Skin *Theme::loadSkinRect(ImageRect &image, const int start, const int end) { - Skin *const skin = load(name, name2); + Skin *const skin = load(name, + name2, + true, + theme->getThemePath()); if (skin != nullptr) loadGrid(); return skin; @@ -1132,7 +1138,10 @@ Image *Theme::getImageFromThemeXml(const std::string &name, if (theme == nullptr) return nullptr; - Skin *const skin = theme->load(name, name2, false); + Skin *const skin = theme->load(name, + name2, + false, + theme->getThemePath()); if (skin != nullptr) { const ImageRect &rect = skin->getBorder(); @@ -1155,7 +1164,10 @@ ImageSet *Theme::getImageSetFromThemeXml(const std::string &name, if (theme == nullptr) return nullptr; - Skin *const skin = theme->load(name, name2, false); + Skin *const skin = theme->load(name, + name2, + false, + theme->getThemePath()); if (skin != nullptr) { const ImageRect &rect = skin->getBorder(); diff --git a/src/gui/theme.h b/src/gui/theme.h index 8618468d9..e3cc55151 100644 --- a/src/gui/theme.h +++ b/src/gui/theme.h @@ -101,15 +101,14 @@ class Theme final : public Palette, */ Skin *load(const std::string &filename, const std::string &filename2, - const bool full = true, - const std::string - &restrict defaultPath = getThemePath()) A_WARN_UNUSED; + const bool full, + const std::string &restrict defaultPath) A_WARN_UNUSED; Skin *loadSkinRect(ImageRect &image, const std::string &name, const std::string &name2, - const int start = 0, - const int end = 8) A_WARN_UNUSED; + const int start, + const int end) A_WARN_UNUSED; void unload(Skin *const skin); @@ -134,8 +133,7 @@ class Theme final : public Palette, * @return the requested color */ inline const Color &getColor(ThemeColorIdT type, - const unsigned int alpha = 255U) - A_WARN_UNUSED + const unsigned int alpha) A_WARN_UNUSED { if (CAST_SIZE(type) >= mColors.size()) { @@ -163,12 +161,12 @@ class Theme final : public Palette, void loadRect(ImageRect &image, const std::string &name, const std::string &name2, - const int start = 0, - const int end = 8); + const int start, + const int end); static void unloadRect(const ImageRect &rect, - const int start = 0, - const int end = 8); + const int start, + const int end); static Image *getImageFromThemeXml(const std::string &name, const std::string &name2) @@ -192,7 +190,7 @@ class Theme final : public Palette, static bool tryThemePath(const std::string &themePath) A_WARN_UNUSED; - void loadColors(std::string file = ""); + void loadColors(std::string file); /** * Tells if the current skins opacity diff --git a/src/gui/widgets/browserbox.cpp b/src/gui/widgets/browserbox.cpp index 1f973c85e..fc9ae9698 100644 --- a/src/gui/widgets/browserbox.cpp +++ b/src/gui/widgets/browserbox.cpp @@ -100,7 +100,12 @@ BrowserBox::BrowserBox(const Widget2 *const widget, mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND, 255U); if (theme != nullptr) - mSkin = theme->load(skin, "browserbox.xml"); + { + mSkin = theme->load(skin, + "browserbox.xml", + true, + theme->getThemePath()); + } if (mInstances == 0) { mEmotes = Loader::getImageSet( diff --git a/src/gui/widgets/button.cpp b/src/gui/widgets/button.cpp index 25986ef8a..f8ddbc8f4 100644 --- a/src/gui/widgets/button.cpp +++ b/src/gui/widgets/button.cpp @@ -360,7 +360,10 @@ void Button::init() { for (int mode = 0; mode < BUTTON_COUNT; mode ++) { - Skin *const skin = theme->load(data[mode], "button.xml"); + Skin *const skin = theme->load(data[mode], + "button.xml", + true, + theme->getThemePath()); if (skin != nullptr) { button[mode] = skin; diff --git a/src/gui/widgets/checkbox.cpp b/src/gui/widgets/checkbox.cpp index 8424c5c0e..81daf7cad 100644 --- a/src/gui/widgets/checkbox.cpp +++ b/src/gui/widgets/checkbox.cpp @@ -117,7 +117,10 @@ CheckBox::CheckBox(const Widget2 *const widget, { if (theme != nullptr) { - mSkin = theme->load("checkbox.xml", ""); + mSkin = theme->load("checkbox.xml", + "", + true, + theme->getThemePath()); updateAlpha(); } } diff --git a/src/gui/widgets/desktop.cpp b/src/gui/widgets/desktop.cpp index 4fe56676b..7a56035fb 100644 --- a/src/gui/widgets/desktop.cpp +++ b/src/gui/widgets/desktop.cpp @@ -65,7 +65,12 @@ Desktop::Desktop(const Widget2 *const widget) : Wallpaper::loadWallpapers(); if (theme != nullptr) - mSkin = theme->load("desktop.xml", ""); + { + mSkin = theme->load("desktop.xml", + "", + true, + theme->getThemePath()); + } if (mSkin != nullptr) mShowBackground = (mSkin->getOption("showBackground") != 0); diff --git a/src/gui/widgets/dropdown.cpp b/src/gui/widgets/dropdown.cpp index 7e9de9b53..1f8b54bc1 100644 --- a/src/gui/widgets/dropdown.cpp +++ b/src/gui/widgets/dropdown.cpp @@ -89,7 +89,10 @@ DropDown::DropDown(const Widget2 *const widget, // Load the background skin for (int i = 0; i < 2; i ++) { - Skin *const skin = theme->load(dropdownFiles[i], "dropdown.xml"); + Skin *const skin = theme->load(dropdownFiles[i], + "dropdown.xml", + true, + theme->getThemePath()); if (skin != nullptr) { if (i == 0) @@ -119,7 +122,7 @@ DropDown::DropDown(const Widget2 *const widget, } // get the border skin - theme->loadRect(skinRect, "dropdown_background.xml", ""); + theme->loadRect(skinRect, "dropdown_background.xml", "", 0, 8); } instances++; @@ -179,7 +182,7 @@ DropDown::~DropDown() if (theme != nullptr) { theme->unload(mSkin); - Theme::unloadRect(skinRect); + Theme::unloadRect(skinRect, 0, 8); } } } diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index fa9fc957e..19d3a30b3 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -236,7 +236,8 @@ ItemContainer::ItemContainer(const Widget2 *const widget, mCellBackgroundImg(Theme::getImageFromThemeXml("inventory_cell.xml", "")), mName(), mShowMatrix(nullptr), - mSkin(theme != nullptr ? theme->load("itemcontainer.xml", "") : nullptr), + mSkin(theme != nullptr ? theme->load("itemcontainer.xml", "", + true, theme->getThemePath()) : nullptr), mVertexes(new ImageCollection), mEquipedColor(getThemeColor(ThemeColorId::ITEM_EQUIPPED, 255U)), mEquipedColor2(getThemeColor(ThemeColorId::ITEM_EQUIPPED_OUTLINE, 255U)), diff --git a/src/gui/widgets/label.cpp b/src/gui/widgets/label.cpp index c4d8d14f6..6fb3ae39e 100644 --- a/src/gui/widgets/label.cpp +++ b/src/gui/widgets/label.cpp @@ -131,7 +131,12 @@ void Label::init() if (mInstances == 0) { if (theme != nullptr) - mSkin = theme->load("label.xml", ""); + { + mSkin = theme->load("label.xml", + "", + true, + theme->getThemePath()); + } } mInstances ++; diff --git a/src/gui/widgets/listbox.cpp b/src/gui/widgets/listbox.cpp index eabf26e19..dcb0c4c9c 100644 --- a/src/gui/widgets/listbox.cpp +++ b/src/gui/widgets/listbox.cpp @@ -118,7 +118,12 @@ ListBox::ListBox(const Widget2 *const widget, mForegroundColor2 = getThemeColor(ThemeColorId::LISTBOX_OUTLINE, 255U); if (theme != nullptr) - mSkin = theme->load(skin, "listbox.xml"); + { + mSkin = theme->load(skin, + "listbox.xml", + true, + theme->getThemePath()); + } if (mSkin != nullptr) { diff --git a/src/gui/widgets/playerbox.cpp b/src/gui/widgets/playerbox.cpp index b6217383f..98e6e8d5a 100644 --- a/src/gui/widgets/playerbox.cpp +++ b/src/gui/widgets/playerbox.cpp @@ -79,8 +79,8 @@ PlayerBox::~PlayerBox() if (gui != nullptr) gui->removeDragged(this); - Theme::unloadRect(mBackground); - Theme::unloadRect(mSelectedBackground); + Theme::unloadRect(mBackground, 0, 8); + Theme::unloadRect(mSelectedBackground, 0, 8); mBeing = nullptr; } @@ -95,7 +95,10 @@ void PlayerBox::init(std::string name, std::string selectedName) if (name.empty()) name = "playerbox.xml"; mSkin = theme->loadSkinRect(mBackground, - name, "playerbox_background.xml"); + name, + "playerbox_background.xml", + 0, + 8); if (mSkin != nullptr) { mDrawBackground = (mSkin->getOption("drawbackground") != 0); @@ -106,7 +109,10 @@ void PlayerBox::init(std::string name, std::string selectedName) if (selectedName.empty()) selectedName = "playerboxselected.xml"; mSelectedSkin = theme->loadSkinRect(mSelectedBackground, - selectedName, "playerbox_background.xml"); + selectedName, + "playerbox_background.xml", + 0, + 8); } else { diff --git a/src/gui/widgets/popup.cpp b/src/gui/widgets/popup.cpp index 0f5c5a31a..0ab2c27c8 100644 --- a/src/gui/widgets/popup.cpp +++ b/src/gui/widgets/popup.cpp @@ -62,7 +62,10 @@ Popup::Popup(const std::string &name, if (theme != nullptr) { - mSkin = theme->load(skin, "popup.xml"); + mSkin = theme->load(skin, + "popup.xml", + true, + theme->getThemePath()); if (mSkin != nullptr) { setPadding(mSkin->getPadding()); diff --git a/src/gui/widgets/progressbar.cpp b/src/gui/widgets/progressbar.cpp index f1889e979..0e01876f5 100644 --- a/src/gui/widgets/progressbar.cpp +++ b/src/gui/widgets/progressbar.cpp @@ -83,14 +83,23 @@ ProgressBar::ProgressBar(const Widget2 *const widget, if (theme != nullptr) { - mSkin = theme->load(skin, "progressbar.xml"); + mSkin = theme->load(skin, + "progressbar.xml", + true, + theme->getThemePath()); if (mSkin != nullptr) { setPadding(mSkin->getPadding()); mFillPadding = mSkin->getOption("fillPadding"); mFillImage = mSkin->getOption("fillImage") != 0; if (mFillImage) - theme->loadRect(mFillRect, skinFill, "progressbar_fill.xml"); + { + theme->loadRect(mFillRect, + skinFill, + "progressbar_fill.xml", + 0, + 8); + } } setHeight(2 * mPadding + getFont()->getHeight() + 2); } @@ -110,7 +119,7 @@ ProgressBar::~ProgressBar() theme->unload(mSkin); mSkin = nullptr; } - Theme::unloadRect(mFillRect); + Theme::unloadRect(mFillRect, 0, 8); delete2(mVertexes); mTextChunk.deleteImage(); } diff --git a/src/gui/widgets/radiobutton.cpp b/src/gui/widgets/radiobutton.cpp index c2e9ad505..62b5bae48 100644 --- a/src/gui/widgets/radiobutton.cpp +++ b/src/gui/widgets/radiobutton.cpp @@ -121,7 +121,10 @@ RadioButton::RadioButton(const Widget2 *const widget, { if (theme != nullptr) { - mSkin = theme->load("radio.xml", ""); + mSkin = theme->load("radio.xml", + "", + true, + theme->getThemePath()); updateAlpha(); } } diff --git a/src/gui/widgets/scrollarea.cpp b/src/gui/widgets/scrollarea.cpp index e22ecdcf3..a99d5cc3c 100644 --- a/src/gui/widgets/scrollarea.cpp +++ b/src/gui/widgets/scrollarea.cpp @@ -157,11 +157,11 @@ ScrollArea::~ScrollArea() instances--; if (instances == 0) { - Theme::unloadRect(background); - Theme::unloadRect(vMarker); - Theme::unloadRect(vMarkerHi); - Theme::unloadRect(vBackground); - Theme::unloadRect(hBackground); + Theme::unloadRect(background, 0, 8); + Theme::unloadRect(vMarker, 0, 8); + Theme::unloadRect(vMarkerHi, 0, 8); + Theme::unloadRect(vBackground, 0, 8); + Theme::unloadRect(hBackground, 0, 8); for (int i = 0; i < 2; i ++) { for (int f = UP; f < BUTTONS_DIR; f ++) @@ -203,18 +203,43 @@ void ScrollArea::init(std::string skinName) skinName = "scroll_background.xml"; if (theme != nullptr) { - theme->loadRect(background, skinName, "scroll_background.xml"); - theme->loadRect(vMarker, "scroll.xml", ""); - theme->loadRect(vMarkerHi, "scroll_highlighted.xml", "scroll.xml"); - theme->loadRect(vBackground, "scroll_vbackground.xml", ""); - theme->loadRect(hBackground, "scroll_hbackground.xml", ""); + theme->loadRect(background, + skinName, + "scroll_background.xml", + 0, + 8); + theme->loadRect(vMarker, + "scroll.xml", + "", + 0, + 8); + theme->loadRect(vMarkerHi, + "scroll_highlighted.xml", + "scroll.xml", + 0, + 8); + theme->loadRect(vBackground, + "scroll_vbackground.xml", + "", + 0, + 8); + theme->loadRect(hBackground, + "scroll_hbackground.xml", + "", + 0, + 8); } for (int i = 0; i < 2; i ++) { Skin *skin = nullptr; if (theme != nullptr) - skin = theme->load(buttonFiles[i], "scrollbuttons.xml"); + { + skin = theme->load(buttonFiles[i], + "scrollbuttons.xml", + true, + theme->getThemePath()); + } if (skin != nullptr) { const ImageRect &rect = skin->getBorder(); diff --git a/src/gui/widgets/skillrectanglelistbox.h b/src/gui/widgets/skillrectanglelistbox.h index 86ce542c6..671932d89 100644 --- a/src/gui/widgets/skillrectanglelistbox.h +++ b/src/gui/widgets/skillrectanglelistbox.h @@ -75,7 +75,9 @@ class SkillRectangleListBox final : public Widget, if (theme != nullptr) { mSkin = theme->load("skillrectanglelistbox.xml", - "listbox.xml"); + "listbox.xml", + true, + theme->getThemePath()); } if (mSkin != nullptr) diff --git a/src/gui/widgets/slider.cpp b/src/gui/widgets/slider.cpp index 0d25ad2c5..900df73a2 100644 --- a/src/gui/widgets/slider.cpp +++ b/src/gui/widgets/slider.cpp @@ -140,7 +140,7 @@ Slider::~Slider() if (mInstances == 0) { for (int mode = 0; mode < 2; mode ++) - Theme::unloadRect(buttons[mode]); + Theme::unloadRect(buttons[mode], 0, 8); } } diff --git a/src/gui/widgets/staticbrowserbox.cpp b/src/gui/widgets/staticbrowserbox.cpp index d602160b6..cd252cce1 100644 --- a/src/gui/widgets/staticbrowserbox.cpp +++ b/src/gui/widgets/staticbrowserbox.cpp @@ -95,7 +95,12 @@ StaticBrowserBox::StaticBrowserBox(const Widget2 *const widget, mBackgroundColor = getThemeColor(ThemeColorId::BACKGROUND, 255U); if (theme != nullptr) - mSkin = theme->load(skin, "browserbox.xml"); + { + mSkin = theme->load(skin, + "browserbox.xml", + true, + theme->getThemePath()); + } if (mInstances == 0) { mEmotes = Loader::getImageSet( diff --git a/src/gui/widgets/tabs/tab.cpp b/src/gui/widgets/tabs/tab.cpp index 88fe5d54f..9dc6c4068 100644 --- a/src/gui/widgets/tabs/tab.cpp +++ b/src/gui/widgets/tabs/tab.cpp @@ -165,7 +165,12 @@ void Tab::init() if (theme != nullptr) { for (int mode = 0; mode < TAB_COUNT; mode ++) - tabImg[mode] = theme->load(data[mode], "tab.xml"); + { + tabImg[mode] = theme->load(data[mode], + "tab.xml", + true, + theme->getThemePath()); + } } updateAlpha(); } diff --git a/src/gui/widgets/textfield.cpp b/src/gui/widgets/textfield.cpp index 8af2109d8..167d2b850 100644 --- a/src/gui/widgets/textfield.cpp +++ b/src/gui/widgets/textfield.cpp @@ -146,8 +146,11 @@ TextField::TextField(const Widget2 *restrict const widget, { if (theme != nullptr) { - mSkin = theme->loadSkinRect(skin, "textfield.xml", - "textfield_background.xml"); + mSkin = theme->loadSkinRect(skin, + "textfield.xml", + "textfield_background.xml", + 0, + 8); } } @@ -181,7 +184,7 @@ TextField::~TextField() if (theme != nullptr) { theme->unload(mSkin); - Theme::unloadRect(skin); + Theme::unloadRect(skin, 0, 8); } } mTextChunk.deleteImage(); diff --git a/src/gui/widgets/textpreview.cpp b/src/gui/widgets/textpreview.cpp index 4d90f1f9c..3feaf08c0 100644 --- a/src/gui/widgets/textpreview.cpp +++ b/src/gui/widgets/textpreview.cpp @@ -56,7 +56,12 @@ TextPreview::TextPreview(const Widget2 *const widget, if (instances == 0) { if (theme != nullptr) - mSkin = theme->load("textpreview.xml", ""); + { + mSkin = theme->load("textpreview.xml", + "", + true, + theme->getThemePath()); + } } instances++; diff --git a/src/gui/widgets/window.cpp b/src/gui/widgets/window.cpp index 132b3f561..3fb6c458e 100644 --- a/src/gui/widgets/window.cpp +++ b/src/gui/widgets/window.cpp @@ -183,7 +183,10 @@ Window::Window(const std::string &caption, // Loads the skin if (theme != nullptr) { - mSkin = theme->load(skin, "window.xml"); + mSkin = theme->load(skin, + "window.xml", + true, + theme->getThemePath()); if (mSkin != nullptr) { setPadding(mSkin->getPadding()); diff --git a/src/gui/windowmenu.cpp b/src/gui/windowmenu.cpp index 65deb45e2..ba4993954 100644 --- a/src/gui/windowmenu.cpp +++ b/src/gui/windowmenu.cpp @@ -52,7 +52,8 @@ WindowMenu::WindowMenu(const Widget2 *const widget) : ActionListener(), SelectionListener(), MouseListener(), - mSkin(theme != nullptr ? theme->load("windowmenu.xml", "") : nullptr), + mSkin(theme != nullptr ? theme->load("windowmenu.xml", "", + true, theme->getThemePath()) : nullptr), mPadding(mSkin != nullptr ? mSkin->getPadding() : 1), mSpacing(mSkin != nullptr ? mSkin->getOption("spacing", 3) : 3), mButtons(), diff --git a/src/input/touch/touchmanager.cpp b/src/input/touch/touchmanager.cpp index df98e667f..ec2d71760 100644 --- a/src/input/touch/touchmanager.cpp +++ b/src/input/touch/touchmanager.cpp @@ -143,7 +143,11 @@ void TouchManager::loadTouchItem(TouchItem **restrict item, else icon = Theme::getImageFromThemeXml(imageName, ""); - Skin *const skin = theme->loadSkinRect(*images, name, ""); + Skin *const skin = theme->loadSkinRect(*images, + name, + "", + 0, + 8); if (skin != nullptr) { Image *const image = images->grid[0]; @@ -389,7 +393,7 @@ void TouchManager::unload(TouchItem *restrict const item) { if (item->images != nullptr) { - Theme::unloadRect(*item->images); + Theme::unloadRect(*item->images, 0, 8); delete2(item->images); if (item->icon != nullptr) { @@ -427,7 +431,10 @@ void TouchManager::loadButtons() restrict2 const int sz = (mButtonsSize + 1) * 50; if (theme == nullptr) return; - Skin *const skin = theme->load("dbutton.xml", ""); + Skin *const skin = theme->load("dbutton.xml", + "", + true, + theme->getThemePath()); if (skin != nullptr) { diff --git a/src/progs/dyecmd/client.cpp b/src/progs/dyecmd/client.cpp index 631469f2b..7046be25d 100644 --- a/src/progs/dyecmd/client.cpp +++ b/src/progs/dyecmd/client.cpp @@ -351,7 +351,10 @@ void Client::gameInit() #endif // USE_SDL2 #endif // ANDROID - mSkin = theme->load("windowmenu.xml", ""); + mSkin = theme->load("windowmenu.xml", + "", + true, + theme->getThemePath()); if (mSkin != nullptr) { mButtonPadding = mSkin->getPadding(); diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp index 65d5fde89..380453c19 100644 --- a/src/progs/manaplus/client.cpp +++ b/src/progs/manaplus/client.cpp @@ -531,7 +531,10 @@ void Client::gameInit() mumbleManager = new MumbleManager; #endif // USE_MUMBLE - mSkin = theme->load("windowmenu.xml", ""); + mSkin = theme->load("windowmenu.xml", + "", + true, + theme->getThemePath()); if (mSkin != nullptr) { mButtonPadding = mSkin->getPadding(); diff --git a/src/test/testlauncher.cpp b/src/test/testlauncher.cpp index d5df688a7..841ca4094 100644 --- a/src/test/testlauncher.cpp +++ b/src/test/testlauncher.cpp @@ -734,7 +734,10 @@ int TestLauncher::testDraw() img[0] = Theme::getImageFromTheme("graphics/sprites/arrow_left.png"); img[1] = Theme::getImageFromTheme("graphics/sprites/arrow_right.png"); img[2] = Theme::getImageFromTheme("graphics/sprites/arrow_up.png"); - Skin *skin = theme->load("button.xml", "button.xml"); + Skin *skin = theme->load("button.xml", + "button.xml", + true, + theme->getThemePath()); if (skin == nullptr) return 0; diff --git a/src/text.cpp b/src/text.cpp index 671139a05..fc343fb96 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -68,7 +68,11 @@ Text::Text(const std::string &text, textManager = new TextManager; if (theme != nullptr) { - theme->loadRect(mBubble, "bubble.xml", ""); + theme->loadRect(mBubble, + "bubble.xml", + "", + 0, + 8); } else { |