comparison orpg/tools/pluginui.py @ 112:61fc775862f7 alpha

Traipse Alpha 'OpenRPG' {091009-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: {091006} 00: Adds Bookmarks (Alpha) with cool Smiley Star and Plus Symbol images! 03: Changes made to the map for increased portability. SnowDog has changes planned in Core, though. Added an initial push to the BCG. Not much to see, just shows off how it is re-writing Main code. {091008} 00: Fix to remote admin commands 01: Minor fix to texted based server, works in /System/ folder Some Core changes to gametree to correctly disply Pretty Print, thanks David! {091009} 00: Fix to Splitter Nodes not being created. Plugin Control panel works with images now Fix to massive amounts of images loading; from Core
author sirebral
date Fri, 09 Oct 2009 23:26:21 -0500
parents 8e2b7da4f509
children 217fb049bd00
comparison
equal deleted inserted replaced
111:0c936d98f9eb 112:61fc775862f7
49 self.err_sizer.Add(self.head_sizer, 0, wx.EXPAND) 49 self.err_sizer.Add(self.head_sizer, 0, wx.EXPAND)
50 self.errorMessage = wx.StaticText(self.panel, wx.ID_ANY, "") 50 self.errorMessage = wx.StaticText(self.panel, wx.ID_ANY, "")
51 self.err_sizer.Add(self.errorMessage, 0, wx.EXPAND) 51 self.err_sizer.Add(self.errorMessage, 0, wx.EXPAND)
52 self.main_sizer.Add(self.err_sizer, 0, wx.EXPAND) 52 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) 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)
54 self.pluginList.InsertColumn(0, "Autostart") 54 #self.pluginList.InsertColumn(0, "Autostart")
55 self.pluginList.InsertColumn(1, "Name") 55 self.pluginList.InsertColumn(0, "Name")
56 self.pluginList.InsertColumn(2, "Author") 56 self.pluginList.InsertColumn(1, "Author")
57 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self._selectPlugin, self.pluginList) 57 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self._selectPlugin, self.pluginList)
58 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self._deselectPlugin, self.pluginList) 58 self.Bind(wx.EVT_LIST_ITEM_DESELECTED, self._deselectPlugin, self.pluginList)
59 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._togglePlugin, self.pluginList) 59 self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self._togglePlugin, self.pluginList)
60 self.Bind(wx.EVT_LIST_COL_CLICK, self._sort, self.pluginList) 60 self.Bind(wx.EVT_LIST_COL_CLICK, self._sort, self.pluginList)
61 self.main_sizer.Add(self.pluginList, 1, wx.EXPAND) 61 self.main_sizer.Add(self.pluginList, 1, wx.EXPAND)
164 164
165 #Events 165 #Events
166 def _selectPlugin(self, evt): 166 def _selectPlugin(self, evt):
167 self._selectedPlugin = evt.GetIndex() 167 self._selectedPlugin = evt.GetIndex()
168 self.__enablePluginBtns() 168 self.__enablePluginBtns()
169 pname = self.pluginList.GetItem(self._selectedPlugin, 1).GetText() 169 pname = self.pluginList.GetItem(self._selectedPlugin, 0).GetText()
170 info = self.available_plugins[pname] 170 info = self.available_plugins[pname]
171 171
172 if info[0] in self.enabled_plugins: 172 if info[0] in self.enabled_plugins:
173 self.enableBtn.Disable() 173 self.enableBtn.Disable()
174 else: 174 else:
175 self.disableBtn.Disable() 175 self.disableBtn.Disable()
176 if self.pluginList.GetItem(self._selectedPlugin, 0).GetText() == "X": 176 if pname in self.startplugs:
177 self.autostartBtn.Label = "Disable Autostart" 177 self.autostartBtn.Label = "Disable Autostart"
178 178
179 self.__doLayout() 179 self.__doLayout()
180 self.pluginList.SetItemState(self._selectedPlugin, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED) 180 self.pluginList.SetItemState(self._selectedPlugin, wx.LIST_STATE_SELECTED, wx.LIST_STATE_SELECTED)
181 181
183 self.__disablePluginBtns() 183 self.__disablePluginBtns()
184 self._selectedPlugin = None 184 self._selectedPlugin = None
185 185
186 def _togglePlugin(self, evt): 186 def _togglePlugin(self, evt):
187 idx = evt.GetIndex() 187 idx = evt.GetIndex()
188 pname = self.pluginList.GetItem(idx, 0).GetText() 188 pname = self.pluginList.GetItem(idx, 1).GetText()
189 info = self.available_plugins[pname] 189 info = self.available_plugins[pname]
190
191 if info[0] in self.enabled_plugins: 190 if info[0] in self.enabled_plugins:
192 self._disable(idx) 191 self._disable(idx)
193 else: 192 else:
194 self._enable(idx) 193 self._enable(idx)
195
196 self.pluginList.SetItemState(self._selectedPlugin, 0, wx.LIST_STATE_SELECTED) 194 self.pluginList.SetItemState(self._selectedPlugin, 0, wx.LIST_STATE_SELECTED)
197 195
198 def _enableAll(self, evt): 196 def _enableAll(self, evt):
199 for pname in self.available_plugins.iterkeys(): 197 for pname in self.available_plugins.iterkeys():
200 info = self.available_plugins[pname] 198 info = self.available_plugins[pname]
204 202
205 def _enable(self, evt): 203 def _enable(self, evt):
206 idx = self.__checkIdx(evt) 204 idx = self.__checkIdx(evt)
207 if idx is None: 205 if idx is None:
208 return 206 return
209 pname = self.pluginList.GetItem(idx, 1).GetText() 207 pname = self.pluginList.GetItem(idx, 0).GetText()
210 info = self.available_plugins[pname] 208 info = self.available_plugins[pname]
211 info[1].menu_start() 209 info[1].menu_start()
212 210
213 try: 211 try:
214 info[1].plugin_enabled() 212 info[1].plugin_enabled()
225 self.enableBtn.Disable() 223 self.enableBtn.Disable()
226 self.disableBtn.Enable() 224 self.disableBtn.Enable()
227 225
228 def _disableAll(self, evt): 226 def _disableAll(self, evt):
229 for entry in self.enabled_plugins.keys(): 227 for entry in self.enabled_plugins.keys():
230 #idx = self.pluginList.FindItem(1, self.enabled_plugins[entry].name) #Old Method 228 #print self.pluginList.FindItem(1, self.enabled_plugins[entry])
231 self._disable(self.enabled_plugins[entry]) #New Method 229 idx = self.pluginList.FindItem(0, self.enabled_plugins[entry].name)
230 print self.pluginList
231 self._disable(idx) #New Method
232 232
233 def _disable(self, evt): 233 def _disable(self, evt):
234 idx = self.__checkIdx(evt) 234 idx = self.__checkIdx(evt)
235 if idx is None: 235 if idx is None:
236 return 236 return
237 pname = self.pluginList.GetItem(idx, 1).GetText() 237 pname = self.pluginList.GetItem(idx, 0).GetText()
238 info = self.available_plugins[pname] 238 info = self.available_plugins[pname]
239 info[1].menu_cleanup() 239 info[1].menu_cleanup()
240 try: 240 try:
241 info[1].plugin_disabled() 241 info[1].plugin_disabled()
242 del self.enabled_plugins[info[0]] 242 del self.enabled_plugins[info[0]]
252 252
253 def _autostart(self, evt): 253 def _autostart(self, evt):
254 idx = self.__checkIdx(evt) 254 idx = self.__checkIdx(evt)
255 if idx is None: 255 if idx is None:
256 return 256 return
257 if self.pluginList.GetItem(idx, 1).GetText() in self.startplugs: 257 if self.pluginList.GetItem(idx, 0).GetText() in self.startplugs:
258 self.startplugs.remove(self.pluginList.GetItem(idx, 1).GetText()) 258 self.startplugs.remove(self.pluginList.GetItem(idx, 0).GetText())
259 self.pluginList.SetItemImage(idx, 0, 0) 259 self.pluginList.SetItemImage(idx, 0, 0)
260 self.autostartBtn.Label = "Autostart" 260 self.autostartBtn.Label = "Autostart"
261 else: 261 else:
262 self.startplugs.append(self.pluginList.GetItem(idx, 1).GetText()) 262 self.startplugs.append(self.pluginList.GetItem(idx, 0).GetText())
263 self.pluginList.SetItemImage(idx, 1, 0) 263 self.pluginList.SetItemImage(idx, 1, 0)
264 self.autostartBtn.Label = "Disable Autostart" 264 self.autostartBtn.Label = "Disable Autostart"
265 265
266 self.plugindb.SetList("plugincontroller", "startup_plugins", self.startplugs) 266 self.plugindb.SetList("plugincontroller", "startup_plugins", self.startplugs)
267 self.__doLayout() 267 self.__doLayout()
302 self.__impPlugin(p[:-4]) 302 self.__impPlugin(p[:-4])
303 303
304 i = 0 304 i = 0
305 for plugname, info in self.available_plugins.iteritems(): 305 for plugname, info in self.available_plugins.iteritems():
306 self.pluginNames.append(plugname) 306 self.pluginNames.append(plugname)
307 idx = self.pluginList.InsertImageItem(self.pluginList.GetItemCount(), 0) 307 #idx = self.pluginList.InsertImageItem(self.pluginList.GetItemCount(), 0)
308 self.pluginList.SetStringItem(idx, 2, info[2]) 308 idx = self.pluginList.InsertStringItem(self.pluginList.GetItemCount(), plugname)
309 self.pluginList.SetStringItem(idx, 1, plugname) 309 self.pluginList.SetStringItem(idx, 1, info[2])
310 self.pluginList.SetItemImage(idx, 0, 0)
311 #self.pluginList.SetStringItem(idx, 1, plugname)
310 if plugname in self.startplugs: 312 if plugname in self.startplugs:
311 self.pluginList.SetItemImage(idx, 1, 0) 313 self.pluginList.SetItemImage(idx, 1, 0)
312 self._enable(idx) 314 self._enable(idx)
313 self.pluginList.SetItemData(idx, i) 315 self.pluginList.SetItemData(idx, i)
314 i += 1 316 i += 1
315 self.pluginList.SetColumnWidth(0, 75) 317 self.pluginList.SetColumnWidth(0, wx.LIST_AUTOSIZE)
316 self.pluginList.SetColumnWidth(1, wx.LIST_AUTOSIZE) 318 self.pluginList.SetColumnWidth(1, wx.LIST_AUTOSIZE)
317 self.pluginList.SetColumnWidth(2, wx.LIST_AUTOSIZE) 319 self.pluginList.SetColumnWidth(2, wx.LIST_AUTOSIZE)
318 self.__doLayout() 320 self.__doLayout()
319 self.__disablePluginBtns() 321 self.__disablePluginBtns()
320 322