From 9636d5db06517252c66aba8b9b0f3bd5351669eb Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 10 Mar 2011 17:59:40 +0000 Subject: [PATCH] - g3d viewer now respects userdata path for screenshots --- source/g3d_viewer/CMakeLists.txt | 3 ++- source/g3d_viewer/main.cpp | 33 ++++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/source/g3d_viewer/CMakeLists.txt b/source/g3d_viewer/CMakeLists.txt index e68802772..45868d9af 100644 --- a/source/g3d_viewer/CMakeLists.txt +++ b/source/g3d_viewer/CMakeLists.txt @@ -73,6 +73,7 @@ SET(GLEST_LIB_INCLUDE_DIRS ${GLEST_LIB_INCLUDE_ROOT}sound ${GLEST_LIB_INCLUDE_ROOT}streflop ${GLEST_LIB_INCLUDE_ROOT}xml + ${GLEST_MAIN_INCLUDE_ROOT}facilities ${GLEST_MAIN_INCLUDE_ROOT}graphics ${GLEST_MAIN_INCLUDE_ROOT}game ${GLEST_MAIN_INCLUDE_ROOT}global @@ -80,7 +81,7 @@ SET(GLEST_LIB_INCLUDE_DIRS ) INCLUDE_DIRECTORIES( ${GLEST_LIB_INCLUDE_DIRS} ) -SET(MG_SOURCE_FILES "../glest_game/graphics/particle_type.cpp" "../glest_game/graphics/unit_particle_type.cpp") +SET(MG_SOURCE_FILES "../glest_game/graphics/particle_type.cpp" "../glest_game/graphics/unit_particle_type.cpp" "../glest_game/global/config.cpp") FOREACH(DIR IN LISTS DIRS_WITH_SRC) INCLUDE_DIRECTORIES( ${DIR} ) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index dd49d04ca..ec3bc31dd 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -10,6 +10,7 @@ #include "xml_parser.h" #include #include +#include "config.h" #include "game_constants.h" #ifndef WIN32 @@ -34,11 +35,27 @@ const char *folderDelimiter = "\\"; const char *folderDelimiter = "/"; #endif -int GameConstants::updateFps= 40; -int GameConstants::cameraFps= 100; +//int GameConstants::updateFps= 40; +//int GameConstants::cameraFps= 100; const string g3dviewerVersionString= "v1.3.6"; +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 Shared{ namespace G3dViewer{ // =============================================== @@ -193,6 +210,8 @@ MainWindow::MainWindow( std::pair > unitToLoad, wxSize(Renderer::windowW, Renderer::windowH)), model(NULL), glCanvas(NULL), renderer(NULL), initTextureManager(true), timer(NULL) { this->appPath = appPath; + + Config &config = Config::getInstance(); //getGlPlatformExtensions(); int args[] = { WX_GL_RGBA, WX_GL_DOUBLEBUFFER, WX_GL_MIN_ALPHA, 8 }; // to prevent flicker glCanvas = new GlCanvas(this, args); @@ -716,8 +735,14 @@ void MainWindow::saveScreenshot() { } } else { - string screenShotsPath = extractDirectoryPathFromFile(appPath) + string("screens/"); - + //string screenShotsPath = extractDirectoryPathFromFile(appPath) + string("screens/"); + string userData = Config::getInstance().getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + string screenShotsPath = userData + string("screens/"); printf("screenShotsPath [%s]\n",screenShotsPath.c_str()); if(isdir(screenShotsPath.c_str()) == false) {