diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 6e090b618..3d9a54f91 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -127,6 +127,7 @@ const char *GAME_ARGS[] = { "--disable-sound", "--enable-legacyfonts", "--use-video-settings", + "--use-font", "--verbose" }; @@ -163,6 +164,7 @@ enum GAME_ARG_TYPE { GAME_ARG_DISABLE_SOUND, GAME_ARG_ENABLE_LEGACYFONTS, GAME_ARG_USE_VIDEO_SETTINGS, + GAME_ARG_USE_FONT, GAME_ARG_VERBOSE_MODE }; @@ -1075,6 +1077,10 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n \t\texample: %s %s=1024x768x*x*",argv0,GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]); printf("\n \t\tsame result for: %s %s=1024x768",argv0,GAME_ARGS[GAME_ARG_USE_VIDEO_SETTINGS]); + printf("\n%s=x\t\t\toverride the font to use.",GAME_ARGS[GAME_ARG_USE_FONT]); + printf("\n \t\tWhere x is the path and name of a font file support by freetype2."); + printf("\n \t\texample: %s %s=$APPLICATIONDATAPATH/data/core/fonts/Vera.ttf",argv0,GAME_ARGS[GAME_ARG_USE_FONT]); + printf("\n%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]); printf("\n\n"); @@ -1096,6 +1102,7 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { Tokenize(customPath,paramPartTokens,"="); if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { string customPathValue = paramPartTokens[1]; + Properties::applyTagsToValue(customPathValue); if(customPathValue != "") { endPathWithSlash(customPathValue); } @@ -1132,6 +1139,7 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { Tokenize(customPath,paramPartTokens,"="); if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { string customPathValue = paramPartTokens[1]; + Properties::applyTagsToValue(customPathValue); pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue; if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom ini path [%s]\n",customPathValue.c_str()); } @@ -1155,6 +1163,7 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { Tokenize(customPath,paramPartTokens,"="); if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { string customPathValue = paramPartTokens[1]; + Properties::applyTagsToValue(customPathValue); pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue; if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom logs path [%s]\n",customPathValue.c_str()); } @@ -2708,6 +2717,35 @@ int glestMain(int argc, char** argv) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",__FILE__,__FUNCTION__,__LINE__,Font::charCount,Font::fontTypeName.c_str(),Shared::Platform::charSet,Font::fontIsMultibyte,Font::fontIsRightToLeft); if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using Font::charCount = %d, Font::fontTypeName [%s] Shared::Platform::charSet = %d, Font::fontIsMultibyte = %d, Font::fontIsRightToLeft = %d\n",Font::charCount,Font::fontTypeName.c_str(),Shared::Platform::charSet,Font::fontIsMultibyte,Font::fontIsRightToLeft); + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_USE_FONT]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_FONT]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_USE_FONT]),&foundParamIndIndex); + } + string paramValue = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(paramValue,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string newfont = paramPartTokens[1]; + //printf("#1 Forcing font [%s] paramPartTokens.size() = %d, paramValue [%s]\n",newfont.c_str(),paramPartTokens.size(),paramValue.c_str()); + Properties::applyTagsToValue(newfont); + printf("Forcing font [%s]\n",newfont.c_str()); + +#if defined(WIN32) + string newEnvValue = "MEGAGLEST_FONT=" + newfont; + _putenv(newEnvValue.c_str()); +#else + setenv("MEGAGLEST_FONT",newfont.c_str(),1); +#endif + } + else { + printf("\nInvalid missing font specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + //printParameterHelp(argv[0],false); + return -1; + } + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]) == true) { diff --git a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp index bd4774d58..c7fc63a47 100644 --- a/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp +++ b/source/shared_lib/sources/graphics/gl/font_textFTGL.cpp @@ -274,6 +274,7 @@ const char* TextFTGL::findFont(const char *firstFontToTry) { path = filename; \ if( !font && path && fileExists(path) == true ) \ font = strdup(path); \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found font file [%s]\n",font); \ } string tryFont = ""; diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index ee972f366..1a4ca27aa 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -453,6 +453,7 @@ std::map Properties::getTagReplacementValues(std::map Properties::getTagReplacementValues(std::map Properties::getTagReplacementValues(std::map Properties::getTagReplacementValues(std::map Properties::getTagReplacementValues(std::map *mapTagReplacementValues) { string originalValue = value; + //if(originalValue.find("$APPLICATIONDATAPATH") != string::npos) { + // printf("\nBEFORE SUBSTITUTE [%s] app [%s] mapTagReplacementValues [%p]\n",originalValue.c_str(),Properties::applicationPath.c_str(),mapTagReplacementValues); + //} + if(mapTagReplacementValues != NULL) { for(std::map::iterator iterMap = mapTagReplacementValues->begin(); iterMap != mapTagReplacementValues->end(); ++iterMap) { @@ -536,6 +546,7 @@ bool Properties::applyTagsToValue(string &value, std::map *mapTag replaceAll(value, "%%HOME%%", (homeDir != NULL ? homeDir : "")); replaceAll(value, "%%USERPROFILE%%",(homeDir != NULL ? homeDir : "")); replaceAll(value, "%%HOMEPATH%%", (homeDir != NULL ? homeDir : "")); + replaceAll(value, "{HOMEPATH}", (homeDir != NULL ? homeDir : "")); // For win32 we allow use of the appdata variable since that is the recommended // place for application data in windows platform @@ -553,8 +564,9 @@ bool Properties::applyTagsToValue(string &value, std::map *mapTag std::string appPath = utf8_encode(szPath); //string appPath = szPath; - replaceAll(value, "$APPDATA", appPath); + replaceAll(value, "$APPDATA", appPath); replaceAll(value, "%%APPDATA%%", appPath); + replaceAll(value, "{APPDATA}", appPath); } #endif @@ -562,13 +574,16 @@ bool Properties::applyTagsToValue(string &value, std::map *mapTag username = getenv("USERNAME"); replaceAll(value, "$USERNAME", (username != NULL ? username : "")); replaceAll(value, "%%USERNAME%%", (username != NULL ? username : "")); + replaceAll(value, "{USERNAME}", (username != NULL ? username : "")); replaceAll(value, "$APPLICATIONPATH", Properties::applicationPath); replaceAll(value, "%%APPLICATIONPATH%%", Properties::applicationPath); + replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath); #if defined(CUSTOM_DATA_INSTALL_PATH) replaceAll(value, "$APPLICATIONDATAPATH", CUSTOM_DATA_INSTALL_PATH); replaceAll(value, "%%APPLICATIONDATAPATH%%", CUSTOM_DATA_INSTALL_PATH); + replaceAll(value, "{APPLICATIONDATAPATH}", CUSTOM_DATA_INSTALL_PATH); //replaceAll(value, "$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //replaceAll(value, "%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); @@ -576,6 +591,7 @@ bool Properties::applyTagsToValue(string &value, std::map *mapTag #else replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath); replaceAll(value, "%%APPLICATIONDATAPATH%%", Properties::applicationPath); + replaceAll(value, "{APPLICATIONDATAPATH}", Properties::applicationPath); //replaceAll(value, "$COMMONDATAPATH", Properties::applicationPath + "/commondata/"); //replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/"); @@ -583,7 +599,9 @@ bool Properties::applyTagsToValue(string &value, std::map *mapTag } - //printf("\nBEFORE SUBSTITUTE [%s] AFTER [%s]\n",originalValue.c_str(),value.c_str()); + //if(originalValue != value || originalValue.find("$APPLICATIONDATAPATH") != string::npos) { + // printf("\nBEFORE SUBSTITUTE [%s] AFTER [%s]\n",originalValue.c_str(),value.c_str()); + //} return (originalValue != value); }