Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ui.py
- #before:
- class Board (Window)
- #add this:
- #Take note that for some weird reasons, there are plenty of spaces random in code, in floats and between self an the rest of the deffinitons, but I'm too lazy to correct it... All I've made here was indentation correction, so the code isn't mine.
- class DynamicGauge (Gauge):
- dynamicGaugePerc = None
- newGaugePerc = 0
- def __init__ ( self ):
- Gauge. __init__ ( self )
- def __del__ ( self ):
- Gauge. __del__ ( self )
- def MakeGauge ( self , width, color1, color2):
- Gauge.MakeGauge ( self , width, color2)
- imgGauge2 = ExpandedImageBox ()
- imgGauge2.SetParent ( self )
- imgGauge2.LoadImage ( "d: / ymir work / ui / pattern / gauge_" + color1 + ".tga" )
- imgGauge2.Show ()
- imgGauge2.SetRenderingRect ( 0.0 , 0.0 , 0.0 , 0.0 )
- imgGauge2.SetPosition ( self .GAUGE_TEMPORARY_PLACE, 0 )
- self .imgGauge2 = imgGauge2
- def SetPercentage ( self , curValue, maxValue):
- # PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
- if maxValue > 0.0:
- percentage = min ( 1.0, float(curValue) / float(maxValue))
- else :
- percentage = 0.0
- # END_OF_PERCENTAGE_MAX_VALUE_ZERO_DIVISION_ERROR
- gaugeSize = -1.0 + float(self.width - self.GAUGE_TEMPORARY_PLACE * 2) * percentage / self .GAUGE_WIDTH
- if self .dynamicGaugePerc = = None :
- self .imgGauge.SetRenderingRect ( 0 . 0 , 0 . 0 , ( - 1 . 0 + float ( self .width - self .GAUGE_TEMPORARY_PLACE * 2 ) * percentage / self .GAUGE_WIDTH), 0 . 0 )
- self .dynamicGaugePerc = percentage
- elif self .dynamicGaugePerc + 0 . 2 < self .newGaugePerc:
- self .imgGauge.SetRenderingRect ( 0 . 0 , 0 . 0 , ( - 1 . 0 + float ( self .width - self .GAUGE_TEMPORARY_PLACE * 2 ) * self .newGaugePerc / self .GAUGE_WIDTH), 0 . 0 )
- self .dynamicGaugePerc = self .newGaugePerc
- self .newGaugePerc = percentage
- self .imgGauge2.SetRenderingRect ( 0 . 0 , 0 . 0 , gaugeSize, 0 . 0 )
- if percentage = = 0 :
- self .imgGauge.Hide ()
- else :
- self .imgGauge.Show ()
- def OnUpdate ( self ):
- if self .dynamicGaugePerc > self .newGaugePerc:
- self .dynamicGaugePerc = self .dynamicGaugePerc - 0 . 005
- self .imgGauge.SetRenderingRect ( 0 . 0 , 0 . 0 , ( - 1 . 0 + float ( self .width - self .GAUGE_TEMPORARY_PLACE * 2 ) * self .dynamicGaugePerc / self .GAUGE_WIDTH), 0 . 0 )
- elif self .dynamicGaugePerc < self .newGaugePerc:
- self .dynamicGaugePerc = self .newGaugePerc
- self .imgGauge.SetRenderingRect ( 0 . 0 , 0 . 0 , ( - 1 . 0 + float ( self .width - self .GAUGE_TEMPORARY_PLACE * 2 ) * self .dynamicGaugePerc / self .GAUGE_WIDTH), 0 . 0 )
- # uitarget.py
- #search:
- hpGauge.MakeGauge ( 130 , "red" )
- #replace:
- hpGauge.MakeGauge ( 130 , "red" , "blue" )
- #search
- ui.Gauge
- #replace:
- ui.DynamicGauge
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement