From c5dd29f4ff59a26e74d8412c4ceccf897404b699 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Sun, 27 Jan 2013 22:10:24 +0000 Subject: [PATCH] new way to define the selectionType. No more use of EnableColorPicking and so on! allowed values are: selectbuf color frustrum Default is selectbuf again as Colorpicking still makes trouble. --- source/glest_game/game/game.cpp | 13 +--------- source/glest_game/global/config.cpp | 5 ++++ source/glest_game/global/config.h | 4 +++ source/glest_game/graphics/renderer.cpp | 8 +++--- source/glest_game/menu/menu_state_options.cpp | 25 +++++++------------ 5 files changed, 22 insertions(+), 33 deletions(-) diff --git a/source/glest_game/game/game.cpp b/source/glest_game/game/game.cpp index 5792531e..515dc918 100644 --- a/source/glest_game/game/game.cpp +++ b/source/glest_game/game/game.cpp @@ -4213,18 +4213,7 @@ string Game::getDebugStats(std::map &factionDebugInfo) { str+= "ExploredCellsLookupItemCache: " + world.getExploredCellsLookupItemCacheStats()+"\n"; str+= "FowAlphaCellsLookupItemCache: " + world.getFowAlphaCellsLookupItemCacheStats()+"\n"; - const bool selectBufPickingSelection = Config::getInstance().getBool("EnableSelectBufPicking","false"); - //const bool colorPickingSelection = Config::getInstance().getBool("EnableColorPicking","true"); - const bool frustumPickingSelection = Config::getInstance().getBool("EnableFrustumPicking","false"); - if(selectBufPickingSelection) { - str += "Unit selection type: selectBuf\n"; - } - else if(frustumPickingSelection) { - str += "Unit selection type: frustrum\n"; - } - else { - str += "Unit selection type: color picking\n"; - } + str += "Selection type: "+toLower(Config::getInstance().getString("SelectionType",Config::selectBufPicking))+"\n"; //str+= "AllFactionsCacheStats: " + world.getAllFactionsCacheStats()+"\n"; //str+= "AttackWarningCount: " + intToStr(world.getUnitUpdater()->getAttackWarningCount()) + "\n"; diff --git a/source/glest_game/global/config.cpp b/source/glest_game/global/config.cpp index 7334d071..0b08855f 100644 --- a/source/glest_game/global/config.cpp +++ b/source/glest_game/global/config.cpp @@ -73,6 +73,11 @@ const char *Config::glestkeys_ini_filename = "glestkeys.ini"; const char *Config::glestuserkeys_ini_filename = "glestuserkeys.ini"; const char *Config::ACTIVE_MOD_PROPERTY_NAME = "current_mod_name"; + + const char *Config::colorPicking = "color"; + const char *Config::selectBufPicking = "frustrum"; + const char *Config::frustrumPicking = "selectbuf"; + map Config::customRuntimeProperties; // ===================================================== diff --git a/source/glest_game/global/config.h b/source/glest_game/global/config.h index 3902d837..c1c5532c 100644 --- a/source/glest_game/global/config.h +++ b/source/glest_game/global/config.h @@ -66,6 +66,10 @@ public: static const char *ACTIVE_MOD_PROPERTY_NAME; + static const char *colorPicking; + static const char *selectBufPicking; + static const char *frustrumPicking; + protected: Config(); diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 86a3edc0..ab73fe5e 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -6691,15 +6691,13 @@ Vec3f Renderer::computeScreenPosition(const Vec3f &worldPos) { void Renderer::computeSelected( Selection::UnitContainer &units, const Object *&obj, const bool withObjectSelection, const Vec2i &posDown, const Vec2i &posUp) { - //const bool selectBufPickingSelection = Config::getInstance().getBool("EnableSelectBufPicking","false"); - const bool colorPickingSelection = Config::getInstance().getBool("EnableColorPicking","true"); - const bool frustumPickingSelection = Config::getInstance().getBool("EnableFrustumPicking","false"); + const string selectionType=toLower(Config::getInstance().getString("SelectionType",Config::selectBufPicking)); - if(colorPickingSelection == true) { + if(selectionType==Config::colorPicking) { selectUsingColorPicking(units,obj, withObjectSelection,posDown, posUp); } /// Frustrum approach --> Currently not accurate enough - else if(frustumPickingSelection == true) { + else if(selectionType==Config::frustrumPicking) { selectUsingFrustumSelection(units,obj, withObjectSelection,posDown, posUp); } else { diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 7ee78a71..e7a4308a 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -201,15 +201,14 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): listBoxSelectionType.pushBackItem("SelectBuffer"); listBoxSelectionType.pushBackItem("ColorPicking"); listBoxSelectionType.pushBackItem("FrustumPicking"); - bool isColorpicking= config.getBool("EnableColorPicking","false"); - bool isFrustumPicking=config.getBool("EnableFrustumPicking","false"); - bool isSelectBuf= config.getBool("EnableSelectBufPicking","true"); - if( isSelectBuf == true && isColorpicking == false && isFrustumPicking == false ) - listBoxSelectionType.setSelectedItemIndex(0); - else if(isColorpicking == false && isFrustumPicking == true) + + const string selectionType=toLower(config.getString("SelectionType",Config::selectBufPicking)); + if( selectionType==Config::colorPicking) + listBoxSelectionType.setSelectedItemIndex(1); + else if ( selectionType==Config::frustrumPicking ) listBoxSelectionType.setSelectedItemIndex(2); else - listBoxSelectionType.setSelectedItemIndex(1); + listBoxSelectionType.setSelectedItemIndex(0); currentLine-=lineOffset; //shadows @@ -1774,19 +1773,13 @@ void MenuStateOptions::saveConfig(){ int selectionTypeindex= listBoxSelectionType.getSelectedItemIndex(); if(selectionTypeindex==0){ - config.setBool("EnableSelectBufPicking", true); - config.setBool("EnableColorPicking", false); - config.setBool("EnableFrustumPicking", false); + config.setString("SelectionType",Config::selectBufPicking); } else if (selectionTypeindex==1){ - config.setBool("EnableSelectBufPicking", false); - config.setBool("EnableColorPicking", true); - config.setBool("EnableFrustumPicking", false); + config.setString("SelectionType",Config::colorPicking); } else if (selectionTypeindex==2){ - config.setBool("EnableSelectBufPicking", false); - config.setBool("EnableColorPicking", false); - config.setBool("EnableFrustumPicking", true); + config.setString("SelectionType",Config::frustrumPicking); } int index= listBoxShadows.getSelectedItemIndex();