Mercurial > traipse_dev
comparison orpg/tools/pluginui.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 | c54768cffbd4 |
children |
comparison
equal
deleted
inserted
replaced
101:394ebb3b6a0f | 135:dcf4fbe09b70 |
---|---|
1 from orpg.orpg_wx import * | 1 from orpg.orpg_wx import * |
2 from orpg.orpgCore import * | 2 from orpg.orpgCore import * |
3 import orpg.plugindb as plugindb | 3 from orpg.plugindb import plugindb |
4 from orpg.dirpath import dir_struct | 4 from orpg.dirpath import dir_struct |
5 | 5 |
6 sys.path.append(dir_struct["plugins"]) | 6 #sys.path.append(dir_struct["plugins"]) |
7 | 7 |
8 class PluginFrame(wx.Frame): | 8 class PluginFrame(wx.Frame): |
9 def __init__(self, parent): | 9 def __init__(self, parent): |
10 wx.Frame.__init__(self, parent, wx.ID_ANY, "Plugin Control Panel") | 10 wx.Frame.__init__(self, parent, wx.ID_ANY, "Plugin Control Panel") |
11 self.panel = wx.Panel(self, wx.ID_ANY) | 11 self.panel = wx.Panel(self, wx.ID_ANY) |
12 self.plugindb = plugindb.PluginDB() | |
13 self.parent = parent | 12 self.parent = parent |
14 self.startplugs = self.plugindb.GetList("plugincontroller", "startup_plugins", []) | 13 self.startplugs = plugindb.GetList("plugincontroller", "startup_plugins", []) |
15 self.available_plugins = {} | 14 self.available_plugins = {} |
16 self.enabled_plugins = {} | 15 self.enabled_plugins = {} |
17 self.pluginNames = [] | 16 self.pluginNames = [] |
18 self.SetMinSize((380, 480)) | 17 self.SetMinSize((380, 480)) |
19 self._selectedPlugin = None | 18 self._selectedPlugin = None |
42 def __buildGUI(self): | 41 def __buildGUI(self): |
43 self.main_sizer = wx.BoxSizer(wx.VERTICAL) | 42 self.main_sizer = wx.BoxSizer(wx.VERTICAL) |
44 self.btn_sizer = wx.BoxSizer(wx.HORIZONTAL) | 43 self.btn_sizer = wx.BoxSizer(wx.HORIZONTAL) |
45 self.btn_sizer2 = wx.BoxSizer(wx.HORIZONTAL) | 44 self.btn_sizer2 = wx.BoxSizer(wx.HORIZONTAL) |
46 self.head_sizer = wx.BoxSizer(wx.HORIZONTAL) | 45 self.head_sizer = wx.BoxSizer(wx.HORIZONTAL) |
47 #pnl = wx.Panel(self.panel, wx.ID_ANY) | |
48 self.err_sizer = wx.BoxSizer(wx.VERTICAL) | 46 self.err_sizer = wx.BoxSizer(wx.VERTICAL) |
49 self.err_sizer.Add(self.head_sizer, 0, wx.EXPAND) | 47 self.err_sizer.Add(self.head_sizer, 0, wx.EXPAND) |
50 self.errorMessage = wx.StaticText(self.panel, wx.ID_ANY, "") | 48 self.errorMessage = wx.StaticText(self.panel, wx.ID_ANY, "") |
51 self.err_sizer.Add(self.errorMessage, 0, wx.EXPAND) | 49 self.err_sizer.Add(self.errorMessage, 0, wx.EXPAND) |
52 self.main_sizer.Add(self.err_sizer, 0, wx.EXPAND) | 50 self.main_sizer.Add(self.err_sizer, 0, wx.EXPAND) |
53 self.pluginList = wx.ListCtrl(self.panel, wx.ID_ANY, style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES|wx.LC_SORT_ASCENDING) | 51 self.pluginList = wx.ListCtrl(self.panel, wx.ID_ANY, |
54 self.pluginList.InsertColumn(1, "Name") | 52 style=wx.LC_SINGLE_SEL|wx.LC_REPORT|wx.LC_HRULES|wx.LC_SORT_ASCENDING) |
55 self.pluginList.InsertColumn(2, "Autostart") | 53 self.pluginList.InsertColumn(0, "Name") |
56 self.pluginList.InsertColumn(3, "Author") | 54 self.pluginList.InsertColumn(1, "Author") |
57 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self._selectPlugin, self.pluginList) | 55 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self._selectPlugin, self.pluginList) |
58 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self._deselectPlugin, self.pluginList) | 56 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self._deselectPlugin, self.pluginList) |
59 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._togglePlugin, self.pluginList) | 57 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._togglePlugin, self.pluginList) |
60 self.Bind(wx.EVT_LIST_COL_CLICK, self._sort, self.pluginList) | 58 self.Bind(wx.EVT_LIST_COL_CLICK, self._sort, self.pluginList) |
61 self.main_sizer.Add(self.pluginList, 1, wx.EXPAND) | 59 self.main_sizer.Add(self.pluginList, 1, wx.EXPAND) |
88 self.__disablePluginBtns() | 86 self.__disablePluginBtns() |
89 | 87 |
90 self.main_sizer.Add(self.btn_sizer, 0, wx.EXPAND) | 88 self.main_sizer.Add(self.btn_sizer, 0, wx.EXPAND) |
91 self.main_sizer.Add(self.btn_sizer2, 0, wx.EXPAND) | 89 self.main_sizer.Add(self.btn_sizer2, 0, wx.EXPAND) |
92 | 90 |
91 # Create Book Mark Image List | |
92 self.pluginList.Bind(wx.EVT_LEFT_DOWN, self.on_hit) | |
93 self._imageList = wx.ImageList( 16, 16, False ) | |
94 img = wx.Image(dir_struct["icon"]+"add_button.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() | |
95 self._imageList.Add( img ) | |
96 img = wx.Image(dir_struct["icon"]+"check_button.png", wx.BITMAP_TYPE_PNG).ConvertToBitmap() | |
97 self._imageList.Add( img ) | |
98 self.pluginList.SetImageList( self._imageList, wx.IMAGE_LIST_SMALL ) | |
99 | |
100 def on_hit(self, evt): | |
101 pos = wx.Point( evt.GetX(), evt.GetY() ) | |
102 (item, flag, sub) = self.pluginList.HitTestSubItem( pos ) | |
103 ## Item == list[server], flag == (32 = 0 colum, 128 = else) ## | |
104 if flag == 32: self._autostart(item) | |
105 evt.Skip() | |
106 | |
93 def __disablePluginBtns(self): | 107 def __disablePluginBtns(self): |
94 self.enableBtn.Disable() | 108 self.enableBtn.Disable() |
95 self.disableBtn.Disable() | 109 self.disableBtn.Disable() |
96 self.autostartBtn.Disable() | 110 self.autostartBtn.Disable() |
97 self.helpBtn.Disable() | 111 self.helpBtn.Disable() |
110 def __clearError(self): | 124 def __clearError(self): |
111 self.errorMessage.Label = "" | 125 self.errorMessage.Label = "" |
112 self.__doLayout() | 126 self.__doLayout() |
113 | 127 |
114 def __checkIdx(self, evt): | 128 def __checkIdx(self, evt): |
115 if isinstance(evt, int): | 129 if isinstance(evt, int): return evt |
116 return evt | 130 elif self._selectedPlugin is not None: return self._selectedPlugin |
117 elif self._selectedPlugin is not None: | |
118 return self._selectedPlugin | |
119 else: | 131 else: |
120 dlg = wx.MessageDialog(None, "You need to select a plugin before you can use this!", 'ERROR', wx.OK) | 132 dlg = wx.MessageDialog(None, |
133 "You need to select a plugin before you can use this!", | |
134 'ERROR', wx.OK) | |
121 dlg.ShowModal() | 135 dlg.ShowModal() |
122 dlg.Destroy() | 136 dlg.Destroy() |
123 return None | 137 return None |
124 | 138 |
125 def __impPlugin(self, pname): | 139 def __impPlugin(self, pname): |
126 try: | 140 try: |
127 if "plugins." + pname in sys.modules: | 141 if "plugins." + pname in sys.modules: |
128 del sys.modules["plugins." + pname]#to ensure that the newly-imported one will be used correctly. No, reload() is not a better way to do this. | 142 del sys.modules["plugins." + pname] |
143 #to ensure that the newly-imported one will be used correctly. | |
144 #No, reload() is not a better way to do this. | |
129 mod = __import__("plugins." + pname) | 145 mod = __import__("plugins." + pname) |
130 plugin = getattr(mod, pname) | 146 plugin = getattr(mod, pname) |
131 pdata = plugin.Plugin(self.plugindb, self.parent) | 147 pdata = plugin.Plugin(plugindb, self.parent) |
132 self.available_plugins[pdata.name] = [pname, pdata, pdata.author, pdata.help] | 148 self.available_plugins[pdata.name] = [pname, pdata, pdata.author, pdata.help] |
133 return plugin | 149 return plugin |
134 | 150 |
135 except Exception, e: | 151 except Exception, e: |
136 self.__error(e) | 152 self.__error(e) |
155 | 171 |
156 if info[0] in self.enabled_plugins: | 172 if info[0] in self.enabled_plugins: |
157 self.enableBtn.Disable() | 173 self.enableBtn.Disable() |
158 else: | 174 else: |
159 self.disableBtn.Disable() | 175 self.disableBtn.Disable() |
160 if self.pluginList.GetItem(self._selectedPlugin, 1).GetText() == "X": | 176 if pname in self.startplugs: |
161 self.autostartBtn.Label = "Disable Autostart" | 177 self.autostartBtn.Label = "Disable Autostart" |
162 | 178 |
163 self.__doLayout() | 179 self.__doLayout() |
164 self.pluginList.SetItemState(self._selectedPlugin, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) | 180 self.pluginList.SetItemState(self._selectedPlugin, |
181 wx.LIST_STATE_SELECTED, | |
182 wx.LIST_STATE_SELECTED) | |
165 | 183 |
166 def _deselectPlugin(self, evt): | 184 def _deselectPlugin(self, evt): |
167 self.__disablePluginBtns() | 185 self.__disablePluginBtns() |
168 self._selectedPlugin = None | 186 self._selectedPlugin = None |
169 | 187 |
170 def _togglePlugin(self, evt): | 188 def _togglePlugin(self, evt): |
171 idx = evt.GetIndex() | 189 idx = evt.GetIndex() |
172 pname = self.pluginList.GetItem(idx, 0).GetText() | 190 pname = self.pluginList.GetItem(idx, 0).GetText() |
173 info = self.available_plugins[pname] | 191 info = self.available_plugins[pname] |
174 | 192 if info[0] in self.enabled_plugins: self._disable(idx) |
175 if info[0] in self.enabled_plugins: | 193 else: self._enable(idx) |
176 self._disable(idx) | |
177 else: | |
178 self._enable(idx) | |
179 | |
180 self.pluginList.SetItemState(self._selectedPlugin, 0, wx.LIST_STATE_SELECTED) | 194 self.pluginList.SetItemState(self._selectedPlugin, 0, wx.LIST_STATE_SELECTED) |
181 | 195 |
182 def _enableAll(self, evt): | 196 def _enableAll(self, evt): |
183 for pname in self.available_plugins.iterkeys(): | 197 for pname in self.available_plugins.iterkeys(): |
184 info = self.available_plugins[pname] | 198 info = self.available_plugins[pname] |
234 self.disableBtn.Disable() | 248 self.disableBtn.Disable() |
235 self.enableBtn.Enable() | 249 self.enableBtn.Enable() |
236 | 250 |
237 def _autostart(self, evt): | 251 def _autostart(self, evt): |
238 idx = self.__checkIdx(evt) | 252 idx = self.__checkIdx(evt) |
239 if idx is None: | 253 if idx is None: return |
240 return | 254 pname = self.pluginList.GetItem(idx, 0).GetText() |
241 if self.pluginList.GetItem(idx, 1).GetText() == "X": | 255 info = self.available_plugins[pname] |
256 if self.pluginList.GetItem(idx, 0).GetText() in self.startplugs: | |
242 self.startplugs.remove(self.pluginList.GetItem(idx, 0).GetText()) | 257 self.startplugs.remove(self.pluginList.GetItem(idx, 0).GetText()) |
243 self.pluginList.SetStringItem(idx, 1, "") | 258 self.pluginList.SetItemImage(idx, 0, 0) |
244 self.autostartBtn.Label = "Autostart" | 259 self.autostartBtn.Label = "Autostart" |
260 if info[0] in self.enabled_plugins: | |
261 dlg = wx.MessageDialog(None, 'Disable Plugin Now?', 'Plugin Enabled', | |
262 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) | |
263 dlg.ShowModal() | |
264 if dlg.ShowModal() == wx.ID_YES: self._disable(evt) | |
245 else: | 265 else: |
246 self.startplugs.append(self.pluginList.GetItem(idx, 0).GetText()) | 266 self.startplugs.append(self.pluginList.GetItem(idx, 0).GetText()) |
247 self.pluginList.SetStringItem(idx, 1, "X") | 267 self.pluginList.SetItemImage(idx, 1, 0) |
248 self.autostartBtn.Label = "Disable Autostart" | 268 self.autostartBtn.Label = "Disable Autostart" |
249 | 269 if info[0] not in self.enabled_plugins: |
250 self.plugindb.SetList("plugincontroller", "startup_plugins", self.startplugs) | 270 dlg = wx.MessageDialog(None, 'Enable Plugin Now?', 'Plugin Disabled', |
271 wx.YES_NO | wx.NO_DEFAULT | wx.ICON_QUESTION) | |
272 if dlg.ShowModal() == wx.ID_YES: self._enable(evt) | |
273 | |
274 plugindb.SetList("plugincontroller", "startup_plugins", self.startplugs) | |
251 self.__doLayout() | 275 self.__doLayout() |
252 | 276 |
253 def _help(self, evt): | 277 def _help(self, evt): |
254 if isinstance(evt, int): | 278 if isinstance(evt, int): idx = evt |
255 idx = evt | 279 elif self._selectedPlugin is not None: idx = self._selectedPlugin |
256 elif self._selectedPlugin is not None: | |
257 idx = self._selectedPlugin | |
258 else: | 280 else: |
259 dlg = wx.MessageDialog(None, "You need to select a plugin before you can use this!", 'ERROR', wx.OK) | 281 dlg = wx.MessageDialog(None, |
282 "You need to select a plugin before you can use this!", | |
283 'ERROR', wx.OK) | |
260 dlg.ShowModal() | 284 dlg.ShowModal() |
261 dlg.Destroy() | 285 dlg.Destroy() |
262 return | 286 return |
263 | 287 |
264 pname = self.pluginList.GetItem(idx, 0).GetText() | 288 pname = self.pluginList.GetItem(idx, 0).GetText() |
265 info = self.available_plugins[pname] | 289 info = self.available_plugins[pname] |
266 | |
267 msg = "Author(s):\t" + info[2] + "\n\n" + info[3] | 290 msg = "Author(s):\t" + info[2] + "\n\n" + info[3] |
268 | |
269 dlg = wx.MessageDialog(None, msg, 'Plugin Information: ' + pname, wx.OK) | 291 dlg = wx.MessageDialog(None, msg, 'Plugin Information: ' + pname, wx.OK) |
270 dlg.ShowModal() | 292 dlg.ShowModal() |
271 dlg.Destroy() | 293 dlg.Destroy() |
272 | 294 |
273 def _update(self, evt): | 295 def _update(self, evt): |
278 self.pluginList.DeleteAllItems() | 300 self.pluginList.DeleteAllItems() |
279 self.pluginNames = [] | 301 self.pluginNames = [] |
280 | 302 |
281 list_of_plugin_dir = os.listdir(dir_struct["plugins"]) | 303 list_of_plugin_dir = os.listdir(dir_struct["plugins"]) |
282 for p in list_of_plugin_dir: | 304 for p in list_of_plugin_dir: |
283 #print p[:2]; print p[-4:] | |
284 if p[:2].lower()=="xx" and p[-3:]==".py": | 305 if p[:2].lower()=="xx" and p[-3:]==".py": |
285 self.__impPlugin(p[:-3]) | 306 self.__impPlugin(p[:-3]) |
286 elif p[:2].lower()=="xx" and p[-4:]==".pyc": | 307 elif p[:2].lower()=="xx" and p[-4:]==".pyc": |
287 self.__impPlugin(p[:-4]) | 308 self.__impPlugin(p[:-4]) |
288 | 309 |
289 i = 0 | 310 i = 0 |
290 for plugname, info in self.available_plugins.iteritems(): | 311 for plugname, info in self.available_plugins.iteritems(): |
291 self.pluginNames.append(plugname) | 312 self.pluginNames.append(plugname) |
292 idx = self.pluginList.InsertStringItem(self.pluginList.GetItemCount(), plugname) | 313 idx = self.pluginList.InsertStringItem(self.pluginList.GetItemCount(), plugname) |
293 self.pluginList.SetStringItem(idx, 2, info[2]) | 314 self.pluginList.SetStringItem(idx, 1, info[2]) |
315 self.pluginList.SetItemImage(idx, 0, 0) | |
294 if plugname in self.startplugs: | 316 if plugname in self.startplugs: |
295 self.pluginList.SetStringItem(idx, 1, "X") | 317 self.pluginList.SetItemImage(idx, 1, 0) |
296 self._enable(idx) | 318 self._enable(idx) |
297 self.pluginList.SetItemData(idx, i) | 319 self.pluginList.SetItemData(idx, i) |
298 i += 1 | 320 i += 1 |
299 self.pluginList.SetColumnWidth(0, wx.LIST_AUTOSIZE) | 321 self.pluginList.SetColumnWidth(0, wx.LIST_AUTOSIZE) |
322 self.pluginList.SetColumnWidth(1, wx.LIST_AUTOSIZE) | |
300 self.__doLayout() | 323 self.__doLayout() |
301 self.__disablePluginBtns() | 324 self.__disablePluginBtns() |
302 | 325 |
303 def _close(self, evt): | 326 def _close(self, evt): |
304 self.Hide() | 327 self.Hide() |