From 819831a2874b5e82a86dbdb15e5e47acc302647d Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Thu, 10 Mar 2011 17:31:55 +0000 Subject: [PATCH] - misc logs and screenshots now also go in userdata folder --- source/g3d_viewer/main.cpp | 2 +- source/glest_game/facilities/logger.cpp | 14 +++++++++++-- source/glest_game/main/main.cpp | 22 +++++++++++++++++---- source/glest_game/main/program.cpp | 10 ++++++++++ source/glest_game/world/world.cpp | 9 +++++++++ source/shared_lib/sources/util/profiler.cpp | 11 ++++++++++- 6 files changed, 60 insertions(+), 8 deletions(-) diff --git a/source/g3d_viewer/main.cpp b/source/g3d_viewer/main.cpp index d2d497a9..dd49d04c 100644 --- a/source/g3d_viewer/main.cpp +++ b/source/g3d_viewer/main.cpp @@ -730,7 +730,7 @@ void MainWindow::saveScreenshot() { //string fileFormat = config.getString("ScreenShotFileType","png"); string fileFormat = "png"; - for(int i=0; i < 1000; ++i) { + for(int i=0; i < 5000; ++i) { path = screenShotsPath; path += string("screen") + intToStr(i) + string(".") + fileFormat; FILE *f= fopen(path.c_str(), "rb"); diff --git a/source/glest_game/facilities/logger.cpp b/source/glest_game/facilities/logger.cpp index e7f64916..6c434609 100644 --- a/source/glest_game/facilities/logger.cpp +++ b/source/glest_game/facilities/logger.cpp @@ -37,8 +37,18 @@ const int Logger::logLineCount= 15; Logger::Logger() { string logs_path = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey); - - fileName= logs_path + "log.txt"; + if(logs_path != "") { + fileName= logs_path + "log.txt"; + } + else { + string userData = Config::getInstance().getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + fileName= userData + "log.txt"; + } loadingTexture=NULL; showProgressBar = false; } diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 57edb1d5..6bdbde19 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -688,15 +688,22 @@ void MainWindow::eventKeyDown(char key){ config.reload(); } else if(key == configKeys.getCharKey("Screenshot")) { - string path = GameConstants::folder_path_screenshots; + string userData = Config::getInstance().getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + + string path = userData + GameConstants::folder_path_screenshots; if(isdir(path.c_str()) == true) { Config &config= Config::getInstance(); string fileFormat = config.getString("ScreenShotFileType","png"); unsigned int queueSize = Renderer::getInstance().getSaveScreenQueueSize(); - for(int i=0; i < 250; ++i) { - path = GameConstants::folder_path_screenshots; + for(int i=0; i < 5000; ++i) { + path = userData + GameConstants::folder_path_screenshots; path += string("screen") + intToStr(i + queueSize) + string(".") + fileFormat; FILE *f= fopen(path.c_str(), "rb"); if(f == NULL) { @@ -1760,7 +1767,14 @@ int glestMain(int argc, char** argv) { gameInitialized = true; // Setup the screenshots folder - string screenShotsPath = GameConstants::folder_path_screenshots; + string userData = config.getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + + string screenShotsPath = userData + GameConstants::folder_path_screenshots; if(isdir(screenShotsPath.c_str()) == false) { createDirectoryPaths(screenShotsPath); } diff --git a/source/glest_game/main/program.cpp b/source/glest_game/main/program.cpp index 21dcf1be..deacbeff 100644 --- a/source/glest_game/main/program.cpp +++ b/source/glest_game/main/program.cpp @@ -491,6 +491,16 @@ void Program::init(WindowGl *window, bool initSound, bool toggleFullScreen){ string logFile = "glest.log"; if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") { logFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + logFile; + } + else { + string userData = config.getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + + logFile = userData + logFile; } logger.setFile(logFile); logger.clear(); diff --git a/source/glest_game/world/world.cpp b/source/glest_game/world/world.cpp index 6202d87f..9e4ca1d1 100644 --- a/source/glest_game/world/world.cpp +++ b/source/glest_game/world/world.cpp @@ -1594,6 +1594,15 @@ std::string World::DumpWorldToLog(bool consoleBasicInfoOnly) const { if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") { debugWorldLogFile = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + debugWorldLogFile; } + else { + string userData = Config::getInstance().getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + debugWorldLogFile = userData + debugWorldLogFile; + } if(consoleBasicInfoOnly == true) { std::cout << "World debug information:" << std::endl; diff --git a/source/shared_lib/sources/util/profiler.cpp b/source/shared_lib/sources/util/profiler.cpp index d2d7c561..b1d93bee 100644 --- a/source/shared_lib/sources/util/profiler.cpp +++ b/source/shared_lib/sources/util/profiler.cpp @@ -1,7 +1,7 @@ // ============================================================== // This file is part of Glest Shared Library (www.glest.org) // -// Copyright (C) 2001-2008 Martiño Figueroa +// Copyright (C) 2001-2008 Marti�o Figueroa // // You can redistribute this code and/or modify it under // the terms of the GNU General Public License as published @@ -75,6 +75,15 @@ Profiler::~Profiler(){ string profileLog = "profiler.log"; if(getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) != "") { profileLog = getGameReadWritePath(GameConstants::path_logs_CacheLookupKey) + profileLog; + } + else { + string userData = config.getString("UserData_Root",""); + if(userData != "") { + if(userData != "" && EndsWith(userData, "/") == false && EndsWith(userData, "\\") == false) { + userData += "/"; + } + } + profileLog = userData + profileLog; } FILE *f= fopen(profileLog.c_str(), "w"); if(f==NULL)