Fix issue #116 - when fonts deleted and reloaded signal back immediately to all registered controls to refresh their font
This commit is contained in:
parent
b2aa5e1991
commit
6f350d6319
|
@ -1,7 +1,7 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.24720.0
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "g2xml", "vc2015\g2xml.vcxproj", "{407355A4-D12A-4E3B-A7EB-A835E573B376}"
|
||||
EndProject
|
||||
|
|
|
@ -6,8 +6,15 @@ ECHO Changing to build folder [%~dp0] p1 [%1] p2 [%2]
|
|||
rem pause
|
||||
cd /d "%~dp0"
|
||||
|
||||
set CUR_DIR=%~dp0
|
||||
set RELEASENAME=megaglest-standalone-data
|
||||
set PROJDIR=..\..\
|
||||
set REPODIR=%~dp0\..\..\
|
||||
set PATH=%path%;%~dp0.\
|
||||
|
||||
set mg_version=
|
||||
for /f "tokens=2 delims= " %%i in ('.\megaglest.exe --version') do call :mgver %%i
|
||||
if exist ".\megaglest.exe" for /f "tokens=2 delims= " %%i in ('.\megaglest.exe --version') do call :mgver %%i
|
||||
if exist "%REPODIR%data\glest_game\megaglest.exe" for /f "tokens=2 delims= " %%i in ('%REPODIR%data\glest_game\megaglest.exe --version') do call :mgver %%i
|
||||
goto got_ver
|
||||
|
||||
:mgver
|
||||
|
@ -27,12 +34,8 @@ exit /B 0
|
|||
:got_ver
|
||||
echo [%mg_version%]
|
||||
|
||||
set RELEASENAME=megaglest-standalone-data
|
||||
set PACKAGE=%RELEASENAME%-%mg_version%.7z
|
||||
set RELEASEDIR=release-data\%RELEASENAME%-%mg_version%
|
||||
set PROJDIR=..\..\
|
||||
set REPODIR=%~dp0\..\..\
|
||||
set PATH=%path%;%~dp0.\
|
||||
rem to debug creating the archive only
|
||||
rem goto make_archive
|
||||
|
||||
|
@ -47,56 +50,56 @@ echo Copying data ...
|
|||
mkdir %RELEASEDIR%\data\
|
||||
cd /d %RELEASEDIR%\data\
|
||||
echo GIT ARCHIVE data ...
|
||||
git archive --remote %REPODIR%\data\glest_game\ HEAD:data | tar -x
|
||||
git archive --format=tar --remote %REPODIR%\data\glest_game\ HEAD:data | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
rem pause
|
||||
|
||||
mkdir %RELEASEDIR%\docs\
|
||||
cd /d %RELEASEDIR%\docs\
|
||||
echo GIT ARCHIVE docs ...
|
||||
git archive --remote %REPODIR%/data/glest_game/ HEAD:docs | tar -x
|
||||
git archive --format=tar --remote %REPODIR%/data/glest_game/ HEAD:docs | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
|
||||
cd /d %RELEASEDIR%\docs\
|
||||
echo GIT ARCHIVE CHANGELOG.txt ...
|
||||
git archive --remote %REPODIR% HEAD:docs/ CHANGELOG.txt | tar -x
|
||||
git archive --format=tar --remote %REPODIR% HEAD:docs/ CHANGELOG.txt | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
rem pause
|
||||
|
||||
cd /d %RELEASEDIR%\docs\
|
||||
echo GIT ARCHIVE README.txt ...
|
||||
git archive --remote %REPODIR% HEAD:docs/ README.txt | tar -x
|
||||
git archive --format=tar --remote %REPODIR% HEAD:docs/ README.txt | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
rem pause
|
||||
|
||||
mkdir %RELEASEDIR%\maps\
|
||||
cd /d %RELEASEDIR%\maps\
|
||||
echo GIT ARCHIVE maps ...
|
||||
git archive --remote %REPODIR%/data/glest_game/ HEAD:maps | tar -x
|
||||
git archive --format=tar --remote %REPODIR%/data/glest_game/ HEAD:maps | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
|
||||
mkdir %RELEASEDIR%\scenarios\
|
||||
cd /d %RELEASEDIR%\scenarios\
|
||||
echo GIT ARCHIVE scenarios ...
|
||||
git archive --remote %REPODIR%/data/glest_game/ HEAD:scenarios | tar -x
|
||||
git archive --format=tar --remote %REPODIR%/data/glest_game/ HEAD:scenarios | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
|
||||
mkdir %RELEASEDIR%\techs\
|
||||
cd /d %RELEASEDIR%\techs\
|
||||
echo GIT ARCHIVE techs ...
|
||||
git archive --remote %REPODIR%/data/glest_game/ HEAD:techs | tar -x
|
||||
git archive --format=tar --remote %REPODIR%/data/glest_game/ HEAD:techs | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
|
||||
mkdir %RELEASEDIR%\tilesets\
|
||||
cd /d %RELEASEDIR%\tilesets\
|
||||
echo GIT ARCHIVE tilesets ...
|
||||
git archive --remote %REPODIR%/data/glest_game/ HEAD:tilesets | tar -x
|
||||
git archive --format=tar --remote %REPODIR%/data/glest_game/ HEAD:tilesets | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
|
||||
mkdir %RELEASEDIR%\tutorials\
|
||||
cd /d %RELEASEDIR%\tutorials\
|
||||
echo GIT ARCHIVE tutorials ...
|
||||
git archive --remote %REPODIR%/data/glest_game/ HEAD:tutorials | tar -x
|
||||
git archive --format=tar --remote %REPODIR%/data/glest_game/ HEAD:tutorials | %CUR_DIR%\tar.exe -xf -
|
||||
cd /d "%~dp0"
|
||||
|
||||
rem START
|
||||
|
|
|
@ -40,7 +40,8 @@ Vec3f GraphicComponent::customTextColor = Vec3f(1.0,1.0,1.0);
|
|||
std::map<std::string, std::map<std::string, GraphicComponent *> > GraphicComponent::registeredGraphicComponentList;
|
||||
|
||||
GraphicComponent::GraphicComponent(std::string containerName, std::string objName) {
|
||||
instanceName = "";
|
||||
this->containerName = containerName;
|
||||
this->instanceName = "";
|
||||
if(objName != "") {
|
||||
registerGraphicComponent(containerName,objName);
|
||||
}
|
||||
|
@ -57,6 +58,10 @@ GraphicComponent::GraphicComponent(std::string containerName, std::string objNam
|
|||
textNativeTranslation = "";
|
||||
}
|
||||
|
||||
GraphicComponent::~GraphicComponent() {
|
||||
CoreData::getInstance().unRegisterFontChangedCallback(this->getInstanceName());
|
||||
}
|
||||
|
||||
void GraphicComponent::clearRegisteredComponents(std::string containerName) {
|
||||
if(containerName == "") {
|
||||
GraphicComponent::registeredGraphicComponentList.clear();
|
||||
|
@ -80,12 +85,20 @@ void GraphicComponent::clearRegisterGraphicComponent(std::string containerName,
|
|||
}
|
||||
|
||||
void GraphicComponent::registerGraphicComponent(std::string containerName, std::string objName) {
|
||||
instanceName = objName;
|
||||
this->containerName = containerName;
|
||||
this->instanceName = objName;
|
||||
registeredGraphicComponentList[containerName][objName] = this;
|
||||
CoreData::getInstance().registerFontChangedCallback(this->getInstanceName(), this);
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] registered [%s] [%s] count = %d\n",__FILE__,__FUNCTION__,__LINE__,containerName.c_str(),instanceName.c_str(),registeredGraphicComponentList[containerName].size());
|
||||
}
|
||||
|
||||
void GraphicComponent::registerGraphicComponentOnlyFontCallbacks(std::string containerName, std::string objName) {
|
||||
this->containerName = containerName;
|
||||
this->instanceName = objName;
|
||||
CoreData::getInstance().registerFontChangedCallback(this->getInstanceName(), this);
|
||||
}
|
||||
|
||||
GraphicComponent * GraphicComponent::findRegisteredComponent(std::string containerName, std::string objName) {
|
||||
GraphicComponent *result = NULL;
|
||||
|
||||
|
@ -208,9 +221,51 @@ bool GraphicComponent::saveCustomProperties(std::string containerName) {
|
|||
return savedChange;
|
||||
}
|
||||
|
||||
void GraphicComponent::setFont(Font2D *font) {
|
||||
this->font = font;
|
||||
if (this->font != NULL) {
|
||||
this->font2DUniqueId = font->getFontUniqueId();
|
||||
}
|
||||
else {
|
||||
this->font2DUniqueId = "";
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicComponent::setFont3D(Font3D *font) {
|
||||
this->font3D = font;
|
||||
if (this->font3D != NULL) {
|
||||
this->font3DUniqueId = font->getFontUniqueId();
|
||||
}
|
||||
else {
|
||||
this->font3DUniqueId = "";
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicComponent::FontChangedCallback(std::string fontUniqueId, Font *font) {
|
||||
//printf("In FontChanged for [%s] font [%p]\n", fontUniqueId.c_str(),font);
|
||||
if (fontUniqueId != "") {
|
||||
if (fontUniqueId == this->font2DUniqueId) {
|
||||
if (font != NULL) {
|
||||
this->font = (Font2D *)font;
|
||||
}
|
||||
else {
|
||||
this->font = NULL;
|
||||
}
|
||||
}
|
||||
else if (fontUniqueId == this->font3DUniqueId) {
|
||||
if (font != NULL) {
|
||||
this->font3D = (Font3D *)font;
|
||||
}
|
||||
else {
|
||||
this->font3D = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GraphicComponent::reloadFonts() {
|
||||
font= CoreData::getInstance().getMenuFontNormal();
|
||||
font3D= CoreData::getInstance().getMenuFontNormal3D();
|
||||
setFont(CoreData::getInstance().getMenuFontNormal());
|
||||
setFont3D(CoreData::getInstance().getMenuFontNormal3D());
|
||||
}
|
||||
|
||||
void GraphicComponent::reloadFontsForRegisterGraphicComponents(std::string containerName) {
|
||||
|
@ -339,7 +394,9 @@ void GraphicLabel::setCenteredH(bool centered) {
|
|||
const int GraphicButton::defH= 22;
|
||||
const int GraphicButton::defW= 90;
|
||||
|
||||
GraphicButton::GraphicButton(std::string containerName, std::string objName) : GraphicComponent(containerName,objName) {
|
||||
GraphicButton::GraphicButton(std::string containerName, std::string objName) :
|
||||
GraphicComponent(containerName,objName) {
|
||||
|
||||
lighted = false;
|
||||
alwaysLighted = false;
|
||||
useCustomTexture = false;
|
||||
|
@ -369,7 +426,8 @@ const int GraphicListBox::defH= 22;
|
|||
const int GraphicListBox::defW= 140;
|
||||
|
||||
GraphicListBox::GraphicListBox(std::string containerName, std::string objName)
|
||||
: GraphicComponent(containerName, objName), graphButton1(), graphButton2() {
|
||||
: GraphicComponent(containerName, objName), graphButton1(containerName, instanceName + "_button1"),
|
||||
graphButton2(containerName, instanceName + "_button2") {
|
||||
selectedItemIndex = 0;
|
||||
lighted = false;
|
||||
leftControlled = false;
|
||||
|
@ -650,10 +708,10 @@ void GraphicMessageBox::init(const string &button1Str, int newWidth, int newHeig
|
|||
addButton(button1Str);
|
||||
}
|
||||
|
||||
void GraphicMessageBox::init(int newWidth, int newHeight){
|
||||
font= CoreData::getInstance().getMenuFontNormal();
|
||||
font3D= CoreData::getInstance().getMenuFontNormal3D();
|
||||
|
||||
void GraphicMessageBox::init(int newWidth, int newHeight) {
|
||||
setFont(CoreData::getInstance().getMenuFontNormal());
|
||||
setFont3D(CoreData::getInstance().getMenuFontNormal3D());
|
||||
|
||||
h= (newHeight >= 0 ? newHeight : defH);
|
||||
w= (newWidth >= 0 ? newWidth : defW);
|
||||
|
||||
|
@ -664,7 +722,7 @@ void GraphicMessageBox::init(int newWidth, int newHeight){
|
|||
}
|
||||
|
||||
void GraphicMessageBox::addButton(const string &buttonStr, int width, int height){
|
||||
GraphicButton *newButton= new GraphicButton();
|
||||
GraphicButton *newButton= new GraphicButton(containerName, instanceName + "_" + buttonStr);
|
||||
newButton->init(0, 0);
|
||||
newButton->setText(buttonStr);
|
||||
if(width != -1){
|
||||
|
@ -968,8 +1026,8 @@ PopupMenu::~PopupMenu() {
|
|||
void PopupMenu::init(string menuHeader,std::vector<string> menuItems) {
|
||||
header = menuHeader;
|
||||
|
||||
font= CoreData::getInstance().getMenuFontNormal();
|
||||
font3D= CoreData::getInstance().getMenuFontNormal3D();
|
||||
setFont(CoreData::getInstance().getMenuFontNormal());
|
||||
setFont3D(CoreData::getInstance().getMenuFontNormal3D());
|
||||
|
||||
buttons.clear();
|
||||
|
||||
|
@ -1019,6 +1077,7 @@ void PopupMenu::init(string menuHeader,std::vector<string> menuItems) {
|
|||
|
||||
for(unsigned int i = 0; i < menuItems.size(); ++i) {
|
||||
GraphicButton button;
|
||||
button.registerGraphicComponentOnlyFontCallbacks(containerName, instanceName + "_Button_" + menuItems[i]);
|
||||
button.init(x+(w-maxButtonWidth)/2, yStartOffset - (i*(textHeight + textHeightSpacing)));
|
||||
button.setText(menuItems[i]);
|
||||
button.setW(maxButtonWidth);
|
||||
|
|
|
@ -44,7 +44,7 @@ class GraphicComponent;
|
|||
// OpenGL renderer GUI components
|
||||
// ===========================================================
|
||||
|
||||
class GraphicComponent {
|
||||
class GraphicComponent : public FontChangedCallbackInterface {
|
||||
public:
|
||||
static const float animSpeed;
|
||||
static const float fadeSpeed;
|
||||
|
@ -57,6 +57,8 @@ protected:
|
|||
string textNativeTranslation;
|
||||
Font2D *font;
|
||||
Font3D *font3D;
|
||||
string font2DUniqueId;
|
||||
string font3DUniqueId;
|
||||
bool enabled;
|
||||
bool editable;
|
||||
bool visible;
|
||||
|
@ -65,11 +67,14 @@ protected:
|
|||
static float fade;
|
||||
static Vec3f customTextColor;
|
||||
|
||||
string containerName;
|
||||
string instanceName;
|
||||
|
||||
virtual void FontChangedCallback(std::string fontUniqueId, Font *font);
|
||||
|
||||
public:
|
||||
GraphicComponent(std::string containerName="", std::string objName="");
|
||||
virtual ~GraphicComponent(){}
|
||||
virtual ~GraphicComponent();
|
||||
|
||||
static void setCustomTextColor(Vec3f value) { customTextColor = value; }
|
||||
static Vec3f getCustomTextColor() { return customTextColor; }
|
||||
|
@ -78,6 +83,7 @@ public:
|
|||
static void clearRegisterGraphicComponent(std::string containerName, std::string objName);
|
||||
static void clearRegisterGraphicComponent(std::string containerName, std::vector<std::string> objNameList);
|
||||
virtual void registerGraphicComponent(std::string containerName, std::string objName);
|
||||
virtual void registerGraphicComponentOnlyFontCallbacks(std::string containerName, std::string objName);
|
||||
static GraphicComponent * findRegisteredComponent(std::string containerName, std::string objName);
|
||||
static void applyAllCustomProperties(std::string containerName);
|
||||
virtual void applyCustomProperties(std::string containerName);
|
||||
|
@ -108,8 +114,8 @@ public:
|
|||
virtual void setH(int h) {this->h= h;}
|
||||
virtual void setText(const string &text) {this->text= text;}
|
||||
virtual void setTextNativeTranslation(const string &text) {this->textNativeTranslation= text;}
|
||||
virtual void setFont(Font2D *font) {this->font= font;}
|
||||
virtual void setFont3D(Font3D *font) {this->font3D= font;}
|
||||
virtual void setFont(Font2D *font);
|
||||
virtual void setFont3D(Font3D *font);
|
||||
virtual void setEnabled(bool enabled) {this->enabled= enabled;}
|
||||
virtual void setEditable(bool editable) {this->editable= editable;}
|
||||
virtual void setVisible(bool value) {this->visible = value;}
|
||||
|
@ -438,7 +444,7 @@ private:
|
|||
|
||||
public:
|
||||
PopupMenu();
|
||||
~PopupMenu();
|
||||
virtual ~PopupMenu();
|
||||
void init(string menuHeader, std::vector<string> menuItems);
|
||||
|
||||
std::vector<GraphicButton> & getMenuItems() {return buttons;}
|
||||
|
|
|
@ -31,6 +31,7 @@ namespace Glest{ namespace Game{
|
|||
|
||||
Console::Console() {
|
||||
//config
|
||||
this->instanceName = "Generic-Console";
|
||||
maxLines = Config::getInstance().getInt("ConsoleMaxLines");
|
||||
maxStoredLines = Config::getInstance().getInt("ConsoleMaxLinesStored");
|
||||
timeout = Config::getInstance().getInt("ConsoleTimeout");
|
||||
|
@ -38,15 +39,67 @@ Console::Console() {
|
|||
xPos=20;
|
||||
yPos=20;
|
||||
lineHeight=Config::getInstance().getInt("FontConsoleBaseSize","18")+2;
|
||||
font=CoreData::getInstance().getConsoleFont();
|
||||
font3D=CoreData::getInstance().getConsoleFont3D();
|
||||
setFont(CoreData::getInstance().getConsoleFont());
|
||||
setFont3D(CoreData::getInstance().getConsoleFont3D());
|
||||
|
||||
stringToHighlight="";
|
||||
onlyChatMessagesInStoredLines=true;
|
||||
}
|
||||
|
||||
Console::~Console() {
|
||||
CoreData::getInstance().unRegisterFontChangedCallback(this->getInstanceName());
|
||||
}
|
||||
|
||||
void Console::setFont(Font2D *font) {
|
||||
this->font = font;
|
||||
if (this->font != NULL) {
|
||||
this->font2DUniqueId = font->getFontUniqueId();
|
||||
}
|
||||
else {
|
||||
this->font2DUniqueId = "";
|
||||
}
|
||||
}
|
||||
|
||||
void Console::setFont3D(Font3D *font) {
|
||||
this->font3D = font;
|
||||
if (this->font3D != NULL) {
|
||||
this->font3DUniqueId = font->getFontUniqueId();
|
||||
}
|
||||
else {
|
||||
this->font3DUniqueId = "";
|
||||
}
|
||||
}
|
||||
|
||||
void Console::registerGraphicComponent(std::string containerName, std::string objName) {
|
||||
this->instanceName = objName;
|
||||
CoreData::getInstance().registerFontChangedCallback(this->getInstanceName(), this);
|
||||
}
|
||||
|
||||
void Console::FontChangedCallback(std::string fontUniqueId, Font *font) {
|
||||
//printf("In FontChanged for [%s] font [%p]\n", fontUniqueId.c_str(),font);
|
||||
if (fontUniqueId != "") {
|
||||
if (fontUniqueId == this->font2DUniqueId) {
|
||||
if (font != NULL) {
|
||||
this->font = (Font2D *)font;
|
||||
}
|
||||
else {
|
||||
this->font = NULL;
|
||||
}
|
||||
}
|
||||
else if (fontUniqueId == this->font3DUniqueId) {
|
||||
if (font != NULL) {
|
||||
this->font3D = (Font3D *)font;
|
||||
}
|
||||
else {
|
||||
this->font3D = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Console::resetFonts() {
|
||||
font=CoreData::getInstance().getConsoleFont();
|
||||
font3D=CoreData::getInstance().getConsoleFont3D();
|
||||
setFont(CoreData::getInstance().getConsoleFont());
|
||||
setFont3D(CoreData::getInstance().getConsoleFont3D());
|
||||
}
|
||||
|
||||
void Console::addStdMessage(const string &s,bool clearOtherLines) {
|
||||
|
|
|
@ -32,8 +32,10 @@ using namespace std;
|
|||
|
||||
namespace Glest { namespace Game {
|
||||
|
||||
using Shared::Graphics::Font;
|
||||
using Shared::Graphics::Font2D;
|
||||
using Shared::Graphics::Font3D;
|
||||
using Shared::Graphics::FontChangedCallbackInterface;
|
||||
using Shared::Graphics::Vec3f;
|
||||
// =====================================================
|
||||
// class Console
|
||||
|
@ -51,7 +53,7 @@ public:
|
|||
bool teamMode;
|
||||
};
|
||||
|
||||
class Console {
|
||||
class Console: public FontChangedCallbackInterface {
|
||||
private:
|
||||
static const int consoleLines= 5;
|
||||
|
||||
|
@ -75,10 +77,20 @@ private:
|
|||
int lineHeight;
|
||||
Font2D *font;
|
||||
Font3D *font3D;
|
||||
string font2DUniqueId;
|
||||
string font3DUniqueId;
|
||||
|
||||
bool onlyChatMessagesInStoredLines;
|
||||
|
||||
string instanceName;
|
||||
|
||||
public:
|
||||
Console();
|
||||
virtual ~Console();
|
||||
|
||||
void registerGraphicComponent(std::string containerName, std::string objName);
|
||||
string getInstanceName() const { return instanceName; }
|
||||
void setInstanceName(string value) { instanceName = value; }
|
||||
|
||||
int getStoredLineCount() const {return (int)storedLines.size();}
|
||||
int getLineCount() const {return (int)lines.size();}
|
||||
|
@ -93,8 +105,8 @@ public:
|
|||
void setLineHeight(int lineHeight) {this->lineHeight= lineHeight;}
|
||||
Font2D *getFont() const {return font;}
|
||||
Font3D *getFont3D() const {return font3D;}
|
||||
void setFont(Font2D *font) {this->font= font;}
|
||||
void setFont3D(Font3D *font) {this->font3D= font;}
|
||||
void setFont(Font2D *font);
|
||||
void setFont3D(Font3D *font);
|
||||
string getStringToHighlight() const { return stringToHighlight;}
|
||||
void setStringToHighlight(string stringToHighlight) { this->stringToHighlight = stringToHighlight;}
|
||||
void resetFonts();
|
||||
|
@ -116,6 +128,8 @@ public:
|
|||
void addLine(string line, bool playSound, Vec3f textColor) { addLine(line,playSound,"",textColor,false); }
|
||||
void update();
|
||||
bool isEmpty();
|
||||
|
||||
virtual void FontChangedCallback(std::string fontUniqueId, Font *font);
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
|
|
@ -1154,6 +1154,34 @@ bool CoreData::hasBattleEndVideoFilename(bool won) const {
|
|||
return result;
|
||||
}
|
||||
|
||||
void CoreData::registerFontChangedCallback(std::string entityName, FontChangedCallbackInterface *cb) {
|
||||
if(entityName == "") {
|
||||
//printf("Register Font Callback detected a blank entityName!\n");
|
||||
//throw megaglest_runtime_error("Register Font Callback detected a blank entityName!");
|
||||
}
|
||||
if (entityName != "") {
|
||||
registeredFontChangedCallbacks[entityName].push_back(cb);
|
||||
}
|
||||
}
|
||||
void CoreData::unRegisterFontChangedCallback(std::string entityName) {
|
||||
if (entityName == "") {
|
||||
//printf("UnRegister Font Callback detected a blank entityName!\n");
|
||||
//throw megaglest_runtime_error("UnRegister Font Callback detected a blank entityName!");
|
||||
}
|
||||
if(entityName != "") {
|
||||
registeredFontChangedCallbacks.erase(entityName);
|
||||
}
|
||||
}
|
||||
void CoreData::triggerFontChangedCallbacks(std::string fontUniqueId, Font *font) {
|
||||
for (std::map<std::string, std::vector<FontChangedCallbackInterface *>>::const_iterator iterMap =
|
||||
registeredFontChangedCallbacks.begin();
|
||||
iterMap != registeredFontChangedCallbacks.end(); iterMap++) {
|
||||
for (int index = 0; index < iterMap->second.size(); ++index) {
|
||||
FontChangedCallbackInterface *cb = iterMap->second[index];
|
||||
cb->FontChangedCallback(fontUniqueId, font);
|
||||
}
|
||||
}
|
||||
}
|
||||
void CoreData::loadFonts() {
|
||||
Renderer &renderer= Renderer::getInstance();
|
||||
Lang &lang= Lang::getInstance();
|
||||
|
@ -1178,26 +1206,34 @@ void CoreData::loadFonts() {
|
|||
string displayFontName = displayFontNamePrefix + intToStr(displayFontSize) + displayFontNamePostfix;
|
||||
|
||||
if(displayFont) {
|
||||
string fontUniqueId = displayFont->getFontUniqueId();
|
||||
renderer.endFont(displayFont, rsGlobal);
|
||||
displayFont=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, displayFont);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
displayFont= renderer.newFont(rsGlobal);
|
||||
if(displayFont) {
|
||||
displayFont->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily",""));
|
||||
displayFont->setSize(displayFontSize);
|
||||
displayFont->setFontUniqueId("displayFont");
|
||||
triggerFontChangedCallbacks(displayFont->getFontUniqueId(), displayFont);
|
||||
}
|
||||
}
|
||||
|
||||
if(displayFont3D) {
|
||||
string fontUniqueId = displayFont3D->getFontUniqueId();
|
||||
renderer.endFont(displayFont3D, rsGlobal);
|
||||
displayFont3D=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, displayFont3D);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == true) {
|
||||
displayFont3D= renderer.newFont3D(rsGlobal);
|
||||
if(displayFont3D) {
|
||||
displayFont3D->setType(displayFontName,config.getString("FontDisplay",""),config.getString("FontDisplayFamily",""));
|
||||
displayFont3D->setSize(displayFontSize);
|
||||
displayFont3D->setFontUniqueId("displayFont3D");
|
||||
triggerFontChangedCallbacks(displayFont3D->getFontUniqueId(), displayFont3D);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1221,26 +1257,34 @@ void CoreData::loadFonts() {
|
|||
string displayFontNameSmall = displayFontNameSmallPrefix + intToStr(displayFontNameSmallSize) + displayFontNameSmallPostfix;
|
||||
|
||||
if(displayFontSmall) {
|
||||
string fontUniqueId = displayFontSmall->getFontUniqueId();
|
||||
renderer.endFont(displayFontSmall, rsGlobal);
|
||||
displayFontSmall=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, displayFontSmall);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
displayFontSmall= renderer.newFont(rsGlobal);
|
||||
if(displayFontSmall) {
|
||||
displayFontSmall->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily",""));
|
||||
displayFontSmall->setSize(displayFontNameSmallSize);
|
||||
displayFontSmall->setFontUniqueId("displayFontSmall");
|
||||
triggerFontChangedCallbacks(displayFontSmall->getFontUniqueId(), displayFontSmall);
|
||||
}
|
||||
}
|
||||
|
||||
if(displayFontSmall3D) {
|
||||
string fontUniqueId = displayFontSmall3D->getFontUniqueId();
|
||||
renderer.endFont(displayFontSmall3D, rsGlobal);
|
||||
displayFontSmall3D=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, displayFontSmall3D);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == true) {
|
||||
displayFontSmall3D= renderer.newFont3D(rsGlobal);
|
||||
if(displayFontSmall3D) {
|
||||
displayFontSmall3D->setType(displayFontNameSmall,config.getString("FontSmallDisplay",""),config.getString("FontSmallDisplayFamily",""));
|
||||
displayFontSmall3D->setSize(displayFontNameSmallSize);
|
||||
displayFontSmall3D->setFontUniqueId("displayFontSmall3D");
|
||||
triggerFontChangedCallbacks(displayFontSmall3D->getFontUniqueId(), displayFontSmall3D);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1265,8 +1309,10 @@ void CoreData::loadFonts() {
|
|||
string menuFontNameNormal= menuFontNameNormalPrefix + intToStr(menuFontNameNormalSize) + menuFontNameNormalPostfix;
|
||||
|
||||
if(menuFontNormal) {
|
||||
string fontUniqueId = menuFontNormal->getFontUniqueId();
|
||||
renderer.endFont(menuFontNormal, rsGlobal);
|
||||
menuFontNormal=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, menuFontNormal);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
menuFontNormal= renderer.newFont(rsGlobal);
|
||||
|
@ -1274,12 +1320,16 @@ void CoreData::loadFonts() {
|
|||
menuFontNormal->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily",""));
|
||||
menuFontNormal->setSize(menuFontNameNormalSize);
|
||||
menuFontNormal->setWidth(Font::wBold);
|
||||
menuFontNormal->setFontUniqueId("menuFontNormal");
|
||||
triggerFontChangedCallbacks(menuFontNormal->getFontUniqueId(), menuFontNormal);
|
||||
}
|
||||
}
|
||||
|
||||
if(menuFontNormal3D) {
|
||||
string fontUniqueId = menuFontNormal3D->getFontUniqueId();
|
||||
renderer.endFont(menuFontNormal3D, rsGlobal);
|
||||
menuFontNormal3D=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, menuFontNormal3D);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == true) {
|
||||
menuFontNormal3D= renderer.newFont3D(rsGlobal);
|
||||
|
@ -1287,6 +1337,8 @@ void CoreData::loadFonts() {
|
|||
menuFontNormal3D->setType(menuFontNameNormal,config.getString("FontMenuNormal",""),config.getString("FontMenuNormalFamily",""));
|
||||
menuFontNormal3D->setSize(menuFontNameNormalSize);
|
||||
menuFontNormal3D->setWidth(Font::wBold);
|
||||
menuFontNormal3D->setFontUniqueId("menuFontNormal3D");
|
||||
triggerFontChangedCallbacks(menuFontNormal3D->getFontUniqueId(), menuFontNormal3D);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1309,26 +1361,34 @@ void CoreData::loadFonts() {
|
|||
string menuFontNameBig= menuFontNameBigPrefix+intToStr(menuFontNameBigSize)+menuFontNameBigPostfix;
|
||||
|
||||
if(menuFontBig) {
|
||||
string fontUniqueId = menuFontBig->getFontUniqueId();
|
||||
renderer.endFont(menuFontBig, rsGlobal);
|
||||
menuFontBig=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, menuFontBig);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
menuFontBig= renderer.newFont(rsGlobal);
|
||||
if(menuFontBig) {
|
||||
menuFontBig->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily",""));
|
||||
menuFontBig->setSize(menuFontNameBigSize);
|
||||
menuFontBig->setFontUniqueId("menuFontBig");
|
||||
triggerFontChangedCallbacks(menuFontBig->getFontUniqueId(), menuFontBig);
|
||||
}
|
||||
}
|
||||
|
||||
if(menuFontBig3D) {
|
||||
string fontUniqueId = menuFontBig3D->getFontUniqueId();
|
||||
renderer.endFont(menuFontBig3D, rsGlobal);
|
||||
menuFontBig3D=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, menuFontBig3D);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == true) {
|
||||
menuFontBig3D= renderer.newFont3D(rsGlobal);
|
||||
if(menuFontBig3D) {
|
||||
menuFontBig3D->setType(menuFontNameBig,config.getString("FontMenuBig",""),config.getString("FontMenuBigFamily",""));
|
||||
menuFontBig3D->setSize(menuFontNameBigSize);
|
||||
menuFontBig3D->setFontUniqueId("menuFontBig3D");
|
||||
triggerFontChangedCallbacks(menuFontBig3D->getFontUniqueId(), menuFontBig3D);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1351,26 +1411,34 @@ void CoreData::loadFonts() {
|
|||
string menuFontNameVeryBig= menuFontNameVeryBigPrefix + intToStr(menuFontNameVeryBigSize) + menuFontNameVeryBigPostfix;
|
||||
|
||||
if(menuFontVeryBig) {
|
||||
string fontUniqueId = menuFontVeryBig->getFontUniqueId();
|
||||
renderer.endFont(menuFontVeryBig, rsGlobal);
|
||||
menuFontVeryBig=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, menuFontVeryBig);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
menuFontVeryBig= renderer.newFont(rsGlobal);
|
||||
if(menuFontVeryBig) {
|
||||
menuFontVeryBig->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily",""));
|
||||
menuFontVeryBig->setSize(menuFontNameVeryBigSize);
|
||||
menuFontVeryBig->setFontUniqueId("menuFontVeryBig");
|
||||
triggerFontChangedCallbacks(menuFontVeryBig->getFontUniqueId(), menuFontVeryBig);
|
||||
}
|
||||
}
|
||||
|
||||
if(menuFontVeryBig3D) {
|
||||
string fontUniqueId = menuFontVeryBig3D->getFontUniqueId();
|
||||
renderer.endFont(menuFontVeryBig3D, rsGlobal);
|
||||
menuFontVeryBig3D=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, menuFontVeryBig3D);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == true) {
|
||||
menuFontVeryBig3D= renderer.newFont3D(rsGlobal);
|
||||
if(menuFontVeryBig3D) {
|
||||
menuFontVeryBig3D->setType(menuFontNameVeryBig,config.getString("FontMenuVeryBig",""),config.getString("FontMenuVeryBigFamily",""));
|
||||
menuFontVeryBig3D->setSize(menuFontNameVeryBigSize);
|
||||
menuFontVeryBig3D->setFontUniqueId("menuFontVeryBig3D");
|
||||
triggerFontChangedCallbacks(menuFontVeryBig3D->getFontUniqueId(), menuFontVeryBig3D);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1394,26 +1462,35 @@ void CoreData::loadFonts() {
|
|||
string consoleFontName= consoleFontNamePrefix + intToStr(consoleFontNameSize) + consoleFontNamePostfix;
|
||||
|
||||
if(consoleFont) {
|
||||
string fontUniqueId = consoleFont->getFontUniqueId();
|
||||
renderer.endFont(consoleFont, rsGlobal);
|
||||
consoleFont=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, consoleFont);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == false) {
|
||||
consoleFont= renderer.newFont(rsGlobal);
|
||||
if(consoleFont) {
|
||||
consoleFont->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily",""));
|
||||
consoleFont->setSize(consoleFontNameSize);
|
||||
consoleFont->setFontUniqueId("consoleFont");
|
||||
triggerFontChangedCallbacks(consoleFont->getFontUniqueId(), consoleFont);
|
||||
}
|
||||
}
|
||||
|
||||
if(consoleFont3D) {
|
||||
string fontUniqueId = consoleFont3D->getFontUniqueId();
|
||||
renderer.endFont(consoleFont3D, rsGlobal);
|
||||
consoleFont3D=NULL;
|
||||
triggerFontChangedCallbacks(fontUniqueId, consoleFont3D);
|
||||
}
|
||||
if(Renderer::renderText3DEnabled == true) {
|
||||
consoleFont3D= renderer.newFont3D(rsGlobal);
|
||||
if(consoleFont3D) {
|
||||
consoleFont3D->setType(consoleFontName,config.getString("FontConsole",""),config.getString("FontConsoleFamily",""));
|
||||
consoleFont3D->setSize(consoleFontNameSize);
|
||||
consoleFont3D->setFontUniqueId("consoleFont3D");
|
||||
triggerFontChangedCallbacks(consoleFont3D->getFontUniqueId(), consoleFont3D);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,11 +28,14 @@ namespace Glest{ namespace Game{
|
|||
|
||||
using ::Shared::Graphics::Texture2D;
|
||||
using ::Shared::Graphics::Texture3D;
|
||||
using ::Shared::Graphics::Font;
|
||||
using ::Shared::Graphics::Font2D;
|
||||
using ::Shared::Graphics::Font3D;
|
||||
using ::Shared::Graphics::FontChangedCallbackInterface;
|
||||
using ::Shared::Sound::StrSound;
|
||||
using ::Shared::Sound::StaticSound;
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class CoreData
|
||||
//
|
||||
|
@ -111,6 +114,7 @@ private:
|
|||
string battleEndLoseVideoFilenameFallback;
|
||||
string battleEndLoseMusicFilename;
|
||||
|
||||
std::map<std::string,std::vector<FontChangedCallbackInterface *>> registeredFontChangedCallbacks;
|
||||
public:
|
||||
|
||||
enum TextureSystemType {
|
||||
|
@ -232,6 +236,8 @@ public:
|
|||
void saveGameSettingsToFile(std::string fileName, GameSettings *gameSettings,int advancedIndex=0);
|
||||
bool loadGameSettingsFromFile(std::string fileName, GameSettings *gameSettings);
|
||||
|
||||
void registerFontChangedCallback(std::string entityName, FontChangedCallbackInterface *cb);
|
||||
void unRegisterFontChangedCallback(std::string entityName);
|
||||
private:
|
||||
|
||||
CoreData();
|
||||
|
@ -256,6 +262,8 @@ private:
|
|||
|
||||
void loadWaterSoundsIfRequired();
|
||||
void loadMusicIfRequired();
|
||||
|
||||
void triggerFontChangedCallbacks(std::string fontUniqueId, Font *font);
|
||||
};
|
||||
|
||||
}} //end namespace
|
||||
|
|
|
@ -2864,7 +2864,9 @@ Vec2f Renderer::getCentered3DPos(const string &text, Font3D *font, Vec2f &pos, i
|
|||
throw megaglest_runtime_error("font == NULL (5) text = " + text);
|
||||
}
|
||||
else if(font->getTextHandler() == NULL) {
|
||||
throw megaglest_runtime_error("font->getTextHandler() == NULL (5) text = " + text);
|
||||
char szBuf[8096] = "";
|
||||
snprintf(szBuf, 8096, "font->getTextHandler() == NULL(5) text = [%s] FontPtr = [%p]\n", text.c_str(),font);
|
||||
throw megaglest_runtime_error(szBuf);
|
||||
}
|
||||
|
||||
float lineWidth = (font->getTextHandler()->Advance(text.c_str()) * ::Shared::Graphics::Font::scaleFontValue);
|
||||
|
@ -3773,6 +3775,7 @@ void Renderer::renderListBox(GraphicListBox *listBox) {
|
|||
glEnable(GL_BLEND);
|
||||
|
||||
GraphicLabel label;
|
||||
label.setInstanceName("ListBox_render_label");
|
||||
if(listBox->getLeftControlled()==true){
|
||||
label.init(listBox->getX()+listBox->getButton1()->getW()+listBox->getButton2()->getW()+2, listBox->getY(), listBox->getW(), listBox->getH(), false,listBox->getTextColor());
|
||||
}
|
||||
|
|
|
@ -818,6 +818,7 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep, bool fatalExit) {
|
|||
|
||||
MainWindow::MainWindow(Program *program) : WindowGl() {
|
||||
this->program= program;
|
||||
this->popupMenu.registerGraphicComponentOnlyFontCallbacks("MainWindow", "popupMenu");
|
||||
this->popupMenu.setEnabled(false);
|
||||
this->popupMenu.setVisible(false);
|
||||
this->triggerLanguageToggle = false;
|
||||
|
|
|
@ -123,6 +123,7 @@ void ProgramState::mouseMove(int x, int y, const MouseState *mouseState) {
|
|||
Program::ShowMessageProgramState::ShowMessageProgramState(Program *program, const char *msg) :
|
||||
ProgramState(program) {
|
||||
userWantsExit = false;
|
||||
msgBox.registerGraphicComponent("ShowMessageProgramState", "msgBox");
|
||||
msgBox.init("Ok");
|
||||
|
||||
if(msg) {
|
||||
|
@ -193,6 +194,7 @@ Program::Program() {
|
|||
|
||||
//mesage box
|
||||
Lang &lang= Lang::getInstance();
|
||||
msgBox.registerGraphicComponent("Program", "msgBox");
|
||||
msgBox.init(lang.getString("Ok"));
|
||||
msgBox.setEnabled(false);
|
||||
}
|
||||
|
|
|
@ -301,10 +301,10 @@ void MainMenu::consoleAddLine(string line) {
|
|||
|
||||
MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateName){
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
this->containerName="";
|
||||
this->containerName = "";
|
||||
this->program= program;
|
||||
this->mainMenu= mainMenu;
|
||||
console.registerGraphicComponent(containerName, "menuStateConsole");
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
//switch on menu music again, it might be muted
|
||||
|
@ -342,7 +342,7 @@ MenuState::MenuState(Program *program, MainMenu *mainMenu, const string &stateNa
|
|||
degToRad(startRotation.x),
|
||||
degToRad(startRotation.y),
|
||||
degToRad(startRotation.z))));
|
||||
|
||||
|
||||
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
|
|
@ -257,7 +257,7 @@ private:
|
|||
public:
|
||||
|
||||
MenuStateConnectedGame(Program *program, MainMenu *mainMenu, JoinMenu joinMenuInfo=jmSimple, bool openNetworkSlots= false);
|
||||
~MenuStateConnectedGame();
|
||||
virtual ~MenuStateConnectedGame();
|
||||
|
||||
void mouseClick(int x, int y, MouseButton mouseButton);
|
||||
void mouseMove(int x, int y, const MouseState *mouseState);
|
||||
|
|
|
@ -383,30 +383,17 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu, Program
|
|||
}
|
||||
|
||||
void MenuStateOptions::reloadUI() {
|
||||
Lang &lang= Lang::getInstance();
|
||||
console.resetFonts();
|
||||
GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||
Lang &lang = Lang::getInstance();
|
||||
//console.resetFonts();
|
||||
//GraphicComponent::reloadFontsForRegisterGraphicComponents(containerName);
|
||||
|
||||
mainMessageBox.init(lang.getString("Ok"));
|
||||
luaMessageBox.init(lang.getString("Yes"),lang.getString("No"));
|
||||
|
||||
buttonAudioSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
buttonAudioSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||
buttonAudioSection.setText(lang.getString("Audio"));
|
||||
|
||||
buttonVideoSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
buttonVideoSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||
buttonVideoSection.setText(lang.getString("Video"));
|
||||
|
||||
buttonMiscSection.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
buttonMiscSection.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||
buttonMiscSection.setText(lang.getString("Misc"));
|
||||
|
||||
buttonNetworkSettings.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
buttonNetworkSettings.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||
buttonNetworkSettings.setText(lang.getString("Network"));
|
||||
|
||||
buttonKeyboardSetup.setFont(CoreData::getInstance().getMenuFontVeryBig());
|
||||
buttonKeyboardSetup.setFont3D(CoreData::getInstance().getMenuFontVeryBig3D());
|
||||
buttonKeyboardSetup.setText(lang.getString("Keyboardsetup"));
|
||||
|
||||
labelVisibleHud.setText(lang.getString("VisibleHUD"));
|
||||
|
@ -415,24 +402,14 @@ void MenuStateOptions::reloadUI() {
|
|||
labelTimeDisplay.setText(lang.getString("TimeDisplay"));
|
||||
|
||||
labelLuaDisableSecuritySandbox.setText(lang.getString("LuaDisableSecuritySandbox"));
|
||||
|
||||
labelLang.setText(lang.getString("Language"));
|
||||
|
||||
labelPlayerNameLabel.setText(lang.getString("Playername"));
|
||||
|
||||
labelPlayerName.setFont(CoreData::getInstance().getMenuFontBig());
|
||||
labelPlayerName.setFont3D(CoreData::getInstance().getMenuFontBig3D());
|
||||
|
||||
labelFontSizeAdjustment.setText(lang.getString("FontSizeAdjustment"));
|
||||
|
||||
labelScreenShotType.setText(lang.getString("ScreenShotFileType"));
|
||||
|
||||
labelDisableScreenshotConsoleText.setText(lang.getString("ScreenShotConsoleText"));
|
||||
|
||||
labelMouseMoveScrollsWorld.setText(lang.getString("MouseScrollsWorld"));
|
||||
labelCameraMoveSpeed.setText(lang.getString("CameraMoveSpeed"));
|
||||
|
||||
|
||||
buttonOk.setText(lang.getString("Save"));
|
||||
buttonReturn.setText(lang.getString("Return"));
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ MenuStateOptionsGraphics::MenuStateOptionsGraphics(Program *program, MainMenu *m
|
|||
MenuState(program, mainMenu, "config")
|
||||
{
|
||||
try {
|
||||
containerName = "Options";
|
||||
containerName = "Options_Graphics";
|
||||
this->parentUI=parentUI;
|
||||
Lang &lang= Lang::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
|
|
|
@ -39,7 +39,7 @@ MenuStateOptionsNetwork::MenuStateOptionsNetwork(Program *program, MainMenu *mai
|
|||
MenuState(program, mainMenu, "config")
|
||||
{
|
||||
try {
|
||||
containerName = "Options";
|
||||
containerName = "Options_Network";
|
||||
Lang &lang= Lang::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
this->parentUI=parentUI;
|
||||
|
|
|
@ -39,7 +39,7 @@ MenuStateOptionsSound::MenuStateOptionsSound(Program *program, MainMenu *mainMen
|
|||
MenuState(program, mainMenu, "config")
|
||||
{
|
||||
try {
|
||||
containerName = "Options";
|
||||
containerName = "Options_Sound";
|
||||
this->parentUI=parentUI;
|
||||
Lang &lang= Lang::getInstance();
|
||||
Config &config= Config::getInstance();
|
||||
|
|
|
@ -106,6 +106,7 @@ MenuStateRoot::MenuStateRoot(Program *program, MainMenu *mainMenu):
|
|||
menuItems.push_back("1");
|
||||
menuItems.push_back("2");
|
||||
menuItems.push_back("3");
|
||||
popupMenu.registerGraphicComponentOnlyFontCallbacks(containerName, "popupMenu");
|
||||
popupMenu.setW(100);
|
||||
popupMenu.setH(100);
|
||||
popupMenu.init("Test Menu",menuItems);
|
||||
|
|
|
@ -22,7 +22,7 @@ using std::string;
|
|||
//class Text;
|
||||
|
||||
namespace Shared { namespace Graphics {
|
||||
|
||||
|
||||
// =====================================================
|
||||
// class FontMetrics
|
||||
// =====================================================
|
||||
|
@ -90,6 +90,7 @@ protected:
|
|||
FontMetrics metrics;
|
||||
|
||||
Text *textHandler;
|
||||
string fontUniqueId;
|
||||
|
||||
public:
|
||||
//constructor & destructor
|
||||
|
@ -97,6 +98,9 @@ public:
|
|||
virtual ~Font();
|
||||
virtual void init()=0;
|
||||
virtual void end()=0;
|
||||
|
||||
void setFontUniqueId(string id) { fontUniqueId = id; }
|
||||
string getFontUniqueId() { return fontUniqueId; }
|
||||
|
||||
//get
|
||||
int getWidth() const;
|
||||
|
@ -147,6 +151,12 @@ Font3D *ConvertFont2DTo3D(Font2D *font);
|
|||
|
||||
const char* findFont(const char *firstFontToTry=NULL,const char *firstFontFamilyToTry=NULL);
|
||||
|
||||
class FontChangedCallbackInterface {
|
||||
public:
|
||||
virtual void FontChangedCallback(std::string fontUniqueId, Font *font) = 0;
|
||||
virtual ~FontChangedCallbackInterface() {};
|
||||
};
|
||||
|
||||
}}//end namespace
|
||||
|
||||
#endif
|
||||
|
|
|
@ -99,6 +99,7 @@ void Font::resetToDefaults() {
|
|||
|
||||
FontMetrics::FontMetrics(Text *textHandler) {
|
||||
this->textHandler = textHandler;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler,this);
|
||||
this->widths = new float[Font::charCount];
|
||||
this->height = 0;
|
||||
|
||||
|
@ -114,6 +115,7 @@ FontMetrics::~FontMetrics() {
|
|||
|
||||
void FontMetrics::setTextHandler(Text *textHandler) {
|
||||
this->textHandler = textHandler;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
|
||||
Text * FontMetrics::getTextHandler() {
|
||||
|
@ -214,7 +216,8 @@ Font::Font(FontTextHandlerType type) {
|
|||
this->type = fontTypeName;
|
||||
width = 400;
|
||||
size = 10;
|
||||
textHandler = NULL;
|
||||
this->textHandler = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
|
||||
#if defined(USE_FTGL)
|
||||
|
||||
|
@ -225,8 +228,9 @@ Font::Font(FontTextHandlerType type) {
|
|||
TextFTGL::faceResolution = Font::faceResolution;
|
||||
TextFTGL::langHeightText = Font::langHeightText;
|
||||
|
||||
textHandler = NULL;
|
||||
textHandler = new TextFTGL(type);
|
||||
this->textHandler = NULL;
|
||||
this->textHandler = new TextFTGL(type);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
|
||||
TextFTGL::faceResolution = Font::faceResolution;
|
||||
TextFTGL::langHeightText = Font::langHeightText;
|
||||
|
@ -237,6 +241,7 @@ Font::Font(FontTextHandlerType type) {
|
|||
catch(exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
textHandler = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -244,10 +249,12 @@ Font::Font(FontTextHandlerType type) {
|
|||
}
|
||||
|
||||
Font::~Font() {
|
||||
if(textHandler) {
|
||||
delete textHandler;
|
||||
if(this->textHandler) {
|
||||
delete this->textHandler;
|
||||
}
|
||||
textHandler = NULL;
|
||||
this->textHandler = NULL;
|
||||
metrics.setTextHandler(this->textHandler);
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
|
||||
string Font::getType() const {
|
||||
|
@ -264,6 +271,7 @@ void Font::setType(string typeX11, string typeGeneric, string typeGenericFamily)
|
|||
catch(exception &ex) {
|
||||
SystemFlags::OutputDebug(SystemFlags::debugError,"In [%s::%s Line: %d] Error [%s]\n",__FILE__,__FUNCTION__,__LINE__,ex.what());
|
||||
textHandler = NULL;
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugError, "In [%s::%s Line: %d] this->textHandler = [%p] Owner = [%p]\n", __FILE__, __FUNCTION__, __LINE__, this->textHandler, this);
|
||||
}
|
||||
}
|
||||
if(textHandler == NULL) {
|
||||
|
|
Loading…
Reference in New Issue