comparison plugins/xxsimpleinit.py @ 18:97265586402b ornery-orc

Traipse 'OpenRPG' {090827-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: Update Manager is now in version 0.8. While not every button works, users can now browse the different revisions and their different changesets. The code has been refined some with feature from Core added to it. A Crash report is now created if the users software crashes. Update Manager has been moved to the Traipse Suite menu item, and a Debug Console as been added as well.
author sirebral
date Thu, 27 Aug 2009 01:04:43 -0500
parents 4385a7d0efd1
children fc48380f0c9f
comparison
equal deleted inserted replaced
17:265b987cce4f 18:97265586402b
8 # 8 #
9 # !self : instance of self 9 # !self : instance of self
10 # !openrpg : instance of the the base openrpg control 10 # !openrpg : instance of the the base openrpg control
11 def __init__(self, plugindb, parent): 11 def __init__(self, plugindb, parent):
12 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent) 12 orpg.pluginhandler.PluginHandler.__init__(self, plugindb, parent)
13 self.orpgframe = open_rpg.get_component('frame') 13 self.orpgframe = component.get('frame')
14 14
15 # The Following code should be edited to contain the proper information 15 # The Following code should be edited to contain the proper information
16 self.name = 'Simple Init' 16 self.name = 'Simple Init'
17 self.author = 'Dj Gilcrease' 17 self.author = 'Dj Gilcrease + Tyler Starke'
18 self.help = 'This is a simplistic Init tool that does not relie on Chat message parsing' 18 self.help = 'This is a simplistic Init tool that does not rely on Chat message parsing'
19 19
20 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled 20 #You can set variables below here. Always set them to a blank value in this section. Use plugin_enabled
21 #to set their proper values. 21 #to set their proper values.
22 22
23 def plugin_menu(self): 23 def plugin_menu(self):
43 self.frame.Bind(wx.EVT_TIMER, self.advanceInit, self.advanceTimer) 43 self.frame.Bind(wx.EVT_TIMER, self.advanceInit, self.advanceTimer)
44 self.buttonTimer = wx.Timer(self.frame, wx.NewId()) 44 self.buttonTimer = wx.Timer(self.frame, wx.NewId())
45 self.frame.Bind(wx.EVT_TIMER, self.buttonCheck, self.buttonTimer) 45 self.frame.Bind(wx.EVT_TIMER, self.buttonCheck, self.buttonTimer)
46 self.buttonTimer.Start(250) 46 self.buttonTimer.Start(250)
47 self.autoAdvancePaused = False 47 self.autoAdvancePaused = False
48 #self.PluginMenu()
49 48
50 def plugin_disabled(self): 49 def plugin_disabled(self):
51 self.plugin_removecmd('/inittoggle') 50 self.plugin_removecmd('/inittoggle')
52 self.plugin_removecmd('/rollinit') 51 self.plugin_removecmd('/rollinit')
53 self.plugin_removecmd('/startcombat') 52 self.plugin_removecmd('/startcombat')
59 del self.advanceTimer 58 del self.advanceTimer
60 59
61 self.buttonTimer.Stop() 60 self.buttonTimer.Stop()
62 del self.buttonTimer 61 del self.buttonTimer
63 62
64 try: 63 try: self.frame.Destroy()
65 self.frame.Destroy() 64 except: pass
66 except:
67 pass
68 65
69 def on_init(self, cmdargs): 66 def on_init(self, cmdargs):
70 if self.frame.IsShown(): 67 if self.frame.IsShown():
71 self.toggle.Check(False) 68 self.toggle.Check(False)
72 self.frame.Hide() 69 self.frame.Hide()
73 else: 70 else:
74 self.toggle.Check(True) 71 self.toggle.Check(True)
75 self.frame.Show() 72 self.frame.Show()
76 print self.toggle.IsChecked()
77 73
78 def startInit(self, evt=None): 74 def startInit(self, evt=None):
79 if self.frame.initList.GetItemCount() == 0: 75 if self.frame.initList.GetItemCount() == 0:
80 self.chat.InfoPost('You need to add some stuff to the Init list before you start') 76 self.chat.InfoPost('You need to add some stuff to the Init list before you start')
81 return 77 return
101 self.frame.clearButton.Disable() 97 self.frame.clearButton.Disable()
102 98
103 self.frame.currentInit = -1 99 self.frame.currentInit = -1
104 self.round = 0 100 self.round = 0
105 101
106 self.chat.Post('<font color="#00ff00" size="4"><b>============ START COMBAT ============</b></font>', True, True) 102 self.chat.Post('<center><font color="#00ff00"><b>== START COMBAT ==</b></font></center>', True, True, c='simpleinit-combat')
107 self.advanceInit() 103 self.advanceInit()
108 self.frame.Thaw() 104 self.frame.Thaw()
109 105
110 if self.frame.autoAdvanceCheck.IsChecked(): 106 if self.frame.autoAdvanceCheck.IsChecked():
111 time = int(60000*int(self.frame.autoAdvanceList.GetStringSelection())) 107 time = int(60000*int(self.frame.autoAdvanceList.GetStringSelection()))
150 if self.autoAdvancePaused and self.frame.autoAdvanceCheck.IsChecked(): 146 if self.autoAdvancePaused and self.frame.autoAdvanceCheck.IsChecked():
151 self.pauseInit('No Adv') 147 self.pauseInit('No Adv')
152 self.frame.Thaw() 148 self.frame.Thaw()
153 149
154 self.advanceTimer.Stop() 150 self.advanceTimer.Stop()
155 self.chat.Post('<font color="#ff0000" size="4"><b>============ END COMBAT ============</b></font>', True, True) 151 self.chat.Post('<center><font color="#ff0000" ><b>== END COMBAT ==</b></font></center>', True, True, c='simpleinit-combat')
156 152
157 def advanceInit(self, evt=None): 153 def advanceInit(self, evt=None):
158 if not self.frame.nextButton.IsEnabled(): 154 if not self.frame.nextButton.IsEnabled():
159 self.chat.InfoPost('You must first Start combat inorder to advance the initiative turn!') 155 self.chat.InfoPost('You must first Start combat inorder to advance the initiative turn!')
160 return 156 return
161 157
162 self.frame.currentInit = self.frame.initIdx+1 158 self.frame.currentInit = self.frame.initIdx+1
163 if self.frame.currentInit.type == 'Effect': 159 if self.frame.currentInit.type == 'Effect':
164 newDur = str(int(self.frame.currentInit.duration)-1) 160 newDur = str(int(self.frame.currentInit.duration)-1)
165 self.frame.initList.SetStringItem(self.frame.initIdx, 2, newDur) 161 self.frame.initList.SetStringItem(self.frame.initIdx, 2, newDur)
166 msg = '<br><table width="100%" border="1"><tr><td align="center"><center><u><b><font color="#ff0000" size="4">EFFECT NOTICE</font></b></u></center></td></tr>' 162 msg = '<br><table width="100%" border="1"><tr><td align="center"><center><u><b><font color="#ff0000" >EFFECT NOTICE</font></b></u></center></td></tr>'
167 msg += '<tr><td align="center"><font color="#000000">' + self.frame.currentInit.name + ' has ' + newDur + ' rounds remaining</font></td></tr></table>' 163 msg += '<tr><td align="center"><font color="#000000">' + self.frame.currentInit.name + ' has ' + newDur + ' rounds remaining</font></td></tr></table><br />'
168 self.chat.Post(msg, True, True) 164 self.chat.Post(msg, True, True, c='simpleinit-effect')
169 wx.CallAfter(self.advanceInit) 165 wx.CallAfter(self.advanceInit)
170 else: 166 else:
171 msg = '<br><table width="100%" border="1"><tr><td align="center"><center><u><font color="#ff0000" size="4"><b>' + self.frame.nextMessage.GetValue() + '</b></font></u></center></td></tr>' 167 msg = '<table width="100%" border="1"><tr><td align="center"><u><font color="#ff0000" ><b>' + self.frame.nextMessage.GetValue() + '</b></font></u></td></tr>'
172 msg += '<tr><td align="center"><b><font size="3"><font color="#ff0000">' + str(self.frame.initIdx+1) + ':</font> ' 168 msg += '<tr><td align="center"><b><font color="#ff0000">' + str(self.frame.initIdx+1) + ':</font> '
173 msg += '<font color="#0000ff">(' + self.frame.currentInit.init + ')</font> ' 169 msg += '<font color="#0000ff">(' + self.frame.currentInit.init + ')</font> '
174 msg += '<font color="#000000">' + self.frame.currentInit.name + '</b></font></font></td></tr></table>' 170 msg += '<font color="#000000">' + self.frame.currentInit.name + '</b></font></td></tr></table><br />'
175 self.chat.Post(msg, True, True) 171 self.chat.Post(msg, True, True, c='simpleinit-pc')
176 172
177 if self.frame.currentInit.type == 'Effect' and int(self.frame.currentInit.duration) <= 0: 173 if self.frame.currentInit.type == 'Effect' and int(self.frame.currentInit.duration) <= 0:
178 self.frame.Freeze() 174 self.frame.Freeze()
179 cidx = self.frame.initIdx 175 cidx = self.frame.initIdx
180 self.frame.initList.DeleteItem(cidx) 176 self.frame.initList.DeleteItem(cidx)
203 self.advanceTimer.Start() 199 self.advanceTimer.Start()
204 self.frame.Thaw() 200 self.frame.Thaw()
205 201
206 def newRound(self): 202 def newRound(self):
207 self.round += 1 203 self.round += 1
208 msg = '<br><hr><font color="#ff0000" size="4"><b>End of Round #' + str(self.round-1) + ', Starting Round #' + str(self.round) + '</b></font><hr>' 204 msg = '<br><hr><font color="#ff0000" ><b>End of Round #' + str(self.round-1) + ', Starting Round #' + str(self.round) + '</b></font><hr>'
209 self.chat.Post(msg, True, True) 205 self.chat.Post(msg, True, True)
210 206
211 def rollD20Init(self): 207 def rollD20Init(self):
212 if not self.frame.rollButton.IsEnabled(): 208 if not self.frame.rollButton.IsEnabled():
213 self.chat.InfoPost("You cannot roll new Inits at this time") 209 self.chat.InfoPost("You cannot roll new Inits at this time")
214 return 210 return
215 self.orpgframe.Freeze() 211 self.orpgframe.Freeze()
216 self.frame.Freeze() 212 self.frame.Freeze()
217 msg = '<br><font color="#0000ff" size="4"><b>============ START INIT LIST ============</b></font><br>' 213 msg = '<br><center><font color="#0000ff" ><b>== START INIT LIST ==</b></font></center><br>'
218 msg += '<font color="#000000"><b>' 214 msg += '<font color="#000000"><b>'
219 for i in xrange(0, self.frame.initList.GetItemCount()): 215 for i in xrange(0, self.frame.initList.GetItemCount()):
220 self.frame.currentInit = i 216 self.frame.currentInit = i
221 if self.frame.currentInit.manual == 'No': 217 if self.frame.currentInit.manual == 'No':
222 initRoll = self.chat.ParseDice('[1d20' + self.frame.currentInit.initMod + ']') 218 initRoll = self.chat.ParseDice('[1d20' + self.frame.currentInit.initMod + ']')
232 msg += '<br>' + self.frame.currentInit.name + ' = <font color="#ff0000">' + initRoll + '</font>' 228 msg += '<br>' + self.frame.currentInit.name + ' = <font color="#ff0000">' + initRoll + '</font>'
233 229
234 msg += '</b></font><br>' 230 msg += '</b></font><br>'
235 231
236 self.frame.initList.SortItems(self.frame.initSort) 232 self.frame.initList.SortItems(self.frame.initSort)
237 msg += '<font color="#0000ff" size="4"><b>============ END INIT LIST ============</b></font>' 233 msg += '<center><font color="#0000ff" ><b>== END INIT LIST ==</b></center></font>'
238 self.chat.Post(msg, True, True) 234 self.chat.Post(msg, True, True, c='simpleinit-lst')
239 235
240 self.frame.Thaw() 236 self.frame.Thaw()
241 if self.frame.IsShown(): 237 if self.frame.IsShown():
242 wx.CallAfter(self.frame.SetFocus) 238 wx.CallAfter(self.frame.SetFocus)
243 wx.CallAfter(self.orpgframe.Thaw) 239 wx.CallAfter(self.orpgframe.Thaw)
246 def rollInit(self, evt): 242 def rollInit(self, evt):
247 if self.frame.initRollType.GetStringSelection() == 'd20': 243 if self.frame.initRollType.GetStringSelection() == 'd20':
248 self.rollD20Init() 244 self.rollD20Init()
249 245
250 def buttonCheck(self, evt): 246 def buttonCheck(self, evt):
251 if self.autoAdvancePaused:
252 return
253 if self.frame.initList.GetItemCount() == 0: 247 if self.frame.initList.GetItemCount() == 0:
254 self.frame.Freeze() 248 self.frame.Freeze()
255 self.advanceTimer.Stop() 249 self.advanceTimer.Stop()
256 self.frame.startButton.Disable() 250 self.frame.startButton.Disable()
257 self.frame.rollButton.Disable() 251 self.frame.rollButton.Disable()
267 self.frame.rollButton.Enable() 261 self.frame.rollButton.Enable()
268 self.frame.editButton.Enable() 262 self.frame.editButton.Enable()
269 self.frame.deleteButton.Enable() 263 self.frame.deleteButton.Enable()
270 self.frame.saveButton.Enable() 264 self.frame.saveButton.Enable()
271 self.frame.clearButton.Enable() 265 self.frame.clearButton.Enable()
266 if self.autoAdvancePaused:
267 return
272 268
273 if not self.frame.autoAdvanceCheck.IsChecked(): 269 if not self.frame.autoAdvanceCheck.IsChecked():
274 self.frame.autoAdvanceToggle.Disable() 270 self.frame.autoAdvanceToggle.Disable()
275 self.autoAdvancePaused = True 271 self.autoAdvancePaused = True
276 elif self.frame.autoAdvanceCheck.IsChecked() and self.frame.stopButton.IsEnabled(): 272 elif self.frame.autoAdvanceCheck.IsChecked() and self.frame.stopButton.IsEnabled():
278 274
279 class InitFrame(wx.Frame): 275 class InitFrame(wx.Frame):
280 def __init__(self, plugin): 276 def __init__(self, plugin):
281 self.plugin = plugin 277 self.plugin = plugin
282 self.toggle = plugin.toggle 278 self.toggle = plugin.toggle
283 self.log = open_rpg.get_component('log') 279 self.log = component.get('log')
284 self.log.log("Enter InitFrame", ORPG_DEBUG) 280 self.log.log("Enter InitFrame", ORPG_DEBUG)
285 281
286 wx.Frame.__init__(self, None, wx.ID_ANY, title="Simple Init", style=wx.DEFAULT_FRAME_STYLE) 282 wx.Frame.__init__(self, None, wx.ID_ANY, title="Simple Init", style=wx.DEFAULT_FRAME_STYLE)
287 self.SetOwnBackgroundColour('#EFEFEF') 283 self.SetOwnBackgroundColour('#EFEFEF')
288 284
289 self.dir_struct = open_rpg.get_component('dir_struct') 285 self.dir_struct = component.get('dir_struct')
290 self.settings = open_rpg.get_component('settings') 286 self.settings = component.get('settings')
291 self.xml = open_rpg.get_component('xml') 287 self.xml = component.get('xml')
292 self.validate = open_rpg.get_component('validate') 288 self.validate = component.get('validate')
293 289
294 self.Freeze() 290 self.Freeze()
295 self.buildMenu() 291 self.buildMenu()
296 self.buildButtons() 292 self.buildButtons()
297 self.buildGUI() 293 self.buildGUI()
300 self.Bind(wx.EVT_CLOSE, self.onCloseWindow) 296 self.Bind(wx.EVT_CLOSE, self.onCloseWindow)
301 297
302 self.log.log("Exit InitFrame", ORPG_DEBUG) 298 self.log.log("Exit InitFrame", ORPG_DEBUG)
303 299
304 def InitSetup(self): 300 def InitSetup(self):
305 self.chat = open_rpg.get_component('chat') 301 self.chat = component.get('chat')
306 self.gametree = open_rpg.get_component('tree') 302 self.gametree = component.get('tree')
307 self.map = open_rpg.get_component('map') 303 self.map = component.get('map')
308 self.session = open_rpg.get_component('session') 304 self.session = component.get('session')
309 305
310 self.initIdx = -1 306 self.initIdx = -1
311 self.Thaw() 307 self.Thaw()
312 308
313 def initSort(self, item1, item2): 309 def initSort(self, item1, item2):