From c3ff9973d954c4430f47807758ae54076f53fed4 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Tue, 20 Nov 2012 01:12:07 +0000 Subject: [PATCH] - fixed screenshots so holding shift ignores the screenshot key --- source/glest_game/main/main.cpp | 22 ++++++++++++++++--- source/glest_game/menu/main_menu.cpp | 7 ++++++ .../sources/platform/sdl/window.cpp | 3 ++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 89e629556..9ba9d81ee 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -924,19 +924,29 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) { } } //else if(key == configKeys.getCharKey("ReloadINI")) { - else if(isKeyPressed(configKeys.getSDLKey("ReloadINI"),key) == true) { + else if(isKeyPressed(configKeys.getSDLKey("ReloadINI"),key,false) == true) { Config &config = Config::getInstance(); config.reload(); } //else if(key == configKeys.getCharKey("Screenshot")) { - else if(isKeyPressed(configKeys.getSDLKey("Screenshot"),key) == true) { + else if(isKeyPressed(configKeys.getSDLKey("Screenshot"),key,false) == true) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot key pressed\n"); + string userData = Config::getInstance().getString("UserData_Root",""); if(userData != "") { endPathWithSlash(userData); } string path = userData + GameConstants::folder_path_screenshots; + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot checking path [%s]\n",path.c_str()); + + if(isdir(path.c_str()) == false) { + createDirectoryPaths(path); + } + if(isdir(path.c_str()) == true) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot path [%s]\n",path.c_str()); + Config &config= Config::getInstance(); string fileFormat = config.getString("ScreenShotFileType","jpg"); @@ -962,14 +972,20 @@ void MainWindow::eventKeyDown(SDL_KeyboardEvent key) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf("In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf); - if(Config::getInstance().getBool("DisableScreenshotConsoleText","false") == false) { + bool showScreenshotSavedMsg = Config::getInstance().getBool("DisableScreenshotConsoleText","false"); + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot console showScreenshotSavedMsg = %d\n",showScreenshotSavedMsg); + + if(showScreenshotSavedMsg == false) { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot console [%s]\n",szBuf); program->consoleAddLine(szBuf); } + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("Screenshot save to [%s]\n",path.c_str()); Renderer::getInstance().saveScreen(path); break; } else { + if(SystemFlags::VERBOSE_MODE_ENABLED) printf("CANNOT save Screenshot [%s]\n",path.c_str()); fclose(f); } } diff --git a/source/glest_game/menu/main_menu.cpp b/source/glest_game/menu/main_menu.cpp index ce11f8f2d..32142abea 100644 --- a/source/glest_game/menu/main_menu.cpp +++ b/source/glest_game/menu/main_menu.cpp @@ -337,7 +337,14 @@ MenuState::~MenuState() { } void MenuState::consoleAddLine(string line) { + bool onlyWantChatMsgs = console.getOnlyChatMessagesInStoredLines(); + if(onlyWantChatMsgs == true) { + console.setOnlyChatMessagesInStoredLines(false); + } console.addLine(line); + if(onlyWantChatMsgs == true) { + console.setOnlyChatMessagesInStoredLines(true); + } } void MenuState::reloadUI() { diff --git a/source/shared_lib/sources/platform/sdl/window.cpp b/source/shared_lib/sources/platform/sdl/window.cpp index 5376fb152..a2c1e4d41 100644 --- a/source/shared_lib/sources/platform/sdl/window.cpp +++ b/source/shared_lib/sources/platform/sdl/window.cpp @@ -880,7 +880,8 @@ bool isKeyPressed(SDLKey compareKey, SDL_KeyboardEvent input,bool modifiersAllow //printf("input.keysym.mod = %d\n",input.keysym.mod); if( (input.keysym.mod & (KMOD_LCTRL | KMOD_RCTRL)) || - (input.keysym.mod & (KMOD_LALT | KMOD_RALT))) { + (input.keysym.mod & (KMOD_LALT | KMOD_RALT)) || + (input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))) { //input.keysym.mod & (KMOD_LSHIFT | KMOD_RSHIFT)) { if(SystemFlags::VERBOSE_MODE_ENABLED) printf ("In [%s::%s Line: %d] result *WOULD HAVE BEEN TRUE* but is false due to: modifiersAllowed = %d input.keysym.mod = %d\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__,modifiersAllowed,input.keysym.mod); result = false;