From c8a6404ecfb99249a1eccb10b7810e561eb5fc88 Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Mon, 18 Apr 2011 23:31:33 +0000 Subject: [PATCH] - screen resolutions sorted now in options menu --- source/glest_game/menu/menu_state_options.cpp | 4 ++-- source/glest_game/menu/menu_state_options.h | 2 +- .../include/platform/common/platform_common.h | 17 ++++++++++++++++- .../sources/platform/common/platform_common.cpp | 5 ++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/source/glest_game/menu/menu_state_options.cpp b/source/glest_game/menu/menu_state_options.cpp index 74a77e71..71f3a3a0 100644 --- a/source/glest_game/menu/menu_state_options.cpp +++ b/source/glest_game/menu/menu_state_options.cpp @@ -130,7 +130,7 @@ MenuStateOptions::MenuStateOptions(Program *program, MainMenu *mainMenu): config.getString("ScreenHeight") + "-" + intToStr(config.getInt("ColorBits")); bool currentResolutionFound = false; - for(list::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){ + for(vector::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){ if((*it).getString() == currentResString) { currentResolutionFound = true; } @@ -821,7 +821,7 @@ void MenuStateOptions::saveConfig(){ string currentResolution=config.getString("ScreenWidth")+"x"+config.getString("ScreenHeight"); string selectedResolution=listBoxScreenModes.getSelectedItem(); if(currentResolution!=selectedResolution){ - for(list::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){ + for(vector::const_iterator it= modeInfos.begin(); it!=modeInfos.end(); ++it){ if((*it).getString()==selectedResolution) { config.setInt("ScreenWidth",(*it).width); diff --git a/source/glest_game/menu/menu_state_options.h b/source/glest_game/menu/menu_state_options.h index ae06548d..1e7acb93 100644 --- a/source/glest_game/menu/menu_state_options.h +++ b/source/glest_game/menu/menu_state_options.h @@ -61,7 +61,7 @@ private: GraphicLabel labelScreenModes; GraphicListBox listBoxScreenModes; - list modeInfos; + vector modeInfos; GraphicLabel labelFullscreenWindowed; GraphicCheckBox checkBoxFullscreenWindowed; diff --git a/source/shared_lib/include/platform/common/platform_common.h b/source/shared_lib/include/platform/common/platform_common.h index d2fad151..2ed0917c 100644 --- a/source/shared_lib/include/platform/common/platform_common.h +++ b/source/shared_lib/include/platform/common/platform_common.h @@ -102,6 +102,21 @@ public: ModeInfo(int width, int height, int depth); + bool operator< (const ModeInfo &j) const { + if(this->width < j.width) { + return true; + } + else if(this->width == j.width && this->height < j.height) { + return true; + } + else if(this->width == j.width && + this->height == j.height && + this->depth < j.depth) { + return true; + } + + return false; + } string getString() const; }; @@ -142,7 +157,7 @@ string extractDirectoryPathFromFile(string filename); string extractLastDirectoryFromPath(string Path); string extractExtension(const string& filename); -void getFullscreenVideoModes(list *modeinfos,bool isFullscreen); +void getFullscreenVideoModes(vector *modeinfos,bool isFullscreen); void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bool isFullscreen); bool changeVideoMode(int resH, int resW, int colorBits, int refreshFrequency); void restoreVideoMode(bool exitingApp=false); diff --git a/source/shared_lib/sources/platform/common/platform_common.cpp b/source/shared_lib/sources/platform/common/platform_common.cpp index a3afa813..c9dedd42 100644 --- a/source/shared_lib/sources/platform/common/platform_common.cpp +++ b/source/shared_lib/sources/platform/common/platform_common.cpp @@ -55,6 +55,7 @@ #include #include #include "randomgen.h" +#include #include "leak_dumper.h" using namespace Shared::Platform; @@ -1314,7 +1315,7 @@ void getFullscreenVideoInfo(int &colorBits,int &screenWidth,int &screenHeight,bo } -void getFullscreenVideoModes(list *modeinfos, bool isFullscreen) { +void getFullscreenVideoModes(vector *modeinfos, bool isFullscreen) { // Get the current video hardware information //const SDL_VideoInfo* vidInfo = SDL_GetVideoInfo(); //colorBits = vidInfo->vfmt->BitsPerPixel; @@ -1499,6 +1500,8 @@ void getFullscreenVideoModes(list *modeinfos, bool isFullscreen) { } } } while(++loops != 4); + + std::sort(modeinfos->begin(),modeinfos->end()); }