Reworked opacity to be stored in that wasted color byte.

This commit is contained in:
Aloshi 2012-10-17 13:21:56 -05:00
parent 358658a36d
commit 8b1e061929
13 changed files with 92 additions and 78 deletions

View file

@ -165,7 +165,7 @@ struct tex {
GLfloat tex2y; GLfloat tex2y;
}; };
void Font::drawText(std::string text, int startx, int starty, int color, char opacity) void Font::drawText(std::string text, int startx, int starty, int color)
{ {
starty += mMaxGlyphHeight; starty += mMaxGlyphHeight;
@ -224,7 +224,7 @@ void Font::drawText(std::string text, int startx, int starty, int color, char op
x += charData[letter].advX; x += charData[letter].advX;
} }
Renderer::buildGLColorArray(colors, color, opacity, pointCount * 3); Renderer::buildGLColorArray(colors, color, pointCount * 3);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);

View file

@ -35,7 +35,7 @@ public:
GLuint textureID; GLuint textureID;
void drawText(std::string text, int startx, int starty, int color, char opacity); //Render some text using this font. void drawText(std::string text, int startx, int starty, int color); //Render some text using this font.
void sizeText(std::string text, int* w, int* h); //Sets the width and height of a given string to given pointers. Skipped if pointer is NULL. void sizeText(std::string text, int* w, int* h); //Sets the width and height of a given string to given pointers. Skipped if pointer is NULL.
private: private:

View file

@ -27,14 +27,14 @@ namespace Renderer
enum FontSize { SMALL, MEDIUM, LARGE }; enum FontSize { SMALL, MEDIUM, LARGE };
int getFontHeight(FontSize size); //sometimes font size is needed before fonts have been loaded; this takes care of that int getFontHeight(FontSize size); //sometimes font size is needed before fonts have been loaded; this takes care of that
void buildGLColorArray(GLubyte* ptr, int color, unsigned char opacity, unsigned int vertCount); void buildGLColorArray(GLubyte* ptr, unsigned int color, unsigned int vertCount);
//drawing commands //drawing commands
void swapBuffers(); void swapBuffers();
void drawRect(int x, int y, int w, int h, int color, unsigned char opacity = 255); void drawRect(int x, int y, int w, int h, unsigned int color);
void drawText(std::string text, int x, int y, int color, unsigned char opacity = 255, FontSize fontsize = MEDIUM); void drawText(std::string text, int x, int y, unsigned int color, FontSize fontsize = MEDIUM);
void drawCenteredText(std::string text, int xOffset, int y, int color, unsigned char opacity = 255, FontSize fontsize = MEDIUM); void drawCenteredText(std::string text, int xOffset, int y, unsigned int color, FontSize fontsize = MEDIUM);
void drawWrappedText(std::string text, int xStart, int yStart, int xLen, int color, unsigned char opacity = 255, FontSize fontsize = MEDIUM); void drawWrappedText(std::string text, int xStart, int yStart, int xLen, unsigned int color, FontSize fontsize = MEDIUM);
} }
#endif #endif

View file

