Commit 9b3589a2 authored by Aloshi's avatar Aloshi

Added theme tags for the Fast Select GuiBox.

See THEMES.md for more detail.
parent 57461ba6
......@@ -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.
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
=================
......
......@@ -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.
......
#include "GuiBox.h"
#include <iostream>
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);
......
......@@ -5,11 +5,23 @@
#include "GuiImage.h"
#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
{
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);
......
......@@ -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<FileData*>* list, char startLetter)
GuiFastSelect::GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data)
{
mLetterID = LETTERS.find(toupper(startLetter));
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();
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();
}
......
......@@ -10,7 +10,7 @@
class GuiFastSelect : GuiComponent
{
public:
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter);
GuiFastSelect(GuiComponent* parent, GuiList<FileData*>* list, char startLetter, GuiBoxData data);
~GuiFastSelect();
void onRender();
......
......@@ -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)
......
......@@ -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);
......
......@@ -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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment