Author: nsmoooose Date: 2007-04-29 10:28:48 -0700 (Sun, 29 Apr 2007) New Revision: 2089 Modified: branches/python_bindings_for_ui/csp/cspsim/SConscript branches/python_bindings_for_ui/csp/cspsim/config/Display.cpp branches/python_bindings_for_ui/csp/cspsim/config/Display.h branches/python_bindings_for_ui/csp/cspsim/swig/CSPSim.i branches/python_bindings_for_ui/csp/cspsim/swig/Config.i branches/python_bindings_for_ui/csp/data/ui/options.py branches/python_bindings_for_ui/csp/data/ui/themes/default/options.xml branches/python_bindings_for_ui/csp/data/ui/themes/experimental/options.xml branches/python_bindings_for_ui/csp/data/ui/themes/red/options.xml Log: All display modes is now automatically enumerated in the options window. No resolution below 640x480 is displayed. Removed hard coded resolutions in xml files. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2089 Modified: branches/python_bindings_for_ui/csp/cspsim/SConscript =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/SConscript 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/cspsim/SConscript 2007-04-29 17:28:48 UTC (rev 2089) @@ -471,7 +471,7 @@ '@cspsim/battlefield', '@cspsim/config', ], - deps = ['csplib'], + deps = ['csplib', 'sdl'], aliases = 'all', SHLIBPREFIX = '_') Modified: branches/python_bindings_for_ui/csp/cspsim/config/Display.cpp =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/config/Display.cpp 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/cspsim/config/Display.cpp 2007-04-29 17:28:48 UTC (rev 2089) @@ -22,6 +22,8 @@ * **/ +#include <sstream> +#include <SDL/SDL.h> #include <csp/cspsim/config/Display.h> CSP_NAMESPACE @@ -61,5 +63,32 @@ m_Fullscreen = fullscreen; } +StringVector Display::enumerateDisplayModes() { + StringVector displayModes; + + /* Get available fullscreen/hardware modes */ + Uint32 flags = SDL_OPENGL | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN; + SDL_Rect **modes=SDL_ListModes(NULL, flags); + + /* Check is there are any modes available */ + if(modes == (SDL_Rect **)0){ + return displayModes; + } + + /* Check if or resolution is restricted */ + if(modes != (SDL_Rect **)-1){ + for(int i=0;modes[i];++i) { + // Only display resolutions higher than 640x480 + if(modes[i]->w < 640 || modes[i]->h < 480) { + continue; + } + std::stringstream textStream; + textStream << modes[i]->w << 'x' << modes[i]->h; + displayModes.push_back(textStream.str()); + } + } + return displayModes; } + +} CSP_NAMESPACE_END Modified: branches/python_bindings_for_ui/csp/cspsim/config/Display.h =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/config/Display.h 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/cspsim/config/Display.h 2007-04-29 17:28:48 UTC (rev 2089) @@ -33,6 +33,8 @@ namespace config { +typedef std::vector<std::string> StringVector; + class CSPSIM_EXPORT Display: public Referenced { public: Display(int width, int height, bool fullscreen); @@ -47,6 +49,8 @@ virtual bool getFullscreen(); virtual void setFullscreen(bool fullscreen); + virtual StringVector enumerateDisplayModes(); + virtual Display* clone(); private: int m_Width; Modified: branches/python_bindings_for_ui/csp/cspsim/swig/CSPSim.i =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/swig/CSPSim.i 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/cspsim/swig/CSPSim.i 2007-04-29 17:28:48 UTC (rev 2089) @@ -48,7 +48,7 @@ namespace csp { -%newobject CSPSim::getConfiguration(); +// %newobject CSPSim::getConfiguration(); class CSPSim { public: Modified: branches/python_bindings_for_ui/csp/cspsim/swig/Config.i =================================================================== --- branches/python_bindings_for_ui/csp/cspsim/swig/Config.i 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/cspsim/swig/Config.i 2007-04-29 17:28:48 UTC (rev 2089) @@ -39,6 +39,8 @@ %newobject Display::clone(); +typedef std::vector<std::string> StringVector; + class Display { public: Display(int width, int height, bool fullscreen); @@ -53,11 +55,11 @@ virtual bool getFullscreen(); virtual void setFullscreen(bool fullscreen); + virtual StringVector enumerateDisplayModes(); + virtual Display* clone(); }; -typedef std::vector<std::string> StringVector; - %newobject UserInterface::clone(); class UserInterface { Modified: branches/python_bindings_for_ui/csp/data/ui/options.py =================================================================== --- branches/python_bindings_for_ui/csp/data/ui/options.py 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/data/ui/options.py 2007-04-29 17:28:48 UTC (rev 2089) @@ -50,12 +50,14 @@ cancelButton = self.getById('cancel') if cancelButton != None: self.connectToClickSignal(cancelButton, self.cancel_Click) + + # Class with usefull functions to handle listboxes. + listBoxManager = ListBoxManager() # List all availible themes in the corresponding listbox and select the current one. self.themeListBox = self.getById('theme') if self.themeListBox != None: themes = self.configuration.getUserInterface().enumerateThemes() - listBoxManager = ListBoxManager() listBoxManager.addListToControl(self.themeListBox, themes) self.themeListBox.setSelectedItemByText(self.configuration.getUserInterface().getTheme()) self.connectToSelectedItemChangedSignal(self.themeListBox, self.theme_Changed) @@ -72,6 +74,9 @@ self.resolutionListBox = self.getById('resolution') if self.resolutionListBox != None: currentResolution = str(self.configuration.getDisplay().getWidth()) + 'x' + str(self.configuration.getDisplay().getHeight()) + displayModes = self.configuration.getDisplay().enumerateDisplayModes() + listBoxManager = ListBoxManager() + listBoxManager.addListToControl(self.resolutionListBox, displayModes) self.resolutionListBox.setSelectedItemByText(currentResolution) self.connectToSelectedItemChangedSignal(self.resolutionListBox, self.resolution_Changed) Modified: branches/python_bindings_for_ui/csp/data/ui/themes/default/options.xml =================================================================== --- branches/python_bindings_for_ui/csp/data/ui/themes/default/options.xml 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/data/ui/themes/default/options.xml 2007-04-29 17:28:48 UTC (rev 2089) @@ -12,15 +12,7 @@ <Label CssClass="stripe" LocationX="0" LocationY="30" SizeWidth="438" SizeHeight="10" /> <Label Text="Resolution:" LocationX="25" LocationY="55" SizeHeight="25" /> - <ListBox Id="resolution" LocationX="145" LocationY="55" SizeWidth="250" SizeHeight="140"> - <Items> - <Item Text="640x480" SizeHeight="30" /> - <Item Text="800x600" SizeHeight="30" /> - <Item Text="1024x768" SizeHeight="30" /> - <Item Text="1280x1024" SizeHeight="30" /> - <Item Text="1920x1200" SizeHeight="30" /> - </Items> - </ListBox> + <ListBox Id="resolution" LocationX="145" LocationY="55" SizeWidth="250" SizeHeight="140" /> <CheckBox Id="fullscreen" LocationX="25" LocationY="195" SizeWidth="150" SizeHeight="30" Text="Fullscreen" /> Modified: branches/python_bindings_for_ui/csp/data/ui/themes/experimental/options.xml =================================================================== --- branches/python_bindings_for_ui/csp/data/ui/themes/experimental/options.xml 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/data/ui/themes/experimental/options.xml 2007-04-29 17:28:48 UTC (rev 2089) @@ -12,15 +12,7 @@ <Label CssClass="stripe" LocationX="0" LocationY="30" SizeWidth="569" SizeHeight="10" /> <Label Text="Resolution:" LocationX="10" LocationY="55" SizeHeight="25" /> - <ListBox Id="resolution" LocationX="20" LocationY="83" SizeWidth="145" SizeHeight="230"> - <Items> - <Item Text="640x480" SizeHeight="30" /> - <Item Text="800x600" SizeHeight="30" /> - <Item Text="1024x768" SizeHeight="30" /> - <Item Text="1280x1024" SizeHeight="30" /> - <Item Text="1920x1200" SizeHeight="30" /> - </Items> - </ListBox> + <ListBox Id="resolution" LocationX="20" LocationY="83" SizeWidth="145" SizeHeight="230" /> <CheckBox Id="fullscreen" LocationX="10" LocationY="330" SizeWidth="150" SizeHeight="30" Text="Fullscreen" /> Modified: branches/python_bindings_for_ui/csp/data/ui/themes/red/options.xml =================================================================== --- branches/python_bindings_for_ui/csp/data/ui/themes/red/options.xml 2007-04-29 11:09:13 UTC (rev 2088) +++ branches/python_bindings_for_ui/csp/data/ui/themes/red/options.xml 2007-04-29 17:28:48 UTC (rev 2089) @@ -12,14 +12,7 @@ <Label CssClass="stripe" LocationX="0" LocationY="30" SizeWidth="438" SizeHeight="10" /> <Label Text="Resolution:" LocationX="25" LocationY="55" SizeHeight="25" /> - <ListBox Id="resolution" LocationX="145" LocationY="55" SizeWidth="250" SizeHeight="140"> - <Items> - <Item Text="640x480" SizeHeight="30" /> - <Item Text="800x600" SizeHeight="30" /> - <Item Text="1024x768" SizeHeight="30" /> - <Item Text="1280x1024" SizeHeight="30" /> - </Items> - </ListBox> + <ListBox Id="resolution" LocationX="145" LocationY="55" SizeWidth="250" SizeHeight="140" /> <CheckBox Id="fullscreen" LocationX="25" LocationY="195" SizeWidth="150" SizeHeight="30" Text="Fullscreen" /> |