diff --git a/THEMES.md b/THEMES.md index 3c554bbf5..4c7c3a2d6 100644 --- a/THEMES.md +++ b/THEMES.md @@ -81,6 +81,8 @@ Display tags must be at the root of the tree - for example, they can't b The Fast Select box can be themed with these tags: +`` - the hex color to use for the letter display on the Fast Select box. + `` - path to a background image file. ~ and . are expanded. `` - if present, the background will be tiled instead of stretched. @@ -95,6 +97,10 @@ The Fast Select box can be themed with these tags: `` - 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. + +**NOTE:** The tiling tags are in and will tile, but will not properly cut off where they should. This should be fixed in a later commit. + + List of variables ================= diff --git a/changelog.txt b/changelog.txt index 269782350..57e4482a9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,8 +1,11 @@ +October 10 +-Added a theming tag for the Fast Select box's text. + 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. +-Added theming tags for the Fast Select GuiBox! See THEMES.md for more details. Tiling still not perfect though. October 5 -GuiFastSelect is working, but ugly. diff --git a/src/components/GuiBox.cpp b/src/components/GuiBox.cpp index 21879b3d6..b90fd9b76 100644 --- a/src/components/GuiBox.cpp +++ b/src/components/GuiBox.cpp @@ -1,5 +1,4 @@ #include "GuiBox.h" -#include GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height) { @@ -20,20 +19,20 @@ void GuiBox::setData(GuiBoxData data) void GuiBox::setHorizontalImage(std::string path, bool tiled) { - mHorizontalImage.setResize(12, mHeight, true); mHorizontalImage.setTiling(tiled); mHorizontalImage.setOrigin(0, 0); mHorizontalImage.setImage(path); + mHorizontalImage.setResize(mHorizontalImage.getHeight(), mHeight, true); } void GuiBox::setVerticalImage(std::string path, bool tiled) { - mVerticalImage.setResize(mWidth, 12, true); mVerticalImage.setTiling(tiled); mVerticalImage.setOrigin(0, 0); mVerticalImage.setImage(path); + mVerticalImage.setResize(mWidth, mVerticalImage.getHeight(), true); } void GuiBox::setBackgroundImage(std::string path, bool tiled) @@ -56,6 +55,8 @@ void GuiBox::setCornerImage(std::string path) void GuiBox::onRender() { + mBackgroundImage.render(); + //left border mHorizontalImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth()); mHorizontalImage.setOffsetY(getOffsetY()); @@ -123,10 +124,15 @@ void GuiBox::onDeinit() int GuiBox::getHorizontalBorderWidth() { - return 12; + return mHorizontalImage.getWidth(); } int GuiBox::getVerticalBorderWidth() { - return 12; + return mVerticalImage.getHeight(); +} + +bool GuiBox::hasBackground() +{ + return mBackgroundImage.hasImage(); } diff --git a/src/components/GuiBox.h b/src/components/GuiBox.h index 5c0f5e49a..f4a21bbd4 100644 --- a/src/components/GuiBox.h +++ b/src/components/GuiBox.h @@ -27,6 +27,8 @@ public: void setVerticalImage(std::string path, bool tiled = false); void setCornerImage(std::string path); + bool hasBackground(); + void onRender(); void onInit(); diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index 7ffaeabbe..fb75f1f17 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, GuiBoxData data) +GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data, int textcolor) { mLetterID = LETTERS.find(toupper(startLetter)); if(mLetterID == std::string::npos) @@ -27,6 +27,8 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList* list, cha mBox->setData(data); addChild(mBox); + mTextColor = textcolor; + mParent->pause(); } @@ -45,8 +47,10 @@ void GuiFastSelect::onRender() { unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); - Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0); - Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), 0xFF0000, Renderer::LARGE); + if(!mBox->hasBackground()) + Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0); + + Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), mTextColor, Renderer::LARGE); } void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown) diff --git a/src/components/GuiFastSelect.h b/src/components/GuiFastSelect.h index 647844d68..c0be2b8bb 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, GuiBoxData data); + GuiFastSelect(GuiComponent* parent, GuiList* list, char startLetter, GuiBoxData data, int textcolor); ~GuiFastSelect(); void onRender(); @@ -31,6 +31,7 @@ private: GuiComponent* mParent; GuiBox* mBox; + int mTextColor; int mScrollTimer, mScrollOffset; bool mScrolling; diff --git a/src/components/GuiGameList.cpp b/src/components/GuiGameList.cpp index e1b59216b..0e1e0eca8 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], mTheme->getBoxData()); + new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getFastSelectColor()); } if(mDetailed) diff --git a/src/components/GuiImage.cpp b/src/components/GuiImage.cpp index c155043cc..da9723020 100644 --- a/src/components/GuiImage.cpp +++ b/src/components/GuiImage.cpp @@ -3,8 +3,8 @@ #include #include -unsigned int GuiImage::getWidth() { return mWidth; } -unsigned int GuiImage::getHeight() { return mHeight; } +unsigned int GuiImage::getWidth() { return mDrawWidth; } +unsigned int GuiImage::getHeight() { return mDrawHeight; } GuiImage::GuiImage(int offsetX, int offsetY, std::string path, unsigned int resizeWidth, unsigned int resizeHeight, bool resizeExact) { @@ -352,3 +352,8 @@ void GuiImage::onDeinit() { unloadImage(); } + +bool GuiImage::hasImage() +{ + return !mPath.empty(); +} diff --git a/src/components/GuiImage.h b/src/components/GuiImage.h index c96175367..bd186b646 100644 --- a/src/components/GuiImage.h +++ b/src/components/GuiImage.h @@ -27,6 +27,8 @@ public: unsigned int getWidth(); //Returns render width in pixels. May be different than actual texture width. unsigned int getHeight(); //Returns render height in pixels. May be different than actual texture height. + bool hasImage(); + void onRender(); //Image textures will be deleted on renderer deinitialization, and recreated on reinitialization (if mPath is not empty). diff --git a/src/components/GuiTheme.cpp b/src/components/GuiTheme.cpp index 37f42b545..862821733 100644 --- a/src/components/GuiTheme.cpp +++ b/src/components/GuiTheme.cpp @@ -11,6 +11,7 @@ int GuiTheme::getPrimaryColor() { return mListPrimaryColor; } int GuiTheme::getSecondaryColor() { return mListSecondaryColor; } int GuiTheme::getSelectorColor() { return mListSelectorColor; } int GuiTheme::getDescColor() { return mDescColor; } +int GuiTheme::getFastSelectColor() { return mFastSelectColor; } bool GuiTheme::getHeaderHidden() { return mHideHeader; } bool GuiTheme::getDividersHidden() { return mHideDividers; } bool GuiTheme::getListCentered() { return mListCentered; } @@ -43,6 +44,7 @@ void GuiTheme::setDefaults() mListSelectorColor = 0x000000; mListSelectedColor = -1; //-1 = use original list color when selected mDescColor = 0x0000FF; + mFastSelectColor = 0xFF0000; mHideHeader = false; mHideDividers = false; mListCentered = true; @@ -107,6 +109,7 @@ void GuiTheme::readXML(std::string path) mListSelectorColor = resolveColor(root.child("listSelectorColor").text().get(), mListSelectorColor); mListSelectedColor = resolveColor(root.child("listSelectedColor").text().get(), mListSelectedColor); mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor); + mFastSelectColor = resolveColor(root.child("fastSelectColor").text().get(), mFastSelectColor); mHideHeader = root.child("hideHeader"); mHideDividers = root.child("hideDividers"); mListCentered = !root.child("listLeftAlign"); diff --git a/src/components/GuiTheme.h b/src/components/GuiTheme.h index 5e834693b..e0159826b 100644 --- a/src/components/GuiTheme.h +++ b/src/components/GuiTheme.h @@ -19,6 +19,7 @@ public: int getSelectorColor(); int getSelectedTextColor(); int getDescColor(); + int getFastSelectColor(); bool getHeaderHidden(); bool getDividersHidden(); bool getListCentered(); @@ -43,7 +44,7 @@ private: std::vector mComponentVector; std::string mPath; - int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor; + int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor, mFastSelectColor; bool mHideHeader, mHideDividers, mListCentered; float mListOffsetX, mGameImageOffsetY, mListTextOffsetX;