Guest User

uipetsystem.py

a guest
Mar 25th, 2020
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 26.00 KB | None | 0 0
  1. import os
  2. import ui
  3. import player
  4. import mouseModule
  5. import net
  6. import app
  7. import snd
  8. import item
  9. import player
  10. import chat
  11. import grp
  12. import uiScriptLocale
  13. import localeInfo
  14. import constInfo
  15. import ime
  16. import wndMgr
  17. import petskill
  18. import uipetfeed
  19. import uipetsystem
  20. import uiToolTip
  21.  
  22.  
  23. AFFECT_DICT = {
  24.         item.APPLY_MAX_HP : localeInfo.TOOLTIP_MAX_HP,
  25.         item.APPLY_MAX_SP : localeInfo.TOOLTIP_MAX_SP,
  26.         item.APPLY_CON : localeInfo.TOOLTIP_CON,
  27.         item.APPLY_INT : localeInfo.TOOLTIP_INT,
  28.         item.APPLY_STR : localeInfo.TOOLTIP_STR,
  29.         item.APPLY_DEX : localeInfo.TOOLTIP_DEX,
  30.         item.APPLY_ATT_SPEED : localeInfo.TOOLTIP_ATT_SPEED,
  31.         item.APPLY_MOV_SPEED : localeInfo.TOOLTIP_MOV_SPEED,
  32.         item.APPLY_CAST_SPEED : localeInfo.TOOLTIP_CAST_SPEED,
  33.         item.APPLY_HP_REGEN : localeInfo.TOOLTIP_HP_REGEN,
  34.         item.APPLY_SP_REGEN : localeInfo.TOOLTIP_SP_REGEN,
  35.         item.APPLY_POISON_PCT : localeInfo.TOOLTIP_APPLY_POISON_PCT,
  36.         item.APPLY_STUN_PCT : localeInfo.TOOLTIP_APPLY_STUN_PCT,
  37.         item.APPLY_SLOW_PCT : localeInfo.TOOLTIP_APPLY_SLOW_PCT,
  38.         item.APPLY_CRITICAL_PCT : localeInfo.TOOLTIP_APPLY_CRITICAL_PCT,
  39.         item.APPLY_PENETRATE_PCT : localeInfo.TOOLTIP_APPLY_PENETRATE_PCT,
  40.  
  41.         item.APPLY_ATTBONUS_WARRIOR : localeInfo.TOOLTIP_APPLY_ATTBONUS_WARRIOR,
  42.         item.APPLY_ATTBONUS_ASSASSIN : localeInfo.TOOLTIP_APPLY_ATTBONUS_ASSASSIN,
  43.         item.APPLY_ATTBONUS_SURA : localeInfo.TOOLTIP_APPLY_ATTBONUS_SURA,
  44.         item.APPLY_ATTBONUS_SHAMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_SHAMAN,
  45.         item.APPLY_ATTBONUS_MONSTER : localeInfo.TOOLTIP_APPLY_ATTBONUS_MONSTER,
  46.  
  47.         item.APPLY_ATTBONUS_HUMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_HUMAN,
  48.         item.APPLY_ATTBONUS_ANIMAL : localeInfo.TOOLTIP_APPLY_ATTBONUS_ANIMAL,
  49.         item.APPLY_ATTBONUS_ORC : localeInfo.TOOLTIP_APPLY_ATTBONUS_ORC,
  50.         item.APPLY_ATTBONUS_MILGYO : localeInfo.TOOLTIP_APPLY_ATTBONUS_MILGYO,
  51.         item.APPLY_ATTBONUS_UNDEAD : localeInfo.TOOLTIP_APPLY_ATTBONUS_UNDEAD,
  52.         item.APPLY_ATTBONUS_DEVIL : localeInfo.TOOLTIP_APPLY_ATTBONUS_DEVIL,
  53.         item.APPLY_STEAL_HP : localeInfo.TOOLTIP_APPLY_STEAL_HP,
  54.         item.APPLY_STEAL_SP : localeInfo.TOOLTIP_APPLY_STEAL_SP,
  55.         item.APPLY_MANA_BURN_PCT : localeInfo.TOOLTIP_APPLY_MANA_BURN_PCT,
  56.         item.APPLY_DAMAGE_SP_RECOVER : localeInfo.TOOLTIP_APPLY_DAMAGE_SP_RECOVER,
  57.         item.APPLY_BLOCK : localeInfo.TOOLTIP_APPLY_BLOCK,
  58.         item.APPLY_DODGE : localeInfo.TOOLTIP_APPLY_DODGE,
  59.         item.APPLY_RESIST_SWORD : localeInfo.TOOLTIP_APPLY_RESIST_SWORD,
  60.         item.APPLY_RESIST_TWOHAND : localeInfo.TOOLTIP_APPLY_RESIST_TWOHAND,
  61.         item.APPLY_RESIST_DAGGER : localeInfo.TOOLTIP_APPLY_RESIST_DAGGER,
  62.         item.APPLY_RESIST_BELL : localeInfo.TOOLTIP_APPLY_RESIST_BELL,
  63.         item.APPLY_RESIST_FAN : localeInfo.TOOLTIP_APPLY_RESIST_FAN,
  64.         item.APPLY_RESIST_BOW : localeInfo.TOOLTIP_RESIST_BOW,
  65.         item.APPLY_RESIST_FIRE : localeInfo.TOOLTIP_RESIST_FIRE,
  66.         item.APPLY_RESIST_ELEC : localeInfo.TOOLTIP_RESIST_ELEC,
  67.         item.APPLY_RESIST_MAGIC : localeInfo.TOOLTIP_RESIST_MAGIC,
  68.         item.APPLY_RESIST_WIND : localeInfo.TOOLTIP_APPLY_RESIST_WIND,
  69.         item.APPLY_REFLECT_MELEE : localeInfo.TOOLTIP_APPLY_REFLECT_MELEE,
  70.         item.APPLY_REFLECT_CURSE : localeInfo.TOOLTIP_APPLY_REFLECT_CURSE,
  71.         item.APPLY_POISON_REDUCE : localeInfo.TOOLTIP_APPLY_POISON_REDUCE,
  72.         item.APPLY_KILL_SP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_SP_RECOVER,
  73.         item.APPLY_EXP_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_EXP_DOUBLE_BONUS,
  74.         item.APPLY_GOLD_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_GOLD_DOUBLE_BONUS,
  75.         item.APPLY_ITEM_DROP_BONUS : localeInfo.TOOLTIP_APPLY_ITEM_DROP_BONUS,
  76.         item.APPLY_POTION_BONUS : localeInfo.TOOLTIP_APPLY_POTION_BONUS,
  77.         item.APPLY_KILL_HP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_HP_RECOVER,
  78.         item.APPLY_IMMUNE_STUN : localeInfo.TOOLTIP_APPLY_IMMUNE_STUN,
  79.         item.APPLY_IMMUNE_SLOW : localeInfo.TOOLTIP_APPLY_IMMUNE_SLOW,
  80.         item.APPLY_IMMUNE_FALL : localeInfo.TOOLTIP_APPLY_IMMUNE_FALL,
  81.         item.APPLY_BOW_DISTANCE : localeInfo.TOOLTIP_BOW_DISTANCE,
  82.         item.APPLY_DEF_GRADE_BONUS : localeInfo.TOOLTIP_DEF_GRADE,
  83.         item.APPLY_ATT_GRADE_BONUS : localeInfo.TOOLTIP_ATT_GRADE,
  84.         item.APPLY_MAGIC_ATT_GRADE : localeInfo.TOOLTIP_MAGIC_ATT_GRADE,
  85.         item.APPLY_MAGIC_DEF_GRADE : localeInfo.TOOLTIP_MAGIC_DEF_GRADE,
  86.         item.APPLY_MAX_STAMINA : localeInfo.TOOLTIP_MAX_STAMINA,
  87.         item.APPLY_MALL_ATTBONUS : localeInfo.TOOLTIP_MALL_ATTBONUS,
  88.         item.APPLY_MALL_DEFBONUS : localeInfo.TOOLTIP_MALL_DEFBONUS,
  89.         item.APPLY_MALL_EXPBONUS : localeInfo.TOOLTIP_MALL_EXPBONUS,
  90.         item.APPLY_MALL_ITEMBONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS,
  91.         item.APPLY_MALL_GOLDBONUS : localeInfo.TOOLTIP_MALL_GOLDBONUS,
  92.         item.APPLY_SKILL_DAMAGE_BONUS : localeInfo.TOOLTIP_SKILL_DAMAGE_BONUS,
  93.         item.APPLY_NORMAL_HIT_DAMAGE_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DAMAGE_BONUS,
  94.         item.APPLY_SKILL_DEFEND_BONUS : localeInfo.TOOLTIP_SKILL_DEFEND_BONUS,
  95.         item.APPLY_NORMAL_HIT_DEFEND_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DEFEND_BONUS,
  96.         item.APPLY_PC_BANG_EXP_BONUS : localeInfo.TOOLTIP_MALL_EXPBONUS_P_STATIC,
  97.         item.APPLY_PC_BANG_DROP_BONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS_P_STATIC,
  98.         item.APPLY_RESIST_WARRIOR : localeInfo.TOOLTIP_APPLY_RESIST_WARRIOR,
  99.         item.APPLY_RESIST_ASSASSIN : localeInfo.TOOLTIP_APPLY_RESIST_ASSASSIN,
  100.         item.APPLY_RESIST_SURA : localeInfo.TOOLTIP_APPLY_RESIST_SURA,
  101.         item.APPLY_RESIST_SHAMAN : localeInfo.TOOLTIP_APPLY_RESIST_SHAMAN,
  102.         item.APPLY_MAX_HP_PCT : localeInfo.TOOLTIP_APPLY_MAX_HP_PCT,
  103.         item.APPLY_MAX_SP_PCT : localeInfo.TOOLTIP_APPLY_MAX_SP_PCT,
  104.         item.APPLY_ENERGY : localeInfo.TOOLTIP_ENERGY,
  105.         item.APPLY_COSTUME_ATTR_BONUS : localeInfo.TOOLTIP_COSTUME_ATTR_BONUS,
  106.        
  107.         item.APPLY_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MAGIC_ATTBONUS_PER,
  108.         item.APPLY_MELEE_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MELEE_MAGIC_ATTBONUS_PER,
  109.         item.APPLY_RESIST_ICE : localeInfo.TOOLTIP_RESIST_ICE,
  110.         item.APPLY_RESIST_EARTH : localeInfo.TOOLTIP_RESIST_EARTH,
  111.         item.APPLY_RESIST_DARK : localeInfo.TOOLTIP_RESIST_DARK,
  112.         item.APPLY_ANTI_CRITICAL_PCT : localeInfo.TOOLTIP_ANTI_CRITICAL_PCT,
  113.         item.APPLY_ANTI_PENETRATE_PCT : localeInfo.TOOLTIP_ANTI_PENETRATE_PCT,
  114.     }
  115.    
  116.    
  117. def checkdiv(n):
  118.     x = str(n/10.0)
  119.     if len(x) > 3:
  120.         return str(x)[0:3]
  121.     return str(x)
  122.  
  123. def pointop(n):
  124.     t = int(n)
  125.     if t / 10 < 1:
  126.         return "0."+n
  127.     else:      
  128.         return n[0:len(n)-1]+"."+n[len(n)-1:]
  129.        
  130.        
  131. def GetAffectString(affectType, affectValue):
  132.     if 0 == affectType:
  133.         return None
  134.  
  135.     if 0 == affectValue:
  136.         return None
  137.  
  138.     try:
  139.         return AFFECT_DICT[affectType](affectValue)
  140.     except TypeError:
  141.         return "UNKNOWN_VALUE[%s] %s" % (affectType, affectValue)
  142.     except KeyError:
  143.         return "UNKNOWN_TYPE[%s] %s" % (affectType, affectValue)
  144.        
  145. class PetSystemMain(ui.ScriptWindow):
  146.     class TextToolTip(ui.Window):
  147.         def __init__(self, y):
  148.             ui.Window.__init__(self, "TOP_MOST")
  149.  
  150.             textLine = ui.TextLine()
  151.             textLine.SetParent(self)
  152.             textLine.SetHorizontalAlignLeft()
  153.             textLine.SetOutline()
  154.             textLine.Show()
  155.             self.y = y
  156.             self.textLine = textLine
  157.  
  158.         def __del__(self):
  159.             ui.Window.__del__(self)
  160.  
  161.         def SetText(self, text):
  162.             self.textLine.SetText(text)
  163.  
  164.         def OnRender(self):
  165.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  166.             self.textLine.SetPosition(mouseX, mouseY - 60 + self.y)
  167.  
  168.     def __init__(self, vnum = 0):
  169.         ui.ScriptWindow.__init__(self)
  170.         self.vnum = vnum
  171.         self.__LoadWindow()
  172.        
  173.  
  174.     def __del__(self):
  175.         ui.ScriptWindow.__del__(self)
  176.  
  177.     def Show(self):
  178.         ui.ScriptWindow.Show(self)
  179.  
  180.     def Close(self):
  181.         self.Hide()
  182.         for i in range(0,4):    
  183.             self.tooltipexp[i].Hide()  
  184.            
  185.         self.feedwind.Close()
  186.         constInfo.PETGUI = 0
  187.  
  188.     def OnPressEscapeKey(self):
  189.         self.Close()
  190.         return TRUE
  191.  
  192.     def __LoadWindow(self):
  193.         try:
  194.             pyScrLoader = ui.PythonScriptLoader()
  195.             pyScrLoader.LoadScriptFile(self, "uiscript/PetInformationWindow.py")
  196.         except:
  197.             import exception
  198.             exception.Abort("PetInformationWindow.LoadWindow.LoadObject")
  199.            
  200.         try:
  201.             self.feedwind = uipetfeed.PetFeedWindow()
  202.             self.board = self.GetChild("board")
  203.             self.boardclose = self.GetChild("CloseButton")
  204.            
  205.             self.slotimgpet = self.GetChild("UpBringing_Pet_Slot")
  206.             self.evolname = self.GetChild("EvolName")
  207.             self.petname = self.GetChild("PetName")
  208.            
  209.             self.expwind = self.GetChild("UpBringing_Pet_EXP_Gauge_Board")
  210.             self.tooltipexp = []
  211.             for i in range(0,4):
  212.                 self.tooltipexp.append(self.TextToolTip(15*i))
  213.                 self.tooltipexp[i].Hide()
  214.            
  215.             self.petlifeg = self.GetChild("LifeGauge")
  216.            
  217.             self.petlevel = self.GetChild("LevelValue")
  218.             self.petexpa = self.GetChild("UpBringing_Pet_EXPGauge_01")
  219.             self.petexpb = self.GetChild("UpBringing_Pet_EXPGauge_02")
  220.             self.petexpc = self.GetChild("UpBringing_Pet_EXPGauge_03")
  221.             self.petexpd = self.GetChild("UpBringing_Pet_EXPGauge_04")
  222.             self.petexpe = self.GetChild("UpBringing_Pet_EXPGauge_05")
  223.             self.petexppages = []          
  224.             self.petexppages.append(self.petexpa)
  225.             self.petexppages.append(self.petexpb)
  226.             self.petexppages.append(self.petexpc)
  227.             self.petexppages.append(self.petexpd)
  228.             self.petexppages.append(self.petexpe)
  229.            
  230.             for exp in self.petexppages:
  231.                 exp.SetSize(0, 0)
  232.                 #exp.Hide()
  233.                
  234.            
  235.            
  236.            
  237.            
  238.             self.petages = self.GetChild("AgeValue")
  239.            
  240.             self.petdur = self.GetChild("LifeTextValue")
  241.            
  242.             #gaugehp
  243.            
  244.             self.nutribtn = self.GetChild("FeedLifeTimeButton")
  245.             self.sviluppobtn = self.GetChild("FeedEvolButton")
  246.             self.itemexp = self.GetChild("FeedExpButton")
  247.            
  248.             self.pethp = self.GetChild("HpValue")
  249.             self.petdef = self.GetChild("DefValue")
  250.             self.petsp = self.GetChild("SpValue")
  251.            
  252.             self.petskill0 = self.GetChild("PetSkillSlot0")
  253.            
  254.            
  255.            
  256.            
  257.            
  258.            
  259.            
  260.             #self.petskill0.SetPetSkillSlot(0, 2, 10)
  261.             #self.petskill0.SetPetSkillSlot(1, 11, 10)
  262.             #self.petskill0.SetPetSkillSlot(2, 5, 10)
  263.             self.petskill0.SetSlot(0, 2, 32, 32, petskill.GetEmptySkill())
  264.             self.petskill0.SetSlot(1, 2, 32, 32, petskill.GetEmptySkill())
  265.             self.petskill0.SetSlot(2, 2, 32, 32, petskill.GetEmptySkill())
  266.             #self.petskill0.SetCoverButton(0)
  267.             #self.petskill0.SetCoverButton(1)
  268.             #self.petskill0.SetCoverButton(2)
  269.             #self.petskill0.SetAlwaysRenderCoverButton(0, True)
  270.             #self.petskill0.SetAlwaysRenderCoverButton(1, True)
  271.             #self.petskill0.SetAlwaysRenderCoverButton(2, True)
  272.             self.petskill0.SetSelectItemSlotEvent(ui.__mem_func__(self.UseSkill))
  273.             self.petskill0.SetUseSlotEvent(ui.__mem_func__(self.UseSkill))
  274.             self.petskill0.SetOverInItemEvent(ui.__mem_func__(self.PetSkillTooltipShow))
  275.             self.petskill0.SetOverOutItemEvent(ui.__mem_func__(self.PetSkillTooltipHide))  
  276.            
  277.            
  278.            
  279.             self.SetDefaultInfo()
  280.            
  281.             self.arrytooltip = [ [-1,-1], [-1,-1], [-1,-1]]
  282.             self.linespet = pack_open("locale/pt/pet_skill.txt", "r").readlines()
  283.             self.linespetskill = pack_open("locale/pt/pet_skill_bonus.txt", "r").readlines()
  284.             self.SkillTooltip = uiToolTip.ToolTip(180)
  285.            
  286.            
  287.             #Event
  288.             self.boardclose.SetEvent(ui.__mem_func__(self.Close,))
  289.             self.nutribtn.SetToggleDownEvent(lambda arg=0,arg1=1: self.OpenFeedBox(arg,arg1))
  290.             self.nutribtn.SetToggleUpEvent(lambda arg=1,arg1=0: self.OpenFeedBox(arg,arg1))
  291.             self.itemexp.SetToggleDownEvent(lambda arg=0,arg1=3: self.OpenFeedBox(arg,arg1))
  292.             self.itemexp.SetToggleUpEvent(lambda arg=1,arg1=0: self.OpenFeedBox(arg,arg1))
  293.             self.sviluppobtn.SetToggleDownEvent(lambda arg=0: self.evolution(arg))
  294.             self.sviluppobtn.SetToggleUpEvent(lambda arg=1: self.evolution(arg))
  295.  
  296.            
  297.            
  298.         except:
  299.             import exception
  300.             exception.Abort("PetInformationWindow.LoadWindow.BindObject")
  301.    
  302.  
  303.            
  304.     def PetSkillTooltipShow(self, slot):
  305.         if self.arrytooltip[slot][0] > 0:
  306.             tokens = self.linespet[self.arrytooltip[slot][0]-1][:-1].split("\t")
  307.             tokens2 = self.linespetskill[self.arrytooltip[slot][0]-1][:-1].split("\t")
  308.             self.SkillTooltip.ClearToolTip()
  309.             self.SkillTooltip.AutoAppendTextLine(tokens[1], grp.GenerateColor(0.9490, 0.9058, 0.7568, 1.0))
  310.             self.SkillTooltip.AppendDescription(tokens[4], 26)
  311.             self.SkillTooltip.AppendSpace(5)
  312.             if self.arrytooltip[slot][0] != 10 and self.arrytooltip[slot][0] != 17 and self.arrytooltip[slot][0] != 18:
  313.                 self.SkillTooltip.AutoAppendTextLine(GetAffectString(int(tokens2[1]), int(tokens2[self.arrytooltip[slot][1]+1])))
  314.             elif self.arrytooltip[slot][0] == 10:
  315.                 self.SkillTooltip.AutoAppendTextLine("Hp Riprtistinati: " + str(tokens2[self.arrytooltip[slot][1]+1]))
  316.             elif self.arrytooltip[slot][0] == 17:
  317.                 self.SkillTooltip.AutoAppendTextLine("Invincibile per: " + checkdiv(int(tokens2[self.arrytooltip[slot][1]+1])) + " secondi")
  318.            
  319.             self.SkillTooltip.AutoAppendTextLine("Cooldown: "+tokens[5]+" sec", grp.GenerateColor(1.0, 0.7843, 0.0, 1.0))
  320.             self.SkillTooltip.AlignHorizonalCenter()
  321.             self.SkillTooltip.ShowToolTip()
  322.        
  323.        
  324.     def PetSkillTooltipHide(self):
  325.         self.SkillTooltip.HideToolTip()
  326.        
  327.        
  328.     def evolution(self, mode):
  329.         if mode == 0:
  330.             net.SendChatPacket("/petvoincrease")
  331.             self.sviluppobtn.Enable()
  332.         #self.SkillTooltip.HideToolTip()
  333.  
  334.     def SetDefaultInfo(self):
  335.         self.evolname.SetText("")
  336.         self.petname.SetText("")
  337.        
  338.         self.petlevel.SetText("")
  339.         self.petages.SetText("")
  340.         self.petdur.SetText("")
  341.        
  342.         self.pethp.SetText("")
  343.         self.petdef.SetText("")
  344.         self.petsp.SetText("")
  345.        
  346.         self.SetDuration("0", "0")
  347.        
  348.         self.slotimgpet.ClearSlot(0)
  349.         self.petskill0.ClearSlot(0)
  350.         self.petskill0.ClearSlot(1)
  351.         self.petskill0.ClearSlot(2)
  352.         self.petskill0.SetSlot(0, 2, 32, 32, petskill.GetEmptySkill())
  353.         self.petskill0.SetSlot(1, 2, 32, 32, petskill.GetEmptySkill())
  354.         self.petskill0.SetSlot(2, 2, 32, 32, petskill.GetEmptySkill())
  355.        
  356.         self.SetExperience(0,0,0)
  357.        
  358.         self.arrytooltip = [ [-1,-1], [-1,-1], [-1,-1]]
  359.        
  360.         self.nutribtn.Disable()
  361.         self.sviluppobtn.Enable()
  362.         self.itemexp.Disable()
  363.    
  364.     def OpenFeedBox(self, mode, btn):
  365.         if constInfo.FEEDWIND == btn or constInfo.FEEDWIND == 0:
  366.             if mode == 0:
  367.                 self.feedwind.Show()
  368.                 constInfo.FEEDWIND = btn
  369.             else:
  370.                 self.feedwind.Close()
  371.                 constInfo.FEEDWIND = 0
  372.  
  373.         else:
  374.             self.nutribtn.Enable()
  375.             self.sviluppobtn.Enable()
  376.             self.itemexp.Enable()
  377.             self.feedwind.Close()
  378.             constInfo.FEEDWIND = 0         
  379.  
  380.    
  381.     def SetImageSlot(self, vnum):
  382.         self.slotimgpet.SetItemSlot(0, int(vnum), 0)
  383.         self.slotimgpet.SetAlwaysRenderCoverButton(0, True)
  384.    
  385.            
  386.     def SetEvolveName(self, name):
  387.         self.evolname.SetText(name)
  388.    
  389.     def SetName(self, name):
  390.         if name != "":
  391.             self.nutribtn.Enable()
  392.             self.sviluppobtn.Enable()
  393.             self.itemexp.Enable()
  394.            
  395.             #pet.SetTop()
  396.         else:
  397.             self.nutribtn.Disable()
  398.             #self.sviluppobtn.Disable()
  399.             self.itemexp.Disable()
  400.            
  401.         self.petname.SetText(name)
  402.    
  403.     def SetLevel(self, level):
  404.         if int(level) == 40 or int(level) == 60 or int(level) == 80:
  405.             constInfo.EVOLUTION = int(level)
  406.         else:
  407.             constInfo.EVOLUTION = 0
  408.         self.petlevel.SetText(level)
  409.    
  410.     def SetAges(self, ages):
  411.         self.petages.SetText(ages)
  412.    
  413.     def SetDuration(self, dur, durt):
  414.         dur1 = int(dur)/60
  415.         durt1 = int(durt)/60
  416.         tmpage = int((int(durt)/60 -int(dur) /60)/24)      
  417.         if int(dur) > 0:
  418.             self.petlifeg.SetPercentage(int(dur)*1.6, int(durt))
  419.             self.petlifeg.Show()
  420.         else:
  421.             self.petlifeg.Hide()
  422.         self.petdur.SetText(str(dur1)+"/"+str(durt1)+" Ore")
  423.         self.SetAges(str(tmpage)+"giorni")
  424.        
  425.     def SetHp(self, hp):
  426.         self.pethp.SetText(pointop(hp)+"%")
  427.        
  428.     def SetDef(self, deff):
  429.         self.petdef.SetText(pointop(deff)+"%")
  430.        
  431.     def SetSp(self, sp):
  432.         self.petsp.SetText(pointop(sp)+"%")
  433.    
  434.     def SetSkill(self, slot, idx, lv):
  435.         if int(idx) != -1:
  436.             self.petskill0.ClearSlot(int(slot))
  437.             self.petskill0.SetPetSkillSlot(int(slot), int(idx), int(lv))
  438.             self.petskill0.SetCoverButton(int(slot))
  439.             self.petskill0.SetAlwaysRenderCoverButton(int(slot), True)
  440.             self.arrytooltip[int(slot)][0] = int(idx)
  441.             self.arrytooltip[int(slot)][1] = int(lv)
  442.             #chat.AppendChat(chat.CHAT_TYPE_INFO, "Slot:"+str(slot)+" idx: "+str(idx)+" Lv:"+str(lv))
  443.            
  444.     def SetExperience(self, expm, expi, exptot):
  445.         expm = int(expm)
  446.         expi = int(expi)
  447.         exptot = int(exptot)
  448.        
  449.         if exptot > 0
  450.             totalexp = exptot
  451.             totexpm = int( float(totalexp) / 100 * 90 )
  452.             totexpi = totalexp - totexpm
  453.             expi = min(expi, totexpi)
  454.             expmp =  float(expm) / totexpm * 100
  455.             expip =  float(expi) / totexpi * 100
  456.         else:
  457.             totalexp = 0
  458.             totexpm = 0
  459.             totexpi = 0
  460.             expmp =  0
  461.             expip =  0
  462.            
  463.        
  464.         curPoint = int(min(expm, totexpm))
  465.         curPoint = int(max(expm, 0))
  466.         maxPoint = int(max(totexpm, 0))
  467.        
  468.         curPointi = int(min(expi, totexpi))
  469.         curPointi = int(max(expi, 0))
  470.         maxPointi = int(max(totexpi, 0))
  471.  
  472.         quarterPoint = maxPoint / 4
  473.         quarterPointi = maxPointi
  474.         FullCount = 0
  475.         FullCounti = 0
  476.  
  477.         if 0 != quarterPoint:
  478.             FullCount = min(4, curPoint / quarterPoint)
  479.            
  480.         if 0 != quarterPointi:
  481.             FullCounti = min(1, curPointi / quarterPointi)
  482.  
  483.         for i in xrange(4):
  484.             self.petexppages[i].Hide()
  485.            
  486.         self.petexppages[4].Hide()
  487.  
  488.         for i in xrange(FullCount):
  489.             self.petexppages[i].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  490.             self.petexppages[i].Show()
  491.            
  492.         for i in xrange(FullCounti):
  493.             self.petexppages[4].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  494.             self.petexppages[4].Show()
  495.  
  496.         if 0 != quarterPoint:
  497.             if FullCount < 4:
  498.                 Percentage = float(curPoint % quarterPoint) / quarterPoint - 1.0
  499.                 self.petexppages[FullCount].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  500.                 self.petexppages[FullCount].Show()
  501.                
  502.         if 0 != quarterPointi:
  503.             if FullCounti < 1:
  504.                 Percentage = float(curPointi % quarterPointi) / quarterPointi - 1.0
  505.                 self.petexppages[4].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  506.                 self.petexppages[4].Show()
  507.            
  508.         #chat.AppendChat(chat.CHAT_TYPE_INFO, str(curPoint)+"-"+str(maxPoint)+"-"+str(FullCount)+"--"+str(quarterPoint))
  509.         #####
  510.         self.tooltipexp[0].SetText("Esperienza : %d of %d" % (expm, totexpm))
  511.         self.tooltipexp[1].SetText("Esperienza : %.2f%%" % expmp)
  512.         self.tooltipexp[2].SetText("EsperienzaI : %d of %d" % (expi, totexpi))
  513.         self.tooltipexp[3].SetText("EsperienzaI : %.2f%%" % expip)
  514.    
  515.     def UseSkill(self, slot):
  516.         #chat.AppendChat(chat.CHAT_TYPE_INFO, "+ --> "+str(slot))
  517.         #chat.AppendChat(chat.CHAT_TYPE_INFO, "Skill: "+ str(petskill.GetSkillbySlot(slot)))
  518.         net.SendChatPacket("/petskills "+str(slot))
  519.    
  520.     def OnUpdate(self):
  521.         if constInfo.FEEDWIND == 0:
  522.             self.nutribtn.Enable()
  523.             self.sviluppobtn.Enable()
  524.             self.itemexp.Enable()
  525.            
  526.         if TRUE == self.expwind.IsIn():
  527.             for i in range(0,4):               
  528.                 self.tooltipexp[i].Show()
  529.         else:
  530.             for i in range(0,4):               
  531.                 self.tooltipexp[i].Hide()
  532.    
  533. class PetSystemMini(ui.ScriptWindow):
  534.     class TextToolTip(ui.Window):
  535.         def __init__(self, y):
  536.             ui.Window.__init__(self, "TOP_MOST")
  537.  
  538.             textLine = ui.TextLine()
  539.             textLine.SetParent(self)
  540.             textLine.SetHorizontalAlignLeft()
  541.             textLine.SetOutline()
  542.             textLine.Show()
  543.             self.y = y
  544.             self.textLine = textLine
  545.  
  546.         def __del__(self):
  547.             ui.Window.__del__(self)
  548.  
  549.         def SetText(self, text):
  550.             self.textLine.SetText(text)
  551.  
  552.         def OnRender(self):
  553.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  554.             self.textLine.SetPosition(mouseX+5, mouseY - 60 + self.y)
  555.  
  556.     def __init__(self, pet_sys, vnum = 0):
  557.         ui.ScriptWindow.__init__(self)
  558.         self.vnum = vnum
  559.         self.pet_main = pet_sys
  560.         self.__LoadWindow()    
  561.  
  562.     def __del__(self):
  563.         ui.ScriptWindow.__del__(self)
  564.  
  565.     def Show(self):
  566.         ui.ScriptWindow.Show(self)
  567.  
  568.     def Close(self):
  569.         self.Hide()
  570.    
  571.     def __LoadWindow(self):
  572.         try:
  573.             pyScrLoader = ui.PythonScriptLoader()
  574.             pyScrLoader.LoadScriptFile(self, "uiscript/PetMiniInformationWindow.py")
  575.         except:
  576.             import exception
  577.             exception.Abort("PetMiniInformationWindow.LoadWindow.LoadObject")
  578.            
  579.         try:
  580.             self.expwind = self.GetChild("pet_mini_info_exp_gauge_board")
  581.             self.mainbg = self.GetChild("main_bg")
  582.             self.mainicon = self.GetChild("main_slot_img")
  583.             self.main_slot_img = self.GetChild("pet_icon_slot")
  584.             self.icon_button = self.GetChild("icon_button")
  585.             self.tooltipexp = []
  586.             for i in range(0,4):
  587.                 self.tooltipexp.append(self.TextToolTip(15*i))
  588.                 self.tooltipexp[i].Hide()
  589.                
  590.             self.pet_icon_slot_ani_img = self.GetChild("pet_icon_slot_ani_img")        
  591.             self.pet_mini_exp_01 = self.GetChild("pet_mini_EXPGauge_01")
  592.             self.pet_mini_exp_02 = self.GetChild("pet_mini_EXPGauge_02")
  593.             self.pet_mini_exp_03 = self.GetChild("pet_mini_EXPGauge_03")
  594.             self.pet_mini_exp_04 = self.GetChild("pet_mini_EXPGauge_04")
  595.             self.pet_mini_exp_05 = self.GetChild("pet_mini_EXPGauge_05")
  596.             self.petmini_exp = []
  597.             self.petmini_exp.append(self.pet_mini_exp_01)
  598.             self.petmini_exp.append(self.pet_mini_exp_02)
  599.             self.petmini_exp.append(self.pet_mini_exp_03)
  600.             self.petmini_exp.append(self.pet_mini_exp_04)
  601.             self.petmini_exp.append(self.pet_mini_exp_05)
  602.             self.petlifeg = self.GetChild("LifeGauge")
  603.             self.skillslot = self.GetChild("mini_skill_slot0")
  604.             self.skillslot.SetSlotScale(0, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  605.             self.skillslot.SetSlotScale(1, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  606.             self.skillslot.SetSlotScale(2, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  607.            
  608.             self.skillslot.SetSelectItemSlotEvent(ui.__mem_func__(self.UseSkill))
  609.             self.skillslot.SetUseSlotEvent(ui.__mem_func__(self.UseSkill))
  610.             self.icon_button.OnMouseLeftButtonUp = lambda : self.__OpenMainBoard()
  611.            
  612.  
  613.            
  614.            
  615.             self.SetDefaultInfo()
  616.            
  617.            
  618.            
  619.             #self.mainbg.Show()
  620.            
  621.         except:
  622.             import exception
  623.             exception.Abort("PetMiniInformationWindow.LoadWindow.BindObject")
  624.            
  625.  
  626.        
  627.     def SetDefaultInfo(self):      
  628.        
  629.         self.SetDuration("0", "0")
  630.        
  631.         self.main_slot_img.Hide()
  632.         self.skillslot.ClearSlot(0)
  633.         self.skillslot.ClearSlot(1)
  634.         self.skillslot.ClearSlot(2)
  635.         self.skillslot.SetSlotScale(0, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  636.         self.skillslot.SetSlotScale(1, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  637.         self.skillslot.SetSlotScale(2, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  638.        
  639.         self.SetExperience(0,0,0)
  640.        
  641.        
  642.     def __OpenMainBoard(self):
  643.         if constInfo.PETGUI == 0:
  644.             self.pet_main.Show()
  645.             self.pet_main.SetTop()
  646.             constInfo.PETGUI = 1
  647.         else:
  648.             self.pet_main.Close()
  649.             constInfo.PETGUI = 0
  650.    
  651.     def SetImageSlot(self, vnum):
  652.         if int(vnum) > 0:
  653.             item.SelectItem(int(vnum))
  654.             self.main_slot_img.SetUpVisual(item.GetIconImageFileName())
  655.             self.main_slot_img.SetOverVisual(item.GetIconImageFileName())
  656.             self.main_slot_img.SetDownVisual(item.GetIconImageFileName())
  657.             self.main_slot_img.Show()
  658.    
  659.            
  660.     def SetDuration(self, dur, durt):
  661.         tmpage = int((int(durt)/60 -int(dur) /60)/24)      
  662.         if int(dur) > 0:
  663.             self.petlifeg.SetPercentage(int(dur), int(durt))
  664.             self.petlifeg.Show()
  665.         else:
  666.             self.petlifeg.Hide()
  667.        
  668.     def SetSkill(self, slot, idx, lv):
  669.         if int(idx) != -1:
  670.             self.skillslot.ClearSlot(int(slot))
  671.             self.skillslot.SetPetSkillSlot(int(slot), int(idx), int(lv), 0.5, 0.5)
  672.             self.skillslot.SetCoverButton(int(slot), "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub", "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub", "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub" , "d:/ymir work/ui/pet/mini_window/pet_slot_corvermini.sub")
  673.             self.skillslot.SetAlwaysRenderCoverButton(int(slot), True)
  674.            
  675.            
  676.     def SetExperience(self, expm, expi, exptot):
  677.         expm = int(expm)
  678.         expi = int(expi)
  679.         exptot = int(exptot)
  680.        
  681.         if exptot > 0
  682.             totalexp = exptot
  683.             totexpm = int( float(totalexp) / 100 * 90 )
  684.             totexpi = totalexp - totexpm
  685.             expi = min(expi, totexpi)
  686.             expmp =  float(expm) / totexpm * 100
  687.             expip =  float(expi) / totexpi * 100
  688.         else:
  689.             totalexp = 0
  690.             totexpm = 0
  691.             totexpi = 0
  692.             expmp =  0
  693.             expip =  0
  694.            
  695.        
  696.         curPoint = int(min(expm, totexpm))
  697.         curPoint = int(max(expm, 0))
  698.         maxPoint = int(max(totexpm, 0))
  699.        
  700.         curPointi = int(min(expi, totexpi))
  701.         curPointi = int(max(expi, 0))
  702.         maxPointi = int(max(totexpi, 0))
  703.  
  704.         quarterPoint = maxPoint / 4
  705.         quarterPointi = maxPointi
  706.         FullCount = 0
  707.         FullCounti = 0
  708.  
  709.         if 0 != quarterPoint:
  710.             FullCount = min(4, curPoint / quarterPoint)
  711.            
  712.         if 0 != quarterPointi:
  713.             FullCounti = min(1, curPointi / quarterPointi)
  714.  
  715.         for i in xrange(4):
  716.             self.petmini_exp[i].Hide()
  717.            
  718.         self.petmini_exp[4].Hide()
  719.  
  720.         for i in xrange(FullCount):
  721.             self.petmini_exp[i].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  722.             self.petmini_exp[i].Show()
  723.            
  724.         for i in xrange(FullCounti):
  725.             self.petmini_exp[4].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  726.             self.petmini_exp[4].Show()
  727.  
  728.         if 0 != quarterPoint:
  729.             if FullCount < 4:
  730.                 Percentage = float(curPoint % quarterPoint) / quarterPoint - 1.0
  731.                 self.petmini_exp[FullCount].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  732.                 self.petmini_exp[FullCount].Show()
  733.                
  734.         if 0 != quarterPointi:
  735.             if FullCounti < 1:
  736.                 Percentage = float(curPointi % quarterPointi) / quarterPointi - 1.0
  737.                 self.petmini_exp[4].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  738.                 self.petmini_exp[4].Show()
  739.            
  740.        
  741.         #####
  742.         self.tooltipexp[0].SetText("Esperienza : %d of %d" % (expm, totexpm))
  743.         self.tooltipexp[1].SetText("Esperienza : %.2f%%" % expmp)
  744.         self.tooltipexp[2].SetText("EsperienzaI : %d of %d" % (expi, totexpi))
  745.         self.tooltipexp[3].SetText("EsperienzaI : %.2f%%" % expip)
  746.    
  747.     def UseSkill(self, slot):
  748.         chat.AppendChat(chat.CHAT_TYPE_INFO, "+ --> "+str(slot))
  749.         chat.AppendChat(chat.CHAT_TYPE_INFO, "Skill: "+ str(petskill.GetSkillbySlot(slot)))
  750.         net.SendChatPacket("/petskills "+str(slot))
  751.    
  752.     def OnUpdate(self):
  753.         self.pet_icon_slot_ani_img = self.GetChild("pet_icon_slot_ani_img")
  754.         if constInfo.PETMINIEVO == 0 and constInfo.EVOLUTION == 40:
  755.             self.pet_icon_slot_ani_img.Show()
  756.         elif constInfo.PETMINIEVO == 1 and constInfo.EVOLUTION == 60:
  757.             self.pet_icon_slot_ani_img.Show()
  758.         elif constInfo.PETMINIEVO == 2 and constInfo.EVOLUTION == 80:
  759.             self.pet_icon_slot_ani_img.Show()
  760.         else:
  761.             self.pet_icon_slot_ani_img.Hide()
  762.            
  763.         if TRUE == self.pet_mini_exp_01.IsIn() or TRUE == self.pet_mini_exp_02.IsIn() or TRUE == self.pet_mini_exp_03.IsIn() or TRUE == self.pet_mini_exp_04.IsIn() or TRUE == self.pet_mini_exp_05.IsIn() or TRUE == self.expwind.IsIn(): #@fixmevegas02
  764.             for i in range(0,4):               
  765.                 self.tooltipexp[i].Show()
  766.                 #(mouseX, mouseY) = wndMgr.GetMousePosition()          
  767.                 #self.tooltipexp[i].SetPosition(mouseX,mouseY)
  768.                 #vegas_test(0)
  769.         else:
  770.             for i in range(0,4):               
  771.                 self.tooltipexp[i].Hide()
Advertisement
Add Comment
Please, Sign In to add comment