Fac acest topic pentru că am observat că foarte mulți dintre voi nu știti să vă faceți niște funcții!
Astăzi o să vă arăt cu să vă puneți switchbot cu buton pe inventar!
Să începem:
Intrăm în root/uiinventory.py şi Căutăm :
Cod: Selectaţi tot
self.costumeButton = self.GetChild2("CostumeButton")Şi sub adăugăm :
Cod: Selectaţi tot
self.Titan = self.GetChild2("Titan_py")Căutăm tot în uiinventory.py :
Cod: Selectaţi tot
# Costume Button
if self.costumeButton:
self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))Şi sub adăugăm :
Cod: Selectaţi tot
#Switchbot
if self.Titan_py:
self.Titan_py.SetEvent(ui.__mem_func__(self.ClickTitan_py))Tot în uiinventory.py căutăm :
Cod: Selectaţi tot
def ClickCostumeButton(self):
print "Click Costume Button"
if self.wndCostume:
if self.wndCostume.IsShow():
self.wndCostume.Hide()
else:
self.wndCostume.Show()
else:
self.wndCostume = CostumeWindow(self)
self.wndCostume.Show()Şi sub adăugăm :
Cod: Selectaţi tot
def ClickTitan_py(self):
import uiswitchbot
uiswitchbot.Bot().Show()Cod: Selectaţi tot
def SetText(self, text, height = 4):
if not self.ButtonText:
textLine = TextLine()
textLine.SetParent(self)
textLine.SetPosition(self.GetWidth()/2, self.GetHeight()/2)
textLine.SetVerticalAlignCenter()
textLine.SetHorizontalAlignCenter()
textLine.Show()
self.ButtonText = textLine
self.ButtonText.SetText(text)Cod: Selectaţi tot
def GetText(self):
if not self.ButtonText:
return# ""
return self.ButtonText.GetText()Deschideţi locale/xx/ui/inventorywindow.py şi cautaţi :
Cod: Selectaţi tot
## MallButton
{
"name" : "MallButton",
"type" : "button",
"x" : 118,
"y" : 154,
"tooltip_text" : uiScriptLocale.MALL_TITLE,
"default_image" : "d:/ymir work/ui/game/TaskBar/Mall_Button_01.tga",
"over_image" : "d:/ymir work/ui/game/TaskBar/Mall_Button_02.tga",
"down_image" : "d:/ymir work/ui/game/TaskBar/Mall_Button_03.tga",
},Cod: Selectaţi tot
## Switchbot
{
"name" : "Titan_py",
"type" : "button",
"x" : 5, ##aici modifici tu pozitia butonului
"y" : 20, ##la fel ca mai sus
"tooltip_text" : "Schimba bonusurile",
"default_image" : "d:/t_work/3.tga",
"over_image" : "d:/t_work/4.tga",
"down_image" : "d:/t_work/4.tga",
},Dacă v-am ajutat, un thx nu strică!
Spor la implementat și mare grijă la tab-uri!








