- added new commandline option to override font file

This commit is contained in:
Mark Vejvoda
2011-06-12 03:44:50 +00:00
parent 752dd26bcd
commit 722261e212
3 changed files with 59 additions and 2 deletions

View File

@@ -127,6 +127,7 @@ const char *GAME_ARGS[] = {
"--disable-sound", "--disable-sound",
"--enable-legacyfonts", "--enable-legacyfonts",
"--use-video-settings", "--use-video-settings",
"--use-font",
"--verbose" "--verbose"
}; };
@@ -163,6 +164,7 @@ enum GAME_ARG_TYPE {
GAME_ARG_DISABLE_SOUND, GAME_ARG_DISABLE_SOUND,
GAME_ARG_ENABLE_LEGACYFONTS, GAME_ARG_ENABLE_LEGACYFONTS,
GAME_ARG_USE_VIDEO_SETTINGS, GAME_ARG_USE_VIDEO_SETTINGS,
GAME_ARG_USE_FONT,
GAME_ARG_VERBOSE_MODE 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\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 \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%s\t\t\tdisplays verbose information in the console.",GAME_ARGS[GAME_ARG_VERBOSE_MODE]);
printf("\n\n"); printf("\n\n");
@@ -1096,6 +1102,7 @@ int setupGameItemPaths(int argc, char** argv, Config *config) {
Tokenize(customPath,paramPartTokens,"="); Tokenize(customPath,paramPartTokens,"=");
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
string customPathValue = paramPartTokens[1]; string customPathValue = paramPartTokens[1];
Properties::applyTagsToValue(customPathValue);
if(customPathValue != "") { if(customPathValue != "") {
endPathWithSlash(customPathValue); endPathWithSlash(customPathValue);
} }
@@ -1132,6 +1139,7 @@ int setupGameItemPaths(int argc, char** argv, Config *config) {
Tokenize(customPath,paramPartTokens,"="); Tokenize(customPath,paramPartTokens,"=");
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
string customPathValue = paramPartTokens[1]; string customPathValue = paramPartTokens[1];
Properties::applyTagsToValue(customPathValue);
pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue; pathCache[GameConstants::path_ini_CacheLookupKey]=customPathValue;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom ini path [%s]\n",customPathValue.c_str()); 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,"="); Tokenize(customPath,paramPartTokens,"=");
if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) {
string customPathValue = paramPartTokens[1]; string customPathValue = paramPartTokens[1];
Properties::applyTagsToValue(customPathValue);
pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue; pathCache[GameConstants::path_logs_CacheLookupKey]=customPathValue;
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom logs path [%s]\n",customPathValue.c_str()); 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); 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(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<string> 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__); 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) { if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SHOW_MAP_CRC]) == true) {

View File

@@ -274,6 +274,7 @@ const char* TextFTGL::findFont(const char *firstFontToTry) {
path = filename; \ path = filename; \
if( !font && path && fileExists(path) == true ) \ if( !font && path && fileExists(path) == true ) \
font = strdup(path); \ font = strdup(path); \
if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Found font file [%s]\n",font); \
} }
string tryFont = ""; string tryFont = "";

View File

@@ -453,6 +453,7 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
mapTagReplacementValues["%%HOME%%"] = (homeDir != NULL ? homeDir : ""); mapTagReplacementValues["%%HOME%%"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["%%USERPROFILE%%"] = (homeDir != NULL ? homeDir : ""); mapTagReplacementValues["%%USERPROFILE%%"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["%%HOMEPATH%%"] = (homeDir != NULL ? homeDir : ""); mapTagReplacementValues["%%HOMEPATH%%"] = (homeDir != NULL ? homeDir : "");
mapTagReplacementValues["{HOMEPATH}"] = (homeDir != NULL ? homeDir : "");
// For win32 we allow use of the appdata variable since that is the recommended // For win32 we allow use of the appdata variable since that is the recommended
// place for application data in windows platform // place for application data in windows platform
@@ -473,6 +474,7 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
//string appPath = szPath; //string appPath = szPath;
mapTagReplacementValues["$APPDATA"] = appPath; mapTagReplacementValues["$APPDATA"] = appPath;
mapTagReplacementValues["%%APPDATA%%"] = appPath; mapTagReplacementValues["%%APPDATA%%"] = appPath;
mapTagReplacementValues["{APPDATA}"] = appPath;
} }
#endif #endif
@@ -481,13 +483,16 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
mapTagReplacementValues["$USERNAME"] = (username != NULL ? username : ""); mapTagReplacementValues["$USERNAME"] = (username != NULL ? username : "");
mapTagReplacementValues["%%USERNAME%%"] = (username != NULL ? username : ""); mapTagReplacementValues["%%USERNAME%%"] = (username != NULL ? username : "");
mapTagReplacementValues["{USERNAME}"] = (username != NULL ? username : "");
mapTagReplacementValues["$APPLICATIONPATH"] = Properties::applicationPath; mapTagReplacementValues["$APPLICATIONPATH"] = Properties::applicationPath;
mapTagReplacementValues["%%APPLICATIONPATH%%"] = Properties::applicationPath; mapTagReplacementValues["%%APPLICATIONPATH%%"] = Properties::applicationPath;
mapTagReplacementValues["{APPLICATIONPATH}"] = Properties::applicationPath;
#if defined(CUSTOM_DATA_INSTALL_PATH) #if defined(CUSTOM_DATA_INSTALL_PATH)
mapTagReplacementValues["$APPLICATIONDATAPATH"] = CUSTOM_DATA_INSTALL_PATH; mapTagReplacementValues["$APPLICATIONDATAPATH"] = CUSTOM_DATA_INSTALL_PATH;
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = CUSTOM_DATA_INSTALL_PATH; mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = CUSTOM_DATA_INSTALL_PATH;
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = CUSTOM_DATA_INSTALL_PATH;
//mapTagReplacementValues["$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //mapTagReplacementValues["$COMMONDATAPATH", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/"); //mapTagReplacementValues["%%COMMONDATAPATH%%", string(CUSTOM_DATA_INSTALL_PATH) + "/commondata/");
@@ -495,6 +500,7 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
#else #else
mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationPath; mapTagReplacementValues["$APPLICATIONDATAPATH"] = Properties::applicationPath;
mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationPath; mapTagReplacementValues["%%APPLICATIONDATAPATH%%"] = Properties::applicationPath;
mapTagReplacementValues["{APPLICATIONDATAPATH}"] = Properties::applicationPath;
//mapTagReplacementValues["$COMMONDATAPATH", Properties::applicationPath + "/commondata/"); //mapTagReplacementValues["$COMMONDATAPATH", Properties::applicationPath + "/commondata/");
//mapTagReplacementValues["%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/"); //mapTagReplacementValues["%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
@@ -517,6 +523,10 @@ std::map<string,string> Properties::getTagReplacementValues(std::map<string,stri
bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTagReplacementValues) { bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTagReplacementValues) {
string originalValue = value; 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) { if(mapTagReplacementValues != NULL) {
for(std::map<string,string>::iterator iterMap = mapTagReplacementValues->begin(); for(std::map<string,string>::iterator iterMap = mapTagReplacementValues->begin();
iterMap != mapTagReplacementValues->end(); ++iterMap) { iterMap != mapTagReplacementValues->end(); ++iterMap) {
@@ -536,6 +546,7 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
replaceAll(value, "%%HOME%%", (homeDir != NULL ? homeDir : "")); replaceAll(value, "%%HOME%%", (homeDir != NULL ? homeDir : ""));
replaceAll(value, "%%USERPROFILE%%",(homeDir != NULL ? homeDir : "")); replaceAll(value, "%%USERPROFILE%%",(homeDir != NULL ? homeDir : ""));
replaceAll(value, "%%HOMEPATH%%", (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 // For win32 we allow use of the appdata variable since that is the recommended
// place for application data in windows platform // place for application data in windows platform
@@ -555,6 +566,7 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
//string appPath = szPath; //string appPath = szPath;
replaceAll(value, "$APPDATA", appPath); replaceAll(value, "$APPDATA", appPath);
replaceAll(value, "%%APPDATA%%", appPath); replaceAll(value, "%%APPDATA%%", appPath);
replaceAll(value, "{APPDATA}", appPath);
} }
#endif #endif
@@ -562,13 +574,16 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
username = getenv("USERNAME"); username = getenv("USERNAME");
replaceAll(value, "$USERNAME", (username != NULL ? username : "")); replaceAll(value, "$USERNAME", (username != NULL ? 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); replaceAll(value, "%%APPLICATIONPATH%%", Properties::applicationPath);
replaceAll(value, "{APPLICATIONPATH}", Properties::applicationPath);
#if defined(CUSTOM_DATA_INSTALL_PATH) #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, "%%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/");
//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<string,string> *mapTag
#else #else
replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath); replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath);
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/");
//replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/"); //replaceAll(value, "%%COMMONDATAPATH%%", Properties::applicationPath + "/commondata/");
@@ -583,7 +599,9 @@ bool Properties::applyTagsToValue(string &value, std::map<string,string> *mapTag
} }
//if(originalValue != value || originalValue.find("$APPLICATIONDATAPATH") != string::npos) {
// printf("\nBEFORE SUBSTITUTE [%s] AFTER [%s]\n",originalValue.c_str(),value.c_str()); // printf("\nBEFORE SUBSTITUTE [%s] AFTER [%s]\n",originalValue.c_str(),value.c_str());
//}
return (originalValue != value); return (originalValue != value);
} }