Guest User

Untitled

a guest
May 4th, 2020
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 21.99 KB | None | 0 0
  1. import ui
  2. import localeInfo
  3. import chr
  4. import item
  5. import app
  6. import skill
  7. import player
  8. import uiToolTip
  9. import math
  10.  
  11. # WEDDING
  12. class LovePointImage(ui.ExpandedImageBox):
  13.     FILE_PATH = "d:/ymir work/ui/pattern/LovePoint/"
  14.     FILE_DICT = {
  15.         0 : FILE_PATH + "01.dds",
  16.         1 : FILE_PATH + "02.dds",
  17.         2 : FILE_PATH + "02.dds",
  18.         3 : FILE_PATH + "03.dds",
  19.         4 : FILE_PATH + "04.dds",
  20.         5 : FILE_PATH + "05.dds",
  21.     }
  22.  
  23.     def __init__(self):
  24.         ui.ExpandedImageBox.__init__(self)
  25.  
  26.         self.loverName = ""
  27.         self.lovePoint = 0
  28.  
  29.         self.toolTip = uiToolTip.ToolTip(100)
  30.         self.toolTip.HideToolTip()
  31.  
  32.     def __del__(self):
  33.         ui.ExpandedImageBox.__del__(self)
  34.  
  35.     def SetLoverInfo(self, name, lovePoint):
  36.         self.loverName = name
  37.         self.lovePoint = lovePoint
  38.         self.__Refresh()
  39.  
  40.     def OnUpdateLovePoint(self, lovePoint):
  41.         self.lovePoint = lovePoint
  42.         self.__Refresh()
  43.  
  44.     def __Refresh(self):
  45.         self.lovePoint = max(0, self.lovePoint)
  46.         self.lovePoint = min(100, self.lovePoint)
  47.  
  48.         if 0 == self.lovePoint:
  49.             loveGrade = 0
  50.         else:
  51.             loveGrade = self.lovePoint / 25 + 1
  52.         fileName = self.FILE_DICT.get(loveGrade, self.FILE_PATH+"00.dds")
  53.  
  54.         try:
  55.             self.LoadImage(fileName)
  56.         except:
  57.             import dbg
  58.             dbg.TraceError("LovePointImage.SetLoverInfo(lovePoint=%d) - LoadError %s" % (lovePoint, fileName))
  59.  
  60.         self.SetScale(0.7, 0.7)
  61.  
  62.         self.toolTip.ClearToolTip()
  63.         self.toolTip.SetTitle(self.loverName)
  64.         self.toolTip.AppendTextLine(localeInfo.AFF_LOVE_POINT % (self.lovePoint))
  65.         self.toolTip.ResizeToolTip()
  66.  
  67.     def OnMouseOverIn(self):
  68.         self.toolTip.ShowToolTip()
  69.  
  70.     def OnMouseOverOut(self):
  71.         self.toolTip.HideToolTip()
  72. # END_OF_WEDDING
  73.  
  74.  
  75. class HorseImage(ui.ExpandedImageBox):
  76.     FILE_PATH = "d:/ymir work/ui/pattern/HorseState/"
  77.     FILE_DICT = {
  78.         00 : FILE_PATH+"00.dds",
  79.         01 : FILE_PATH+"00.dds",
  80.         02 : FILE_PATH+"00.dds",
  81.         03 : FILE_PATH+"00.dds",
  82.         10 : FILE_PATH+"10.dds",
  83.         11 : FILE_PATH+"11.dds",
  84.         12 : FILE_PATH+"12.dds",
  85.         13 : FILE_PATH+"13.dds",
  86.         20 : FILE_PATH+"20.dds",
  87.         21 : FILE_PATH+"21.dds",
  88.         22 : FILE_PATH+"22.dds",
  89.         23 : FILE_PATH+"23.dds",
  90.         30 : FILE_PATH+"30.dds",
  91.         31 : FILE_PATH+"31.dds",
  92.         32 : FILE_PATH+"32.dds",
  93.         33 : FILE_PATH+"33.dds",
  94.     }
  95.  
  96.     def __init__(self):
  97.         ui.ExpandedImageBox.__init__(self)
  98.  
  99.         #self.textLineList = []
  100.         self.toolTip = uiToolTip.ToolTip(100)
  101.         self.toolTip.HideToolTip()
  102.  
  103.     def __GetHorseGrade(self, level):
  104.         if 0 == level:
  105.             return 0
  106.  
  107.         return (level-1)/10 + 1
  108.  
  109.     def SetState(self, level, health, battery):
  110.         #self.textLineList=[]
  111.         self.toolTip.ClearToolTip()
  112.  
  113.         if level>0:
  114.  
  115.             try:
  116.                 grade = self.__GetHorseGrade(level)
  117.                 self.__AppendText(localeInfo.LEVEL_LIST[grade])
  118.             except IndexError:
  119.                 print "HorseImage.SetState(level=%d, health=%d, battery=%d) - Unknown Index" % (level, health, battery)
  120.                 return
  121.  
  122.             try:
  123.                 healthName=localeInfo.HEALTH_LIST[health]
  124.                 if len(healthName)>0:
  125.                     self.__AppendText(healthName)
  126.             except IndexError:
  127.                 print "HorseImage.SetState(level=%d, health=%d, battery=%d) - Unknown Index" % (level, health, battery)
  128.                 return
  129.  
  130.             if health>0:
  131.                 if battery==0:
  132.                     self.__AppendText(localeInfo.NEEFD_REST)
  133.  
  134.             try:
  135.                 fileName=self.FILE_DICT[health*10+battery]
  136.             except KeyError:
  137.                 print "HorseImage.SetState(level=%d, health=%d, battery=%d) - KeyError" % (level, health, battery)
  138.  
  139.             try:
  140.                 self.LoadImage(fileName)
  141.             except:
  142.                 print "HorseImage.SetState(level=%d, health=%d, battery=%d) - LoadError %s" % (level, health, battery, fileName)
  143.  
  144.         self.SetScale(0.7, 0.7)
  145.  
  146.     def __AppendText(self, text):
  147.         self.toolTip.AppendTextLine(text)
  148.         self.toolTip.ResizeToolTip()
  149.  
  150.         #x=self.GetWidth()/2
  151.         #textLine = ui.TextLine()
  152.         #textLine.SetParent(self)
  153.         #textLine.SetSize(0, 0)
  154.         #textLine.SetOutline()
  155.         #textLine.Hide()
  156.         #textLine.SetPosition(x, 40+len(self.textLineList)*16)
  157.         #textLine.SetText(text)
  158.         #self.textLineList.append(textLine)
  159.  
  160.     def OnMouseOverIn(self):
  161.         #for textLine in self.textLineList:
  162.         #   textLine.Show()
  163.  
  164.         self.toolTip.ShowToolTip()
  165.  
  166.     def OnMouseOverOut(self):
  167.         #for textLine in self.textLineList:
  168.         #   textLine.Hide()
  169.  
  170.         self.toolTip.HideToolTip()
  171.  
  172. # AUTO_POTION
  173. class AutoPotionImage(ui.ExpandedImageBox):
  174.  
  175.     FILE_PATH_HP = "d:/ymir work/ui/pattern/auto_hpgauge/"
  176.     FILE_PATH_SP = "d:/ymir work/ui/pattern/auto_spgauge/"
  177.  
  178.     def __init__(self):
  179.         ui.ExpandedImageBox.__init__(self)
  180.  
  181.         self.loverName = ""
  182.         self.lovePoint = 0
  183.         self.potionType = player.AUTO_POTION_TYPE_HP
  184.         self.filePath = ""
  185.  
  186.         self.toolTip = uiToolTip.ToolTip(100)
  187.         self.toolTip.HideToolTip()
  188.  
  189.     def __del__(self):
  190.         ui.ExpandedImageBox.__del__(self)
  191.  
  192.     def SetPotionType(self, type):
  193.         self.potionType = type
  194.        
  195.         if player.AUTO_POTION_TYPE_HP == type:
  196.             self.filePath = self.FILE_PATH_HP
  197.         elif player.AUTO_POTION_TYPE_SP == type:
  198.             self.filePath = self.FILE_PATH_SP
  199.            
  200.  
  201.     def OnUpdateAutoPotionImage(self):
  202.         self.__Refresh()
  203.  
  204.     def __Refresh(self):
  205.         print "__Refresh"
  206.    
  207.         isActivated, currentAmount, totalAmount, slotIndex = player.GetAutoPotionInfo(self.potionType)
  208.        
  209.         amountPercent = (float(currentAmount) / totalAmount) * 100.0
  210.         grade = math.ceil(amountPercent / 20)
  211.        
  212.         if 5.0 > amountPercent:
  213.             grade = 0
  214.            
  215.         if 80.0 < amountPercent:
  216.             grade = 4
  217.             if 90.0 < amountPercent:
  218.                 grade = 5          
  219.  
  220.         fmt = self.filePath + "%.2d.dds"
  221.         fileName = fmt % grade
  222.        
  223.         print self.potionType, amountPercent, fileName
  224.  
  225.         try:
  226.             self.LoadImage(fileName)
  227.         except:
  228.             import dbg
  229.             dbg.TraceError("AutoPotionImage.__Refresh(potionType=%d) - LoadError %s" % (self.potionType, fileName))
  230.  
  231.         self.SetScale(0.7, 0.7)
  232.  
  233.         self.toolTip.ClearToolTip()
  234.        
  235.         if player.AUTO_POTION_TYPE_HP == type:
  236.             self.toolTip.SetTitle(locale.TOOLTIP_AUTO_POTION_HP)
  237.         else:
  238.             self.toolTip.SetTitle(locale.TOOLTIP_AUTO_POTION_SP)
  239.            
  240.         self.toolTip.AppendTextLine(locale.TOOLTIP_AUTO_POTION_REST % (amountPercent))
  241.         self.toolTip.ResizeToolTip()
  242.  
  243.     def OnMouseOverIn(self):
  244.         self.toolTip.ShowToolTip()
  245.  
  246.     def OnMouseOverOut(self):
  247.         self.toolTip.HideToolTip()
  248. # END_OF_AUTO_POTION
  249.  
  250.  
  251. class AffectImage(ui.ExpandedImageBox):
  252.  
  253.     def __init__(self):
  254.         ui.ExpandedImageBox.__init__(self)
  255.  
  256.         self.toolTipText = None
  257.         self.isSkillAffect = True
  258.         self.description = None
  259.         self.endTime = 0
  260.         self.affect = None
  261.         self.isClocked = True
  262.  
  263.     def SetAffect(self, affect):
  264.         self.affect = affect
  265.  
  266.     def GetAffect(self):
  267.         return self.affect
  268.  
  269.     def SetToolTipText(self, text, x = 0, y = -19):
  270.  
  271.         if not self.toolTipText:
  272.             textLine = ui.TextLine()
  273.             textLine.SetParent(self)
  274.             textLine.SetSize(0, 0)
  275.             textLine.SetOutline()
  276.             textLine.Hide()
  277.             self.toolTipText = textLine
  278.            
  279.         self.toolTipText.SetText(text)
  280.         w, h = self.toolTipText.GetTextSize()
  281.         self.toolTipText.SetPosition(max(0, x + self.GetWidth()/2 - w/2), y)
  282.  
  283.     def SetDescription(self, description):
  284.         self.description = description
  285.  
  286.     def SetDuration(self, duration):
  287.         self.endTime = 0
  288.         if duration > 0:
  289.             self.endTime = app.GetGlobalTimeStamp() + duration
  290.  
  291.     def UpdateAutoPotionDescription(self):     
  292.        
  293.         potionType = 0
  294.         if self.affect == chr.NEW_AFFECT_AUTO_HP_RECOVERY:
  295.             potionType = player.AUTO_POTION_TYPE_HP
  296.         else:
  297.             potionType = player.AUTO_POTION_TYPE_SP
  298.        
  299.         isActivated, currentAmount, totalAmount, slotIndex = player.GetAutoPotionInfo(potionType)
  300.        
  301.         #print "UpdateAutoPotionDescription ", isActivated, currentAmount, totalAmount, slotIndex
  302.        
  303.         amountPercent = 0.0
  304.        
  305.         try:
  306.             amountPercent = (float(currentAmount) / totalAmount) * 100.0       
  307.         except:
  308.             amountPercent = 100.0
  309.        
  310.         self.SetToolTipText(self.description % amountPercent, 0, 40)
  311.        
  312.     def SetClock(self, isClocked):
  313.         self.isClocked = isClocked
  314.        
  315.     def UpdateDescription(self):
  316.         if not self.isClocked:
  317.             self.__UpdateDescription2()
  318.             return
  319.    
  320.         if not self.description:
  321.             return
  322.  
  323.         toolTip = self.description
  324.         if self.endTime > 0:
  325.             leftTime = localeInfo.SecondToDHM(self.endTime - app.GetGlobalTimeStamp())
  326.             toolTip += " (%s : %s)" % (localeInfo.LEFT_TIME, leftTime)
  327.         self.SetToolTipText(toolTip, 0, 40)
  328.        
  329.     #µ¶ŔĎąöŔüżˇĽ­ ˝Ă°ŁŔ» Á¦°ĹÇϱâ Ŕ§ÇŘĽ­ »çżë
  330.     def __UpdateDescription2(self):
  331.         if not self.description:
  332.             return
  333.  
  334.         toolTip = self.description
  335.         self.SetToolTipText(toolTip, 0, 40)
  336.  
  337.     def SetSkillAffectFlag(self, flag):
  338.         self.isSkillAffect = flag
  339.  
  340.     def IsSkillAffect(self):
  341.         return self.isSkillAffect
  342.  
  343.     def OnMouseOverIn(self):
  344.         if self.toolTipText:
  345.             self.toolTipText.Show()
  346.  
  347.     def OnMouseOverOut(self):
  348.         if self.toolTipText:
  349.             self.toolTipText.Hide()
  350.  
  351. class AffectShower(ui.Window):
  352.  
  353.     MALL_DESC_IDX_START = 1000
  354.     IMAGE_STEP = 25
  355.     AFFECT_MAX_NUM = 32
  356.  
  357.     INFINITE_AFFECT_DURATION = 0x1FFFFFFF
  358.    
  359.     AFFECT_DATA_DICT =  {
  360.             chr.AFFECT_POISON : (localeInfo.SKILL_TOXICDIE, "d:/ymir work/ui/skill/common/affect/poison.sub"),
  361.             chr.AFFECT_SLOW : (localeInfo.SKILL_SLOW, "d:/ymir work/ui/skill/common/affect/slow.sub"),
  362.             chr.AFFECT_STUN : (localeInfo.SKILL_STUN, "d:/ymir work/ui/skill/common/affect/stun.sub"),
  363.  
  364.             chr.AFFECT_ATT_SPEED_POTION : (localeInfo.SKILL_INC_ATKSPD, "d:/ymir work/ui/skill/common/affect/Increase_Attack_Speed.sub"),
  365.             chr.AFFECT_MOV_SPEED_POTION : (localeInfo.SKILL_INC_MOVSPD, "d:/ymir work/ui/skill/common/affect/Increase_Move_Speed.sub"),
  366.             chr.AFFECT_FISH_MIND : (localeInfo.SKILL_FISHMIND, "d:/ymir work/ui/skill/common/affect/fishmind.sub"),
  367.  
  368.             chr.AFFECT_JEONGWI : (localeInfo.SKILL_JEONGWI, "d:/ymir work/ui/skill/warrior/jeongwi_03.sub",),
  369.             chr.AFFECT_GEOMGYEONG : (localeInfo.SKILL_GEOMGYEONG, "d:/ymir work/ui/skill/warrior/geomgyeong_03.sub",),
  370.             chr.AFFECT_CHEONGEUN : (localeInfo.SKILL_CHEONGEUN, "d:/ymir work/ui/skill/warrior/cheongeun_03.sub",),
  371.             chr.AFFECT_GYEONGGONG : (localeInfo.SKILL_GYEONGGONG, "d:/ymir work/ui/skill/assassin/gyeonggong_03.sub",),
  372.             chr.AFFECT_EUNHYEONG : (localeInfo.SKILL_EUNHYEONG, "d:/ymir work/ui/skill/assassin/eunhyeong_03.sub",),
  373.             chr.AFFECT_GWIGEOM : (localeInfo.SKILL_GWIGEOM, "d:/ymir work/ui/skill/sura/gwigeom_03.sub",),
  374.             chr.AFFECT_GONGPO : (localeInfo.SKILL_GONGPO, "d:/ymir work/ui/skill/sura/gongpo_03.sub",),
  375.             chr.AFFECT_JUMAGAP : (localeInfo.SKILL_JUMAGAP, "d:/ymir work/ui/skill/sura/jumagap_03.sub"),
  376.             chr.AFFECT_HOSIN : (localeInfo.SKILL_HOSIN, "d:/ymir work/ui/skill/shaman/hosin_03.sub",),
  377.             chr.AFFECT_BOHO : (localeInfo.SKILL_BOHO, "d:/ymir work/ui/skill/shaman/boho_03.sub",),
  378.             chr.AFFECT_KWAESOK : (localeInfo.SKILL_KWAESOK, "d:/ymir work/ui/skill/shaman/kwaesok_03.sub",),
  379.             chr.AFFECT_HEUKSIN : (localeInfo.SKILL_HEUKSIN, "d:/ymir work/ui/skill/sura/heuksin_03.sub",),
  380.             chr.AFFECT_MUYEONG : (localeInfo.SKILL_MUYEONG, "d:/ymir work/ui/skill/sura/muyeong_03.sub",),
  381.             chr.AFFECT_GICHEON : (localeInfo.SKILL_GICHEON, "d:/ymir work/ui/skill/shaman/gicheon_03.sub",),
  382.             chr.AFFECT_JEUNGRYEOK : (localeInfo.SKILL_JEUNGRYEOK, "d:/ymir work/ui/skill/shaman/jeungryeok_03.sub",),
  383.             chr.AFFECT_PABEOP : (localeInfo.SKILL_PABEOP, "d:/ymir work/ui/skill/sura/pabeop_03.sub",),
  384.             chr.AFFECT_FALLEN_CHEONGEUN : (localeInfo.SKILL_CHEONGEUN, "d:/ymir work/ui/skill/warrior/cheongeun_03.sub",),
  385.             28 : (localeInfo.SKILL_FIRE, "d:/ymir work/ui/skill/sura/hwayeom_03.sub",),
  386.             chr.AFFECT_CHINA_FIREWORK : (localeInfo.SKILL_POWERFUL_STRIKE, "d:/ymir work/ui/skill/common/affect/powerfulstrike.sub",),
  387.  
  388.             #64 - END
  389.             chr.NEW_AFFECT_EXP_BONUS : (localeInfo.TOOLTIP_MALL_EXPBONUS_STATIC, "d:/ymir work/ui/skill/common/affect/exp_bonus.sub",),
  390.  
  391.             chr.NEW_AFFECT_ITEM_BONUS : (localeInfo.TOOLTIP_MALL_ITEMBONUS_STATIC, "d:/ymir work/ui/skill/common/affect/item_bonus.sub",),
  392.             chr.NEW_AFFECT_SAFEBOX : (localeInfo.TOOLTIP_MALL_SAFEBOX, "d:/ymir work/ui/skill/common/affect/safebox.sub",),
  393.             chr.NEW_AFFECT_AUTOLOOT : (localeInfo.TOOLTIP_MALL_AUTOLOOT, "d:/ymir work/ui/skill/common/affect/autoloot.sub",),
  394.             chr.NEW_AFFECT_FISH_MIND : (localeInfo.TOOLTIP_MALL_FISH_MIND, "d:/ymir work/ui/skill/common/affect/fishmind.sub",),
  395.             chr.NEW_AFFECT_MARRIAGE_FAST : (localeInfo.TOOLTIP_MALL_MARRIAGE_FAST, "d:/ymir work/ui/skill/common/affect/marriage_fast.sub",),
  396.             chr.NEW_AFFECT_GOLD_BONUS : (localeInfo.TOOLTIP_MALL_GOLDBONUS_STATIC, "d:/ymir work/ui/skill/common/affect/gold_bonus.sub",),
  397.  
  398.             chr.NEW_AFFECT_NO_DEATH_PENALTY : (localeInfo.TOOLTIP_APPLY_NO_DEATH_PENALTY, "d:/ymir work/ui/skill/common/affect/gold_premium.sub"),
  399.             chr.NEW_AFFECT_SKILL_BOOK_BONUS : (localeInfo.TOOLTIP_APPLY_SKILL_BOOK_BONUS, "d:/ymir work/ui/skill/common/affect/gold_premium.sub"),
  400.             chr.NEW_AFFECT_SKILL_BOOK_NO_DELAY : (localeInfo.TOOLTIP_APPLY_SKILL_BOOK_NO_DELAY, "d:/ymir work/ui/skill/common/affect/gold_premium.sub"),
  401.            
  402.             # ŔÚµżą°ľŕ hp, sp
  403.             chr.NEW_AFFECT_AUTO_HP_RECOVERY : (localeInfo.TOOLTIP_AUTO_POTION_REST, "d:/ymir work/ui/pattern/auto_hpgauge/05.dds"),        
  404.             chr.NEW_AFFECT_AUTO_SP_RECOVERY : (localeInfo.TOOLTIP_AUTO_POTION_REST, "d:/ymir work/ui/pattern/auto_spgauge/05.dds"),
  405.  
  406.             MALL_DESC_IDX_START+player.POINT_MALL_ATTBONUS : (localeInfo.TOOLTIP_MALL_ATTBONUS_STATIC, "d:/ymir work/ui/skill/common/affect/att_bonus.sub",),
  407.             MALL_DESC_IDX_START+player.POINT_MALL_DEFBONUS : (localeInfo.TOOLTIP_MALL_DEFBONUS_STATIC, "d:/ymir work/ui/skill/common/affect/def_bonus.sub",),
  408.             MALL_DESC_IDX_START+player.POINT_MALL_EXPBONUS : (localeInfo.TOOLTIP_MALL_EXPBONUS, "d:/ymir work/ui/skill/common/affect/exp_bonus.sub",),
  409.             MALL_DESC_IDX_START+player.POINT_MALL_ITEMBONUS : (localeInfo.TOOLTIP_MALL_ITEMBONUS, "d:/ymir work/ui/skill/common/affect/item_bonus.sub",),
  410.             MALL_DESC_IDX_START+player.POINT_MALL_GOLDBONUS : (localeInfo.TOOLTIP_MALL_GOLDBONUS, "d:/ymir work/ui/skill/common/affect/gold_bonus.sub",),
  411.             MALL_DESC_IDX_START+player.POINT_CRITICAL_PCT : (localeInfo.TOOLTIP_APPLY_CRITICAL_PCT,"d:/ymir work/ui/skill/common/affect/critical.sub"),
  412.             MALL_DESC_IDX_START+player.POINT_PENETRATE_PCT : (localeInfo.TOOLTIP_APPLY_PENETRATE_PCT, "d:/ymir work/ui/skill/common/affect/gold_premium.sub"),
  413.             MALL_DESC_IDX_START+player.POINT_MAX_HP_PCT : (localeInfo.TOOLTIP_MAX_HP_PCT, "d:/ymir work/ui/skill/common/affect/gold_premium.sub"),
  414.             MALL_DESC_IDX_START+player.POINT_MAX_SP_PCT : (localeInfo.TOOLTIP_MAX_SP_PCT, "d:/ymir work/ui/skill/common/affect/gold_premium.sub"), 
  415.  
  416.             MALL_DESC_IDX_START+player.POINT_PC_BANG_EXP_BONUS : (localeInfo.TOOLTIP_MALL_EXPBONUS_P_STATIC, "d:/ymir work/ui/skill/common/affect/EXP_Bonus_p_on.sub",),
  417.             MALL_DESC_IDX_START+player.POINT_PC_BANG_DROP_BONUS: (localeInfo.TOOLTIP_MALL_ITEMBONUS_P_STATIC, "d:/ymir work/ui/skill/common/affect/Item_Bonus_p_on.sub",),
  418.     }
  419.  
  420.     def __init__(self):
  421.         ui.Window.__init__(self)
  422.  
  423.         self.serverPlayTime=0
  424.         self.clientPlayTime=0
  425.        
  426.         self.lastUpdateTime=0
  427.         self.affectImageDict={}
  428.         self.horseImage=None
  429.         self.lovePointImage=None
  430.         self.autoPotionImageHP = AutoPotionImage()
  431.         self.autoPotionImageSP = AutoPotionImage()
  432.         self.SetPosition(10, 10)
  433.         self.Show()
  434.  
  435.     def ClearAllAffects(self):
  436.         self.horseImage=None
  437.         self.lovePointImage=None
  438.         self.affectImageDict={}
  439.         self.__ArrangeImageList()
  440.  
  441.     def ClearAffects(self): ## ˝şĹł ŔĚĆĺĆ®¸¸ ľřľŰ´Ď´Ů.
  442.         self.living_affectImageDict={}
  443.         for key, image in self.affectImageDict.items():
  444.             if not image.IsSkillAffect():
  445.                 self.living_affectImageDict[key] = image
  446.         self.affectImageDict = self.living_affectImageDict
  447.         self.__ArrangeImageList()
  448.  
  449.     def BINARY_NEW_AddAffect(self, type, pointIdx, value, duration):
  450.  
  451.         print "BINARY_NEW_AddAffect", type, pointIdx, value, duration
  452.  
  453.         if type < 500:
  454.             return
  455.  
  456.         if type == chr.NEW_AFFECT_MALL:
  457.             affect = self.MALL_DESC_IDX_START + pointIdx
  458.         else:
  459.             affect = type
  460.  
  461.         if self.affectImageDict.has_key(affect):
  462.             return
  463.  
  464.         if not self.AFFECT_DATA_DICT.has_key(affect):
  465.             return
  466.  
  467.         ## żë˝ĹŔÇ °ˇČŁ, Ľ±ŔÎŔÇ ±łČĆŔş Duration Ŕ» 0 Ŕ¸·Î ĽłÁ¤ÇŃ´Ů.
  468.         if affect == chr.NEW_AFFECT_NO_DEATH_PENALTY or\
  469.            affect == chr.NEW_AFFECT_SKILL_BOOK_BONUS or\
  470.            affect == chr.NEW_AFFECT_AUTO_SP_RECOVERY or\
  471.            affect == chr.NEW_AFFECT_AUTO_HP_RECOVERY or\
  472.            affect == chr.NEW_AFFECT_SKILL_BOOK_NO_DELAY:
  473.             duration = 0
  474.  
  475.         affectData = self.AFFECT_DATA_DICT[affect]
  476.         description = affectData[0]
  477.         filename = affectData[1]
  478.  
  479.         if pointIdx == player.POINT_MALL_ITEMBONUS or\
  480.            pointIdx == player.POINT_MALL_GOLDBONUS:
  481.             value = 1 + float(value) / 100.0
  482.  
  483.         trashValue = 123
  484.         #if affect == chr.NEW_AFFECT_AUTO_SP_RECOVERY or affect == chr.NEW_AFFECT_AUTO_HP_RECOVERY:
  485.         if trashValue == 1:
  486.             try:
  487.                 #image = AutoPotionImage()
  488.                 #image.SetParent(self)
  489.                 image = None
  490.                
  491.                 if affect == chr.NEW_AFFECT_AUTO_SP_RECOVERY:
  492.                     image.SetPotionType(player.AUTO_POTION_TYPE_SP)
  493.                     image = self.autoPotionImageSP
  494.                     #self.autoPotionImageSP = image;
  495.                 else:
  496.                     image.SetPotionType(player.AUTO_POTION_TYPE_HP)
  497.                     image = self.autoPotionImageHP
  498.                     #self.autoPotionImageHP = image;
  499.                
  500.                 image.SetParent(self)
  501.                 image.Show()
  502.                 image.OnUpdateAutoPotionImage()
  503.                
  504.                 self.affectImageDict[affect] = image
  505.                 self.__ArrangeImageList()
  506.                
  507.             except Exception, e:
  508.                 print "except Aff auto potion affect ", e
  509.                 pass               
  510.            
  511.         else:
  512.             if affect != chr.NEW_AFFECT_AUTO_SP_RECOVERY and affect != chr.NEW_AFFECT_AUTO_HP_RECOVERY:
  513.                 description = description(float(value))
  514.  
  515.             try:
  516.                 print "Add affect %s" % affect
  517.                 image = AffectImage()
  518.                 image.SetParent(self)
  519.                 image.LoadImage(filename)
  520.                 image.SetDescription(description)
  521.                 image.SetDuration(duration)
  522.                 image.SetAffect(affect)
  523.                 if affect == chr.NEW_AFFECT_EXP_BONUS_EURO_FREE or\
  524.                     affect == chr.NEW_AFFECT_EXP_BONUS_EURO_FREE_UNDER_15 or\
  525.                     self.INFINITE_AFFECT_DURATION < duration:
  526.                     image.SetClock(False)
  527.                     image.UpdateDescription()
  528.                 elif affect == chr.NEW_AFFECT_AUTO_SP_RECOVERY or affect == chr.NEW_AFFECT_AUTO_HP_RECOVERY:
  529.                     image.UpdateAutoPotionDescription()
  530.                 else:
  531.                     image.UpdateDescription()
  532.                    
  533.                 if affect == chr.NEW_AFFECT_DRAGON_SOUL_DECK1 or affect == chr.NEW_AFFECT_DRAGON_SOUL_DECK2:
  534.                     image.SetScale(1, 1)
  535.                 else:
  536.                     image.SetScale(0.7, 0.7)
  537.                 image.SetSkillAffectFlag(False)
  538.                 image.Show()
  539.                 self.affectImageDict[affect] = image
  540.                 self.__ArrangeImageList()
  541.             except Exception, e:
  542.                 print "except Aff affect ", e
  543.                 pass
  544.  
  545.     def BINARY_NEW_RemoveAffect(self, type, pointIdx):
  546.         if type == chr.NEW_AFFECT_MALL:
  547.             affect = self.MALL_DESC_IDX_START + pointIdx
  548.         else:
  549.             affect = type
  550.    
  551.         print "Remove Affect %s %s" % ( type , pointIdx )
  552.         self.__RemoveAffect(affect)
  553.         self.__ArrangeImageList()
  554.  
  555.     def SetAffect(self, affect):
  556.         self.__AppendAffect(affect)
  557.         self.__ArrangeImageList()
  558.  
  559.     def ResetAffect(self, affect):
  560.         self.__RemoveAffect(affect)
  561.         self.__ArrangeImageList()
  562.  
  563.     def SetLoverInfo(self, name, lovePoint):
  564.         image = LovePointImage()
  565.         image.SetParent(self)
  566.         image.SetLoverInfo(name, lovePoint)
  567.         self.lovePointImage = image
  568.         self.__ArrangeImageList()
  569.  
  570.     def ShowLoverState(self):
  571.         if self.lovePointImage:
  572.             self.lovePointImage.Show()
  573.             self.__ArrangeImageList()
  574.  
  575.     def HideLoverState(self):
  576.         if self.lovePointImage:
  577.             self.lovePointImage.Hide()
  578.             self.__ArrangeImageList()
  579.  
  580.     def ClearLoverState(self):
  581.         self.lovePointImage = None
  582.         self.__ArrangeImageList()
  583.  
  584.     def OnUpdateLovePoint(self, lovePoint):
  585.         if self.lovePointImage:
  586.             self.lovePointImage.OnUpdateLovePoint(lovePoint)
  587.  
  588.     def SetHorseState(self, level, health, battery):
  589.         if level==0:
  590.             self.horseImage=None
  591.         else:
  592.             image = HorseImage()
  593.             image.SetParent(self)
  594.             image.SetState(level, health, battery)
  595.             image.Show()
  596.  
  597.             self.horseImage=image
  598.             self.__ArrangeImageList()
  599.  
  600.     def SetPlayTime(self, playTime):
  601.         self.serverPlayTime = playTime
  602.         self.clientPlayTime = app.GetTime()
  603.        
  604.         if locale.IsVIETNAM():     
  605.             image = PlayTimeImage()
  606.             image.SetParent(self)
  607.             image.SetPlayTime(playTime)
  608.             image.Show()
  609.  
  610.             self.playTimeImage=image
  611.             self.__ArrangeImageList()
  612.  
  613.     def __AppendAffect(self, affect):
  614.  
  615.         if self.affectImageDict.has_key(affect):
  616.             return
  617.  
  618.         try:
  619.             affectData = self.AFFECT_DATA_DICT[affect]
  620.         except KeyError:
  621.             return
  622.  
  623.         name = affectData[0]
  624.         filename = affectData[1]
  625.  
  626.         skillIndex = player.AffectIndexToSkillIndex(affect)
  627.         if 0 != skillIndex:
  628.             name = skill.GetSkillName(skillIndex)
  629.  
  630.         image = AffectImage()
  631.         image.SetParent(self)
  632.         image.SetSkillAffectFlag(True)
  633.  
  634.         try:
  635.             image.LoadImage(filename)
  636.         except:
  637.             pass
  638.  
  639.         image.SetToolTipText(name, 0, 40)
  640.         image.SetScale(0.7, 0.7)
  641.         image.Show()
  642.         self.affectImageDict[affect] = image
  643.  
  644.     def __RemoveAffect(self, affect):
  645.         """
  646.         if affect == chr.NEW_AFFECT_AUTO_SP_RECOVERY:
  647.             self.autoPotionImageSP.Hide()
  648.  
  649.         if affect == chr.NEW_AFFECT_AUTO_HP_RECOVERY:
  650.             self.autoPotionImageHP.Hide()
  651.         """
  652.            
  653.         if not self.affectImageDict.has_key(affect):
  654.             print "__RemoveAffect %s ( No Affect )" % affect
  655.             return
  656.  
  657.         print "__RemoveAffect %s ( Affect )" % affect
  658.         del self.affectImageDict[affect]
  659.        
  660.         self.__ArrangeImageList()
  661.  
  662.     def __ArrangeImageList(self):
  663.  
  664.         width = len(self.affectImageDict) * self.IMAGE_STEP
  665.         if self.lovePointImage:
  666.             width+=self.IMAGE_STEP
  667.         if self.horseImage:
  668.             width+=self.IMAGE_STEP
  669.  
  670.         self.SetSize(width, 26)
  671.  
  672.         xPos = 0
  673.  
  674.         if self.lovePointImage:
  675.             if self.lovePointImage.IsShow():
  676.                 self.lovePointImage.SetPosition(xPos, 0)
  677.                 xPos += self.IMAGE_STEP
  678.  
  679.         if self.horseImage:
  680.             self.horseImage.SetPosition(xPos, 0)
  681.             xPos += self.IMAGE_STEP
  682.  
  683.         for image in self.affectImageDict.values():
  684.             image.SetPosition(xPos, 0)
  685.             xPos += self.IMAGE_STEP
  686.  
  687.     def OnUpdate(self):
  688.         try:
  689.             if app.GetGlobalTime() - self.lastUpdateTime > 500:
  690.             #if 0 < app.GetGlobalTime():
  691.                 self.lastUpdateTime = app.GetGlobalTime()
  692.  
  693.                 for image in self.affectImageDict.values():
  694.                     if image.GetAffect() == chr.NEW_AFFECT_AUTO_HP_RECOVERY or image.GetAffect() == chr.NEW_AFFECT_AUTO_SP_RECOVERY:
  695.                         image.UpdateAutoPotionDescription()
  696.                         continue
  697.                        
  698.                     if not image.IsSkillAffect():
  699.                         image.UpdateDescription()
  700.         except Exception, e:
  701.             print "AffectShower::OnUpdate error : ", e
Add Comment
Please, Sign In to add comment