Mercurial > fife-parpg
comparison engine/python/fife/extensions/fife_settings.py @ 533:082e919cc348
Setting Extension:
Added possibility to set a custom style for the options gui
author | nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sat, 29 May 2010 17:52:07 +0000 |
parents | 4da56756a617 |
children | 00aa20dc8b7f |
comparison
equal
deleted
inserted
replaced
532:4da56756a617 | 533:082e919cc348 |
---|---|
146 tree.write(os.path.join(self._appdata, self._settings_file), 'UTF-8') | 146 tree.write(os.path.join(self._appdata, self._settings_file), 'UTF-8') |
147 | 147 |
148 #default settings | 148 #default settings |
149 self._resolutions = ['640x480', '800x600', '1024x768', '1280x800', '1440x900'] | 149 self._resolutions = ['640x480', '800x600', '1024x768', '1280x800', '1440x900'] |
150 | 150 |
151 #Used to stylize the options gui | |
152 self._gui_style = "default" | |
153 | |
151 self.loadSettings() | 154 self.loadSettings() |
152 | 155 |
153 def loadSettings(self): | 156 def loadSettings(self): |
154 self._tree = ET.parse(os.path.join(self._appdata, self._settings_file)) | 157 self._tree = ET.parse(os.path.join(self._appdata, self._settings_file)) |
155 self._root_element = self._tree.getroot() | 158 self._root_element = self._tree.getroot() |
156 self.validateTree() | 159 self.validateTree() |
160 | |
161 def setGuiStyle(self, style): | |
162 """ Set a custom gui style used for the option dialog. | |
163 @param style: Pychan style to be used | |
164 @type style: C{string} | |
165 """ | |
166 self._gui_style = style | |
157 | 167 |
158 def validateTree(self): | 168 def validateTree(self): |
159 """ Iterates the settings tree and prints warning when an invalid tag is found """ | 169 """ Iterates the settings tree and prints warning when an invalid tag is found """ |
160 for c in self._root_element.getchildren(): | 170 for c in self._root_element.getchildren(): |
161 if c.tag != "Module": | 171 if c.tag != "Module": |
363 | 373 |
364 if os.path.isfile(self._settings_gui_xml): | 374 if os.path.isfile(self._settings_gui_xml): |
365 self.OptionsDlg = pychan.loadXML(self._settings_gui_xml) | 375 self.OptionsDlg = pychan.loadXML(self._settings_gui_xml) |
366 else: | 376 else: |
367 self.OptionsDlg = pychan.loadXML(StringIO(self._settings_gui_xml)) | 377 self.OptionsDlg = pychan.loadXML(StringIO(self._settings_gui_xml)) |
378 self.OptionsDlg.stylize(self._gui_style) | |
368 self.OptionsDlg.distributeInitialData({ | 379 self.OptionsDlg.distributeInitialData({ |
369 'screen_resolution' : self._resolutions, | 380 'screen_resolution' : self._resolutions, |
370 'render_backend' : ['OpenGL', 'SDL'] | 381 'render_backend' : ['OpenGL', 'SDL'] |
371 }) | 382 }) |
372 self.OptionsDlg.distributeData({ | 383 self.OptionsDlg.distributeData({ |