annotate gui/menus.py @ 183:7b6aba7839ea

getGameEnvironment of GameState now returns a locals dictionary that is empty at the beginning of the game and will be saved in save games. The vals and funcs are now both in the globals dictionary. This WILL break old saves.
author Beliar <KarstenBock@gmx.net>
date Thu, 15 Mar 2012 16:24:05 +0100
parents b3b82c2aebee
children
rev   line source
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
1 # This file is part of PARPG.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
2
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
3 # PARPG is free software: you can redistribute it and/or modify
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
4 # it under the terms of the GNU General Public License as published by
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
5 # the Free Software Foundation, either version 3 of the License, or
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
6 # (at your option) any later version.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
7
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
8 # PARPG is distributed in the hope that it will be useful,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
11 # GNU General Public License for more details.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
12
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
13 # You should have received a copy of the GNU General Public License
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
14 # along with PARPG. If not, see <http://www.gnu.org/licenses/>.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
15
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
16 import logging
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
17
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
18 from fife.extensions import pychan
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
19
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
20 from parpg import vfs
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
21 from dialogs import RestartDialog
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
22
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
23 logger = logging.getLogger('menus')
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
24
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
25 class ContextMenu(object):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
26 def __init__(self, engine, menu_items, pos):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
27 """@type engine: engine.Engine
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
28 @param engine: An instance of the class Engine from engine.py
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
29 @type menu_items: list
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
30 @param menu_items: A list of items containing the name and
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
31 text for the menu item and callback
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
32 i.e. [["menu", "Some text", Callback]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
33 @type pos: (int, int)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
34 @param pos: Screen position to use
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
35 @return: None"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
36 self.vbox = pychan.widgets.VBox(position=pos)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
37 events_to_map = {}
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
38 for item in menu_items:
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
39 p = pychan.widgets.Button(name=item[0], text=unicode(item[1]))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
40 self.vbox.addChild(p)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
41 events_to_map [item[0]] = self.actionDecorator(*item[2:])
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
42 self.vbox.mapEvents(events_to_map)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
43
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
44 def show(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
45 """Shows the context menu"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
46 self.vbox.show()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
47 def hide(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
48 """Hides the context menu"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
49 self.vbox.hide()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
50
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
51 def actionDecorator (self,func, *args, **kwargs):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
52 """This function is supposed to add some generic that should be
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
53 executed before and/or after an action is fired through the
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
54 context menu.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
55
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
56 @type func: Any callable
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
57 @param func: The original action function
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
58 @param args: Unpacked list of positional arguments
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
59 @param kwargs: Unpacked list of keyword arguments
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
60 @return: A wrapped version of func"""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
61 def decoratedFunc ():
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
62 """ This is the actual wrapped version of func, that is returned.
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
63 It takes no external arguments, so it can safely be passed around
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
64 as a callback."""
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
65 # some stuff that we do before the actual action is executed
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
66 self.hide()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
67 # run the action function, and record the return value
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
68 ret_val = func (*args,**kwargs)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
69 # we can eventually add some post-action code here, if needed (e.g. logging)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
70 pass
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
71 # return the value, as if the original function was called
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
72 return ret_val
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
73 return decoratedFunc
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
74
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
75 class SettingsMenu(object):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
76 def __init__(self, engine, settings):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
77 self.engine = engine
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
78 self.settings = settings
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
79
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
80 # available options
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
81 screen_modes = self.engine.getDeviceCaps().getSupportedScreenModes()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
82 resolutions = list(set([(mode.getWidth(), mode.getHeight())
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
83 for mode in screen_modes]))
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
84 self.resolutions = ["{0}x{1}".format(item[0], item[1])
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
85 for item in sorted(resolutions)[1:]]
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
86
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
87 self.render_backends = ['OpenGL', 'SDL']
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
88 self.lighting_models = range(3)
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
89
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
90 # selected options
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
91 self.resolution = self.settings.get("FIFE", "ScreenResolution")
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
92 self.render_backend = self.settings.get("FIFE", "RenderBackend")
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
93 self.lighting_model = self.settings.get("FIFE", "Lighting")
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
94 self.fullscreen = self.settings.get("FIFE", "FullScreen")
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
95 self.sound = self.settings.get("FIFE", "PlaySounds")
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
96 self.scroll_speed = self.settings.get("parpg", "ScrollSpeed")
2
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
97
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
98 xml_file = vfs.VFS.open('gui/settings_menu.xml')
06145a6ee387 Fixed resource path dependencies issue that caused PARPG to crash on start.
M. George Hansen <technopolitica@gmail.com>
parents: 0
diff changeset
99 self.window = pychan.loadXML(xml_file)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
100 self.restart_dialog = RestartDialog(self.settings)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
101 self.window.mapEvents({'okButton': self.save,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
102 'cancelButton': self.hide,
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
103 'defaultButton': self.reset,
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
104 'scroll_speed': self.update})
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
105 self.initializeWidgets()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
106 self.fillWidgets()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
107
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
108 def initializeWidgets(self):
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
109 scroll_speed = unicode(self.scroll_speed)
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
110 initial_data = {'screen_resolution': self.resolutions,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
111 'render_backend': self.render_backends,
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
112 'lighting_model': self.lighting_models,
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
113 'scroll_speed_value': scroll_speed}
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
114
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
115 self.window.distributeInitialData(initial_data)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
116
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
117
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
118 def fillWidgets(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
119 resolution = self.resolutions.index(self.resolution)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
120 backend = self.render_backends.index(self.render_backend)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
121 lighting = self.lighting_models.index(self.lighting_model)
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
122
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
123 self.window.distributeData({'screen_resolution': resolution,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
124 'render_backend': backend,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
125 'lighting_model': lighting,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
126 'enable_fullscreen': self.fullscreen,
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
127 'enable_sound': self.sound})
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
128
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
129 def update(self):
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
130 """updates lables to show realtime data"""
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
131 #collects the data from the widgets
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
132 (scroll_speed) = self.window.collectData('scroll_speed')
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
133
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
134 #alter the data note:pychan insists that all lables be given
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
135 # unicode text
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
136 #the slice rounds the number displayed
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
137 scroll_speed = unicode(scroll_speed)[:3]
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
138
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
139 #adds the data to the proper widgets
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
140 self.window.distributeInitialData({'scroll_speed_value': scroll_speed})
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
141
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
142 def show(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
143 self.window.show()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
144
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
145 def hide(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
146 self.window.hide()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
147
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
148 def reset(self):
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
149 self.settings.read(self.settings.system_path)
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
150 self.fillWidgets()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
151
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
152 def save(self):
4
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
153 (resolution, backend, lighting, fullscreen, sound, scroll_speed) = \
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
154 self.window.collectData('screen_resolution', 'render_backend',
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
155 'lighting_model', 'enable_fullscreen',
bf1dd9c24a7e Scrolling by keyboard is now possible.
DomtronVox
parents: 2
diff changeset
156 'enable_sound', 'scroll_speed')
167
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
157 self.settings.set("FIFE", "ScreenResolution", self.resolutions[resolution])
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
158 self.settings.set("FIFE", "RenderBackend", self.render_backends[backend])
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
159 self.settings.set("FIFE", "Lighting", self.lighting_models[lighting])
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
160 self.settings.set("FIFE", "FullScreen", fullscreen)
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
161 self.settings.set("FIFE", "EnableSound", sound)
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
162 self.settings.set("FIFE", "ScrollSpeed", scroll_speed)
b3b82c2aebee Using fife settings module again instead of our own.
Beliar <KarstenBock@gmx.net>
parents: 4
diff changeset
163 self.settings.saveSettings("../settings.xml")
0
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
164
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
165 self.restart_dialog.show()
7a89ea5404b1 Initial commit of parpg-core.
M. George Hansen <technopolitica@gmail.com>
parents:
diff changeset
166 self.hide()