Mercurial > traipse_dev
comparison orpg/tools/orpg_settings.py @ 135:dcf4fbe09b70 beta
Traipse Beta 'OpenRPG' {091010-00}
Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on
code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to
offer more advanced features and enhance the productivity of the user.
Update Summary (Beta)
Added Bookmarks
Fix to Remote Admin Commands
Minor fix to text based Server
Fix to Pretty Print, from Core
Fix to Splitter Nodes not being created
Fix to massive amounts of images loading, from Core
Added 'boot' command to remote admin
Added confirmation window for sent nodes
Minor changes to allow for portability to an OpenSUSE linux OS
Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG
Zoom Mouse plugin added
Images added to Plugin UI
Switching to Element Tree
Map efficiency, from FlexiRPG
Added Status Bar to Update Manager
default_manifest.xml renamed to default_upmana.xml
Cleaner clode for saved repositories
New TrueDebug Class in orpg_log (See documentation for usage)
Mercurial's hgweb folder is ported to upmana
**Pretty important update that can help remove thousands of dead children from your gametree.
**Children, <forms />, <group_atts />, <horizontal />, <cols />, <rows />, <height />, etc... are all tags now. Check your gametree and
look for dead children!!
**New Gamtree Recusion method, mapping, and context sensitivity. !!Alpha - Watch out for infinite loops!!
author | sirebral |
---|---|
date | Tue, 10 Nov 2009 14:11:28 -0600 |
parents | 68c7bd272f27 |
children | 565ab3d84430 |
comparison
equal
deleted
inserted
replaced
101:394ebb3b6a0f | 135:dcf4fbe09b70 |
---|---|
28 | 28 |
29 from orpg.orpg_windows import * | 29 from orpg.orpg_windows import * |
30 from orpg.orpgCore import component | 30 from orpg.orpgCore import component |
31 from orpg.dirpath import dir_struct | 31 from orpg.dirpath import dir_struct |
32 from rgbhex import * | 32 from rgbhex import * |
33 import sys | 33 |
34 import os | |
35 from orpg.orpg_xml import xml | |
36 from orpg.tools.orpg_log import logger | 34 from orpg.tools.orpg_log import logger |
37 from orpg.tools.validate import validate | 35 from orpg.tools.validate import validate |
38 from orpg.orpg_xml import xml | 36 from orpg.orpg_xml import xml |
39 | 37 from orpg.tools.settings import settings |
40 class orpgSettings: | |
41 def __init__(self): | |
42 self.xml = component.get("xml") | |
43 self.changes = [] | |
44 validate.config_file("settings.xml","default_settings.xml") | |
45 self.filename = dir_struct["user"] + "settings.xml" | |
46 temp_file = open(self.filename) | |
47 txt = temp_file.read() | |
48 temp_file.close() | |
49 | |
50 self.xml_dom = xml.parseXml(txt) | |
51 | |
52 if self.xml_dom is None: self.rebuildSettings() | |
53 self.xml_dom = self.xml_dom._get_documentElement() | |
54 | |
55 def rebuildSettings(self): | |
56 logger.info("Settings file has be corrupted, rebuilding settings.", True) | |
57 try: os.remove(self.filename) | |
58 except: pass | |
59 | |
60 validate.config_file("settings.xml","default_settings.xml") | |
61 temp_file = open(self.filename) | |
62 txt = temp_file.read() | |
63 temp_file.close() | |
64 self.xml_dom = xml.parseXml(txt) | |
65 | |
66 def get_setting(self, name): ##Depricated | |
67 return self.get(name) | |
68 | |
69 def get(self, name): | |
70 try: return self.xml_dom.getElementsByTagName(name)[0].getAttribute("value") | |
71 except: return 0 | |
72 | |
73 def get_setting_keys(self): ##Depricated | |
74 return self.get_keys() | |
75 | |
76 def get_keys(self): | |
77 keys = [] | |
78 tabs = self.xml_dom.getElementsByTagName("tab") | |
79 for i in xrange(0, len(tabs)): | |
80 if tabs[i].getAttribute("type") == 'grid': | |
81 children = tabs[i]._get_childNodes() | |
82 for c in children: keys.append(c._get_tagName()) | |
83 return keys | |
84 | |
85 def set_setting(self, name, value): ##Depricated | |
86 self.change(name, value) | |
87 | |
88 def change(self, name, value): | |
89 self.xml_dom.getElementsByTagName(name)[0].setAttribute("value", value) | |
90 | |
91 def add_setting(self, tab, setting, value, options, help): ##Depricated | |
92 return self.add(tab, setting, value, options, help) | |
93 | |
94 def add(self, tab, setting, value, options, help): | |
95 if len(self.xml_dom.getElementsByTagName(setting)) > 0: return False | |
96 tabs = self.xml_dom.getElementsByTagName("tab") | |
97 newsetting = xml.parseXml('<' + setting + ' value="' + value + '" options="' + | |
98 options + '" help="' + help + '" />')._get_documentElement() | |
99 for i in xrange(0, len(tabs)): | |
100 if tabs[i].getAttribute("name") == tab and tabs[i].getAttribute("type") == 'grid': | |
101 tabs[i].appendChild(newsetting) | |
102 return True | |
103 return False | |
104 | |
105 def add_tab(self, parent, tabname, tabtype): | |
106 tab_xml = '<tab ' | |
107 if tabtype == 'text': tab_xml += 'name="' + tabname + '" type="text" />' | |
108 else: tab_xml += 'name="' + tabname + '" type="' + tabtype + '"></tab>' | |
109 newtab = xml.parseXml(tab_xml)._get_documentElement() | |
110 if parent != None: | |
111 tabs = self.xml_dom.getElementsByTagName("tab") | |
112 for i in xrange(0, len(tabs)): | |
113 if tabs[i].getAttribute("name") == parent and tabs[i].getAttribute("type") == 'tab': | |
114 children = tabs[i]._get_childNodes() | |
115 for c in children: | |
116 if c.getAttribute("name") == tabname: return False | |
117 tabs[i].appendChild(newtab) | |
118 return True | |
119 else: | |
120 children = self.xml_dom._get_childNodes() | |
121 for c in children: | |
122 if c.getAttribute("name") == tabname: return False | |
123 self.xml_dom.appendChild(newtab) | |
124 return True | |
125 return False | |
126 | |
127 def updateIni(self): | |
128 defaultFile = orpg.dirpath.dir_struct['template'] + 'default_settings.xml' | |
129 temp_file = open(defaultFile) | |
130 txt = temp_file.read() | |
131 temp_file.close() | |
132 default_dom = xml.parseXml(txt)._get_documentElement() | |
133 for child in default_dom.getChildren(): | |
134 if child._get_tagName() == 'tab' and child.hasChildNodes(): self.proccessChildren(child) | |
135 default_dom.unlink() | |
136 | |
137 def proccessChildren(self, dom, parent=None): | |
138 if dom._get_tagName() == 'tab': | |
139 self.add_tab(parent, dom.getAttribute("name"), dom.getAttribute("type")) | |
140 | |
141 for child in dom.getChildren(): | |
142 if child._get_tagName() == 'tab' and child.hasChildNodes(): | |
143 self.proccessChildren(child, dom.getAttribute("name")) | |
144 else: | |
145 self.add_setting(dom.getAttribute("name"), child._get_tagName(), | |
146 child.getAttribute("value"), child.getAttribute("options"), | |
147 child.getAttribute("help")) | |
148 | |
149 def save(self): | |
150 temp_file = open(self.filename, "w") | |
151 temp_file.write(xml.toxml(self.xml_dom,1)) | |
152 temp_file.close() | |
153 | 38 |
154 class orpgSettingsWnd(wx.Dialog): | 39 class orpgSettingsWnd(wx.Dialog): |
155 def __init__(self, parent): | 40 def __init__(self, parent): |
156 wx.Dialog.__init__(self,parent,-1,"OpenRPG Preferences", | 41 wx.Dialog.__init__(self,parent,-1,"OpenRPG Preferences", |
157 wx.DefaultPosition,size = wx.Size(-1,-1), | 42 wx.DefaultPosition,size = wx.Size(-1,-1), |
399 cols = self.GetNumberCols() | 284 cols = self.GetNumberCols() |
400 col_w = w/(cols) | 285 col_w = w/(cols) |
401 for i in range(0,cols): self.SetColSize(i,col_w) | 286 for i in range(0,cols): self.SetColSize(i,col_w) |
402 self.Refresh() | 287 self.Refresh() |
403 | 288 |
404 settings = orpgSettings() | 289 #settings = orpg.tools.settings.Settings() |
405 component.add('settings', settings) |