Advertisement
Guest User

Untitled

a guest
Aug 8th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 71.78 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. import player
  17. import uiprivateshopbuilder
  18. import ui
  19. import mouseModule
  20. import constInfo
  21.  
  22. WARP_SCROLLS = [22011, 22000, 22010]
  23.  
  24. DESC_DEFAULT_MAX_COLS = 26
  25. DESC_WESTERN_MAX_COLS = 35
  26. DESC_WESTERN_MAX_WIDTH = 220
  27.  
  28. def chop(n):
  29.     return round(n - 0.5, 1)
  30.  
  31. def SplitDescription(desc, limit):
  32.     total_tokens = desc.split()
  33.     line_tokens = []
  34.     line_len = 0
  35.     lines = []
  36.     for token in total_tokens:
  37.         if "|" in token:
  38.             sep_pos = token.find("|")
  39.             line_tokens.append(token[:sep_pos])
  40.  
  41.             lines.append(" ".join(line_tokens))
  42.             line_len = len(token) - (sep_pos + 1)
  43.             line_tokens = [token[sep_pos+1:]]
  44.         else:
  45.             line_len += len(token)
  46.             if len(line_tokens) + line_len > limit:
  47.                 lines.append(" ".join(line_tokens))
  48.                 line_len = len(token)
  49.                 line_tokens = [token]
  50.             else:
  51.                 line_tokens.append(token)
  52.    
  53.     if line_tokens:
  54.         lines.append(" ".join(line_tokens))
  55.  
  56.     return lines
  57.  
  58. ###################################################################################################
  59. ## ToolTip
  60. ##
  61. ##   NOTE : ??? Item? Skill? ???? ?? ?????
  62. ##        ??? ??? ??? ?? ??
  63. ##
  64. class ToolTip(ui.ThinBoard):
  65.  
  66.     TOOL_TIP_WIDTH = 190
  67.     TOOL_TIP_HEIGHT = 10
  68.  
  69.     TEXT_LINE_HEIGHT = 17
  70.  
  71.     TITLE_COLOR = grp.GenerateColor(0.9490, 0.9058, 0.7568, 1.0)
  72.     SPECIAL_TITLE_COLOR = grp.GenerateColor(1.0, 0.7843, 0.0, 1.0)
  73.     NORMAL_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  74.     FONT_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  75.     PRICE_COLOR = 0xffFFB96D
  76.  
  77.     HIGH_PRICE_COLOR = SPECIAL_TITLE_COLOR
  78.     MIDDLE_PRICE_COLOR = grp.GenerateColor(0.85, 0.85, 0.85, 1.0)
  79.     LOW_PRICE_COLOR = grp.GenerateColor(0.7, 0.7, 0.7, 1.0)
  80.  
  81.     ENABLE_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  82.     DISABLE_COLOR = grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)
  83.  
  84.     NEGATIVE_COLOR = grp.GenerateColor(0.9, 0.4745, 0.4627, 1.0)
  85.     POSITIVE_COLOR = grp.GenerateColor(0.5411, 0.7254, 0.5568, 1.0)
  86.     SPECIAL_POSITIVE_COLOR = grp.GenerateColor(0.6911, 0.8754, 0.7068, 1.0)
  87.     SPECIAL_POSITIVE_COLOR2 = grp.GenerateColor(0.8824, 0.9804, 0.8824, 1.0)
  88.  
  89.     CONDITION_COLOR = 0xffBEB47D
  90.     CAN_LEVEL_UP_COLOR = 0xff8EC292
  91.     CANNOT_LEVEL_UP_COLOR = DISABLE_COLOR
  92.     NEED_SKILL_POINT_COLOR = 0xff9A9CDB
  93.     COLOR_VNUM = 0xffFFFF00
  94.  
  95.     def __init__(self, width = TOOL_TIP_WIDTH, isPickable=FALSE):
  96.         ui.ThinBoard.__init__(self, "TOP_MOST")
  97.  
  98.         if isPickable:
  99.             pass
  100.         else:
  101.             self.AddFlag("not_pick")
  102.  
  103.         self.AddFlag("float")
  104.  
  105.         self.followFlag = TRUE
  106.         self.toolTipWidth = width
  107.  
  108.         self.xPos = -1
  109.         self.yPos = -1
  110.  
  111.         self.defFontName = localeInfo.UI_DEF_FONT
  112.         self.ClearToolTip()
  113.         if app.__COMPARE_TOOLTIP__:
  114.             self.CompareTooltip = None
  115.             self.IsCompare = False
  116.  
  117.     def __del__(self):
  118.         ui.ThinBoard.__del__(self)
  119.         if app.__COMPARE_TOOLTIP__ and self.CompareTooltip:
  120.             del self.CompareTooltip
  121.  
  122.     def SetCannotUseItemForceSetDisableColor(self, enable):
  123.         self.bCannotUseItemForceSetDisableColor = enable
  124.  
  125.     def ClearToolTip(self):
  126.         self.toolTipHeight = 12
  127.         self.childrenList = []
  128.  
  129.     def SetFollow(self, flag):
  130.         self.followFlag = flag
  131.  
  132.     def SetDefaultFontName(self, fontName):
  133.         self.defFontName = fontName
  134.  
  135.     def AppendSpace(self, size):
  136.         self.toolTipHeight += size
  137.         self.ResizeToolTip()
  138.  
  139.     def AppendHorizontalLine(self):
  140.  
  141.         for i in xrange(2):
  142.             horizontalLine = ui.Line()
  143.             horizontalLine.SetParent(self)
  144.             horizontalLine.SetPosition(0, self.toolTipHeight + 3 + i)
  145.             horizontalLine.SetWindowHorizontalAlignCenter()
  146.             horizontalLine.SetSize(150, 0)
  147.             horizontalLine.Show()
  148.  
  149.             if 0 == i:
  150.                 horizontalLine.SetColor(0xff555555)
  151.             else:
  152.                 horizontalLine.SetColor(0xff000000)
  153.  
  154.             self.childrenList.append(horizontalLine)
  155.  
  156.         self.toolTipHeight += 11
  157.         self.ResizeToolTip()
  158.  
  159.     def AlignHorizonalCenter(self):
  160.         for child in self.childrenList:
  161.             (x, y)=child.GetLocalPosition()
  162.             child.SetPosition(self.toolTipWidth/2, y)
  163.  
  164.         self.ResizeToolTip()
  165.  
  166.     def AutoAppendTextLine(self, text, color = FONT_COLOR, centerAlign = TRUE):
  167.         textLine = ui.TextLine()
  168.         textLine.SetParent(self)
  169.         textLine.SetFontName(self.defFontName)
  170.         textLine.SetPackedFontColor(color)
  171.         textLine.SetText(text)
  172.         textLine.SetOutline()
  173.         textLine.SetFeather(FALSE)
  174.         textLine.Show()
  175.  
  176.         if centerAlign:
  177.             textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  178.             textLine.SetHorizontalAlignCenter()
  179.  
  180.         else:
  181.             textLine.SetPosition(10, self.toolTipHeight)
  182.  
  183.         self.childrenList.append(textLine)
  184.  
  185.         (textWidth, textHeight)=textLine.GetTextSize()
  186.  
  187.         textWidth += 40
  188.         textHeight += 5
  189.  
  190.         if self.toolTipWidth < textWidth:
  191.             self.toolTipWidth = textWidth
  192.  
  193.         self.toolTipHeight += textHeight
  194.  
  195.         return textLine
  196.  
  197.     def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = TRUE):
  198.         textLine = ui.TextLine()
  199.         textLine.SetParent(self)
  200.         textLine.SetFontName(self.defFontName)
  201.         textLine.SetPackedFontColor(color)
  202.         textLine.SetText(text)
  203.         textLine.SetOutline()
  204.         textLine.SetFeather(FALSE)
  205.         textLine.Show()
  206.  
  207.         if centerAlign:
  208.             textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  209.             textLine.SetHorizontalAlignCenter()
  210.  
  211.         else:
  212.             textLine.SetPosition(10, self.toolTipHeight)
  213.  
  214.         self.childrenList.append(textLine)
  215.  
  216.         self.toolTipHeight += self.TEXT_LINE_HEIGHT
  217.         self.ResizeToolTip()
  218.  
  219.         return textLine
  220.  
  221.     def AppendDescription(self, desc, limit, color = FONT_COLOR):
  222.         if localeInfo.IsEUROPE():
  223.             self.__AppendDescription_WesternLanguage(desc, color)
  224.         else:
  225.             self.__AppendDescription_EasternLanguage(desc, limit, color)
  226.  
  227.     def __AppendDescription_EasternLanguage(self, description, characterLimitation, color=FONT_COLOR):
  228.         length = len(description)
  229.         if 0 == length:
  230.             return
  231.  
  232.         lineCount = grpText.GetSplitingTextLineCount(description, characterLimitation)
  233.         for i in xrange(lineCount):
  234.             if 0 == i:
  235.                 self.AppendSpace(5)
  236.             self.AppendTextLine(grpText.GetSplitingTextLine(description, characterLimitation, i), color)
  237.  
  238.     def __AppendDescription_WesternLanguage(self, desc, color=FONT_COLOR):
  239.         lines = SplitDescription(desc, DESC_WESTERN_MAX_COLS)
  240.         if not lines:
  241.             return
  242.  
  243.         self.AppendSpace(5)
  244.         for line in lines:
  245.             self.AppendTextLine(line, color)
  246.            
  247.  
  248.     def ResizeToolTip(self):
  249.         self.SetSize(self.toolTipWidth, self.TOOL_TIP_HEIGHT + self.toolTipHeight)
  250.  
  251.     def SetTitle(self, name):
  252.         self.AppendTextLine(name, self.TITLE_COLOR)
  253.  
  254.     def GetLimitTextLineColor(self, curValue, limitValue):
  255.         if curValue < limitValue:
  256.             return self.DISABLE_COLOR
  257.  
  258.         return self.ENABLE_COLOR
  259.  
  260.     def GetChangeTextLineColor(self, value, isSpecial=FALSE):
  261.         if value > 0:
  262.             if isSpecial:
  263.                 return self.SPECIAL_POSITIVE_COLOR
  264.             else:
  265.                 return self.POSITIVE_COLOR
  266.  
  267.         if 0 == value:
  268.             return self.NORMAL_COLOR
  269.  
  270.         return self.NEGATIVE_COLOR
  271.  
  272.     def SetToolTipPosition(self, x = -1, y = -1):
  273.         self.xPos = x
  274.         self.yPos = y
  275.  
  276.     def ShowToolTip(self):
  277.         self.SetTop()
  278.         self.Show()
  279.  
  280.         self.OnUpdate()
  281.  
  282.     def HideToolTip(self):
  283.         self.Hide()
  284.         if app.__COMPARE_TOOLTIP__ and self.CompareTooltip:
  285.             self.CompareTooltip.Hide()
  286.  
  287.     if app.__COMPARE_TOOLTIP__:
  288.         def SetCompareItem(self, itemVnum):
  289.             slotIndex = item.GetCompareIndex(itemVnum)
  290.             if slotIndex:
  291.                 if not self.CompareTooltip:
  292.                     self.CompareTooltip = ItemToolTip()
  293.                     self.CompareTooltip.IsCompare = True
  294.  
  295.                 self.CompareTooltip.SetInventoryItem(slotIndex, False)
  296.                 self.CompareTooltip.ResizeToolTip()
  297.  
  298.     def OnUpdate(self):
  299.  
  300.         if not self.followFlag:
  301.             return
  302.  
  303.         x = 0
  304.         y = 0
  305.         width = self.GetWidth()
  306.         height = self.toolTipHeight
  307.  
  308.         if -1 == self.xPos and -1 == self.yPos:
  309.  
  310.             (mouseX, mouseY) = wndMgr.GetMousePosition()
  311.  
  312.             if mouseY < wndMgr.GetScreenHeight() - 200:
  313.                 y = mouseY + 40
  314.             else:
  315.                 y = mouseY - height - 30
  316.  
  317.             x = mouseX - width/2               
  318.  
  319.         else:
  320.  
  321.             x = self.xPos - width/2
  322.             y = self.yPos - height
  323.  
  324.         x = max(x, 0)
  325.         y = max(y, 0)
  326.         x = min(x + width/2, wndMgr.GetScreenWidth() - width/2) - width/2
  327.         y = min(y + self.GetHeight(), wndMgr.GetScreenHeight()) - self.GetHeight()
  328.  
  329.         parentWindow = self.GetParentProxy()
  330.         if parentWindow:
  331.             (gx, gy) = parentWindow.GetGlobalPosition()
  332.             x -= gx
  333.             y -= gy
  334.  
  335.         if app.__COMPARE_TOOLTIP__:
  336.             if self.IsCompare:
  337.                 return
  338.             if self.CompareTooltip:
  339.                 val = [0] * 2
  340.                 if x < self.CompareTooltip.GetWidth():
  341.                     val[0] = self.GetWidth()
  342.                 else:
  343.                     val[0] = -self.CompareTooltip.GetWidth()
  344.                 CompareHeight = wndMgr.GetScreenHeight() - self.CompareTooltip.GetHeight()
  345.                 if y > CompareHeight:
  346.                     val[1] = CompareHeight - y
  347.                 elif y < 0:
  348.                     val[1] = 0 - y
  349.                 self.CompareTooltip.SetPosition(x + val[0], y + val[1])
  350.  
  351.         self.SetPosition(x, y)
  352.  
  353. class ItemToolTip(ToolTip):
  354.     if app.ENABLE_SEND_TARGET_INFO:
  355.         isStone = False
  356.         isBook = False
  357.         isBook2 = False
  358.  
  359.     CHARACTER_NAMES = (
  360.         localeInfo.TOOLTIP_WARRIOR,
  361.         localeInfo.TOOLTIP_ASSASSIN,
  362.         localeInfo.TOOLTIP_SURA,
  363.         localeInfo.TOOLTIP_SHAMAN
  364.     )      
  365.  
  366.     CHARACTER_COUNT = len(CHARACTER_NAMES)
  367.     WEAR_NAMES = (
  368.         localeInfo.TOOLTIP_ARMOR,
  369.         localeInfo.TOOLTIP_HELMET,
  370.         localeInfo.TOOLTIP_SHOES,
  371.         localeInfo.TOOLTIP_WRISTLET,
  372.         localeInfo.TOOLTIP_WEAPON,
  373.         localeInfo.TOOLTIP_NECK,
  374.         localeInfo.TOOLTIP_EAR,
  375.         localeInfo.TOOLTIP_UNIQUE,
  376.         localeInfo.TOOLTIP_SHIELD,
  377.         localeInfo.TOOLTIP_ARROW,
  378.     )
  379.     WEAR_COUNT = len(WEAR_NAMES)
  380.  
  381.     AFFECT_DICT = {
  382.         item.APPLY_MAX_HP : localeInfo.TOOLTIP_MAX_HP,
  383.         item.APPLY_MAX_SP : localeInfo.TOOLTIP_MAX_SP,
  384.         item.APPLY_CON : localeInfo.TOOLTIP_CON,
  385.         item.APPLY_INT : localeInfo.TOOLTIP_INT,
  386.         item.APPLY_STR : localeInfo.TOOLTIP_STR,
  387.         item.APPLY_DEX : localeInfo.TOOLTIP_DEX,
  388.         item.APPLY_ATT_SPEED : localeInfo.TOOLTIP_ATT_SPEED,
  389.         item.APPLY_MOV_SPEED : localeInfo.TOOLTIP_MOV_SPEED,
  390.         item.APPLY_CAST_SPEED : localeInfo.TOOLTIP_CAST_SPEED,
  391.         item.APPLY_HP_REGEN : localeInfo.TOOLTIP_HP_REGEN,
  392.         item.APPLY_SP_REGEN : localeInfo.TOOLTIP_SP_REGEN,
  393.         item.APPLY_POISON_PCT : localeInfo.TOOLTIP_APPLY_POISON_PCT,
  394.         item.APPLY_STUN_PCT : localeInfo.TOOLTIP_APPLY_STUN_PCT,
  395.         item.APPLY_SLOW_PCT : localeInfo.TOOLTIP_APPLY_SLOW_PCT,
  396.         item.APPLY_CRITICAL_PCT : localeInfo.TOOLTIP_APPLY_CRITICAL_PCT,
  397.         item.APPLY_PENETRATE_PCT : localeInfo.TOOLTIP_APPLY_PENETRATE_PCT,
  398.  
  399.         item.APPLY_ATTBONUS_WARRIOR : localeInfo.TOOLTIP_APPLY_ATTBONUS_WARRIOR,
  400.         item.APPLY_ATTBONUS_ASSASSIN : localeInfo.TOOLTIP_APPLY_ATTBONUS_ASSASSIN,
  401.         item.APPLY_ATTBONUS_SURA : localeInfo.TOOLTIP_APPLY_ATTBONUS_SURA,
  402.         item.APPLY_ATTBONUS_SHAMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_SHAMAN,
  403.         item.APPLY_ATTBONUS_MONSTER : localeInfo.TOOLTIP_APPLY_ATTBONUS_MONSTER,
  404.  
  405.         item.APPLY_ATTBONUS_HUMAN : localeInfo.TOOLTIP_APPLY_ATTBONUS_HUMAN,
  406.         item.APPLY_ATTBONUS_ANIMAL : localeInfo.TOOLTIP_APPLY_ATTBONUS_ANIMAL,
  407.         item.APPLY_ATTBONUS_ORC : localeInfo.TOOLTIP_APPLY_ATTBONUS_ORC,
  408.         item.APPLY_ATTBONUS_MILGYO : localeInfo.TOOLTIP_APPLY_ATTBONUS_MILGYO,
  409.         item.APPLY_ATTBONUS_UNDEAD : localeInfo.TOOLTIP_APPLY_ATTBONUS_UNDEAD,
  410.         item.APPLY_ATTBONUS_DEVIL : localeInfo.TOOLTIP_APPLY_ATTBONUS_DEVIL,
  411.         item.APPLY_STEAL_HP : localeInfo.TOOLTIP_APPLY_STEAL_HP,
  412.         item.APPLY_STEAL_SP : localeInfo.TOOLTIP_APPLY_STEAL_SP,
  413.         item.APPLY_MANA_BURN_PCT : localeInfo.TOOLTIP_APPLY_MANA_BURN_PCT,
  414.         item.APPLY_DAMAGE_SP_RECOVER : localeInfo.TOOLTIP_APPLY_DAMAGE_SP_RECOVER,
  415.         item.APPLY_BLOCK : localeInfo.TOOLTIP_APPLY_BLOCK,
  416.         item.APPLY_DODGE : localeInfo.TOOLTIP_APPLY_DODGE,
  417.         item.APPLY_RESIST_SWORD : localeInfo.TOOLTIP_APPLY_RESIST_SWORD,
  418.         item.APPLY_RESIST_TWOHAND : localeInfo.TOOLTIP_APPLY_RESIST_TWOHAND,
  419.         item.APPLY_RESIST_DAGGER : localeInfo.TOOLTIP_APPLY_RESIST_DAGGER,
  420.         item.APPLY_RESIST_BELL : localeInfo.TOOLTIP_APPLY_RESIST_BELL,
  421.         item.APPLY_RESIST_FAN : localeInfo.TOOLTIP_APPLY_RESIST_FAN,
  422.         item.APPLY_RESIST_BOW : localeInfo.TOOLTIP_RESIST_BOW,
  423.         item.APPLY_RESIST_FIRE : localeInfo.TOOLTIP_RESIST_FIRE,
  424.         item.APPLY_RESIST_ELEC : localeInfo.TOOLTIP_RESIST_ELEC,
  425.         item.APPLY_RESIST_MAGIC : localeInfo.TOOLTIP_RESIST_MAGIC,
  426.         item.APPLY_RESIST_WIND : localeInfo.TOOLTIP_APPLY_RESIST_WIND,
  427.         item.APPLY_REFLECT_MELEE : localeInfo.TOOLTIP_APPLY_REFLECT_MELEE,
  428.         item.APPLY_REFLECT_CURSE : localeInfo.TOOLTIP_APPLY_REFLECT_CURSE,
  429.         item.APPLY_POISON_REDUCE : localeInfo.TOOLTIP_APPLY_POISON_REDUCE,
  430.         item.APPLY_KILL_SP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_SP_RECOVER,
  431.         item.APPLY_EXP_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_EXP_DOUBLE_BONUS,
  432.         item.APPLY_GOLD_DOUBLE_BONUS : localeInfo.TOOLTIP_APPLY_GOLD_DOUBLE_BONUS,
  433.         item.APPLY_ITEM_DROP_BONUS : localeInfo.TOOLTIP_APPLY_ITEM_DROP_BONUS,
  434.         item.APPLY_POTION_BONUS : localeInfo.TOOLTIP_APPLY_POTION_BONUS,
  435.         item.APPLY_KILL_HP_RECOVER : localeInfo.TOOLTIP_APPLY_KILL_HP_RECOVER,
  436.         item.APPLY_IMMUNE_STUN : localeInfo.TOOLTIP_APPLY_IMMUNE_STUN,
  437.         item.APPLY_IMMUNE_SLOW : localeInfo.TOOLTIP_APPLY_IMMUNE_SLOW,
  438.         item.APPLY_IMMUNE_FALL : localeInfo.TOOLTIP_APPLY_IMMUNE_FALL,
  439.         item.APPLY_BOW_DISTANCE : localeInfo.TOOLTIP_BOW_DISTANCE,
  440.         item.APPLY_DEF_GRADE_BONUS : localeInfo.TOOLTIP_DEF_GRADE,
  441.         item.APPLY_ATT_GRADE_BONUS : localeInfo.TOOLTIP_ATT_GRADE,
  442.         item.APPLY_MAGIC_ATT_GRADE : localeInfo.TOOLTIP_MAGIC_ATT_GRADE,
  443.         item.APPLY_MAGIC_DEF_GRADE : localeInfo.TOOLTIP_MAGIC_DEF_GRADE,
  444.         item.APPLY_MAX_STAMINA : localeInfo.TOOLTIP_MAX_STAMINA,
  445.         item.APPLY_MALL_ATTBONUS : localeInfo.TOOLTIP_MALL_ATTBONUS,
  446.         item.APPLY_MALL_DEFBONUS : localeInfo.TOOLTIP_MALL_DEFBONUS,
  447.         item.APPLY_MALL_EXPBONUS : localeInfo.TOOLTIP_MALL_EXPBONUS,
  448.         item.APPLY_MALL_ITEMBONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS,
  449.         item.APPLY_MALL_GOLDBONUS : localeInfo.TOOLTIP_MALL_GOLDBONUS,
  450.         item.APPLY_SKILL_DAMAGE_BONUS : localeInfo.TOOLTIP_SKILL_DAMAGE_BONUS,
  451.         item.APPLY_NORMAL_HIT_DAMAGE_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DAMAGE_BONUS,
  452.         item.APPLY_SKILL_DEFEND_BONUS : localeInfo.TOOLTIP_SKILL_DEFEND_BONUS,
  453.         item.APPLY_NORMAL_HIT_DEFEND_BONUS : localeInfo.TOOLTIP_NORMAL_HIT_DEFEND_BONUS,
  454.         item.APPLY_PC_BANG_EXP_BONUS : localeInfo.TOOLTIP_MALL_EXPBONUS_P_STATIC,
  455.         item.APPLY_PC_BANG_DROP_BONUS : localeInfo.TOOLTIP_MALL_ITEMBONUS_P_STATIC,    
  456.         item.APPLY_RESIST_WARRIOR : localeInfo.TOOLTIP_APPLY_RESIST_WARRIOR,
  457.         item.APPLY_RESIST_ASSASSIN : localeInfo.TOOLTIP_APPLY_RESIST_ASSASSIN,
  458.         item.APPLY_RESIST_SURA : localeInfo.TOOLTIP_APPLY_RESIST_SURA,
  459.         item.APPLY_RESIST_SHAMAN : localeInfo.TOOLTIP_APPLY_RESIST_SHAMAN,
  460.     }
  461.  
  462.     ATTRIBUTE_NEED_WIDTH = {
  463.         23 : 230,
  464.         24 : 230,
  465.         25 : 230,
  466.         26 : 220,
  467.         27 : 210,
  468.  
  469.         35 : 210,
  470.         36 : 210,
  471.         37 : 210,
  472.         38 : 210,
  473.         39 : 210,
  474.         40 : 210,
  475.         41 : 210,
  476.  
  477.         42 : 220,
  478.         43 : 230,
  479.         45 : 230,
  480.     }
  481.  
  482.     ANTI_FLAG_DICT = {
  483.         0 : item.ITEM_ANTIFLAG_WARRIOR,
  484.         1 : item.ITEM_ANTIFLAG_ASSASSIN,
  485.         2 : item.ITEM_ANTIFLAG_SURA,
  486.         3 : item.ITEM_ANTIFLAG_SHAMAN,
  487.     }
  488.  
  489.     FONT_COLOR = grp.GenerateColor(0.7607, 0.7607, 0.7607, 1.0)
  490.  
  491.     def __init__(self, *args, **kwargs):
  492.         ToolTip.__init__(self, *args, **kwargs)
  493.         self.itemVnum = 0
  494.         self.isShopItem = FALSE
  495.  
  496.     def __del__(self):
  497.         ToolTip.__del__(self)
  498.  
  499.     def CanEquip(self):
  500.         if not item.IsEquipmentVID(self.itemVnum):
  501.             return TRUE
  502.  
  503.         race = player.GetRace()
  504.         job = chr.RaceToJob(race)
  505.         if not self.ANTI_FLAG_DICT.has_key(job):
  506.             return FALSE
  507.  
  508.         if item.IsAntiFlag(self.ANTI_FLAG_DICT[job]):
  509.             return FALSE
  510.  
  511.         sex = chr.RaceToSex(race)
  512.        
  513.         MALE = 1
  514.         FEMALE = 0
  515.  
  516.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_MALE) and sex == MALE:
  517.             return FALSE
  518.  
  519.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_FEMALE) and sex == FEMALE:
  520.             return FALSE
  521.  
  522.         for i in xrange(item.LIMIT_MAX_NUM):
  523.             (limitType, limitValue) = item.GetLimit(i)
  524.  
  525.             if item.LIMIT_LEVEL == limitType:
  526.                 if player.GetStatus(player.LEVEL) < limitValue:
  527.                     return FALSE
  528.             """
  529.             elif item.LIMIT_STR == limitType:
  530.                 if player.GetStatus(player.ST) < limitValue:
  531.                     return FALSE
  532.             elif item.LIMIT_DEX == limitType:
  533.                 if player.GetStatus(player.DX) < limitValue:
  534.                     return FALSE
  535.             elif item.LIMIT_INT == limitType:
  536.                 if player.GetStatus(player.IQ) < limitValue:
  537.                     return FALSE
  538.             elif item.LIMIT_CON == limitType:
  539.                 if player.GetStatus(player.HT) < limitValue:
  540.                     return FALSE
  541.             """
  542.  
  543.         return TRUE
  544.  
  545.     def AppendTextLine(self, text, color = FONT_COLOR, centerAlign = TRUE):
  546.  
  547.         if not self.CanEquip():
  548.             color = self.DISABLE_COLOR
  549.  
  550.         return ToolTip.AppendTextLine(self, text, color, centerAlign)
  551.  
  552.     def ClearToolTip(self):
  553.         self.isShopItem = FALSE
  554.         self.toolTipWidth = self.TOOL_TIP_WIDTH
  555.         ToolTip.ClearToolTip(self)
  556.  
  557.     def SetInventoryItem(self, slotIndex, CompareItem = True):
  558.         itemVnum = player.GetItemIndex(slotIndex)
  559.         if 0 == itemVnum:
  560.             return
  561.  
  562.         self.ClearToolTip()
  563.         if shop.IsOpen():
  564.             if not shop.IsPrivateShop():
  565.                 item.SelectItem(itemVnum)
  566.                 self.AppendSellingPrice(player.GetISellItemPrice(slotIndex))
  567.  
  568.         metinSlot = [player.GetItemMetinSocket(slotIndex, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
  569.         attrSlot = [player.GetItemAttribute(slotIndex, i) for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM)]
  570.  
  571.         #print itemVnum, metinSlot, attrSlot
  572.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  573.         if app.ENABLE_SEND_TARGET_INFO:
  574.             def SetItemToolTipStone(self, itemVnum):
  575.                 self.itemVnum = itemVnum
  576.                 item.SelectItem(itemVnum)
  577.                 itemType = item.GetItemType()
  578.  
  579.                 itemDesc = item.GetItemDescription()
  580.                 itemSummary = item.GetItemSummary()
  581.                 attrSlot = 0
  582.                 self.__AdjustMaxWidth(attrSlot, itemDesc)
  583.                 itemName = item.GetItemName()
  584.                 realName = itemName[:itemName.find("+")]
  585.                 self.SetTitle(realName + " +0 - +4")
  586.  
  587.                 ## Description ###
  588.                 self.AppendDescription(itemDesc, 26)
  589.                 self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
  590.  
  591.                 if item.ITEM_TYPE_METIN == itemType:
  592.                     self.AppendMetinInformation()
  593.                     self.AppendMetinWearInformation()
  594.  
  595.                 for i in xrange(item.LIMIT_MAX_NUM):
  596.                     (limitType, limitValue) = item.GetLimit(i)
  597.  
  598.                     if item.LIMIT_REAL_TIME_START_FIRST_USE == limitType:
  599.                         self.AppendRealTimeStartFirstUseLastTime(item, metinSlot, i)
  600.  
  601.                     elif item.LIMIT_TIMER_BASED_ON_WEAR == limitType:
  602.                         self.AppendTimerBasedOnWearLastTime(metinSlot)
  603.  
  604.             self.ShowToolTip()
  605.         if app.__COMPARE_TOOLTIP__ and app.IsPressed(app.DIK_LALT) and not slotIndex >= player.EQUIPMENT_SLOT_START and CompareItem:
  606.             self.SetCompareItem(itemVnum)
  607.             return
  608.  
  609.     def SetShopItem(self, slotIndex):
  610.         itemVnum = shop.GetItemID(slotIndex)
  611.         if 0 == itemVnum:
  612.             return
  613.  
  614.         price = shop.GetItemPrice(slotIndex)
  615.         self.ClearToolTip()
  616.         self.isShopItem = TRUE
  617.  
  618.         metinSlot = []
  619.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  620.             metinSlot.append(shop.GetItemMetinSocket(slotIndex, i))
  621.         attrSlot = []
  622.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  623.             attrSlot.append(shop.GetItemAttribute(slotIndex, i))
  624.  
  625.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  626.         self.AppendPrice(price)
  627.         if app.__COMPARE_TOOLTIP__ and shop.IsOpen() and not shop.IsMainPlayerPrivateShop():
  628.             self.SetCompareItem(itemVnum)
  629.  
  630.     def SetExchangeOwnerItem(self, slotIndex):
  631.         itemVnum = exchange.GetItemVnumFromSelf(slotIndex)
  632.         if 0 == itemVnum:
  633.             return
  634.  
  635.         self.ClearToolTip()
  636.  
  637.         metinSlot = []
  638.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  639.             metinSlot.append(exchange.GetItemMetinSocketFromSelf(slotIndex, i))
  640.         attrSlot = []
  641.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  642.             attrSlot.append(exchange.GetItemAttributeFromSelf(slotIndex, i))
  643.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  644.         if app.__COMPARE_TOOLTIP__:
  645.             self.SetCompareItem(itemVnum)
  646.  
  647.     def SetExchangeTargetItem(self, slotIndex):
  648.         itemVnum = exchange.GetItemVnumFromTarget(slotIndex)
  649.         if 0 == itemVnum:
  650.             return
  651.  
  652.         self.ClearToolTip()
  653.  
  654.         metinSlot = []
  655.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  656.             metinSlot.append(exchange.GetItemMetinSocketFromTarget(slotIndex, i))
  657.         attrSlot = []
  658.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  659.             attrSlot.append(exchange.GetItemAttributeFromTarget(slotIndex, i))
  660.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  661.  
  662.     def SetPrivateShopBuilderItem(self, inventorySlotIndex, privateShopSlotIndex):
  663.         itemVnum = player.GetItemIndex(inventorySlotIndex)
  664.         if 0 == itemVnum:
  665.             return
  666.  
  667.         item.SelectItem(itemVnum)
  668.         self.ClearToolTip()
  669.         self.AppendSellingPrice(shop.GetPrivateShopItemPrice(inventorySlotIndex))
  670.  
  671.         metinSlot = []
  672.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  673.             metinSlot.append(player.GetItemMetinSocket(inventorySlotIndex, i))
  674.         attrSlot = []
  675.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  676.             attrSlot.append(player.GetItemAttribute(inventorySlotIndex, i))
  677.  
  678.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  679.  
  680.     def SetSafeBoxItem(self, slotIndex):
  681.         itemVnum = safebox.GetItemID(slotIndex)
  682.         if 0 == itemVnum:
  683.             return
  684.  
  685.         self.ClearToolTip()
  686.         metinSlot = []
  687.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  688.             metinSlot.append(safebox.GetItemMetinSocket(slotIndex, i))
  689.         attrSlot = []
  690.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  691.             attrSlot.append(safebox.GetItemAttribute(slotIndex, i))
  692.  
  693.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  694.         if app.__COMPARE_TOOLTIP__:
  695.             self.SetCompareItem(itemVnum)
  696.  
  697.     def SetMallItem(self, slotIndex):
  698.         itemVnum = safebox.GetMallItemID(slotIndex)
  699.         if 0 == itemVnum:
  700.             return
  701.  
  702.         self.ClearToolTip()
  703.         metinSlot = []
  704.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  705.             metinSlot.append(safebox.GetMallItemMetinSocket(slotIndex, i))
  706.         attrSlot = []
  707.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  708.             attrSlot.append(safebox.GetMallItemAttribute(slotIndex, i))
  709.  
  710.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  711.         if app.__COMPARE_TOOLTIP__:
  712.             self.SetCompareItem(itemVnum)
  713.  
  714.     def SetItemToolTip(self, itemVnum):
  715.         self.ClearToolTip()
  716.         metinSlot = []
  717.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  718.             metinSlot.append(0)
  719.         attrSlot = []
  720.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  721.             attrSlot.append((0, 0))
  722.  
  723.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  724.  
  725.     def __AppendAttackSpeedInfo(self, item):
  726.         atkSpd = item.GetValue(0)
  727.  
  728.         if atkSpd < 80:
  729.             stSpd = localeInfo.TOOLTIP_ITEM_VERY_FAST
  730.         elif atkSpd <= 95:
  731.             stSpd = localeInfo.TOOLTIP_ITEM_FAST
  732.         elif atkSpd <= 105:
  733.             stSpd = localeInfo.TOOLTIP_ITEM_NORMAL
  734.         elif atkSpd <= 120:
  735.             stSpd = localeInfo.TOOLTIP_ITEM_SLOW
  736.         else:
  737.             stSpd = localeInfo.TOOLTIP_ITEM_VERY_SLOW
  738.  
  739.         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_SPEED % stSpd, self.NORMAL_COLOR)
  740.  
  741.     def __AppendAttackGradeInfo(self):
  742.         atkGrade = item.GetValue(1)
  743.         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_GRADE % atkGrade, self.GetChangeTextLineColor(atkGrade))
  744.  
  745.     def __AppendAttackPowerInfo(self):
  746.         minPower = item.GetValue(3)
  747.         maxPower = item.GetValue(4)
  748.         addPower = item.GetValue(5)
  749.         if maxPower > minPower:
  750.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_POWER % (minPower+addPower, maxPower+addPower), self.POSITIVE_COLOR)
  751.         else:
  752.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_ATT_POWER_ONE_ARG % (minPower+addPower), self.POSITIVE_COLOR)
  753.  
  754.     def __AppendMagicAttackInfo(self):
  755.         minMagicAttackPower = item.GetValue(1)
  756.         maxMagicAttackPower = item.GetValue(2)
  757.         addPower = item.GetValue(5)
  758.  
  759.         if minMagicAttackPower > 0 or maxMagicAttackPower > 0:
  760.             if maxMagicAttackPower > minMagicAttackPower:
  761.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_ATT_POWER % (minMagicAttackPower+addPower, maxMagicAttackPower+addPower), self.POSITIVE_COLOR)
  762.             else:
  763.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_ATT_POWER_ONE_ARG % (minMagicAttackPower+addPower), self.POSITIVE_COLOR)
  764.  
  765.     def __AppendMagicDefenceInfo(self):
  766.         magicDefencePower = item.GetValue(0)
  767.  
  768.         if magicDefencePower > 0:
  769.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_MAGIC_DEF_POWER % magicDefencePower, self.GetChangeTextLineColor(magicDefencePower))
  770.  
  771.     def __item_vnum(self, itemVnum):
  772.         self.AppendTextLine(localeInfo.TOOLTIP_VNUM_ITEM % (itemVnum),0xff00CED1)
  773.  
  774.  
  775.     def __AppendAttributeInformation(self, attrSlot):
  776.         if 0 != attrSlot:
  777.  
  778.             for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  779.                 type = attrSlot[i][0]
  780.                 value = attrSlot[i][1]
  781.  
  782.                 if 0 == value:
  783.                     continue
  784.  
  785.                 affectString = self.__GetAffectString(type, value)
  786.                 if affectString:
  787.                     affectColor = self.__GetAttributeColor(i, value)
  788.                     self.AppendTextLine(affectString, affectColor)
  789.  
  790.     def __GetAttributeColor(self, index, value):
  791.         if value > 0:
  792.             if index >= 5:
  793.                 return self.SPECIAL_POSITIVE_COLOR2
  794.             else:
  795.                 return self.SPECIAL_POSITIVE_COLOR
  796.         elif value == 0:
  797.             return self.NORMAL_COLOR
  798.         else:
  799.             return self.NEGATIVE_COLOR
  800.  
  801.     def __IsPolymorphItem(self, itemVnum):
  802.         if itemVnum >= 70103 and itemVnum <= 70106:
  803.             return 1
  804.         return 0
  805.  
  806.     def __SetPolymorphItemTitle(self, monsterVnum):
  807.         if localeInfo.IsVIETNAM():
  808.             itemName =item.GetItemName()
  809.             itemName+=" "
  810.             itemName+=nonplayer.GetMonsterName(monsterVnum)
  811.         else:
  812.             itemName =nonplayer.GetMonsterName(monsterVnum)
  813.             itemName+=" "
  814.             itemName+=item.GetItemName()
  815.         self.SetTitle(itemName)
  816.  
  817.     def __SetNormalItemTitle(self):
  818.         if app.ENABLE_SEND_TARGET_INFO:
  819.             if self.isStone:
  820.                 itemName = item.GetItemName()
  821.                 realName = itemName[:itemName.find("+")]
  822.                 self.SetTitle(realName + " +0 - +4")
  823.             else:
  824.                 self.SetTitle(item.GetItemName())
  825.         else:
  826.             self.SetTitle(item.GetItemName())
  827.  
  828.     def __SetSpecialItemTitle(self):
  829.         self.AppendTextLine(item.GetItemName(), self.SPECIAL_TITLE_COLOR)
  830.  
  831.     def __SetItemTitle(self, itemVnum, metinSlot, attrSlot):
  832.         if self.__IsPolymorphItem(itemVnum):
  833.             self.__SetPolymorphItemTitle(metinSlot[0])
  834.         else:
  835.             if self.__IsAttr(attrSlot):
  836.                 self.__SetSpecialItemTitle()
  837.                 return
  838.  
  839.             self.__SetNormalItemTitle()
  840.  
  841.     def __IsAttr(self, attrSlot):
  842.         if not attrSlot:
  843.             return FALSE
  844.  
  845.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  846.             type = attrSlot[i][0]
  847.             if 0 != type:
  848.                 return TRUE
  849.  
  850.         return FALSE
  851.    
  852.     def AddRefineItemData(self, itemVnum, metinSlot, attrSlot = 0):
  853.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  854.             metinSlotData=metinSlot[i]
  855.             if self.GetMetinItemIndex(metinSlotData) == constInfo.ERROR_METIN_STONE:
  856.                 metinSlot[i]=player.METIN_SOCKET_TYPE_SILVER
  857.  
  858.         self.AddItemData(itemVnum, metinSlot, attrSlot)
  859.  
  860.     def AddItemData_Offline(self, itemVnum, itemDesc, itemSummary, metinSlot, attrSlot):
  861.         self.__AdjustMaxWidth(attrSlot, itemDesc)
  862.         self.__SetItemTitle(itemVnum, metinSlot, attrSlot)
  863.        
  864.         if self.__IsHair(itemVnum):
  865.             self.__AppendHairIcon(itemVnum)
  866.  
  867.         ### Description ###
  868.         self.AppendDescription(itemDesc, 26)
  869.         self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
  870.  
  871.     def AddItemData(self, itemVnum, metinSlot, attrSlot = 0):
  872.  
  873.         self.itemVnum = itemVnum
  874.         item.SelectItem(itemVnum)
  875.         itemType = item.GetItemType()
  876.         itemSubType = item.GetItemSubType()
  877.  
  878.         if 50026 == itemVnum:
  879.             if 0 != metinSlot:
  880.                 name = item.GetItemName()
  881.                 if metinSlot[0] > 0:
  882.                     name += " "
  883.                     name += localeInfo.NumberToMoneyString(metinSlot[0])
  884.                 self.SetTitle(name)
  885.                 self.ShowToolTip()
  886.             return
  887.  
  888.         ### Skill Book ###
  889.         if app.ENABLE_SEND_TARGET_INFO:
  890.             if 50300 == itemVnum and not self.isBook:
  891.                 if 0 != metinSlot and not self.isBook:
  892.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILLBOOK_NAME, 1)
  893.                     self.ShowToolTip()
  894.                 elif self.isBook:
  895.                     self.SetTitle(item.GetItemName())
  896.                     self.AppendDescription(item.GetItemDescription(), 26)
  897.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  898.                     self.ShowToolTip()                 
  899.                 return
  900.             elif 70037 == itemVnum :
  901.                 if 0 != metinSlot and not self.isBook2:
  902.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  903.                     self.AppendDescription(item.GetItemDescription(), 26)
  904.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  905.                     self.ShowToolTip()
  906.                 elif self.isBook2:
  907.                     self.SetTitle(item.GetItemName())
  908.                     self.AppendDescription(item.GetItemDescription(), 26)
  909.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  910.                     self.ShowToolTip()                 
  911.                 return
  912.             elif 70055 == itemVnum:
  913.                 if 0 != metinSlot:
  914.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  915.                     self.AppendDescription(item.GetItemDescription(), 26)
  916.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  917.                     self.ShowToolTip()
  918.                 return
  919.         else:
  920.             if 50300 == itemVnum:
  921.                 if 0 != metinSlot:
  922.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILLBOOK_NAME, 1)
  923.                     self.ShowToolTip()
  924.                 return
  925.             elif 70037 == itemVnum:
  926.                 if 0 != metinSlot:
  927.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  928.                     self.AppendDescription(item.GetItemDescription(), 26)
  929.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  930.                     self.ShowToolTip()
  931.                 return
  932.             elif 70055 == itemVnum:
  933.                 if 0 != metinSlot:
  934.                     self.__SetSkillBookToolTip(metinSlot[0], localeInfo.TOOLTIP_SKILL_FORGET_BOOK_NAME, 0)
  935.                     self.AppendDescription(item.GetItemDescription(), 26)
  936.                     self.AppendDescription(item.GetItemSummary(), 26, self.CONDITION_COLOR)
  937.                     self.ShowToolTip()
  938.                 return
  939.  
  940.         if 27989 == itemVnum or 76006 == itemVnum:
  941.             if 0 != metinSlot:
  942.                 useCount = int(metinSlot[0])
  943.                 self.AppendTextLine("Codul obiectului: %i" % itemVnum)
  944.                 name = item.GetItemName()
  945.                 self.SetTitle(name)
  946.                 self.AppendDescription(item.GetItemDescription(), 26)
  947.                 self.AppendTextLine(localeInfo.TOOLTIP_REST_USABLE_COUNT % (6 - useCount), self.NORMAL_COLOR)
  948.                 self.ShowToolTip()
  949.             return
  950.  
  951.         if 73763 == itemVnum:
  952.             if 0 != metinSlot:
  953.                 self.AppendTextLine("Codul obiectului: %i" % itemVnum)
  954.                 name = item.GetItemName()
  955.                 self.SetTitle(name)
  956.                 self.AppendDescription(item.GetItemDescription(), 26)
  957.                 self.ShowToolTip()
  958.             return
  959.  
  960.         ###########################################################################################
  961.  
  962.         if chr.IsGameMaster(player.GetMainCharacterIndex()):
  963.             self.AppendTextLine("Codul obiectului: %i" % itemVnum)
  964.  
  965.         self.ShowToolTip()
  966.  
  967.         itemDesc = item.GetItemDescription()
  968.         itemSummary = item.GetItemSummary()
  969.  
  970.         self.__AdjustMaxWidth(attrSlot, itemDesc)
  971.         self.__SetItemTitle(itemVnum, metinSlot, attrSlot)
  972.        
  973.         if self.__IsHair(itemVnum):
  974.             self.__AppendHairIcon(itemVnum)
  975.  
  976.         ### Description ###
  977.         self.AppendDescription(itemDesc, 26)
  978.         self.AppendDescription(itemSummary, 26, self.CONDITION_COLOR)
  979.  
  980.         ### Weapon ###
  981.         if item.ITEM_TYPE_WEAPON == itemType:
  982.  
  983.             self.__AppendLimitInformation()
  984.  
  985.             self.AppendSpace(5)
  986.  
  987.             ## ??? ?? ??? ?? ????.
  988.             if item.WEAPON_FAN == itemSubType:
  989.                 self.__AppendMagicAttackInfo()
  990.                 self.__AppendAttackPowerInfo()
  991.  
  992.             else:
  993.                 self.__AppendAttackPowerInfo()
  994.                 self.__AppendMagicAttackInfo()
  995.  
  996.             self.__AppendAffectInformation()
  997.             self.__AppendAttributeInformation(attrSlot)
  998.  
  999.             self.AppendWearableInformation()
  1000.             self.__AppendMetinSlotInfo(metinSlot)
  1001.  
  1002.         ### Armor ###
  1003.         elif item.ITEM_TYPE_ARMOR == itemType:
  1004.             self.__AppendLimitInformation()
  1005.  
  1006.             ## ???
  1007.             defGrade = item.GetValue(1)
  1008.             defBonus = item.GetValue(5)*2 ## ??? ?? ?? ?? ??? ??
  1009.             if defGrade > 0:
  1010.                 self.AppendSpace(5)
  1011.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_DEF_GRADE % (defGrade+defBonus), self.GetChangeTextLineColor(defGrade))
  1012.  
  1013.             self.__AppendMagicDefenceInfo()
  1014.             self.__AppendAffectInformation()
  1015.             self.__AppendAttributeInformation(attrSlot)
  1016.  
  1017.             self.AppendWearableInformation()
  1018.  
  1019.             if itemSubType in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):             
  1020.                 self.__AppendAccessoryMetinSlotInfo(metinSlot, constInfo.GET_ACCESSORY_MATERIAL_VNUM(itemVnum, itemSubType))
  1021.             else:
  1022.                 self.__AppendMetinSlotInfo(metinSlot)
  1023.  
  1024.         ## Rod ##
  1025.         elif item.ITEM_TYPE_ROD == itemType:
  1026.  
  1027.             if 0 != metinSlot:
  1028.                 curLevel = item.GetValue(0) / 10
  1029.                 curEXP = metinSlot[0]
  1030.                 maxEXP = item.GetValue(2)
  1031.                 self.__AppendLimitInformation()
  1032.                 self.__AppendRodInformation(curLevel, curEXP, maxEXP)
  1033.  
  1034.         ## Pick ##
  1035.         elif item.ITEM_TYPE_PICK == itemType:
  1036.  
  1037.             if 0 != metinSlot:
  1038.                 curLevel = item.GetValue(0) / 10
  1039.                 curEXP = metinSlot[0]
  1040.                 maxEXP = item.GetValue(2)
  1041.                 self.__AppendLimitInformation()
  1042.                 self.__AppendPickInformation(curLevel, curEXP, maxEXP)
  1043.  
  1044.         ## Lottery ##
  1045.         elif item.ITEM_TYPE_LOTTERY == itemType:
  1046.             if 0 != metinSlot:
  1047.  
  1048.                 ticketNumber = int(metinSlot[0])
  1049.                 stepNumber = int(metinSlot[1])
  1050.  
  1051.                 self.AppendSpace(5)
  1052.                 self.AppendTextLine(localeInfo.TOOLTIP_LOTTERY_STEP_NUMBER % (stepNumber), self.NORMAL_COLOR)
  1053.                 self.AppendTextLine(localeInfo.TOOLTIP_LOTTO_NUMBER % (ticketNumber), self.NORMAL_COLOR);
  1054.  
  1055.         ### Metin ###
  1056.         elif item.ITEM_TYPE_METIN == itemType:
  1057.             self.AppendMetinInformation()
  1058.             self.AppendMetinWearInformation()
  1059.  
  1060.         ### Fish ###
  1061.         elif item.ITEM_TYPE_FISH == itemType:
  1062.             if 0 != metinSlot:
  1063.                 self.__AppendFishInfo(metinSlot[0])
  1064.        
  1065.         ## item.ITEM_TYPE_BLEND
  1066.         elif item.ITEM_TYPE_BLEND == itemType:
  1067.             self.__AppendLimitInformation()
  1068.  
  1069.             if metinSlot:
  1070.                 affectType = metinSlot[0]
  1071.                 affectValue = metinSlot[1]
  1072.                 time = metinSlot[2]
  1073.                 self.AppendSpace(5)
  1074.                 affectText = self.__GetAffectString(affectType, affectValue)
  1075.  
  1076.                 self.AppendTextLine(affectText, self.NORMAL_COLOR)
  1077.  
  1078.                 if time > 0:
  1079.                     minute = (time / 60)
  1080.                     second = (time % 60)
  1081.                     timeString = localeInfo.TOOLTIP_POTION_TIME
  1082.  
  1083.                     if minute > 0:
  1084.                         timeString += str(minute) + localeInfo.TOOLTIP_POTION_MIN
  1085.                     if second > 0:
  1086.                         timeString += " " + str(second) + localeInfo.TOOLTIP_POTION_SEC
  1087.  
  1088.                     self.AppendTextLine(timeString)
  1089.                 #else:
  1090.                     #self.AppendTextLine(localeInfo.BLEND_POTION_NO_TIME)
  1091.             #else:
  1092.                 #self.AppendTextLine("BLEND_POTION_NO_INFO")
  1093.  
  1094.         elif item.ITEM_TYPE_UNIQUE == itemType:
  1095.             if 0 != metinSlot:
  1096.  
  1097.                 time = metinSlot[player.METIN_SOCKET_MAX_NUM-1]
  1098.  
  1099.                 if 1 == item.GetValue(2): ## ??? ?? Flag / ?? ??? ??
  1100.                     self.AppendMallItemLastTime(time)
  1101.                 else:
  1102.                     self.AppendUniqueItemLastTime(time)
  1103.  
  1104.         ### Use ###
  1105.         elif item.ITEM_TYPE_USE == itemType:
  1106.             self.__AppendLimitInformation()
  1107.  
  1108.             if item.USE_POTION == itemSubType or item.USE_POTION_NODELAY == itemSubType:
  1109.                 self.__AppendPotionInformation()
  1110.  
  1111.             elif item.USE_ABILITY_UP == itemSubType:
  1112.                 self.__AppendAbilityPotionInformation()
  1113.  
  1114.  
  1115.             ## ??? ???
  1116.             elif 50004 == itemVnum:
  1117.                 if 0 != metinSlot:
  1118.                     useCount = int(metinSlot[0])
  1119.  
  1120.                     self.AppendSpace(5)
  1121.                     self.AppendTextLine(localeInfo.TOOLTIP_REST_USABLE_COUNT % (10 - useCount), self.NORMAL_COLOR)
  1122.  
  1123.             ## ????
  1124.             elif constInfo.IS_AUTO_POTION(itemVnum):
  1125.                 if 0 != metinSlot:
  1126.                     ## 0: ???, 1: ???, 2: ??
  1127.                     isActivated = int(metinSlot[0])
  1128.                     usedAmount = float(metinSlot[1])
  1129.                     totalAmount = float(metinSlot[2])
  1130.                    
  1131.                     if 0 == totalAmount:
  1132.                         totalAmount = 1
  1133.                    
  1134.                     self.AppendSpace(5)
  1135.  
  1136.                     if 0 != isActivated:
  1137.                         self.AppendTextLine("(%s)" % (localeInfo.TOOLTIP_AUTO_POTION_USING), self.SPECIAL_POSITIVE_COLOR)
  1138.                         self.AppendTextLine(localeInfo.TOOLTIP_AUTO_POTION_REST + " %.2f%%" % (100.0 - ((usedAmount/totalAmount) * 100.0)), self.POSITIVE_COLOR)
  1139.                         self.AppendSpace(5)
  1140.  
  1141.                        
  1142.             ## ?? ???
  1143.             elif itemVnum in WARP_SCROLLS:
  1144.                 if 0 != metinSlot:
  1145.                     xPos = int(metinSlot[0])
  1146.                     yPos = int(metinSlot[1])
  1147.  
  1148.                     if xPos != 0 and yPos != 0:
  1149.                         (mapName, xBase, yBase) = background.GlobalPositionToMapInfo(xPos, yPos)
  1150.                        
  1151.                         localeInfoMapName=localeInfo.MINIMAP_ZONE_NAME_DICT.get(mapName, "")
  1152.  
  1153.                         self.AppendSpace(5)
  1154.  
  1155.                         if localeInfoMapName!="":                      
  1156.                             self.AppendTextLine(localeInfo.TOOLTIP_MEMORIZED_POSITION % (localeInfoMapName, int(xPos-xBase)/100, int(yPos-yBase)/100), self.NORMAL_COLOR)
  1157.                         else:
  1158.                             self.AppendTextLine(localeInfo.TOOLTIP_MEMORIZED_POSITION_ERROR % (int(xPos)/100, int(yPos)/100), self.NORMAL_COLOR)
  1159.                             dbg.TraceError("NOT_EXIST_IN_MINIMAP_ZONE_NAME_DICT: %s" % mapName)
  1160.  
  1161.             #####
  1162.             if item.USE_SPECIAL == itemSubType:
  1163.                 if 0 != metinSlot:
  1164.                     time = metinSlot[player.METIN_SOCKET_MAX_NUM-1]
  1165.  
  1166.                     ## ??? ?? Flag
  1167.                     if 1 == item.GetValue(2):
  1168.                         self.AppendMallItemLastTime(time)
  1169.  
  1170.         else:
  1171.             self.__AppendLimitInformation()
  1172.  
  1173.         self.ShowToolTip()
  1174.  
  1175.     ## ?????
  1176.     def __IsHair(self, itemVnum):
  1177.         return (self.__IsOldHair(itemVnum) or
  1178.             self.__IsNewHair(itemVnum) or
  1179.             self.__IsNewHair2(itemVnum))   
  1180.  
  1181.     def __IsOldHair(self, itemVnum):
  1182.         return itemVnum > 73000 and itemVnum < 74000   
  1183.  
  1184.     def __IsNewHair(self, itemVnum):
  1185.         return itemVnum > 74000 and itemVnum < 75000   
  1186.  
  1187.     def __IsNewHair2(self, itemVnum):
  1188.         return itemVnum > 75000 and itemVnum < 77000   
  1189.  
  1190.     def __AppendHairIcon(self, itemVnum):
  1191.         itemImage = ui.ImageBox()
  1192.         itemImage.SetParent(self)
  1193.         itemImage.Show()           
  1194.  
  1195.         if self.__IsOldHair(itemVnum):
  1196.             itemImage.LoadImage("d:/ymir work/item/quest/"+str(itemVnum)+".tga")
  1197.         elif self.__IsNewHair(itemVnum): # ?? ?? ??? ????? ????. ??? ???? 1000?? ??? ???.
  1198.             itemImage.LoadImage("d:/ymir work/item/quest/"+str(itemVnum-1000)+".tga")
  1199.         elif self.__IsNewHair2(itemVnum): # ?? ?? ??? ????? ????. ??? ???? 1000?? ??? ???.
  1200.             itemImage.LoadImage("icon/hair/%d.sub" % (itemVnum))
  1201.  
  1202.         itemImage.SetPosition(itemImage.GetWidth()/2, self.toolTipHeight)
  1203.         self.toolTipHeight += itemImage.GetHeight()
  1204.         #self.toolTipWidth += itemImage.GetWidth()/2
  1205.         self.childrenList.append(itemImage)
  1206.         self.ResizeToolTip()
  1207.  
  1208.     ## ???? ? Description ? ?? ?? ???? ????
  1209.     def __AdjustMaxWidth(self, attrSlot, desc):
  1210.         newToolTipWidth = self.toolTipWidth
  1211.         newToolTipWidth = max(self.__AdjustAttrMaxWidth(attrSlot), newToolTipWidth)
  1212.         newToolTipWidth = max(self.__AdjustDescMaxWidth(desc), newToolTipWidth)
  1213.         if newToolTipWidth > self.toolTipWidth:
  1214.             self.toolTipWidth = newToolTipWidth
  1215.             self.ResizeToolTip()
  1216.  
  1217.     def __AdjustAttrMaxWidth(self, attrSlot):
  1218.         if 0 == attrSlot:
  1219.             return self.toolTipWidth
  1220.  
  1221.         maxWidth = self.toolTipWidth
  1222.         for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1223.             type = attrSlot[i][0]
  1224.             value = attrSlot[i][1]
  1225.             if self.ATTRIBUTE_NEED_WIDTH.has_key(type):
  1226.                 if value > 0:
  1227.                     maxWidth = max(self.ATTRIBUTE_NEED_WIDTH[type], maxWidth)
  1228.  
  1229.                     # ATTR_CHANGE_TOOLTIP_WIDTH
  1230.                     #self.toolTipWidth = max(self.ATTRIBUTE_NEED_WIDTH[type], self.toolTipWidth)
  1231.                     #self.ResizeToolTip()
  1232.                     # END_OF_ATTR_CHANGE_TOOLTIP_WIDTH
  1233.  
  1234.         return maxWidth
  1235.  
  1236.     def __AdjustDescMaxWidth(self, desc):
  1237.         if len(desc) < DESC_DEFAULT_MAX_COLS:
  1238.             return self.toolTipWidth
  1239.    
  1240.         return DESC_WESTERN_MAX_WIDTH
  1241.  
  1242.     def __SetSkillBookToolTip(self, skillIndex, bookName, skillGrade):
  1243.         skillName = skill.GetSkillName(skillIndex)
  1244.  
  1245.         if not skillName:
  1246.             return
  1247.  
  1248.         if localeInfo.IsVIETNAM():
  1249.             itemName = bookName + " " + skillName
  1250.         else:
  1251.             itemName = skillName + " " + bookName
  1252.         self.SetTitle(itemName)
  1253.  
  1254.     def __AppendPickInformation(self, curLevel, curEXP, maxEXP):
  1255.         self.AppendSpace(5)
  1256.         self.AppendTextLine(localeInfo.TOOLTIP_PICK_LEVEL % (curLevel), self.NORMAL_COLOR)
  1257.         self.AppendTextLine(localeInfo.TOOLTIP_PICK_EXP % (curEXP, maxEXP), self.NORMAL_COLOR)
  1258.  
  1259.         if curEXP == maxEXP:
  1260.             self.AppendSpace(5)
  1261.             self.AppendTextLine(localeInfo.TOOLTIP_PICK_UPGRADE1, self.NORMAL_COLOR)
  1262.             self.AppendTextLine(localeInfo.TOOLTIP_PICK_UPGRADE2, self.NORMAL_COLOR)
  1263.             self.AppendTextLine(localeInfo.TOOLTIP_PICK_UPGRADE3, self.NORMAL_COLOR)
  1264.  
  1265.  
  1266.     def __AppendRodInformation(self, curLevel, curEXP, maxEXP):
  1267.         self.AppendSpace(5)
  1268.         self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_LEVEL % (curLevel), self.NORMAL_COLOR)
  1269.         self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_EXP % (curEXP, maxEXP), self.NORMAL_COLOR)
  1270.  
  1271.         if curEXP == maxEXP:
  1272.             self.AppendSpace(5)
  1273.             self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_UPGRADE1, self.NORMAL_COLOR)
  1274.             self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_UPGRADE2, self.NORMAL_COLOR)
  1275.             self.AppendTextLine(localeInfo.TOOLTIP_FISHINGROD_UPGRADE3, self.NORMAL_COLOR)
  1276.  
  1277.     def __AppendLimitInformation(self):
  1278.  
  1279.         appendSpace = FALSE
  1280.  
  1281.         for i in xrange(item.LIMIT_MAX_NUM):
  1282.  
  1283.             (limitType, limitValue) = item.GetLimit(i)
  1284.  
  1285.             if limitValue > 0:
  1286.                 if FALSE == appendSpace:
  1287.                     self.AppendSpace(5)
  1288.                     appendSpace = TRUE
  1289.  
  1290.             else:
  1291.                 continue
  1292.  
  1293.             if item.LIMIT_LEVEL == limitType:
  1294.                 color = self.GetLimitTextLineColor(player.GetStatus(player.LEVEL), limitValue)
  1295.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_LEVEL % (limitValue), color)
  1296.             """
  1297.             elif item.LIMIT_STR == limitType:
  1298.                 color = self.GetLimitTextLineColor(player.GetStatus(player.ST), limitValue)
  1299.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_STR % (limitValue), color)
  1300.             elif item.LIMIT_DEX == limitType:
  1301.                 color = self.GetLimitTextLineColor(player.GetStatus(player.DX), limitValue)
  1302.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_DEX % (limitValue), color)
  1303.             elif item.LIMIT_INT == limitType:
  1304.                 color = self.GetLimitTextLineColor(player.GetStatus(player.IQ), limitValue)
  1305.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_INT % (limitValue), color)
  1306.             elif item.LIMIT_CON == limitType:
  1307.                 color = self.GetLimitTextLineColor(player.GetStatus(player.HT), limitValue)
  1308.                 self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_CON % (limitValue), color)
  1309.             """
  1310.  
  1311.     def __GetAffectString(self, affectType, affectValue):
  1312.         if 0 == affectType:
  1313.             return None
  1314.  
  1315.         if 0 == affectValue:
  1316.             return None
  1317.  
  1318.         try:
  1319.             return self.AFFECT_DICT[affectType](affectValue)
  1320.         except TypeError:
  1321.             return "UNKNOWN_VALUE[%s] %s" % (affectType, affectValue)
  1322.         except KeyError:
  1323.             return "UNKNOWN_TYPE[%s] %s" % (affectType, affectValue)
  1324.  
  1325.     def __AppendAffectInformation(self):
  1326.         for i in xrange(item.ITEM_APPLY_MAX_NUM):
  1327.  
  1328.             (affectType, affectValue) = item.GetAffect(i)
  1329.  
  1330.             affectString = self.__GetAffectString(affectType, affectValue)
  1331.             if affectString:
  1332.                 self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  1333.  
  1334.     def AppendWearableInformation(self):
  1335.  
  1336.         self.AppendSpace(5)
  1337.         self.AppendTextLine(localeInfo.TOOLTIP_ITEM_WEARABLE_JOB, self.NORMAL_COLOR)
  1338.  
  1339.         flagList = (
  1340.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_WARRIOR),
  1341.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_ASSASSIN),
  1342.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_SURA),
  1343.             not item.IsAntiFlag(item.ITEM_ANTIFLAG_SHAMAN))
  1344.  
  1345.         characterNames = ""
  1346.         for i in xrange(self.CHARACTER_COUNT):
  1347.  
  1348.             name = self.CHARACTER_NAMES[i]
  1349.             flag = flagList[i]
  1350.  
  1351.             if flag:
  1352.                 characterNames += " "
  1353.                 characterNames += name
  1354.  
  1355.         textLine = self.AppendTextLine(characterNames, self.NORMAL_COLOR, TRUE)
  1356.         textLine.SetFeather()
  1357.  
  1358.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_MALE):
  1359.             textLine = self.AppendTextLine(localeInfo.FOR_FEMALE, self.NORMAL_COLOR, TRUE)
  1360.             textLine.SetFeather()
  1361.  
  1362.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_FEMALE):
  1363.             textLine = self.AppendTextLine(localeInfo.FOR_MALE, self.NORMAL_COLOR, TRUE)
  1364.             textLine.SetFeather()
  1365.  
  1366.     def __AppendPotionInformation(self):
  1367.         self.AppendSpace(5)
  1368.  
  1369.         healHP = item.GetValue(0)
  1370.         healSP = item.GetValue(1)
  1371.         healStatus = item.GetValue(2)
  1372.         healPercentageHP = item.GetValue(3)
  1373.         healPercentageSP = item.GetValue(4)
  1374.  
  1375.         if healHP > 0:
  1376.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_HP_POINT % healHP, self.GetChangeTextLineColor(healHP))
  1377.         if healSP > 0:
  1378.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_SP_POINT % healSP, self.GetChangeTextLineColor(healSP))
  1379.         if healStatus != 0:
  1380.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_CURE)
  1381.         if healPercentageHP > 0:
  1382.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_HP_PERCENT % healPercentageHP, self.GetChangeTextLineColor(healPercentageHP))
  1383.         if healPercentageSP > 0:
  1384.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_SP_PERCENT % healPercentageSP, self.GetChangeTextLineColor(healPercentageSP))
  1385.  
  1386.     def __AppendAbilityPotionInformation(self):
  1387.  
  1388.         self.AppendSpace(5)
  1389.  
  1390.         abilityType = item.GetValue(0)
  1391.         time = item.GetValue(1)
  1392.         point = item.GetValue(2)
  1393.  
  1394.         if abilityType == item.APPLY_ATT_SPEED:
  1395.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_ATTACK_SPEED % point, self.GetChangeTextLineColor(point))
  1396.         elif abilityType == item.APPLY_MOV_SPEED:
  1397.             self.AppendTextLine(localeInfo.TOOLTIP_POTION_PLUS_MOVING_SPEED % point, self.GetChangeTextLineColor(point))
  1398.  
  1399.         if time > 0:
  1400.             minute = (time / 60)
  1401.             second = (time % 60)
  1402.             timeString = localeInfo.TOOLTIP_POTION_TIME
  1403.  
  1404.             if minute > 0:
  1405.                 timeString += str(minute) + localeInfo.TOOLTIP_POTION_MIN
  1406.             if second > 0:
  1407.                 timeString += " " + str(second) + localeInfo.TOOLTIP_POTION_SEC
  1408.  
  1409.             self.AppendTextLine(timeString)
  1410.  
  1411.     def GetPriceColor(self, price):
  1412.         if price>=constInfo.HIGH_PRICE:
  1413.             return self.HIGH_PRICE_COLOR
  1414.         if price>=constInfo.MIDDLE_PRICE:
  1415.             return self.MIDDLE_PRICE_COLOR
  1416.         else:
  1417.             return self.LOW_PRICE_COLOR
  1418.                        
  1419.     def AppendPrice(self, price):  
  1420.         self.AppendSpace(5)
  1421.         self.AppendTextLine(localeInfo.TOOLTIP_BUYPRICE  % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
  1422.  
  1423.     def AppendSellingPrice(self, price):
  1424.         if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):           
  1425.             self.AppendTextLine(localeInfo.TOOLTIP_ANTI_SELL, self.DISABLE_COLOR)
  1426.             self.AppendSpace(5)
  1427.         else:
  1428.             self.AppendTextLine(localeInfo.TOOLTIP_SELLPRICE % (localeInfo.NumberToMoneyString(price)), self.GetPriceColor(price))
  1429.             self.AppendSpace(5)
  1430.  
  1431.     def AppendMetinInformation(self):
  1432.         affectType, affectValue = item.GetAffect(0)
  1433.         #affectType = item.GetValue(0)
  1434.         #affectValue = item.GetValue(1)
  1435.  
  1436.         affectString = self.__GetAffectString(affectType, affectValue)
  1437.  
  1438.         if affectString:
  1439.             self.AppendSpace(5)
  1440.             self.AppendTextLine(affectString, self.GetChangeTextLineColor(affectValue))
  1441.  
  1442.     def AppendMetinWearInformation(self):
  1443.  
  1444.         self.AppendSpace(5)
  1445.         self.AppendTextLine(localeInfo.TOOLTIP_SOCKET_REFINABLE_ITEM, self.NORMAL_COLOR)
  1446.  
  1447.         flagList = (item.IsWearableFlag(item.WEARABLE_BODY),
  1448.                     item.IsWearableFlag(item.WEARABLE_HEAD),
  1449.                     item.IsWearableFlag(item.WEARABLE_FOOTS),
  1450.                     item.IsWearableFlag(item.WEARABLE_WRIST),
  1451.                     item.IsWearableFlag(item.WEARABLE_WEAPON),
  1452.                     item.IsWearableFlag(item.WEARABLE_NECK),
  1453.                     item.IsWearableFlag(item.WEARABLE_EAR),
  1454.                     item.IsWearableFlag(item.WEARABLE_UNIQUE),
  1455.                     item.IsWearableFlag(item.WEARABLE_SHIELD),
  1456.                     item.IsWearableFlag(item.WEARABLE_ARROW))
  1457.  
  1458.         wearNames = ""
  1459.         for i in xrange(self.WEAR_COUNT):
  1460.  
  1461.             name = self.WEAR_NAMES[i]
  1462.             flag = flagList[i]
  1463.  
  1464.             if flag:
  1465.                 wearNames += "  "
  1466.                 wearNames += name
  1467.  
  1468.         textLine = ui.TextLine()
  1469.         textLine.SetParent(self)
  1470.         textLine.SetFontName(self.defFontName)
  1471.         textLine.SetPosition(self.toolTipWidth/2, self.toolTipHeight)
  1472.         textLine.SetHorizontalAlignCenter()
  1473.         textLine.SetPackedFontColor(self.NORMAL_COLOR)
  1474.         textLine.SetText(wearNames)
  1475.         textLine.Show()
  1476.         self.childrenList.append(textLine)
  1477.  
  1478.         self.toolTipHeight += self.TEXT_LINE_HEIGHT
  1479.         self.ResizeToolTip()
  1480.  
  1481.     def GetMetinSocketType(self, number):
  1482.         if player.METIN_SOCKET_TYPE_NONE == number:
  1483.             return player.METIN_SOCKET_TYPE_NONE
  1484.         elif player.METIN_SOCKET_TYPE_SILVER == number:
  1485.             return player.METIN_SOCKET_TYPE_SILVER
  1486.         elif player.METIN_SOCKET_TYPE_GOLD == number:
  1487.             return player.METIN_SOCKET_TYPE_GOLD
  1488.         else:
  1489.             item.SelectItem(number)
  1490.             if item.METIN_NORMAL == item.GetItemSubType():
  1491.                 return player.METIN_SOCKET_TYPE_SILVER
  1492.             elif item.METIN_GOLD == item.GetItemSubType():
  1493.                 return player.METIN_SOCKET_TYPE_GOLD
  1494.             elif "USE_PUT_INTO_ACCESSORY_SOCKET" == item.GetUseType(number):
  1495.                 return player.METIN_SOCKET_TYPE_SILVER
  1496.  
  1497.         return player.METIN_SOCKET_TYPE_NONE
  1498.  
  1499.     def GetMetinItemIndex(self, number):
  1500.         if player.METIN_SOCKET_TYPE_SILVER == number:
  1501.             return 0
  1502.         if player.METIN_SOCKET_TYPE_GOLD == number:
  1503.             return 0
  1504.  
  1505.         return number
  1506.  
  1507.     def __AppendAccessoryMetinSlotInfo(self, metinSlot, mtrlVnum):     
  1508.         ACCESSORY_SOCKET_MAX_SIZE = 3      
  1509.  
  1510.         cur=min(metinSlot[0], ACCESSORY_SOCKET_MAX_SIZE)
  1511.         end=min(metinSlot[1], ACCESSORY_SOCKET_MAX_SIZE)
  1512.  
  1513.         affectType1, affectValue1 = item.GetAffect(0)
  1514.         affectList1=[0, max(1, affectValue1*10/100), max(2, affectValue1*20/100), max(3, affectValue1*40/100)]
  1515.  
  1516.         affectType2, affectValue2 = item.GetAffect(1)
  1517.         affectList2=[0, max(1, affectValue2*10/100), max(2, affectValue2*20/100), max(3, affectValue2*40/100)]
  1518.  
  1519.         mtrlPos=0
  1520.         mtrlList=[mtrlVnum]*cur+[player.METIN_SOCKET_TYPE_SILVER]*(end-cur)
  1521.         for mtrl in mtrlList:
  1522.             affectString1 = self.__GetAffectString(affectType1, affectList1[mtrlPos+1]-affectList1[mtrlPos])           
  1523.             affectString2 = self.__GetAffectString(affectType2, affectList2[mtrlPos+1]-affectList2[mtrlPos])
  1524.  
  1525.             leftTime = 0
  1526.             if cur == mtrlPos+1:
  1527.                 leftTime=metinSlot[2]
  1528.  
  1529.             self.__AppendMetinSlotInfo_AppendMetinSocketData(mtrlPos, mtrl, affectString1, affectString2, leftTime)
  1530.             mtrlPos+=1
  1531.  
  1532.     def __AppendMetinSlotInfo(self, metinSlot):
  1533.         if self.__AppendMetinSlotInfo_IsEmptySlotList(metinSlot):
  1534.             return
  1535.  
  1536.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1537.             self.__AppendMetinSlotInfo_AppendMetinSocketData(i, metinSlot[i])
  1538.  
  1539.     def __AppendMetinSlotInfo_IsEmptySlotList(self, metinSlot):
  1540.         if 0 == metinSlot:
  1541.             return 1
  1542.  
  1543.         for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1544.             metinSlotData=metinSlot[i]
  1545.             if 0 != self.GetMetinSocketType(metinSlotData):
  1546.                 if 0 != self.GetMetinItemIndex(metinSlotData):
  1547.                     return 0
  1548.  
  1549.         return 1
  1550.  
  1551.     def __AppendMetinSlotInfo_AppendMetinSocketData(self, index, metinSlotData, custumAffectString="", custumAffectString2="", leftTime=0):
  1552.  
  1553.         slotType = self.GetMetinSocketType(metinSlotData)
  1554.         itemIndex = self.GetMetinItemIndex(metinSlotData)
  1555.  
  1556.         if 0 == slotType:
  1557.             return
  1558.  
  1559.         self.AppendSpace(5)
  1560.  
  1561.         slotImage = ui.ImageBox()
  1562.         slotImage.SetParent(self)
  1563.         slotImage.SetPosition(9, self.toolTipHeight-1)
  1564.         slotImage.Show()
  1565.  
  1566.         ## Name
  1567.         nameTextLine = ui.TextLine()
  1568.         nameTextLine.SetParent(self)
  1569.         nameTextLine.SetFontName(self.defFontName)
  1570.         nameTextLine.SetPackedFontColor(self.NORMAL_COLOR)
  1571.         nameTextLine.SetPosition(50, self.toolTipHeight + 2)
  1572.         nameTextLine.SetOutline()
  1573.         nameTextLine.SetFeather()
  1574.         nameTextLine.Show()        
  1575.  
  1576.         self.childrenList.append(nameTextLine)
  1577.  
  1578.         if player.METIN_SOCKET_TYPE_SILVER == slotType:
  1579.             slotImage.LoadImage("d:/ymir work/ui/game/windows/metin_slot_silver.sub")
  1580.         elif player.METIN_SOCKET_TYPE_GOLD == slotType:
  1581.             slotImage.LoadImage("d:/ymir work/ui/game/windows/metin_slot_gold.sub")
  1582.  
  1583.         self.childrenList.append(slotImage)
  1584.  
  1585.         metinImage = ui.ImageBox()
  1586.         metinImage.SetParent(self)
  1587.         metinImage.SetPosition(10, self.toolTipHeight)
  1588.         metinImage.Show()
  1589.         self.childrenList.append(metinImage)
  1590.  
  1591.         if itemIndex:
  1592.  
  1593.             item.SelectItem(itemIndex)
  1594.  
  1595.             ## Image
  1596.             try:
  1597.                 metinImage.LoadImage(item.GetIconImageFileName())
  1598.             except:
  1599.                 dbg.TraceError("ItemToolTip.__AppendMetinSocketData() - Failed to find image file %d:%s" %
  1600.                     (itemIndex, item.GetIconImageFileName())
  1601.                 )
  1602.  
  1603.             nameTextLine.SetText(item.GetItemName())
  1604.            
  1605.             ## Affect      
  1606.             affectTextLine = ui.TextLine()
  1607.             affectTextLine.SetParent(self)
  1608.             affectTextLine.SetFontName(self.defFontName)
  1609.             affectTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  1610.             affectTextLine.SetPosition(50, self.toolTipHeight + 16 + 2)
  1611.             affectTextLine.SetOutline()
  1612.             affectTextLine.SetFeather()
  1613.             affectTextLine.Show()          
  1614.                            
  1615.             if custumAffectString:
  1616.                 affectTextLine.SetText(custumAffectString)
  1617.             elif itemIndex!=constInfo.ERROR_METIN_STONE:
  1618.                 affectType, affectValue = item.GetAffect(0)
  1619.                 affectString = self.__GetAffectString(affectType, affectValue)
  1620.                 if affectString:
  1621.                     affectTextLine.SetText(affectString)
  1622.             else:
  1623.                 affectTextLine.SetText(localeInfo.TOOLTIP_APPLY_NOAFFECT)
  1624.            
  1625.             self.childrenList.append(affectTextLine)           
  1626.  
  1627.             if custumAffectString2:
  1628.                 affectTextLine = ui.TextLine()
  1629.                 affectTextLine.SetParent(self)
  1630.                 affectTextLine.SetFontName(self.defFontName)
  1631.                 affectTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  1632.                 affectTextLine.SetPosition(50, self.toolTipHeight + 16 + 2 + 16 + 2)
  1633.                 affectTextLine.SetOutline()
  1634.                 affectTextLine.SetFeather()
  1635.                 affectTextLine.Show()
  1636.                 affectTextLine.SetText(custumAffectString2)
  1637.                 self.childrenList.append(affectTextLine)
  1638.                 self.toolTipHeight += 16 + 2
  1639.  
  1640.             if 0 != leftTime:
  1641.                 timeText = (localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(leftTime))
  1642.  
  1643.                 timeTextLine = ui.TextLine()
  1644.                 timeTextLine.SetParent(self)
  1645.                 timeTextLine.SetFontName(self.defFontName)
  1646.                 timeTextLine.SetPackedFontColor(self.POSITIVE_COLOR)
  1647.                 timeTextLine.SetPosition(50, self.toolTipHeight + 16 + 2 + 16 + 2)
  1648.                 timeTextLine.SetOutline()
  1649.                 timeTextLine.SetFeather()
  1650.                 timeTextLine.Show()
  1651.                 timeTextLine.SetText(timeText)
  1652.                 self.childrenList.append(timeTextLine)
  1653.                 self.toolTipHeight += 16 + 2
  1654.  
  1655.         else:
  1656.             nameTextLine.SetText(localeInfo.TOOLTIP_SOCKET_EMPTY)
  1657.  
  1658.         self.toolTipHeight += 35
  1659.         self.ResizeToolTip()
  1660.         return
  1661.  
  1662.     def __AppendFishInfo(self, size):
  1663.         if size > 0:
  1664.             self.AppendSpace(5)
  1665.             self.AppendTextLine(localeInfo.TOOLTIP_FISH_LEN % (float(size) / 100.0), self.NORMAL_COLOR)
  1666.  
  1667.     def AppendUniqueItemLastTime(self, restMin):
  1668.         restSecond = restMin*60
  1669.         self.AppendSpace(5)
  1670.         self.AppendTextLine(localeInfo.LEFT_TIME + " : " + localeInfo.SecondToHM(restSecond), self.NORMAL_COLOR)
  1671.  
  1672.     def AppendMallItemLastTime(self, endTime):
  1673.         leftSec = max(0, endTime - app.GetGlobalTimeStamp())
  1674.         self.AppendSpace(5)
  1675.         self.AppendTextLine(localeInfo.LEFT_TIME + " : " + localeInfo.SecondToDHM(leftSec), self.NORMAL_COLOR)
  1676.  
  1677. class HyperlinkItemToolTip(ItemToolTip):
  1678.     def __init__(self):
  1679.         ItemToolTip.__init__(self, isPickable=TRUE)
  1680.  
  1681.     def SetHyperlinkItem(self, tokens):
  1682.         minTokenCount = 3 + player.METIN_SOCKET_MAX_NUM
  1683.         maxTokenCount = minTokenCount + 2 * player.ATTRIBUTE_SLOT_MAX_NUM
  1684.         if tokens and len(tokens) >= minTokenCount and len(tokens) <= maxTokenCount:
  1685.             head, vnum, flag = tokens[:3]
  1686.             itemVnum = int(vnum, 16)
  1687.             metinSlot = [int(metin, 16) for metin in tokens[3:6]]
  1688.  
  1689.             rests = tokens[6:]
  1690.             if rests:
  1691.                 attrSlot = []
  1692.  
  1693.                 rests.reverse()
  1694.                 while rests:
  1695.                     key = int(rests.pop(), 16)
  1696.                     if rests:
  1697.                         val = int(rests.pop())
  1698.                         attrSlot.append((key, val))
  1699.  
  1700.                 attrSlot += [(0, 0)] * (player.ATTRIBUTE_SLOT_MAX_NUM - len(attrSlot))
  1701.             else:
  1702.                 attrSlot = [(0, 0)] * player.ATTRIBUTE_SLOT_MAX_NUM
  1703.  
  1704.             self.ClearToolTip()
  1705.             self.AddItemData(itemVnum, metinSlot, attrSlot)
  1706.  
  1707.             ItemToolTip.OnUpdate(self)
  1708.  
  1709.     def OnUpdate(self):
  1710.         pass
  1711.  
  1712.     def OnMouseLeftButtonDown(self):
  1713.         self.Hide()
  1714.  
  1715. class SkillToolTip(ToolTip):
  1716.  
  1717.     POINT_NAME_DICT = {
  1718.         player.LEVEL : localeInfo.SKILL_TOOLTIP_LEVEL,
  1719.         player.IQ : localeInfo.SKILL_TOOLTIP_INT,
  1720.     }
  1721.  
  1722.     SKILL_TOOL_TIP_WIDTH = 200
  1723.     PARTY_SKILL_TOOL_TIP_WIDTH = 340
  1724.  
  1725.     PARTY_SKILL_EXPERIENCE_AFFECT_LIST = (  ( 2, 2,  10,),
  1726.                                             ( 8, 3,  20,),
  1727.                                             (14, 4,  30,),
  1728.                                             (22, 5,  45,),
  1729.                                             (28, 6,  60,),
  1730.                                             (34, 7,  80,),
  1731.                                             (38, 8, 100,), )
  1732.  
  1733.     PARTY_SKILL_PLUS_GRADE_AFFECT_LIST = (  ( 4, 2, 1, 0,),
  1734.                                             (10, 3, 2, 0,),
  1735.                                             (16, 4, 2, 1,),
  1736.                                             (24, 5, 2, 2,), )
  1737.  
  1738.     PARTY_SKILL_ATTACKER_AFFECT_LIST = (    ( 36, 3, ),
  1739.                                             ( 26, 1, ),
  1740.                                             ( 32, 2, ), )
  1741.  
  1742.     SKILL_GRADE_NAME = {    player.SKILL_GRADE_MASTER : localeInfo.SKILL_GRADE_NAME_MASTER,
  1743.                             player.SKILL_GRADE_GRAND_MASTER : localeInfo.SKILL_GRADE_NAME_GRAND_MASTER,
  1744.                             player.SKILL_GRADE_PERFECT_MASTER : localeInfo.SKILL_GRADE_NAME_PERFECT_MASTER, }
  1745.  
  1746.     AFFECT_NAME_DICT =  {
  1747.                             "HP" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_POWER,
  1748.                             "ATT_GRADE" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_GRADE,
  1749.                             "DEF_GRADE" : localeInfo.TOOLTIP_SKILL_AFFECT_DEF_GRADE,
  1750.                             "ATT_SPEED" : localeInfo.TOOLTIP_SKILL_AFFECT_ATT_SPEED,
  1751.                             "MOV_SPEED" : localeInfo.TOOLTIP_SKILL_AFFECT_MOV_SPEED,
  1752.                             "DODGE" : localeInfo.TOOLTIP_SKILL_AFFECT_DODGE,
  1753.                             "RESIST_NORMAL" : localeInfo.TOOLTIP_SKILL_AFFECT_RESIST_NORMAL,
  1754.                             "REFLECT_MELEE" : localeInfo.TOOLTIP_SKILL_AFFECT_REFLECT_MELEE,
  1755.                         }
  1756.     AFFECT_APPEND_TEXT_DICT =   {
  1757.                                     "DODGE" : "%",
  1758.                                     "RESIST_NORMAL" : "%",
  1759.                                     "REFLECT_MELEE" : "%",
  1760.                                 }
  1761.  
  1762.     def __init__(self):
  1763.         ToolTip.__init__(self, self.SKILL_TOOL_TIP_WIDTH)
  1764.     def __del__(self):
  1765.         ToolTip.__del__(self)
  1766.  
  1767.     def SetSkill(self, skillIndex, skillLevel = -1):
  1768.  
  1769.         if 0 == skillIndex:
  1770.             return
  1771.  
  1772.         if skill.SKILL_TYPE_GUILD == skill.GetSkillType(skillIndex):
  1773.  
  1774.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  1775.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  1776.                 self.ResizeToolTip()
  1777.  
  1778.             self.AppendDefaultData(skillIndex)
  1779.             self.AppendSkillConditionData(skillIndex)
  1780.             self.AppendGuildSkillData(skillIndex, skillLevel)
  1781.  
  1782.         else:
  1783.  
  1784.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  1785.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  1786.                 self.ResizeToolTip()
  1787.  
  1788.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  1789.             skillGrade = player.GetSkillGrade(slotIndex)
  1790.             skillLevel = player.GetSkillLevel(slotIndex)
  1791.             skillCurrentPercentage = player.GetSkillCurrentEfficientPercentage(slotIndex)
  1792.             skillNextPercentage = player.GetSkillNextEfficientPercentage(slotIndex)
  1793.  
  1794.             self.AppendDefaultData(skillIndex)
  1795.             self.AppendSkillConditionData(skillIndex)
  1796.             self.AppendSkillDataNew(slotIndex, skillIndex, skillGrade, skillLevel, skillCurrentPercentage, skillNextPercentage)
  1797.             self.AppendSkillRequirement(skillIndex, skillLevel)
  1798.  
  1799.         self.ShowToolTip()
  1800.  
  1801.     def SetSkillNew(self, slotIndex, skillIndex, skillGrade, skillLevel):
  1802.  
  1803.         if 0 == skillIndex:
  1804.             return
  1805.  
  1806.         if player.SKILL_INDEX_TONGSOL == skillIndex:
  1807.  
  1808.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  1809.             skillLevel = player.GetSkillLevel(slotIndex)
  1810.  
  1811.             self.AppendDefaultData(skillIndex)
  1812.             self.AppendPartySkillData(skillGrade, skillLevel)
  1813.  
  1814.         elif player.SKILL_INDEX_RIDING == skillIndex:
  1815.  
  1816.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  1817.             self.AppendSupportSkillDefaultData(skillIndex, skillGrade, skillLevel, 30)
  1818.  
  1819.         elif player.SKILL_INDEX_SUMMON == skillIndex:
  1820.  
  1821.             maxLevel = 10
  1822.  
  1823.             self.ClearToolTip()
  1824.             self.__SetSkillTitle(skillIndex, skillGrade)
  1825.  
  1826.             ## Description
  1827.             description = skill.GetSkillDescription(skillIndex)
  1828.             self.AppendDescription(description, 25)
  1829.  
  1830.             if skillLevel == 10:
  1831.                 self.AppendSpace(5)
  1832.                 self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_MASTER % (skillLevel), self.NORMAL_COLOR)
  1833.                 self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (skillLevel*10), self.NORMAL_COLOR)
  1834.  
  1835.             else:
  1836.                 self.AppendSpace(5)
  1837.                 self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel), self.NORMAL_COLOR)
  1838.                 self.__AppendSummonDescription(skillLevel, self.NORMAL_COLOR)
  1839.  
  1840.                 self.AppendSpace(5)
  1841.                 self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel+1), self.NEGATIVE_COLOR)
  1842.                 self.__AppendSummonDescription(skillLevel+1, self.NEGATIVE_COLOR)
  1843.  
  1844.         elif skill.SKILL_TYPE_GUILD == skill.GetSkillType(skillIndex):
  1845.  
  1846.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  1847.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  1848.                 self.ResizeToolTip()
  1849.  
  1850.             self.AppendDefaultData(skillIndex)
  1851.             self.AppendSkillConditionData(skillIndex)
  1852.             self.AppendGuildSkillData(skillIndex, skillLevel)
  1853.  
  1854.         else:
  1855.  
  1856.             if self.SKILL_TOOL_TIP_WIDTH != self.toolTipWidth:
  1857.                 self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  1858.                 self.ResizeToolTip()
  1859.  
  1860.             slotIndex = player.GetSkillSlotIndex(skillIndex)
  1861.  
  1862.             skillCurrentPercentage = player.GetSkillCurrentEfficientPercentage(slotIndex)
  1863.             skillNextPercentage = player.GetSkillNextEfficientPercentage(slotIndex)
  1864.  
  1865.             self.AppendDefaultData(skillIndex, skillGrade)
  1866.             self.AppendSkillConditionData(skillIndex)
  1867.             self.AppendSkillDataNew(slotIndex, skillIndex, skillGrade, skillLevel, skillCurrentPercentage, skillNextPercentage)
  1868.             self.AppendSkillRequirement(skillIndex, skillLevel)
  1869.  
  1870.         self.ShowToolTip()
  1871.  
  1872.     def __SetSkillTitle(self, skillIndex, skillGrade):
  1873.         self.SetTitle(skill.GetSkillName(skillIndex, skillGrade))
  1874.         self.__AppendSkillGradeName(skillIndex, skillGrade)
  1875.  
  1876.     def __AppendSkillGradeName(self, skillIndex, skillGrade):      
  1877.         if self.SKILL_GRADE_NAME.has_key(skillGrade):
  1878.             self.AppendSpace(5)
  1879.             self.AppendTextLine(self.SKILL_GRADE_NAME[skillGrade] % (skill.GetSkillName(skillIndex, 0)), self.CAN_LEVEL_UP_COLOR)
  1880.  
  1881.     def SetSkillOnlyName(self, slotIndex, skillIndex, skillGrade):
  1882.         if 0 == skillIndex:
  1883.             return
  1884.  
  1885.         slotIndex = player.GetSkillSlotIndex(skillIndex)
  1886.  
  1887.         self.toolTipWidth = self.SKILL_TOOL_TIP_WIDTH
  1888.         self.ResizeToolTip()
  1889.  
  1890.         self.ClearToolTip()
  1891.         self.__SetSkillTitle(skillIndex, skillGrade)       
  1892.         self.AppendDefaultData(skillIndex, skillGrade)
  1893.         self.AppendSkillConditionData(skillIndex)      
  1894.         self.ShowToolTip()
  1895.  
  1896.     def AppendDefaultData(self, skillIndex, skillGrade = 0):
  1897.         self.ClearToolTip()
  1898.         self.__SetSkillTitle(skillIndex, skillGrade)
  1899.  
  1900.         ## Level Limit
  1901.         levelLimit = skill.GetSkillLevelLimit(skillIndex)
  1902.         if levelLimit > 0:
  1903.  
  1904.             color = self.NORMAL_COLOR
  1905.             if player.GetStatus(player.LEVEL) < levelLimit:
  1906.                 color = self.NEGATIVE_COLOR
  1907.  
  1908.             self.AppendSpace(5)
  1909.             self.AppendTextLine(localeInfo.TOOLTIP_ITEM_LIMIT_LEVEL % (levelLimit), color)
  1910.  
  1911.         ## Description
  1912.         description = skill.GetSkillDescription(skillIndex)
  1913.         self.AppendDescription(description, 25)
  1914.  
  1915.     def AppendSupportSkillDefaultData(self, skillIndex, skillGrade, skillLevel, maxLevel):
  1916.         self.ClearToolTip()
  1917.         self.__SetSkillTitle(skillIndex, skillGrade)
  1918.  
  1919.         ## Description
  1920.         description = skill.GetSkillDescription(skillIndex)
  1921.         self.AppendDescription(description, 25)
  1922.  
  1923.         if 1 == skillGrade:
  1924.             skillLevel += 19
  1925.         elif 2 == skillGrade:
  1926.             skillLevel += 29
  1927.         elif 3 == skillGrade:
  1928.             skillLevel = 40
  1929.  
  1930.         self.AppendSpace(5)
  1931.         self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_WITH_MAX % (skillLevel, maxLevel), self.NORMAL_COLOR)
  1932.  
  1933.     def AppendSkillConditionData(self, skillIndex):
  1934.         conditionDataCount = skill.GetSkillConditionDescriptionCount(skillIndex)
  1935.         if conditionDataCount > 0:
  1936.             self.AppendSpace(5)
  1937.             for i in xrange(conditionDataCount):
  1938.                 self.AppendTextLine(skill.GetSkillConditionDescription(skillIndex, i), self.CONDITION_COLOR)
  1939.  
  1940.     def AppendGuildSkillData(self, skillIndex, skillLevel):
  1941.         skillMaxLevel = 7
  1942.         skillCurrentPercentage = float(skillLevel) / float(skillMaxLevel)
  1943.         skillNextPercentage = float(skillLevel+1) / float(skillMaxLevel)
  1944.         ## Current Level
  1945.         if skillLevel > 0:
  1946.             if self.HasSkillLevelDescription(skillIndex, skillLevel):
  1947.                 self.AppendSpace(5)
  1948.                 if skillLevel == skillMaxLevel:
  1949.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_MASTER % (skillLevel), self.NORMAL_COLOR)
  1950.                 else:
  1951.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel), self.NORMAL_COLOR)
  1952.  
  1953.                 #####
  1954.  
  1955.                 for i in xrange(skill.GetSkillAffectDescriptionCount(skillIndex)):
  1956.                     self.AppendTextLine(skill.GetSkillAffectDescription(skillIndex, i, skillCurrentPercentage), self.ENABLE_COLOR)
  1957.  
  1958.                 ## Cooltime
  1959.                 coolTime = skill.GetSkillCoolTime(skillIndex, skillCurrentPercentage)
  1960.                 if coolTime > 0:
  1961.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_COOL_TIME + str(coolTime), self.ENABLE_COLOR)
  1962.  
  1963.                 ## SP
  1964.                 needGSP = skill.GetSkillNeedSP(skillIndex, skillCurrentPercentage)
  1965.                 if needGSP > 0:
  1966.                     self.AppendTextLine(localeInfo.TOOLTIP_NEED_GSP % (needGSP), self.ENABLE_COLOR)
  1967.  
  1968.         ## Next Level
  1969.         if skillLevel < skillMaxLevel:
  1970.             if self.HasSkillLevelDescription(skillIndex, skillLevel+1):
  1971.                 self.AppendSpace(5)
  1972.                 self.AppendTextLine(localeInfo.TOOLTIP_NEXT_SKILL_LEVEL_1 % (skillLevel+1, skillMaxLevel), self.DISABLE_COLOR)
  1973.  
  1974.                 #####
  1975.  
  1976.                 for i in xrange(skill.GetSkillAffectDescriptionCount(skillIndex)):
  1977.                     self.AppendTextLine(skill.GetSkillAffectDescription(skillIndex, i, skillNextPercentage), self.DISABLE_COLOR)
  1978.  
  1979.                 ## Cooltime
  1980.                 coolTime = skill.GetSkillCoolTime(skillIndex, skillNextPercentage)
  1981.                 if coolTime > 0:
  1982.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_COOL_TIME + str(coolTime), self.DISABLE_COLOR)
  1983.  
  1984.                 ## SP
  1985.                 needGSP = skill.GetSkillNeedSP(skillIndex, skillNextPercentage)
  1986.                 if needGSP > 0:
  1987.                     self.AppendTextLine(localeInfo.TOOLTIP_NEED_GSP % (needGSP), self.DISABLE_COLOR)
  1988.  
  1989.     def AppendSkillDataNew(self, slotIndex, skillIndex, skillGrade, skillLevel, skillCurrentPercentage, skillNextPercentage):
  1990.  
  1991.         self.skillMaxLevelStartDict = { 0 : 17, 1 : 7, 2 : 10, }
  1992.         self.skillMaxLevelEndDict = { 0 : 20, 1 : 10, 2 : 10, }
  1993.  
  1994.         skillLevelUpPoint = 1
  1995.         realSkillGrade = player.GetSkillGrade(slotIndex)
  1996.         skillMaxLevelStart = self.skillMaxLevelStartDict.get(realSkillGrade, 15)
  1997.         skillMaxLevelEnd = self.skillMaxLevelEndDict.get(realSkillGrade, 20)
  1998.  
  1999.         ## Current Level
  2000.         if skillLevel > 0:
  2001.             if self.HasSkillLevelDescription(skillIndex, skillLevel):
  2002.                 self.AppendSpace(5)
  2003.                 if skillGrade == skill.SKILL_GRADE_COUNT:
  2004.                     pass
  2005.                 elif skillLevel == skillMaxLevelEnd:
  2006.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL_MASTER % (skillLevel), self.NORMAL_COLOR)
  2007.                 else:
  2008.                     self.AppendTextLine(localeInfo.TOOLTIP_SKILL_LEVEL % (skillLevel), self.NORMAL_COLOR)
  2009.                 self.AppendSkillLevelDescriptionNew(skillIndex, skillCurrentPercentage, self.ENABLE_COLOR)
  2010.  
  2011.         ## Next Level
  2012.         if skillGrade != skill.SKILL_GRADE_COUNT:
  2013.             if skillLevel < skillMaxLevelEnd:
  2014.                 if self.HasSkillLevelDescription(skillIndex, skillLevel+skillLevelUpPoint):
  2015.                     self.AppendSpace(5)
  2016.                     ## HP??, ???? ????? ??
  2017.                     if skillIndex == 141 or skillIndex == 142:
  2018.                         self.AppendTextLine(localeInfo.TOOLTIP_NEXT_SKILL_LEVEL_3 % (skillLevel+1), self.DISABLE_COLOR)
  2019.                     else:
  2020.                         self.AppendTextLine(localeInfo.TOOLTIP_NEXT_SKILL_LEVEL_1 % (skillLevel+1, skillMaxLevelEnd), self.DISABLE_COLOR)
  2021.                     self.AppendSkillLevelDescriptionNew(skillIndex, skillNextPercentage, self.DISABLE_COLOR)
  2022.  
  2023.     def AppendSkillLevelDescriptionNew(self, skillIndex, skillPercentage, color):
  2024.  
  2025.         affectDataCount = skill.GetNewAffectDataCount(skillIndex)
  2026.         if affectDataCount > 0:
  2027.             for i in xrange(affectDataCount):
  2028.                 type, minValue, maxValue = skill.GetNewAffectData(skillIndex, i, skillPercentage)
  2029.  
  2030.                 if not self.AFFECT_NAME_DICT.has_key(type):
  2031.                     continue
  2032.  
  2033.                 minValue = int(minValue)
  2034.                 maxValue = int(maxValue)
  2035.                 affectText = self.AFFECT_NAME_DICT[type]
  2036.  
  2037.                 if "HP" == type:
  2038.                     if minValue < 0 and maxValue < 0:
  2039.                         minValue *= -1
  2040.                         maxValue *= -1
  2041.  
  2042.                     else:
  2043.                         affectText = localeInfo.TOOLTIP_SKILL_AFFECT_HEAL
  2044.  
  2045.                 affectText += str(minValue)
  2046.                 if minValue != maxValue:
  2047.                     affectText += " - " + str(maxValue)
  2048.                 affectText += self.AFFECT_APPEND_TEXT_DICT.get(type, "")
  2049.  
  2050.                 #import debugInfo
  2051.                 #if debugInfo.IsDebugMode():
  2052.                 #   affectText = "!!" + affectText
  2053.  
  2054.                 self.AppendTextLine(affectText, color)
  2055.            
  2056.         else:
  2057.             for i in xrange(skill.GetSkillAffectDescriptionCount(skillIndex)):
  2058.                 self.AppendTextLine(skill.GetSkillAffectDescription(skillIndex, i, skillPercentage), color)
  2059.        
  2060.  
  2061.         ## Duration
  2062.         duration = skill.GetDuration(skillIndex, skillPercentage)
  2063.         if duration > 0:
  2064.             self.AppendTextLine(localeInfo.TOOLTIP_SKILL_DURATION % (duration), color)
  2065.  
  2066.         ## Cooltime
  2067.         coolTime = skill.GetSkillCoolTime(skillIndex, skillPercentage)
  2068.         if coolTime > 0:
  2069.             self.AppendTextLine(localeInfo.TOOLTIP_SKILL_COOL_TIME + str(coolTime), color)
  2070.  
  2071.         ## SP
  2072.         needSP = skill.GetSkillNeedSP(skillIndex, skillPercentage)
  2073.         if needSP != 0:
  2074.             continuationSP = skill.GetSkillContinuationSP(skillIndex, skillPercentage)
  2075.  
  2076.             if skill.IsUseHPSkill(skillIndex):
  2077.                 self.AppendNeedHP(needSP, continuationSP, color)
  2078.             else:
  2079.                 self.AppendNeedSP(needSP, continuationSP, color)
  2080.  
  2081.     def AppendSkillRequirement(self, skillIndex, skillLevel):
  2082.  
  2083.         skillMaxLevel = skill.GetSkillMaxLevel(skillIndex)
  2084.  
  2085.         if skillLevel >= skillMaxLevel:
  2086.             return
  2087.  
  2088.         isAppendHorizontalLine = FALSE
  2089.  
  2090.         ## Requirement
  2091.         if skill.IsSkillRequirement(skillIndex):
  2092.  
  2093.             if not isAppendHorizontalLine:
  2094.                 isAppendHorizontalLine = TRUE
  2095.                 self.AppendHorizontalLine()
  2096.  
  2097.             requireSkillName, requireSkillLevel = skill.GetSkillRequirementData(skillIndex)
  2098.  
  2099.             color = self.CANNOT_LEVEL_UP_COLOR
  2100.             if skill.CheckRequirementSueccess(skillIndex):
  2101.                 color = self.CAN_LEVEL_UP_COLOR
  2102.             self.AppendTextLine(localeInfo.TOOLTIP_REQUIREMENT_SKILL_LEVEL % (requireSkillName, requireSkillLevel), color)
  2103.  
  2104.         ## Require Stat
  2105.         requireStatCount = skill.GetSkillRequireStatCount(skillIndex)
  2106.         if requireStatCount > 0:
  2107.  
  2108.             for i in xrange(requireStatCount):
  2109.                 type, level = skill.GetSkillRequireStatData(skillIndex, i)
  2110.                 if self.POINT_NAME_DICT.has_key(type):
  2111.  
  2112.                     if not isAppendHorizontalLine:
  2113.                         isAppendHorizontalLine = TRUE
  2114.                         self.AppendHorizontalLine()
  2115.  
  2116.                     name = self.POINT_NAME_DICT[type]
  2117.                     color = self.CANNOT_LEVEL_UP_COLOR
  2118.                     if player.GetStatus(type) >= level:
  2119.                         color = self.CAN_LEVEL_UP_COLOR
  2120.                     self.AppendTextLine(localeInfo.TOOLTIP_REQUIREMENT_STAT_LEVEL % (name, level), color)
  2121.  
  2122.     def HasSkillLevelDescription(self, skillIndex, skillLevel):
  2123.         if skill.GetSkillAffectDescriptionCount(skillIndex) > 0:
  2124.             return TRUE
  2125.         if skill.GetSkillCoolTime(skillIndex, skillLevel) > 0:
  2126.             return TRUE
  2127.         if skill.GetSkillNeedSP(skillIndex, skillLevel) > 0:
  2128.             return TRUE
  2129.  
  2130.         return FALSE
  2131.  
  2132.     def AppendMasterAffectDescription(self, index, desc, color):
  2133.         self.AppendTextLine(desc, color)
  2134.  
  2135.     def AppendNextAffectDescription(self, index, desc):
  2136.         self.AppendTextLine(desc, self.DISABLE_COLOR)
  2137.  
  2138.     def AppendNeedHP(self, needSP, continuationSP, color):
  2139.  
  2140.         self.AppendTextLine(localeInfo.TOOLTIP_NEED_HP % (needSP), color)
  2141.  
  2142.         if continuationSP > 0:
  2143.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_HP_PER_SEC % (continuationSP), color)
  2144.  
  2145.     def AppendNeedSP(self, needSP, continuationSP, color):
  2146.  
  2147.         if -1 == needSP:
  2148.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_ALL_SP, color)
  2149.  
  2150.         else:
  2151.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_SP % (needSP), color)
  2152.  
  2153.         if continuationSP > 0:
  2154.             self.AppendTextLine(localeInfo.TOOLTIP_NEED_SP_PER_SEC % (continuationSP), color)
  2155.  
  2156.     def AppendPartySkillData(self, skillGrade, skillLevel):
  2157.  
  2158.         if 1 == skillGrade:
  2159.             skillLevel += 19
  2160.         elif 2 == skillGrade:
  2161.             skillLevel += 29
  2162.         elif 3 == skillGrade:
  2163.             skillLevel =  40
  2164.  
  2165.         if skillLevel <= 0:
  2166.             return
  2167.  
  2168.         skillIndex = player.SKILL_INDEX_TONGSOL
  2169.         slotIndex = player.GetSkillSlotIndex(skillIndex)
  2170.         skillPower = player.GetSkillCurrentEfficientPercentage(slotIndex)
  2171.         if localeInfo.IsBRAZIL():
  2172.             k = skillPower
  2173.         else:
  2174.             k = player.GetSkillLevel(skillIndex) / 100.0
  2175.         self.AppendSpace(5)
  2176.         self.AutoAppendTextLine(localeInfo.TOOLTIP_PARTY_SKILL_LEVEL % skillLevel, self.NORMAL_COLOR)
  2177.  
  2178.         if skillLevel>=10:
  2179.             self.AutoAppendTextLine(localeInfo.PARTY_SKILL_ATTACKER % chop( 10 + 60 * k ))
  2180.  
  2181.         if skillLevel>=20:
  2182.             self.AutoAppendTextLine(localeInfo.PARTY_SKILL_BERSERKER    % chop(1 + 5 * k))
  2183.             self.AutoAppendTextLine(localeInfo.PARTY_SKILL_TANKER   % chop(50 + 1450 * k))
  2184.  
  2185.         if skillLevel>=25:
  2186.             self.AutoAppendTextLine(localeInfo.PARTY_SKILL_BUFFER % chop(5 + 45 * k ))
  2187.  
  2188.         if skillLevel>=35:
  2189.             self.AutoAppendTextLine(localeInfo.PARTY_SKILL_SKILL_MASTER % chop(25 + 600 * k ))
  2190.  
  2191.         if skillLevel>=40:
  2192.             self.AutoAppendTextLine(localeInfo.PARTY_SKILL_DEFENDER % chop( 5 + 30 * k ))
  2193.  
  2194.         self.AlignHorizonalCenter()
  2195.  
  2196.     def __AppendSummonDescription(self, skillLevel, color):
  2197.         if skillLevel > 1:
  2198.             self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (skillLevel * 10), color)
  2199.         elif 1 == skillLevel:
  2200.             self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (15), color)
  2201.         elif 0 == skillLevel:
  2202.             self.AppendTextLine(localeInfo.SKILL_SUMMON_DESCRIPTION % (10), color)
  2203.  
  2204.  
  2205. if __name__ == "__main__"
  2206.     import app
  2207.     import wndMgr
  2208.     import systemSetting
  2209.     import mouseModule
  2210.     import grp
  2211.     import ui
  2212.    
  2213.     #wndMgr.SetOutlineFlag(TRUE)
  2214.  
  2215.     app.SetMouseHandler(mouseModule.mouseController)
  2216.     app.SetHairColorEnable(TRUE)
  2217.     wndMgr.SetMouseHandler(mouseModule.mouseController)
  2218.     wndMgr.SetScreenSize(systemSetting.GetWidth(), systemSetting.GetHeight())
  2219.     app.Create("METIN2 CLOSED BETA", systemSetting.GetWidth(), systemSetting.GetHeight(), 1)
  2220.     mouseModule.mouseController.Create()
  2221.  
  2222.     toolTip = ItemToolTip()
  2223.     toolTip.ClearToolTip()
  2224.     #toolTip.AppendTextLine("Test")
  2225.     desc = "Item descriptions:|increase of width of display to 35 digits per row AND installation of function that the displayed words are not broken up in two parts, but instead if one word is too long to be displayed in this row, this word will start in the next row."
  2226.     summ = ""
  2227.  
  2228.     toolTip.AddItemData_Offline(10, desc, summ, 0, 0)
  2229.     toolTip.Show()
  2230.    
  2231.     app.Loop()
  2232.  
  2233.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement