diff --git a/THEMES.md b/THEMES.md index 176b53f51..3c554bbf5 100644 --- a/THEMES.md +++ b/THEMES.md @@ -77,6 +77,24 @@ Display tags must be at the root of the tree - for example, they can't b `` - the percentage to offset the displayed game image by. Default is the height of the header font. + + +The Fast Select box can be themed with these tags: + +`` - path to a background image file. ~ and . are expanded. + +`` - if present, the background will be tiled instead of stretched. + +`` - path to the "left" border image file. It will be flipped for the right border. ~ and . are expanded. + +`` - if present, the horizontal image will be tiled instead of stretched downwards. + +`` - path to the "top" border image file. It will be flipped for the bottom border. ~ and . are expanded. + +`` - if present, the vertical image will be tiled instead of stretched to the right. + +`` - path to the "top left corner" image file. It will be flipped for the top right, bottom right, and bottom left corners. ~ and . are expanded. + List of variables ================= diff --git a/changelog.txt b/changelog.txt index 53b693b00..269782350 100644 --- a/changelog.txt +++ b/changelog.txt @@ -2,6 +2,7 @@ October 7 -Fixed borders for GuiBox. The right and bottom borders are flipped, too. -Added corners for GuiBox. -Added setFlipX() and setFlipY() to the GuiImage class. +-Added theming options for the Fast Select GuiBox! See THEMES.md for more details. October 5 -GuiFastSelect is working, but ugly. diff --git a/src/components/GuiBox.cpp b/src/components/GuiBox.cpp index 2f2db5602..21879b3d6 100644 --- a/src/components/GuiBox.cpp +++ b/src/components/GuiBox.cpp @@ -1,4 +1,5 @@ #include "GuiBox.h" +#include GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height) { @@ -9,6 +10,14 @@ GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height mHeight = height; } +void GuiBox::setData(GuiBoxData data) +{ + setBackgroundImage(data.backgroundPath, data.backgroundTiled); + setHorizontalImage(data.horizontalPath, data.horizontalTiled); + setVerticalImage(data.verticalPath, data.verticalTiled); + setCornerImage(data.cornerPath); +} + void GuiBox::setHorizontalImage(std::string path, bool tiled) { mHorizontalImage.setResize(12, mHeight, true); diff --git a/src/components/GuiBox.h b/src/components/GuiBox.h index 64af57bd1..5c0f5e49a 100644 --- a/src/components/GuiBox.h +++ b/src/components/GuiBox.h @@ -5,11 +5,23 @@ #include "GuiImage.h" #include +struct GuiBoxData { + std::string backgroundPath; + bool backgroundTiled; + std::string horizontalPath; + bool horizontalTiled; + std::string verticalPath; + bool verticalTiled; + std::string cornerPath; +}; + class GuiBox : public GuiComponent { public: GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height); + void setData(GuiBoxData data); + void setBackgroundImage(std::string path, bool tiled = true); void setHorizontalImage(std::string path, bool tiled = false); void setVerticalImage(std::string path, bool tiled = false); diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index ea9f6ef95..7ffaeabbe 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -6,7 +6,7 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; const int GuiFastSelect::SCROLLSPEED = 100; const int GuiFastSelect::SCROLLDELAY = 507; -GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter) +GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data) { mLetterID = LETTERS.find(toupper(startLetter)); if(mLetterID == std::string::npos) @@ -24,13 +24,9 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, cha unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); mBox = new GuiBox(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6); + mBox->setData(data); addChild(mBox); - //set test mBox info - mBox->setHorizontalImage("left.jpg", false); - mBox->setVerticalImage("top.jpg", false); - mBox->setCornerImage("corner.jpg"); - mParent->pause(); } diff --git a/src/components/GuiFastSelect.h b/src/components/GuiFastSelect.h index dffda4bf0..647844d68 100644 --- a/src/components/GuiFastSelect.h +++ b/src/components/GuiFastSelect.h @@ -10,7 +10,7 @@ class GuiFastSelect : GuiComponent { public: - GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter); + GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data); ~GuiFastSelect(); void onRender(); diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index e21147b5c..e1b59216b 100644 --- a/src/components/GuiGameList.cpp +++ b/src/components/GuiGameList.cpp @@ -154,7 +154,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown) if(button == InputManager::SELECT && keyDown) { - new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0]); + new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData()); } if(mDetailed) diff --git a/src/components/GuiTheme.cpp b/src/components/GuiTheme.cpp index 299d2cd27..37f42b545 100644 --- a/src/components/GuiTheme.cpp +++ b/src/components/GuiTheme.cpp @@ -21,6 +21,8 @@ float GuiTheme::getListTextOffsetX() { return mListTextOffsetX; } int GuiTheme::getSelectedTextColor() { return mListSelectedColor; } +GuiBoxData GuiTheme::getBoxData() { return mBoxData; } + GuiTheme::GuiTheme(std::string path) { setDefaults(); @@ -48,6 +50,14 @@ void GuiTheme::setDefaults() mListOffsetX = 0.5; mListTextOffsetX = 0.005; mGameImageOffsetY = (float)Renderer::getFontHeight(Renderer::LARGE) / Renderer::getScreenHeight(); + + mBoxData.backgroundPath = ""; + mBoxData.backgroundTiled = false; + mBoxData.horizontalPath = ""; + mBoxData.horizontalTiled = false; + mBoxData.verticalPath = ""; + mBoxData.verticalTiled = false; + mBoxData.cornerPath = ""; } void GuiTheme::deleteComponents() @@ -101,6 +111,15 @@ void GuiTheme::readXML(std::string path) mHideDividers = root.child("hideDividers"); mListCentered = !root.child("listLeftAlign"); + //GuiBox theming data + mBoxData.backgroundPath = expandPath(root.child("boxBackground").text().get()); + mBoxData.backgroundTiled = root.child("boxBackgroundTiled"); + mBoxData.horizontalPath = expandPath(root.child("boxHorizontal").text().get()); + mBoxData.horizontalTiled = root.child("boxHorizontalTiled"); + mBoxData.verticalPath = expandPath(root.child("boxVertical").text().get()); + mBoxData.verticalTiled = root.child("boxVerticalTiled"); + mBoxData.cornerPath = expandPath(root.child("boxCorner").text().get()); + mListOffsetX = strToFloat(root.child("listOffsetX").text().get(), mListOffsetX); mGameImageOffsetY = strToFloat(root.child("gameImageOffsetY").text().get(), mGameImageOffsetY); mListTextOffsetX = strToFloat(root.child("listTextOffsetX").text().get(), mListTextOffsetX); diff --git a/src/components/GuiTheme.h b/src/components/GuiTheme.h index a8d47e9dd..5e834693b 100644 --- a/src/components/GuiTheme.h +++ b/src/components/GuiTheme.h @@ -3,6 +3,7 @@ #include "../GuiComponent.h" #include "../pugiXML/pugixml.hpp" +#include "GuiBox.h" //This class loads an XML-defined list of GuiComponents. class GuiTheme : public GuiComponent @@ -25,6 +26,8 @@ public: float getListOffsetX(); float getListTextOffsetX(); float getGameImageOffsetY(); + + GuiBoxData getBoxData(); private: void setDefaults(); void deleteComponents(); @@ -44,6 +47,8 @@ private: bool mHideHeader, mHideDividers, mListCentered; float mListOffsetX, mGameImageOffsetY, mListTextOffsetX; + + GuiBoxData mBoxData; }; #endif