comparison plugins/xxsimpleinit.py @ 63:c160f26ecf65 ornery-dev

Traipse Dev 'OpenRPG' {090817-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: Minor fixes to plugins. Hidden Die Roll no longer prints out data to the terminal. Bug fix in Simple Init; if the Auto Advance check was off and members were added, buttons would remain disabled. Added new CSS classes to Simple Init posts. Fix to Chat Log so log parses CSS classes correctly. Added Text Color button from Core; background color defaults to your settings. Fix to Alias Lib so panes have a minimum size.
author sirebral
date Mon, 17 Aug 2009 00:56:02 -0500
parents 4385a7d0efd1
children c54768cffbd4
comparison
equal deleted inserted replaced
62:e8029caed892 63:c160f26ecf65
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 = open_rpg.get_component('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():