- allow overriding text colors

This commit is contained in:
Mark Vejvoda 2012-06-01 05:26:01 +00:00
parent 35b917106c
commit dcc615d427
4 changed files with 17 additions and 5 deletions

View File

@ -35,6 +35,8 @@ float GraphicComponent::anim= 0.f;
float GraphicComponent::fade= 0.f;
const float GraphicComponent::animSpeed= 0.02f;
const float GraphicComponent::fadeSpeed= 0.01f;
// WHITE
Vec3f GraphicComponent::customTextColor = Vec3f(1.0,1.0,1.0);
std::map<std::string, std::map<std::string, GraphicComponent *> > GraphicComponent::registeredGraphicComponentList;

View File

@ -62,6 +62,7 @@ protected:
static float anim;
static float fade;
static Vec3f customTextColor;
string instanceName;
@ -69,6 +70,9 @@ public:
GraphicComponent(std::string containerName="", std::string objName="");
virtual ~GraphicComponent(){}
static void setCustomTextColor(Vec3f value) { customTextColor = value; }
static Vec3f getCustomTextColor() { return customTextColor; }
static void clearRegisteredComponents(std::string containerName="");
static void clearRegisterGraphicComponent(std::string containerName, std::string objName);
static void clearRegisterGraphicComponent(std::string containerName, std::vector<std::string> objNameList);
@ -138,7 +142,7 @@ private:
public:
GraphicLabel();
void init(int x, int y, int w=defW, int h=defH, bool centered= false, Vec3f textColor=Vec3f(1.f, 1.f, 1.f), bool wordWrap=false);
void init(int x, int y, int w=defW, int h=defH, bool centered= false, Vec3f textColor=GraphicComponent::customTextColor, bool wordWrap=false);
bool getCentered() const {return centered;}
void setCentered(bool centered) {this->centered= centered;}
@ -206,7 +210,7 @@ private:
public:
GraphicListBox(std::string containerName="", std::string objName="");
void init(int x, int y, int w=defW, int h=defH, Vec3f textColor=Vec3f(1.f, 1.f, 1.f));
void init(int x, int y, int w=defW, int h=defH, Vec3f textColor=GraphicComponent::customTextColor);
int getItemCount() const {return items.size();}
string getItem(int index) const {return items[index];}

View File

@ -2826,14 +2826,14 @@ void Renderer::renderButton(GraphicButton *button, const Vec4f *fontColorOverrid
}
//button
Vec4f fontColor;
Vec4f fontColor(GraphicComponent::getCustomTextColor());
if(fontColorOverride != NULL) {
fontColor= *fontColorOverride;
}
else {
// white shadowed is default ( in the menu for example )
fontColor=Vec4f(1.f, 1.f, 1.f, GraphicComponent::getFade());
fontColor.w = GraphicComponent::getFade();
}
//Vec4f color= Vec4f(1.f, 1.f, 1.f, GraphicComponent::getFade());

View File

@ -1,6 +1,6 @@
// This file is part of Glest (www.glest.org)
//
// Copyright (C) 2001-2008 Martiño Figueroa
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
//
// You can redistribute this code and/or modify it under
// the terms of the GNU General Public License as published
@ -3361,6 +3361,12 @@ int glestMain(int argc, char** argv) {
UPNP_Tools::isUPNP = !config.getBool("DisableUPNP","false");
Texture::useTextureCompression = config.getBool("EnableTextureCompression","false");
if(config.getString("CustomMenuTextColor","") != "") {
string customMenuTextColor = config.getString("CustomMenuTextColor");
Vec3f customTextColor = Vec3f::strToVec3(customMenuTextColor);
GraphicComponent::setCustomTextColor(customTextColor);
}
// 256 for English
// 30000 for Chinese
Font::charCount = config.getInt("FONT_CHARCOUNT",intToStr(Font::charCount).c_str());