@ -8,24 +8,24 @@
namespace Renderer { namespace Renderer {
bool loadedFonts = false; bool loadedFonts = false;
void setColor4bArray(GLubyte* array, int color, unsigned char opacity) void setColor4bArray(GLubyte* array, unsigned int color)
{ {
array[0] = (color & 0x00ff0000) / 0x10000; array[0] = (color & 0xff000000) / 0x1000000;
array[1] = (color & 0x0000ff00) / 0x100; array[1] = (color & 0x00ff0000) / 0x10000;
array[2] = (color & 0x000000ff); array[2] = (color & 0x0000ff00) / 0x100;
array[3] = opacity; array[3] = (color & 0x000000ff);
} }
void buildGLColorArray(GLubyte* ptr, int color, unsigned char opacity, unsigned int vertCount) void buildGLColorArray(GLubyte* ptr, unsigned int color, unsigned int vertCount)
{ {
for(unsigned int i = 0; i < vertCount; i++) for(unsigned int i = 0; i < vertCount; i++)
{ {
setColor4bArray(ptr, color, opacity); setColor4bArray(ptr, color);
ptr += 4; ptr += 4;
} }
} }
void drawRect(int x, int y, int w, int h, int color, unsigned char opacity) void drawRect(int x, int y, int w, int h, unsigned int color)
{ {
GLfloat points[12]; GLfloat points[12];
@ -38,7 +38,7 @@ namespace Renderer {
points[10] = x + w; points[11] = y + h; points[10] = x + w; points[11] = y + h;
GLubyte colors[6*4]; GLubyte colors[6*4];
buildGLColorArray(colors, color, opacity, 6); buildGLColorArray(colors, color, 6);
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
@ -119,7 +119,7 @@ namespace Renderer {
return h; return h;
} }
void drawText(std::string text, int x, int y, int color, unsigned char opacity, FontSize font) void drawText(std::string text, int x, int y, unsigned int color, FontSize font)
{ {
if(!loadedFonts) if(!loadedFonts)
loadFonts(); loadFonts();
@ -127,10 +127,10 @@ namespace Renderer {
//if(x < 0) //if(x < 0)
// std::cout << "drawing at " << x << std::endl; // std::cout << "drawing at " << x << std::endl;
getFont(font)->drawText(text, x, y, color, opacity); getFont(font)->drawText(text, x, y, color);
} }
void drawCenteredText(std::string text, int xOffset, int y, int color, unsigned char opacity, FontSize fontsize) void drawCenteredText(std::string text, int xOffset, int y, unsigned int color, FontSize fontsize)
{ {
if(!loadedFonts) if(!loadedFonts)
loadFonts(); loadFonts();
@ -145,12 +145,12 @@ namespace Renderer {
x += xOffset * 0.5; x += xOffset * 0.5;
drawText(text, x, y, color, opacity, fontsize); drawText(text, x, y, color, fontsize);
} }
//this could probably be optimized //this could probably be optimized
//draws text and ensures it's never longer than xLen //draws text and ensures it's never longer than xLen
void drawWrappedText(std::string text, int xStart, int yStart, int xLen, int color, unsigned char opacity, FontSize fontsize) void drawWrappedText(std::string text, int xStart, int yStart, int xLen, unsigned int color, FontSize fontsize)
{ {
if(!loadedFonts) if(!loadedFonts)
loadFonts(); loadFonts();
@ -199,7 +199,7 @@ namespace Renderer {
{ {
//render line now //render line now
if(w > 0) //make sure it's not blank if(w > 0) //make sure it's not blank
drawText(line, xStart, y, color, opacity, fontsize); drawText(line, xStart, y, color, fontsize);
//increment y by height and some extra padding for the next line //increment y by height and some extra padding for the next line
y += h + 4; y += h + 4;

View file

@ -47,11 +47,11 @@ void GuiFastSelect::onRender()
unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight(); unsigned int sw = Renderer::getScreenWidth(), sh = Renderer::getScreenHeight();
if(!mBox->hasBackground()) if(!mBox->hasBackground())
Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0, 255); Renderer::drawRect(sw * 0.2, sh * 0.2, sw * 0.6, sh * 0.6, 0x000FF0FF);
mBox->render(); mBox->render();
Renderer::drawCenteredText(LETTERS.substr(mLetterID, 1), 0, sh * 0.5 - (Renderer::getFontHeight(Renderer::LARGE) * 0.5), mTextColor, 255, 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

@ -93,13 +93,13 @@ void GuiGameList::onRender()
//header //header
if(!mTheme->getHeaderHidden()) if(!mTheme->getHeaderHidden())
Renderer::drawCenteredText(mSystem->getName(), 0, 1, 0xFF0000, 255, Renderer::LARGE); Renderer::drawCenteredText(mSystem->getName(), 0, 1, 0xFF0000FF, Renderer::LARGE);
if(mDetailed) if(mDetailed)
{ {
//divider //divider
if(!mTheme->getDividersHidden()) if(!mTheme->getDividersHidden())
Renderer::drawRect(Renderer::getScreenWidth() * mTheme->getListOffsetX() - 4, Renderer::getFontHeight(Renderer::LARGE) + 2, 8, Renderer::getScreenHeight(), 0x0000FF, 255); Renderer::drawRect(Renderer::getScreenWidth() * mTheme->getListOffsetX() - 4, Renderer::getFontHeight(Renderer::LARGE) + 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())
@ -108,7 +108,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(), 255, Renderer::SMALL); Renderer::drawWrappedText(desc, Renderer::getScreenWidth() * 0.03, mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, Renderer::getScreenWidth() * (mTheme->getListOffsetX() - 0.03), mTheme->getDescColor(), Renderer::SMALL);
} }
} }
} }
@ -223,6 +223,8 @@ void GuiGameList::updateTheme()
mTheme->readXML(""); //clears any current theme mTheme->readXML(""); //clears any current theme
mList->setSelectorColor(mTheme->getSelectorColor()); mList->setSelectorColor(mTheme->getSelectorColor());
std::cout << "selector alpha: " << (mTheme->getSelectorColor() & 0x000000ff) << "\n";
mList->setSelectedTextColor(mTheme->getSelectedTextColor()); mList->setSelectedTextColor(mTheme->getSelectedTextColor());
mList->setScrollSound(mTheme->getMenuScrollSound()); mList->setScrollSound(mTheme->getMenuScrollSound());

View file

@ -271,10 +271,10 @@ void GuiImage::onRender()
float xCount = ((float)mResizeWidth/mWidth); float xCount = ((float)mResizeWidth/mWidth);
float yCount = ((float)mResizeHeight/mHeight); float yCount = ((float)mResizeHeight/mHeight);
Renderer::buildGLColorArray(colors, 0xFFFFFF, getOpacity(), 6); Renderer::buildGLColorArray(colors, 0xFFFFFF00 | (getOpacity()), 6);
buildImageArray(getOffsetX(), getOffsetY(), points, texs, xCount, yCount); buildImageArray(getOffsetX(), getOffsetY(), points, texs, xCount, yCount);
}else{ }else{
Renderer::buildGLColorArray(colors, 0xFFFFFF, getOpacity(), 6); Renderer::buildGLColorArray(colors, 0xFFFFFF00 | (getOpacity()), 6);
buildImageArray(getOffsetX(), getOffsetY(), points, texs); buildImageArray(getOffsetX(), getOffsetY(), points, texs);
} }

View file

@ -36,21 +36,21 @@ GuiInputConfig::~GuiInputConfig()
void GuiInputConfig::onRender() void GuiInputConfig::onRender()
{ {
Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0xFFFFFF); Renderer::drawRect(0, 0, Renderer::getScreenWidth(), Renderer::getScreenHeight(), 0xFFFFFFFF);
int height = Renderer::getFontHeight(Renderer::MEDIUM) + 6; int height = Renderer::getFontHeight(Renderer::MEDIUM) + 6;
Renderer::drawCenteredText("It looks like you have a joystick plugged in!", 0, 2, 0x000000); Renderer::drawCenteredText("It looks like you have a joystick plugged in!", 0, 2, 0x000000FF);
Renderer::drawCenteredText("POV hats (some D-Pads) are automatically mapped to directions.", 0, height, 0x000000); Renderer::drawCenteredText("POV hats (some D-Pads) are automatically mapped to directions.", 0, height, 0x000000FF);
Renderer::drawCenteredText("You can press a keyboard key to skip any input.", 0, height * 2, 0x000000); Renderer::drawCenteredText("You can press a keyboard key to skip any input.", 0, height * 2, 0x000000FF);
Renderer::drawCenteredText("If you want to remap later, just delete ~/.es_input.cfg.", 0, height * 3, 0x000000); Renderer::drawCenteredText("If you want to remap later, just delete ~/.es_input.cfg.", 0, height * 3, 0x000000FF);
Renderer::drawCenteredText("This interface only configures the first joystick plugged in.", 0, height * 4, 0x000000); Renderer::drawCenteredText("This interface only configures the first joystick plugged in.", 0, height * 4, 0x000000FF);
Renderer::drawCenteredText("Remember - you'll need to set up your emulator separately!", 0, Renderer::getScreenHeight() - height, 0x000000); Renderer::drawCenteredText("Remember - you'll need to set up your emulator separately!", 0, Renderer::getScreenHeight() - height, 0x000000FF);
if(mDone) if(mDone)
Renderer::drawCenteredText("All done! Press a keyboard key to save.", 0, height * 5, 0x00BB00); Renderer::drawCenteredText("All done! Press a keyboard key to save.", 0, height * 5, 0x00BB00FF);
else else
Renderer::drawCenteredText("Please press the axis/button for " + sInputs[mInputNum], 0, height * 5, 0x00C000); Renderer::drawCenteredText("Please press the axis/button for " + sInputs[mInputNum], 0, height * 5, 0x00C000FF);
} }
void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown) void GuiInputConfig::onInput(InputManager::InputButton button, bool keyDown)

View file

@ -17,8 +17,8 @@ GuiList<listType>::GuiList(int offsetX, int offsetY, Renderer::FontSize fontsize
mTextOffsetX = 0; mTextOffsetX = 0;
mFont = fontsize; mFont = fontsize;
mSelectorColor = 0x000000; mSelectorColor = 0x000000FF;
mSelectedTextColorOverride = -1; mSelectedTextColorOverride = 0x0000FF;
mScrollSound = NULL; mScrollSound = NULL;
mDrawCentered = true; mDrawCentered = true;
@ -56,7 +56,7 @@ void GuiList<listType>::onRender()
if(mRowVector.size() == 0) if(mRowVector.size() == 0)
{ {
Renderer::drawCenteredText("The list is empty.", 0, y, 0x0000FF, 255, mFont); Renderer::drawCenteredText("The list is empty.", 0, y, 0xFF0000FF, mFont);
return; return;
} }
@ -66,17 +66,18 @@ void GuiList<listType>::onRender()
for(int i = startEntry; i < listCutoff; i++) for(int i = startEntry; i < listCutoff; i++)
{ {
//draw selector bar
if(mSelection == i) if(mSelection == i)
{ {
Renderer::drawRect(getOffsetX(), y, Renderer::getScreenWidth(), Renderer::getFontHeight(mFont), mSelectorColor, 255); Renderer::drawRect(getOffsetX(), y, Renderer::getScreenWidth(), Renderer::getFontHeight(mFont), mSelectorColor);
} }
ListRow row = mRowVector.at((unsigned int)i); ListRow row = mRowVector.at((unsigned int)i);
if(mDrawCentered) if(mDrawCentered)
Renderer::drawCenteredText(row.name, getOffsetX(), y, row.color, mFont); Renderer::drawCenteredText(row.name, getOffsetX(), y, (mSelection == i) ? mSelectedTextColorOverride : row.color, mFont);
else else
Renderer::drawText(row.name, getOffsetX() + mTextOffsetX, y, (mSelectedTextColorOverride != -1 && mSelection == i ? mSelectedTextColorOverride : row.color), 255, mFont); Renderer::drawText(row.name, getOffsetX() + mTextOffsetX, y, (mSelection == i) ? mSelectedTextColorOverride : row.color, mFont);
y += entrySize; y += entrySize;
} }
@ -163,7 +164,7 @@ void GuiList<listType>::scroll()
//list management stuff //list management stuff
template <typename listType> template <typename listType>
void GuiList<listType>::addObject(std::string name, listType obj, int color) void GuiList<listType>::addObject(std::string name, listType obj, unsigned int color)
{ {
ListRow row = {name, obj, color}; ListRow row = {name, obj, color};
mRowVector.push_back(row); mRowVector.push_back(row);
@ -219,13 +220,14 @@ void GuiList<listType>::onResume()
} }
template <typename listType> template <typename listType>
void GuiList<listType>::setSelectorColor(int selectorColor) void GuiList<listType>::setSelectorColor(unsigned int selectorColor)
{ {
mSelectorColor = selectorColor; mSelectorColor = selectorColor;
std::cout << "mSelectorColor alpha: " << (mSelectorColor & 0x000000ff) << "\n";
} }
template <typename listType> template <typename listType>
void GuiList<listType>::setSelectedTextColor(int selectedColor) void GuiList<listType>::setSelectedTextColor(unsigned int selectedColor)
{ {
mSelectedTextColorOverride = selectedColor; mSelectedTextColorOverride = selectedColor;
} }

View file

@ -21,7 +21,7 @@ public:
void onTick(int deltaTime); void onTick(int deltaTime);
void onInput(InputManager::InputButton button, bool keyDown); void onInput(InputManager::InputButton button, bool keyDown);
void addObject(std::string name, listType obj, int color = 0xFF0000); void addObject(std::string name, listType obj, unsigned int color = 0xFF0000);
void clear(); void clear();
void onPause(); void onPause();
@ -33,8 +33,8 @@ public:
void stopScrolling(); void stopScrolling();
bool isScrolling(); bool isScrolling();
void setSelectorColor(int selectorColor); void setSelectorColor(unsigned int selectorColor);
void setSelectedTextColor(int selectedColor); void setSelectedTextColor(unsigned int selectedColor);
void setCentered(bool centered); void setCentered(bool centered);
void setScrollSound(Sound* sound); void setScrollSound(Sound* sound);
void setTextOffsetX(int textoffsetx); void setTextOffsetX(int textoffsetx);
@ -53,7 +53,7 @@ private:
bool mScrolling; bool mScrolling;
Renderer::FontSize mFont; Renderer::FontSize mFont;
int mSelectorColor, mSelectedTextColorOverride; unsigned int mSelectorColor, mSelectedTextColorOverride;
bool mDrawCentered; bool mDrawCentered;
int mTextOffsetX; int mTextOffsetX;
@ -62,7 +62,7 @@ private:
{ {
std::string name; std::string name;
listType object; listType object;
int color; unsigned int color;
}; };
std::vector<ListRow> mRowVector; std::vector<ListRow> mRowVector;

View file

@ -49,8 +49,8 @@ void GuiMenu::populateList()
{ {
mList->clear(); mList->clear();
mList->addObject("Restart", "sudo shutdown -r now", 0x0000FF); mList->addObject("Restart", "sudo shutdown -r now", 0x0000FFFF);
mList->addObject("Shutdown", "sudo shutdown -h now", 0x0000FF); mList->addObject("Shutdown", "sudo shutdown -h now", 0x0000FFFF);
} }
void GuiMenu::onRender() void GuiMenu::onRender()

View file

@ -7,18 +7,18 @@
#include <sstream> #include <sstream>
#include "../Renderer.h" #include "../Renderer.h"
int GuiTheme::getPrimaryColor() { return mListPrimaryColor; } unsigned int GuiTheme::getPrimaryColor() { return mListPrimaryColor; }
int GuiTheme::getSecondaryColor() { return mListSecondaryColor; } unsigned int GuiTheme::getSecondaryColor() { return mListSecondaryColor; }
int GuiTheme::getSelectorColor() { return mListSelectorColor; } unsigned int GuiTheme::getSelectorColor() { return mListSelectorColor; }
int GuiTheme::getDescColor() { return mDescColor; } unsigned int GuiTheme::getDescColor() { return mDescColor; }
int GuiTheme::getFastSelectColor() { return mFastSelectColor; } unsigned 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; }
float GuiTheme::getListOffsetX() { return mListOffsetX; } float GuiTheme::getListOffsetX() { return mListOffsetX; }
float GuiTheme::getListTextOffsetX() { return mListTextOffsetX; } float GuiTheme::getListTextOffsetX() { return mListTextOffsetX; }
int GuiTheme::getSelectedTextColor() { return mListSelectedColor; } unsigned int GuiTheme::getSelectedTextColor() { return mListSelectedColor; }
GuiBoxData GuiTheme::getBoxData() { return mBoxData; } GuiBoxData GuiTheme::getBoxData() { return mBoxData; }
@ -49,12 +49,12 @@ GuiTheme::~GuiTheme()
void GuiTheme::setDefaults() void GuiTheme::setDefaults()
{ {
mListPrimaryColor = 0x0000FF; mListPrimaryColor = 0x0000FFFF;
mListSecondaryColor = 0x00FF00; mListSecondaryColor = 0x00FF00FF;
mListSelectorColor = 0x000000; mListSelectorColor = 0x000000FF;
mListSelectedColor = -1; //-1 = use original list color when selected mListSelectedColor = 0xFF0000FF;
mDescColor = 0x0000FF; mDescColor = 0x0000FFFF;
mFastSelectColor = 0xFF0000; mFastSelectColor = 0xFF0000FF;
mHideHeader = false; mHideHeader = false;
mHideDividers = false; mHideDividers = false;
mListCentered = true; mListCentered = true;
@ -128,7 +128,7 @@ void GuiTheme::readXML(std::string path)
mListPrimaryColor = resolveColor(root.child("listPrimaryColor").text().get(), mListPrimaryColor); mListPrimaryColor = resolveColor(root.child("listPrimaryColor").text().get(), mListPrimaryColor);
mListSecondaryColor = resolveColor(root.child("listSecondaryColor").text().get(), mListSecondaryColor); mListSecondaryColor = resolveColor(root.child("listSecondaryColor").text().get(), mListSecondaryColor);
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(), mListPrimaryColor);
mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor); mDescColor = resolveColor(root.child("descColor").text().get(), mDescColor);
mFastSelectColor = resolveColor(root.child("fastSelectColor").text().get(), mFastSelectColor); mFastSelectColor = resolveColor(root.child("fastSelectColor").text().get(), mFastSelectColor);
mHideHeader = root.child("hideHeader"); mHideHeader = root.child("hideHeader");
@ -271,12 +271,22 @@ float GuiTheme::resolveExp(std::string str, float defaultVal)
} }
//takes a string of hex and resolves it to an integer //takes a string of hex and resolves it to an integer
int GuiTheme::resolveColor(std::string str, int defaultColor) unsigned int GuiTheme::resolveColor(std::string str, unsigned int defaultColor)
{ {
if(str.empty()) if(str.empty())
return defaultColor; return defaultColor;
int ret; if(str.length() != 6 && str.length() != 8)
{
std::cerr << "Error - color \"" << str << "\" is not a valid hex color! Must be 6 or 8 characters.\n";
return defaultColor;
}
//if there's no alpha specified, assume FF
if(str.length() == 6)
str += "FF";
unsigned int ret;
std::stringstream ss; std::stringstream ss;
ss << std::hex << str; ss << std::hex << str;
ss >> ret; ss >> ret;

View file

@ -15,12 +15,12 @@ public:
void readXML(std::string path); void readXML(std::string path);
int getPrimaryColor(); unsigned int getPrimaryColor();
int getSecondaryColor(); unsigned int getSecondaryColor();
int getSelectorColor(); unsigned int getSelectorColor();
int getSelectedTextColor(); unsigned int getSelectedTextColor();
int getDescColor(); unsigned int getDescColor();
int getFastSelectColor(); unsigned int getFastSelectColor();
bool getHeaderHidden(); bool getHeaderHidden();
bool getDividersHidden(); bool getDividersHidden();
bool getListCentered(); bool getListCentered();
@ -50,13 +50,13 @@ private:
//utility functions //utility functions
std::string expandPath(std::string path); std::string expandPath(std::string path);
float resolveExp(std::string str, float defaultVal = 0.0); float resolveExp(std::string str, float defaultVal = 0.0);
int resolveColor(std::string str, int defaultColor = 0x000000); unsigned int resolveColor(std::string str, unsigned int defaultColor = 0x000000FF);
void splitString(std::string str, char delim, std::string* before, std::string* after); void splitString(std::string str, char delim, std::string* before, std::string* after);
float strToFloat(std::string str, float defaultVal = 0.0f); float strToFloat(std::string str, float defaultVal = 0.0f);
std::vector<GuiComponent*> mComponentVector; std::vector<GuiComponent*> mComponentVector;
std::string mPath; std::string mPath;
int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor, mFastSelectColor; unsigned int mListPrimaryColor, mListSecondaryColor, mListSelectorColor, mListSelectedColor, mDescColor, mFastSelectColor;
bool mHideHeader, mHideDividers, mListCentered; bool mHideHeader, mHideDividers, mListCentered;
float mListOffsetX, mListTextOffsetX, mGameImageOffsetX, mGameImageOffsetY, mGameImageWidth, mGameImageHeight, mGameImageOriginX, mGameImageOriginY; float mListOffsetX, mListTextOffsetX, mGameImageOffsetX, mGameImageOffsetY, mGameImageWidth, mGameImageHeight, mGameImageOriginX, mGameImageOriginY;