This is a horse gui:
the class in uiaffectShower.* (root..):
Code:
class HorseImage(ui.ExpandedImageBox):
FILE_PATH = "d:/ymir work/ui/pattern/HorseState/"
PORCIENTO_BARRA = {
00 : 0,
01 : 0,
02 : 0,
03 : 0,
10 : 10,
11 : 15,
12 : 20,
13 : 30,
20 : 35,
21 : 40,
22 : 45,
23 : 50,
30 : 55,
31 : 60,
32 : 70,
33 : 100,
}
BARRA_BARRA = {
00 : "negrogauge",
01 : "negrogauge",
02 : "negrogauge",
03 : "negrogauge",
10 : "rojogauge",
11 : "rojogauge",
12 : "rojogauge",
13 : "rojogauge",
20 : "amarillogauge",
21 : "amarillogauge",
22 : "amarillogauge",
23 : "amarillogauge",
30 : "greengauge",
31 : "greengauge",
32 : "greengauge",
33 : "greengauge",
}
FILE_DICT = {
00 : FILE_PATH+"00.dds",
01 : FILE_PATH+"00.dds",
02 : FILE_PATH+"00.dds",
03 : FILE_PATH+"00.dds",
10 : FILE_PATH+"10.dds",
11 : FILE_PATH+"11.dds",
12 : FILE_PATH+"12.dds",
13 : FILE_PATH+"13.dds",
20 : FILE_PATH+"20.dds",
21 : FILE_PATH+"21.dds",
22 : FILE_PATH+"22.dds",
23 : FILE_PATH+"23.dds",
30 : FILE_PATH+"30.dds",
31 : FILE_PATH+"31.dds",
32 : FILE_PATH+"32.dds",
33 : FILE_PATH+"33.dds",
}
def __init__(self):
ui.ExpandedImageBox.__init__(self)
#self.textLineList = []
self.toolTip = uiToolTip.ToolTip(100)
self.toolTip.HideToolTip()
self.CB= ui.ImageBox()
self.CB.LoadImage("d:/global/horse/viewer.dds")
self.CB.SetPosition(255, 5)
self.CB.Show()
self.CB.AddFlag("movable")
self.CB.AddFlag("attach")
self.CAB= ui.ImageBox()
self.CAB.SetParent(self.CB)
self.CAB.SetPosition(16, 17)
self.CAB.Show()
self.Gauge3 = ui.AniImageBox()
self.Gauge3.SetDelay(5)
self.Gauge3.Show()
self.Gauge3.SetParent(self.CAB)
self.Gauge3.SetPercentage(100, 100)
self.NivelC = ui.TextLine()
self.NivelC.SetFeather()
self.NivelC.SetOutline()
self.NivelC.SetPackedFontColor(0xffFFFBF6)
self.NivelC.Show()
self.NivelC.SetParent(self.CB)
self.NivelC.SetPosition(22, 2)
self.Hambre = ui.TextLine()
self.Hambre.SetFeather()
self.Hambre.SetOutline()
self.Hambre.SetPackedFontColor(0xffFFFBF6)
self.Hambre.Show()
self.Hambre.SetParent(self.CB)
self.Hambre.SetPosition(60, 26)
self.Descansar = ui.TextLine()
self.Descansar.SetFeather()
self.Descansar.SetOutline()
self.Descansar.SetPackedFontColor(0xffFF8C00)
self.Descansar.Show()
self.Descansar.SetParent(self.CB)
self.Descansar.SetPosition(60, 36)
def __GetHorseGrade(self, level):
if 0 == level:
return 0
return (level-1)/10 + 1
def SetState(self, level, health, battery):
#self.textLineList=[]
self.toolTip.ClearToolTip()
if level>0:
try:
grade = self.__GetHorseGrade(level)
self.__AppendText(locale.LEVEL_LIST[grade])
self.NivelC.SetText(locale.LEVEL_LIST[grade])
LEVEL_IMAGE=["", "d:/global/horse/horse_1.dds", "d:/global/horse/horse_2.dds", "d:/global/horse/horse_3.dds"]
self.CAB.LoadImage(LEVEL_IMAGE[grade])
except IndexError:
print "HorseImage.SetState(level=%d, health=%d, battery=%d) - Unknown Index" % (level, health, battery)
return
try:
healthName=locale.HEALTH_LIST[health]
if len(healthName)>0:
self.__AppendText(healthName)
self.Hambre.SetText(healthName)
except IndexError:
print "HorseImage.SetState(level=%d, health=%d, battery=%d) - Unknown Index" % (level, health, battery)
return
if health>0:
if battery==0:
self.__AppendText(locale.NEEFD_REST)
self.Descansar.SetText("Cansado")
try:
fileName=self.FILE_DICT[health*10+battery]
pogresoactual=self.PORCIENTO_BARRA[health*10+battery]
BarraActual=self.BARRA_BARRA[health*10+battery]
except KeyError:
print "HorseImage.SetState(level=%d, health=%d, battery=%d) - KeyError" % (level, health, battery)
try:
for x in range(int(1),int(7)):
self.Gauge3.AppendImage("d:/global/"+BarraActual+"/0"+str(x)+".tga")
self.Gauge3.SetPosition(44, 3)
self.Gauge3.SetPercentage(pogresoactual, 100)
except:
print "HorseImage.SetState(level=%d, health=%d, battery=%d) - LoadError %s" % (level, health, battery, fileName, pogresoactual)
self.SetScale(0.7, 0.7)
def __AppendText(self, text):
self.toolTip.AppendTextLine(text)
self.toolTip.ResizeToolTip()
#x=self.GetWidth()/2
#textLine = ui.TextLine()
#textLine.SetParent(self)
#textLine.SetSize(0, 0)
#textLine.SetOutline()
#textLine.Hide()
#textLine.SetPosition(x, 40+len(self.textLineList)*16)
#textLine.SetText(text)
#self.textLineList.append(textLine)
def OnMouseOverIn(self):
#for textLine in self.textLineList:
# textLine.Show()
self.toolTip.ShowToolTip()
def OnMouseOverOut(self):
#for textLine in self.textLineList:
# textLine.Hide()
self.toolTip.HideToolTip()
Or in attachment exist one py
and the files
Screen cap:
I fyou have any error, reply this post :P







