diff --git a/CMakeLists.txt b/CMakeLists.txt index cf4d125a..40cd595a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,10 +74,25 @@ IF(CMAKE_COMPILER_IS_GNUCXX OR MINGW) SET(SVN_VERSION_CMD "-DSVNVERSION='\\\"`svnversion -n ${PROJECT_SOURCE_DIR}`\\\"'") ENDIF() - SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SVN_VERSION_CMD}") - SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SVN_VERSION_CMD}") - SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SVN_VERSION_CMD}") - SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${SVN_VERSION_CMD}") + IF(CMAKE_INSTALL_PREFIX STREQUAL "") + #SET(MEGAGLEST_BIN_INSTALL_PATH "") + #SET(MEGAGLEST_DATA_INSTALL_PATH "") + + MESSAGE(STATUS "*NOTE: NOT USING a Custom Data Install Path...") + ELSE() + SET(MEGAGLEST_BIN_INSTALL_PATH "bin/") + SET(MEGAGLEST_DATA_INSTALL_PATH "share/megaglest/") + SET(CUSTOM_DATA_INSTALL_PATH "'\\\"${CMAKE_INSTALL_PREFIX}/${MEGAGLEST_DATA_INSTALL_PATH}\\\"'") + SET(CUSTOM_DATA_INSTALL_PATH_VALUE "-DCUSTOM_DATA_INSTALL_PATH=${CUSTOM_DATA_INSTALL_PATH}") + + MESSAGE(STATUS "*NOTE: Custom Data Install Path is [${CUSTOM_DATA_INSTALL_PATH}]") + ENDIF() + + SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${SVN_VERSION_CMD} ${CUSTOM_DATA_INSTALL_PATH_VALUE}") + SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${SVN_VERSION_CMD} ${CUSTOM_DATA_INSTALL_PATH_VALUE}") + SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${SVN_VERSION_CMD} ${CUSTOM_DATA_INSTALL_PATH_VALUE}") + SET(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} ${SVN_VERSION_CMD} ${CUSTOM_DATA_INSTALL_PATH_VALUE}") + # We do some funky character escaping to get the right stuff written out to # the final Makefile so we get the SVN Global Revsion # string(REPLACE "'" "\"" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") @@ -131,7 +146,7 @@ IF(WIN32) include_directories("${PROJECT_SOURCE_DIR}/source/win32_deps/Microsoft\ DirectX\ SDK \(November 2007\)/Include") include_directories(${PROJECT_SOURCE_DIR}/source/win32_deps/openal-soft-1.12.854/include) ENDIF() - + ADD_SUBDIRECTORY( source/shared_lib ) ADD_SUBDIRECTORY( source/glest_game ) #if(wxWidgets_FOUND) diff --git a/mk/linux/configuration.xml b/mk/linux/configuration.xml index 16a906fd..4e4b2cc5 100644 --- a/mk/linux/configuration.xml +++ b/mk/linux/configuration.xml @@ -1,9 +1,9 @@ - <file-name-main value="glest.ini"/> + <file-name-main value="$APPLICATIONDATAPATH/glest.ini"/> <file-name value="$HOME/.megaglest/glestuser.ini"/> - <icon value="true" path="glest.ico"/> + <icon value="true" path="$APPLICATIONDATAPATH/glest.ico"/> <field-groups> <field-group name="General"> <field type="Int"> @@ -358,16 +358,6 @@ system instead of a styled 3D mouse pointer."/> <enum value="false"/> </enums> </field> - <field type="Enum"> - <name value="Client and Server data file transfer support"/> - <variable-name value="AllowDownloadDataSynch"/> - <description value=""/> - <default value="false"/> - <enums> - <enum value="true"/> - <enum value="false"/> - </enums> - </field> <field type="Enum"> <name value="Enable Network Debugging Output"/> <variable-name value="DebugNetwork"/> diff --git a/mk/linux/glest.ini b/mk/linux/glest.ini index 112deb06..d13f0a95 100644 --- a/mk/linux/glest.ini +++ b/mk/linux/glest.ini @@ -19,7 +19,8 @@ ColorBits=32 ConsoleMaxLines=7 ConsoleMaxLinesStored=20 ConsoleTimeout=20 -DataPath=$APPLICATIONPATH/ +DataPath=$APPLICATIONDATAPATH/ +LogPath=$HOME/.megaglest/ DayTime=1000 DebugLogFile=debug.log DebugMode=false diff --git a/source/configurator/CMakeLists.txt b/source/configurator/CMakeLists.txt index 32ae5d06..c2ca8f13 100644 --- a/source/configurator/CMakeLists.txt +++ b/source/configurator/CMakeLists.txt @@ -59,6 +59,7 @@ SET(DIRS_WITH_SRC . ) +SET(GLEST_MAIN_INCLUDE_ROOT "../glest_game/") SET(GLEST_LIB_INCLUDE_ROOT "../shared_lib/include/") SET(GLEST_LIB_INCLUDE_DIRS @@ -71,10 +72,14 @@ SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_ROOT}map ${GLEST_LIB_INCLUDE_ROOT}sound ${GLEST_LIB_INCLUDE_ROOT}xml + ${GLEST_LIB_INCLUDE_ROOT}streflop + ${GLEST_MAIN_INCLUDE_ROOT}facilities + ${GLEST_MAIN_INCLUDE_ROOT}game + ${GLEST_MAIN_INCLUDE_ROOT}global ) INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} ) -SET(MG_SOURCE_FILES "") +SET(MG_SOURCE_FILES "../glest_game/global/config.cpp") FOREACH(DIR IN LISTS DIRS_WITH_SRC) INCLUDE_DIRECTORIES( ${DIR} ) @@ -107,10 +112,25 @@ SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1) ADD_EXECUTABLE(${TARGET_NAME} ${MG_SOURCE_FILES} ${MG_INCLUDE_FILES}) TARGET_LINK_LIBRARIES(${TARGET_NAME} streflop) IF(WIN32) -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ELSE() -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ENDIF() TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS}) +# Requires an install prefix for the items below to work +IF(NOT CMAKE_INSTALL_PREFIX STREQUAL "") + # Installation of the program + INSTALL(TARGETS + ${TARGET_NAME} + DESTINATION ${MEGAGLEST_BIN_INSTALL_PATH}) + + # Installation of the program config and image files + INSTALL(FILES + "${PROJECT_SOURCE_DIR}/mk/linux/glest.ini" + "${PROJECT_SOURCE_DIR}/mk/linux/glestkeys.ini" + "${PROJECT_SOURCE_DIR}/mk/linux/configuration.xml" + "${PROJECT_SOURCE_DIR}/mk/linux/glest.ico" + DESTINATION ${MEGAGLEST_DATA_INSTALL_PATH}) +ENDIF() diff --git a/source/configurator/configuration.cpp b/source/configurator/configuration.cpp index 97c89023..4ffe9f37 100644 --- a/source/configurator/configuration.cpp +++ b/source/configurator/configuration.cpp @@ -61,7 +61,7 @@ void Configuration::loadStructure(const string &path){ //icon XmlNode *iconNode= configurationNode->getChild("icon"); icon= iconNode->getAttribute("value")->getBoolValue(); - if(icon){ + if(icon) { iconPath= iconNode->getAttribute("path")->getValue(); Properties::applyTagsToValue(iconPath); } diff --git a/source/configurator/main.cpp b/source/configurator/main.cpp index 74226d2e..7a780915 100644 --- a/source/configurator/main.cpp +++ b/source/configurator/main.cpp @@ -7,16 +7,39 @@ #include <wx/image.h> #include <wx/bitmap.h> #include <wx/icon.h> +#include "platform_common.h" +#include "config.h" +#include "game_constants.h" +#include "util.h" +#include <wx/stdpaths.h> using namespace std; +using namespace Shared::PlatformCommon; +using namespace Glest::Game; +using namespace Shared::Util; -namespace Configurator{ +namespace Glest { namespace Game { +string getGameReadWritePath(string lookupKey) { + string path = ""; + if(path == "" && getenv("GLESTHOME") != NULL) { + path = getenv("GLESTHOME"); + if(path != "" && EndsWith(path, "/") == false && EndsWith(path, "\\") == false) { + path += "/"; + } + + //SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] path to be used for read/write files [%s]\n",__FILE__,__FUNCTION__,__LINE__,path.c_str()); + } + + return path; +} +}} + +namespace Configurator { // =============================================== // class MainWindow // =============================================== - const int MainWindow::margin= 10; const int MainWindow::panelMargin= 20; const int MainWindow::gridMarginHorizontal= 30; @@ -24,26 +47,30 @@ const int MainWindow::gridMarginHorizontal= 30; const string MainWindow::versionString= "v1.3.5"; const string MainWindow::winHeader= "Mega-Glest config " + versionString + " - Built: " + __DATE__; -MainWindow::MainWindow() : +MainWindow::MainWindow(string appPath) : wxFrame( NULL, -1, Configuration::ToUnicode(winHeader), wxDefaultPosition, wxSize(800, 600)){ SetExtraStyle(wxFRAME_EX_CONTEXTHELP); - configuration.load("configuration.xml"); + this->appPath = appPath; + Properties::setApplicationPath(executable_path(appPath)); + Config &config = Config::getInstance(); + string iniFilePath = extractDirectoryPathFromFile(config.getFileName(false)); + configuration.load(iniFilePath + "configuration.xml"); //Create(NULL, -1, "", wxDefaultPosition, wxDefaultSize, wxCAPTION | wxSYSTEM_MENU); SetTitle(Configuration::ToUnicode(("Configurator - " + configuration.getTitle() + " - Editing " + configuration.getFileName()).c_str())); - if(configuration.getIcon()){ - - printf("In [%s::%s] icon = [%s]\n",__FILE__,__FUNCTION__,configuration.getIconPath().c_str()); + if(configuration.getIcon()) { + string iconPath = configuration.getIconPath(); + printf("In [%s::%s] icon = [%s]\n",__FILE__,__FUNCTION__,iconPath.c_str()); wxInitAllImageHandlers(); wxIcon icon; - icon.LoadFile(Configuration::ToUnicode(configuration.getIconPath().c_str()), wxBITMAP_TYPE_ICO); + icon.LoadFile(Configuration::ToUnicode(iconPath.c_str()), wxBITMAP_TYPE_ICO); SetIcon(icon); } @@ -180,8 +207,19 @@ END_EVENT_TABLE() // =============================================== bool App::OnInit(){ - try{ - mainWindow= new MainWindow(); + try { + SystemFlags::VERBOSE_MODE_ENABLED = true; + string appPath = ""; + wxString exe_path = wxStandardPaths::Get().GetExecutablePath(); + + #if defined(__MINGW32__) + const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(wxFNCONV(exe_path)); + appPath = tmp_buf; + #else + appPath = wxFNCONV(exe_path); + #endif + + mainWindow= new MainWindow(appPath); mainWindow->Show(); } catch(const exception &e){ diff --git a/source/configurator/main.h b/source/configurator/main.h index 1568263c..a84f899d 100644 --- a/source/configurator/main.h +++ b/source/configurator/main.h @@ -49,8 +49,10 @@ private: wxNotebook *notebook; wxTextCtrl *infoText; + string appPath; + public: - MainWindow(); + MainWindow(string appPath); void init(); static const string versionString; static const string winHeader; diff --git a/source/g3d_viewer/CMakeLists.txt b/source/g3d_viewer/CMakeLists.txt index dca2a548..b68bcb05 100644 --- a/source/g3d_viewer/CMakeLists.txt +++ b/source/g3d_viewer/CMakeLists.txt @@ -114,9 +114,23 @@ SET_SOURCE_FILES_PROPERTIES(${MG_INCLUDE_FILES} PROPERTIES HEADER_FILE_ONLY 1) ADD_EXECUTABLE(${TARGET_NAME} ${MG_SOURCE_FILES} ${MG_INCLUDE_FILES}) TARGET_LINK_LIBRARIES(${TARGET_NAME} streflop) IF(WIN32) -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ELSE() -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ENDIF() TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS}) +# Requires an install prefix for the items below to work +IF(NOT CMAKE_INSTALL_PREFIX STREQUAL "") + # Installation of the program + INSTALL(TARGETS + ${TARGET_NAME} + DESTINATION ${MEGAGLEST_BIN_INSTALL_PATH}) + + # Installation of the program config and image files + INSTALL(FILES + "${PROJECT_SOURCE_DIR}/mk/linux/glest.ini" + "${PROJECT_SOURCE_DIR}/mk/linux/glestkeys.ini" + "${PROJECT_SOURCE_DIR}/data/glest_game/g3dviewer.ico" + DESTINATION ${MEGAGLEST_DATA_INSTALL_PATH}) +ENDIF() diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index 463ec8fe..2c4a54dd 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -218,6 +218,7 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad, Properties::setApplicationPath(executable_path(appPath)); Config &config = Config::getInstance(); + string iniFilePath = extractDirectoryPathFromFile(config.getFileName(false)); //getGlPlatformExtensions(); int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker @@ -330,10 +331,11 @@ MainWindow::MainWindow( std::pair<string,vector<string> > unitToLoad, #else wxIcon icon; - std::ifstream testFile("g3dviewer.ico"); + string icon_file = iniFilePath + "g3dviewer.ico"; + std::ifstream testFile(icon_file.c_str()); if(testFile.good()) { testFile.close(); - icon.LoadFile(wxT("g3dviewer.ico"),wxBITMAP_TYPE_ICO); + icon.LoadFile(ToUnicode(icon_file.c_str()),wxBITMAP_TYPE_ICO); } #endif SetIcon(icon); @@ -1797,7 +1799,9 @@ END_EVENT_TABLE() // class App // =============================================== -bool App::OnInit(){ +bool App::OnInit() { + SystemFlags::VERBOSE_MODE_ENABLED = true; + string modelPath=""; string particlePath=""; string projectileParticlePath=""; diff --git a/source/glest_game/CMakeLists.txt b/source/glest_game/CMakeLists.txt index d87a4f62..693d6a79 100644 --- a/source/glest_game/CMakeLists.txt +++ b/source/glest_game/CMakeLists.txt @@ -185,52 +185,39 @@ IF(WIN32) TARGET_LINK_LIBRARIES(${TARGET_NAME} stdc++ gcc odbc32 wsock32 winspool winmm shell32 comctl32 ctl3d32 advapi32 wsock32 opengl32 glu32 ole32 oleaut32 uuid mingw32 ddraw dsound dxguid ws2_32 iphlpapi wsock32 libogg libvorbis libvorbisfile zlib jpeg libpng xerces-c2_8_0 OpenAL32 libcurl winmm gdi32 opengl32 glu32 SDL SDLmain lua5.1 streflop libmegaglest stdc++ moldname mingwex msvcrt user32 kernel32) ENDIF() IF(NOT WIN32) -TARGET_LINK_LIBRARIES(${TARGET_NAME} streflop) -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} streflop) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ENDIF() TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS}) -# Installation of the program -INSTALL(TARGETS - ${TARGET_NAME} - DESTINATION bin/megaglest) +# Requires an install prefix for the items below to work +IF(NOT CMAKE_INSTALL_PREFIX STREQUAL "") + # Installation of the program + INSTALL(TARGETS + ${TARGET_NAME} + DESTINATION ${MEGAGLEST_BIN_INSTALL_PATH}) -# Installation of the program config and image files -INSTALL(FILES - "${PROJECT_SOURCE_DIR}/mk/linux/glest.ini" - "${PROJECT_SOURCE_DIR}/mk/linux/glestkeys.ini" - "${PROJECT_SOURCE_DIR}/mk/linux/megaglest.bmp" - "${PROJECT_SOURCE_DIR}/data/glest_game/megaglest.ico" - DESTINATION bin/megaglest) + # Installation of the program config and image files + INSTALL(FILES + "${PROJECT_SOURCE_DIR}/mk/linux/glest.ini" + "${PROJECT_SOURCE_DIR}/mk/linux/glestkeys.ini" + "${PROJECT_SOURCE_DIR}/mk/linux/megaglest.bmp" + DESTINATION ${MEGAGLEST_DATA_INSTALL_PATH}) -# Installation of the tools -#INSTALL(TARGETS -# "${PROJECT_SOURCE_DIR}/mk/linux/megaglest_configurator" -# "${PROJECT_SOURCE_DIR}/mk/linux/megaglest_editor" -# "${PROJECT_SOURCE_DIR}/mk/linux/megaglest_g3dviewer" -# DESTINATION bin/megaglest) - -# Installation of the program config and image files -#INSTALL(FILES -# "${PROJECT_SOURCE_DIR}/mk/linux/g3dviewer.ico" -# "${PROJECT_SOURCE_DIR}/mk/linux/editor.ico" -# "${PROJECT_SOURCE_DIR}/mk/linux/configuration.xml" -# DESTINATION bin/megaglest) - -# Installation of data files from outside normal data folder -INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/source/masterserver/flags" - DESTINATION share/megaglest/data/core/misc_textures - OPTIONAL REGEX "/.svn" EXCLUDE) - -# Installation of the data -install( - DIRECTORY "${PROJECT_SOURCE_DIR}/data/glest_game/data" - "${PROJECT_SOURCE_DIR}/data/glest_game/docs" - "${PROJECT_SOURCE_DIR}/data/glest_game/maps" - "${PROJECT_SOURCE_DIR}/data/glest_game/scenarios" - "${PROJECT_SOURCE_DIR}/data/glest_game/techs" - "${PROJECT_SOURCE_DIR}/data/glest_game/tilesets" - "${PROJECT_SOURCE_DIR}/data/glest_game/tutorials" - DESTINATION share/megaglest - OPTIONAL REGEX "/.svn" EXCLUDE) + # Installation of data files from outside normal data folder + INSTALL(DIRECTORY "${PROJECT_SOURCE_DIR}/source/masterserver/flags" + DESTINATION ${MEGAGLEST_DATA_INSTALL_PATH}data/core/misc_textures + OPTIONAL REGEX "/.svn" EXCLUDE) + # Installation of the data + install( + DIRECTORY "${PROJECT_SOURCE_DIR}/data/glest_game/data" + "${PROJECT_SOURCE_DIR}/data/glest_game/docs" + "${PROJECT_SOURCE_DIR}/data/glest_game/maps" + "${PROJECT_SOURCE_DIR}/data/glest_game/scenarios" + "${PROJECT_SOURCE_DIR}/data/glest_game/techs" + "${PROJECT_SOURCE_DIR}/data/glest_game/tilesets" + "${PROJECT_SOURCE_DIR}/data/glest_game/tutorials" + DESTINATION ${MEGAGLEST_DATA_INSTALL_PATH} + OPTIONAL REGEX "/.svn" EXCLUDE) +ENDIF() diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 342760e0..8aa0f073 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -86,6 +86,24 @@ Config::Config() { fileLoaded.second = false; } +bool Config::tryCustomPath(std::pair<ConfigType,ConfigType> &type, std::pair<string,string> &file, string custom_path) { + bool wasFound = false; + if((type.first == cfgMainGame && type.second == cfgUserGame && + file.first == glest_ini_filename && file.second == glestuser_ini_filename) || + (type.first == cfgMainKeys && type.second == cfgUserKeys && + file.first == glestkeys_ini_filename && file.second == glestuserkeys_ini_filename)) { + + string linuxPath = custom_path; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("-=-=-=-=-=-=-= looking for file in possible location [%s]\n",linuxPath.c_str()); + if(fileExists(linuxPath + file.first) == true) { + file.first = linuxPath + file.first; + file.second = linuxPath + file.second; + wasFound = true; + } + } + return wasFound; +} + Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist) { fileLoaded.first = false; fileLoaded.second = false; @@ -97,39 +115,21 @@ Config::Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> f fileName.first = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.first; fileName.second = getGameReadWritePath(GameConstants::path_ini_CacheLookupKey) + fileName.second; } -// Look in standard linux shared paths for ini files + + bool foundPath = false; +#if defined(CUSTOM_DATA_INSTALL_PATH) + foundPath = tryCustomPath(cfgType, fileName, CUSTOM_DATA_INSTALL_PATH); +#endif + // Look in standard linux shared paths for ini files #if defined(__linux__) - else if(cfgType.first == cfgMainGame && cfgType.second == cfgUserGame && - fileName.first == glest_ini_filename && fileName.second == glestuser_ini_filename) { - string linuxPath = "/usr/share/megaglest/"; - if(fileExists(linuxPath + fileName.first) == true) { - fileName.first = linuxPath + fileName.first; - fileName.second = linuxPath + fileName.second; - } - else { - linuxPath = "/usr/local/share/megaglest/"; - if(fileExists(linuxPath + fileName.first) == true) { - fileName.first = linuxPath + fileName.first; - fileName.second = linuxPath + fileName.second; - } - } + if(foundPath == false) { + foundPath = tryCustomPath(cfgType, fileName, "/usr/share/megaglest/"); } - else if(cfgType.first == cfgMainKeys && cfgType.second == cfgUserKeys && - fileName.first == glestkeys_ini_filename && fileName.second == glestuserkeys_ini_filename) { - string linuxPath = "/usr/share/megaglest/"; - if(fileExists(linuxPath + fileName.first) == true) { - fileName.first = linuxPath + fileName.first; - fileName.second = linuxPath + fileName.second; - } - else { - linuxPath = "/usr/local/share/megaglest/"; - if(fileExists(linuxPath + fileName.first) == true) { - fileName.first = linuxPath + fileName.first; - fileName.second = linuxPath + fileName.second; - } - } + if(foundPath == false) { + foundPath = tryCustomPath(cfgType, fileName, "/usr/local/share/megaglest/"); } #endif + if(fileMustExist.first == true && fileExists(fileName.first) == false) { string currentpath = extractDirectoryPathFromFile(Properties::getApplicationPath()); fileName.first = currentpath + fileName.first; diff --git a/source/glest_game/global/config.h b/source/glest_game/global/config.h index b2d7f539..e898d11d 100644 --- a/source/glest_game/global/config.h +++ b/source/glest_game/global/config.h @@ -55,7 +55,7 @@ public: protected: Config(); Config(std::pair<ConfigType,ConfigType> type, std::pair<string,string> file, std::pair<bool,bool> fileMustExist); - + bool tryCustomPath(std::pair<ConfigType,ConfigType> &type, std::pair<string,string> &file, string custom_path); static void CopyAll(Config *src,Config *dest); vector<pair<string,string> > getPropertiesFromContainer(const Properties &propertiesObj) const; diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 72d1ce43..4d3f198e 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -2721,10 +2721,11 @@ int glestMainWrapper(int argc, char** argv) { //#endif #endif + application_binary= executable_path(argv[0],true); #ifdef WIN32_STACK_TRACE __try { #endif - application_binary= executable_path(argv[0],true); + //application_binary= executable_path(argv[0],true); //printf("\n\nargv0 [%s] application_binary [%s]\n\n",argv[0],application_binary.c_str()); #if defined(__GNUC__) && !defined(__MINGW32__) && !defined(__FreeBSD__) && !defined(BSD) diff --git a/source/glest_map_editor/CMakeLists.txt b/source/glest_map_editor/CMakeLists.txt index 0aa4a387..37165393 100644 --- a/source/glest_map_editor/CMakeLists.txt +++ b/source/glest_map_editor/CMakeLists.txt @@ -115,9 +115,23 @@ ENDIF() TARGET_LINK_LIBRARIES(${TARGET_NAME} streflop) IF(WIN32) -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ELSE() -TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) + TARGET_LINK_LIBRARIES(${TARGET_NAME} libmegaglest) ENDIF() TARGET_LINK_LIBRARIES(${TARGET_NAME} ${EXTERNAL_LIBS}) +# Requires an install prefix for the items below to work +IF(NOT CMAKE_INSTALL_PREFIX STREQUAL "") + # Installation of the program + INSTALL(TARGETS + ${TARGET_NAME} + DESTINATION ${MEGAGLEST_BIN_INSTALL_PATH}) + + # Installation of the program config and image files + INSTALL(FILES + "${PROJECT_SOURCE_DIR}/mk/linux/glest.ini" + "${PROJECT_SOURCE_DIR}/mk/linux/glestkeys.ini" + "${PROJECT_SOURCE_DIR}/data/glest_game/editor.ico" + DESTINATION ${MEGAGLEST_DATA_INSTALL_PATH}) +ENDIF() diff --git a/source/glest_map_editor/main.cpp b/source/glest_map_editor/main.cpp index a087284e..73e941e3 100644 --- a/source/glest_map_editor/main.cpp +++ b/source/glest_map_editor/main.cpp @@ -338,33 +338,36 @@ void MainWindow::init(string fname) { toolbar2->AddTool(miRadius + 9, _("radius9"), wxBitmap(radius_9), _("9 (17x17)")); toolbar2->Realize(); + Config &config = Config::getInstance(); + string iniFilePath = extractDirectoryPathFromFile(config.getFileName(false)); + string userData = config.getString("UserData_Root",""); + if(userData != "") { + endPathWithSlash(userData); + } + //std::cout << "A" << std::endl; wxInitAllImageHandlers(); #ifdef WIN32 //std::cout << "B" << std::endl; -#if defined(__MINGW32__) - wxIcon icon(ToUnicode("IDI_ICON1")); -#else - wxIcon icon("IDI_ICON1"); -#endif + #if defined(__MINGW32__) + wxIcon icon(ToUnicode("IDI_ICON1")); + #else + wxIcon icon("IDI_ICON1"); + #endif #else //std::cout << "B" << std::endl; wxIcon icon; - std::ifstream testFile("editor.ico"); + string icon_file = iniFilePath + "editor.ico"; + std::ifstream testFile(icon_file.c_str()); if(testFile.good()) { testFile.close(); - icon.LoadFile(wxT("editor.ico"),wxBITMAP_TYPE_ICO); + icon.LoadFile(ToUnicode(icon_file.c_str()),wxBITMAP_TYPE_ICO); } #endif //std::cout << "C" << std::endl; SetIcon(icon); fileDialog = new wxFileDialog(this); - Config &config = Config::getInstance(); - string userData = config.getString("UserData_Root",""); - if(userData != "") { - endPathWithSlash(userData); - } string defaultPath = userData + "maps/"; fileDialog->SetDirectory(ToUnicode(defaultPath)); @@ -1387,6 +1390,8 @@ bool SimpleDialog::show(const string &title, bool wide) { // =============================================== bool App::OnInit() { + SystemFlags::VERBOSE_MODE_ENABLED = true; + string fileparam; if(argc==2){ if(argv[1][0]=='-') { // any flag gives help and exits program. diff --git a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp index ea532f0b..8a113fd9 100644 --- a/source/shared_lib/sources/platform/sdl/gl_wrap.cpp +++ b/source/shared_lib/sources/platform/sdl/gl_wrap.cpp @@ -66,14 +66,24 @@ void PlatformContextGl::init(int colorBits, int depthBits, int stencilBits,bool int resH = PlatformCommon::Private::ScreenHeight; #ifndef WIN32 - if(fileExists("megaglest.bmp")) { + string mg_icon_file = ""; +#if defined(CUSTOM_DATA_INSTALL_PATH_VALUE) + if(fileExists(CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp")) { + mg_icon_file = CUSTOM_DATA_INSTALL_PATH_VALUE + "megaglest.bmp"; + } +#endif + + if(mg_icon_file == "" && fileExists("megaglest.bmp")) { + mg_icon_file = "megaglest.bmp"; + } + if(mg_icon_file != "") { if(icon != NULL) { SDL_FreeSurface(icon); icon = NULL; } - icon = SDL_LoadBMP("megaglest.bmp"); + icon = SDL_LoadBMP(mg_icon_file.c_str()); //SDL_Surface *icon = IMG_Load("megaglest.ico"); diff --git a/source/shared_lib/sources/util/properties.cpp b/source/shared_lib/sources/util/properties.cpp index c30106df..069be916 100644 --- a/source/shared_lib/sources/util/properties.cpp +++ b/source/shared_lib/sources/util/properties.cpp @@ -141,6 +141,14 @@ bool Properties::applyTagsToValue(string &value) { 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); +#else + replaceAll(value, "$APPLICATIONDATAPATH", Properties::applicationPath); + replaceAll(value, "%%APPLICATIONDATAPATH%%", Properties::applicationPath); +#endif + return (originalValue != value); }