Mercurial > fife-parpg
annotate engine/python/fife/extensions/fife_settings.py @ 555:63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
Stylize the changes require restart dialog
author | nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Thu, 17 Jun 2010 20:10:48 +0000 |
parents | 9b549d42f9ea |
children | 1d60e0223117 |
rev | line source |
---|---|
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
1 # -*- coding: utf-8 -*- |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
2 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
3 # #################################################################### |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
4 # Copyright (C) 2005-2010 by the FIFE team |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
5 # http://www.fifengine.net |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
6 # This file is part of FIFE. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
7 # |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
8 # FIFE is free software; you can redistribute it and/or |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
10 # License as published by the Free Software Foundation; either |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
11 # version 2.1 of the License, or (at your option) any later version. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
12 # |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
13 # This library is distributed in the hope that it will be useful, |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
16 # Lesser General Public License for more details. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
17 # |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
19 # License along with this library; if not, write to the |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
20 # Free Software Foundation, Inc., |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
22 # #################################################################### |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
23 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
24 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
25 Settings |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
26 ================================== |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
27 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
28 This module provides a nice framework for loading and saving game settings. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
29 It is by no means complete but it does provide a good starting point. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
30 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
31 @note: Please note that you MUST provide a default settings-dist.xml file |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
32 in the root directory of your project for this module to function correctly. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
33 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
34 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
35 import shutil |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
36 import os |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
37 from StringIO import StringIO |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
38 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
39 from fife.extensions import pychan |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
40 from fife.extensions.fife_utils import getUserDataDirectory |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
41 try: |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
42 import xml.etree.cElementTree as ET |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
43 except: |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
44 import xml.etree.ElementTree as ET |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
45 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
46 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
47 SETTINGS_GUI_XML="""\ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
48 <Window name="Settings" title="Settings"> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
49 <Label text="Settings menu!" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
50 <HBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
51 <VBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
52 <Label text="Resolution:" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
53 <Label text="Renderer:" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
54 </VBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
55 <VBox min_size="120,60"> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
56 <DropDown name="screen_resolution" min_size="120,0" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
57 <DropDown name="render_backend" min_size="120,0" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
58 </VBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
59 </HBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
60 <CheckBox name="enable_fullscreen" text="Use the full screen mode" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
61 <CheckBox name="enable_sound" text="Enable sound" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
62 <HBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
63 <Spacer /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
64 <Button name="cancelButton" text="Cancel" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
65 <Button name="okButton" text="Ok" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
66 <Button name="defaultButton" text="Defaults" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
67 </HBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
68 </Window> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
69 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
70 |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
71 CHANGES_REQUIRE_RESTART="""\ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
72 <Window title="Changes require restart"> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
73 <Label text="Some of your changes require you to restart." /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
74 <HBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
75 <Spacer /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
76 <Button name="closeButton" text="Ok" /> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
77 </HBox> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
78 </Window> |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
79 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
80 |
505
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
81 EMPTY_SETTINGS="""\ |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
82 <?xml version='1.0' encoding='UTF-8'?> |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
83 <Settings> |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
84 |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
85 </Settings> |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
86 """ |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
87 |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
88 FIFE_MODULE = "FIFE" |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
89 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
90 class Setting(object): |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
91 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
92 This class manages loading and saving of game settings. |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
93 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
94 Usage:: |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
95 from fife.extensions.fife_settings import Setting |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
96 settings = Setting(app_name="myapp") |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
97 screen_width = settings.get("FIFE", "ScreenWidth", 1024) |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
98 screen_height = settings.get("FIFE", "ScreenHeight", 768) |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
99 """ |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
100 |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
539
diff
changeset
|
101 def __init__(self, app_name="", settings_file="", settings_gui_xml="", changes_gui_xml="", copy_dist=True): |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
102 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
103 Initializes the Setting object. |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
104 |
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
105 @param app_name: The applications name. If this parameter is provided |
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
106 alone it will try to read the settings file from the users home directory. |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
107 In windows this will be something like: C:\Documents and Settings\user\Application Data\fife |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
108 @type app_name: C{string} |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
109 @param settings_file: The name of the settings file. If this parameter is |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
110 provided it will look for the setting file as you specify it, first looking |
505
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
111 in the working directory. It will NOT look in the users home directory. |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
112 @type settings_file: C{string} |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
113 @param settings_gui_xml: If you specify this parameter you can customize the look |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
114 of the settings dialog box. |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
539
diff
changeset
|
115 @param copy_dist: Copies the settings-dist.xml file to the settings_file location. If |
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
539
diff
changeset
|
116 this is False it will create a new empty xml file. |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
117 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
118 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
119 self._app_name = app_name |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
120 self._settings_file = settings_file |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
121 self._settings_gui_xml = settings_gui_xml |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
122 self._changes_gui_xml = changes_gui_xml |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
123 |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
124 # Holds SettingEntries |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
125 self._entries = {} |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
126 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
127 if self._settings_file == "": |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
128 self._settings_file = "settings.xml" |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
129 self._appdata = getUserDataDirectory("fife", self._app_name) |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
130 else: |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
131 self._appdata = os.path.dirname(self._settings_file) |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
132 self._settings_file = os.path.basename(self._settings_file) |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
133 |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
134 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
135 if self._settings_gui_xml == "": |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
136 self._settings_gui_xml = SETTINGS_GUI_XML |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
137 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
138 if self._changes_gui_xml == "": |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
139 self._changes_gui_xml = CHANGES_REQUIRE_RESTART |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
140 |
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
141 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
142 if not os.path.exists(os.path.join(self._appdata, self._settings_file)): |
543
cb7ec12214a9
Items can now be serialized/deserialized to/from disk. I haven't finished actors yet. This allows for persistent states when you enter/leave maps.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
539
diff
changeset
|
143 if os.path.exists('settings-dist.xml') and copy_dist: |
505
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
144 shutil.copyfile('settings-dist.xml', os.path.join(self._appdata, self._settings_file)) |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
145 else: |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
146 #no settings file found |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
147 tree = ET.parse(StringIO(EMPTY_SETTINGS)) |
ee65aa323457
Updated the ApplicationBase settings to use the new and improved fife_setting extension. I was able to remove all the setting related functions from the demos and editor so that the ApplicationBase now takes care of all the FIFE related settings.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
499
diff
changeset
|
148 tree.write(os.path.join(self._appdata, self._settings_file), 'UTF-8') |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
149 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
150 #default settings |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
151 self._resolutions = ['640x480', '800x600', '1024x768', '1280x800', '1440x900'] |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
152 self._renderbackends = ['OpenGL', 'SDL'] |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
153 |
533
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
154 #Used to stylize the options gui |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
155 self._gui_style = "default" |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
156 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
157 self.loadSettings() |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
158 |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
159 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
160 self._initDefaultSettingEntries() |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
161 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
162 def _initDefaultSettingEntries(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
163 """Initializes the default fife setting entries. Not to be called from |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
164 outside this class.""" |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
165 self.createAndAddEntry(FIFE_MODULE, "PlaySounds", "enable_sound", |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
166 requiresrestart=True) |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
167 self.createAndAddEntry(FIFE_MODULE, "FullScreen", "enable_fullscreen", |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
168 requiresrestart=True) |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
169 self.createAndAddEntry(FIFE_MODULE, "ScreenResolution", "screen_resolution", initialdata = self._resolutions, |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
170 requiresrestart=True) |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
171 self.createAndAddEntry(FIFE_MODULE, "RenderBackend", "render_backend", initialdata = self._renderbackends, |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
172 requiresrestart=True) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
173 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
174 def createAndAddEntry(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
175 """" |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
176 @param module: The Setting module this Entry belongs to |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
177 @type module: C{String} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
178 @param name: The Setting's name |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
179 @type name: C{String} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
180 @param widgetname: The name of the widget that is used to change this |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
181 setting |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
182 @type widgetname: C{String} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
183 @param applyfunction: function that makes the changes when the Setting is |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
184 saved |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
185 @type applyfunction: C{function} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
186 @param initialdata: If the widget supports the setInitialData() function |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
187 this can be used to set the initial data |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
188 @type initialdata: C{String} or C{Boolean} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
189 @param requiresrestart: Whether or not the changing of this setting |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
190 requires a restart |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
191 @type requiresrestart: C{Boolean} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
192 """ |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
193 entry = SettingEntry(module, name, widgetname, applyfunction, initialdata, requiresrestart) |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
194 self.addEntry(entry) |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
195 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
196 def addEntry(self, entry): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
197 """Adds a new C{SettingEntry} to the Settting |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
198 @param entry: A new SettingEntry that is to be added |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
199 @type entry: C{SettingEntry} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
200 """ |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
201 if entry.module not in self._entries: |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
202 self._entries[entry.module] = {} |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
203 self._entries[entry.module][entry.name] = entry |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
204 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
205 def loadSettings(self): |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
206 self._tree = ET.parse(os.path.join(self._appdata, self._settings_file)) |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
207 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
208 self._root_element = self._tree.getroot() |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
209 self.validateTree() |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
210 |
533
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
211 def setGuiStyle(self, style): |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
212 """ Set a custom gui style used for the option dialog. |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
213 @param style: Pychan style to be used |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
214 @type style: C{string} |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
215 """ |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
216 self._gui_style = style |
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
217 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
218 def validateTree(self): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
219 """ Iterates the settings tree and prints warning when an invalid tag is found """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
220 for c in self._root_element.getchildren(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
221 if c.tag != "Module": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
222 print "Invalid tag in settings.xml. Expected Module, got: ", c.tag |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
223 elif c.get("name", "") == "": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
224 print "Invalid tag in settings.xml. Module name is empty." |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
225 else: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
226 for e in c.getchildren(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
227 if e.tag != "Setting": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
228 print "Invalid tag in settings.xml in module: ",c.tag, |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
229 print ". Expected Setting, got: ", e.tag |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
230 elif c.get("name", "") == "": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
231 print "Invalid tag in settings.xml in module: ",c.tag, |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
232 print ". Setting name is empty", e.tag |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
233 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
234 def getModuleTree(self, module): |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
235 """ |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
236 Returns a module element from the settings tree. If no module with the specified |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
237 name exists, a new element will be created. |
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
238 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
239 @param module: The module to get from the settings tree |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
240 @type module: C{string} |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
241 """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
242 if not isinstance(module, str) and not isinstance(module, unicode): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
243 raise AttributeError("Settings:getModuleTree: Invalid type for module argument.") |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
244 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
245 for c in self._root_element.getchildren(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
246 if c.tag == "Module" and c.get("name", "") == module: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
247 return c |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
248 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
249 # Create module |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
250 return ET.SubElement(self._root_element, "Module", {"name":module}) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
251 |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
252 def get(self, module, name, defaultValue=None): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
253 """ Gets the value of a specified setting |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
254 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
255 @param module: Name of the module to get the setting from |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
256 @param name: Setting name |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
257 @param defaultValue: Specifies the default value to return if the setting is not found |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
258 @type defaultValue: C{str} or C{unicode} or C{int} or C{float} or C{bool} or C{list} or C{dict} |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
259 """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
260 if not isinstance(name, str) and not isinstance(name, unicode): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
261 raise AttributeError("Settings:get: Invalid type for name argument.") |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
262 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
263 moduleTree = self.getModuleTree(module) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
264 element = None |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
265 for e in moduleTree.getchildren(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
266 if e.tag == "Setting" and e.get("name", "") == name: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
267 element = e |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
268 break |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
269 else: |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
270 return defaultValue |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
271 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
272 e_value = element.text |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
273 e_strip = element.get("strip", "1").strip().lower() |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
274 e_type = str(element.get("type", "str")).strip() |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
275 |
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
276 if e_value is None: |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
277 return defaultValue |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
278 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
279 # Strip value |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
280 if e_strip == "" or e_strip == "false" or e_strip == "no" or e_strip == "0": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
281 e_strip = False |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
282 else: e_strip = True |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
283 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
284 if e_type == "str" or e_type == "unicode": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
285 if e_strip: e_value = e_value.strip() |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
286 else: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
287 e_value = e_value.strip() |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
288 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
289 # Return value |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
290 if e_type == 'int': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
291 return int(e_value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
292 elif e_type == 'float': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
293 return float(e_value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
294 elif e_type == 'bool': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
295 e_value = e_value.lower() |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
296 if e_value == "" or e_value == "false" or e_value == "no" or e_value == "0": |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
297 return False |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
298 else: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
299 return True |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
300 elif e_type == 'str': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
301 return str(e_value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
302 elif e_type == 'unicode': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
303 return unicode(e_value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
304 elif e_type == 'list': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
305 return self._deserializeList(e_value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
306 elif e_type == 'dict': |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
307 return self._deserializeDict(e_value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
308 |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
309 def set(self, module, name, value, extra_attrs={}): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
310 """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
311 Sets a setting to specified value. |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
312 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
313 @param module: Module where the setting should be set |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
314 @param name: Name of setting |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
315 @param value: Value to assign to setting |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
316 @type value: C{str} or C{unicode} or C{int} or C{float} or C{bool} or C{list} or C{dict} |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
317 @param extra_attrs: Extra attributes to be stored in the XML-file |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
318 @type extra_attrs: C{dict} |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
319 """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
320 if not isinstance(name, str) and not isinstance(name, unicode): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
321 raise AttributeError("Settings:set: Invalid type for name argument.") |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
322 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
323 moduleTree = self.getModuleTree(module) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
324 e_type = "str" |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
325 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
326 if isinstance(value, bool): # This must be before int |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
327 e_type = "bool" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
328 value = str(value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
329 elif isinstance(value, int): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
330 e_type = "int" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
331 value = str(value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
332 elif isinstance(value, float): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
333 e_type = "float" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
334 value = str(value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
335 elif isinstance(value, unicode): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
336 e_type = "unicode" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
337 value = unicode(value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
338 elif isinstance(value, list): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
339 e_type = "list" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
340 value = self._serializeList(value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
341 elif isinstance(value, dict): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
342 e_type = "dict" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
343 value = self._serializeDict(value) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
344 else: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
345 e_type = "str" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
346 value = str(value) |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
347 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
348 for e in moduleTree.getchildren(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
349 if e.tag != "Setting": continue |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
350 if e.get("name", "") == name: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
351 e.text = value |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
352 break |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
353 else: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
354 attrs = {"name":name, "type":e_type} |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
355 for k in extra_attrs: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
356 if k not in attrs: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
357 attrs[k] = extra_args[k] |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
358 elm = ET.SubElement(moduleTree, "Setting", attrs) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
359 elm.text = value |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
360 |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
361 def saveSettings(self): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
362 """ Writes the settings to the settings file """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
363 self._indent(self._root_element) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
364 self._tree.write(os.path.join(self._appdata, self._settings_file), 'UTF-8') |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
365 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
366 def _indent(self, elem, level=0): |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
367 """ |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
368 Adds whitespace, so the resulting XML-file is properly indented. |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
369 Shamelessly stolen from http://effbot.org/zone/element-lib.htm |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
370 """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
371 i = "\n" + level*" " |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
372 if len(elem): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
373 if not elem.text or not elem.text.strip(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
374 elem.text = i + " " |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
375 if not elem.tail or not elem.tail.strip(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
376 elem.tail = i |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
377 for elem in elem: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
378 self._indent(elem, level+1) |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
379 if not elem.tail or not elem.tail.strip(): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
380 elem.tail = i |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
381 else: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
382 if level and (not elem.tail or not elem.tail.strip()): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
383 elem.tail = i |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
384 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
385 # FIXME: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
386 # These serialization functions are not reliable at all |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
387 # This will only serialize the first level of a dict or list |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
388 # It will not check the types nor the content for conflicts. |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
389 # Perhaps we should add a small serialization library? |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
390 def _serializeList(self, list): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
391 """ Serializes a list, so it can be stored in a text file """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
392 return " ; ".join(list) |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
393 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
394 def _deserializeList(self, string): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
395 """ Deserializes a list back into a list object """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
396 return string.split(" ; ") |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
397 |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
398 def _serializeDict(self, dict): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
399 """ Serializes a list, so it can be stored in a text file """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
400 serial = "" |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
401 for key in dict: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
402 value = dict[key] |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
403 if serial != "": serial += " ; " |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
404 serial += str(key)+" : "+str(value) |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
405 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
406 return serial |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
407 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
408 def _deserializeDict(self, serial): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
409 """ Deserializes a list back into a dict object """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
410 dict = {} |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
411 items = serial.split(" ; ") |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
412 for i in items: |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
413 kv_pair = i.split(" : ") |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
414 dict[kv_pair[0]] = kv_pair[1] |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
415 return dict |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
416 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
417 def onOptionsPress(self): |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
418 """ |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
419 Opens the options dialog box. Usually you would bind this to a button. |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
420 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
421 self.changesRequireRestart = False |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
422 self.isSetToDefault = False |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
423 |
555
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
424 self.OptionsDlg = self._loadWidget(self._settings_gui_xml) |
533
082e919cc348
Setting Extension:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
532
diff
changeset
|
425 self.OptionsDlg.stylize(self._gui_style) |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
426 self.fillWidgets() |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
427 self.OptionsDlg.mapEvents({ |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
428 'okButton' : self.applySettings, |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
429 'cancelButton' : self.OptionsDlg.hide, |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
430 'defaultButton' : self.setDefaults |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
431 }) |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
432 self.OptionsDlg.show() |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
433 |
555
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
434 def _loadWidget(self, dialog): |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
435 """Loads a widget. Can load both files and pure xml strings""" |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
436 if os.path.isfile(self._settings_gui_xml): |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
437 return pychan.loadXML(dialog) |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
438 else: |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
439 return pychan.loadXML(StringIO(dialog)) |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
440 |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
441 |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
442 def fillWidgets(self): |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
443 for module in self._entries.itervalues(): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
444 for entry in module.itervalues(): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
445 widget = self.OptionsDlg.findChildByName(entry.settingwidgetname) |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
446 value = self.get(entry.module, entry.name) |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
447 if type(entry.initialdata) is list: |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
448 try: |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
449 value = entry.initialdata.index(value) |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
450 except ValueError: |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
451 raise ValueError("\"" + value + "\" is not a valid value for " + entry.name + ". Valid options: " + str(entry.initialdata)) |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
452 entry.initializeWidget(widget, value) |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
453 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
454 def applySettings(self): |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
455 """ |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
456 Writes the settings file. If a change requires a restart of the engine |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
457 it notifies you with a small dialog box. |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
458 """ |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
459 for module in self._entries.itervalues(): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
460 for entry in module.itervalues(): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
461 widget = self.OptionsDlg.findChildByName(entry.settingwidgetname) |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
462 data = widget.getData() |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
463 |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
464 # If the data is a list we need to get the correct selected data |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
465 # from the list. This is needed for e.g. dropdowns or listboxs |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
466 if type(entry.initialdata) is list: |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
467 data = entry.initialdata[data] |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
468 |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
469 # only require restart if something really changed |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
470 if entry.requiresrestart and data != self.get(entry.module, entry.name): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
471 self.changesRequireRestart = True |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
472 |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
473 self.set(entry.module, entry.name, data) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
474 |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
475 entry.onApply(data) |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
476 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
477 self.saveSettings() |
514
0cdc727f9f66
Honour the "settings_gui_xml" paramater in the Settings class
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
505
diff
changeset
|
478 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
479 self.OptionsDlg.hide() |
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
480 if self.changesRequireRestart: |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
481 self._showChangeRequireRestartDialog() |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
482 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
483 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
484 def _showChangeRequireRestartDialog(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
485 """Shows a dialog that informes the user that a restart is required |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
486 to perform the changes.""" |
555
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
487 RestartDlg = self._loadWidget(self._changes_gui_xml) |
63226105ac45
Load the changes_gui_xml correcty, even if it is set to a file
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
554
diff
changeset
|
488 RestartDlg.stylize(self._gui_style) |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
489 RestartDlg.mapEvents({ 'closeButton' : RestartDlg.hide }) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
490 RestartDlg.show() |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
491 |
499
3dff106b945b
Combined the settings extension with the editor settings module. It is now a little more robust. Note that the settings file format has changed.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
497
diff
changeset
|
492 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
493 def setAvailableScreenResolutions(self, reslist): |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
494 """ |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
495 A list of valid default screen resolutions. This should be called once |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
496 right after you instantiate Settings. |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
497 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
498 Valid screen resolutions must be strings in the form of: WIDTHxHEIGHT |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
499 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
500 Example: |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
501 settings.setAvailableScreenResolutions(["800x600", "1024x768"]) |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
502 """ |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
503 self._resolutions = reslist |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
504 |
497
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
505 def setDefaults(self): |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
506 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
507 Overwrites the setting file with the default settings-dist.xml file. |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
508 """ |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
509 shutil.copyfile('settings-dist.xml', os.path.join(self._appdata, self._settings_file)) |
559a26347730
Forgot to add fife_settings.py in my last commit. Adding it now.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff
changeset
|
510 self.changesRequireRestart = True |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
511 self.loadSettings() |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
512 self._showChangeRequireRestartDialog() |
532
4da56756a617
Fixed a small bug that didn't allow to use xml files as gui input for the setting extension
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
515
diff
changeset
|
513 |
515
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
514 if self.OptionsDlg: |
520bd1621644
Added a loadSettings function. Added the ability to set the valid screen resolutions. Fixed a problem with the settings dialog that kept the settings you selected even though you pressed cancel. When you press the "defaults" button it now applies the defaults and prompts the user to restart the game.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
514
diff
changeset
|
515 self.OptionsDlg.hide() |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
516 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
517 |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
518 def _getEntries(self): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
519 return self._entries |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
520 |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
521 def _setEntries(self, entries): |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
522 self._entries = entries |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
523 |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
524 entries = property(_getEntries, _setEntries) |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
525 |
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
526 |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
527 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
528 class SettingEntry(object): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
529 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
530 def __init__(self, module, name, widgetname, applyfunction=None, initialdata=None, requiresrestart=False): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
531 """ |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
532 @param module: The Setting module this Entry belongs to |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
533 @type module: C{String} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
534 @param name: The Setting's name |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
535 @type name: C{String} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
536 @param widgetname: The name of the widget that is used to change this |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
537 setting |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
538 @type widgetname: C{String} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
539 @param applyfunction: function that makes the changes when the Setting is |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
540 saved |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
541 @type applyfunction: C{function} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
542 @param initialdata: If the widget supports the setInitialData() function |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
543 this can be used to set the initial data |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
544 @type initialdata: C{String} or C{Boolean} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
545 @param requiresrestart: Whether or not the changing of this setting |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
546 requires a restart |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
547 @type requiresrestart: C{Boolean} |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
548 """ |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
549 self._module = module |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
550 self._name = name |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
551 self._settingwidgetname = widgetname |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
552 self._requiresrestart = requiresrestart |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
553 self._initialdata = initialdata |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
554 self._applyfunction = applyfunction |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
555 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
556 def initializeWidget(self, widget, currentValue): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
557 """Initialize the widget with needed data""" |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
558 if self._initialdata is not None: |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
559 widget.setInitialData(self._initialdata) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
560 widget.setData(currentValue) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
561 |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
562 def onApply(self, data): |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
563 """Implement actions that need to be taken when the setting is changed |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
564 here. |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
565 """ |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
566 if self._applyfunction is not None: |
554
9b549d42f9ea
Improved fife_settings:
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
543
diff
changeset
|
567 self._applyfunction(data) |
538
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
568 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
569 def _getModule(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
570 return self._module |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
571 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
572 def _setModule(self, module): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
573 self._module = module |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
574 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
575 def _getName(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
576 return self._name |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
577 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
578 def _setName(self, name): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
579 self._name = name |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
580 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
581 def _getSettingWidgetName(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
582 return self._settingwidgetname |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
583 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
584 def _setSettingWidgetName(self, settingwidgetname): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
585 self._settingwidgetname = settingwidgetname |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
586 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
587 def _getRequiresRestart(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
588 return self._requiresrestart |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
589 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
590 def _setRequiresRestart(self, requiresrestart): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
591 self._requiresrestart = requiresrestart |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
592 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
593 def _getInitialData(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
594 return self._initialdata |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
595 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
596 def _setInitialData(self, initialdata): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
597 self._initialdata = initialdata |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
598 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
599 def _getApplyFunction(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
600 return self._applyfunction |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
601 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
602 def _setApplyFunction(self, applyfunction): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
603 self._applyfunction = applyfunction |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
604 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
605 module = property(_getModule, _setModule) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
606 name = property(_getName, _setName) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
607 settingwidgetname = property(_getSettingWidgetName, _setSettingWidgetName) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
608 requiresrestart = property(_getRequiresRestart, _setRequiresRestart) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
609 initialdata = property(_getInitialData, _setInitialData) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
610 applyfunction = property(_getApplyFunction, _setApplyFunction) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
611 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
612 def __str__(self): |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
613 return "SettingEntry: " + self.name + " Module: " + self.module + " Widget: " + \ |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
614 self.settingwidgetname + " requiresrestart: " + str(self.requiresrestart) + \ |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
615 " initialdata: " + str(self.initialdata) |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
616 |
00aa20dc8b7f
Made the Setting class much more customizable by adding the SettingEntry class.
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
533
diff
changeset
|
617 |