comparison orpg/tools/orpg_settings.py @ 228:24769389a7ba alpha

Traipse Alpha 'OpenRPG' {100612-01} 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 (Preparing to close updates) New Features: New to Map, can re-order Grid, Miniatures, and Whiteboard layer draw order Fixes: Fix to InterParse that was causing an Infernal Loop with Namespace Internal Fix to XML data, removed old Minidom and switched to Element Tree Fix to Server that was causing eternal attempt to find a Server ID, in Register Rooms thread Fix to metaservers.xml file not being created
author sirebral
date Sat, 12 Jun 2010 04:38:29 -0500
parents b633f4c64aae
children
comparison
equal deleted inserted replaced
225:2c6db2043764 228:24769389a7ba
31 from orpg.dirpath import dir_struct 31 from orpg.dirpath import dir_struct
32 from rgbhex import * 32 from rgbhex import *
33 33
34 from orpg.tools.orpg_log import logger 34 from orpg.tools.orpg_log import logger
35 from orpg.tools.validate import validate 35 from orpg.tools.validate import validate
36 from orpg.orpg_xml import xml 36 from xml.etree.ElementTree import ElementTree, Element, parse
37 from xml.etree.ElementTree import fromstring, tostring
37 from orpg.tools.settings import settings 38 from orpg.tools.settings import settings
38 39
39 class orpgSettingsWnd(wx.Dialog): 40 class orpgSettingsWnd(wx.Dialog):
40 def __init__(self, parent): 41 def __init__(self, parent):
41 wx.Dialog.__init__(self,parent,-1,"OpenRPG Preferences", 42 wx.Dialog.__init__(self,parent,-1,"OpenRPG Preferences",
68 self.winsizer.SetDimension(0,0,w,h-25) 69 self.winsizer.SetDimension(0,0,w,h-25)
69 70
70 def build_gui(self): 71 def build_gui(self):
71 validate.config_file("settings.xml","default_settings.xml") 72 validate.config_file("settings.xml","default_settings.xml")
72 filename = dir_struct["user"] + "settings.xml" 73 filename = dir_struct["user"] + "settings.xml"
73 temp_file = open(filename) 74 temp_file = parse(filename)
74 temp_file.close() 75 children = self.settings.xml_dom.getchildren()
75 children = self.settings.xml_dom._get_childNodes() 76 for c in children: self.build_window(c, self.tabber)
76 for c in children: self.build_window(c,self.tabber)
77 77
78 def build_window(self, xml_dom, parent_wnd): 78 def build_window(self, xml_dom, parent_wnd):
79 name = xml_dom._get_nodeName() 79 name = xml_dom.tag
80 #container = 0 80 #container = 0
81 if name=="tab": temp_wnd = self.do_tab_window(xml_dom,parent_wnd) 81 if name=="tab": temp_wnd = self.do_tab_window(xml_dom,parent_wnd)
82 return temp_wnd 82 return temp_wnd
83 83
84 def do_tab_window(self, xml_dom, parent_wnd): 84 def do_tab_window(self, xml_dom, parent_wnd):
85 type = xml_dom.getAttribute("type") 85 type = xml_dom.get("type")
86 name = xml_dom.getAttribute("name") 86 name = xml_dom.get("name")
87 87
88 if type == "grid": 88 if type == "grid":
89 temp_wnd = self.do_grid_tab(xml_dom, parent_wnd) 89 temp_wnd = self.do_grid_tab(xml_dom, parent_wnd)
90 parent_wnd.AddPage(temp_wnd, name, False) 90 parent_wnd.AddPage(temp_wnd, name, False)
91 elif type == "tab": 91 elif type == "tab":
92 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_NO_X_BUTTON) 92 temp_wnd = orpgTabberWnd(parent_wnd, style=FNB.FNB_NO_X_BUTTON)
93 children = xml_dom._get_childNodes() 93 children = xml_dom.getchildren()
94 for c in children: 94 for c in children:
95 if c._get_nodeName() == "tab": self.do_tab_window(c, temp_wnd) 95 if c.tag == "tab": self.do_tab_window(c, temp_wnd)
96 temp_wnd.SetSelection(0) 96 temp_wnd.SetSelection(0)
97 parent_wnd.AddPage(temp_wnd, name, False) 97 parent_wnd.AddPage(temp_wnd, name, False)
98 elif type == "text": 98 elif type == "text":
99 temp_wnd = wx.TextCtrl(parent_wnd,-1) 99 temp_wnd = wx.TextCtrl(parent_wnd,-1)
100 parent_wnd.AddPage(temp_wnd, name, False) 100 parent_wnd.AddPage(temp_wnd, name, False)
101 else: temp_wnd = None 101 else: temp_wnd = None
102 return temp_wnd 102 return temp_wnd
103 103
104 def do_grid_tab(self, xml_dom, parent_wnd): 104 def do_grid_tab(self, xml_dom, parent_wnd):
105 settings = [] 105 settings = []
106 children = xml_dom._get_childNodes() 106 children = xml_dom.getchildren()
107 for c in children: 107 for c in children:
108 name = c._get_nodeName() 108 name = c.tag
109 value = c.getAttribute("value") 109 value = c.get("value")
110 help = c.getAttribute("help") 110 help = c.get("help")
111 options = c.getAttribute("options") 111 options = c.get("options")
112 settings.append([name, value, options, help]) 112 settings.append([name, value, options, help])
113 temp_wnd = settings_grid(parent_wnd, settings, self.changes) 113 temp_wnd = settings_grid(parent_wnd, settings, self.changes)
114 return temp_wnd 114 return temp_wnd
115 115
116 def onOk(self, evt): 116 def onOk(self, evt):
307 cols = self.GetNumberCols() 307 cols = self.GetNumberCols()
308 col_w = w/(cols) 308 col_w = w/(cols)
309 for i in range(0,cols): self.SetColSize(i,col_w) 309 for i in range(0,cols): self.SetColSize(i,col_w)
310 self.Refresh() 310 self.Refresh()
311 311
312 #settings = orpg.tools.settings.Settings()