Advertisement
deadx2

Untitled

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