comparison orpg/tools/toolBars.py @ 23:551cd440acce traipse_dev

Final Dev build of the Day. Should reduce RAM usage more.
author sirebral
date Sat, 25 Jul 2009 21:05:18 -0500
parents 4385a7d0efd1
children c54768cffbd4
comparison
equal deleted inserted replaced
22:88cea66228d6 23:551cd440acce
78 data = "" 78 data = ""
79 mode = 1 79 mode = 1
80 if id == TB_MAP_MODE: 80 if id == TB_MAP_MODE:
81 mode = 1 81 mode = 1
82 self.mapmode +=1 82 self.mapmode +=1
83 if self.mapmode >3: 83 if self.mapmode >3: self.mapmode = 1
84 self.mapmode = 1
85 bm = wx.Image(self.modeicons[self.mapmode-1],wx.BITMAP_TYPE_GIF).ConvertToBitmap() 84 bm = wx.Image(self.modeicons[self.mapmode-1],wx.BITMAP_TYPE_GIF).ConvertToBitmap()
86 self.butt= wx.BitmapButton(self,TB_MAP_MODE,bm) 85 self.butt= wx.BitmapButton(self,TB_MAP_MODE,bm)
87 data = self.mapmode 86 data = self.mapmode
88 if self.callback != None: 87 if self.callback != None: self.callback(mode,data)
89 self.callback(mode,data)
90 88
91 class DiceToolBar(wx.Panel): 89 class DiceToolBar(wx.Panel):
92 """This is where all of the dice related tools belong for quick reference.""" 90 """This is where all of the dice related tools belong for quick reference."""
93 def __init__( self, parent, id=-1, title="Dice Tool Bar", size=wx.Size(300, 45), callBack=None ): 91 def __init__( self, parent, id=-1, title="Dice Tool Bar", size=wx.Size(300, 45), callBack=None ):
94 wx.Panel.__init__(self, parent, id, size=size) 92 wx.Panel.__init__(self, parent, id, size=size)
140 def onToolBarClick( self, evt ): 138 def onToolBarClick( self, evt ):
141 # Get our modifiers 139 # Get our modifiers
142 numDie = self.numDieText.GetValue() 140 numDie = self.numDieText.GetValue()
143 dieMod = self.dieModText.GetValue() 141 dieMod = self.dieModText.GetValue()
144 # Init the die roll text 142 # Init the die roll text
145 if not len(numDie): 143 if not len(numDie): numDie = 1
146 numDie = 1
147 dieRoll = str(numDie) 144 dieRoll = str(numDie)
148 # Figure out which die roll was selected 145 # Figure out which die roll was selected
149 id = evt.GetId() 146 id = evt.GetId()
150 recycle_bin = {TB_IDC_D4: "d4", TB_IDC_D6: "d6", TB_IDC_D8: "d8", TB_IDC_D10: "d10", TB_IDC_D12: "d12", TB_IDC_D20: "d20", TB_IDC_D100: "d100"} 147 recycle_bin = {TB_IDC_D4: "d4", TB_IDC_D6: "d6", TB_IDC_D8: "d8", TB_IDC_D10: "d10",
151 dieType = recycle_bin[id]; recycle_bin = {} 148 TB_IDC_D12: "d12", TB_IDC_D20: "d20", TB_IDC_D100: "d100"}
152 # To appease tdb...I personally disagree with this! 149 dieType = recycle_bin[id]; del recycle_bin
153 if len(dieMod) and dieMod[0] not in "*/-+": 150 if len(dieMod) and dieMod[0] not in "*/-+": dieMod = "+" + dieMod #Add Modifier
154 dieMod = "+" + dieMod 151 rollString = "[" + dieRoll + dieType + dieMod + "]" # Build the complete die roll text now
155 # Build the complete die roll text now 152 if self.callBack != None: self.callBack( rollString,1,1 ) # Now, call the post method to send everything off with
156 rollString = "[" + dieRoll + dieType + dieMod + "]"
157 # Now, call the post method to send everything off with
158 if self.callBack != None:
159 self.callBack( rollString,1,1 )