Advertisement
Guest User

Untitled

a guest
Mar 25th, 2020
340
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 26.15 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.             #PET_FILE_NAME = "%s/pet_skill.txt" % app.GetLocalePath()
  283.             #PET_FILE_SKILL = "%s/pet_skill_bonus.txt" % app.GetLocalePath()
  284.             self.linespet = open("locale/pt/pet_skill.txt", "r").readlines()
  285.             self.linespetskill = open("locale/pt/pet_skill_bonus.txt", "r").readlines()
  286.             self.SkillTooltip = uiToolTip.ToolTip(180)
  287.            
  288.            
  289.             #Event
  290.             self.boardclose.SetEvent(ui.__mem_func__(self.Close,))
  291.             self.nutribtn.SetToggleDownEvent(lambda arg=0,arg1=1: self.OpenFeedBox(arg,arg1))
  292.             self.nutribtn.SetToggleUpEvent(lambda arg=1,arg1=0: self.OpenFeedBox(arg,arg1))
  293.             self.itemexp.SetToggleDownEvent(lambda arg=0,arg1=3: self.OpenFeedBox(arg,arg1))
  294.             self.itemexp.SetToggleUpEvent(lambda arg=1,arg1=0: self.OpenFeedBox(arg,arg1))
  295.             self.sviluppobtn.SetToggleDownEvent(lambda arg=0: self.evolution(arg))
  296.             self.sviluppobtn.SetToggleUpEvent(lambda arg=1: self.evolution(arg))
  297.  
  298.            
  299.            
  300.         except:
  301.             import exception
  302.             exception.Abort("PetInformationWindow.LoadWindow.BindObject")
  303.    
  304.  
  305.            
  306.     def PetSkillTooltipShow(self, slot):
  307.         if self.arrytooltip[slot][0] > 0:
  308.             tokens = self.linespet[self.arrytooltip[slot][0]-1][:-1].split("\t")
  309.             tokens2 = self.linespetskill[self.arrytooltip[slot][0]-1][:-1].split("\t")
  310.             self.SkillTooltip.ClearToolTip()
  311.             self.SkillTooltip.AutoAppendTextLine(tokens[1], grp.GenerateColor(0.9490, 0.9058, 0.7568, 1.0))
  312.             self.SkillTooltip.AppendDescription(tokens[4], 26)
  313.             self.SkillTooltip.AppendSpace(5)
  314.             if self.arrytooltip[slot][0] != 10 and self.arrytooltip[slot][0] != 17 and self.arrytooltip[slot][0] != 18:
  315.                 self.SkillTooltip.AutoAppendTextLine(GetAffectString(int(tokens2[1]), int(tokens2[self.arrytooltip[slot][1]+1])))
  316.             elif self.arrytooltip[slot][0] == 10:
  317.                 self.SkillTooltip.AutoAppendTextLine("Hp Riprtistinati: " + str(tokens2[self.arrytooltip[slot][1]+1]))
  318.             elif self.arrytooltip[slot][0] == 17:
  319.                 self.SkillTooltip.AutoAppendTextLine("Invincibile per: " + checkdiv(int(tokens2[self.arrytooltip[slot][1]+1])) + " secondi")
  320.            
  321.             self.SkillTooltip.AutoAppendTextLine("Cooldown: "+tokens[5]+" sec", grp.GenerateColor(1.0, 0.7843, 0.0, 1.0))
  322.             self.SkillTooltip.AlignHorizonalCenter()
  323.             self.SkillTooltip.ShowToolTip()
  324.        
  325.        
  326.     def PetSkillTooltipHide(self):
  327.         self.SkillTooltip.HideToolTip()
  328.        
  329.        
  330.     def evolution(self, mode):
  331.         if mode == 0:
  332.             net.SendChatPacket("/petvoincrease")
  333.             self.sviluppobtn.Enable()
  334.         #self.SkillTooltip.HideToolTip()
  335.  
  336.     def SetDefaultInfo(self):
  337.         self.evolname.SetText("")
  338.         self.petname.SetText("")
  339.        
  340.         self.petlevel.SetText("")
  341.         self.petages.SetText("")
  342.         self.petdur.SetText("")
  343.        
  344.         self.pethp.SetText("")
  345.         self.petdef.SetText("")
  346.         self.petsp.SetText("")
  347.        
  348.         self.SetDuration("0", "0")
  349.        
  350.         self.slotimgpet.ClearSlot(0)
  351.         self.petskill0.ClearSlot(0)
  352.         self.petskill0.ClearSlot(1)
  353.         self.petskill0.ClearSlot(2)
  354.         self.petskill0.SetSlot(0, 2, 32, 32, petskill.GetEmptySkill())
  355.         self.petskill0.SetSlot(1, 2, 32, 32, petskill.GetEmptySkill())
  356.         self.petskill0.SetSlot(2, 2, 32, 32, petskill.GetEmptySkill())
  357.        
  358.         self.SetExperience(0,0,0)
  359.        
  360.         self.arrytooltip = [ [-1,-1], [-1,-1], [-1,-1]]
  361.        
  362.         self.nutribtn.Disable()
  363.         self.sviluppobtn.Enable()
  364.         self.itemexp.Disable()
  365.    
  366.     def OpenFeedBox(self, mode, btn):
  367.         if constInfo.FEEDWIND == btn or constInfo.FEEDWIND == 0:
  368.             if mode == 0:
  369.                 self.feedwind.Show()
  370.                 constInfo.FEEDWIND = btn
  371.             else:
  372.                 self.feedwind.Close()
  373.                 constInfo.FEEDWIND = 0
  374.  
  375.         else:
  376.             self.nutribtn.Enable()
  377.             self.sviluppobtn.Enable()
  378.             self.itemexp.Enable()
  379.             self.feedwind.Close()
  380.             constInfo.FEEDWIND = 0         
  381.  
  382.    
  383.     def SetImageSlot(self, vnum):
  384.         self.slotimgpet.SetItemSlot(0, int(vnum), 0)
  385.         self.slotimgpet.SetAlwaysRenderCoverButton(0, True)
  386.    
  387.            
  388.     def SetEvolveName(self, name):
  389.         self.evolname.SetText(name)
  390.    
  391.     def SetName(self, name):
  392.         if name != "":
  393.             self.nutribtn.Enable()
  394.             self.sviluppobtn.Enable()
  395.             self.itemexp.Enable()
  396.            
  397.             #pet.SetTop()
  398.         else:
  399.             self.nutribtn.Disable()
  400.             #self.sviluppobtn.Disable()
  401.             self.itemexp.Disable()
  402.            
  403.         self.petname.SetText(name)
  404.    
  405.     def SetLevel(self, level):
  406.         if int(level) == 40 or int(level) == 60 or int(level) == 80:
  407.             constInfo.EVOLUTION = int(level)
  408.         else:
  409.             constInfo.EVOLUTION = 0
  410.         self.petlevel.SetText(level)
  411.    
  412.     def SetAges(self, ages):
  413.         self.petages.SetText(ages)
  414.    
  415.     def SetDuration(self, dur, durt):
  416.         dur1 = int(dur)/60
  417.         durt1 = int(durt)/60
  418.         tmpage = int((int(durt)/60 -int(dur) /60)/24)      
  419.         if int(dur) > 0:
  420.             self.petlifeg.SetPercentage(int(dur)*1.6, int(durt))
  421.             self.petlifeg.Show()
  422.         else:
  423.             self.petlifeg.Hide()
  424.         self.petdur.SetText(str(dur1)+"/"+str(durt1)+" Ore")
  425.         self.SetAges(str(tmpage)+"giorni")
  426.        
  427.     def SetHp(self, hp):
  428.         self.pethp.SetText(pointop(hp)+"%")
  429.        
  430.     def SetDef(self, deff):
  431.         self.petdef.SetText(pointop(deff)+"%")
  432.        
  433.     def SetSp(self, sp):
  434.         self.petsp.SetText(pointop(sp)+"%")
  435.    
  436.     def SetSkill(self, slot, idx, lv):
  437.         if int(idx) != -1:
  438.             self.petskill0.ClearSlot(int(slot))
  439.             self.petskill0.SetPetSkillSlot(int(slot), int(idx), int(lv))
  440.             self.petskill0.SetCoverButton(int(slot))
  441.             self.petskill0.SetAlwaysRenderCoverButton(int(slot), True)
  442.             self.arrytooltip[int(slot)][0] = int(idx)
  443.             self.arrytooltip[int(slot)][1] = int(lv)
  444.             #chat.AppendChat(chat.CHAT_TYPE_INFO, "Slot:"+str(slot)+" idx: "+str(idx)+" Lv:"+str(lv))
  445.            
  446.     def SetExperience(self, expm, expi, exptot):
  447.         expm = int(expm)
  448.         expi = int(expi)
  449.         exptot = int(exptot)
  450.        
  451.         if exptot > 0
  452.             totalexp = exptot
  453.             totexpm = int( float(totalexp) / 100 * 90 )
  454.             totexpi = totalexp - totexpm
  455.             expi = min(expi, totexpi)
  456.             expmp =  float(expm) / totexpm * 100
  457.             expip =  float(expi) / totexpi * 100
  458.         else:
  459.             totalexp = 0
  460.             totexpm = 0
  461.             totexpi = 0
  462.             expmp =  0
  463.             expip =  0
  464.            
  465.        
  466.         curPoint = int(min(expm, totexpm))
  467.         curPoint = int(max(expm, 0))
  468.         maxPoint = int(max(totexpm, 0))
  469.        
  470.         curPointi = int(min(expi, totexpi))
  471.         curPointi = int(max(expi, 0))
  472.         maxPointi = int(max(totexpi, 0))
  473.  
  474.         quarterPoint = maxPoint / 4
  475.         quarterPointi = maxPointi
  476.         FullCount = 0
  477.         FullCounti = 0
  478.  
  479.         if 0 != quarterPoint:
  480.             FullCount = min(4, curPoint / quarterPoint)
  481.            
  482.         if 0 != quarterPointi:
  483.             FullCounti = min(1, curPointi / quarterPointi)
  484.  
  485.         for i in xrange(4):
  486.             self.petexppages[i].Hide()
  487.            
  488.         self.petexppages[4].Hide()
  489.  
  490.         for i in xrange(FullCount):
  491.             self.petexppages[i].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  492.             self.petexppages[i].Show()
  493.            
  494.         for i in xrange(FullCounti):
  495.             self.petexppages[4].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  496.             self.petexppages[4].Show()
  497.  
  498.         if 0 != quarterPoint:
  499.             if FullCount < 4:
  500.                 Percentage = float(curPoint % quarterPoint) / quarterPoint - 1.0
  501.                 self.petexppages[FullCount].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  502.                 self.petexppages[FullCount].Show()
  503.                
  504.         if 0 != quarterPointi:
  505.             if FullCounti < 1:
  506.                 Percentage = float(curPointi % quarterPointi) / quarterPointi - 1.0
  507.                 self.petexppages[4].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  508.                 self.petexppages[4].Show()
  509.            
  510.         #chat.AppendChat(chat.CHAT_TYPE_INFO, str(curPoint)+"-"+str(maxPoint)+"-"+str(FullCount)+"--"+str(quarterPoint))
  511.         #####
  512.         self.tooltipexp[0].SetText("Esperienza : %d of %d" % (expm, totexpm))
  513.         self.tooltipexp[1].SetText("Esperienza : %.2f%%" % expmp)
  514.         self.tooltipexp[2].SetText("EsperienzaI : %d of %d" % (expi, totexpi))
  515.         self.tooltipexp[3].SetText("EsperienzaI : %.2f%%" % expip)
  516.    
  517.     def UseSkill(self, slot):
  518.         #chat.AppendChat(chat.CHAT_TYPE_INFO, "+ --> "+str(slot))
  519.         #chat.AppendChat(chat.CHAT_TYPE_INFO, "Skill: "+ str(petskill.GetSkillbySlot(slot)))
  520.         net.SendChatPacket("/petskills "+str(slot))
  521.    
  522.     def OnUpdate(self):
  523.         if constInfo.FEEDWIND == 0:
  524.             self.nutribtn.Enable()
  525.             self.sviluppobtn.Enable()
  526.             self.itemexp.Enable()
  527.            
  528.         if TRUE == self.expwind.IsIn():
  529.             for i in range(0,4):               
  530.                 self.tooltipexp[i].Show()
  531.         else:
  532.             for i in range(0,4):               
  533.                 self.tooltipexp[i].Hide()
  534.    
  535. class PetSystemMini(ui.ScriptWindow):
  536.     class TextToolTip(ui.Window):
  537.         def __init__(self, y):
  538.             ui.Window.__init__(self, "TOP_MOST")
  539.  
  540.             textLine = ui.TextLine()
  541.             textLine.SetParent(self)
  542.             textLine.SetHorizontalAlignLeft()
  543.             textLine.SetOutline()
  544.             textLine.Show()
  545.             self.y = y
  546.             self.textLine = textLine
  547.  
  548.         def __del__(self):
  549.             ui.Window.__del__(self)
  550.  
  551.         def SetText(self, text):
  552.             self.textLine.SetText(text)
  553.  
  554.         def OnRender(self):
  555.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  556.             self.textLine.SetPosition(mouseX+5, mouseY - 60 + self.y)
  557.  
  558.     def __init__(self, pet_sys, vnum = 0):
  559.         ui.ScriptWindow.__init__(self)
  560.         self.vnum = vnum
  561.         self.pet_main = pet_sys
  562.         self.__LoadWindow()    
  563.  
  564.     def __del__(self):
  565.         ui.ScriptWindow.__del__(self)
  566.  
  567.     def Show(self):
  568.         ui.ScriptWindow.Show(self)
  569.  
  570.     def Close(self):
  571.         self.Hide()
  572.    
  573.     def __LoadWindow(self):
  574.         try:
  575.             pyScrLoader = ui.PythonScriptLoader()
  576.             pyScrLoader.LoadScriptFile(self, "uiscript/PetMiniInformationWindow.py")
  577.         except:
  578.             import exception
  579.             exception.Abort("PetMiniInformationWindow.LoadWindow.LoadObject")
  580.            
  581.         try:
  582.             self.expwind = self.GetChild("pet_mini_info_exp_gauge_board")
  583.             self.mainbg = self.GetChild("main_bg")
  584.             self.mainicon = self.GetChild("main_slot_img")
  585.             self.main_slot_img = self.GetChild("pet_icon_slot")
  586.             self.icon_button = self.GetChild("icon_button")
  587.             self.tooltipexp = []
  588.             for i in range(0,4):
  589.                 self.tooltipexp.append(self.TextToolTip(15*i))
  590.                 self.tooltipexp[i].Hide()
  591.                
  592.             self.pet_icon_slot_ani_img = self.GetChild("pet_icon_slot_ani_img")        
  593.             self.pet_mini_exp_01 = self.GetChild("pet_mini_EXPGauge_01")
  594.             self.pet_mini_exp_02 = self.GetChild("pet_mini_EXPGauge_02")
  595.             self.pet_mini_exp_03 = self.GetChild("pet_mini_EXPGauge_03")
  596.             self.pet_mini_exp_04 = self.GetChild("pet_mini_EXPGauge_04")
  597.             self.pet_mini_exp_05 = self.GetChild("pet_mini_EXPGauge_05")
  598.             self.petmini_exp = []
  599.             self.petmini_exp.append(self.pet_mini_exp_01)
  600.             self.petmini_exp.append(self.pet_mini_exp_02)
  601.             self.petmini_exp.append(self.pet_mini_exp_03)
  602.             self.petmini_exp.append(self.pet_mini_exp_04)
  603.             self.petmini_exp.append(self.pet_mini_exp_05)
  604.             self.petlifeg = self.GetChild("LifeGauge")
  605.             self.skillslot = self.GetChild("mini_skill_slot0")
  606.             self.skillslot.SetSlotScale(0, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  607.             self.skillslot.SetSlotScale(1, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  608.             self.skillslot.SetSlotScale(2, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  609.            
  610.             self.skillslot.SetSelectItemSlotEvent(ui.__mem_func__(self.UseSkill))
  611.             self.skillslot.SetUseSlotEvent(ui.__mem_func__(self.UseSkill))
  612.             self.icon_button.OnMouseLeftButtonUp = lambda : self.__OpenMainBoard()
  613.            
  614.  
  615.            
  616.            
  617.             self.SetDefaultInfo()
  618.            
  619.            
  620.            
  621.             #self.mainbg.Show()
  622.            
  623.         except:
  624.             import exception
  625.             exception.Abort("PetMiniInformationWindow.LoadWindow.BindObject")
  626.            
  627.  
  628.        
  629.     def SetDefaultInfo(self):      
  630.        
  631.         self.SetDuration("0", "0")
  632.        
  633.         self.main_slot_img.Hide()
  634.         self.skillslot.ClearSlot(0)
  635.         self.skillslot.ClearSlot(1)
  636.         self.skillslot.ClearSlot(2)
  637.         self.skillslot.SetSlotScale(0, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  638.         self.skillslot.SetSlotScale(1, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  639.         self.skillslot.SetSlotScale(2, 2, 16, 16, petskill.GetEmptySkill(), 0.5, 0.5)
  640.        
  641.         self.SetExperience(0,0,0)
  642.        
  643.        
  644.     def __OpenMainBoard(self):
  645.         if constInfo.PETGUI == 0:
  646.             self.pet_main.Show()
  647.             self.pet_main.SetTop()
  648.             constInfo.PETGUI = 1
  649.         else:
  650.             self.pet_main.Close()
  651.             constInfo.PETGUI = 0
  652.    
  653.     def SetImageSlot(self, vnum):
  654.         if int(vnum) > 0:
  655.             item.SelectItem(int(vnum))
  656.             self.main_slot_img.SetUpVisual(item.GetIconImageFileName())
  657.             self.main_slot_img.SetOverVisual(item.GetIconImageFileName())
  658.             self.main_slot_img.SetDownVisual(item.GetIconImageFileName())
  659.             self.main_slot_img.Show()
  660.    
  661.            
  662.     def SetDuration(self, dur, durt):
  663.         tmpage = int((int(durt)/60 -int(dur) /60)/24)      
  664.         if int(dur) > 0:
  665.             self.petlifeg.SetPercentage(int(dur), int(durt))
  666.             self.petlifeg.Show()
  667.         else:
  668.             self.petlifeg.Hide()
  669.        
  670.     def SetSkill(self, slot, idx, lv):
  671.         if int(idx) != -1:
  672.             self.skillslot.ClearSlot(int(slot))
  673.             self.skillslot.SetPetSkillSlot(int(slot), int(idx), int(lv), 0.5, 0.5)
  674.             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")
  675.             self.skillslot.SetAlwaysRenderCoverButton(int(slot), True)
  676.            
  677.            
  678.     def SetExperience(self, expm, expi, exptot):
  679.         expm = int(expm)
  680.         expi = int(expi)
  681.         exptot = int(exptot)
  682.        
  683.         if exptot > 0
  684.             totalexp = exptot
  685.             totexpm = int( float(totalexp) / 100 * 90 )
  686.             totexpi = totalexp - totexpm
  687.             expi = min(expi, totexpi)
  688.             expmp =  float(expm) / totexpm * 100
  689.             expip =  float(expi) / totexpi * 100
  690.         else:
  691.             totalexp = 0
  692.             totexpm = 0
  693.             totexpi = 0
  694.             expmp =  0
  695.             expip =  0
  696.            
  697.        
  698.         curPoint = int(min(expm, totexpm))
  699.         curPoint = int(max(expm, 0))
  700.         maxPoint = int(max(totexpm, 0))
  701.        
  702.         curPointi = int(min(expi, totexpi))
  703.         curPointi = int(max(expi, 0))
  704.         maxPointi = int(max(totexpi, 0))
  705.  
  706.         quarterPoint = maxPoint / 4
  707.         quarterPointi = maxPointi
  708.         FullCount = 0
  709.         FullCounti = 0
  710.  
  711.         if 0 != quarterPoint:
  712.             FullCount = min(4, curPoint / quarterPoint)
  713.            
  714.         if 0 != quarterPointi:
  715.             FullCounti = min(1, curPointi / quarterPointi)
  716.  
  717.         for i in xrange(4):
  718.             self.petmini_exp[i].Hide()
  719.            
  720.         self.petmini_exp[4].Hide()
  721.  
  722.         for i in xrange(FullCount):
  723.             self.petmini_exp[i].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  724.             self.petmini_exp[i].Show()
  725.            
  726.         for i in xrange(FullCounti):
  727.             self.petmini_exp[4].SetRenderingRect(0.0, 0.0, 0.0, 0.0)
  728.             self.petmini_exp[4].Show()
  729.  
  730.         if 0 != quarterPoint:
  731.             if FullCount < 4:
  732.                 Percentage = float(curPoint % quarterPoint) / quarterPoint - 1.0
  733.                 self.petmini_exp[FullCount].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  734.                 self.petmini_exp[FullCount].Show()
  735.                
  736.         if 0 != quarterPointi:
  737.             if FullCounti < 1:
  738.                 Percentage = float(curPointi % quarterPointi) / quarterPointi - 1.0
  739.                 self.petmini_exp[4].SetRenderingRect(0.0, Percentage, 0.0, 0.0)
  740.                 self.petmini_exp[4].Show()
  741.            
  742.        
  743.         #####
  744.         self.tooltipexp[0].SetText("Esperienza : %d of %d" % (expm, totexpm))
  745.         self.tooltipexp[1].SetText("Esperienza : %.2f%%" % expmp)
  746.         self.tooltipexp[2].SetText("EsperienzaI : %d of %d" % (expi, totexpi))
  747.         self.tooltipexp[3].SetText("EsperienzaI : %.2f%%" % expip)
  748.    
  749.     def UseSkill(self, slot):
  750.         chat.AppendChat(chat.CHAT_TYPE_INFO, "+ --> "+str(slot))
  751.         chat.AppendChat(chat.CHAT_TYPE_INFO, "Skill: "+ str(petskill.GetSkillbySlot(slot)))
  752.         net.SendChatPacket("/petskills "+str(slot))
  753.    
  754.     def OnUpdate(self):
  755.         self.pet_icon_slot_ani_img = self.GetChild("pet_icon_slot_ani_img")
  756.         if constInfo.PETMINIEVO == 0 and constInfo.EVOLUTION == 40:
  757.             self.pet_icon_slot_ani_img.Show()
  758.         elif constInfo.PETMINIEVO == 1 and constInfo.EVOLUTION == 60:
  759.             self.pet_icon_slot_ani_img.Show()
  760.         elif constInfo.PETMINIEVO == 2 and constInfo.EVOLUTION == 80:
  761.             self.pet_icon_slot_ani_img.Show()
  762.         else:
  763.             self.pet_icon_slot_ani_img.Hide()
  764.            
  765.         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
  766.             for i in range(0,4):               
  767.                 self.tooltipexp[i].Show()
  768.                 #(mouseX, mouseY) = wndMgr.GetMousePosition()          
  769.                 #self.tooltipexp[i].SetPosition(mouseX,mouseY)
  770.                 #vegas_test(0)
  771.         else:
  772.             for i in range(0,4):               
  773.                 self.tooltipexp[i].Hide()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement