Added theming tag for the Fast Select box's text color.

This commit is contained in:
Aloshi 2012-10-10 08:51:48 -05:00
parent 9b3589a22f
commit 6de46003d9
11 changed files with 47 additions and 14 deletions

View file

@ -81,6 +81,8 @@ Display tags must be at the root of the <theme> tree - for example, they can't b
The Fast Select box can be themed with these tags: The Fast Select box can be themed with these tags:
`<fastSelectColor>` - the hex color to use for the letter display on the Fast Select box.
`<boxBackground>` - path to a background image file. ~ and . are expanded. `<boxBackground>` - path to a background image file. ~ and . are expanded.
`<boxBackgroundTiled />` - if present, the background will be tiled instead of stretched. `<boxBackgroundTiled />` - if present, the background will be tiled instead of stretched.
@ -95,6 +97,10 @@ The Fast Select box can be themed with these tags:
`<boxCorner>` - 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. `<boxCorner>` - 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 List of variables
================= =================

View file

@ -1,8 +1,11 @@
October 10
-Added a theming tag for the Fast Select box's text.
October 7 October 7
-Fixed borders for GuiBox. The right and bottom borders are flipped, too. -Fixed borders for GuiBox. The right and bottom borders are flipped, too.
-Added corners for GuiBox. -Added corners for GuiBox.
-Added setFlipX() and setFlipY() to the GuiImage class. -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 October 5
-GuiFastSelect is working, but ugly. -GuiFastSelect is working, but ugly.

View file

@ -1,5 +1,4 @@
#include "GuiBox.h" #include "GuiBox.h"
#include <iostream>
GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height) 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) void GuiBox::setHorizontalImage(std::string path, bool tiled)
{ {
mHorizontalImage.setResize(12, mHeight, true);
mHorizontalImage.setTiling(tiled); mHorizontalImage.setTiling(tiled);
mHorizontalImage.setOrigin(0, 0); mHorizontalImage.setOrigin(0, 0);
mHorizontalImage.setImage(path); mHorizontalImage.setImage(path);
mHorizontalImage.setResize(mHorizontalImage.getHeight(), mHeight, true);
} }
void GuiBox::setVerticalImage(std::string path, bool tiled) void GuiBox::setVerticalImage(std::string path, bool tiled)
{ {
mVerticalImage.setResize(mWidth, 12, true);
mVerticalImage.setTiling(tiled); mVerticalImage.setTiling(tiled);
mVerticalImage.setOrigin(0, 0); mVerticalImage.setOrigin(0, 0);
mVerticalImage.setImage(path); mVerticalImage.setImage(path);
mVerticalImage.setResize(mWidth, mVerticalImage.getHeight(), true);
} }
void GuiBox::setBackgroundImage(std::string path, bool tiled) void GuiBox::setBackgroundImage(std::string path, bool tiled)
@ -56,6 +55,8 @@ void GuiBox::setCornerImage(std::string path)
void GuiBox::onRender() void GuiBox::onRender()
{ {
mBackgroundImage.render();
//left border //left border
mHorizontalImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth()); mHorizontalImage.setOffsetX(getOffsetX() - getHorizontalBorderWidth());
mHorizontalImage.setOffsetY(getOffsetY()); mHorizontalImage.setOffsetY(getOffsetY());
@ -123,10 +124,15 @@ void GuiBox::onDeinit()
int GuiBox::getHorizontalBorderWidth() int GuiBox::getHorizontalBorderWidth()
{ {
return 12; return mHorizontalImage.getWidth();
} }
int GuiBox::getVerticalBorderWidth() int GuiBox::getVerticalBorderWidth()
{ {
return 12; return mVerticalImage.getHeight();
}
bool GuiBox::hasBackground()
{
return mBackgroundImage.hasImage();
} }

View file

@ -27,6 +27,8 @@ public:
void setVerticalImage(std::string path, bool tiled = false); void setVerticalImage(std::string path, bool tiled = false);
void setCornerImage(std::string path); void setCornerImage(std::string path);
bool hasBackground();
void onRender(); void onRender();
void onInit(); void onInit();

View file

@ -6,7 +6,7 @@ const std::string GuiFastSelect::LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int GuiFastSelect::SCROLLSPEED = 100; const int GuiFastSelect::SCROLLSPEED = 100;
const int GuiFastSelect::SCROLLDELAY = 507; const int GuiFastSelect::SCROLLDELAY = 507;
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data) GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor)
{ {
mLetterID = LETTERS.find(toupper(startLetter)); mLetterID = LETTERS.find(toupper(startLetter));
if(mLetterID == std::string::npos) if(mLetterID == std::string::npos)
@ -27,6 +27,8 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
mBox->setData(data); mBox->setData(data);
addChild(mBox); addChild(mBox);
mTextColor = textcolor;
mParent->pause(); mParent->pause();
} }
@ -45,8 +47,10 @@ void GuiFastSelect::onRender()
{ {
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
if(!mBox->hasBackground())
Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0); 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);
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) void GuiFastSelect::onInput(InputManager::InputButton button, bool keyDown)

View file

@ -10,7 +10,7 @@
class GuiFastSelect : GuiComponent class GuiFastSelect : GuiComponent
{ {
public: public:
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data); GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data, int textcolor);
~GuiFastSelect(); ~GuiFastSelect();
void onRender(); void onRender();
@ -31,6 +31,7 @@ private:
GuiComponent* mParent; GuiComponent* mParent;
GuiBox* mBox; GuiBox* mBox;
int mTextColor;
int mScrollTimer, mScrollOffset; int mScrollTimer, mScrollOffset;
bool mScrolling; bool mScrolling;

View file

@ -154,7 +154,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
if(button == InputManager::SELECT && 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) if(mDetailed)

View file

@ -3,8 +3,8 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <math.h> #include <math.h>
unsigned int GuiImage::getWidth() { return mWidth; } unsigned int GuiImage::getWidth() { return mDrawWidth; }
unsigned int GuiImage::getHeight() { return mHeight; } unsigned int GuiImage::getHeight() { return mDrawHeight; }
GuiImage::GuiImage(int offsetX, int offsetY, std::string path, unsigned int resizeWidth, unsigned int resizeHeight, bool resizeExact) 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(); unloadImage();
} }
bool GuiImage::hasImage()
{
return !mPath.empty();
}

View file

@ -27,6 +27,8 @@ public:
unsigned int getWidth(); //Returns render width in pixels. May be different than actual texture width. 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. unsigned int getHeight(); //Returns render height in pixels. May be different than actual texture height.
bool hasImage();
void onRender(); void onRender();
//Image textures will be deleted on renderer deinitialization, and recreated on reinitialization (if mPath is not empty). //Image textures will be deleted on renderer deinitialization, and recreated on reinitialization (if mPath is not empty).

View file

@ -11,6 +11,7 @@ int GuiTheme::getPrimaryColor() { return mListPrimaryColor; }
int GuiTheme::getSecondaryColor() { return mListSecondaryColor; } int GuiTheme::getSecondaryColor() { return mListSecondaryColor; }
int GuiTheme::getSelectorColor() { return mListSelectorColor; } int GuiTheme::getSelectorColor() { return mListSelectorColor; }
int GuiTheme::getDescColor() { return mDescColor; } int GuiTheme::getDescColor() { return mDescColor; }
int GuiTheme::getFastSelectColor() { return mFastSelectColor; }
bool GuiTheme::getHeaderHidden() { return mHideHeader; } bool GuiTheme::getHeaderHidden() { return mHideHeader; }
bool GuiTheme::getDividersHidden() { return mHideDividers; } bool GuiTheme::getDividersHidden() { return mHideDividers; }
bool GuiTheme::getListCentered() { return mListCentered; } bool GuiTheme::getListCentered() { return mListCentered; }
@ -43,6 +44,7 @@ void GuiTheme::setDefaults()
mListSelectorColor = 0x000000; mListSelectorColor = 0x000000;
mListSelectedColor = -1; //-1 = use original list color when selected mListSelectedColor = -1; //-1 = use original list color when selected
mDescColor = 0x0000FF; mDescColor = 0x0000FF;
mFastSelectColor = 0xFF0000;
mHideHeader = false; mHideHeader = false;
mHideDividers = false; mHideDividers = false;
mListCentered = true; mListCentered = true;
@ -107,6 +109,7 @@ void GuiTheme::readXML(std::string path)
mListSelectorColor = resolveColor(root.child("listSelectorColor").text().get(), mListSelectorColor); mListSelectorColor = resolveColor(root.child("listSelectorColor").text().get(), mListSelectorColor);
mListSelectedColor = resolveColor(root.child("listSelectedColor").text().get(), mListSelectedColor); mListSelectedColor = resolveColor(root.child("listSelectedColor").text().get(), mListSelectedColor);
mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor); mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor);
mFastSelectColor = resolveColor(root.child("fastSelectColor").text().get(), mFastSelectColor);
mHideHeader = root.child("hideHeader"); mHideHeader = root.child("hideHeader");
mHideDividers = root.child("hideDividers"); mHideDividers = root.child("hideDividers");
mListCentered = !root.child("listLeftAlign"); mListCentered = !root.child("listLeftAlign");

View file

@ -19,6 +19,7 @@ public:
int getSelectorColor(); int getSelectorColor();
int getSelectedTextColor(); int getSelectedTextColor();
int getDescColor(); int getDescColor();
int getFastSelectColor();
bool getHeaderHidden(); bool getHeaderHidden();
bool getDividersHidden(); bool getDividersHidden();
bool getListCentered(); bool getListCentered();
@ -43,7 +44,7 @@ private:
std::vector<GuiComponent*> mComponentVector; std::vector<GuiComponent*> mComponentVector;
std::string mPath; std::string mPath;
int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor; int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor, mFastSelectColor;
bool mHideHeader, mHideDividers, mListCentered; bool mHideHeader, mHideDividers, mListCentered;
float mListOffsetX, mGameImageOffsetY, mListTextOffsetX; float mListOffsetX, mGameImageOffsetY, mListTextOffsetX;