diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cd2f021..06c10746 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,7 @@ OPTION(BUILD_MEGAGLEST_MODEL_IMPORT_EXPORT_TOOLS "Build model import/export tool OPTION(BUILD_MEGAGLEST_MODEL_VIEWER "Build model viewer" ON) OPTION(BUILD_MEGAGLEST_MAP_EDITOR "Build map editor" ON) OPTION(BUILD_MEGAGLEST "Build MegaGlest" ON) +OPTION(WITH_VLC "Use libVLC to play videos" ON) FIND_PROGRAM(HELP2MAN "help2man") diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index e26809ee..390f6071 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -1151,6 +1151,29 @@ int setupGameItemPaths(int argc, char** argv, Config *config) { } Text::DEFAULT_FONT_PATH = pathCache[GameConstants::path_data_CacheLookupKey]; + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_FONT_PATH]) == true) { + int foundParamIndIndex = -1; + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_FONT_PATH]) + string("="),&foundParamIndIndex); + if(foundParamIndIndex < 0) { + hasCommandArgument(argc, argv,string(GAME_ARGS[GAME_ARG_FONT_PATH]),&foundParamIndIndex); + } + string customPath = argv[foundParamIndIndex]; + vector paramPartTokens; + Tokenize(customPath,paramPartTokens,"="); + if(paramPartTokens.size() >= 2 && paramPartTokens[1].length() > 0) { + string customPathValue = paramPartTokens[1]; + Properties::applyTagsToValue(customPathValue); + + Text::DEFAULT_FONT_PATH_ABSOLUTE = customPathValue; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Using custom fonts path [%s]\n",customPathValue.c_str()); + } + else { + + printf("\nInvalid path specified on commandline [%s] value [%s]\n\n",argv[foundParamIndIndex],(paramPartTokens.size() >= 2 ? paramPartTokens[1].c_str() : NULL)); + printParameterHelp(argv[0],false); + return 1; + } + } return 0; } diff --git a/source/shared_lib/CMakeLists.txt b/source/shared_lib/CMakeLists.txt index 129680ec..e7dbef15 100644 --- a/source/shared_lib/CMakeLists.txt +++ b/source/shared_lib/CMakeLists.txt @@ -110,23 +110,23 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST # ENDIF() - FIND_PACKAGE(LUAJIT) - IF(LUAJIT_FOUND) - MESSAGE(STATUS "**NOTE: LUAJIT found, this should improve Lua performance.") - - INCLUDE_DIRECTORIES(${LUAJIT_INCLUDE_DIR}) - IF(UNIX) - SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUAJIT_LIBRARIES} "libdl.so") - ENDIF() - ELSE() - MESSAGE(STATUS "**WARNING: LUAJIT NOT found, so Lua performance may suffer.") - - FIND_PACKAGE(LUA REQUIRED) - INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) - IF(UNIX) - SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUA_LIBRARIES} "libdl.so") - ENDIF() +# FIND_PACKAGE(LUAJIT) +# IF(LUAJIT_FOUND) +# MESSAGE(STATUS "**NOTE: LUAJIT found, this should improve Lua performance.") +# +# INCLUDE_DIRECTORIES(${LUAJIT_INCLUDE_DIR}) +# IF(UNIX) +# SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUAJIT_LIBRARIES} "libdl.so") +# ENDIF() +# ELSE() +# MESSAGE(STATUS "**WARNING: LUAJIT NOT found, so Lua performance may suffer.") +# + FIND_PACKAGE(LUA REQUIRED) + INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR}) + IF(UNIX) + SET(EXTERNAL_LIBS ${EXTERNAL_LIBS} ${LUA_LIBRARIES} "libdl.so") ENDIF() +# ENDIF() OPTION(WANT_STATIC_LIBS "builds as many static libs as possible" OFF) @@ -223,7 +223,7 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST SET(LIBVLC_MIN_VERSION "1.1.0") FIND_PACKAGE(LIBVLC) - IF(LIBVLC_FOUND AND NOT LIBVLC_VERSION STRLESS "${LIBVLC_MIN_VERSION}") + IF(LIBVLC_FOUND AND WITH_VLC AND NOT LIBVLC_VERSION STRLESS "${LIBVLC_MIN_VERSION}") MESSAGE(STATUS "**NOTE: LIBVLC found so videos are supported.") INCLUDE_DIRECTORIES(${LIBVLC_INCLUDE_DIR}) IF(UNIX) @@ -239,6 +239,12 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST ELSE() MESSAGE(STATUS "**WARNING: LIBVLC NOT found so videos are NOT supported.") + + IF(WITH_VLC) + MESSAGE(STATUS "**WARNING: LIBVLC NOT found so videos are NOT supported.") + ELSE() + MESSAGE(STATUS "LIBVLC disabled so videos are NOT supported.") + ENDIF() ENDIF() ######################################################################################### diff --git a/source/shared_lib/include/graphics/font_text.h b/source/shared_lib/include/graphics/font_text.h index 8bfb63b1..8504a9f5 100644 --- a/source/shared_lib/include/graphics/font_text.h +++ b/source/shared_lib/include/graphics/font_text.h @@ -32,6 +32,7 @@ protected: public: static std::string DEFAULT_FONT_PATH; + static std::string DEFAULT_FONT_PATH_ABSOLUTE; Text(FontTextHandlerType type); virtual ~Text(); diff --git a/source/shared_lib/include/platform/sdl/platform_main.h b/source/shared_lib/include/platform/sdl/platform_main.h index 78c09404..b1f13b76 100644 --- a/source/shared_lib/include/platform/sdl/platform_main.h +++ b/source/shared_lib/include/platform/sdl/platform_main.h @@ -59,6 +59,7 @@ const char *GAME_ARGS[] = { "--data-path", "--ini-path", "--log-path", + "--font-path", "--show-ini-settings", "--convert-models", "--use-language", @@ -131,6 +132,7 @@ enum GAME_ARG_TYPE { GAME_ARG_DATA_PATH, GAME_ARG_INI_PATH, GAME_ARG_LOG_PATH, + GAME_ARG_FONT_PATH, GAME_ARG_SHOW_INI_SETTINGS, GAME_ARG_CONVERT_MODELS, GAME_ARG_USE_LANGUAGE, @@ -347,6 +349,10 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n%s=x\t\t\tSets the game logs path to x",GAME_ARGS[GAME_ARG_LOG_PATH]); printf("\n \t\texample:"); printf("\n %s %s=~/game_logs/",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_LOG_PATH]); + printf("\n%s=x\t\t\tSets the game fonts path to x",GAME_ARGS[GAME_ARG_FONT_PATH]); + printf("\n \t\texample:"); + printf("\n %s %s=~/myfonts/",extractFileFromDirectoryPath(argv0).c_str(),GAME_ARGS[GAME_ARG_FONT_PATH]); + printf("\n%s=x\t\tdisplay merged ini settings information.",GAME_ARGS[GAME_ARG_SHOW_INI_SETTINGS]); printf("\n \t\tWhere x is an optional property name to"); printf("\n \t\t filter (default shows all)."); diff --git a/source/shared_lib/sources/graphics/font.cpp b/source/shared_lib/sources/graphics/font.cpp index 711ba670..be5def72 100644 --- a/source/shared_lib/sources/graphics/font.cpp +++ b/source/shared_lib/sources/graphics/font.cpp @@ -366,6 +366,9 @@ string findFontFamily(const char* font, const char *fontFamily) { // -DWANT_FONTCONFIG=Off FcFini(); } + else { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("******************* FONT CONFIG will not be called font [%s] fontFamily [%s]!\n",(font != NULL ? font : "null"),(fontFamily != NULL ? fontFamily : "null")); + } #else if(SystemFlags::VERBOSE_MODE_ENABLED) printf("******************* NO FONT CONFIG ENABLED!\n"); #endif @@ -382,17 +385,19 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry path = filename; \ if( font == NULL && path != NULL && strlen(path) > 0 && fileExists(path) == true ) { \ font = strdup(path); \ - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 candidate font file [%s]\n",(font != NULL ? font : "null")); \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 candidate font file exists [%s]\n",(font != NULL ? font : "null")); \ } \ if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#1 Searching for font file [%s] result [%s]\n",(path != NULL ? path : "null"),(font != NULL ? font : "null")); \ - if( font != NULL && fontFamily != NULL && strlen(fontFamily) > 0) { \ + if( font == NULL && fontFamily != NULL && strlen(fontFamily) > 0) { \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font [%s] family [%s]\n",(font != NULL ? font : "null"),(fontFamily != NULL ? fontFamily : "null")); \ string fileFound = findFontFamily(font, fontFamily); \ if(fileFound != "") { \ path = fileFound.c_str(); \ - if( font != NULL && path && strlen(path) > 0 && fileExists(path) == true ) { \ - free((void*)font); \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file found [%s]\n",fileFound.c_str()); \ + if( path != NULL && strlen(path) > 0 && fileExists(path) == true ) { \ + if(font) free((void*)font); \ font = strdup(path); \ - if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file [%s]\n",(font != NULL ? font : "null")); \ + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 candidate font file has been set[%s]\n",(font != NULL ? font : "null")); \ } \ } \ if(SystemFlags::VERBOSE_MODE_ENABLED) printf("#2 Searching for font family [%s] result [%s]\n",(fontFamily != NULL ? fontFamily : "null"),(font != NULL ? font : "null")); \ @@ -420,6 +425,10 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry if(getenv("MEGAGLEST_FONT") != NULL) { tryFont = getenv("MEGAGLEST_FONT"); + + if(Text::DEFAULT_FONT_PATH_ABSOLUTE != "") { + tryFont = Text::DEFAULT_FONT_PATH_ABSOLUTE + "/" + extractFileFromDirectoryPath(tryFont); + } #ifdef WIN32 replaceAll(tryFont, "/", "\\"); #endif @@ -433,16 +442,20 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry string data_path = Text::DEFAULT_FONT_PATH; string defaultFont = data_path + "data/core/fonts/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf + if(Text::DEFAULT_FONT_PATH_ABSOLUTE != "") { + data_path = Text::DEFAULT_FONT_PATH; + defaultFont = data_path + "/LinBiolinum_RB.ttf";//LinBiolinum_Re-0.6.4.ttf + } tryFont = defaultFont; #ifdef WIN32 replaceAll(tryFont, "/", "\\"); #endif CHECK_FONT_PATH(tryFont.c_str(),"Linux Biolinum O:style=Bold") -#ifdef FONT_PATH + #ifdef FONT_PATH // Get distro-specified font path CHECK_FONT_PATH(FONT_PATH) -#endif + #endif CHECK_FONT_PATH("/usr/share/fonts/truetype/uralic/gothub__.ttf","Gothic Uralic:style=Regular") @@ -486,6 +499,11 @@ const char* findFont(const char *firstFontToTry,const char *firstFontFamilyToTry CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeSans.ttf","FreeSans") CHECK_FONT_PATH("/usr/share/fonts/truetype/freefont/FreeMono.ttf","FreeMono") + // gentoo paths + CHECK_FONT_PATH("/usr/share/fonts/freefont-ttf/FreeSerif.ttf","FreeSerif") + CHECK_FONT_PATH("/usr/share/fonts/freefont-ttf/FreeSans.ttf","FreeSans") + CHECK_FONT_PATH("/usr/share/fonts/freefont-ttf/FreeMono.ttf","FreeMono") + #ifdef _WIN32 CHECK_FONT_PATH("c:\\windows\\fonts\\verdana.ttf",NULL) CHECK_FONT_PATH("c:\\windows\\fonts\\tahoma.ttf",NULL) diff --git a/source/shared_lib/sources/graphics/font_text.cpp b/source/shared_lib/sources/graphics/font_text.cpp index 1738a2f8..4b969b4d 100644 --- a/source/shared_lib/sources/graphics/font_text.cpp +++ b/source/shared_lib/sources/graphics/font_text.cpp @@ -13,6 +13,7 @@ using namespace std; std::string Text::DEFAULT_FONT_PATH = ""; +std::string Text::DEFAULT_FONT_PATH_ABSOLUTE = ""; //==================================================================== Text::Text(FontTextHandlerType type) {