Added theme tags for the Fast Select GuiBox.

See THEMES.md for more detail.
This commit is contained in:
Aloshi 2012-10-07 17:59:20 -05:00
parent 57461ba676
commit 9b3589a22f
9 changed files with 68 additions and 8 deletions

View file

@ -77,6 +77,24 @@ Display tags must be at the root of the <theme> tree - for example, they can't b
`<gameImageOffsetY>` - the percentage to offset the displayed game image by. Default is the height of the header font. `<gameImageOffsetY>` - 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:
`<boxBackground>` - path to a background image file. ~ and . are expanded.
`<boxBackgroundTiled />` - if present, the background will be tiled instead of stretched.
`<boxHorizontal>` - path to the "left" border image file. It will be flipped for the right border. ~ and . are expanded.
`<boxHorizontalTiled />` - if present, the horizontal image will be tiled instead of stretched downwards.
`<boxVertical>` - path to the "top" border image file. It will be flipped for the bottom border. ~ and . are expanded.
`<boxVerticalTiled />` - if present, the vertical image will be tiled instead of stretched to the right.
`<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.
List of variables List of variables
================= =================

View file

@ -2,6 +2,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.
October 5 October 5
-GuiFastSelect is working, but ugly. -GuiFastSelect is working, but ugly.

View file

@ -1,4 +1,5 @@
#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)
{ {
@ -9,6 +10,14 @@ GuiBox::GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height
mHeight = 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) void GuiBox::setHorizontalImage(std::string path, bool tiled)
{ {
mHorizontalImage.setResize(12, mHeight, true); mHorizontalImage.setResize(12, mHeight, true);

View file

@ -5,11 +5,23 @@
#include "GuiImage.h" #include "GuiImage.h"
#include <string> #include <string>
struct GuiBoxData {
std::string backgroundPath;
bool backgroundTiled;
std::string horizontalPath;
bool horizontalTiled;
std::string verticalPath;
bool verticalTiled;
std::string cornerPath;
};
class GuiBox : public GuiComponent class GuiBox : public GuiComponent
{ {
public: public:
GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height); GuiBox(int offsetX, int offsetY, unsigned int width, unsigned int height);
void setData(GuiBoxData data);
void setBackgroundImage(std::string path, bool tiled = true); void setBackgroundImage(std::string path, bool tiled = true);
void setHorizontalImage(std::string path, bool tiled = false); void setHorizontalImage(std::string path, bool tiled = false);
void setVerticalImage(std::string path, bool tiled = false); void setVerticalImage(std::string path, bool tiled = false);

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) GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data)
{ {
mLetterID = LETTERS.find(toupper(startLetter)); mLetterID = LETTERS.find(toupper(startLetter));
if(mLetterID == std::string::npos) if(mLetterID == std::string::npos)
@ -24,13 +24,9 @@ GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, cha
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
mBox = new GuiBox(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6); mBox = new GuiBox(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6);
mBox->setData(data);
addChild(mBox); addChild(mBox);
//set test mBox info
mBox->setHorizontalImage("left.jpg", false);
mBox->setVerticalImage("top.jpg", false);
mBox->setCornerImage("corner.jpg");
mParent->pause(); mParent->pause();
} }

View file

@ -10,7 +10,7 @@
class GuiFastSelect : GuiComponent class GuiFastSelect : GuiComponent
{ {
public: public:
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter); GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data);
~GuiFastSelect(); ~GuiFastSelect();
void onRender(); void onRender();

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]); new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData());
} }
if(mDetailed) if(mDetailed)

View file

@ -21,6 +21,8 @@ float GuiTheme::getListTextOffsetX() { return mListTextOffsetX; }
int GuiTheme::getSelectedTextColor() { return mListSelectedColor; } int GuiTheme::getSelectedTextColor() { return mListSelectedColor; }
GuiBoxData GuiTheme::getBoxData() { return mBoxData; }
GuiTheme::GuiTheme(std::string path) GuiTheme::GuiTheme(std::string path)
{ {
setDefaults(); setDefaults();
@ -48,6 +50,14 @@ void GuiTheme::setDefaults()
mListOffsetX = 0.5; mListOffsetX = 0.5;
mListTextOffsetX = 0.005; mListTextOffsetX = 0.005;
mGameImageOffsetY = (float)Renderer::getFontHeight(Renderer::LARGE) / Renderer::getScreenHeight(); 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() void GuiTheme::deleteComponents()
@ -101,6 +111,15 @@ void GuiTheme::readXML(std::string path)
mHideDividers = root.child("hideDividers"); mHideDividers = root.child("hideDividers");
mListCentered = !root.child("listLeftAlign"); 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); mListOffsetX = strToFloat(root.child("listOffsetX").text().get(), mListOffsetX);
mGameImageOffsetY = strToFloat(root.child("gameImageOffsetY").text().get(), mGameImageOffsetY); mGameImageOffsetY = strToFloat(root.child("gameImageOffsetY").text().get(), mGameImageOffsetY);
mListTextOffsetX = strToFloat(root.child("listTextOffsetX").text().get(), mListTextOffsetX); mListTextOffsetX = strToFloat(root.child("listTextOffsetX").text().get(), mListTextOffsetX);

View file

@ -3,6 +3,7 @@
#include "../GuiComponent.h" #include "../GuiComponent.h"
#include "../pugiXML/pugixml.hpp" #include "../pugiXML/pugixml.hpp"
#include "GuiBox.h"
//This class loads an XML-defined list of GuiComponents. //This class loads an XML-defined list of GuiComponents.
class GuiTheme : public GuiComponent class GuiTheme : public GuiComponent
@ -25,6 +26,8 @@ public:
float getListOffsetX(); float getListOffsetX();
float getListTextOffsetX(); float getListTextOffsetX();
float getGameImageOffsetY(); float getGameImageOffsetY();
GuiBoxData getBoxData();
private: private:
void setDefaults(); void setDefaults();
void deleteComponents(); void deleteComponents();
@ -44,6 +47,8 @@ private:
bool mHideHeader, mHideDividers, mListCentered; bool mHideHeader, mHideDividers, mListCentered;
float mListOffsetX, mGameImageOffsetY, mListTextOffsetX; float mListOffsetX, mGameImageOffsetY, mListTextOffsetX;
GuiBoxData mBoxData;
}; };
#endif #endif