mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-25 23:55:38 +00:00
Heavily refactored how theming data is accessed.
This commit is contained in:
parent
6e31f17c3b
commit
989ba9a8f9
|
@ -1,5 +1,6 @@
|
||||||
November 17
|
November 17
|
||||||
-Fixed default game image resizing if none is defined.
|
-Fixed default game image resizing if none is defined.
|
||||||
|
-Heavily refactored theming. You shouldn't notice any changes, but if something broke, let me know!
|
||||||
|
|
||||||
November 14
|
November 14
|
||||||
-Added Exit command to the menu.
|
-Added Exit command to the menu.
|
||||||
|
|
|
@ -5,9 +5,6 @@
|
||||||
#include "GuiFastSelect.h"
|
#include "GuiFastSelect.h"
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
//this is just a default value; the true value is in mTheme->getListOffsetX();
|
|
||||||
const float GuiGameList::sInfoWidth = 0.5;
|
|
||||||
|
|
||||||
|
|
||||||
GuiGameList::GuiGameList(bool useDetail)
|
GuiGameList::GuiGameList(bool useDetail)
|
||||||
{
|
{
|
||||||
|
@ -21,10 +18,10 @@ GuiGameList::GuiGameList(bool useDetail)
|
||||||
//Those with smaller displays may prefer the older view.
|
//Those with smaller displays may prefer the older view.
|
||||||
if(mDetailed)
|
if(mDetailed)
|
||||||
{
|
{
|
||||||
mList = new GuiList<FileData*>(Renderer::getScreenWidth() * sInfoWidth, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM));
|
mList = new GuiList<FileData*>(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX"), Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, Renderer::getDefaultFont(Renderer::MEDIUM));
|
||||||
|
|
||||||
mScreenshot = new GuiImage(Renderer::getScreenWidth() * mTheme->getGameImageOffsetX(), Renderer::getScreenHeight() * mTheme->getGameImageOffsetY(), "", mTheme->getGameImageWidth(), mTheme->getGameImageHeight(), false);
|
mScreenshot = new GuiImage(Renderer::getScreenWidth() * mTheme->getFloat("gameImageOffsetX"), Renderer::getScreenHeight() * mTheme->getFloat("gameImageOffsetY"), "", mTheme->getFloat("gameImageWidth"), mTheme->getFloat("gameImageHeight"), false);
|
||||||
mScreenshot->setOrigin(mTheme->getGameImageOriginX(), mTheme->getGameImageOriginY());
|
mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY"));
|
||||||
//addChild(mScreenshot);
|
//addChild(mScreenshot);
|
||||||
|
|
||||||
//the animation renders the screenshot
|
//the animation renders the screenshot
|
||||||
|
@ -93,14 +90,14 @@ void GuiGameList::onRender()
|
||||||
mTheme->render();
|
mTheme->render();
|
||||||
|
|
||||||
//header
|
//header
|
||||||
if(!mTheme->getHeaderHidden())
|
if(!mTheme->getBool("hideHeader"))
|
||||||
Renderer::drawCenteredText(mSystem->getName(), 0, 1, 0xFF0000FF, Renderer::getDefaultFont(Renderer::LARGE));
|
Renderer::drawCenteredText(mSystem->getName(), 0, 1, 0xFF0000FF, Renderer::getDefaultFont(Renderer::LARGE));
|
||||||
|
|
||||||
if(mDetailed)
|
if(mDetailed)
|
||||||
{
|
{
|
||||||
//divider
|
//divider
|
||||||
if(!mTheme->getDividersHidden())
|
if(!mTheme->getBool("hideDividers"))
|
||||||
Renderer::drawRect(Renderer::getScreenWidth() * mTheme->getListOffsetX() - 4, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, 8, Renderer::getScreenHeight(), 0x0000FFFF);
|
Renderer::drawRect(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX") - 4, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, 8, Renderer::getScreenHeight(), 0x0000FFFF);
|
||||||
|
|
||||||
//if we're not scrolling and we have selected a non-folder
|
//if we're not scrolling and we have selected a non-folder
|
||||||
if(!mList->isScrolling() && mList->getSelectedObject() && !mList->getSelectedObject()->isFolder())
|
if(!mList->isScrolling() && mList->getSelectedObject() && !mList->getSelectedObject()->isFolder())
|
||||||
|
@ -109,7 +106,7 @@ void GuiGameList::onRender()
|
||||||
|
|
||||||
std::string desc = game->getDescription();
|
std::string desc = game->getDescription();
|
||||||
if(!desc.empty())
|
if(!desc.empty())
|
||||||
Renderer::drawWrappedText(desc, Renderer::getScreenWidth() * 0.03, mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, Renderer::getScreenWidth() * (mTheme->getListOffsetX() - 0.03), mTheme->getDescColor(), mTheme->getDescriptionFont());
|
Renderer::drawWrappedText(desc, Renderer::getScreenWidth() * 0.03, mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03), mTheme->getColor("description"), mTheme->getDescriptionFont());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,7 +118,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
||||||
if(!keyDown)
|
if(!keyDown)
|
||||||
{
|
{
|
||||||
//play select sound
|
//play select sound
|
||||||
mTheme->getMenuSelectSound()->play();
|
mTheme->getSound("menuSelect")->play();
|
||||||
|
|
||||||
FileData* file = mList->getSelectedObject();
|
FileData* file = mList->getSelectedObject();
|
||||||
if(file->isFolder()) //if you selected a folder, add this directory to the stack, and use the selected one
|
if(file->isFolder()) //if you selected a folder, add this directory to the stack, and use the selected one
|
||||||
|
@ -133,7 +130,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
||||||
mList->stopScrolling();
|
mList->stopScrolling();
|
||||||
|
|
||||||
//wait for the sound to finish or we'll never hear it...
|
//wait for the sound to finish or we'll never hear it...
|
||||||
while(mTheme->getMenuSelectSound()->isPlaying());
|
while(mTheme->getSound("menuSelect")->isPlaying());
|
||||||
|
|
||||||
mSystem->launchGame((GameData*)file);
|
mSystem->launchGame((GameData*)file);
|
||||||
}
|
}
|
||||||
|
@ -149,7 +146,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
||||||
updateDetailData();
|
updateDetailData();
|
||||||
|
|
||||||
//play the back sound
|
//play the back sound
|
||||||
mTheme->getMenuBackSound()->play();
|
mTheme->getSound("menuBack")->play();
|
||||||
}
|
}
|
||||||
|
|
||||||
//only allow switching systems if more than one exists (otherwise it'll reset your position when you switch and it's annoying)
|
//only allow switching systems if more than one exists (otherwise it'll reset your position when you switch and it's annoying)
|
||||||
|
@ -174,7 +171,7 @@ void GuiGameList::onInput(InputManager::InputButton button, bool keyDown)
|
||||||
//open the fast select menu
|
//open the fast select menu
|
||||||
if(button == InputManager::SELECT && keyDown)
|
if(button == InputManager::SELECT && keyDown)
|
||||||
{
|
{
|
||||||
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getFastSelectColor(), mTheme->getMenuScrollSound());
|
new GuiFastSelect(this, mList, mList->getSelectedObject()->getName()[0], mTheme->getBoxData(), mTheme->getColor("fastSelect"), mTheme->getSound("menuScroll"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mDetailed)
|
if(mDetailed)
|
||||||
|
@ -201,9 +198,9 @@ void GuiGameList::updateList()
|
||||||
FileData* file = mFolder->getFile(i);
|
FileData* file = mFolder->getFile(i);
|
||||||
|
|
||||||
if(file->isFolder())
|
if(file->isFolder())
|
||||||
mList->addObject(file->getName(), file, mTheme->getSecondaryColor());
|
mList->addObject(file->getName(), file, mTheme->getColor("secondary"));
|
||||||
else
|
else
|
||||||
mList->addObject(file->getName(), file, mTheme->getPrimaryColor());
|
mList->addObject(file->getName(), file, mTheme->getColor("primary"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,24 +220,24 @@ void GuiGameList::updateTheme()
|
||||||
else
|
else
|
||||||
mTheme->readXML(""); //clears any current theme
|
mTheme->readXML(""); //clears any current theme
|
||||||
|
|
||||||
mList->setSelectorColor(mTheme->getSelectorColor());
|
mList->setSelectorColor(mTheme->getColor("selector"));
|
||||||
mList->setSelectedTextColor(mTheme->getSelectedTextColor());
|
mList->setSelectedTextColor(mTheme->getColor("selected"));
|
||||||
mList->setScrollSound(mTheme->getMenuScrollSound());
|
mList->setScrollSound(mTheme->getSound("menuScroll"));
|
||||||
|
|
||||||
//fonts
|
//fonts
|
||||||
mList->setFont(mTheme->getListFont());
|
mList->setFont(mTheme->getListFont());
|
||||||
|
|
||||||
if(mDetailed)
|
if(mDetailed)
|
||||||
{
|
{
|
||||||
mList->setCentered(mTheme->getListCentered());
|
mList->setCentered(mTheme->getBool("listCentered"));
|
||||||
|
|
||||||
mList->setOffsetX(mTheme->getListOffsetX() * Renderer::getScreenWidth());
|
mList->setOffsetX(mTheme->getFloat("listOffsetX") * Renderer::getScreenWidth());
|
||||||
mList->setTextOffsetX(mTheme->getListTextOffsetX() * Renderer::getScreenWidth());
|
mList->setTextOffsetX(mTheme->getFloat("listTextOffsetX") * Renderer::getScreenWidth());
|
||||||
|
|
||||||
mScreenshot->setOffsetX(mTheme->getGameImageOffsetX() * Renderer::getScreenWidth());
|
mScreenshot->setOffsetX(mTheme->getFloat("gameImageOffsetX") * Renderer::getScreenWidth());
|
||||||
mScreenshot->setOffsetY(mTheme->getGameImageOffsetY() * Renderer::getScreenHeight());
|
mScreenshot->setOffsetY(mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight());
|
||||||
mScreenshot->setOrigin(mTheme->getGameImageOriginX(), mTheme->getGameImageOriginY());
|
mScreenshot->setOrigin(mTheme->getFloat("gameImageOriginX"), mTheme->getFloat("gameImageOriginY"));
|
||||||
mScreenshot->setResize(mTheme->getGameImageWidth(), mTheme->getGameImageHeight(), false);
|
mScreenshot->setResize(mTheme->getFloat("gameImageWidth"), mTheme->getFloat("gameImageHeight"), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,10 +248,10 @@ void GuiGameList::updateDetailData()
|
||||||
|
|
||||||
if(mList->getSelectedObject() && !mList->getSelectedObject()->isFolder())
|
if(mList->getSelectedObject() && !mList->getSelectedObject()->isFolder())
|
||||||
{
|
{
|
||||||
mScreenshot->setOffset((mTheme->getGameImageOffsetX() - 0.05) * Renderer::getScreenWidth(), mTheme->getGameImageOffsetY() * Renderer::getScreenHeight());
|
mScreenshot->setOffset((mTheme->getFloat("gameImageOffsetX") - 0.05) * Renderer::getScreenWidth(), mTheme->getFloat("gameImageOffsetY") * Renderer::getScreenHeight());
|
||||||
|
|
||||||
if(((GameData*)mList->getSelectedObject())->getImagePath().empty())
|
if(((GameData*)mList->getSelectedObject())->getImagePath().empty())
|
||||||
mScreenshot->setImage(mTheme->getImageNotFoundPath());
|
mScreenshot->setImage(mTheme->getString("imageNotFoundPath"));
|
||||||
else
|
else
|
||||||
mScreenshot->setImage(((GameData*)mList->getSelectedObject())->getImagePath());
|
mScreenshot->setImage(((GameData*)mList->getSelectedObject())->getImagePath());
|
||||||
|
|
||||||
|
@ -277,7 +274,7 @@ void GuiGameList::clearDetailData()
|
||||||
void GuiGameList::onPause()
|
void GuiGameList::onPause()
|
||||||
{
|
{
|
||||||
mList->stopScrolling();
|
mList->stopScrolling();
|
||||||
mTheme->getMenuOpenSound()->play();
|
mTheme->getSound("menuOpenSound")->play();
|
||||||
InputManager::unregisterComponent(this);
|
InputManager::unregisterComponent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,35 +7,36 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "../Renderer.h"
|
#include "../Renderer.h"
|
||||||
|
|
||||||
unsigned int GuiTheme::getPrimaryColor() { return mListPrimaryColor; }
|
//really, this should all be refactored into "getColor("attribName")" and such,
|
||||||
unsigned int GuiTheme::getSecondaryColor() { return mListSecondaryColor; }
|
//but it's a little late now.
|
||||||
unsigned int GuiTheme::getSelectorColor() { return mListSelectorColor; }
|
|
||||||
unsigned int GuiTheme::getDescColor() { return mDescColor; }
|
|
||||||
unsigned int GuiTheme::getFastSelectColor() { return mFastSelectColor; }
|
|
||||||
bool GuiTheme::getHeaderHidden() { return mHideHeader; }
|
|
||||||
bool GuiTheme::getDividersHidden() { return mHideDividers; }
|
|
||||||
bool GuiTheme::getListCentered() { return mListCentered; }
|
|
||||||
float GuiTheme::getListOffsetX() { return mListOffsetX; }
|
|
||||||
float GuiTheme::getListTextOffsetX() { return mListTextOffsetX; }
|
|
||||||
|
|
||||||
unsigned int GuiTheme::getSelectedTextColor() { return mListSelectedColor; }
|
unsigned int GuiTheme::getColor(std::string name)
|
||||||
|
{
|
||||||
|
return mColorMap[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GuiTheme::getBool(std::string name)
|
||||||
|
{
|
||||||
|
return mBoolMap[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
float GuiTheme::getFloat(std::string name)
|
||||||
|
{
|
||||||
|
return mFloatMap[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
Sound* GuiTheme::getSound(std::string name)
|
||||||
|
{
|
||||||
|
return mSoundMap[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string GuiTheme::getString(std::string name)
|
||||||
|
{
|
||||||
|
return mStringMap[name];
|
||||||
|
}
|
||||||
|
|
||||||
GuiBoxData GuiTheme::getBoxData() { return mBoxData; }
|
GuiBoxData GuiTheme::getBoxData() { return mBoxData; }
|
||||||
|
|
||||||
Sound* GuiTheme::getMenuScrollSound() { return &mMenuScrollSound; }
|
|
||||||
Sound* GuiTheme::getMenuSelectSound() { return &mMenuSelectSound; }
|
|
||||||
Sound* GuiTheme::getMenuBackSound() { return &mMenuBackSound; }
|
|
||||||
Sound* GuiTheme::getMenuOpenSound() { return &mMenuOpenSound; }
|
|
||||||
|
|
||||||
float GuiTheme::getGameImageOffsetX() { return mGameImageOffsetX; }
|
|
||||||
float GuiTheme::getGameImageOffsetY() { return mGameImageOffsetY; }
|
|
||||||
float GuiTheme::getGameImageWidth() { return mGameImageWidth; }
|
|
||||||
float GuiTheme::getGameImageHeight() { return mGameImageHeight; }
|
|
||||||
float GuiTheme::getGameImageOriginX() { return mGameImageOriginX; }
|
|
||||||
float GuiTheme::getGameImageOriginY() { return mGameImageOriginY; }
|
|
||||||
|
|
||||||
std::string GuiTheme::getImageNotFoundPath() { return mImageNotFoundPath; }
|
|
||||||
|
|
||||||
Font* GuiTheme::getListFont()
|
Font* GuiTheme::getListFont()
|
||||||
{
|
{
|
||||||
if(mListFont == NULL)
|
if(mListFont == NULL)
|
||||||
|
@ -54,6 +55,11 @@ Font* GuiTheme::getDescriptionFont()
|
||||||
|
|
||||||
GuiTheme::GuiTheme(std::string path)
|
GuiTheme::GuiTheme(std::string path)
|
||||||
{
|
{
|
||||||
|
mSoundMap["menuScroll"] = new Sound();
|
||||||
|
mSoundMap["menuSelect"] = new Sound();
|
||||||
|
mSoundMap["menuBack"] = new Sound();
|
||||||
|
mSoundMap["menuOpen"] = new Sound();
|
||||||
|
|
||||||
mListFont = NULL;
|
mListFont = NULL;
|
||||||
mDescFont = NULL;
|
mDescFont = NULL;
|
||||||
|
|
||||||
|
@ -70,25 +76,32 @@ GuiTheme::~GuiTheme()
|
||||||
|
|
||||||
void GuiTheme::setDefaults()
|
void GuiTheme::setDefaults()
|
||||||
{
|
{
|
||||||
mListPrimaryColor = 0x0000FFFF;
|
mColorMap["primary"] = 0x0000FFFF;
|
||||||
mListSecondaryColor = 0x00FF00FF;
|
mColorMap["secondary"] = 0x00FF00FF;
|
||||||
mListSelectorColor = 0x000000FF;
|
mColorMap["selector"] = 0x000000FF;
|
||||||
mListSelectedColor = 0xFF0000FF;
|
mColorMap["selected"] = 0xFF0000FF;
|
||||||
mDescColor = 0x0000FFFF;
|
mColorMap["description"] = 0x0000FFFF;
|
||||||
mFastSelectColor = 0xFF0000FF;
|
mColorMap["fastSelect"] = 0xFF0000FF;
|
||||||
mHideHeader = false;
|
|
||||||
mHideDividers = false;
|
|
||||||
mListCentered = true;
|
|
||||||
|
|
||||||
mListOffsetX = 0.5;
|
mBoolMap["hideHeader"] = false;
|
||||||
mListTextOffsetX = 0.005;
|
mBoolMap["hideDividers"] = false;
|
||||||
|
mBoolMap["listCentered"] = true;
|
||||||
|
|
||||||
mGameImageOriginX = 0.5;
|
mFloatMap["listOffsetX"] = 0.5;
|
||||||
mGameImageOriginY = 0;
|
mFloatMap["listTextOffsetX"] = 0.005;
|
||||||
mGameImageOffsetX = mListOffsetX / 2;
|
mFloatMap["gameImageOriginX"] = 0.5;
|
||||||
mGameImageOffsetY = (float)Renderer::getDefaultFont(Renderer::LARGE)->getHeight() / Renderer::getScreenHeight();
|
mFloatMap["gameImageOriginY"] = 0;
|
||||||
mGameImageWidth = mListOffsetX;
|
mFloatMap["gameImageOffsetX"] = mFloatMap["listOffsetX"] / 2;
|
||||||
mGameImageHeight = 0;
|
mFloatMap["gameImageOffsetY"] = (float)Renderer::getDefaultFont(Renderer::LARGE)->getHeight() / (float)Renderer::getScreenHeight();
|
||||||
|
mFloatMap["gameImageWidth"] = mFloatMap["listOffsetX"];
|
||||||
|
mFloatMap["gameImageHeight"] = 0;
|
||||||
|
|
||||||
|
mSoundMap["menuScroll"]->loadFile("");
|
||||||
|
mSoundMap["menuSelect"]->loadFile("");
|
||||||
|
mSoundMap["menuBack"]->loadFile("");
|
||||||
|
mSoundMap["menuOpen"]->loadFile("");
|
||||||
|
|
||||||
|
mStringMap["imageNotFoundPath"] = "";
|
||||||
|
|
||||||
mBoxData.backgroundPath = "";
|
mBoxData.backgroundPath = "";
|
||||||
mBoxData.backgroundTiled = false;
|
mBoxData.backgroundTiled = false;
|
||||||
|
@ -98,13 +111,6 @@ void GuiTheme::setDefaults()
|
||||||
mBoxData.verticalTiled = false;
|
mBoxData.verticalTiled = false;
|
||||||
mBoxData.cornerPath = "";
|
mBoxData.cornerPath = "";
|
||||||
|
|
||||||
mMenuScrollSound.loadFile("");
|
|
||||||
mMenuSelectSound.loadFile("");
|
|
||||||
mMenuBackSound.loadFile("");
|
|
||||||
mMenuOpenSound.loadFile("");
|
|
||||||
|
|
||||||
mImageNotFoundPath = "";
|
|
||||||
|
|
||||||
if(mListFont != NULL)
|
if(mListFont != NULL)
|
||||||
{
|
{
|
||||||
delete mListFont;
|
delete mListFont;
|
||||||
|
@ -160,14 +166,15 @@ void GuiTheme::readXML(std::string path)
|
||||||
pugi::xml_node root = doc.child("theme");
|
pugi::xml_node root = doc.child("theme");
|
||||||
|
|
||||||
//load non-component theme stuff
|
//load non-component theme stuff
|
||||||
mListPrimaryColor = resolveColor(root.child("listPrimaryColor").text().get(), mListPrimaryColor);
|
mColorMap["primary"] = resolveColor(root.child("listPrimaryColor").text().get(), mColorMap["primary"]);
|
||||||
mListSecondaryColor = resolveColor(root.child("listSecondaryColor").text().get(), mListSecondaryColor);
|
mColorMap["secondary"] = resolveColor(root.child("listSecondaryColor").text().get(), mColorMap["secondary"]);
|
||||||
mListSelectorColor = resolveColor(root.child("listSelectorColor").text().get(), mListSelectorColor);
|
mColorMap["selector"] = resolveColor(root.child("listSelectorColor").text().get(), mColorMap["selector"]);
|
||||||
mListSelectedColor = resolveColor(root.child("listSelectedColor").text().get(), mListPrimaryColor);
|
mColorMap["selected"] = resolveColor(root.child("listSelectedColor").text().get(), mColorMap["primary"]);
|
||||||
mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor);
|
mColorMap["description"] = resolveColor(root.child("descColor").text().get(), mColorMap["description"]);
|
||||||
mFastSelectColor = resolveColor(root.child("fastSelectColor").text().get(), mFastSelectColor);
|
mColorMap["fastSelect"] = resolveColor(root.child("fastSelectColor").text().get(), mColorMap["fastSelect"]);
|
||||||
mHideHeader = root.child("hideHeader");
|
|
||||||
mHideDividers = root.child("hideDividers");
|
mBoolMap["hideHeader"] = root.child("hideHeader");
|
||||||
|
mBoolMap["hideDividers"] = root.child("hideDividers");
|
||||||
|
|
||||||
//GuiBox theming data
|
//GuiBox theming data
|
||||||
mBoxData.backgroundPath = expandPath(root.child("boxBackground").text().get());
|
mBoxData.backgroundPath = expandPath(root.child("boxBackground").text().get());
|
||||||
|
@ -179,9 +186,9 @@ void GuiTheme::readXML(std::string path)
|
||||||
mBoxData.cornerPath = expandPath(root.child("boxCorner").text().get());
|
mBoxData.cornerPath = expandPath(root.child("boxCorner").text().get());
|
||||||
|
|
||||||
//list stuff
|
//list stuff
|
||||||
mListCentered = !root.child("listLeftAlign");
|
mBoolMap["listCentered"] = !root.child("listLeftAlign");
|
||||||
mListOffsetX = strToFloat(root.child("listOffsetX").text().get(), mListOffsetX);
|
mFloatMap["listOffsetX"] = strToFloat(root.child("listOffsetX").text().get(), mFloatMap["listOffsetX"]);
|
||||||
mListTextOffsetX = strToFloat(root.child("listTextOffsetX").text().get(), mListTextOffsetX);
|
mFloatMap["listTextOffsetX"] = strToFloat(root.child("listTextOffsetX").text().get(), mFloatMap["listTextOffsetX"]);
|
||||||
|
|
||||||
//game image stuff
|
//game image stuff
|
||||||
std::string artPos = root.child("gameImagePos").text().get();
|
std::string artPos = root.child("gameImagePos").text().get();
|
||||||
|
@ -193,20 +200,20 @@ void GuiTheme::readXML(std::string path)
|
||||||
splitString(artDim, ' ', &artWidth, &artHeight);
|
splitString(artDim, ' ', &artWidth, &artHeight);
|
||||||
splitString(artOrigin, ' ', &artOriginX, &artOriginY);
|
splitString(artOrigin, ' ', &artOriginX, &artOriginY);
|
||||||
|
|
||||||
mGameImageOffsetX = resolveExp(artPosX, mGameImageOffsetX);
|
mFloatMap["gameImageOffsetX"] = resolveExp(artPosX, mFloatMap["gameImageOffsetX"]);
|
||||||
mGameImageOffsetY = resolveExp(artPosY, mGameImageOffsetY);
|
mFloatMap["gameImageOffsetY"] = resolveExp(artPosY, mFloatMap["gameImageOffsetY"]);
|
||||||
mGameImageWidth = resolveExp(artWidth, mGameImageWidth);
|
mFloatMap["gameImageWidth"] = resolveExp(artWidth, mFloatMap["gameImageWidth"]);
|
||||||
mGameImageHeight = resolveExp(artHeight, mGameImageHeight);
|
mFloatMap["gameImageHeight"] = resolveExp(artHeight, mFloatMap["gameImageHeight"]);
|
||||||
mGameImageOriginX = resolveExp(artOriginX, mGameImageOriginX);
|
mFloatMap["gameImageOriginX"] = resolveExp(artOriginX, mFloatMap["gameImageOriginX"]);
|
||||||
mGameImageOriginY = resolveExp(artOriginY, mGameImageOriginY);
|
mFloatMap["gameImageOriginY"] = resolveExp(artOriginY, mFloatMap["gameImageOriginY"]);
|
||||||
|
|
||||||
mImageNotFoundPath = expandPath(root.child("gameImageNotFound").text().get());
|
mStringMap["imageNotFoundPath"] = expandPath(root.child("gameImageNotFound").text().get());
|
||||||
|
|
||||||
//sounds
|
//sounds
|
||||||
mMenuScrollSound.loadFile(expandPath(root.child("menuScrollSound").text().get()));
|
mSoundMap["menuScroll"]->loadFile(expandPath(root.child("menuScrollSound").text().get()));
|
||||||
mMenuSelectSound.loadFile(expandPath(root.child("menuSelectSound").text().get()));
|
mSoundMap["menuSelect"]->loadFile(expandPath(root.child("menuSelectSound").text().get()));
|
||||||
mMenuBackSound.loadFile(expandPath(root.child("menuBackSound").text().get()));
|
mSoundMap["menuBack"]->loadFile(expandPath(root.child("menuBackSound").text().get()));
|
||||||
mMenuOpenSound.loadFile(expandPath(root.child("menuOpenSound").text().get()));
|
mSoundMap["menuOpen"]->loadFile(expandPath(root.child("menuOpenSound").text().get()));
|
||||||
|
|
||||||
//fonts
|
//fonts
|
||||||
mListFont = resolveFont(root.child("listFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::MEDIUM)->getSize());
|
mListFont = resolveFont(root.child("listFont"), Font::getDefaultPath(), Renderer::getDefaultFont(Renderer::MEDIUM)->getSize());
|
||||||
|
@ -305,7 +312,7 @@ float GuiTheme::resolveExp(std::string str, float defaultVal)
|
||||||
|
|
||||||
//set variables
|
//set variables
|
||||||
exp.setVariable("headerHeight", Renderer::getDefaultFont(Renderer::LARGE)->getHeight() / Renderer::getScreenHeight());
|
exp.setVariable("headerHeight", Renderer::getDefaultFont(Renderer::LARGE)->getHeight() / Renderer::getScreenHeight());
|
||||||
exp.setVariable("infoWidth", mListOffsetX);
|
exp.setVariable("infoWidth", mFloatMap["listOffsetX"]);
|
||||||
|
|
||||||
return exp.eval();
|
return exp.eval();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,34 +16,13 @@ public:
|
||||||
|
|
||||||
void readXML(std::string path);
|
void readXML(std::string path);
|
||||||
|
|
||||||
unsigned int getPrimaryColor();
|
|
||||||
unsigned int getSecondaryColor();
|
|
||||||
unsigned int getSelectorColor();
|
|
||||||
unsigned int getSelectedTextColor();
|
|
||||||
unsigned int getDescColor();
|
|
||||||
unsigned int getFastSelectColor();
|
|
||||||
bool getHeaderHidden();
|
|
||||||
bool getDividersHidden();
|
|
||||||
bool getListCentered();
|
|
||||||
|
|
||||||
float getListOffsetX();
|
|
||||||
float getListTextOffsetX();
|
|
||||||
|
|
||||||
float getGameImageOffsetX();
|
|
||||||
float getGameImageOffsetY();
|
|
||||||
float getGameImageWidth();
|
|
||||||
float getGameImageHeight();
|
|
||||||
float getGameImageOriginX();
|
|
||||||
float getGameImageOriginY();
|
|
||||||
|
|
||||||
GuiBoxData getBoxData();
|
GuiBoxData getBoxData();
|
||||||
|
|
||||||
Sound* getMenuScrollSound();
|
unsigned int getColor(std::string name);
|
||||||
Sound* getMenuSelectSound();
|
bool getBool(std::string name);
|
||||||
Sound* getMenuBackSound();
|
float getFloat(std::string name);
|
||||||
Sound* getMenuOpenSound();
|
Sound* getSound(std::string name);
|
||||||
|
std::string getString(std::string name);
|
||||||
std::string getImageNotFoundPath();
|
|
||||||
|
|
||||||
Font* getListFont();
|
Font* getListFont();
|
||||||
Font* getDescriptionFont();
|
Font* getDescriptionFont();
|
||||||
|
@ -64,12 +43,13 @@ private:
|
||||||
std::vector<GuiComponent*> mComponentVector;
|
std::vector<GuiComponent*> mComponentVector;
|
||||||
std::string mPath;
|
std::string mPath;
|
||||||
|
|
||||||
unsigned int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor, mFastSelectColor;
|
std::map<std::string, unsigned int> mColorMap;
|
||||||
bool mHideHeader, mHideDividers, mListCentered;
|
std::map<std::string, bool> mBoolMap;
|
||||||
float mListOffsetX, mListTextOffsetX, mGameImageOffsetX, mGameImageOffsetY, mGameImageWidth, mGameImageHeight, mGameImageOriginX, mGameImageOriginY;
|
std::map<std::string, float> mFloatMap;
|
||||||
|
std::map<std::string, Sound*> mSoundMap;
|
||||||
|
std::map<std::string, std::string> mStringMap;
|
||||||
|
|
||||||
GuiBoxData mBoxData;
|
GuiBoxData mBoxData;
|
||||||
Sound mMenuScrollSound, mMenuSelectSound, mMenuBackSound, mMenuOpenSound;
|
|
||||||
std::string mImageNotFoundPath;
|
|
||||||
Font* mListFont;
|
Font* mListFont;
|
||||||
Font* mDescFont;
|
Font* mDescFont;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue