sevastian25

uitooltip.py

Jun 30th, 2025
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 103.08 KB | None | 0 0
  1. import dbg
  2. import player
  3. import item
  4. import grp
  5. import wndMgr
  6. import skill
  7. import shop
  8. import exchange
  9. import grpText
  10. import safebox
  11. import localeInfo
  12. import app
  13. import background
  14. import nonplayer
  15. import chr
  16.  
  17. import ui
  18. import mouseModule
  19. import constInfo
  20. from constInfo import Emoji
  21.  
  22. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  23.     import acce
  24.  
  25. WARP_SCROLLS = [22011, 22000, 22010]
  26.  
  27. DESC_DEFAULT_MAX_COLS = 26
  28. DESC_WESTERN_MAX_COLS = 35
  29. DESC_WESTERN_MAX_WIDTH = 220
  30.  
  31. def Emoji(path):
  32.     return "|E{}|e".format(path)
  33.  
  34. def chop(n):
  35.     return round(n - 0.5, 1)
  36.  
  37. def SplitDescription(desc, limit):
  38.     total_tokens = desc.split()
  39.     line_tokens = []
  40.     line_len = 0
  41.     lines = []
  42.     for token in total_tokens:
  43.         if "|" in token:
  44.             sep_pos = token.find("|")
  45.             line_tokens.append(token[:sep_pos])
  46.  
  47.             lines.append(" ".join(line_tokens))
  48.             line_len = len(token) - (sep_pos + 1)
  49.             line_tokens = [token[sep_pos+1:]]
  50.         else:
  51.             line_len += len(token)
  52.             if len(line_tokens) + line_len > limit:
  53.                 lines.append(" ".join(line_tokens))
  54.                 line_len = len(token)
  55.                 line_tokens = [token]
  56.             else:
  57.                 line_tokens.append(token)
  58.  
  59.     if line_tokens:
  60.         lines.append(" ".join(line_tokens))
  61.  
  62.     return lines
  63.  
  64. ###################################################################################################
  65. ## ToolTip
  66. ##
  67. ##
  68. class ToolTip(ui.ThinBoard):
  69.  
  70.     TOOL_TIP_WIDTH = 190
  71.     TOOL_TIP_HEIGHT = 10
  72.  
  73.     TEXT_LINE_HEIGHT = 17
  74.  
  75.     TITLE_COLOR = grp.GenerateColor(0.9490, 0.9058, 0.7568, 1.0)
  76.     SPECIAL_TITLE_COLOR = grp.GenerateColor(1.0, 0.7843, 0.0, 1.0)
  77.     NORMAL_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  78.     FONT_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  79.     PRICE_COLOR = 0xffFFB96D
  80.  
  81.     HIGH_PRICE_COLOR = SPECIAL_TITLE_COLOR
  82.     MIDDLE_PRICE_COLOR = grp.GenerateColor(0.85, 0.85, 0.85, 1.0)
  83.     LOW_PRICE_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
  84.  
  85.     ENABLE_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  86.     DISABLE_COLOR = grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)
  87.  
  88.     NEGATIVE_COLOR = grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)
  89.     POSITIVE_COLOR = grp.GenerateColor(0.5411, 0.7254, 0.5568, 1.0)
  90.     SPECIAL_POSITIVE_COLOR = grp.GenerateColor(0.6911, 0.8754, 0.7068, 1.0) #bonus 1-4
  91.     SPECIAL_POSITIVE_COLOR2 = grp.GenerateColor(0.8824, 0.9804, 0.8824, 1.0) #bonus 6-7
  92.     SPECIAL_POSITIVE_COLOR5 = grp.GenerateColor(0.7824, 0.9004, 0.8024, 1.0) #bonus 5
  93.  
  94.     CONDITION_COLOR = 0xffBEB47D
  95.     CAN_LEVEL_UP_COLOR = 0xff8EC292
  96.     CANNOT_LEVEL_UP_COLOR = DISABLE_COLOR
  97.     NEED_SKILL_POINT_COLOR = 0xff9A9CDB
  98.  
  99.     def __init__(self, width = TOOL_TIP_WIDTH, isPickable=False):
  100.         ui.ThinBoard.__init__(self, "TOP_MOST")
  101.  
  102.         if isPickable:
  103.             pass
  104.         else:
  105.             self.AddFlag("not_pick")
  106.  
  107.         self.AddFlag("float")
  108.  
  109.         self.followFlag = True
  110.         self.toolTipWidth = width
  111.  
  112.         self.xPos = -1
  113.         self.yPos = -1
  114.  
  115.         self.defFontName = localeInfo.UI_DEF_FONT
  116.         self.ClearToolTip()
  117.  
  118.     def __del__(self):
  119.         ui.ThinBoard.__del__(self)
  120.  
  121.     def ClearToolTip(self):
  122.         self.toolTipHeight = 12
  123.         self.childrenList = []
  124.  
  125.     def SetFollow(self, flag):
  126.         self.followFlag = flag
  127.  
  128.     def SetDefaultFontName(self, fontName):
  129.         self.defFontName = fontName
  130.  
  131.     def AppendSpace(self, size):
  132.         self.toolTipHeight += size
  133.         self.ResizeToolTip()
  134.  
  135.     def AppendTextLineNew(self, text, color = FONT_COLOR, centerAlign = True):
  136.         textLine = ui.TextLine()
  137.         textLine.SetParent(self)
  138.         textLine.SetFontName(self.defFontName)
  139.         textLine.SetPackedFontColor(color)
  140.         textLine.SetText(text)
  141.         textLine.SetOutline()
  142.         textLine.SetFeather(False)
  143.         textLine.Show()
  144.  
  145.         if centerAlign:
  146.             textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  147.             textLine.SetHorizontalAlignCenter()
  148.  
  149.         else:
  150.             textLine.SetPosition(10, self.toolTipHeight)
  151.  
  152.         self.childrenList.append(textLine)
  153.  
  154.         self.toolTipHeight += self.TEXT_LINE_HEIGHT
  155.         self.ResizeToolTip()
  156.  
  157.         return textLine
  158.  
  159.     def AppendHorizontalLine(self):
  160.         for i in xrange(2):
  161.             horizontalLine = ui.Line()
  162.             horizontalLine.SetParent(self)
  163.             horizontalLine.SetPosition(0, self.toolTipHeight + 3 + i)
  164.             horizontalLine.SetWindowHorizontalAlignCenter()
  165.             horizontalLine.SetSize(150, 0)
  166.             horizontalLine.Show()
  167.  
  168.             if 0 == i:
  169.                 horizontalLine.SetColor(0xff555555)
  170.             else:
  171.                 horizontalLine.SetColor(0xff000000)
  172.  
  173.             self.childrenList.append(horizontalLine)
  174.  
  175.         self.toolTipHeight += 11
  176.         self.ResizeToolTip()
  177.  
  178.     if app.ENABLE_DUNGEON_INFO_SYSTEM:
  179.         def TextAlignHorizonalCenter(self):
  180.             for child in self.childrenList:
  181.                 (x, y) = child.GetLocalPosition()
  182.                 try:
  183.                     if child.GetText() != "":
  184.                         child.SetPosition(self.toolTipWidth / 2, y)
  185.                 except:
  186.                     pass
  187.  
  188.             self.ResizeToolTip()
  189.  
  190.     def AlignHorizonalCenter(self):
  191.         for child in self.childrenList:
  192.             (x, y)=child.GetLocalPosition()
  193.             child.SetPosition(self.toolTipWidth/2, y)
  194.  
  195.         self.ResizeToolTip()
  196.  
  197.     def AlignTextLineHorizonalCenter(self):
  198.         for child in self.childrenList:
  199.             if type(child).__name__ == "TextLine":
  200.                 (x, y) = child.GetLocalPosition()
  201.                 child.SetPosition(self.toolTipWidth / 2, y)
  202.  
  203.         self.ResizeToolTip()
  204.  
  205.     def AutoAppendTextLine(self, text, color = FONT_COLOR, centerAlign = True, show = True):
  206.         textLine = ui.TextLine()
  207.         textLine.SetParent(self)
  208.         textLine.SetFontName(self.defFontName)
  209.         textLine.SetPackedFontColor(color)
  210.         textLine.SetText(text)
  211.         textLine.SetOutline()
  212.         textLine.SetFeather(False)
  213.         if show:
  214.             textLine.Show()
  215.  
  216.         self.childrenList.append(textLine)
  217.  
  218.         (textWidth, textHeight)=textLine.GetTextSize()
  219.  
  220.         textWidth += 40
  221.         textHeight += 5
  222.  
  223.         if self.toolTipWidth < textWidth:
  224.             self.toolTipWidth = textWidth
  225.  
  226.         # @fixme017 BEGIN (moved after the set of the new width)
  227.         if centerAlign:
  228.             textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  229.             textLine.SetHorizontalAlignCenter()
  230.         else:
  231.             textLine.SetPosition(10, self.toolTipHeight)
  232.         # @fixme017 END
  233.  
  234.         self.toolTipHeight += textHeight
  235.  
  236.         return textLine
  237.  
  238.     def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True, show = True):
  239.         textLine = ui.TextLine()
  240.         textLine.SetParent(self)
  241.         textLine.SetFontName(self.defFontName)
  242.         textLine.SetPackedFontColor(color)
  243.         textLine.SetText(text)
  244.         textLine.SetOutline()
  245.         textLine.SetFeather(False)
  246.         if show:
  247.             textLine.Show()
  248.  
  249.         if centerAlign:
  250.             textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  251.             textLine.SetHorizontalAlignCenter()
  252.  
  253.         else:
  254.             textLine.SetPosition(10, self.toolTipHeight)
  255.  
  256.         self.childrenList.append(textLine)
  257.  
  258.         self.toolTipHeight += self.TEXT_LINE_HEIGHT
  259.         self.ResizeToolTip()
  260.  
  261.         return textLine
  262.  
  263.     def AppendDescription(self, desc, limit, color = FONT_COLOR):
  264.         if localeInfo.IsEUROPE():
  265.             self.__AppendDescription_WesternLanguage(desc, color)
  266.         else:
  267.             self.__AppendDescription_EasternLanguage(desc, limit, color)
  268.  
  269.     if app.ENABLE_CHEQUE_SYSTEM:
  270.         def SetThinBoardSize(self, width, height = 12) :
  271.             self.toolTipWidth = width
  272.             self.toolTipHeight = height
  273.  
  274.     def __AppendDescription_EasternLanguage(self, description, characterLimitation, color=FONT_COLOR):
  275.         length = len(description)
  276.         if 0 == length:
  277.             return
  278.  
  279.         lineCount = grpText.GetSplitingTextLineCount(description, characterLimitation)
  280.         for i in xrange(lineCount):
  281.             if 0 == i:
  282.                 self.AppendSpace(5)
  283.             self.AppendTextLine(grpText.GetSplitingTextLine(description, characterLimitation, i), color)
  284.  
  285.     def __AppendDescription_WesternLanguage(self, desc, color=FONT_COLOR):
  286.         lines = SplitDescription(desc, DESC_WESTERN_MAX_COLS)
  287.         if not lines:
  288.             return
  289.  
  290.         self.AppendSpace(5)
  291.         for line in lines:
  292.             self.AppendTextLine(line, color)
  293.  
  294.  
  295.     def ResizeToolTip(self):
  296.         self.SetSize(self.toolTipWidth, self.TOOL_TIP_HEIGHT + self.toolTipHeight)
  297.  
  298.     def ResizeToolTipEx(self): # fix: center the image on the price.
  299.         self.SetSize(self.toolTipWidth, self.TOOL_TIP_HEIGHT + self.toolTipHeight + 3)
  300.  
  301.     def ResizeToolTipText(self, x, y):
  302.         self.SetSize(x, y)
  303.  
  304.     def SetTitle(self, name):
  305.         self.AppendTextLine(name, self.TITLE_COLOR)
  306.  
  307.     def GetLimitTextLineColor(self, curValue, limitValue):
  308.         if curValue < limitValue:
  309.             return self.DISABLE_COLOR
  310.  
  311.         return self.ENABLE_COLOR
  312.  
  313.     def GetChangeTextLineColor(self, value, isSpecial=False):
  314.         if value > 0:
  315.             if isSpecial:
  316.                 return self.SPECIAL_POSITIVE_COLOR
  317.             else:
  318.                 return self.POSITIVE_COLOR
  319.  
  320.         if 0 == value:
  321.             return self.NORMAL_COLOR
  322.  
  323.         return self.NEGATIVE_COLOR
  324.  
  325.     def SetToolTipPosition(self, x = -1, y = -1):
  326.         self.xPos = x
  327.         self.yPos = y
  328.  
  329.     def ShowToolTip(self):
  330.         self.SetTop()
  331.         self.Show()
  332.  
  333.         self.OnUpdate()
  334.  
  335.     def HideToolTip(self):
  336.         self.Hide()
  337.  
  338.     def OnUpdate(self):
  339.  
  340.         if not self.followFlag:
  341.             return
  342.  
  343.         x = 0
  344.         y = 0
  345.         width = self.GetWidth()
  346.         height = self.toolTipHeight
  347.  
  348.         if -1 == self.xPos and -1 == self.yPos:
  349.  
  350.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  351.  
  352.             if mouseY < wndMgr.GetScreenHeight() - 300:
  353.                 y = mouseY + 40
  354.             else:
  355.                 y = mouseY - height - 30
  356.  
  357.             x = mouseX - width/2
  358.  
  359.         else:
  360.  
  361.             x = self.xPos - width/2
  362.             y = self.yPos - height
  363.  
  364.         x = max(x, 0)
  365.         y = max(y, 0)
  366.         x = min(x + width/2, wndMgr.GetScreenWidth() - width/2) - width/2
  367.         y = min(y + self.GetHeight(), wndMgr.GetScreenHeight()) - self.GetHeight()
  368.  
  369.         parentWindow = self.GetParentProxy()
  370.         if parentWindow:
  371.             (gx, gy) = parentWindow.GetGlobalPosition()
  372.             x -= gx
  373.             y -= gy
  374.  
  375.         self.SetPosition(x, y)
  376.  
  377. class ItemToolTip(ToolTip):
  378.  
  379.     if app.ENABLE_SEND_TARGET_INFO:
  380.         isStone = False
  381.         isBook = False
  382.         isBook2 = False
  383.  
  384.     CHARACTER_NAMES = (
  385.         "|Eemoji/warrior_m|e",
  386.         "|Eemoji/assassin_w|e",
  387.         "|Eemoji/sura_m|e",
  388.         "|Eemoji/shaman_w|e",
  389.     )
  390.     if app.ENABLE_WOLFMAN_CHARACTER:
  391.         CHARACTER_NAMES += (
  392.             "|Eemoji/wolfman_m|e",
  393.         )
  394.  
  395.     ANTI_FLAG_NAMES = (
  396.         "|Eemoji/anti_drop|e",
  397.         "|Eemoji/anti_sell|e",
  398.         "|Eemoji/anti_exchange|e",
  399.         "|Eemoji/anti_stack|e",
  400.         "|Eemoji/anti_shop|e",
  401.         "|Eemoji/anti_safebox|e",
  402.     )
  403.  
  404.     ANTI_FLAG_COUNT = len(ANTI_FLAG_NAMES)
  405.  
  406.     CHARACTER_COUNT = len(CHARACTER_NAMES)
  407.     WEAR_NAMES = (
  408.         localeInfo.TOOLTIP_ARMOR,
  409.         localeInfo.TOOLTIP_HELMET,
  410.         localeInfo.TOOLTIP_SHOES,
  411.         localeInfo.TOOLTIP_WRISTLET,
  412.         localeInfo.TOOLTIP_WEAPON,
  413.         localeInfo.TOOLTIP_NECK,
  414.         localeInfo.TOOLTIP_EAR,
  415.         localeInfo.TOOLTIP_UNIQUE,
  416.         localeInfo.TOOLTIP_SHIELD,
  417.         localeInfo.TOOLTIP_ARROW,
  418.     )
  419.     WEAR_COUNT = len(WEAR_NAMES)
  420.  
  421.     AFFECT_DICT = {
  422.         item.APPLY_MAX_HP : localeInfo.TOOLTIP_MAX_HP,
  423.         item.APPLY_MAX_SP : localeInfo.TOOLTIP_MAX_SP,
  424.         item.APPLY_CON : localeInfo.TOOLTIP_CON,
  425.         item.APPLY_INT : localeInfo.TOOLTIP_INT,
  426.         item.APPLY_STR : localeInfo.TOOLTIP_STR,
  427.         item.APPLY_DEX : localeInfo.TOOLTIP_DEX,
  428.         item.APPLY_ATT_SPEED : localeInfo.TOOLTIP_ATT_SPEED,
  429.         item.APPLY_MOV_SPEED : localeInfo.TOOLTIP_MOV_SPEED,
  430.         item.APPLY_CAST_SPEED : localeInfo.TOOLTIP_CAST_SPEED,
  431.         item.APPLY_HP_REGEN : localeInfo.TOOLTIP_HP_REGEN,
  432.         item.APPLY_SP_REGEN : localeInfo.TOOLTIP_SP_REGEN,
  433.         item.APPLY_POISON_PCT : localeInfo.TOOLTIP_APPLY_POISON_PCT,
  434.         item.APPLY_STUN_PCT : localeInfo.TOOLTIP_APPLY_STUN_PCT,
  435.         item.APPLY_SLOW_PCT : localeInfo.TOOLTIP_APPLY_SLOW_PCT,
  436.         item.APPLY_CRITICAL_PCT : localeInfo.TOOLTIP_APPLY_CRITICAL_PCT,
  437.         item.APPLY_PENETRATE_PCT : localeInfo.TOOLTIP_APPLY_PENETRATE_PCT,
  438.  
  439.         item.APPLY_ATTBONUS_WARRIOR : localeInfo.TOOLTIP_APPLY_ATTBONUS_WARRIOR,
  440.         item.APPLY_ATTBONUS_ASSASSIN : localeInfo.TOOLTIP_APPLY_ATTBONUS_ASSASSIN,
  441.         item.APPLY_ATTBONUS_SURA : localeInfo.TOOLTIP_APPLY_ATTBONUS_SURA,
  442.         item.APPLY_ATTBONUS_SHAMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_SHAMAN,
  443.         item.APPLY_ATTBONUS_MONSTER : localeInfo.TOOLTIP_APPLY_ATTBONUS_MONSTER,
  444.  
  445.         item.APPLY_ATTBONUS_HUMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_HUMAN,
  446.         item.APPLY_ATTBONUS_ANIMAL : localeInfo.TOOLTIP_APPLY_ATTBONUS_ANIMAL,
  447.         item.APPLY_ATTBONUS_ORC : localeInfo.TOOLTIP_APPLY_ATTBONUS_ORC,
  448.         item.APPLY_ATTBONUS_MILGYO : localeInfo.TOOLTIP_APPLY_ATTBONUS_MILGYO,
  449.         item.APPLY_ATTBONUS_UNDEAD : localeInfo.TOOLTIP_APPLY_ATTBONUS_UNDEAD,
  450.         item.APPLY_ATTBONUS_DEVIL : localeInfo.TOOLTIP_APPLY_ATTBONUS_DEVIL,
  451.         item.APPLY_STEAL_HP : localeInfo.TOOLTIP_APPLY_STEAL_HP,
  452.         item.APPLY_STEAL_SP : localeInfo.TOOLTIP_APPLY_STEAL_SP,
  453.         item.APPLY_MANA_BURN_PCT : localeInfo.TOOLTIP_APPLY_MANA_BURN_PCT,
  454.         item.APPLY_DAMAGE_SP_RECOVER : localeInfo.TOOLTIP_APPLY_DAMAGE_SP_RECOVER,
  455.         item.APPLY_BLOCK : localeInfo.TOOLTIP_APPLY_BLOCK,
  456.         item.APPLY_DODGE : localeInfo.TOOLTIP_APPLY_DODGE,
  457.         item.APPLY_RESIST_SWORD : localeInfo.TOOLTIP_APPLY_RESIST_SWORD,
  458.         item.APPLY_RESIST_TWOHAND : localeInfo.TOOLTIP_APPLY_RESIST_TWOHAND,
  459.         item.APPLY_RESIST_DAGGER : localeInfo.TOOLTIP_APPLY_RESIST_DAGGER,
  460.         item.APPLY_RESIST_BELL : localeInfo.TOOLTIP_APPLY_RESIST_BELL,
  461.         item.APPLY_RESIST_FAN : localeInfo.TOOLTIP_APPLY_RESIST_FAN,
  462.         item.APPLY_RESIST_BOW : localeInfo.TOOLTIP_RESIST_BOW,
  463.         item.APPLY_RESIST_FIRE : localeInfo.TOOLTIP_RESIST_FIRE,
  464.         item.APPLY_RESIST_ELEC : localeInfo.TOOLTIP_RESIST_ELEC,
  465.         item.APPLY_RESIST_MAGIC : localeInfo.TOOLTIP_RESIST_MAGIC,
  466.         item.APPLY_RESIST_WIND : localeInfo.TOOLTIP_APPLY_RESIST_WIND,
  467.         item.APPLY_REFLECT_MELEE : localeInfo.TOOLTIP_APPLY_REFLECT_MELEE,
  468.         item.APPLY_REFLECT_CURSE : localeInfo.TOOLTIP_APPLY_REFLECT_CURSE,
  469.         item.APPLY_POISON_REDUCE : localeInfo.TOOLTIP_APPLY_POISON_REDUCE,
  470.         item.APPLY_KILL_SP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_SP_RECOVER,
  471.         item.APPLY_EXP_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_EXP_DOUBLE_BONUS,
  472.         item.APPLY_GOLD_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_GOLD_DOUBLE_BONUS,
  473.         item.APPLY_ITEM_DROP_BONUS : localeInfo.TOOLTIP_APPLY_ITEM_DROP_BONUS,
  474.         item.APPLY_POTION_BONUS : localeInfo.TOOLTIP_APPLY_POTION_BONUS,
  475.         item.APPLY_KILL_HP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_HP_RECOVER,
  476.         item.APPLY_IMMUNE_STUN : localeInfo.TOOLTIP_APPLY_IMMUNE_STUN,
  477.         item.APPLY_IMMUNE_SLOW : localeInfo.TOOLTIP_APPLY_IMMUNE_SLOW,
  478.         item.APPLY_IMMUNE_FALL : localeInfo.TOOLTIP_APPLY_IMMUNE_FALL,
  479.         item.APPLY_BOW_DISTANCE : localeInfo.TOOLTIP_BOW_DISTANCE,
  480.         item.APPLY_DEF_GRADE_BONUS : localeInfo.TOOLTIP_DEF_GRADE,
  481.         item.APPLY_ATT_GRADE_BONUS : localeInfo.TOOLTIP_ATT_GRADE,
  482.         item.APPLY_MAGIC_ATT_GRADE : localeInfo.TOOLTIP_MAGIC_ATT_GRADE,
  483.         item.APPLY_MAGIC_DEF_GRADE : localeInfo.TOOLTIP_MAGIC_DEF_GRADE,
  484.         item.APPLY_MAX_STAMINA : localeInfo.TOOLTIP_MAX_STAMINA,
  485.         item.APPLY_MALL_ATTBONUS : localeInfo.TOOLTIP_MALL_ATTBONUS,
  486.         item.APPLY_MALL_DEFBONUS : localeInfo.TOOLTIP_MALL_DEFBONUS,
  487.         item.APPLY_MALL_EXPBONUS : localeInfo.TOOLTIP_MALL_EXPBONUS,
  488.         item.APPLY_MALL_ITEMBONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS,
  489.         item.APPLY_MALL_GOLDBONUS : localeInfo.TOOLTIP_MALL_GOLDBONUS,
  490.         item.APPLY_SKILL_DAMAGE_BONUS : localeInfo.TOOLTIP_SKILL_DAMAGE_BONUS,
  491.         item.APPLY_NORMAL_HIT_DAMAGE_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DAMAGE_BONUS,
  492.         item.APPLY_SKILL_DEFEND_BONUS : localeInfo.TOOLTIP_SKILL_DEFEND_BONUS,
  493.         item.APPLY_NORMAL_HIT_DEFEND_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DEFEND_BONUS,
  494.         item.APPLY_PC_BANG_EXP_BONUS : localeInfo.TOOLTIP_MALL_EXPBONUS_P_STATIC,
  495.         item.APPLY_PC_BANG_DROP_BONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS_P_STATIC,
  496.         item.APPLY_RESIST_WARRIOR : localeInfo.TOOLTIP_APPLY_RESIST_WARRIOR,
  497.         item.APPLY_RESIST_ASSASSIN : localeInfo.TOOLTIP_APPLY_RESIST_ASSASSIN,
  498.         item.APPLY_RESIST_SURA : localeInfo.TOOLTIP_APPLY_RESIST_SURA,
  499.         item.APPLY_RESIST_SHAMAN : localeInfo.TOOLTIP_APPLY_RESIST_SHAMAN,
  500.         item.APPLY_MAX_HP_PCT : localeInfo.TOOLTIP_APPLY_MAX_HP_PCT,
  501.         item.APPLY_MAX_SP_PCT : localeInfo.TOOLTIP_APPLY_MAX_SP_PCT,
  502.         item.APPLY_ENERGY : localeInfo.TOOLTIP_ENERGY,
  503.         item.APPLY_COSTUME_ATTR_BONUS : localeInfo.TOOLTIP_COSTUME_ATTR_BONUS,
  504.  
  505.         item.APPLY_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MAGIC_ATTBONUS_PER,
  506.         item.APPLY_MELEE_MAGIC_ATTBONUS_PER : localeInfo.TOOLTIP_MELEE_MAGIC_ATTBONUS_PER,
  507.         item.APPLY_RESIST_ICE : localeInfo.TOOLTIP_RESIST_ICE,
  508.         item.APPLY_RESIST_EARTH : localeInfo.TOOLTIP_RESIST_EARTH,
  509.         item.APPLY_RESIST_DARK : localeInfo.TOOLTIP_RESIST_DARK,
  510.         item.APPLY_ANTI_CRITICAL_PCT : localeInfo.TOOLTIP_ANTI_CRITICAL_PCT,
  511.         item.APPLY_ANTI_PENETRATE_PCT : localeInfo.TOOLTIP_ANTI_PENETRATE_PCT,
  512.         item.APPLY_ATTBONUS_CZ : localeInfo.TOOLTIP_APPLY_ATTBONUS_CZ,
  513.         item.APPLY_ATTBONUS_INSECT : localeInfo.TOOLTIP_APPLY_ATTBONUS_INSECT,
  514.         item.APPLY_ATTBONUS_DESERT : localeInfo.TOOLTIP_APPLY_ATTBONUS_DESERT,
  515.         item.APPLY_ATTBONUS_SWORD : localeInfo.TOOLTIP_APPLY_ATTBONUS_SWORD,
  516.         item.APPLY_ATTBONUS_TWOHAND : localeInfo.TOOLTIP_APPLY_ATTBONUS_TWOHAND,
  517.         item.APPLY_ATTBONUS_DAGGER : localeInfo.TOOLTIP_APPLY_ATTBONUS_DAGGER,
  518.         item.APPLY_ATTBONUS_BELL : localeInfo.TOOLTIP_APPLY_ATTBONUS_BELL,
  519.         item.APPLY_ATTBONUS_FAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_FAN,
  520.         item.APPLY_ATTBONUS_BOW : localeInfo.TOOLTIP_APPLY_ATTBONUS_BOW,
  521.         item.APPLY_RESIST_HUMAN : localeInfo.TOOLTIP_APPLY_RESIST_HUMAN,
  522.         item.APPLY_RESIST_MOUNT_FALL : localeInfo.TOOLTIP_APPLY_RESIST_MOUNT_FALL,
  523.     }
  524.  
  525.     if app.ENABLE_WOLFMAN_CHARACTER:
  526.         AFFECT_DICT.update({
  527.             item.APPLY_BLEEDING_PCT : localeInfo.TOOLTIP_APPLY_BLEEDING_PCT,
  528.             item.APPLY_BLEEDING_REDUCE : localeInfo.TOOLTIP_APPLY_BLEEDING_REDUCE,
  529.             item.APPLY_ATTBONUS_WOLFMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_WOLFMAN,
  530.             item.APPLY_RESIST_CLAW : localeInfo.TOOLTIP_APPLY_RESIST_CLAW,
  531.             item.APPLY_RESIST_WOLFMAN : localeInfo.TOOLTIP_APPLY_RESIST_WOLFMAN,
  532.             item.APPLY_ATTBONUS_CLAW : localeInfo.TOOLTIP_APPLY_ATTBONUS_CLAW,
  533.         })
  534.  
  535.     if app.ENABLE_MAGIC_REDUCTION_SYSTEM:
  536.         AFFECT_DICT.update({
  537.             item.APPLY_RESIST_MAGIC_REDUCTION : localeInfo.TOOLTIP_RESIST_MAGIC_REDUCTION,
  538.         })
  539.  
  540.     AFFECT_DICT.update({
  541.         item.APPLY_ENCHANT_ELECT : localeInfo.TOOLTIP_APPLY_ENCHANT_ELECT,
  542.         item.APPLY_ENCHANT_FIRE : localeInfo.TOOLTIP_APPLY_ENCHANT_FIRE,
  543.         item.APPLY_ENCHANT_ICE : localeInfo.TOOLTIP_APPLY_ENCHANT_ICE,
  544.         item.APPLY_ENCHANT_WIND : localeInfo.TOOLTIP_APPLY_ENCHANT_WIND,
  545.         item.APPLY_ENCHANT_EARTH : localeInfo.TOOLTIP_APPLY_ENCHANT_EARTH,
  546.         item.APPLY_ENCHANT_DARK : localeInfo.TOOLTIP_APPLY_ENCHANT_DARK,
  547.     })
  548.  
  549.     ATTRIBUTE_NEED_WIDTH = {
  550.         23 : 230,
  551.         24 : 230,
  552.         25 : 230,
  553.         26 : 220,
  554.         27 : 210,
  555.  
  556.         35 : 210,
  557.         36 : 210,
  558.         37 : 210,
  559.         38 : 210,
  560.         39 : 210,
  561.         40 : 210,
  562.         41 : 210,
  563.  
  564.         42 : 220,
  565.         43 : 230,
  566.         45 : 230,
  567.     }
  568.  
  569.     ANTI_FLAG_DICT = {
  570.         0 : item.ITEM_ANTIFLAG_WARRIOR,
  571.         1 : item.ITEM_ANTIFLAG_ASSASSIN,
  572.         2 : item.ITEM_ANTIFLAG_SURA,
  573.         3 : item.ITEM_ANTIFLAG_SHAMAN,
  574.     }
  575.     if app.ENABLE_WOLFMAN_CHARACTER:
  576.         ANTI_FLAG_DICT.update({
  577.             4 : item.ITEM_ANTIFLAG_WOLFMAN,
  578.         })
  579.  
  580.     FONT_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  581.  
  582.     def __init__(self, *args, **kwargs):
  583.         ToolTip.__init__(self, *args, **kwargs)
  584.         self.itemVnum = 0
  585.         self.metinSlot = []
  586.         self.isShopItem = False
  587.  
  588.         self.bCannotUseItemForceSetDisableColor = True
  589.  
  590.     def __del__(self):
  591.         ToolTip.__del__(self)
  592.         self.metinSlot = None
  593.  
  594.     def SetCannotUseItemForceSetDisableColor(self, enable):
  595.         self.bCannotUseItemForceSetDisableColor = enable
  596.  
  597.     def CanEquip(self):
  598.         if not item.IsEquipmentVID(self.itemVnum):
  599.             return True
  600.  
  601.         race = player.GetRace()
  602.         job = chr.RaceToJob(race)
  603.         if not self.ANTI_FLAG_DICT.has_key(job):
  604.             return False
  605.  
  606.         if item.IsAntiFlag(self.ANTI_FLAG_DICT[job]):
  607.             return False
  608.  
  609.         sex = chr.RaceToSex(race)
  610.  
  611.         MALE = 1
  612.         FEMALE = 0
  613.  
  614.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_MALE) and sex == MALE:
  615.             return False
  616.  
  617.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_FEMALE) and sex == FEMALE:
  618.             return False
  619.  
  620.         for i in xrange(item.LIMIT_MAX_NUM):
  621.             (limitType, limitValue) = item.GetLimit(i)
  622.  
  623.             if item.LIMIT_LEVEL == limitType:
  624.                 if player.GetStatus(player.LEVEL) < limitValue:
  625.                     return False
  626.             """
  627.             elif item.LIMIT_STR == limitType:
  628.                 if player.GetStatus(player.ST) < limitValue:
  629.                     return False
  630.             elif item.LIMIT_DEX == limitType:
  631.                 if player.GetStatus(player.DX) < limitValue:
  632.                     return False
  633.             elif item.LIMIT_INT == limitType:
  634.                 if player.GetStatus(player.IQ) < limitValue:
  635.                     return False
  636.             elif item.LIMIT_CON == limitType:
  637.                 if player.GetStatus(player.HT) < limitValue:
  638.                     return False
  639.             """
  640.  
  641.         return True
  642.  
  643.     def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = True):
  644.         if not self.CanEquip() and self.bCannotUseItemForceSetDisableColor:
  645.             color = self.DISABLE_COLOR
  646.  
  647.         return ToolTip.AppendTextLine(self, text, color, centerAlign)
  648.  
  649.     def ClearToolTip(self):
  650.         self.isShopItem = False
  651.         self.toolTipWidth = self.TOOL_TIP_WIDTH
  652.         ToolTip.ClearToolTip(self)
  653.  
  654.     def SetInventoryItem(self, slotIndex, window_type = player.INVENTORY):
  655.         itemVnum = player.GetItemIndex(window_type, slotIndex)
  656.         if 0 == itemVnum:
  657.             return
  658.  
  659.         self.ClearToolTip()
  660.         if shop.IsOpen():
  661.             if not shop.IsPrivateShop():
  662.                 item.SelectItem(itemVnum)
  663.                 if app.ENABLE_CHEQUE_SYSTEM:
  664.                     self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_SELL_PRICE, grp.GenerateColor(1.0, 0.9686, 0.3098, 1.0))
  665.                     self.AppendSellingPrice(player.GetISellItemPrice(window_type, slotIndex))
  666.                 else:
  667.                     self.AppendSellingPrice(player.GetISellItemPrice(window_type, slotIndex))
  668.  
  669.         metinSlot = [player.GetItemMetinSocket(window_type, slotIndex, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
  670.         attrSlot = [player.GetItemAttribute(window_type, slotIndex, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  671.  
  672.         self.AddItemData(itemVnum, metinSlot, attrSlot, 0, 0, window_type, slotIndex)
  673.  
  674.         if app.QUICK_SELL_SYSTEM:
  675.             self.AppendQuckSellItem(slotIndex)
  676.  
  677.         if app.ENABLE_IKASHOP_RENEWAL:
  678.             if app.EXTEND_IKASHOP_ULTIMATE:
  679.                 if itemVnum == 51998:
  680.                     self.AppendTextLine(localeInfo.IKASHOP_ULTIMATE_SHOP_PRIVATE_KEY_MULTIUSE_TOOLTIP)
  681.  
  682.     def SetShopItem(self, slotIndex):
  683.         itemVnum = shop.GetItemID(slotIndex)
  684.         if 0 == itemVnum:
  685.             return
  686.  
  687.         price = shop.GetItemPrice(slotIndex)
  688.         if app.ENABLE_CHEQUE_SYSTEM:
  689.             cheque = shop.GetItemCheque(slotIndex)
  690.         self.ClearToolTip()
  691.         self.isShopItem = True
  692.  
  693.         metinSlot = []
  694.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  695.             metinSlot.append(shop.GetItemMetinSocket(slotIndex, i))
  696.         attrSlot = []
  697.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  698.             attrSlot.append(shop.GetItemAttribute(slotIndex, i))
  699.  
  700.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  701.         if app.ENABLE_CHEQUE_SYSTEM:
  702.             self.AppendSpace(5)
  703.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_SELL_PRICE, grp.GenerateColor(1.0, 0.9686, 0.3098, 1.0))
  704.             self.AppendCheque(cheque)
  705.             self.AppendPrice(price)
  706.         else:
  707.             self.AppendPrice(price)
  708.  
  709.     if app.ENABLE_SEND_TARGET_INFO:
  710.         def SetItemToolTipStone(self, itemVnum):
  711.             self.itemVnum = itemVnum
  712.             item.SelectItem(itemVnum)
  713.             itemType = item.GetItemType()
  714.  
  715.             itemDesc = item.GetItemDescription()
  716.             itemSummary = item.GetItemSummary()
  717.             attrSlot = 0
  718.             self.__AdjustMaxWidth(attrSlot, itemDesc)
  719.             itemName = item.GetItemName()
  720.             realName = itemName[:itemName.find("+")]
  721.             self.SetTitle(realName + " +0 - +4")
  722.  
  723.             ## Description ###
  724.             self.AppendDescription(itemDesc, 26)
  725.             self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
  726.  
  727.             if item.ITEM_TYPE_METIN == itemType:
  728.                 self.AppendMetinInformation()
  729.                 self.AppendMetinWearInformation()
  730.  
  731.             for i in xrange(item.LIMIT_MAX_NUM):
  732.                 (limitType, limitValue) = item.GetLimit(i)
  733.  
  734.                 if item.LIMIT_REAL_TIME_START_FIRST_USE == limitType:
  735.                     self.AppendRealTimeStartFirstUseLastTime(item, metinSlot, i)
  736.  
  737.                 elif item.LIMIT_TIMER_BASED_ON_WEAR == limitType:
  738.                     self.AppendTimerBasedOnWearLastTime(metinSlot)
  739.  
  740.             self.ShowToolTip()
  741.  
  742.     if app.ENABLE_RENEWAL_SHOPEX:
  743.         def SetShopItemByShopEx(self, slotIndex, type):
  744.             itemVnum = shop.GetItemID(slotIndex)
  745.             PriceVnum = shop.GetItemPriceVnum(slotIndex)
  746.             if itemVnum == 0 or (PriceVnum == 0 and type == shop.SHOPEX_ITEM):
  747.                 return
  748.             price = shop.GetItemPrice(slotIndex)
  749.             self.ClearToolTip()
  750.             self.isShopItem = True
  751.             metinSlot = []
  752.             for i in xrange(player.METIN_SOCKET_MAX_NUM):
  753.                 metinSlot.append(shop.GetItemMetinSocket(slotIndex, i))
  754.             attrSlot = []
  755.             for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  756.                 attrSlot.append(shop.GetItemAttribute(slotIndex, i))
  757.             self.AddItemData(itemVnum, metinSlot, attrSlot)
  758.             self.AppendSpace(5)
  759.             if type == shop.SHOPEX_ITEM:
  760.                 self.AddSHOPEXItem(PriceVnum, price)
  761.             else:
  762.                 self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE  % (localeInfo.NumberToShopEXP(price)), self.GetPriceColor(price))
  763.  
  764.         def AddSHOPEXItem(self, itemVnum, price):
  765.             self.AppendTextLine("Price:")
  766.             item.SelectItem(itemVnum)
  767.             name = "%s(%dx)" % (item.GetItemName(), price)
  768.             self.AutoAppendTextLine(name, self.SPECIAL_TITLE_COLOR)
  769.             itemImage = ui.ImageBox()
  770.             itemImage.SetParent(self)
  771.             itemImage.Show()
  772.             itemImage.LoadImage(item.GetIconImageFileName())
  773.             itemImage.SetPosition(self.toolTipWidth / 2 - 16, self.toolTipHeight + 2.5)
  774.             self.toolTipHeight += itemImage.GetHeight() + 2.5
  775.             self.childrenList.append(itemImage)
  776.             self.ResizeToolTipEx()
  777.  
  778.     def SetShopItemBySecondaryCoin(self, slotIndex):
  779.         itemVnum = shop.GetItemID(slotIndex)
  780.         if 0 == itemVnum:
  781.             return
  782.  
  783.         price = shop.GetItemPrice(slotIndex)
  784.         self.ClearToolTip()
  785.         self.isShopItem = True
  786.  
  787.         metinSlot = []
  788.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  789.             metinSlot.append(shop.GetItemMetinSocket(slotIndex, i))
  790.         attrSlot = []
  791.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  792.             attrSlot.append(shop.GetItemAttribute(slotIndex, i))
  793.  
  794.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  795.         self.AppendPriceBySecondaryCoin(price)
  796.  
  797.     def SetExchangeOwnerItem(self, slotIndex):
  798.         itemVnum = exchange.GetItemVnumFromSelf(slotIndex)
  799.         if 0 == itemVnum:
  800.             return
  801.  
  802.         self.ClearToolTip()
  803.  
  804.         metinSlot = []
  805.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  806.             metinSlot.append(exchange.GetItemMetinSocketFromSelf(slotIndex, i))
  807.         attrSlot = []
  808.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  809.             attrSlot.append(exchange.GetItemAttributeFromSelf(slotIndex, i))
  810.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  811.  
  812.     def SetExchangeTargetItem(self, slotIndex):
  813.         itemVnum = exchange.GetItemVnumFromTarget(slotIndex)
  814.         if 0 == itemVnum:
  815.             return
  816.  
  817.         self.ClearToolTip()
  818.  
  819.         metinSlot = []
  820.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  821.             metinSlot.append(exchange.GetItemMetinSocketFromTarget(slotIndex, i))
  822.         attrSlot = []
  823.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  824.             attrSlot.append(exchange.GetItemAttributeFromTarget(slotIndex, i))
  825.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  826.  
  827.     def SetPrivateShopBuilderItem(self, invenType, invenPos, privateShopSlotIndex):
  828.         itemVnum = player.GetItemIndex(invenType, invenPos)
  829.         if 0 == itemVnum:
  830.             return
  831.  
  832.         item.SelectItem(itemVnum)
  833.         self.ClearToolTip()
  834.         if app.ENABLE_CHEQUE_SYSTEM:
  835.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_SELL_PRICE, grp.GenerateColor(1.0, 0.9686, 0.3098, 1.0))
  836.             self.AppendSellingCheque(shop.GetPrivateShopItemCheque(invenType, invenPos))
  837.             self.AppendSellingPrice(shop.GetPrivateShopItemPrice(invenType, invenPos))
  838.         else:
  839.             self.AppendSellingPrice(shop.GetPrivateShopItemPrice(invenType, invenPos))
  840.  
  841.         metinSlot = []
  842.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  843.             metinSlot.append(player.GetItemMetinSocket(invenPos, i))
  844.         attrSlot = []
  845.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  846.             attrSlot.append(player.GetItemAttribute(invenPos, i))
  847.  
  848.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  849.  
  850.     def SetSafeBoxItem(self, slotIndex):
  851.         itemVnum = safebox.GetItemID(slotIndex)
  852.         if 0 == itemVnum:
  853.             return
  854.  
  855.         self.ClearToolTip()
  856.         metinSlot = []
  857.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  858.             metinSlot.append(safebox.GetItemMetinSocket(slotIndex, i))
  859.         attrSlot = []
  860.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  861.             attrSlot.append(safebox.GetItemAttribute(slotIndex, i))
  862.  
  863.         self.AddItemData(itemVnum, metinSlot, attrSlot, safebox.GetItemFlags(slotIndex))
  864.  
  865.     def SetMallItem(self, slotIndex):
  866.         itemVnum = safebox.GetMallItemID(slotIndex)
  867.         if 0 == itemVnum:
  868.             return
  869.  
  870.         self.ClearToolTip()
  871.         metinSlot = []
  872.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  873.             metinSlot.append(safebox.GetMallItemMetinSocket(slotIndex, i))
  874.         attrSlot = []
  875.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  876.             attrSlot.append(safebox.GetMallItemAttribute(slotIndex, i))
  877.  
  878.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  879.  
  880.     def SetItemToolTip(self, itemVnum):
  881.         self.ClearToolTip()
  882.         metinSlot = []
  883.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  884.             metinSlot.append(0)
  885.         attrSlot = []
  886.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  887.             attrSlot.append((0, 0))
  888.  
  889.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  890.  
  891.     def __AppendAttackSpeedInfo(self, item):
  892.         atkSpd = item.GetValue(0)
  893.  
  894.         if atkSpd < 80:
  895.             stSpd = localeInfo.TOOLTIP_ITEM_VERY_FAST
  896.         elif atkSpd <= 95:
  897.             stSpd = localeInfo.TOOLTIP_ITEM_FAST
  898.         elif atkSpd <= 105:
  899.             stSpd = localeInfo.TOOLTIP_ITEM_NORMAL
  900.         elif atkSpd <= 120:
  901.             stSpd = localeInfo.TOOLTIP_ITEM_SLOW
  902.         else:
  903.             stSpd = localeInfo.TOOLTIP_ITEM_VERY_SLOW
  904.  
  905.         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_SPEED % stSpd, self.NORMAL_COLOR)
  906.  
  907.     def __AppendAttackGradeInfo(self):
  908.         atkGrade = item.GetValue(1)
  909.         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_GRADE % atkGrade, self.GetChangeTextLineColor(atkGrade))
  910.  
  911.     if app.ENABLE_ACCE_COSTUME_SYSTEM:
  912.         def CalcAcceValue(self, value, abs):
  913.             if not value:
  914.                 return 0
  915.  
  916.             valueCalc   = round(value * abs) / 100
  917.             valueCalc   -= 0.5
  918.             valueCalc   = int(valueCalc) +1 if valueCalc > 0 else int(valueCalc)
  919.             value       = 1 if (valueCalc <= 0 and value > 0) else valueCalc
  920.             return value
  921.  
  922.     def __AppendAttackPowerInfo(self, itemAbsChance = 0):
  923.         minPower = item.GetValue(3)
  924.         maxPower = item.GetValue(4)
  925.         addPower = item.GetValue(5)
  926.         if app.ENABLE_ACCE_COSTUME_SYSTEM:
  927.             if itemAbsChance != 0:
  928.                 minPower = self.CalcAcceValue(minPower, itemAbsChance)
  929.                 maxPower = self.CalcAcceValue(maxPower, itemAbsChance)
  930.                 addPower = self.CalcAcceValue(addPower, itemAbsChance)
  931.  
  932.         if maxPower > minPower:
  933.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_POWER % (minPower+addPower, maxPower+addPower), self.POSITIVE_COLOR)
  934.         else:
  935.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_POWER_ONE_ARG % (minPower+addPower), self.POSITIVE_COLOR)
  936.  
  937.     def __AppendMagicAttackInfo(self, itemAbsChance = 0):
  938.         minMagicAttackPower = item.GetValue(1)
  939.         maxMagicAttackPower = item.GetValue(2)
  940.         addPower            = item.GetValue(5)
  941.         if app.ENABLE_ACCE_COSTUME_SYSTEM:
  942.             if itemAbsChance != 0:
  943.                 minMagicAttackPower = self.CalcAcceValue(minMagicAttackPower, itemAbsChance)
  944.                 maxMagicAttackPower = self.CalcAcceValue(maxMagicAttackPower, itemAbsChance)
  945.                 addPower            = self.CalcAcceValue(addPower, itemAbsChance)
  946.  
  947.         if minMagicAttackPower > 0 or maxMagicAttackPower > 0:
  948.             if maxMagicAttackPower > minMagicAttackPower:
  949.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_ATT_POWER % (minMagicAttackPower+addPower, maxMagicAttackPower+addPower), self.POSITIVE_COLOR)
  950.             else:
  951.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_ATT_POWER_ONE_ARG % (minMagicAttackPower+addPower), self.POSITIVE_COLOR)
  952.  
  953.     def __AppendMagicDefenceInfo(self, itemAbsChance = 0):
  954.         magicDefencePower = item.GetValue(0)
  955.         if app.ENABLE_ACCE_COSTUME_SYSTEM:
  956.             if itemAbsChance != 0:
  957.                 magicDefencePower = self.CalcAcceValue(magicDefencePower, itemAbsChance)
  958.  
  959.         if magicDefencePower > 0:
  960.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_DEF_POWER % magicDefencePower, self.GetChangeTextLineColor(magicDefencePower))
  961.  
  962.     if app.ENABLE_IKASHOP_RENEWAL:
  963.         def AppendAttributes(self, attrs):
  964.             attrs = list(attrs)
  965.             for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM - len(attrs)):
  966.                 attrs.append((0,0))
  967.             self.__AppendAttributeInformation(attrs)
  968.  
  969.     def __AppendAttributeInformation(self, attrSlot, itemAbsChance = 0):
  970.         if 0 != attrSlot:
  971.             for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  972.                 type = attrSlot[i][0]
  973.                 value = attrSlot[i][1]
  974.  
  975.                 if 0 == value:
  976.                     continue
  977.  
  978.                 affectString = self.__GetAffectString(type, value)
  979.                 if app.ENABLE_ACCE_COSTUME_SYSTEM:
  980.                     if item.GetItemType() == item.ITEM_TYPE_COSTUME:
  981.                         if item.GetItemSubType() == item.COSTUME_TYPE_ACCE:
  982.                             if itemAbsChance != 0:
  983.                                 value = self.CalcAcceValue(value, itemAbsChance)
  984.                                 affectString = self.__GetAffectString(type, value)
  985.  
  986.                 if affectString:
  987.                     affectColor = self.__GetAttributeColor(i, value)
  988.                     self.AppendTextLine(affectString, affectColor)
  989.  
  990.     def __GetAttributeColor(self, index, value):
  991.         if value > 0:
  992.             if index >= player.ATTRIBUTE_SLOT_RARE_START and index < player.ATTRIBUTE_SLOT_RARE_END:
  993.                 return self.SPECIAL_POSITIVE_COLOR2
  994.             else:
  995.                 if index == player.ATTRIBUTE_SLOT_NORM_END:
  996.                     return self.SPECIAL_POSITIVE_COLOR5
  997.                 else:
  998.                     return self.SPECIAL_POSITIVE_COLOR
  999.         elif value == 0:
  1000.             return self.NORMAL_COLOR
  1001.         else:
  1002.             return self.NEGATIVE_COLOR
  1003.  
  1004.     def __IsPolymorphItem(self, itemVnum):
  1005.         if itemVnum >= 70103 and itemVnum <= 70107:
  1006.             return 1
  1007.         return 0
  1008.  
  1009.     def __SetPolymorphItemTitle(self, monsterVnum):
  1010.         if localeInfo.IsVIETNAM():
  1011.             itemName =item.GetItemName()
  1012.             itemName+=" "
  1013.             itemName+=nonplayer.GetMonsterName(monsterVnum)
  1014.         else:
  1015.             itemName =nonplayer.GetMonsterName(monsterVnum)
  1016.             itemName+=" "
  1017.             itemName+=item.GetItemName()
  1018.         self.SetTitle(itemName)
  1019.  
  1020.     def __SetNormalItemTitle(self):
  1021.         if app.ENABLE_SEND_TARGET_INFO:
  1022.             if self.isStone:
  1023.                 itemName = item.GetItemName()
  1024.                 realName = itemName[:itemName.find("+")]
  1025.                 self.SetTitle(realName + " +0 - +4")
  1026.             else:
  1027.                 self.SetTitle(item.GetItemName())
  1028.         else:
  1029.             self.SetTitle(item.GetItemName())
  1030.  
  1031.     def __SetSpecialItemTitle(self):
  1032.         self.AppendTextLine(item.GetItemName(), self.SPECIAL_TITLE_COLOR)
  1033.  
  1034.     def __SetItemTitle(self, itemVnum, metinSlot, attrSlot):
  1035.         if localeInfo.IsCANADA():
  1036.             if 72726 == itemVnum or 72730 == itemVnum:
  1037.                 self.AppendTextLine(item.GetItemName(), grp.GenerateColor(1.0, 0.7843, 0.0, 1.0))
  1038.                 return
  1039.  
  1040.         if self.__IsPolymorphItem(itemVnum):
  1041.             self.__SetPolymorphItemTitle(metinSlot[0])
  1042.         else:
  1043.             if self.__IsAttr(attrSlot):
  1044.                 self.__SetSpecialItemTitle()
  1045.                 return
  1046.  
  1047.             self.__SetNormalItemTitle()
  1048.  
  1049.     def __IsAttr(self, attrSlot):
  1050.         if not attrSlot:
  1051.             return False
  1052.  
  1053.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1054.             type = attrSlot[i][0]
  1055.             if 0 != type:
  1056.                 return True
  1057.  
  1058.         return False
  1059.  
  1060.     def AddRefineItemData(self, itemVnum, metinSlot, attrSlot = 0):
  1061.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1062.             metinSlotData=metinSlot[i]
  1063.             if self.GetMetinItemIndex(metinSlotData) == constInfo.ERROR_METIN_STONE:
  1064.                 metinSlot[i]=player.METIN_SOCKET_TYPE_SILVER
  1065.  
  1066.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  1067.  
  1068.     def AddItemData_Offline(self, itemVnum, itemDesc, itemSummary, metinSlot, attrSlot):
  1069.         self.__AdjustMaxWidth(attrSlot, itemDesc)
  1070.         self.__SetItemTitle(itemVnum, metinSlot, attrSlot)
  1071.  
  1072.         if self.__IsHair(itemVnum):
  1073.             self.__AppendHairIcon(itemVnum)
  1074.  
  1075.         ### Description ###
  1076.         self.AppendDescription(itemDesc, 26)
  1077.         self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
  1078.  
  1079.     def AddItemData(self, itemVnum, metinSlot, attrSlot = 0, flags = 0, unbindTime = 0, window_type = player.INVENTORY, slotIndex = -1):
  1080.         self.itemVnum = itemVnum
  1081.         self.metinSlot = metinSlot
  1082.         item.SelectItem(itemVnum)
  1083.         itemType = item.GetItemType()
  1084.         itemSubType = item.GetItemSubType()
  1085.  
  1086.         if not item.GetItemDescription():
  1087.             self.__CalculateToolTipWidth()
  1088.  
  1089.         if 50026 == itemVnum:
  1090.             if 0 != metinSlot:
  1091.                 name = item.GetItemName()
  1092.                 if metinSlot[0] > 0:
  1093.                     name += " "
  1094.                     name += localeInfo.NumberToMoneyString(metinSlot[0])
  1095.             self.SetTitle(name)
  1096.             self.__AppendSealInformation(window_type, slotIndex) ## cyh itemseal 2013 11 11
  1097.             self.AdditionalTips(window_type, itemVnum, metinSlot, slotIndex)
  1098.             self.ShowToolTip()
  1099.             return
  1100.  
  1101.         ### Skill Book ###
  1102.         if app.ENABLE_SEND_TARGET_INFO:
  1103.             if 50300 == itemVnum and not self.isBook:
  1104.                 if 0 != metinSlot and not self.isBook:
  1105.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILLBOOK_NAME, 1)
  1106.                     self.ShowToolTip()
  1107.                 elif self.isBook:
  1108.                     self.SetTitle(item.GetItemName())
  1109.                     self.AppendDescription(item.GetItemDescription(), 26)
  1110.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  1111.                     self.ShowToolTip()                 
  1112.                 return
  1113.             elif 70037 == itemVnum :
  1114.                 if 0 != metinSlot and not self.isBook2:
  1115.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  1116.                     self.AppendDescription(item.GetItemDescription(), 26)
  1117.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  1118.                     self.ShowToolTip()
  1119.                 elif self.isBook2:
  1120.                     self.SetTitle(item.GetItemName())
  1121.                     self.AppendDescription(item.GetItemDescription(), 26)
  1122.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  1123.                     self.ShowToolTip()                 
  1124.                 return
  1125.             elif 70055 == itemVnum:
  1126.                 if 0 != metinSlot:
  1127.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  1128.                     self.AppendDescription(item.GetItemDescription(), 26)
  1129.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  1130.                     self.ShowToolTip()
  1131.                 return
  1132.         else:
  1133.             if 50300 == itemVnum:
  1134.                 if 0 != metinSlot:
  1135.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILLBOOK_NAME, 1)
  1136.                     self.ShowToolTip()
  1137.                 return
  1138.             elif 70037 == itemVnum:
  1139.                 if 0 != metinSlot:
  1140.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  1141.                     self.AppendDescription(item.GetItemDescription(), 26)
  1142.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  1143.                     self.ShowToolTip()
  1144.                 return
  1145.             elif 70055 == itemVnum:
  1146.                 if 0 != metinSlot:
  1147.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  1148.                     self.AppendDescription(item.GetItemDescription(), 26)
  1149.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  1150.                     self.ShowToolTip()
  1151.                 return
  1152.         ###########################################################################################
  1153.  
  1154.  
  1155.         itemDesc = item.GetItemDescription()
  1156.         itemSummary = item.GetItemSummary()
  1157.  
  1158.         isCostumeItem = 0
  1159.         isCostumeHair = 0
  1160.         isCostumeBody = 0
  1161.         if app.ENABLE_MOUNT_COSTUME_SYSTEM:
  1162.             isCostumeMount = 0
  1163.         if app.ENABLE_ACCE_COSTUME_SYSTEM:
  1164.             isCostumeAcce = 0
  1165.         if app.ENABLE_WEAPON_COSTUME_SYSTEM:
  1166.             isCostumeWeapon = 0
  1167.  
  1168.         if app.ENABLE_COSTUME_SYSTEM:
  1169.             if item.ITEM_TYPE_COSTUME == itemType:
  1170.                 isCostumeItem = 1
  1171.                 isCostumeHair = item.COSTUME_TYPE_HAIR == itemSubType
  1172.                 isCostumeBody = item.COSTUME_TYPE_BODY == itemSubType
  1173.                 if app.ENABLE_MOUNT_COSTUME_SYSTEM:
  1174.                     isCostumeMount = item.COSTUME_TYPE_MOUNT == itemSubType
  1175.                 if app.ENABLE_ACCE_COSTUME_SYSTEM:
  1176.                     isCostumeAcce = item.COSTUME_TYPE_ACCE == itemSubType
  1177.                 if app.ENABLE_WEAPON_COSTUME_SYSTEM:
  1178.                     isCostumeWeapon = item.COSTUME_TYPE_WEAPON == itemSubType
  1179.  
  1180.                 #dbg.TraceError("IS_COSTUME_ITEM! body(%d) hair(%d)" % (isCostumeBody, isCostumeHair))
  1181.  
  1182.         self.__AdjustMaxWidth(attrSlot, itemDesc)
  1183.         self.__SetItemTitle(itemVnum, metinSlot, attrSlot)
  1184.  
  1185.         ### Hair Preview Image ###
  1186.         if self.__IsHair(itemVnum):
  1187.             self.__AppendHairIcon(itemVnum)
  1188.  
  1189.         ### Description ###
  1190.         self.AppendDescription(itemDesc, 26)
  1191.         self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
  1192.  
  1193.         ### Weapon ###
  1194.         if item.ITEM_TYPE_WEAPON == itemType:
  1195.  
  1196.             self.__AppendLimitInformation()
  1197.  
  1198.             self.AppendSpace(5)
  1199.  
  1200.             if item.WEAPON_FAN == itemSubType:
  1201.                 self.__AppendMagicAttackInfo()
  1202.                 self.__AppendAttackPowerInfo()
  1203.  
  1204.             else:
  1205.                 self.__AppendAttackPowerInfo()
  1206.                 self.__AppendMagicAttackInfo()
  1207.  
  1208.             self.__AppendAffectInformation()
  1209.             self.__AppendAttributeInformation(attrSlot)
  1210.  
  1211.             self.AppendWearableInformation()
  1212.  
  1213.             if app.ENABLE_QUIVER_SYSTEM and item.WEAPON_QUIVER == itemSubType:
  1214.                 self.AppendLastTimeInformation(metinSlot)
  1215.             else:
  1216.                 self.__AppendMetinSlotInfo(metinSlot)
  1217.  
  1218.         ### Armor ###
  1219.         elif item.ITEM_TYPE_ARMOR == itemType:
  1220.             self.__AppendLimitInformation()
  1221.  
  1222.             defGrade = item.GetValue(1)
  1223.             defBonus = item.GetValue(5)*2
  1224.             if defGrade > 0:
  1225.                 self.AppendSpace(5)
  1226.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_DEF_GRADE % (defGrade+defBonus), self.GetChangeTextLineColor(defGrade))
  1227.  
  1228.             self.__AppendMagicDefenceInfo()
  1229.             self.__AppendAffectInformation()
  1230.             self.__AppendAttributeInformation(attrSlot)
  1231.  
  1232.             self.AppendWearableInformation()
  1233.  
  1234.             if itemSubType in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1235.                 self.__AppendAccessoryMetinSlotInfo(metinSlot, constInfo.GET_ACCESSORY_MATERIAL_VNUM(itemVnum, itemSubType))
  1236.             else:
  1237.                 self.__AppendMetinSlotInfo(metinSlot)
  1238.  
  1239.         ### Ring Slot Item (Not UNIQUE) ###
  1240.         elif item.ITEM_TYPE_RING == itemType:
  1241.             self.__AppendLimitInformation()
  1242.             self.__AppendAffectInformation()
  1243.             self.__AppendAttributeInformation(attrSlot)
  1244.  
  1245.             #self.__AppendAccessoryMetinSlotInfo(metinSlot, 99001)
  1246.  
  1247.  
  1248.         ### Belt Item ###
  1249.         elif item.ITEM_TYPE_BELT == itemType:
  1250.             self.__AppendLimitInformation()
  1251.             self.__AppendAffectInformation()
  1252.             self.__AppendAttributeInformation(attrSlot)
  1253.  
  1254.             self.__AppendAccessoryMetinSlotInfo(metinSlot, constInfo.GET_BELT_MATERIAL_VNUM(itemVnum))
  1255.  
  1256.         elif app.ENABLE_PET_SYSTEM_EX and item.ITEM_TYPE_PET == itemType:
  1257.             self.__AppendLimitInformation()
  1258.             self.__AppendAffectInformation()
  1259.             self.__AppendAttributeInformation(attrSlot)
  1260.             self.AppendWearableInformation()
  1261.             self.AppendLastTimeInformation(metinSlot)
  1262.  
  1263.         elif isCostumeItem:
  1264.             self.__AppendLimitInformation()
  1265.             self.__AppendAffectInformation()
  1266.             if app.ENABLE_ACCE_COSTUME_SYSTEM and isCostumeAcce:
  1267.                 ## ABSORPTION RATE
  1268.                 absChance = int(metinSlot[acce.ABSORPTION_SOCKET])
  1269.                 self.AppendTextLine(localeInfo.ACCE_ABSORB_CHANCE % (absChance), self.CONDITION_COLOR)
  1270.                 ## END ABSORPTION RATE
  1271.  
  1272.                 itemAbsorbedVnum = int(metinSlot[acce.ABSORBED_SOCKET])
  1273.                 if itemAbsorbedVnum:
  1274.                     ## ATTACK / DEFENSE
  1275.                     item.SelectItem(itemAbsorbedVnum)
  1276.                     if item.GetItemType() == item.ITEM_TYPE_WEAPON:
  1277.                         if item.GetItemSubType() == item.WEAPON_FAN:
  1278.                             self.__AppendMagicAttackInfo(metinSlot[acce.ABSORPTION_SOCKET])
  1279.                             item.SelectItem(itemAbsorbedVnum)
  1280.                             self.__AppendAttackPowerInfo(metinSlot[acce.ABSORPTION_SOCKET])
  1281.                         else:
  1282.                             self.__AppendAttackPowerInfo(metinSlot[acce.ABSORPTION_SOCKET])
  1283.                             item.SelectItem(itemAbsorbedVnum)
  1284.                             self.__AppendMagicAttackInfo(metinSlot[acce.ABSORPTION_SOCKET])
  1285.                     elif item.GetItemType() == item.ITEM_TYPE_ARMOR:
  1286.                         defGrade = item.GetValue(1)
  1287.                         defBonus = item.GetValue(5) * 2
  1288.                         defGrade = self.CalcAcceValue(defGrade, metinSlot[acce.ABSORPTION_SOCKET])
  1289.                         defBonus = self.CalcAcceValue(defBonus, metinSlot[acce.ABSORPTION_SOCKET])
  1290.  
  1291.                         if defGrade > 0:
  1292.                             self.AppendSpace(5)
  1293.                             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_DEF_GRADE % (defGrade + defBonus), self.GetChangeTextLineColor(defGrade))
  1294.  
  1295.                         item.SelectItem(itemAbsorbedVnum)
  1296.                         self.__AppendMagicDefenceInfo(metinSlot[acce.ABSORPTION_SOCKET])
  1297.                     ## END ATTACK / DEFENSE
  1298.  
  1299.                     ## EFFECT
  1300.                     item.SelectItem(itemAbsorbedVnum)
  1301.                     for i in xrange(item.ITEM_APPLY_MAX_NUM):
  1302.                         (affectType, affectValue) = item.GetAffect(i)
  1303.                         affectValue = self.CalcAcceValue(affectValue, metinSlot[acce.ABSORPTION_SOCKET])
  1304.                         affectString = self.__GetAffectString(affectType, affectValue)
  1305.                         if (not app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue != 0)\
  1306.                                 or (app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue > 0):
  1307.                             self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  1308.  
  1309.                         item.SelectItem(itemAbsorbedVnum)
  1310.                     # END EFFECT
  1311.  
  1312.                     item.SelectItem(itemVnum)
  1313.                     ## ATTR
  1314.                     self.__AppendAttributeInformation(attrSlot, metinSlot[acce.ABSORPTION_SOCKET])
  1315.                     # END ATTR
  1316.                 else:
  1317.                     # ATTR
  1318.                     self.__AppendAttributeInformation(attrSlot)
  1319.                     # END ATTR
  1320.             else:
  1321.                 self.__AppendAttributeInformation(attrSlot)
  1322.  
  1323.             self.AppendWearableInformation()
  1324.             self.AppendLastTimeInformation(metinSlot)
  1325.  
  1326.         ## Rod ##
  1327.         elif item.ITEM_TYPE_ROD == itemType:
  1328.  
  1329.             if 0 != metinSlot:
  1330.                 curLevel = item.GetValue(0) / 10
  1331.                 curEXP = metinSlot[0]
  1332.                 maxEXP = item.GetValue(2)
  1333.                 self.__AppendLimitInformation()
  1334.                 self.__AppendRodInformation(curLevel, curEXP, maxEXP)
  1335.  
  1336.         ## Pick ##
  1337.         elif item.ITEM_TYPE_PICK == itemType:
  1338.  
  1339.             if 0 != metinSlot:
  1340.                 curLevel = item.GetValue(0) / 10
  1341.                 curEXP = metinSlot[0]
  1342.                 maxEXP = item.GetValue(2)
  1343.                 self.__AppendLimitInformation()
  1344.                 self.__AppendPickInformation(curLevel, curEXP, maxEXP)
  1345.  
  1346.         ## Lottery ##
  1347.         elif item.ITEM_TYPE_LOTTERY == itemType:
  1348.             if 0 != metinSlot:
  1349.  
  1350.                 ticketNumber = int(metinSlot[0])
  1351.                 stepNumber = int(metinSlot[1])
  1352.  
  1353.                 self.AppendSpace(5)
  1354.                 self.AppendTextLine(localeInfo.TOOLTIP_LOTTERY_STEP_NUMBER % (stepNumber), self.NORMAL_COLOR)
  1355.                 self.AppendTextLine(localeInfo.TOOLTIP_LOTTO_NUMBER % (ticketNumber), self.NORMAL_COLOR);
  1356.  
  1357.         ### Metin ###
  1358.         elif item.ITEM_TYPE_METIN == itemType:
  1359.             self.AppendMetinInformation()
  1360.             self.AppendMetinWearInformation()
  1361.  
  1362.         ### Fish ###
  1363.         elif item.ITEM_TYPE_FISH == itemType:
  1364.             if 0 != metinSlot:
  1365.                 self.__AppendFishInfo(metinSlot[0])
  1366.  
  1367.         ## item.ITEM_TYPE_BLEND
  1368.         elif item.ITEM_TYPE_BLEND == itemType:
  1369.             self.__AppendLimitInformation()
  1370.  
  1371.             if metinSlot:
  1372.                 affectType = metinSlot[0]
  1373.                 affectValue = metinSlot[1]
  1374.                 time = metinSlot[2]
  1375.                 self.AppendSpace(5)
  1376.                 affectText = self.__GetAffectString(affectType, affectValue)
  1377.  
  1378.                 self.AppendTextLine(affectText, self.NORMAL_COLOR)
  1379.  
  1380.                 if time > 0:
  1381.                     minute = (time / 60)
  1382.                     second = (time % 60)
  1383.                     timeString = localeInfo.TOOLTIP_POTION_TIME
  1384.  
  1385.                     if minute > 0:
  1386.                         timeString += str(minute) + localeInfo.TOOLTIP_POTION_MIN
  1387.                     if second > 0:
  1388.                         timeString += " " + str(second) + localeInfo.TOOLTIP_POTION_SEC
  1389.  
  1390.                     self.AppendTextLine(timeString)
  1391.                 else:
  1392.                     self.AppendTextLine(localeInfo.BLEND_POTION_NO_TIME)
  1393.             else:
  1394.                 self.AppendTextLine("BLEND_POTION_NO_INFO")
  1395.  
  1396.         elif item.ITEM_TYPE_UNIQUE == itemType:
  1397.             if 0 != metinSlot:
  1398.                 if not self.AppendLastTimeInformation(metinSlot):
  1399.                     time = metinSlot[player.METIN_SOCKET_MAX_NUM-1]
  1400.  
  1401.                     if 1 == item.GetValue(2):
  1402.                         self.AppendMallItemLastTime(time)
  1403.                     else:
  1404.                         self.AppendUniqueItemLastTime(time)
  1405.  
  1406.         ### Use ###
  1407.         elif item.ITEM_TYPE_USE == itemType:
  1408.             self.__AppendLimitInformation()
  1409.  
  1410.             if item.USE_POTION == itemSubType or item.USE_POTION_NODELAY == itemSubType:
  1411.                 self.__AppendPotionInformation()
  1412.  
  1413.             elif item.USE_ABILITY_UP == itemSubType:
  1414.                 self.__AppendAbilityPotionInformation()
  1415.  
  1416.  
  1417.             if 27989 == itemVnum or 76006 == itemVnum:
  1418.                 if 0 != metinSlot:
  1419.                     useCount = int(metinSlot[0])
  1420.  
  1421.                     self.AppendSpace(5)
  1422.                     self.AppendTextLine(localeInfo.TOOLTIP_REST_USABLE_COUNT % (6 - useCount), self.NORMAL_COLOR)
  1423.  
  1424.             elif 50004 == itemVnum:
  1425.                 if 0 != metinSlot:
  1426.                     useCount = int(metinSlot[0])
  1427.  
  1428.                     self.AppendSpace(5)
  1429.                     self.AppendTextLine(localeInfo.TOOLTIP_REST_USABLE_COUNT % (10 - useCount), self.NORMAL_COLOR)
  1430.  
  1431.             elif constInfo.IS_AUTO_POTION(itemVnum):
  1432.                 if 0 != metinSlot:
  1433.                     isActivated = int(metinSlot[0])
  1434.                     usedAmount = float(metinSlot[1])
  1435.                     totalAmount = float(metinSlot[2])
  1436.  
  1437.                     if 0 == totalAmount:
  1438.                         totalAmount = 1
  1439.  
  1440.                     self.AppendSpace(5)
  1441.  
  1442.                     if 0 != isActivated:
  1443.                         self.AppendTextLine("(%s)" % (localeInfo.TOOLTIP_AUTO_POTION_USING), self.SPECIAL_POSITIVE_COLOR)
  1444.                         self.AppendSpace(5)
  1445.  
  1446.                     self.AppendTextLine(localeInfo.TOOLTIP_AUTO_POTION_REST % (100.0 - ((usedAmount / totalAmount) * 100.0)), self.POSITIVE_COLOR)
  1447.  
  1448.             elif itemVnum in WARP_SCROLLS:
  1449.                 if 0 != metinSlot:
  1450.                     xPos = int(metinSlot[0])
  1451.                     yPos = int(metinSlot[1])
  1452.  
  1453.                     if xPos != 0 and yPos != 0:
  1454.                         (mapName, xBase, yBase) = background.GlobalPositionToMapInfo(xPos, yPos)
  1455.  
  1456.                         localeMapName=localeInfo.MINIMAP_ZONE_NAME_DICT.get(mapName, "")
  1457.  
  1458.                         self.AppendSpace(5)
  1459.  
  1460.                         if localeMapName!="":
  1461.                             self.AppendTextLine(localeInfo.TOOLTIP_MEMORIZED_POSITION % (localeMapName, int(xPos-xBase)/100, int(yPos-yBase)/100), self.NORMAL_COLOR)
  1462.                         else:
  1463.                             self.AppendTextLine(localeInfo.TOOLTIP_MEMORIZED_POSITION_ERROR % (int(xPos)/100, int(yPos)/100), self.NORMAL_COLOR)
  1464.                             dbg.TraceError("NOT_EXIST_IN_MINIMAP_ZONE_NAME_DICT: %s" % mapName)
  1465.  
  1466.             #####
  1467.             if item.USE_SPECIAL == itemSubType:
  1468.                 if not self.AppendLastTimeInformation(metinSlot):
  1469.                     if 0 != metinSlot:
  1470.                         time = metinSlot[player.METIN_SOCKET_MAX_NUM-1]
  1471.  
  1472.                         if 1 == item.GetValue(2):
  1473.                             self.AppendMallItemLastTime(time)
  1474.  
  1475.             elif item.USE_TIME_CHARGE_PER == itemSubType:
  1476.                 if metinSlot[2]:
  1477.                     self.AppendTextLine(localeInfo.TOOLTIP_TIME_CHARGER_PER(metinSlot[2]))
  1478.                 else:
  1479.                     self.AppendTextLine(localeInfo.TOOLTIP_TIME_CHARGER_PER(item.GetValue(0)))
  1480.  
  1481.                 self.AppendLastTimeInformation(metinSlot)
  1482.  
  1483.             elif item.USE_TIME_CHARGE_FIX == itemSubType:
  1484.                 if metinSlot[2]:
  1485.                     self.AppendTextLine(localeInfo.TOOLTIP_TIME_CHARGER_FIX(metinSlot[2]))
  1486.                 else:
  1487.                     self.AppendTextLine(localeInfo.TOOLTIP_TIME_CHARGER_FIX(item.GetValue(0)))
  1488.  
  1489.                 self.AppendLastTimeInformation(metinSlot)
  1490.  
  1491.         elif item.ITEM_TYPE_QUEST == itemType:
  1492.             for i in xrange(item.LIMIT_MAX_NUM):
  1493.                 (limitType, limitValue) = item.GetLimit(i)
  1494.  
  1495.                 if item.LIMIT_REAL_TIME == limitType:
  1496.                     self.AppendMallItemLastTime(metinSlot[0])
  1497.         elif item.ITEM_TYPE_DS == itemType:
  1498.             self.AppendTextLine(self.__DragonSoulInfoString(itemVnum))
  1499.             self.__AppendAttributeInformation(attrSlot)
  1500.         else:
  1501.             self.__AppendLimitInformation()
  1502.  
  1503.         for i in xrange(item.LIMIT_MAX_NUM):
  1504.             (limitType, limitValue) = item.GetLimit(i)
  1505.             #dbg.TraceError("LimitType : %d, limitValue : %d" % (limitType, limitValue))
  1506.  
  1507.             if item.LIMIT_REAL_TIME_START_FIRST_USE == limitType:
  1508.                 self.AppendRealTimeStartFirstUseLastTime(item, metinSlot, i)
  1509.                 #dbg.TraceError("2) REAL_TIME_START_FIRST_USE flag On ")
  1510.  
  1511.             elif item.LIMIT_TIMER_BASED_ON_WEAR == limitType:
  1512.                 self.AppendTimerBasedOnWearLastTime(metinSlot)
  1513.                 #dbg.TraceError("1) REAL_TIME flag On ")
  1514.  
  1515.         if app.ENABLE_ANTIFLAG_TOOLTIP:
  1516.             self.AppendAntiflagInformation()
  1517.         self.__AppendSealInformation(window_type, slotIndex) ## cyh itemseal 2013 11 11
  1518.  
  1519.         self.AdditionalTips(window_type, itemVnum, metinSlot, slotIndex)
  1520.         self.ShowToolTip()
  1521.  
  1522.     def AdditionalTips(self, window_type, itemVnum, metinSlot, slotIndex):
  1523.         item.SelectItem(itemVnum)
  1524.         itemType = item.GetItemType()
  1525.         itemSubType = item.GetItemSubType()
  1526.  
  1527.         if app.ENABLE_EMOJI_SYSTEM and item.IsFlag(item.ITEM_FLAG_STACKABLE) and window_type in (player.INVENTORY,):
  1528.             if player.GetItemCount(window_type, slotIndex) > 1:
  1529.                 self.AppendTextLine(localeInfo.TOOLTIP_TIPS_SPLIT_ITEM.format(Emoji("icon\emoji\key_shift.png"), Emoji("icon\emoji\key_lclick.png")))
  1530.  
  1531.         if chr.IsGameMaster(0):
  1532.             self.AppendSpace(5)
  1533.             self.AppendTextLine("VNUM: {}".format(itemVnum), 0xFFf863ff)
  1534.             self.AppendSpace(3)
  1535.             self.AppendTextLine("TYPE: {} SUBTYPE {}".format(itemType, itemSubType), 0xFF00cfb6)
  1536.             if metinSlot:
  1537.                 self.AppendSpace(3)
  1538.                 self.AppendTextLine("SOCKET: {}".format(','.join([str(i) for i in metinSlot])), 0xFF00b6d6)
  1539.  
  1540.     def __DragonSoulInfoString (self, dwVnum):
  1541.         step = (dwVnum / 100) % 10
  1542.         refine = (dwVnum / 10) % 10
  1543.         if 0 == step:
  1544.             return localeInfo.DRAGON_SOUL_STEP_LEVEL1 + " " + localeInfo.DRAGON_SOUL_STRENGTH(refine)
  1545.         elif 1 == step:
  1546.             return localeInfo.DRAGON_SOUL_STEP_LEVEL2 + " " + localeInfo.DRAGON_SOUL_STRENGTH(refine)
  1547.         elif 2 == step:
  1548.             return localeInfo.DRAGON_SOUL_STEP_LEVEL3 + " " + localeInfo.DRAGON_SOUL_STRENGTH(refine)
  1549.         elif 3 == step:
  1550.             return localeInfo.DRAGON_SOUL_STEP_LEVEL4 + " " + localeInfo.DRAGON_SOUL_STRENGTH(refine)
  1551.         elif 4 == step:
  1552.             return localeInfo.DRAGON_SOUL_STEP_LEVEL5 + " " + localeInfo.DRAGON_SOUL_STRENGTH(refine)
  1553.         else:
  1554.             return ""
  1555.  
  1556.  
  1557.     def __IsHair(self, itemVnum):
  1558.         return (self.__IsOldHair(itemVnum) or
  1559.             self.__IsNewHair(itemVnum) or
  1560.             self.__IsNewHair2(itemVnum) or
  1561.             self.__IsNewHair3(itemVnum)
  1562.         )
  1563.  
  1564.     def __IsOldHair(self, itemVnum):
  1565.         return itemVnum > 73000 and itemVnum < 74000
  1566.  
  1567.     def __IsNewHair(self, itemVnum):
  1568.         return itemVnum > 74000 and itemVnum < 75000
  1569.  
  1570.     if app.QUICK_SELL_SYSTEM:
  1571.         def AppendQuckSellItem(self,slotIndex):
  1572.             if player.IsEquipmentSlot(slotIndex):
  1573.                 return
  1574.             if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
  1575.                 return
  1576.             else:
  1577.                 self.AppendSpace(5)
  1578.                 self.AppendTextLine(localeInfo.QUICK_SELL_TOOLTIP, self.NORMAL_COLOR)
  1579.  
  1580.     def __IsNewHair2(self, itemVnum):
  1581.         return itemVnum > 75000 and itemVnum < 76000
  1582.  
  1583.     def __IsNewHair3(self, itemVnum):
  1584.         return ((74012 < itemVnum and itemVnum < 74022) or
  1585.             (74262 < itemVnum and itemVnum < 74272) or
  1586.             (74512 < itemVnum and itemVnum < 74599) or
  1587.             (74762 < itemVnum and itemVnum < 74799) or
  1588.             (45000 < itemVnum and itemVnum < 47000))
  1589.  
  1590.     def __AppendHairIcon(self, itemVnum):
  1591.         itemImage = ui.ImageBox()
  1592.         itemImage.SetParent(self)
  1593.         itemImage.Show()
  1594.  
  1595.         if self.__IsOldHair(itemVnum):
  1596.             itemImage.LoadImage("d:/ymir work/item/quest/"+str(itemVnum)+".tga")
  1597.         elif self.__IsNewHair3(itemVnum):
  1598.             itemImage.LoadImage("icon/hair/%d.sub" % (itemVnum))
  1599.         elif self.__IsNewHair(itemVnum):
  1600.             itemImage.LoadImage("d:/ymir work/item/quest/"+str(itemVnum-1000)+".tga")
  1601.         elif self.__IsNewHair2(itemVnum):
  1602.             itemImage.LoadImage("icon/hair/%d.sub" % (itemVnum))
  1603.  
  1604.         itemImage.SetPosition(itemImage.GetWidth()/2, self.toolTipHeight)
  1605.         self.toolTipHeight += itemImage.GetHeight()
  1606.         #self.toolTipWidth += itemImage.GetWidth()/2
  1607.         self.childrenList.append(itemImage)
  1608.         self.ResizeToolTip()
  1609.  
  1610.     def __AdjustMaxWidth(self, attrSlot, desc):
  1611.         newToolTipWidth = self.toolTipWidth
  1612.         newToolTipWidth = max(self.__AdjustAttrMaxWidth(attrSlot), newToolTipWidth)
  1613.         newToolTipWidth = max(self.__AdjustDescMaxWidth(desc), newToolTipWidth)
  1614.         if newToolTipWidth > self.toolTipWidth:
  1615.             self.toolTipWidth = newToolTipWidth
  1616.             self.ResizeToolTip()
  1617.  
  1618.     def __AdjustAttrMaxWidth(self, attrSlot):
  1619.         if 0 == attrSlot:
  1620.             return self.toolTipWidth
  1621.  
  1622.         maxWidth = self.toolTipWidth
  1623.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1624.             type = attrSlot[i][0]
  1625.             value = attrSlot[i][1]
  1626.             if self.ATTRIBUTE_NEED_WIDTH.has_key(type):
  1627.                 if value > 0:
  1628.                     maxWidth = max(self.ATTRIBUTE_NEED_WIDTH[type], maxWidth)
  1629.  
  1630.                     # ATTR_CHANGE_TOOLTIP_WIDTH
  1631.                     #self.toolTipWidth = max(self.ATTRIBUTE_NEED_WIDTH[type], self.toolTipWidth)
  1632.                     #self.ResizeToolTip()
  1633.                     # END_OF_ATTR_CHANGE_TOOLTIP_WIDTH
  1634.  
  1635.         return maxWidth
  1636.  
  1637.     def __AdjustDescMaxWidth(self, desc):
  1638.         if len(desc) < DESC_DEFAULT_MAX_COLS:
  1639.             return self.toolTipWidth
  1640.  
  1641.         return DESC_WESTERN_MAX_WIDTH
  1642.  
  1643.     def ResizeToolTipWidth(self, width):
  1644.         self.toolTipWidth = width
  1645.  
  1646.     def __CalculateToolTipWidth(self):
  1647.         affectTextLineLenList = []
  1648.  
  1649.         metinSocket = self.metinSlot
  1650.         if metinSocket:
  1651.             for socketIndex in metinSocket:
  1652.                 if socketIndex:
  1653.                     item.SelectItem(socketIndex)
  1654.  
  1655.                     affectType, affectValue = item.GetAffect(0)
  1656.                     affectString = self.__GetAffectString(affectType, affectValue)
  1657.                     if affectString:
  1658.                         affectTextLineLenList.append(len(affectString))
  1659.  
  1660.             if self.itemVnum:
  1661.                 item.SelectItem(self.itemVnum)
  1662.             self.metinSlot = None
  1663.  
  1664.         if self.toolTipWidth == self.TOOL_TIP_WIDTH:
  1665.             if affectTextLineLenList:
  1666.                 self.toolTipWidth += max(affectTextLineLenList) + 25
  1667.  
  1668.         self.AlignTextLineHorizonalCenter()
  1669.  
  1670.     def __SetSkillBookToolTip(self, skillIndex, bookName, skillGrade):
  1671.         skillName = skill.GetSkillName(skillIndex)
  1672.  
  1673.         if not skillName:
  1674.             return
  1675.  
  1676.         if localeInfo.IsVIETNAM():
  1677.             itemName = bookName + " " + skillName
  1678.         else:
  1679.             itemName = skillName + " " + bookName
  1680.         self.SetTitle(itemName)
  1681.  
  1682.     def __AppendPickInformation(self, curLevel, curEXP, maxEXP):
  1683.         self.AppendSpace(5)
  1684.         self.AppendTextLine(localeInfo.TOOLTIP_PICK_LEVEL % (curLevel), self.NORMAL_COLOR)
  1685.         self.AppendTextLine(localeInfo.TOOLTIP_PICK_EXP % (curEXP, maxEXP), self.NORMAL_COLOR)
  1686.  
  1687.         if curEXP == maxEXP:
  1688.             self.AppendSpace(5)
  1689.             self.AppendTextLine(localeInfo.TOOLTIP_PICK_UPGRADE1, self.NORMAL_COLOR)
  1690.             self.AppendTextLine(localeInfo.TOOLTIP_PICK_UPGRADE2, self.NORMAL_COLOR)
  1691.             self.AppendTextLine(localeInfo.TOOLTIP_PICK_UPGRADE3, self.NORMAL_COLOR)
  1692.  
  1693.  
  1694.     def __AppendRodInformation(self, curLevel, curEXP, maxEXP):
  1695.         self.AppendSpace(5)
  1696.         self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_LEVEL % (curLevel), self.NORMAL_COLOR)
  1697.         self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_EXP % (curEXP, maxEXP), self.NORMAL_COLOR)
  1698.  
  1699.         if curEXP == maxEXP:
  1700.             self.AppendSpace(5)
  1701.             self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_UPGRADE1, self.NORMAL_COLOR)
  1702.             self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_UPGRADE2, self.NORMAL_COLOR)
  1703.             self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_UPGRADE3, self.NORMAL_COLOR)
  1704.  
  1705.     def __AppendLimitInformation(self):
  1706.  
  1707.         appendSpace = False
  1708.  
  1709.         for i in xrange(item.LIMIT_MAX_NUM):
  1710.  
  1711.             (limitType, limitValue) = item.GetLimit(i)
  1712.  
  1713.             if limitValue > 0:
  1714.                 if False == appendSpace:
  1715.                     self.AppendSpace(5)
  1716.                     appendSpace = True
  1717.  
  1718.             else:
  1719.                 continue
  1720.  
  1721.             if item.LIMIT_LEVEL == limitType:
  1722.                 color = self.GetLimitTextLineColor(player.GetStatus(player.LEVEL), limitValue)
  1723.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_LEVEL % (limitValue), color)
  1724.             """
  1725.             elif item.LIMIT_STR == limitType:
  1726.                 color = self.GetLimitTextLineColor(player.GetStatus(player.ST), limitValue)
  1727.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_STR % (limitValue), color)
  1728.             elif item.LIMIT_DEX == limitType:
  1729.                 color = self.GetLimitTextLineColor(player.GetStatus(player.DX), limitValue)
  1730.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_DEX % (limitValue), color)
  1731.             elif item.LIMIT_INT == limitType:
  1732.                 color = self.GetLimitTextLineColor(player.GetStatus(player.IQ), limitValue)
  1733.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_INT % (limitValue), color)
  1734.             elif item.LIMIT_CON == limitType:
  1735.                 color = self.GetLimitTextLineColor(player.GetStatus(player.HT), limitValue)
  1736.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_CON % (limitValue), color)
  1737.             """
  1738.  
  1739.     ## cyh itemseal 2013 11 11
  1740.     def __AppendSealInformation(self, window_type, slotIndex):
  1741.         if not app.ENABLE_SOULBIND_SYSTEM:
  1742.             return
  1743.  
  1744.         itemSealDate = player.GetItemSealDate(window_type, slotIndex)
  1745.         if itemSealDate == item.GetDefaultSealDate():
  1746.             return
  1747.  
  1748.         if itemSealDate == item.GetUnlimitedSealDate():
  1749.             self.AppendSpace(5)
  1750.             self.AppendTextLine(localeInfo.TOOLTIP_SEALED, self.NEGATIVE_COLOR)
  1751.  
  1752.         elif itemSealDate > 0:
  1753.             self.AppendSpace(5)
  1754.             hours, minutes = player.GetItemUnSealLeftTime(window_type, slotIndex)
  1755.             self.AppendTextLine(localeInfo.TOOLTIP_UNSEAL_LEFT_TIME % (hours, minutes), self.NEGATIVE_COLOR)
  1756.  
  1757.     def __GetAffectString(self, affectType, affectValue):
  1758.         if 0 == affectType:
  1759.             return None
  1760.  
  1761.         if 0 == affectValue:
  1762.             return None
  1763.  
  1764.         try:
  1765.             return self.AFFECT_DICT[affectType](affectValue)
  1766.         except TypeError:
  1767.             return "UNKNOWN_VALUE[%s] %s" % (affectType, affectValue)
  1768.         except KeyError:
  1769.             return "UNKNOWN_TYPE[%s] %s" % (affectType, affectValue)
  1770.  
  1771.     def __AppendAffectInformation(self):
  1772.         for i in xrange(item.ITEM_APPLY_MAX_NUM):
  1773.             (affectType, affectValue) = item.GetAffect(i)
  1774.             if app.ENABLE_ACCE_COSTUME_SYSTEM and affectType==item.APPLY_ACCEDRAIN_RATE:
  1775.                 continue
  1776.             if app.ENABLE_MOUNT_COSTUME_SYSTEM and affectType==item.APPLY_MOUNT:
  1777.                 continue
  1778.             affectString = self.__GetAffectString(affectType, affectValue)
  1779.             if affectString:
  1780.                 self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  1781.  
  1782.     if app.ENABLE_ANTIFLAG_TOOLTIP:
  1783.         def AppendAntiflagInformation(self):
  1784.             antiFlagList = (
  1785.                 item.IsAntiFlag(item.ITEM_ANTIFLAG_DROP),
  1786.                 item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL),
  1787.                 item.IsAntiFlag(item.ITEM_ANTIFLAG_GIVE),
  1788.                 item.IsAntiFlag(item.ITEM_ANTIFLAG_STACK),
  1789.                 item.IsAntiFlag(item.ITEM_ANTIFLAG_MYSHOP),
  1790.                 item.IsAntiFlag(item.ITEM_ANTIFLAG_SAFEBOX))
  1791.    
  1792.             vectorSearch = self.ANTI_FLAG_NAMES
  1793.    
  1794.             count_antiFlags = 0
  1795.             antiFlagNames = ""
  1796.             for i in range(self.ANTI_FLAG_COUNT):
  1797.    
  1798.                 name = vectorSearch[i]
  1799.                 antiFlag = antiFlagList[i]
  1800.    
  1801.                 if antiFlag:
  1802.                     antiFlagNames += "" if count_antiFlags == 0 else "  "
  1803.                     antiFlagNames += name
  1804.                     count_antiFlags += 1
  1805.    
  1806.             if count_antiFlags != 0:
  1807.                 self.AppendSpace(5)
  1808.                 self.AppendTextLineNew(localeInfo.TOOLTIP_IMPOSSIBLE_TEXT, self.NEGATIVE_COLOR)
  1809.                 textLine = self.AppendTextLineNew(antiFlagNames, self.NORMAL_COLOR if self.CanEquip() else self.DISABLE_COLOR, True)
  1810.                 textLine.SetFeather(False)
  1811.                 self.AppendSpace(5)
  1812.  
  1813.     def AppendLastTimeInformation(self, metinSlot):
  1814.         bHasRealtimeFlag = False
  1815.         for i in xrange(item.LIMIT_MAX_NUM):
  1816.             (limitType, limitValue) = item.GetLimit(i)
  1817.             if item.LIMIT_REAL_TIME == limitType:
  1818.                 bHasRealtimeFlag = True
  1819.  
  1820.         if bHasRealtimeFlag:
  1821.             self.AppendMallItemLastTime(metinSlot[0])
  1822.         return bHasRealtimeFlag
  1823.  
  1824.     def AppendWearableInformation(self):
  1825.  
  1826.         self.AppendSpace(5)
  1827.         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_WEARABLE_JOB, self.NORMAL_COLOR)
  1828.  
  1829.         flagList = (
  1830.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_WARRIOR),
  1831.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_ASSASSIN),
  1832.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_SURA),
  1833.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_SHAMAN))
  1834.         if app.ENABLE_WOLFMAN_CHARACTER:
  1835.             flagList += (not item.IsAntiFlag(item.ITEM_ANTIFLAG_WOLFMAN),)
  1836.         characterNames = ""
  1837.         for i in xrange(self.CHARACTER_COUNT):
  1838.  
  1839.             name = self.CHARACTER_NAMES[i]
  1840.             flag = flagList[i]
  1841.  
  1842.             if flag:
  1843.                 characterNames += " "
  1844.                 characterNames += name
  1845.  
  1846.         textLine = self.AppendTextLine(characterNames, self.NORMAL_COLOR, True)
  1847.         textLine.SetFeather()
  1848.  
  1849.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_MALE):
  1850.             textLine = self.AppendTextLine(localeInfo.FOR_FEMALE, self.NORMAL_COLOR, True)
  1851.             textLine.SetFeather()
  1852.  
  1853.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_FEMALE):
  1854.             textLine = self.AppendTextLine(localeInfo.FOR_MALE, self.NORMAL_COLOR, True)
  1855.             textLine.SetFeather()
  1856.  
  1857.     def __AppendPotionInformation(self):
  1858.         self.AppendSpace(5)
  1859.  
  1860.         healHP = item.GetValue(0)
  1861.         healSP = item.GetValue(1)
  1862.         healStatus = item.GetValue(2)
  1863.         healPercentageHP = item.GetValue(3)
  1864.         healPercentageSP = item.GetValue(4)
  1865.  
  1866.         if healHP > 0:
  1867.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_HP_POINT % healHP, self.GetChangeTextLineColor(healHP))
  1868.         if healSP > 0:
  1869.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_SP_POINT % healSP, self.GetChangeTextLineColor(healSP))
  1870.         if healStatus != 0:
  1871.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_CURE)
  1872.         if healPercentageHP > 0:
  1873.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_HP_PERCENT % healPercentageHP, self.GetChangeTextLineColor(healPercentageHP))
  1874.         if healPercentageSP > 0:
  1875.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_SP_PERCENT % healPercentageSP, self.GetChangeTextLineColor(healPercentageSP))
  1876.  
  1877.     def __AppendAbilityPotionInformation(self):
  1878.  
  1879.         self.AppendSpace(5)
  1880.  
  1881.         abilityType = item.GetValue(0)
  1882.         time = item.GetValue(1)
  1883.         point = item.GetValue(2)
  1884.  
  1885.         if abilityType == item.APPLY_ATT_SPEED:
  1886.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_ATTACK_SPEED % point, self.GetChangeTextLineColor(point))
  1887.         elif abilityType == item.APPLY_MOV_SPEED:
  1888.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_MOVING_SPEED % point, self.GetChangeTextLineColor(point))
  1889.  
  1890.         if time > 0:
  1891.             minute = (time / 60)
  1892.             second = (time % 60)
  1893.             timeString = localeInfo.TOOLTIP_POTION_TIME
  1894.  
  1895.             if minute > 0:
  1896.                 timeString += str(minute) + localeInfo.TOOLTIP_POTION_MIN
  1897.             if second > 0:
  1898.                 timeString += " " + str(second) + localeInfo.TOOLTIP_POTION_SEC
  1899.  
  1900.             self.AppendTextLine(timeString)
  1901.  
  1902.     def GetPriceColor(self, price):
  1903.         if price>=constInfo.HIGH_PRICE:
  1904.             return self.HIGH_PRICE_COLOR
  1905.         if price>=constInfo.MIDDLE_PRICE:
  1906.             return self.MIDDLE_PRICE_COLOR
  1907.         else:
  1908.             return self.LOW_PRICE_COLOR
  1909.  
  1910.     def AppendPrice(self, price):
  1911.         if app.ENABLE_CHEQUE_SYSTEM:
  1912.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_YANG  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
  1913.             self.AppendSpace(5)
  1914.         else:
  1915.             self.AppendSpace(5)
  1916.             self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
  1917.  
  1918.     def AppendPriceBySecondaryCoin(self, price):
  1919.         self.AppendSpace(5)
  1920.         self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE % (localeInfo.NumberToSecondaryCoinString(price)), self.GetPriceColor(price))
  1921.  
  1922.     def AppendSellingPrice(self, price):
  1923.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
  1924.             self.AppendTextLine(localeInfo.TOOLTIP_ANTI_SELL, self.DISABLE_COLOR)
  1925.             self.AppendSpace(5)
  1926.         else:
  1927.             if app.ENABLE_CHEQUE_SYSTEM:
  1928.                 self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_YANG % (localeInfo.NumberToGold(price)), self.GetPriceColor(price))
  1929.                 self.AppendSpace(5)
  1930.             else:
  1931.                 self.AppendTextLine(localeInfo.TOOLTIP_SELLPRICE % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
  1932.                 self.AppendSpace(5)
  1933.  
  1934.     if app.ENABLE_CHEQUE_SYSTEM:
  1935.         def AppendCheque(self, price):
  1936.             if price <=0:
  1937.                 return
  1938.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_WON % (localeInfo.NumberToCheque(price)), grp.GenerateColor(0.0, 0.8470, 1.0, 1.0))
  1939.  
  1940.         def AppendSellingCheque(self, price):
  1941.             if price<=0:
  1942.                 return
  1943.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_WON % (localeInfo.NumberToCheque(price)), grp.GenerateColor(0.0, 0.8470, 1.0, 1.0))
  1944.  
  1945.         def AppendSellingCheque2(self, price):
  1946.             if price<=0:
  1947.                 return
  1948.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_SELL_PRICE, grp.GenerateColor(1.0, 0.9686, 0.3098, 1.0))
  1949.             self.AppendTextLine(localeInfo.CHEQUE_SYSTEM_WON % (localeInfo.NumberToCheque(price)), grp.GenerateColor(0.0, 0.8470, 1.0, 1.0))
  1950.  
  1951.     def AppendMetinInformation(self):
  1952.         if constInfo.ENABLE_FULLSTONE_DETAILS:
  1953.             for i in xrange(item.ITEM_APPLY_MAX_NUM):
  1954.                 (affectType, affectValue) = item.GetAffect(i)
  1955.                 affectString = self.__GetAffectString(affectType, affectValue)
  1956.                 if affectString:
  1957.                     self.AppendSpace(5)
  1958.                     self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  1959.  
  1960.     def AppendMetinWearInformation(self):
  1961.  
  1962.         self.AppendSpace(5)
  1963.         self.AppendTextLine(localeInfo.TOOLTIP_SOCKET_REFINABLE_ITEM, self.NORMAL_COLOR)
  1964.  
  1965.         flagList = (item.IsWearableFlag(item.WEARABLE_BODY),
  1966.                     item.IsWearableFlag(item.WEARABLE_HEAD),
  1967.                     item.IsWearableFlag(item.WEARABLE_FOOTS),
  1968.                     item.IsWearableFlag(item.WEARABLE_WRIST),
  1969.                     item.IsWearableFlag(item.WEARABLE_WEAPON),
  1970.                     item.IsWearableFlag(item.WEARABLE_NECK),
  1971.                     item.IsWearableFlag(item.WEARABLE_EAR),
  1972.                     item.IsWearableFlag(item.WEARABLE_UNIQUE),
  1973.                     item.IsWearableFlag(item.WEARABLE_SHIELD),
  1974.                     item.IsWearableFlag(item.WEARABLE_ARROW))
  1975.         if app.ENABLE_PENDANT_SYSTEM:
  1976.             flagList += (item.IsWearableFlag(item.WEARABLE_PENDANT),)
  1977.         if app.ENABLE_GLOVE_SYSTEM:
  1978.             flagList += (item.IsWearableFlag(item.WEARABLE_GLOVE),)
  1979.  
  1980.         wearNames = ""
  1981.         for i in xrange(self.WEAR_COUNT):
  1982.  
  1983.             name = self.WEAR_NAMES[i]
  1984.             flag = flagList[i]
  1985.  
  1986.             if flag:
  1987.                 wearNames += " "*2
  1988.                 wearNames += name
  1989.  
  1990.         textLine = ui.TextLine()
  1991.         textLine.SetParent(self)
  1992.         textLine.SetFontName(self.defFontName)
  1993.         textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  1994.         textLine.SetHorizontalAlignCenter()
  1995.         textLine.SetPackedFontColor(self.NORMAL_COLOR)
  1996.         textLine.SetText(wearNames)
  1997.         textLine.Show()
  1998.         self.childrenList.append(textLine)
  1999.  
  2000.         self.toolTipHeight += self.TEXT_LINE_HEIGHT
  2001.         self.ResizeToolTip()
  2002.  
  2003.     def GetMetinSocketType(self, number):
  2004.         if player.METIN_SOCKET_TYPE_NONE == number:
  2005.             return player.METIN_SOCKET_TYPE_NONE
  2006.         elif player.METIN_SOCKET_TYPE_SILVER == number:
  2007.             return player.METIN_SOCKET_TYPE_SILVER
  2008.         elif player.METIN_SOCKET_TYPE_GOLD == number:
  2009.             return player.METIN_SOCKET_TYPE_GOLD
  2010.         else:
  2011.             item.SelectItem(number)
  2012.             if item.METIN_NORMAL == item.GetItemSubType():
  2013.                 return player.METIN_SOCKET_TYPE_SILVER
  2014.             elif item.METIN_GOLD == item.GetItemSubType():
  2015.                 return player.METIN_SOCKET_TYPE_GOLD
  2016.             elif "USE_PUT_INTO_ACCESSORY_SOCKET" == item.GetUseType(number):
  2017.                 return player.METIN_SOCKET_TYPE_SILVER
  2018.             elif "USE_PUT_INTO_RING_SOCKET" == item.GetUseType(number):
  2019.                 return player.METIN_SOCKET_TYPE_SILVER
  2020.             elif "USE_PUT_INTO_BELT_SOCKET" == item.GetUseType(number):
  2021.                 return player.METIN_SOCKET_TYPE_SILVER
  2022.  
  2023.         return player.METIN_SOCKET_TYPE_NONE
  2024.  
  2025.     def GetMetinItemIndex(self, number):
  2026.         if player.METIN_SOCKET_TYPE_SILVER == number:
  2027.             return 0
  2028.         if player.METIN_SOCKET_TYPE_GOLD == number:
  2029.             return 0
  2030.  
  2031.         return number
  2032.  
  2033.     def __AppendAccessoryMetinSlotInfo(self, metinSlot, mtrlVnum):
  2034.         ACCESSORY_SOCKET_MAX_SIZE = 3
  2035.  
  2036.         cur=min(metinSlot[0], ACCESSORY_SOCKET_MAX_SIZE)
  2037.         end=min(metinSlot[1], ACCESSORY_SOCKET_MAX_SIZE)
  2038.  
  2039.         affectType1, affectValue1 = item.GetAffect(0)
  2040.         affectList1=[0, max(1, affectValue1*10/100), max(2, affectValue1*20/100), max(3, affectValue1*40/100)]
  2041.  
  2042.         affectType2, affectValue2 = item.GetAffect(1)
  2043.         affectList2=[0, max(1, affectValue2*10/100), max(2, affectValue2*20/100), max(3, affectValue2*40/100)]
  2044.  
  2045.         affectType3, affectValue3 = item.GetAffect(2)
  2046.         affectList3=[0, max(1, affectValue3*10/100), max(2, affectValue3*20/100), max(3, affectValue3*40/100)]
  2047.  
  2048.         mtrlPos=0
  2049.         mtrlList=[mtrlVnum]*cur+[player.METIN_SOCKET_TYPE_SILVER]*(end-cur)
  2050.         for mtrl in mtrlList:
  2051.             affectString1 = self.__GetAffectString(affectType1, affectList1[mtrlPos+1]-affectList1[mtrlPos])
  2052.             affectString2 = self.__GetAffectString(affectType2, affectList2[mtrlPos+1]-affectList2[mtrlPos])
  2053.             affectString3 = self.__GetAffectString(affectType3, affectList3[mtrlPos+1]-affectList3[mtrlPos])
  2054.  
  2055.             leftTime = 0
  2056.             if cur == mtrlPos+1:
  2057.                 leftTime=metinSlot[2]
  2058.  
  2059.             self.__AppendMetinSlotInfo_AppendMetinSocketData(mtrlPos, mtrl, affectString1, affectString2, affectString3, leftTime)
  2060.             mtrlPos+=1
  2061.  
  2062.     def __AppendMetinSlotInfo(self, metinSlot):
  2063.         if self.__AppendMetinSlotInfo_IsEmptySlotList(metinSlot):
  2064.             return
  2065.  
  2066.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  2067.             self.__AppendMetinSlotInfo_AppendMetinSocketData(i, metinSlot[i])
  2068.  
  2069.     def __AppendMetinSlotInfo_IsEmptySlotList(self, metinSlot):
  2070.         if 0 == metinSlot:
  2071.             return 1
  2072.  
  2073.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  2074.             metinSlotData=metinSlot[i]
  2075.             if 0 != self.GetMetinSocketType(metinSlotData):
  2076.                 if 0 != self.GetMetinItemIndex(metinSlotData):
  2077.                     return 0
  2078.  
  2079.         return 1
  2080.  
  2081.     def __AppendMetinSlotInfo_AppendMetinSocketData(self, index, metinSlotData, custumAffectString="", custumAffectString2="", custumAffectString3="", leftTime=0):
  2082.  
  2083.         slotType = self.GetMetinSocketType(metinSlotData)
  2084.         itemIndex = self.GetMetinItemIndex(metinSlotData)
  2085.  
  2086.         if 0 == slotType:
  2087.             return
  2088.  
  2089.         self.AppendSpace(5)
  2090.  
  2091.         slotImage = ui.ImageBox()
  2092.         slotImage.SetParent(self)
  2093.         slotImage.Show()
  2094.  
  2095.         ## Name
  2096.         nameTextLine = ui.TextLine()
  2097.         nameTextLine.SetParent(self)
  2098.         nameTextLine.SetFontName(self.defFontName)
  2099.         nameTextLine.SetPackedFontColor(self.NORMAL_COLOR)
  2100.         nameTextLine.SetOutline()
  2101.         nameTextLine.SetFeather()
  2102.         nameTextLine.Show()
  2103.  
  2104.         self.childrenList.append(nameTextLine)
  2105.  
  2106.         if player.METIN_SOCKET_TYPE_SILVER == slotType:
  2107.             slotImage.LoadImage("d:/ymir work/ui/game/windows/metin_slot_silver.sub")
  2108.         elif player.METIN_SOCKET_TYPE_GOLD == slotType:
  2109.             slotImage.LoadImage("d:/ymir work/ui/game/windows/metin_slot_gold.sub")
  2110.  
  2111.         self.childrenList.append(slotImage)
  2112.  
  2113.         if localeInfo.IsARABIC():
  2114.             slotImage.SetPosition(self.toolTipWidth - slotImage.GetWidth() - 9, self.toolTipHeight-1)
  2115.             nameTextLine.SetPosition(self.toolTipWidth - 50, self.toolTipHeight + 2)
  2116.         else:
  2117.             slotImage.SetPosition(9, self.toolTipHeight-1)
  2118.             nameTextLine.SetPosition(50, self.toolTipHeight + 2)
  2119.  
  2120.         metinImage = ui.ImageBox()
  2121.         metinImage.SetParent(self)
  2122.         metinImage.Show()
  2123.         self.childrenList.append(metinImage)
  2124.  
  2125.         if itemIndex:
  2126.  
  2127.             item.SelectItem(itemIndex)
  2128.  
  2129.             ## Image
  2130.             try:
  2131.                 metinImage.LoadImage(item.GetIconImageFileName())
  2132.             except:
  2133.                 dbg.TraceError("ItemToolTip.__AppendMetinSocketData() - Failed to find image file %d:%s" %
  2134.                     (itemIndex, item.GetIconImageFileName())
  2135.                 )
  2136.  
  2137.             nameTextLine.SetText(item.GetItemName())
  2138.  
  2139.             ## Affect
  2140.             affectTextLine = ui.TextLine()
  2141.             affectTextLine.SetParent(self)
  2142.             affectTextLine.SetFontName(self.defFontName)
  2143.             affectTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  2144.             affectTextLine.SetOutline()
  2145.             affectTextLine.SetFeather()
  2146.             affectTextLine.Show()
  2147.  
  2148.             if localeInfo.IsARABIC():
  2149.                 metinImage.SetPosition(self.toolTipWidth - metinImage.GetWidth() - 10, self.toolTipHeight)
  2150.                 affectTextLine.SetPosition(self.toolTipWidth - 50, self.toolTipHeight + 16 + 2)
  2151.             else:
  2152.                 metinImage.SetPosition(10, self.toolTipHeight)
  2153.                 affectTextLine.SetPosition(50, self.toolTipHeight + 16 + 2)
  2154.  
  2155.             if custumAffectString:
  2156.                 affectTextLine.SetText(custumAffectString)
  2157.             elif itemIndex!=constInfo.ERROR_METIN_STONE:
  2158.                 affectType, affectValue = item.GetAffect(0)
  2159.                 affectString = self.__GetAffectString(affectType, affectValue)
  2160.                 if affectString:
  2161.                     affectTextLine.SetText(affectString)
  2162.             else:
  2163.                 affectTextLine.SetText(localeInfo.TOOLTIP_APPLY_NOAFFECT)
  2164.  
  2165.             self.childrenList.append(affectTextLine)
  2166.  
  2167.             if constInfo.ENABLE_FULLSTONE_DETAILS and (not custumAffectString2) and (itemIndex!=constInfo.ERROR_METIN_STONE):
  2168.                 custumAffectString2 = self.__GetAffectString(*item.GetAffect(1))
  2169.  
  2170.             if custumAffectString2:
  2171.                 affectTextLine = ui.TextLine()
  2172.                 affectTextLine.SetParent(self)
  2173.                 affectTextLine.SetFontName(self.defFontName)
  2174.                 affectTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  2175.                 affectTextLine.SetPosition(50, self.toolTipHeight + 16 + 2 + 16 + 2)
  2176.                 affectTextLine.SetOutline()
  2177.                 affectTextLine.SetFeather()
  2178.                 affectTextLine.Show()
  2179.                 affectTextLine.SetText(custumAffectString2)
  2180.                 self.childrenList.append(affectTextLine)
  2181.                 self.toolTipHeight += 16 + 2
  2182.  
  2183.             if constInfo.ENABLE_FULLSTONE_DETAILS and (not custumAffectString3) and (itemIndex!=constInfo.ERROR_METIN_STONE):
  2184.                 custumAffectString3 = self.__GetAffectString(*item.GetAffect(2))
  2185.  
  2186.             if custumAffectString3:
  2187.                 affectTextLine = ui.TextLine()
  2188.                 affectTextLine.SetParent(self)
  2189.                 affectTextLine.SetFontName(self.defFontName)
  2190.                 affectTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  2191.                 affectTextLine.SetPosition(50, self.toolTipHeight + 16 + 2 + 16 + 2)
  2192.                 affectTextLine.SetOutline()
  2193.                 affectTextLine.SetFeather()
  2194.                 affectTextLine.Show()
  2195.                 affectTextLine.SetText(custumAffectString3)
  2196.                 self.childrenList.append(affectTextLine)
  2197.                 self.toolTipHeight += 16 + 2
  2198.  
  2199.             if 0 != leftTime:
  2200.                 timeText = (localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(leftTime))
  2201.  
  2202.                 timeTextLine = ui.TextLine()
  2203.                 timeTextLine.SetParent(self)
  2204.                 timeTextLine.SetFontName(self.defFontName)
  2205.                 timeTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  2206.                 timeTextLine.SetPosition(50, self.toolTipHeight + 16 + 2 + 16 + 2)
  2207.                 timeTextLine.SetOutline()
  2208.                 timeTextLine.SetFeather()
  2209.                 timeTextLine.Show()
  2210.                 timeTextLine.SetText(timeText)
  2211.                 self.childrenList.append(timeTextLine)
  2212.                 self.toolTipHeight += 16 + 2
  2213.  
  2214.         else:
  2215.             nameTextLine.SetText(localeInfo.TOOLTIP_SOCKET_EMPTY)
  2216.  
  2217.         self.toolTipHeight += 35
  2218.         self.ResizeToolTip()
  2219.  
  2220.     def __AppendFishInfo(self, size):
  2221.         if size > 0:
  2222.             self.AppendSpace(5)
  2223.             self.AppendTextLine(localeInfo.TOOLTIP_FISH_LEN % (float(size) / 100.0), self.NORMAL_COLOR)
  2224.  
  2225.     def AppendUniqueItemLastTime(self, restMin):
  2226.         if restMin > 0: # @fixme012
  2227.             restSecond = restMin*60
  2228.             self.AppendSpace(5)
  2229.             self.AppendTextLine(localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(restSecond), self.NORMAL_COLOR)
  2230.  
  2231.     def AppendMallItemLastTime(self, endTime):
  2232.         if endTime > 0: # @fixme012
  2233.             if endTime >= app.GetGlobalTimeStamp():
  2234.                 leftSec = endTime - app.GetGlobalTimeStamp()
  2235.                 self.AppendSpace(5)
  2236.                 self.AppendTextLine(localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(leftSec), self.NORMAL_COLOR)
  2237.             else:
  2238.                 self.AppendSpace(5)
  2239.                 self.AppendTextLine(localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(endTime), self.NORMAL_COLOR)
  2240.  
  2241.     def AppendTimerBasedOnWearLastTime(self, metinSlot):
  2242.         if 0 == metinSlot[0]:
  2243.             self.AppendSpace(5)
  2244.             self.AppendTextLine(localeInfo.CANNOT_USE, self.DISABLE_COLOR)
  2245.         else:
  2246.             endTime = app.GetGlobalTimeStamp() + metinSlot[0]
  2247.             self.AppendMallItemLastTime(endTime)
  2248.  
  2249.     def AppendRealTimeStartFirstUseLastTime(self, item, metinSlot, limitIndex):
  2250.         useCount = metinSlot[1]
  2251.         endTime = metinSlot[0]
  2252.  
  2253.         if 0 == useCount:
  2254.             if 0 == endTime:
  2255.                 (limitType, limitValue) = item.GetLimit(limitIndex)
  2256.                 endTime = limitValue
  2257.  
  2258.             endTime += app.GetGlobalTimeStamp()
  2259.  
  2260.         self.AppendMallItemLastTime(endTime)
  2261.  
  2262.     if app.ENABLE_ACCE_COSTUME_SYSTEM:
  2263.         def SetAcceResultItem(self, slotIndex, window_type = player.INVENTORY):
  2264.             (itemVnum, MinAbs, MaxAbs) = acce.GetResultItem()
  2265.             if not itemVnum:
  2266.                 return
  2267.  
  2268.             self.ClearToolTip()
  2269.  
  2270.             metinSlot   = [player.GetItemMetinSocket(window_type, slotIndex, i)     for i in xrange(player.METIN_SOCKET_MAX_NUM)    ]
  2271.             attrSlot    = [player.GetItemAttribute(window_type, slotIndex, i)       for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)  ]
  2272.  
  2273.             item.SelectItem(itemVnum)
  2274.             itemType = item.GetItemType()
  2275.             itemSubType = item.GetItemSubType()
  2276.             if itemType != item.ITEM_TYPE_COSTUME and itemSubType != item.COSTUME_TYPE_ACCE:
  2277.                 return
  2278.  
  2279.             absChance = MaxAbs
  2280.             itemDesc = item.GetItemDescription()
  2281.             self.__AdjustMaxWidth(attrSlot, itemDesc)
  2282.             self.__SetItemTitle(itemVnum, metinSlot, attrSlot)
  2283.             self.AppendDescription(itemDesc, 26)
  2284.             self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  2285.             self.__AppendLimitInformation()
  2286.  
  2287.             ## ABSORPTION RATE
  2288.             if MinAbs == MaxAbs:
  2289.                 self.AppendTextLine(localeInfo.ACCE_ABSORB_CHANCE % (MinAbs), self.CONDITION_COLOR)
  2290.             else:
  2291.                 self.AppendTextLine(localeInfo.ACCE_ABSORB_CHANCE2 % (MinAbs, MaxAbs), self.CONDITION_COLOR)
  2292.             ## END ABSOPRTION RATE
  2293.  
  2294.             itemAbsorbedVnum = int(metinSlot[acce.ABSORBED_SOCKET])
  2295.             if itemAbsorbedVnum:
  2296.                 ## ATTACK / DEFENCE
  2297.                 item.SelectItem(itemAbsorbedVnum)
  2298.                 if item.GetItemType() == item.ITEM_TYPE_WEAPON:
  2299.                     if item.GetItemSubType() == item.WEAPON_FAN:
  2300.                         self.__AppendMagicAttackInfo(absChance)
  2301.                         item.SelectItem(itemAbsorbedVnum)
  2302.                         self.__AppendAttackPowerInfo(absChance)
  2303.                     else:
  2304.                         self.__AppendAttackPowerInfo(absChance)
  2305.                         item.SelectItem(itemAbsorbedVnum)
  2306.                         self.__AppendMagicAttackInfo(absChance)
  2307.                 elif item.GetItemType() == item.ITEM_TYPE_ARMOR:
  2308.                     defGrade = item.GetValue(1)
  2309.                     defBonus = item.GetValue(5) * 2
  2310.                     defGrade = self.CalcAcceValue(defGrade, absChance)
  2311.                     defBonus = self.CalcAcceValue(defBonus, absChance)
  2312.  
  2313.                     if defGrade > 0:
  2314.                         self.AppendSpace(5)
  2315.                         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_DEF_GRADE % (defGrade + defBonus), self.GetChangeTextLineColor(defGrade))
  2316.  
  2317.                     item.SelectItem(itemAbsorbedVnum)
  2318.                     self.__AppendMagicDefenceInfo(absChance)
  2319.                 ## END ATTACK / DEFENCE
  2320.  
  2321.                 ## EFFECT
  2322.                 item.SelectItem(itemAbsorbedVnum)
  2323.                 for i in xrange(item.ITEM_APPLY_MAX_NUM):
  2324.                     (affectType, affectValue) = item.GetAffect(i)
  2325.                     affectValue = self.CalcAcceValue(affectValue, absChance)
  2326.                     affectString = self.__GetAffectString(affectType, affectValue)
  2327.                     if (not app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue != 0)\
  2328.                             or (app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue > 0):
  2329.                         self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  2330.  
  2331.                     item.SelectItem(itemAbsorbedVnum)
  2332.                 # END EFFECT
  2333.  
  2334.             item.SelectItem(itemVnum)
  2335.             ## ATTR
  2336.             self.__AppendAttributeInformation(attrSlot, MaxAbs)
  2337.             # END ATTR
  2338.  
  2339.             self.AppendWearableInformation()
  2340.             self.ShowToolTip()
  2341.  
  2342.         def SetAcceResultAbsItem(self, slotIndex1, slotIndex2, window_type = player.INVENTORY):
  2343.             itemVnumAcce = player.GetItemIndex(window_type, slotIndex1)
  2344.             itemVnumTarget = player.GetItemIndex(window_type, slotIndex2)
  2345.             if not itemVnumAcce or not itemVnumTarget:
  2346.                 return
  2347.  
  2348.             self.ClearToolTip()
  2349.  
  2350.             item.SelectItem(itemVnumAcce)
  2351.             itemType = item.GetItemType()
  2352.             itemSubType = item.GetItemSubType()
  2353.             if itemType != item.ITEM_TYPE_COSTUME and itemSubType != item.COSTUME_TYPE_ACCE:
  2354.                 return
  2355.  
  2356.             metinSlot = [player.GetItemMetinSocket(window_type, slotIndex1, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
  2357.             attrSlot = [player.GetItemAttribute(window_type, slotIndex2, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  2358.  
  2359.             itemDesc = item.GetItemDescription()
  2360.             self.__AdjustMaxWidth(attrSlot, itemDesc)
  2361.             self.__SetItemTitle(itemVnumAcce, metinSlot, attrSlot)
  2362.             self.AppendDescription(itemDesc, 26)
  2363.             self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  2364.             item.SelectItem(itemVnumAcce)
  2365.             self.__AppendLimitInformation()
  2366.  
  2367.             ## ABSORPTION RATE
  2368.             self.AppendTextLine(localeInfo.ACCE_ABSORB_CHANCE % (metinSlot[acce.ABSORPTION_SOCKET]), self.CONDITION_COLOR)
  2369.             ## END ABSOPRTION RATE
  2370.  
  2371.             ## ATTACK / DEFENCE
  2372.             itemAbsorbedVnum = itemVnumTarget
  2373.             item.SelectItem(itemAbsorbedVnum)
  2374.             if item.GetItemType() == item.ITEM_TYPE_WEAPON:
  2375.                 if item.GetItemSubType() == item.WEAPON_FAN:
  2376.                     self.__AppendMagicAttackInfo(metinSlot[acce.ABSORPTION_SOCKET])
  2377.                     item.SelectItem(itemAbsorbedVnum)
  2378.                     self.__AppendAttackPowerInfo(metinSlot[acce.ABSORPTION_SOCKET])
  2379.                 else:
  2380.                     self.__AppendAttackPowerInfo(metinSlot[acce.ABSORPTION_SOCKET])
  2381.                     item.SelectItem(itemAbsorbedVnum)
  2382.                     self.__AppendMagicAttackInfo(metinSlot[acce.ABSORPTION_SOCKET])
  2383.             elif item.GetItemType() == item.ITEM_TYPE_ARMOR:
  2384.                 defGrade = item.GetValue(1)
  2385.                 defBonus = item.GetValue(5) * 2
  2386.                 defGrade = self.CalcAcceValue(defGrade, metinSlot[acce.ABSORPTION_SOCKET])
  2387.                 defBonus = self.CalcAcceValue(defBonus, metinSlot[acce.ABSORPTION_SOCKET])
  2388.  
  2389.                 if defGrade > 0:
  2390.                     self.AppendSpace(5)
  2391.                     self.AppendTextLine(localeInfo.TOOLTIP_ITEM_DEF_GRADE % (defGrade + defBonus), self.GetChangeTextLineColor(defGrade))
  2392.  
  2393.                 item.SelectItem(itemAbsorbedVnum)
  2394.                 self.__AppendMagicDefenceInfo(metinSlot[acce.ABSORPTION_SOCKET])
  2395.             ## END ATTACK / DEFENCE
  2396.  
  2397.             ## EFFECT
  2398.             item.SelectItem(itemAbsorbedVnum)
  2399.             for i in xrange(item.ITEM_APPLY_MAX_NUM):
  2400.                 (affectType, affectValue) = item.GetAffect(i)
  2401.                 affectValue = self.CalcAcceValue(affectValue, metinSlot[acce.ABSORPTION_SOCKET])
  2402.                 affectString = self.__GetAffectString(affectType, affectValue)
  2403.                 if (not app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue != 0)\
  2404.                         or (app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue > 0):
  2405.                     self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  2406.  
  2407.                 item.SelectItem(itemAbsorbedVnum)
  2408.             ## END EFFECT
  2409.  
  2410.             ## ATTR
  2411.             item.SelectItem(itemAbsorbedVnum)
  2412.             for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  2413.                 type = attrSlot[i][0]
  2414.                 value = attrSlot[i][1]
  2415.                 if not value:
  2416.                     continue
  2417.  
  2418.                 affectValue = self.CalcAcceValue(value, metinSlot[acce.ABSORPTION_SOCKET])
  2419.                 affectString = self.__GetAffectString(type, affectValue)
  2420.                 if (not app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue != 0)\
  2421.                         or (app.USE_ACCE_ABSORB_WITH_NO_NEGATIVE_BONUS and affectString and affectValue > 0):
  2422.                     affectColor = self.__GetAttributeColor(i, affectValue)
  2423.                     self.AppendTextLine(affectString, affectColor)
  2424.  
  2425.                 item.SelectItem(itemAbsorbedVnum)
  2426.             ## END ATTR
  2427.  
  2428.             ## WEARABLE
  2429.             item.SelectItem(itemVnumAcce)
  2430.             self.AppendSpace(5)
  2431.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_WEARABLE_JOB, self.NORMAL_COLOR)
  2432.  
  2433.             item.SelectItem(itemVnumAcce)
  2434.             flagList = (
  2435.                         not item.IsAntiFlag(item.ITEM_ANTIFLAG_WARRIOR),
  2436.                         not item.IsAntiFlag(item.ITEM_ANTIFLAG_ASSASSIN),
  2437.                         not item.IsAntiFlag(item.ITEM_ANTIFLAG_SURA),
  2438.                         not item.IsAntiFlag(item.ITEM_ANTIFLAG_SHAMAN)
  2439.             )
  2440.  
  2441.             if app.ENABLE_WOLFMAN_CHARACTER:
  2442.                 flagList += (not item.IsAntiFlag(item.ITEM_ANTIFLAG_WOLFMAN),)
  2443.  
  2444.             characterNames = ""
  2445.             for i in xrange(self.CHARACTER_COUNT):
  2446.                 name = self.CHARACTER_NAMES[i]
  2447.                 flag = flagList[i]
  2448.                 if flag:
  2449.                     characterNames += " "
  2450.                     characterNames += name
  2451.  
  2452.             textLine = self.AppendTextLine(characterNames, self.NORMAL_COLOR, True)
  2453.             textLine.SetFeather()
  2454.  
  2455.             item.SelectItem(itemVnumAcce)
  2456.             if item.IsAntiFlag(item.ITEM_ANTIFLAG_MALE):
  2457.                 textLine = self.AppendTextLine(localeInfo.FOR_FEMALE, self.NORMAL_COLOR, True)
  2458.                 textLine.SetFeather()
  2459.  
  2460.             if item.IsAntiFlag(item.ITEM_ANTIFLAG_FEMALE):
  2461.                 textLine = self.AppendTextLine(localeInfo.FOR_MALE, self.NORMAL_COLOR, True)
  2462.                 textLine.SetFeather()
  2463.             ## END WEARABLE
  2464.  
  2465.             self.ShowToolTip()
  2466.  
  2467. class HyperlinkItemToolTip(ItemToolTip):
  2468.     def __init__(self):
  2469.         ItemToolTip.__init__(self, isPickable=True)
  2470.  
  2471.     def SetHyperlinkItem(self, tokens):
  2472.         minTokenCount = 3 + player.METIN_SOCKET_MAX_NUM
  2473.         maxTokenCount = minTokenCount + 2 * player.ATTRIBUTE_SLOT_MAX_NUM
  2474.         if tokens and len(tokens) >= minTokenCount and len(tokens) <= maxTokenCount:
  2475.             head, vnum, flag = tokens[:3]
  2476.             itemVnum = int(vnum, 16)
  2477.             metinSlot = [int(metin, 16) for metin in tokens[3:6]]
  2478.  
  2479.             rests = tokens[6:]
  2480.             if rests:
  2481.                 attrSlot = []
  2482.  
  2483.                 rests.reverse()
  2484.                 while rests:
  2485.                     key = int(rests.pop(), 16)
  2486.                     if rests:
  2487.                         val = int(rests.pop())
  2488.                         attrSlot.append((key, val))
  2489.  
  2490.                 attrSlot += [(0, 0)] * (player.ATTRIBUTE_SLOT_MAX_NUM - len(attrSlot))
  2491.             else:
  2492.                 attrSlot = [(0, 0)] * player.ATTRIBUTE_SLOT_MAX_NUM
  2493.  
  2494.             self.ClearToolTip()
  2495.             self.AddItemData(itemVnum, metinSlot, attrSlot)
  2496.  
  2497.             ItemToolTip.OnUpdate(self)
  2498.  
  2499.     def OnUpdate(self):
  2500.         pass
  2501.  
  2502.     def OnMouseLeftButtonDown(self):
  2503.         self.Hide()
  2504.  
  2505. if app.__BL_MULTI_LANGUAGE_PREMIUM__:
  2506.     class CountryToolTip(ToolTip):
  2507.         def __init__(self):
  2508.             ToolTip.__init__(self, isPickable=True)
  2509.  
  2510.         def __del__(self):
  2511.             ToolTip.__del__(self)
  2512.  
  2513.         def OnMouseLeftButtonDown(self):
  2514.             self.Hide()
  2515.  
  2516. class SkillToolTip(ToolTip):
  2517.  
  2518.     POINT_NAME_DICT = {
  2519.         player.LEVEL : localeInfo.SKILL_TOOLTIP_LEVEL,
  2520.         player.IQ : localeInfo.SKILL_TOOLTIP_INT,
  2521.     }
  2522.  
  2523.     SKILL_TOOL_TIP_WIDTH = 200
  2524.     PARTY_SKILL_TOOL_TIP_WIDTH = 340
  2525.  
  2526.     PARTY_SKILL_EXPERIENCE_AFFECT_LIST = (  ( 2, 2, 10,),
  2527.                                             ( 8, 3, 20,),
  2528.                                             (14, 4, 30,),
  2529.                                             (22, 5, 45,),
  2530.                                             (28, 6, 60,),
  2531.                                             (34, 7, 80,),
  2532.                                             (38, 8, 100,), )
  2533.  
  2534.     PARTY_SKILL_PLUS_GRADE_AFFECT_LIST = (  ( 4, 2, 1, 0,),
  2535.                                             (10, 3, 2, 0,),
  2536.                                             (16, 4, 2, 1,),
  2537.                                             (24, 5, 2, 2,), )
  2538.  
  2539.     PARTY_SKILL_ATTACKER_AFFECT_LIST = (    ( 36, 3, ),
  2540.                                             ( 26, 1, ),
  2541.                                             ( 32, 2, ), )
  2542.  
  2543.     SKILL_GRADE_NAME = {    player.SKILL_GRADE_MASTER : localeInfo.SKILL_GRADE_NAME_MASTER,
  2544.                             player.SKILL_GRADE_GRAND_MASTER : localeInfo.SKILL_GRADE_NAME_GRAND_MASTER,
  2545.                             player.SKILL_GRADE_PERFECT_MASTER : localeInfo.SKILL_GRADE_NAME_PERFECT_MASTER, }
  2546.  
  2547.     AFFECT_NAME_DICT =  {
  2548.                             "HP" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_POWER,
  2549.                             "ATT_GRADE" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_GRADE,
  2550.                             "DEF_GRADE" : localeInfo.TOOLTIP_SKILL_AFFECT_DEF_GRADE,
  2551.                             "ATT_SPEED" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_SPEED,
  2552.                             "MOV_SPEED" : localeInfo.TOOLTIP_SKILL_AFFECT_MOV_SPEED,
  2553.                             "DODGE" : localeInfo.TOOLTIP_SKILL_AFFECT_DODGE,
  2554.                             "RESIST_NORMAL" : localeInfo.TOOLTIP_SKILL_AFFECT_RESIST_NORMAL,
  2555.                             "REFLECT_MELEE" : localeInfo.TOOLTIP_SKILL_AFFECT_REFLECT_MELEE,
  2556.                         }
  2557.     AFFECT_APPEND_TEXT_DICT =   {
  2558.                                     "DODGE" : "%",
  2559.                                     "RESIST_NORMAL" : "%",
  2560.                                     "REFLECT_MELEE" : "%",
  2561.                                 }
  2562.  
  2563.     if app.__BL_MULTI_LANGUAGE__:
  2564.         @staticmethod
  2565.         def ReloadVariables():
  2566.             SkillToolTip.POINT_NAME_DICT = {
  2567.                 player.LEVEL : localeInfo.SKILL_TOOLTIP_LEVEL,
  2568.                 player.IQ : localeInfo.SKILL_TOOLTIP_INT,
  2569.             }
  2570.  
  2571.             SkillToolTip.SKILL_GRADE_NAME = {
  2572.                 player.SKILL_GRADE_MASTER : localeInfo.SKILL_GRADE_NAME_MASTER,
  2573.                 player.SKILL_GRADE_GRAND_MASTER : localeInfo.SKILL_GRADE_NAME_GRAND_MASTER,
  2574.                 player.SKILL_GRADE_PERFECT_MASTER : localeInfo.SKILL_GRADE_NAME_PERFECT_MASTER,
  2575.             }
  2576.  
  2577.             SkillToolTip.AFFECT_NAME_DICT = {
  2578.                 "HP" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_POWER,
  2579.                 "ATT_GRADE" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_GRADE,
  2580.                 "DEF_GRADE" : localeInfo.TOOLTIP_SKILL_AFFECT_DEF_GRADE,
  2581.                 "ATT_SPEED" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_SPEED,
  2582.                 "MOV_SPEED" : localeInfo.TOOLTIP_SKILL_AFFECT_MOV_SPEED,
  2583.                 "DODGE" : localeInfo.TOOLTIP_SKILL_AFFECT_DODGE,
  2584.                 "RESIST_NORMAL" : localeInfo.TOOLTIP_SKILL_AFFECT_RESIST_NORMAL,
  2585.                 "REFLECT_MELEE" : localeInfo.TOOLTIP_SKILL_AFFECT_REFLECT_MELEE,
  2586.             }
  2587.  
  2588.     def __init__(self):
  2589.         ToolTip.__init__(self, self.SKILL_TOOL_TIP_WIDTH)
  2590.     def __del__(self):
  2591.         ToolTip.__del__(self)
  2592.  
  2593.     def SetSkill(self, skillIndex, skillLevel = -1):
  2594.  
  2595.         if 0 == skillIndex:
  2596.             return
  2597.  
  2598.         if skill.SKILL_TYPE_GUILD == skill.GetSkillType(skillIndex):
  2599.  
  2600.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  2601.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  2602.                 self.ResizeToolTip()
  2603.  
  2604.             self.AppendDefaultData(skillIndex)
  2605.             self.AppendSkillConditionData(skillIndex)
  2606.             self.AppendGuildSkillData(skillIndex, skillLevel)
  2607.  
  2608.         else:
  2609.  
  2610.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  2611.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  2612.                 self.ResizeToolTip()
  2613.  
  2614.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  2615.             skillGrade = player.GetSkillGrade(slotIndex)
  2616.             skillLevel = player.GetSkillLevel(slotIndex)
  2617.             skillCurrentPercentage = player.GetSkillCurrentEfficientPercentage(slotIndex)
  2618.             skillNextPercentage = player.GetSkillNextEfficientPercentage(slotIndex)
  2619.  
  2620.             self.AppendDefaultData(skillIndex)
  2621.             self.AppendSkillConditionData(skillIndex)
  2622.             self.AppendSkillDataNew(slotIndex, skillIndex, skillGrade, skillLevel, skillCurrentPercentage, skillNextPercentage)
  2623.             self.AppendSkillRequirement(skillIndex, skillLevel)
  2624.  
  2625.         self.ShowToolTip()
  2626.  
  2627.     def SetSkillNew(self, slotIndex, skillIndex, skillGrade, skillLevel):
  2628.  
  2629.         if 0 == skillIndex:
  2630.             return
  2631.  
  2632.         if player.SKILL_INDEX_TONGSOL == skillIndex:
  2633.  
  2634.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  2635.             skillLevel = player.GetSkillLevel(slotIndex)
  2636.  
  2637.             self.AppendDefaultData(skillIndex)
  2638.             self.AppendPartySkillData(skillGrade, skillLevel)
  2639.  
  2640.         elif player.SKILL_INDEX_RIDING == skillIndex:
  2641.  
  2642.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  2643.             self.AppendSupportSkillDefaultData(skillIndex, skillGrade, skillLevel, 30)
  2644.  
  2645.         elif player.SKILL_INDEX_SUMMON == skillIndex:
  2646.  
  2647.             maxLevel = 10
  2648.  
  2649.             self.ClearToolTip()
  2650.             self.__SetSkillTitle(skillIndex, skillGrade)
  2651.  
  2652.             ## Description
  2653.             description = skill.GetSkillDescription(skillIndex)
  2654.             self.AppendDescription(description, 25)
  2655.  
  2656.             if skillLevel == 10:
  2657.                 self.AppendSpace(5)
  2658.                 self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_MASTER % (skillLevel), self.NORMAL_COLOR)
  2659.                 self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (skillLevel*10), self.NORMAL_COLOR)
  2660.  
  2661.             else:
  2662.                 self.AppendSpace(5)
  2663.                 self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel), self.NORMAL_COLOR)
  2664.                 self.__AppendSummonDescription(skillLevel, self.NORMAL_COLOR)
  2665.  
  2666.                 self.AppendSpace(5)
  2667.                 self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel+1), self.NEGATIVE_COLOR)
  2668.                 self.__AppendSummonDescription(skillLevel+1, self.NEGATIVE_COLOR)
  2669.  
  2670.         elif skill.SKILL_TYPE_GUILD == skill.GetSkillType(skillIndex):
  2671.  
  2672.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  2673.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  2674.                 self.ResizeToolTip()
  2675.  
  2676.             self.AppendDefaultData(skillIndex)
  2677.             self.AppendSkillConditionData(skillIndex)
  2678.             self.AppendGuildSkillData(skillIndex, skillLevel)
  2679.  
  2680.         else:
  2681.  
  2682.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  2683.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  2684.                 self.ResizeToolTip()
  2685.  
  2686.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  2687.  
  2688.             skillCurrentPercentage = player.GetSkillCurrentEfficientPercentage(slotIndex)
  2689.             skillNextPercentage = player.GetSkillNextEfficientPercentage(slotIndex)
  2690.  
  2691.             self.AppendDefaultData(skillIndex, skillGrade)
  2692.             self.AppendSkillConditionData(skillIndex)
  2693.             self.AppendSkillDataNew(slotIndex, skillIndex, skillGrade, skillLevel, skillCurrentPercentage, skillNextPercentage)
  2694.             self.AppendSkillRequirement(skillIndex, skillLevel)
  2695.  
  2696.         self.ShowToolTip()
  2697.  
  2698.     def __SetSkillTitle(self, skillIndex, skillGrade):
  2699.         self.SetTitle(skill.GetSkillName(skillIndex, skillGrade))
  2700.         self.__AppendSkillGradeName(skillIndex, skillGrade)
  2701.  
  2702.     def __AppendSkillGradeName(self, skillIndex, skillGrade):
  2703.         if self.SKILL_GRADE_NAME.has_key(skillGrade):
  2704.             self.AppendSpace(5)
  2705.             self.AppendTextLine(self.SKILL_GRADE_NAME[skillGrade] % (skill.GetSkillName(skillIndex, 0)), self.CAN_LEVEL_UP_COLOR)
  2706.  
  2707.     def SetSkillOnlyName(self, slotIndex, skillIndex, skillGrade):
  2708.         if 0 == skillIndex:
  2709.             return
  2710.  
  2711.         slotIndex = player.GetSkillSlotIndex(skillIndex)
  2712.  
  2713.         self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  2714.         self.ResizeToolTip()
  2715.  
  2716.         self.ClearToolTip()
  2717.         self.__SetSkillTitle(skillIndex, skillGrade)
  2718.         self.AppendDefaultData(skillIndex, skillGrade)
  2719.         self.AppendSkillConditionData(skillIndex)
  2720.         self.ShowToolTip()
  2721.  
  2722.     def AppendDefaultData(self, skillIndex, skillGrade = 0):
  2723.         self.ClearToolTip()
  2724.         self.__SetSkillTitle(skillIndex, skillGrade)
  2725.  
  2726.         ## Level Limit
  2727.         levelLimit = skill.GetSkillLevelLimit(skillIndex)
  2728.         if levelLimit > 0:
  2729.  
  2730.             color = self.NORMAL_COLOR
  2731.             if player.GetStatus(player.LEVEL) < levelLimit:
  2732.                 color = self.NEGATIVE_COLOR
  2733.  
  2734.             self.AppendSpace(5)
  2735.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_LEVEL % (levelLimit), color)
  2736.  
  2737.         ## Description
  2738.         description = skill.GetSkillDescription(skillIndex)
  2739.         self.AppendDescription(description, 25)
  2740.  
  2741.     def AppendSupportSkillDefaultData(self, skillIndex, skillGrade, skillLevel, maxLevel):
  2742.         self.ClearToolTip()
  2743.         self.__SetSkillTitle(skillIndex, skillGrade)
  2744.  
  2745.         ## Description
  2746.         description = skill.GetSkillDescription(skillIndex)
  2747.         self.AppendDescription(description, 25)
  2748.  
  2749.         if 1 == skillGrade:
  2750.             skillLevel += 19
  2751.         elif 2 == skillGrade:
  2752.             skillLevel += 29
  2753.         elif 3 == skillGrade:
  2754.             skillLevel = 40
  2755.  
  2756.         self.AppendSpace(5)
  2757.         self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_WITH_MAX % (skillLevel, maxLevel), self.NORMAL_COLOR)
  2758.  
  2759.     def AppendSkillConditionData(self, skillIndex):
  2760.         conditionDataCount = skill.GetSkillConditionDescriptionCount(skillIndex)
  2761.         if conditionDataCount > 0:
  2762.             self.AppendSpace(5)
  2763.             for i in xrange(conditionDataCount):
  2764.                 self.AppendTextLine(skill.GetSkillConditionDescription(skillIndex, i), self.CONDITION_COLOR)
  2765.  
  2766.     def AppendGuildSkillData(self, skillIndex, skillLevel):
  2767.         skillMaxLevel = 7
  2768.         skillCurrentPercentage = float(skillLevel) / float(skillMaxLevel)
  2769.         skillNextPercentage = float(skillLevel+1) / float(skillMaxLevel)
  2770.         ## Current Level
  2771.         if skillLevel > 0:
  2772.             if self.HasSkillLevelDescription(skillIndex, skillLevel):
  2773.                 self.AppendSpace(5)
  2774.                 if skillLevel == skillMaxLevel:
  2775.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_MASTER % (skillLevel), self.NORMAL_COLOR)
  2776.                 else:
  2777.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel), self.NORMAL_COLOR)
  2778.  
  2779.                 #####
  2780.  
  2781.                 for i in xrange(skill.GetSkillAffectDescriptionCount(skillIndex)):
  2782.                     self.AppendTextLine(skill.GetSkillAffectDescription(skillIndex, i, skillCurrentPercentage), self.ENABLE_COLOR)
  2783.  
  2784.                 ## Cooltime
  2785.                 coolTime = skill.GetSkillCoolTime(skillIndex, skillCurrentPercentage)
  2786.                 if coolTime > 0:
  2787.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_COOL_TIME + str(coolTime), self.ENABLE_COLOR)
  2788.  
  2789.                 ## SP
  2790.                 needGSP = skill.GetSkillNeedSP(skillIndex, skillCurrentPercentage)
  2791.                 if needGSP > 0:
  2792.                     self.AppendTextLine(localeInfo.TOOLTIP_NEED_GSP % (needGSP), self.ENABLE_COLOR)
  2793.  
  2794.         ## Next Level
  2795.         if skillLevel < skillMaxLevel:
  2796.             if self.HasSkillLevelDescription(skillIndex, skillLevel+1):
  2797.                 self.AppendSpace(5)
  2798.                 self.AppendTextLine(localeInfo.TOOLTIP_NEXT_SKILL_LEVEL_1 % (skillLevel+1, skillMaxLevel), self.DISABLE_COLOR)
  2799.  
  2800.                 #####
  2801.  
  2802.                 for i in xrange(skill.GetSkillAffectDescriptionCount(skillIndex)):
  2803.                     self.AppendTextLine(skill.GetSkillAffectDescription(skillIndex, i, skillNextPercentage), self.DISABLE_COLOR)
  2804.  
  2805.                 ## Cooltime
  2806.                 coolTime = skill.GetSkillCoolTime(skillIndex, skillNextPercentage)
  2807.                 if coolTime > 0:
  2808.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_COOL_TIME + str(coolTime), self.DISABLE_COLOR)
  2809.  
  2810.                 ## SP
  2811.                 needGSP = skill.GetSkillNeedSP(skillIndex, skillNextPercentage)
  2812.                 if needGSP > 0:
  2813.                     self.AppendTextLine(localeInfo.TOOLTIP_NEED_GSP % (needGSP), self.DISABLE_COLOR)
  2814.  
  2815.     def AppendSkillDataNew(self, slotIndex, skillIndex, skillGrade, skillLevel, skillCurrentPercentage, skillNextPercentage):
  2816.  
  2817.         self.skillMaxLevelStartDict = { 0 : 17, 1 : 7, 2 : 10, }
  2818.         self.skillMaxLevelEndDict = { 0 : 20, 1 : 10, 2 : 10, }
  2819.  
  2820.         skillLevelUpPoint = 1
  2821.         realSkillGrade = player.GetSkillGrade(slotIndex)
  2822.         skillMaxLevelStart = self.skillMaxLevelStartDict.get(realSkillGrade, 15)
  2823.         skillMaxLevelEnd = self.skillMaxLevelEndDict.get(realSkillGrade, 20)
  2824.  
  2825.         ## Current Level
  2826.         if skillLevel > 0:
  2827.             if self.HasSkillLevelDescription(skillIndex, skillLevel):
  2828.                 self.AppendSpace(5)
  2829.                 if skillGrade == skill.SKILL_GRADE_COUNT:
  2830.                     pass
  2831.                 elif skillLevel == skillMaxLevelEnd:
  2832.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_MASTER % (skillLevel), self.NORMAL_COLOR)
  2833.                 else:
  2834.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel), self.NORMAL_COLOR)
  2835.                 self.AppendSkillLevelDescriptionNew(skillIndex, skillCurrentPercentage, self.ENABLE_COLOR)
  2836.  
  2837.         ## Next Level
  2838.         if skillGrade != skill.SKILL_GRADE_COUNT:
  2839.             if skillLevel < skillMaxLevelEnd:
  2840.                 if self.HasSkillLevelDescription(skillIndex, skillLevel+skillLevelUpPoint):
  2841.                     self.AppendSpace(5)
  2842.                     if skillIndex == 141 or skillIndex == 142:
  2843.                         self.AppendTextLine(localeInfo.TOOLTIP_NEXT_SKILL_LEVEL_3 % (skillLevel+1), self.DISABLE_COLOR)
  2844.                     else:
  2845.                         self.AppendTextLine(localeInfo.TOOLTIP_NEXT_SKILL_LEVEL_1 % (skillLevel+1, skillMaxLevelEnd), self.DISABLE_COLOR)
  2846.                     self.AppendSkillLevelDescriptionNew(skillIndex, skillNextPercentage, self.DISABLE_COLOR)
  2847.  
  2848.     def AppendSkillLevelDescriptionNew(self, skillIndex, skillPercentage, color):
  2849.  
  2850.         affectDataCount = skill.GetNewAffectDataCount(skillIndex)
  2851.         if affectDataCount > 0:
  2852.             for i in xrange(affectDataCount):
  2853.                 type, minValue, maxValue = skill.GetNewAffectData(skillIndex, i, skillPercentage)
  2854.  
  2855.                 if not self.AFFECT_NAME_DICT.has_key(type):
  2856.                     continue
  2857.  
  2858.                 minValue = int(minValue)
  2859.                 maxValue = int(maxValue)
  2860.                 affectText = self.AFFECT_NAME_DICT[type]
  2861.  
  2862.                 if "HP" == type:
  2863.                     if minValue < 0 and maxValue < 0:
  2864.                         minValue *= -1
  2865.                         maxValue *= -1
  2866.  
  2867.                     else:
  2868.                         affectText = localeInfo.TOOLTIP_SKILL_AFFECT_HEAL
  2869.  
  2870.                 affectText += str(minValue)
  2871.                 if minValue != maxValue:
  2872.                     affectText += " - " + str(maxValue)
  2873.                 affectText += self.AFFECT_APPEND_TEXT_DICT.get(type, "")
  2874.  
  2875.                 #import debugInfo
  2876.                 #if debugInfo.IsDebugMode():
  2877.                 #   affectText = "!!" + affectText
  2878.  
  2879.                 self.AppendTextLine(affectText, color)
  2880.  
  2881.         else:
  2882.             for i in xrange(skill.GetSkillAffectDescriptionCount(skillIndex)):
  2883.                 self.AppendTextLine(skill.GetSkillAffectDescription(skillIndex, i, skillPercentage), color)
  2884.  
  2885.  
  2886.         ## Duration
  2887.         duration = skill.GetDuration(skillIndex, skillPercentage)
  2888.         if duration > 0:
  2889.             self.AppendTextLine(localeInfo.TOOLTIP_SKILL_DURATION % (duration), color)
  2890.  
  2891.         ## Cooltime
  2892.         coolTime = skill.GetSkillCoolTime(skillIndex, skillPercentage)
  2893.         if coolTime > 0:
  2894.             self.AppendTextLine(localeInfo.TOOLTIP_SKILL_COOL_TIME + str(coolTime), color)
  2895.  
  2896.         ## SP
  2897.         needSP = skill.GetSkillNeedSP(skillIndex, skillPercentage)
  2898.         if needSP != 0:
  2899.             continuationSP = skill.GetSkillContinuationSP(skillIndex, skillPercentage)
  2900.  
  2901.             if skill.IsUseHPSkill(skillIndex):
  2902.                 self.AppendNeedHP(needSP, continuationSP, color)
  2903.             else:
  2904.                 self.AppendNeedSP(needSP, continuationSP, color)
  2905.  
  2906.     def AppendSkillRequirement(self, skillIndex, skillLevel):
  2907.  
  2908.         skillMaxLevel = skill.GetSkillMaxLevel(skillIndex)
  2909.  
  2910.         if skillLevel >= skillMaxLevel:
  2911.             return
  2912.  
  2913.         isAppendHorizontalLine = False
  2914.  
  2915.         ## Requirement
  2916.         if skill.IsSkillRequirement(skillIndex):
  2917.  
  2918.             if not isAppendHorizontalLine:
  2919.                 isAppendHorizontalLine = True
  2920.                 self.AppendHorizontalLine()
  2921.  
  2922.             requireSkillName, requireSkillLevel = skill.GetSkillRequirementData(skillIndex)
  2923.  
  2924.             color = self.CANNOT_LEVEL_UP_COLOR
  2925.             if skill.CheckRequirementSueccess(skillIndex):
  2926.                 color = self.CAN_LEVEL_UP_COLOR
  2927.             self.AppendTextLine(localeInfo.TOOLTIP_REQUIREMENT_SKILL_LEVEL % (requireSkillName, requireSkillLevel), color)
  2928.  
  2929.         ## Require Stat
  2930.         requireStatCount = skill.GetSkillRequireStatCount(skillIndex)
  2931.         if requireStatCount > 0:
  2932.  
  2933.             for i in xrange(requireStatCount):
  2934.                 type, level = skill.GetSkillRequireStatData(skillIndex, i)
  2935.                 if self.POINT_NAME_DICT.has_key(type):
  2936.  
  2937.                     if not isAppendHorizontalLine:
  2938.                         isAppendHorizontalLine = True
  2939.                         self.AppendHorizontalLine()
  2940.  
  2941.                     name = self.POINT_NAME_DICT[type]
  2942.                     color = self.CANNOT_LEVEL_UP_COLOR
  2943.                     if player.GetStatus(type) >= level:
  2944.                         color = self.CAN_LEVEL_UP_COLOR
  2945.                     self.AppendTextLine(localeInfo.TOOLTIP_REQUIREMENT_STAT_LEVEL % (name, level), color)
  2946.  
  2947.     def HasSkillLevelDescription(self, skillIndex, skillLevel):
  2948.         if skill.GetSkillAffectDescriptionCount(skillIndex) > 0:
  2949.             return True
  2950.         if skill.GetSkillCoolTime(skillIndex, skillLevel) > 0:
  2951.             return True
  2952.         if skill.GetSkillNeedSP(skillIndex, skillLevel) > 0:
  2953.             return True
  2954.  
  2955.         return False
  2956.  
  2957.     def AppendMasterAffectDescription(self, index, desc, color):
  2958.         self.AppendTextLine(desc, color)
  2959.  
  2960.     def AppendNextAffectDescription(self, index, desc):
  2961.         self.AppendTextLine(desc, self.DISABLE_COLOR)
  2962.  
  2963.     def AppendNeedHP(self, needSP, continuationSP, color):
  2964.  
  2965.         self.AppendTextLine(localeInfo.TOOLTIP_NEED_HP % (needSP), color)
  2966.  
  2967.         if continuationSP > 0:
  2968.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_HP_PER_SEC % (continuationSP), color)
  2969.  
  2970.     def AppendNeedSP(self, needSP, continuationSP, color):
  2971.  
  2972.         if -1 == needSP:
  2973.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_ALL_SP, color)
  2974.  
  2975.         else:
  2976.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_SP % (needSP), color)
  2977.  
  2978.         if continuationSP > 0:
  2979.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_SP_PER_SEC % (continuationSP), color)
  2980.  
  2981.     def AppendPartySkillData(self, skillGrade, skillLevel):
  2982.         # @fixme008 BEGIN
  2983.         def comma_fix(vl):
  2984.             return vl.replace("%,0f", "%.0f")
  2985.         # @fixme008 END
  2986.  
  2987.         if 1 == skillGrade:
  2988.             skillLevel += 19
  2989.         elif 2 == skillGrade:
  2990.             skillLevel += 29
  2991.         elif 3 == skillGrade:
  2992.             skillLevel = 40
  2993.  
  2994.         if skillLevel <= 0:
  2995.             return
  2996.  
  2997.         skillIndex = player.SKILL_INDEX_TONGSOL
  2998.         slotIndex = player.GetSkillSlotIndex(skillIndex)
  2999.         skillPower = player.GetSkillCurrentEfficientPercentage(slotIndex)
  3000.         k = skillPower # @fixme008
  3001.         self.AppendSpace(5)
  3002.         self.AutoAppendTextLine(localeInfo.TOOLTIP_PARTY_SKILL_LEVEL % skillLevel, self.NORMAL_COLOR)
  3003.  
  3004.         # @fixme008 BEGIN
  3005.         if skillLevel>=10:
  3006.             self.AutoAppendTextLine(comma_fix(localeInfo.PARTY_SKILL_ATTACKER) % chop( 10 + 60 * k ))
  3007.  
  3008.         if skillLevel>=20:
  3009.             self.AutoAppendTextLine(comma_fix(localeInfo.PARTY_SKILL_BERSERKER) % chop(1 + 5 * k))
  3010.             self.AutoAppendTextLine(comma_fix(localeInfo.PARTY_SKILL_TANKER) % chop(50 + 1450 * k))
  3011.  
  3012.         if skillLevel>=25:
  3013.             self.AutoAppendTextLine(comma_fix(localeInfo.PARTY_SKILL_BUFFER) % chop(5 + 45 * k ))
  3014.  
  3015.         if skillLevel>=35:
  3016.             self.AutoAppendTextLine(comma_fix(localeInfo.PARTY_SKILL_SKILL_MASTER) % chop(25 + 600 * k ))
  3017.  
  3018.         if skillLevel>=40:
  3019.             self.AutoAppendTextLine(comma_fix(localeInfo.PARTY_SKILL_DEFENDER) % chop( 5 + 30 * k ))
  3020.         # @fixme008 END
  3021.  
  3022.         self.AlignHorizonalCenter()
  3023.  
  3024.     def __AppendSummonDescription(self, skillLevel, color):
  3025.         if skillLevel > 1:
  3026.             self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (skillLevel * 10), color)
  3027.         elif 1 == skillLevel:
  3028.             self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (15), color)
  3029.         elif 0 == skillLevel:
  3030.             self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (10), color)
  3031.  
Advertisement
Add Comment
Please, Sign In to add comment