Advertisement
Guest User

Untitled

a guest
Mar 14th, 2023
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 49.91 KB | None | 0 0
  1. import app
  2. import ui
  3. import playerm2g2
  4. import m2netm2g
  5. import wndMgr
  6. import messenger
  7. import guild
  8. import chr
  9. import nonplayer
  10. import localeInfo
  11. import constInfo
  12.  
  13. if app.ENABLE_12ZI or app.ENABLE_POISON_GAUGE_EFFECT:
  14.     import chrmgrm2g
  15.     import background
  16.  
  17. if app.ENABLE_12ZI or app.ENABLE_MESSENGER_BLOCK:
  18.     import uiCommon
  19.  
  20. if constInfo.SHOW_HP_MONSTERS_SYSTEM:
  21.     import uiHealth
  22.  
  23. if app.ENABLE_SEND_TARGET_INFO:
  24.     import uiToolTip
  25.     import item
  26.  
  27.     MONSTER_INFO_DATA = {}
  28.  
  29.     def HAS_FLAG(value, flag):
  30.         return (value & flag) == flag
  31.  
  32. class TargetBoard(ui.ThinBoard):
  33.     if app.ENABLE_SEND_TARGET_INFO:
  34.         class InfoBoard(ui.ThinBoard):
  35.             class ItemListBoxItem(ui.ListBoxExNew.Item):
  36.                 def __init__(self, width):
  37.                     ui.ListBoxExNew.Item.__init__(self)
  38.  
  39.                     image = ui.ExpandedImageBox()
  40.                     image.SetParent(self)
  41.                     image.Show()
  42.                     self.image = image
  43.  
  44.                     nameLine = ui.TextLine()
  45.                     nameLine.SetParent(self)
  46.                     if localeInfo.IsARABIC():
  47.                         nameLine.SetPosition(5 + 5, 0)
  48.                         nameLine.SetWindowHorizontalAlignRight()
  49.                     else:
  50.                         nameLine.SetPosition(32 + 5, 0)
  51.                     nameLine.Show()
  52.                     self.nameLine = nameLine
  53.  
  54.                     self.SetSize(width, 32 + 5)
  55.  
  56.                 def LoadImage(self, image, name = None):
  57.                     self.image.LoadImage(image)
  58.                     self.SetSize(self.GetWidth(), self.image.GetHeight() + 5 * (self.image.GetHeight() / 32))
  59.                     if name != None:
  60.                         self.SetText(name)
  61.  
  62.                 def SetText(self, text):
  63.                     self.nameLine.SetText(text)
  64.  
  65.                 def RefreshHeight(self):
  66.                     ui.ListBoxExNew.Item.RefreshHeight(self)
  67.                     self.image.SetRenderingRect(0.0, 0.0 - float(self.removeTop) / float(self.GetHeight()), 0.0, 0.0 - float(self.removeBottom) / float(self.GetHeight()))
  68.                     self.image.SetPosition(0, - self.removeTop)
  69.  
  70.             MAX_ITEM_COUNT = 5
  71.  
  72.             EXP_BASE_LVDELTA = [
  73.                 1,  #  -15 0
  74.                 5,  #  -14 1
  75.                 10, #  -13 2
  76.                 20, #  -12 3
  77.                 30, #  -11 4
  78.                 50, #  -10 5
  79.                 70, #  -9  6
  80.                 80, #  -8  7
  81.                 85, #  -7  8
  82.                 90, #  -6  9
  83.                 92, #  -5  10
  84.                 94, #  -4  11
  85.                 96, #  -3  12
  86.                 98, #  -2  13
  87.                 100,    #  -1  14
  88.                 100,    #  0   15
  89.                 105,    #  1   16
  90.                 110,    #  2   17
  91.                 115,    #  3   18
  92.                 120,    #  4   19
  93.                 125,    #  5   20
  94.                 130,    #  6   21
  95.                 135,    #  7   22
  96.                 140,    #  8   23
  97.                 145,    #  9   24
  98.                 150,    #  10  25
  99.                 155,    #  11  26
  100.                 160,    #  12  27
  101.                 165,    #  13  28
  102.                 170,    #  14  29
  103.                 180,    #  15  30
  104.             ]
  105.  
  106.             RACE_FLAG_TO_NAME = {
  107.                 1 << 0  : localeInfo.TARGET_INFO_RACE_ANIMAL,
  108.                 1 << 1  : localeInfo.TARGET_INFO_RACE_UNDEAD,
  109.                 1 << 2  : localeInfo.TARGET_INFO_RACE_DEVIL,
  110.                 1 << 3  : localeInfo.TARGET_INFO_RACE_HUMAN,
  111.                 1 << 4  : localeInfo.TARGET_INFO_RACE_ORC,
  112.                 1 << 5  : localeInfo.TARGET_INFO_RACE_MILGYO,
  113.             }
  114.             if app.ENABLE_ELEMENT_ADD:
  115.                 RACE_FLAG_TO_NAME.update({
  116.                     1 << 6  : localeInfo.TARGET_INFO_RACE_INSECT,
  117.                     1 << 7  : localeInfo.TARGET_INFO_RACE_DESERT,
  118.                     1 << 11 : localeInfo.TARGET_INFO_RACE_CZ,
  119.                 })
  120.  
  121.             if app.ENABLE_ELEMENT_ADD: # renewal
  122.                 SUB_RACE_FLAG_TO_NAME = {
  123.                     0  : localeInfo.TARGET_INFO_RACE_ELEC,
  124.                     1  : localeInfo.TARGET_INFO_RACE_FIRE,
  125.                     2  : localeInfo.TARGET_INFO_RACE_ICE,
  126.                     3  : localeInfo.TARGET_INFO_RACE_WIND,
  127.                     4  : localeInfo.TARGET_INFO_RACE_EARTH,
  128.                     5  : localeInfo.TARGET_INFO_RACE_DARK,
  129.                 }
  130.  
  131.             if app.ENABLE_WOLFMAN_CHARACTER:
  132.                 STONE_START_VNUM = 28029 # 28012
  133.             else:
  134.                 STONE_START_VNUM = 28030
  135.             if app.ENABLE_MAGIC_REDUCTION_SYSTEM:
  136.                 STONE_LAST_VNUM = 28045
  137.             else:
  138.                 STONE_LAST_VNUM = 28042
  139.  
  140.             BOARD_WIDTH = 250
  141.  
  142.             def __init__(self):
  143.                 ui.ThinBoard.__init__(self)
  144.  
  145.                 self.HideCorners(self.LT)
  146.                 self.HideCorners(self.RT)
  147.                 self.HideLine(self.T)
  148.  
  149.                 self.race = 0
  150.                 self.hasItems = False
  151.  
  152.                 self.itemTooltip = uiToolTip.ItemToolTip()
  153.                 self.itemTooltip.HideToolTip()
  154.  
  155.                 self.stoneImg = None
  156.                 self.stoneVnum = None
  157.                 self.lastStoneVnum = 0
  158.                 self.nextStoneIconChange = 0
  159.  
  160.                 self.itemScrollBar = None
  161.  
  162.                 self.SetSize(self.BOARD_WIDTH, 0)
  163.  
  164.             def __del__(self):
  165.                 ui.ThinBoard.__del__(self)
  166.  
  167.             def __UpdatePosition(self, targetBoard):
  168.                 self.SetPosition(targetBoard.GetLeft() + (targetBoard.GetWidth() - self.GetWidth()) / 2, targetBoard.GetBottom() - 17)
  169.  
  170.             def Open(self, targetBoard, race):
  171.                 self.__LoadInformation(race)
  172.  
  173.                 self.SetSize(self.BOARD_WIDTH, self.yPos + 10)
  174.                 self.__UpdatePosition(targetBoard)
  175.  
  176.                 self.Show()
  177.  
  178.             def Refresh(self):
  179.                 self.__LoadInformation(self.race)
  180.                 self.SetSize(self.BOARD_WIDTH, self.yPos + 10)
  181.  
  182.             def Close(self):
  183.                 self.itemTooltip.HideToolTip()
  184.                 self.itemScrollBar = None
  185.                 self.Hide()
  186.  
  187.             def __LoadInformation(self, race):
  188.                 self.yPos = 7
  189.                 self.children = []
  190.                 self.race = race
  191.                 self.stoneImg = None
  192.                 self.stoneVnum = None
  193.                 self.nextStoneIconChange = 0
  194.  
  195.                 self.__LoadInformation_Default(race)
  196.                 self.__LoadInformation_Race(race)
  197.                 self.__LoadInformation_Resists(race) # EXTENDED
  198.                 self.__LoadInformation_Drops(race)
  199.  
  200.             def __LoadInformation_Default_GetHitRate(self, race):
  201.                 attacker_dx = nonplayer.GetMonsterDX(race)
  202.                 attacker_level = nonplayer.GetMonsterLevel(race)
  203.  
  204.                 self_dx = playerm2g2.GetStatus(playerm2g2.DX)
  205.                 self_level = playerm2g2.GetStatus(playerm2g2.LEVEL)
  206.  
  207.                 iARSrc = min(90, (attacker_dx * 4 + attacker_level * 2) / 6)
  208.                 iERSrc = min(90, (self_dx * 4 + self_level * 2) / 6)
  209.  
  210.                 fAR = (float(iARSrc) + 210.0) / 300.0
  211.                 fER = (float(iERSrc) * 2 + 5) / (float(iERSrc) + 95) * 3.0 / 10.0
  212.  
  213.                 return fAR - fER
  214.  
  215.             def __LoadInformation_Resists(self, race): # EXTENDED
  216.                 self.AppendSeperator()
  217.                 self.AppendTextLine(localeInfo.TARGET_INFO_RESISTS)
  218.                 self.AppendTextLine(localeInfo.TARGET_INFO_RESISTS_LINE % (nonplayer.GetResist(race, nonplayer.MOB_RESIST_FIST)))
  219.                 self.AppendTextLine(localeInfo.TARGET_INFO_RESISTS_LINE0 % (nonplayer.GetResist(race, nonplayer.MOB_RESIST_SWORD), nonplayer.GetResist(race, nonplayer.MOB_RESIST_TWOHAND), nonplayer.GetResist(race, nonplayer.MOB_RESIST_DAGGER)))
  220.                 self.AppendTextLine(localeInfo.TARGET_INFO_RESISTS_LINE1 % (nonplayer.GetResist(race, nonplayer.MOB_RESIST_BELL), nonplayer.GetResist(race, nonplayer.MOB_RESIST_FAN), nonplayer.GetResist(race, nonplayer.MOB_RESIST_BOW)))
  221.                 if app.ENABLE_PROTO_RENEWAL:
  222.                     self.AppendTextLine(localeInfo.TARGET_INFO_RESISTS_LINE2 % (nonplayer.GetResist(race, nonplayer.MOB_RESIST_CLAW), nonplayer.GetResist(race, nonplayer.MOB_RESIST_BLEEDING)))
  223.  
  224.             def __LoadInformation_Default(self, race):
  225.                 self.AppendSeperator()
  226.                 self.AppendTextLine(localeInfo.TARGET_INFO_MAX_HP % str(nonplayer.GetMonsterMaxHP(race)))
  227.  
  228.                 # calc att damage
  229.                 monsterLevel = nonplayer.GetMonsterLevel(race)
  230.                 fHitRate = self.__LoadInformation_Default_GetHitRate(race)
  231.                 iDamMin, iDamMax = nonplayer.GetMonsterDamage(race)
  232.                 iDamMin = int((iDamMin + nonplayer.GetMonsterST(race)) * 2 * fHitRate) + monsterLevel * 2
  233.                 iDamMax = int((iDamMax + nonplayer.GetMonsterST(race)) * 2 * fHitRate) + monsterLevel * 2
  234.                 iDef = playerm2g2.GetStatus(playerm2g2.DEF_GRADE) * (100 + playerm2g2.GetStatus(playerm2g2.DEF_BONUS)) / 100
  235.                 fDamMulti = nonplayer.GetMonsterDamageMultiply(race)
  236.                 iDamMin = int(max(0, iDamMin - iDef) * fDamMulti)
  237.                 iDamMax = int(max(0, iDamMax - iDef) * fDamMulti)
  238.                 if iDamMin < 1:
  239.                     iDamMin = 1
  240.                 if iDamMax < 5:
  241.                     iDamMax = 5
  242.                 self.AppendTextLine(localeInfo.TARGET_INFO_DAMAGE % (str(iDamMin), str(iDamMax)))
  243.  
  244.                 idx = min(len(self.EXP_BASE_LVDELTA) - 1, max(0, (monsterLevel + 15) - playerm2g2.GetStatus(playerm2g2.LEVEL)))
  245.                 iExp = nonplayer.GetMonsterExp(race) * self.EXP_BASE_LVDELTA[idx] / 100
  246.                 self.AppendTextLine(localeInfo.TARGET_INFO_EXP % str(iExp))
  247.                 self.AppendTextLine(localeInfo.TARGET_INFO_GOLD_MIN_MAX % (localeInfo.NumberToMoneyStringEx(nonplayer.GetMobGoldMin(race)), localeInfo.NumberToMoneyStringEx(nonplayer.GetMobGoldMax(race)))) # EXTENDED
  248.                 self.AppendTextLine(localeInfo.TARGET_INFO_REGEN_INFO % (nonplayer.GetMobRegenPercent(race), nonplayer.GetMobRegenCycle(race))) # EXTENDED
  249.  
  250.             def __LoadInformation_Race(self, race):
  251.                 dwRaceFlag = nonplayer.GetMonsterRaceFlag(race)
  252.                 self.AppendSeperator()
  253.  
  254.                 mainrace = ""
  255.                 subrace = ""
  256.                 race_range = 17 ## PythonNonPlayer.h -> ERaceFlags +1
  257.  
  258.                 for i in xrange(race_range):
  259.                     curFlag = 1 << i
  260.                     if HAS_FLAG(dwRaceFlag, curFlag):
  261.                         if self.RACE_FLAG_TO_NAME.has_key(curFlag):
  262.                             mainrace += self.RACE_FLAG_TO_NAME[curFlag] + ", "
  263.  
  264.                 if app.ENABLE_ELEMENT_ADD:
  265.                     for i in xrange(nonplayer.MOB_ELEMENTAL_MAX_NUM):
  266.                         if nonplayer.GetMonsterEnchantElement(race, i) >= 1:
  267.                             if self.SUB_RACE_FLAG_TO_NAME.has_key(i):
  268.                                 subrace += self.SUB_RACE_FLAG_TO_NAME[i] + ", "
  269.  
  270.                 if nonplayer.IsMonsterStone(race):
  271.                     mainrace += localeInfo.TARGET_INFO_RACE_METIN + ", "
  272.                 if mainrace == "":
  273.                     mainrace = localeInfo.TARGET_INFO_NO_RACE
  274.                 else:
  275.                     mainrace = mainrace[:-2]
  276.                 if subrace == "":
  277.                     subrace = localeInfo.TARGET_INFO_NO_SUBRACE
  278.                 else:
  279.                     subrace = subrace[:-2]
  280.  
  281.                 self.AppendTextLine(localeInfo.TARGET_INFO_MAINRACE % mainrace)
  282.                 self.AppendTextLine(localeInfo.TARGET_INFO_SUBRACE % subrace)
  283.  
  284.             def __LoadInformation_Drops(self, race):
  285.                 self.AppendSeperator()
  286.  
  287.                 if race in MONSTER_INFO_DATA:
  288.                     if len(MONSTER_INFO_DATA[race]["items"]) == 0:
  289.                         self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)
  290.                     else:
  291.                         itemListBox = ui.ListBoxExNew(32 + 5, self.MAX_ITEM_COUNT)
  292.                         itemListBox.SetSize(self.GetWidth() - 15 * 2 - ui.ScrollBar.SCROLLBAR_WIDTH, (32 + 5) * self.MAX_ITEM_COUNT)
  293.                         height = 0
  294.                         for curItem in MONSTER_INFO_DATA[race]["items"]:
  295.                             if curItem.has_key("vnum_list"):
  296.                                 height += self.AppendItem(itemListBox, curItem["vnum_list"], curItem["count"])
  297.                             else:
  298.                                 height += self.AppendItem(itemListBox, curItem["vnum"], curItem["count"])
  299.                         if height < itemListBox.GetHeight():
  300.                             itemListBox.SetSize(itemListBox.GetWidth(), height)
  301.                         self.AppendWindow(itemListBox, 15)
  302.                         itemListBox.SetBasePos(0)
  303.  
  304.                         if len(MONSTER_INFO_DATA[race]["items"]) > itemListBox.GetViewItemCount():
  305.                             itemScrollBar = ui.ScrollBar()
  306.                             itemScrollBar.SetParent(self)
  307.                             itemScrollBar.SetPosition(itemListBox.GetRight(), itemListBox.GetTop())
  308.                             itemScrollBar.SetScrollBarSize(32 * self.MAX_ITEM_COUNT + 5 * (self.MAX_ITEM_COUNT - 1))
  309.                             itemScrollBar.SetMiddleBarSize(float(self.MAX_ITEM_COUNT) / float(height / (32 + 5)))
  310.                             itemScrollBar.Show()
  311.                             itemListBox.SetScrollBar(itemScrollBar)
  312.                             self.itemScrollBar = itemScrollBar
  313.                         else:
  314.                             self.itemScrollBar = None
  315.                 else:
  316.                     self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)
  317.  
  318.             if app.ENABLE_RUN_MOUSE_WHEEL_EVENT:
  319.                 def OnRunMouseWheel(self, pos):
  320.                     if self.itemScrollBar.IsShow():
  321.                         if pos > 0:
  322.                             self.itemScrollBar.OnUp()
  323.                         else:
  324.                             self.itemScrollBar.OnDown()
  325.  
  326.             def AppendTextLine(self, text):
  327.                 textLine = ui.TextLine()
  328.                 textLine.SetParent(self)
  329.                 textLine.SetWindowHorizontalAlignCenter()
  330.                 textLine.SetHorizontalAlignCenter()
  331.                 textLine.SetText(text)
  332.                 textLine.SetPosition(0, self.yPos)
  333.                 textLine.Show()
  334.  
  335.                 self.children.append(textLine)
  336.                 self.yPos += 17
  337.  
  338.             def AppendSeperator(self):
  339.                 img = ui.ImageBox()
  340.                 img.LoadImage("d:/ymir work/ui/seperator.tga")
  341.                 self.AppendWindow(img)
  342.                 img.SetPosition(img.GetLeft(), img.GetTop() - 15)
  343.                 self.yPos -= 15
  344.  
  345.             def AppendItem(self, listBox, vnums, count):
  346.                 if type(vnums) == int:
  347.                     vnum = vnums
  348.                 else:
  349.                     vnum = vnums[0]
  350.  
  351.                 item.SelectItem(vnum)
  352.                 itemName = item.GetItemName()
  353.                 if type(vnums) != int and len(vnums) > 1:
  354.                     vnums = sorted(vnums)
  355.                     realName = itemName[:itemName.find("+")]
  356.                     if item.GetItemType() == item.ITEM_TYPE_METIN:
  357.                         realName = localeInfo.TARGET_INFO_STONE_NAME
  358.                         itemName = realName + "+0 ~ +4"
  359.                     else:
  360.                         itemName = realName + "+" + str(vnums[0] % 10) + " - +" + str(vnums[len(vnums) - 1] % 10)
  361.                     vnum = vnums[len(vnums) - 1]
  362.  
  363.                 myItem = self.ItemListBoxItem(listBox.GetWidth())
  364.                 myItem.LoadImage(item.GetIconImageFileName())
  365.                 if count <= 1:
  366.                     myItem.SetText(itemName)
  367.                 else:
  368.                     myItem.SetText("%dx %s" % (count, itemName))
  369.                 myItem.SAFE_SetOverInEvent(self.OnShowItemTooltip, vnum)
  370.                 myItem.SAFE_SetOverOutEvent(self.OnHideItemTooltip)
  371.                 listBox.AppendItem(myItem)
  372.  
  373.                 if item.GetItemType() == item.ITEM_TYPE_METIN:
  374.                     self.stoneImg = myItem
  375.                     self.stoneVnum = vnums
  376.                     self.lastStoneVnum = self.STONE_LAST_VNUM + vnums[len(vnums) - 1] % 1000 / 100 * 100
  377.  
  378.                 return myItem.GetHeight()
  379.  
  380.             def OnShowItemTooltip(self, vnum):
  381.                 item.SelectItem(vnum)
  382.                 if item.GetItemType() == item.ITEM_TYPE_METIN:
  383.                     self.itemTooltip.isStone = True
  384.                     self.itemTooltip.isBook = False
  385.                     self.itemTooltip.isBook2 = False
  386.                     self.itemTooltip.SetItemToolTip(self.lastStoneVnum)
  387.                 else:
  388.                     self.itemTooltip.isStone = False
  389.                     self.itemTooltip.isBook = True
  390.                     self.itemTooltip.isBook2 = True
  391.                     self.itemTooltip.SetItemToolTip(vnum)
  392.  
  393.             def OnHideItemTooltip(self):
  394.                 self.itemTooltip.HideToolTip()
  395.  
  396.             def AppendWindow(self, wnd, x = 0, width = 0, height = 0):
  397.                 if width == 0:
  398.                     width = wnd.GetWidth()
  399.                 if height == 0:
  400.                     height = wnd.GetHeight()
  401.  
  402.                 wnd.SetParent(self)
  403.                 if x == 0:
  404.                     wnd.SetPosition((self.GetWidth() - width) / 2, self.yPos)
  405.                 else:
  406.                     wnd.SetPosition(x, self.yPos)
  407.                 wnd.Show()
  408.  
  409.                 self.children.append(wnd)
  410.                 self.yPos += height + 5
  411.  
  412.             def OnUpdate(self):
  413.                 if self.stoneImg != None and self.stoneVnum != None and app.GetTime() >= self.nextStoneIconChange:
  414.                     nextImg = self.lastStoneVnum + 1
  415.                     if nextImg % 100 > self.STONE_LAST_VNUM % 100:
  416.                         nextImg -= (self.STONE_LAST_VNUM - self.STONE_START_VNUM) + 1
  417.                     self.lastStoneVnum = nextImg
  418.                     self.nextStoneIconChange = app.GetTime() + 2.5
  419.  
  420.                     item.SelectItem(nextImg)
  421.                     itemName = item.GetItemName()
  422.                     realName = itemName[:itemName.find("+")]
  423.                     realName = realName + "+0 ~ +4"
  424.                     self.stoneImg.LoadImage(item.GetIconImageFileName(), realName)
  425.  
  426.                     if self.itemTooltip.IsShow() and self.itemTooltip.isStone:
  427.                         self.itemTooltip.SetItemToolTip(nextImg)
  428.  
  429.     BUTTON_NAME_LIST = [
  430.         localeInfo.TARGET_BUTTON_WHISPER,
  431.         localeInfo.TARGET_BUTTON_EXCHANGE,
  432.         localeInfo.TARGET_BUTTON_FIGHT,
  433.         localeInfo.TARGET_BUTTON_ACCEPT_FIGHT,
  434.         localeInfo.TARGET_BUTTON_AVENGE,
  435.         localeInfo.TARGET_BUTTON_FRIEND,
  436.         localeInfo.TARGET_BUTTON_INVITE_PARTY,
  437.         localeInfo.TARGET_BUTTON_LEAVE_PARTY,
  438.         localeInfo.TARGET_BUTTON_EXCLUDE,
  439.         localeInfo.TARGET_BUTTON_INVITE_GUILD,
  440.         localeInfo.TARGET_BUTTON_DISMOUNT,
  441.         localeInfo.TARGET_BUTTON_EXIT_OBSERVER,
  442.         localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT,
  443.         localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY,
  444.         localeInfo.TARGET_BUTTON_BUILDING_DESTROY,
  445.         localeInfo.TARGET_BUTTON_EMOTION_ALLOW,
  446.         "VOTE_BLOCK_CHAT",
  447.     ]
  448.     if app.ENABLE_MESSENGER_BLOCK:
  449.         BUTTON_NAME_LIST.append(localeInfo.TARGET_BUTTON_BLOCK)
  450.         BUTTON_NAME_LIST.append(localeInfo.TARGET_BUTTON_BLOCK_REMOVE)
  451.  
  452.     if app.ENABLE_12ZI:
  453.         BUTTON_NAME_LIST.append(localeInfo.TARGET_BUTTON_REVIVE)
  454.  
  455.     GRADE_NAME =    {
  456.                         nonplayer.PAWN : localeInfo.TARGET_LEVEL_PAWN,
  457.                         nonplayer.S_PAWN : localeInfo.TARGET_LEVEL_S_PAWN,
  458.                         nonplayer.KNIGHT : localeInfo.TARGET_LEVEL_KNIGHT,
  459.                         nonplayer.S_KNIGHT : localeInfo.TARGET_LEVEL_S_KNIGHT,
  460.                         nonplayer.BOSS : localeInfo.TARGET_LEVEL_BOSS,
  461.                         nonplayer.KING : localeInfo.TARGET_LEVEL_KING,
  462.                     }
  463.     EXCHANGE_LIMIT_RANGE = 3000
  464.  
  465.     if app.ENABLE_ELEMENT_ADD:
  466.         ELEMENT_ENCHANT_ICON_SCALE = 0.8
  467.         ELEMENT_IMG_PATH = \
  468.         {
  469.             nonplayer.MOB_ENCHANT_ELECT : "d:/ymir work/ui/game/12zi/element/elect.sub",
  470.             nonplayer.MOB_ENCHANT_FIRE  : "d:/ymir work/ui/game/12zi/element/fire.sub",
  471.             nonplayer.MOB_ENCHANT_ICE   : "d:/ymir work/ui/game/12zi/element/ice.sub",
  472.             nonplayer.MOB_ENCHANT_WIND  : "d:/ymir work/ui/game/12zi/element/wind.sub",
  473.             nonplayer.MOB_ENCHANT_EARTH : "d:/ymir work/ui/game/12zi/element/earth.sub",
  474.             nonplayer.MOB_ENCHANT_DARK  : "d:/ymir work/ui/game/12zi/element/dark.sub",
  475.         }
  476.  
  477.     def __init__(self):
  478.         ui.ThinBoard.__init__(self)
  479.  
  480.         if app.ENABLE_MESSENGER_BLOCK:
  481.             self.AddFlag("float")
  482.  
  483.         name = ui.TextLine()
  484.         name.SetParent(self)
  485.         name.SetDefaultFontName()
  486.         name.SetOutline()
  487.         name.Show()
  488.  
  489.         if app.ENABLE_ACCUMULATE_DAMAGE_DISPLAY:
  490.             damage_display = ui.TextLine()
  491.             damage_display.SetParent( name )
  492.             damage_display.SetDefaultFontName()
  493.             damage_display.SetOutline()
  494.             damage_display.Show()
  495.             self.damage_display = damage_display
  496.  
  497.         hpGauge = ui.Gauge()
  498.         hpGauge.SetParent(self)
  499.         hpGauge.MakeGauge(130, "red")
  500.         hpGauge.Hide()
  501.  
  502.         if app.ENABLE_POISON_GAUGE_EFFECT:
  503.             hpPoisonGauge = ui.Gauge()
  504.             hpPoisonGauge.SetParent(self)
  505.             hpPoisonGauge.MakeGauge(130, "lime")
  506.             hpPoisonGauge.SetPosition(175, 17)
  507.             hpPoisonGauge.SetWindowHorizontalAlignRight()
  508.             hpPoisonGauge.Hide()
  509.  
  510.         if constInfo.SHOW_HP_MONSTERS_SYSTEM:
  511.             hpPercenttxt = ui.TextLine()
  512.             hpPercenttxt.SetParent(self)
  513.             hpPercenttxt.SetPosition(160, 13)
  514.             hpPercenttxt.SetText("")
  515.             hpPercenttxt.Hide()
  516.  
  517.         if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  518.             hpDecimal = ui.TextLine()
  519.             hpDecimal.SetParent(hpGauge)
  520.             hpDecimal.SetDefaultFontName()
  521.             hpDecimal.SetPosition(5, 5)
  522.             hpDecimal.SetOutline()
  523.             hpDecimal.Hide()
  524.  
  525.         closeButton = ui.Button()
  526.         closeButton.SetParent(self)
  527.         closeButton.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  528.         closeButton.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  529.         closeButton.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  530.         closeButton.SetPosition(30, 13)
  531.  
  532.         if localeInfo.IsARABIC():
  533.             hpGauge.SetPosition(55, 17)
  534.             hpGauge.SetWindowHorizontalAlignLeft()
  535.             closeButton.SetWindowHorizontalAlignLeft()
  536.         else:
  537.             hpGauge.SetPosition(175, 17)
  538.             hpGauge.SetWindowHorizontalAlignRight()
  539.             closeButton.SetWindowHorizontalAlignRight()
  540.  
  541.         if app.ENABLE_SEND_TARGET_INFO:
  542.             infoButton = ui.Button()
  543.             infoButton.SetParent(self)
  544.             infoButton.SetUpVisual("d:/ymir work/ui/pattern/q_mark_01.tga")
  545.             infoButton.SetOverVisual("d:/ymir work/ui/pattern/q_mark_02.tga")
  546.             infoButton.SetDownVisual("d:/ymir work/ui/pattern/q_mark_01.tga")
  547.             infoButton.SetEvent(ui.__mem_func__(self.OnPressedInfoButton))
  548.             infoButton.Hide()
  549.  
  550.             infoBoard = self.InfoBoard()
  551.             infoBoard.Hide()
  552.             infoButton.showWnd = infoBoard
  553.  
  554.         closeButton.SetEvent(ui.__mem_func__(self.OnPressedCloseButton))
  555.         closeButton.Show()
  556.  
  557.         if app.ENABLE_ELEMENT_ADD:
  558.             self.element_enchants_dict = {}
  559.             self.elementImgDict = {}
  560.             for element, path in self.ELEMENT_IMG_PATH.items():
  561.                 elementImg = ui.ExpandedImageBox()
  562.                 elementImg.SetParent(self)
  563.                 elementImg.LoadImage( path )
  564.                 elementImg.SetPosition(0, 0)
  565.                 if localeInfo.IsARABIC():
  566.                     elementImg.SetWindowHorizontalAlignRight()
  567.                 else:
  568.                     elementImg.SetWindowHorizontalAlignLeft()
  569.                 elementImg.SetScale(self.ELEMENT_ENCHANT_ICON_SCALE, self.ELEMENT_ENCHANT_ICON_SCALE)
  570.                 elementImg.Hide()
  571.                 self.elementImgDict[element] = elementImg
  572.  
  573.         self.buttonDict = {}
  574.         self.showingButtonList = []
  575.         for buttonName in self.BUTTON_NAME_LIST:
  576.             button = ui.Button()
  577.             button.SetParent(self)
  578.  
  579.             if localeInfo.IsARABIC():
  580.                 button.SetUpVisual("d:/ymir work/ui/public/Small_Button_01.sub")
  581.                 button.SetOverVisual("d:/ymir work/ui/public/Small_Button_02.sub")
  582.                 button.SetDownVisual("d:/ymir work/ui/public/Small_Button_03.sub")
  583.             else:
  584.                 button.SetUpVisual("d:/ymir work/ui/public/small_thin_button_01.sub")
  585.                 button.SetOverVisual("d:/ymir work/ui/public/small_thin_button_02.sub")
  586.                 button.SetDownVisual("d:/ymir work/ui/public/small_thin_button_03.sub")
  587.  
  588.             button.SetWindowHorizontalAlignCenter()
  589.             button.SetText(buttonName)
  590.             button.Hide()
  591.             self.buttonDict[buttonName] = button
  592.             self.showingButtonList.append(button)
  593.  
  594.         self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER].SetEvent(ui.__mem_func__(self.OnWhisper))
  595.         self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE].SetEvent(ui.__mem_func__(self.OnExchange))
  596.         self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
  597.         self.buttonDict[localeInfo.TARGET_BUTTON_ACCEPT_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
  598.         self.buttonDict[localeInfo.TARGET_BUTTON_AVENGE].SetEvent(ui.__mem_func__(self.OnPVP))
  599.         self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  600.         self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  601.         self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyInvite))
  602.         self.buttonDict[localeInfo.TARGET_BUTTON_LEAVE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyExit))
  603.         self.buttonDict[localeInfo.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))
  604.  
  605.         self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_GUILD].SAFE_SetEvent(self.__OnGuildAddMember)
  606.         self.buttonDict[localeInfo.TARGET_BUTTON_DISMOUNT].SAFE_SetEvent(self.__OnDismount)
  607.         self.buttonDict[localeInfo.TARGET_BUTTON_EXIT_OBSERVER].SAFE_SetEvent(self.__OnExitObserver)
  608.         self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT].SAFE_SetEvent(self.__OnViewEquipment)
  609.         self.buttonDict[localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY].SAFE_SetEvent(self.__OnRequestParty)
  610.         self.buttonDict[localeInfo.TARGET_BUTTON_BUILDING_DESTROY].SAFE_SetEvent(self.__OnDestroyBuilding)
  611.         self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW].SAFE_SetEvent(self.__OnEmotionAllow)
  612.         if app.ENABLE_12ZI:
  613.             self.buttonDict[localeInfo.TARGET_BUTTON_REVIVE].SAFE_SetEvent(self.__OnReviveQustionDialog)
  614.         if app.ENABLE_MESSENGER_BLOCK:
  615.             self.buttonDict[localeInfo.TARGET_BUTTON_BLOCK].SAFE_SetEvent(self.__OnBlock)
  616.             self.buttonDict[localeInfo.TARGET_BUTTON_BLOCK_REMOVE].SAFE_SetEvent(self.__OnBlockRemove)
  617.  
  618.         self.buttonDict["VOTE_BLOCK_CHAT"].SetEvent(ui.__mem_func__(self.__OnVoteBlockChat))
  619.  
  620.         self.name = name
  621.         self.hpGauge = hpGauge
  622.         if app.ENABLE_POISON_GAUGE_EFFECT:
  623.             self.hpPoisonGauge = hpPoisonGauge
  624.         if app.ENABLE_SEND_TARGET_INFO:
  625.             self.infoButton = infoButton
  626.             self.vnum = 0
  627.         if constInfo.SHOW_HP_MONSTERS_SYSTEM:
  628.             self.hpPercenttxt = hpPercenttxt
  629.         if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  630.             self.hpDecimal = hpDecimal
  631.         self.closeButton = closeButton
  632.         self.nameString = 0
  633.         self.nameLength = 0
  634.         self.vid = 0
  635.         self.eventWhisper = None
  636.         self.isShowButton = False
  637.         if app.ENABLE_12ZI or app.ENABLE_MESSENGER_BLOCK:
  638.             self.questionDialog = None
  639.         if constInfo.PAST_HEALTH_ON_TARGET:
  640.             self.oldPercentage = 100
  641.             self.newPercentage = 100
  642.  
  643.         self.__Initialize()
  644.         self.ResetTargetBoard()
  645.  
  646.     def __del__(self):
  647.         ui.ThinBoard.__del__(self)
  648.  
  649.         print "===================================================== DESTROYED TARGET BOARD"
  650.  
  651.     def __Initialize(self):
  652.         self.nameString = ""
  653.         self.nameLength = 0
  654.         self.vid = 0
  655.         if app.ENABLE_SEND_TARGET_INFO:
  656.             self.vnum = 0
  657.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  658.             self.targetAffectIconContainers = {}
  659.         self.isShowButton = False
  660.  
  661.     def Destroy(self):
  662.         self.eventWhisper = None
  663.         self.closeButton = None
  664.         self.showingButtonList = None
  665.         self.buttonDict = None
  666.         self.name = None
  667.         self.hpGauge = None
  668.         if app.ENABLE_POISON_GAUGE_EFFECT:
  669.             self.hpPoisonGauge = None
  670.  
  671.         if app.ENABLE_ELEMENT_ADD:
  672.             self.element_enchants_dict = None
  673.             self.elementImgDict = None
  674.         if app.ENABLE_ACCUMULATE_DAMAGE_DISPLAY:
  675.             self.damage_display = None
  676.         if app.ENABLE_SEND_TARGET_INFO:
  677.             self.infoButton = None
  678.         if constInfo.PAST_HEALTH_ON_TARGET:
  679.             self.oldPercentage = 100
  680.             self.newPercentage = 100
  681.         if constInfo.SHOW_HP_MONSTERS_SYSTEM:
  682.             self.hpPercenttxt = None
  683.         if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  684.             self.hpDecimal = None
  685.  
  686.         self.__Initialize()
  687.  
  688.     if app.ENABLE_SEND_TARGET_INFO:
  689.         def RefreshMonsterInfoBoard(self):
  690.             if not self.infoButton.showWnd.IsShow():
  691.                 return
  692.  
  693.             self.infoButton.showWnd.Refresh()
  694.  
  695.         def OnPressedInfoButton(self):
  696.             m2netm2g.SendTargetInfoLoad(playerm2g2.GetTargetVID())
  697.             if self.infoButton.showWnd.IsShow():
  698.                 self.infoButton.showWnd.Close()
  699.             elif self.vnum != 0:
  700.                 self.infoButton.showWnd.Open(self, self.vnum)
  701.  
  702.     if app.ENABLE_TARGET_AFFECT_SHOWER:
  703.         def OpenTargetAffectIconContainer(self, vid):
  704.             container = self.targetAffectIconContainers.get(vid)
  705.             if not container:
  706.                 container = TargetAffectIconContainer()
  707.                 self.targetAffectIconContainers[vid] = container
  708.  
  709.             container.Show()
  710.             self.UpdateTargetAffectIconContainerPosition(vid)
  711.  
  712.         def HideTargetAffectIconContainer(self, vid):
  713.             container = self.targetAffectIconContainers.get(vid)
  714.             if container and container.IsShow():
  715.                 container.Hide()
  716.  
  717.         def RefreshTargetAffect(self, vid, affectNum, duration):
  718.             container = self.targetAffectIconContainers.get(vid)
  719.             if container:
  720.                 container.SetAffect(affectNum, duration)
  721.  
  722.         def UpdateTargetAffectIconContainerPosition(self, vid):
  723.             container = self.targetAffectIconContainers.get(vid)
  724.             if container:
  725.                 x, y = self.GetGlobalPosition()
  726.                 targetBoardHeight = self.GetHeight()
  727.  
  728.                 #container.SetPosition(x + 10, y + targetBoardHeight + 5)
  729.                 container.SetPosition(x + 250, y + targetBoardHeight + 0)
  730.  
  731.     def OnPressedCloseButton(self):
  732.         playerm2g2.ClearTarget()
  733.         self.Close()
  734.  
  735.     def Close(self):
  736.         self.__Initialize()
  737.         self.HideButtonSystems()
  738.         self.Hide()
  739.  
  740.     def Open(self, vid, name):
  741.         if app.ENABLE_ELEMENT_ADD:
  742.             self.__HideAllElementImg()
  743.         if app.ENABLE_ACCUMULATE_DAMAGE_DISPLAY:
  744.             self.damage_display.Hide()
  745.  
  746.         if vid:
  747.             if not constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD():
  748.                 if not playerm2g2.IsSameEmpire(vid):
  749.                     self.Hide()
  750.                     return
  751.  
  752.             if vid != self.GetTargetVID():
  753.                 self.ResetTargetBoard()
  754.                 self.SetTargetVID(vid)
  755.                 self.SetTargetName(name)
  756.  
  757.             if app.ENABLE_ELEMENT_ADD:
  758.                 self.ShowElementImg(self.element_enchants_dict)
  759.  
  760.             if playerm2g2.IsMainCharacterIndex(vid):
  761.                 self.__ShowMainCharacterMenu()
  762.             elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  763.                 self.Hide()
  764.             else:
  765.                 self.RefreshButton()
  766.                 self.Show()
  767.         else:
  768.             self.HideAllButton()
  769.             if app.ENABLE_PREMIUM_PRIVATE_SHOP:
  770.                 self.HideButtonSystems()
  771.                 self.name.SetPosition(0, 13)
  772.                 self.name.SetHorizontalAlignCenter()
  773.                 self.name.SetWindowHorizontalAlignCenter()
  774.             self.__ShowButton(localeInfo.TARGET_BUTTON_WHISPER)
  775.             self.__ShowButton("VOTE_BLOCK_CHAT")
  776.             self.__ArrangeButtonPosition()
  777.             self.SetTargetName(name)
  778.             self.Show()
  779.  
  780.     def Refresh(self):
  781.         if self.IsShow():
  782.             if self.IsShowButton():
  783.                 self.RefreshButton()
  784.  
  785.     def RefreshByVID(self, vid):
  786.         if vid == self.GetTargetVID():
  787.             self.Refresh()
  788.  
  789.     def RefreshByName(self, name):
  790.         if name == self.GetTargetName():
  791.             self.Refresh()
  792.  
  793.     def __ShowMainCharacterMenu(self):
  794.         canShow=0
  795.  
  796.         self.HideAllButton()
  797.         self.HideButtonSystems()
  798.         if app.ENABLE_ELEMENT_ADD or app.ENABLE_PENDANT:
  799.             self.__HideAllElementImg()
  800.  
  801.         if playerm2g2.IsMountingHorse():
  802.             self.__ShowButton(localeInfo.TARGET_BUTTON_DISMOUNT)
  803.             canShow=1
  804.  
  805.         if playerm2g2.IsObserverMode():
  806.             self.__ShowButton(localeInfo.TARGET_BUTTON_EXIT_OBSERVER)
  807.             canShow=1
  808.  
  809.         if canShow:
  810.             self.name.SetPosition(0, 13)
  811.             self.name.SetHorizontalAlignCenter()
  812.             self.name.SetWindowHorizontalAlignCenter()
  813.             self.__ArrangeButtonPosition()
  814.             self.Show()
  815.         else:
  816.             self.Hide()
  817.  
  818.     def __ShowNameOnlyMenu(self):
  819.         self.HideAllButton()
  820.         self.HideButtonSystems()
  821.  
  822.     def SetWhisperEvent(self, event):
  823.         self.eventWhisper = event
  824.  
  825.     def UpdatePosition(self):
  826.         self.SetPosition(wndMgr.GetScreenWidth()/2 - self.GetWidth()/2, 10)
  827.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  828.             self.UpdateTargetAffectIconContainerPosition(self.vid)
  829.  
  830.     def ResetTargetBoard(self):
  831.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  832.             affectContainer = self.targetAffectIconContainers.get(self.vid)
  833.             if affectContainer and not affectContainer.HasActiveAffects():
  834.                 del self.targetAffectIconContainers[self.vid]
  835.  
  836.         for btn in self.buttonDict.values():
  837.             btn.Hide()
  838.  
  839.         self.__Initialize()
  840.  
  841.         self.name.SetPosition(0, 13)
  842.         self.name.SetHorizontalAlignCenter()
  843.         self.name.SetWindowHorizontalAlignCenter()
  844.  
  845.         if app.ENABLE_ACCUMULATE_DAMAGE_DISPLAY:
  846.             #self.damage_display.SetPosition(0, 30)
  847.             self.damage_display.SetPosition(15, 30)
  848.             self.damage_display.SetHorizontalAlignLeft()
  849.             self.damage_display.SetWindowHorizontalAlignCenter()
  850.  
  851.         self.hpGauge.Hide()
  852.         if app.ENABLE_POISON_GAUGE_EFFECT:
  853.             self.hpPoisonGauge.Hide()
  854.  
  855.         if app.ENABLE_SEND_TARGET_INFO:
  856.             self.infoButton.Hide()
  857.             self.infoButton.showWnd.Close()
  858.         if constInfo.SHOW_HP_MONSTERS_SYSTEM:
  859.             self.hpPercenttxt.Hide()
  860.         if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  861.             self.hpDecimal.Hide()
  862.  
  863.         self.SetSize(250, 40)
  864.  
  865.     def SetTargetVID(self, vid):
  866.         self.vid = vid
  867.         if app.ENABLE_SEND_TARGET_INFO:
  868.             self.vnum = 0
  869.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  870.             self.OpenTargetAffectIconContainer(vid)
  871.  
  872.     def SetEnemyVID(self, vid):
  873.         self.SetTargetVID(vid)
  874.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  875.             self.OpenTargetAffectIconContainer(vid)
  876.  
  877.         name = chr.GetNameByVID(vid)
  878.         if app.ENABLE_SEND_TARGET_INFO:
  879.             vnum = nonplayer.GetRaceNumByVID(vid)
  880.         level = nonplayer.GetLevelByVID(vid)
  881.         grade = nonplayer.GetGradeByVID(vid)
  882.  
  883.         nameFront = ""
  884.         if -1 != level:
  885.             nameFront += "Lv." + str(level) + " "
  886.         if self.GRADE_NAME.has_key(grade):
  887.             nameFront += "(" + self.GRADE_NAME[grade] + ") "
  888.  
  889.         self.SetTargetName(nameFront + name)
  890.  
  891.         if app.ENABLE_ELEMENT_ADD:
  892.             self.__HideAllElementImg()
  893.             self.ShowElementImg(nonplayer.GetElementEnchantsByVID(vid))
  894.  
  895.         if app.ENABLE_ACCUMULATE_DAMAGE_DISPLAY:
  896.             accumulate_count = playerm2g2.GetAccumulateDamageByVID(vid)
  897.             if accumulate_count:
  898.                 self.damage_display.SetText( localeInfo.TARGET_TOOLTIP_ATTACK_COUNT % accumulate_count )
  899.                 self.damage_display.Show()
  900.             else:
  901.                 self.damage_display.Hide()
  902.  
  903.         if app.ENABLE_SEND_TARGET_INFO:
  904.             (textWidth, textHeight) = self.name.GetTextSize()
  905.             if localeInfo.IsARABIC():
  906.                 self.infoButton.SetPosition(textWidth + 45, 12)
  907.                 self.infoButton.SetWindowHorizontalAlignRight()
  908.             else:
  909.                 self.infoButton.SetPosition(textWidth + 25, 12)
  910.                 self.infoButton.SetWindowHorizontalAlignLeft()
  911.  
  912.             self.vnum = vnum
  913.             self.infoButton.Show()
  914.  
  915.     def GetTargetVID(self):
  916.         return self.vid
  917.  
  918.     def GetTargetName(self):
  919.         return self.nameString
  920.  
  921.     def SetTargetName(self, name):
  922.         self.nameString = name
  923.         self.nameLength = len(name)
  924.  
  925.         if app.ENABLE_AUTO_SYSTEM:
  926.             if item.CheckAffect(chr.NEW_AFFECT_AUTO,0):
  927.                 self.name.SetText("[Auto]" + name)
  928.             else:
  929.                 self.name.SetText(name)
  930.         else:
  931.             self.name.SetText(name)
  932.  
  933.     if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  934.         def SetHP(self, IsPC, hpPercentage, curHP, maxHP):
  935.             if app.ENABLE_SEND_TARGET_INFO and IsPC == True:
  936.                 self.infoButton.Hide()
  937.                 self.infoButton.showWnd.Close()
  938.  
  939.             if not self.hpGauge.IsShow():
  940.                 if IsPC == False:
  941.                     self.SetSize(200 + 7 * self.nameLength, self.GetHeight())
  942.  
  943.                 if localeInfo.IsARABIC():
  944.                     self.name.SetPosition( self.GetWidth()-23, 13)
  945.                 else:
  946.                     self.name.SetPosition(23, 13)
  947.                 if IsPC == False:
  948.                     self.name.SetWindowHorizontalAlignLeft()
  949.                     self.name.SetHorizontalAlignLeft()
  950.                     self.hpGauge.Show()
  951.                 self.UpdatePosition()
  952.  
  953.             self.hpGauge.SetPercentage(hpPercentage, 100)
  954.             if app.ENABLE_POISON_GAUGE_EFFECT:
  955.                 self.hpPoisonGauge.SetPercentage(hpPercentage, 100)
  956.             if constInfo.PAST_HEALTH_ON_TARGET:
  957.                 self.oldPercentage = float(self.newPercentage)
  958.                 self.newPercentage = float(hpPercentage)
  959.                 self.hpGauge.SetPercentageBack(self.oldPercentage, 100)
  960.             iMinHPText = '.'.join([i - 3 < 0 and str(curHP)[:i] or str(curHP)[i-3:i] for i in range(len(str(curHP)) % 3, len(str(curHP))+1, 3) if i])
  961.             iMaxHPText = '.'.join([i - 3 < 0 and str(maxHP)[:i] or str(maxHP)[i-3:i] for i in range(len(str(maxHP)) % 3, len(str(maxHP))+1, 3) if i])
  962.             self.hpDecimal.SetText(str(iMinHPText) + "/" + str(iMaxHPText))
  963.             (textWidth, textHeight)=self.hpDecimal.GetTextSize()
  964.  
  965.             if localeInfo.IsARABIC():
  966.                 self.hpDecimal.SetPosition(120 / 2 + textWidth / 2, -17) #edit arabic
  967.             else:
  968.                 self.hpDecimal.SetPosition(130 / 2 - textWidth / 2, -13)
  969.             self.hpDecimal.Show()
  970.     else:
  971.         def SetHP(self, hpPercentage):
  972.             if not self.hpGauge.IsShow():
  973.                 self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  974.  
  975.                 self.name.SetPosition(23, 13)
  976.  
  977.                 self.name.SetWindowHorizontalAlignLeft()
  978.                 self.name.SetHorizontalAlignLeft()
  979.                 self.hpGauge.Show()
  980.                 self.UpdatePosition()
  981.             if constInfo.SHOW_HP_MONSTERS_SYSTEM:
  982.                 self.hpPercenttxt.SetPosition(200 + 7*self.nameLength-205, 13) #hier_anpassen_%anzeige
  983.                 self.hpPercenttxt.Show()
  984.                 self.hpPercenttxt.SetText("%d%%" % (hpPercentage))
  985.  
  986.             self.hpGauge.SetPercentage(hpPercentage, 100)
  987.             if app.ENABLE_POISON_GAUGE_EFFECT:
  988.                 self.hpPoisonGauge.SetPercentage(hpPercentage, 100)
  989.             if constInfo.PAST_HEALTH_ON_TARGET:
  990.                 self.oldPercentage = float(self.newPercentage)
  991.                 self.newPercentage = float(hpPercentage)
  992.                 self.hpGauge.SetPercentageBack(self.oldPercentage, 100)
  993.  
  994.     def ShowDefaultButton(self):
  995.         self.isShowButton = True
  996.         self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER])
  997.         self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
  998.         self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT])
  999.         self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW])
  1000.         if app.ENABLE_VIEW_EQUIP_RENEWAL:
  1001.             if chr.IsGameMaster(playerm2g2.GetMainCharacterIndex()):
  1002.                 self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT])
  1003.         for button in self.showingButtonList:
  1004.             button.Show()
  1005.  
  1006.     def HideButtonSystems(self):
  1007.         if app.ENABLE_SEND_TARGET_INFO:
  1008.             self.infoButton.Hide()
  1009.             self.infoButton.showWnd.Close()
  1010.  
  1011.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  1012.             self.HideTargetAffectIconContainer(self.vid)
  1013.  
  1014.     def HideAllButton(self):
  1015.         self.isShowButton = False
  1016.         for button in self.showingButtonList:
  1017.             button.Hide()
  1018.         self.showingButtonList = []
  1019.  
  1020.     def __ShowButton(self, name):
  1021.  
  1022.         if not self.buttonDict.has_key(name):
  1023.             return
  1024.  
  1025.         if app.ENABLE_PREMIUM_PRIVATE_SHOP:
  1026.             if name == "VOTE_BLOCK_CHAT":
  1027.                 return
  1028.  
  1029.         self.buttonDict[name].Show()
  1030.         self.showingButtonList.append(self.buttonDict[name])
  1031.  
  1032.     def __HideButton(self, name):
  1033.  
  1034.         if not self.buttonDict.has_key(name):
  1035.             return
  1036.  
  1037.         button = self.buttonDict[name]
  1038.         button.Hide()
  1039.  
  1040.         for btnInList in self.showingButtonList:
  1041.             if btnInList == button:
  1042.                 self.showingButtonList.remove(button)
  1043.                 break
  1044.  
  1045.     def OnWhisper(self):
  1046.         if None != self.eventWhisper:
  1047.             self.eventWhisper(self.nameString)
  1048.  
  1049.     def OnExchange(self):
  1050.         m2netm2g.SendExchangeStartPacket(self.vid)
  1051.  
  1052.     def OnPVP(self):
  1053.         m2netm2g.SendChatPacket("/pvp %d" % (self.vid))
  1054.  
  1055.     def OnAppendToMessenger(self):
  1056.         m2netm2g.SendMessengerAddByVIDPacket(self.vid)
  1057.  
  1058.     def OnPartyInvite(self):
  1059.         m2netm2g.SendPartyInvitePacket(self.vid)
  1060.  
  1061.     def OnPartyExit(self):
  1062.         m2netm2g.SendPartyExitPacket()
  1063.  
  1064.     def OnPartyRemove(self):
  1065.         pid = playerm2g2.PartyMemberVIDToPID(self.vid)
  1066.         if pid:
  1067.             m2netm2g.SendPartyRemovePacket(pid)
  1068.  
  1069.     def __OnGuildAddMember(self):
  1070.         m2netm2g.SendGuildAddMemberPacket(self.vid)
  1071.  
  1072.     def __OnDismount(self):
  1073.         m2netm2g.SendChatPacket("/unmount")
  1074.  
  1075.     def __OnExitObserver(self):
  1076.         m2netm2g.SendChatPacket("/observer_exit")
  1077.  
  1078.     def __OnViewEquipment(self):
  1079.         if app.ENABLE_VIEW_EQUIP_RENEWAL:
  1080.             if not chr.IsGameMaster(playerm2g2.GetMainCharacterIndex()):
  1081.                 return
  1082.  
  1083.         m2netm2g.SendChatPacket("/view_equip " + str(self.vid))
  1084.  
  1085.     def __OnRequestParty(self):
  1086.         m2netm2g.SendChatPacket("/party_request " + str(self.vid))
  1087.  
  1088.     def __OnDestroyBuilding(self):
  1089.         m2netm2g.SendChatPacket("/build d %d" % (self.vid))
  1090.  
  1091.     def __OnEmotionAllow(self):
  1092.         m2netm2g.SendChatPacket("/emotion_allow %d" % (self.vid))
  1093.  
  1094.     def __OnVoteBlockChat(self):
  1095.         cmd = "/vote_block_chat %s" % (self.nameString)
  1096.         m2netm2g.SendChatPacket(cmd)
  1097.  
  1098.     def OnPressEscapeKey(self):
  1099.         self.OnPressedCloseButton()
  1100.         return True
  1101.  
  1102.     def IsShowButton(self):
  1103.         return self.isShowButton
  1104.  
  1105.     def RefreshButton(self):
  1106.         self.HideAllButton()
  1107.  
  1108.         if app.ENABLE_12ZI:
  1109.             if chrmgrm2g.IsDead(self.vid):
  1110.                 if background.IsReviveTargetMap():
  1111.                     self.__ShowButton(localeInfo.TARGET_BUTTON_REVIVE)
  1112.                     self.__ArrangeButtonPosition()
  1113.                 return
  1114.  
  1115.         if chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  1116.             #self.__ShowButton(localeInfo.TARGET_BUTTON_BUILDING_DESTROY)
  1117.             #self.__ArrangeButtonPosition()
  1118.             return
  1119.  
  1120.         if playerm2g2.IsPVPInstance(self.vid) or playerm2g2.IsObserverMode():
  1121.             # PVP_INFO_SIZE_BUG_FIX
  1122.             self.SetSize(200 + 7*self.nameLength, 40)
  1123.             self.UpdatePosition()
  1124.             # END_OF_PVP_INFO_SIZE_BUG_FIX
  1125.             return
  1126.  
  1127.         self.ShowDefaultButton()
  1128.  
  1129.         if guild.MainPlayerHasAuthority(guild.AUTH_ADD_MEMBER):
  1130.             if not guild.IsMemberByName(self.nameString):
  1131.                 if 0 == chr.GetGuildID(self.vid):
  1132.                     self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_GUILD)
  1133.  
  1134.         if not messenger.IsFriendByName(self.nameString):
  1135.             self.__ShowButton(localeInfo.TARGET_BUTTON_FRIEND)
  1136.  
  1137.         if app.ENABLE_MESSENGER_BLOCK:
  1138.             if not messenger.IsBlockFriendByName(self.nameString):
  1139.                 self.__ShowButton(localeInfo.TARGET_BUTTON_BLOCK)
  1140.             else:
  1141.                 self.__ShowButton(localeInfo.TARGET_BUTTON_BLOCK_REMOVE)
  1142.  
  1143.         if playerm2g2.IsPartyMember(self.vid):
  1144.             self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  1145.  
  1146.             if playerm2g2.IsPartyLeader(self.vid):
  1147.                 self.__ShowButton(localeInfo.TARGET_BUTTON_LEAVE_PARTY)
  1148.             elif playerm2g2.IsPartyLeader(playerm2g2.GetMainCharacterIndex()):
  1149.                 self.__ShowButton(localeInfo.TARGET_BUTTON_EXCLUDE)
  1150.         else:
  1151.             if playerm2g2.IsPartyMember(playerm2g2.GetMainCharacterIndex()):
  1152.                 if playerm2g2.IsPartyLeader(playerm2g2.GetMainCharacterIndex()):
  1153.                     self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  1154.             else:
  1155.                 if chr.IsPartyMember(self.vid):
  1156.                     self.__ShowButton(localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY)
  1157.                 else:
  1158.                     self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  1159.  
  1160.             if playerm2g2.IsRevengeInstance(self.vid):
  1161.                 self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  1162.                 self.__ShowButton(localeInfo.TARGET_BUTTON_AVENGE)
  1163.             elif playerm2g2.IsChallengeInstance(self.vid):
  1164.                 self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  1165.                 self.__ShowButton(localeInfo.TARGET_BUTTON_ACCEPT_FIGHT)
  1166.             elif playerm2g2.IsCantFightInstance(self.vid):
  1167.                 self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  1168.  
  1169.             if not playerm2g2.IsSameEmpire(self.vid):
  1170.                 self.__HideButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  1171.                 self.__HideButton(localeInfo.TARGET_BUTTON_FRIEND)
  1172.                 self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  1173.  
  1174.         distance = playerm2g2.GetCharacterDistance(self.vid)
  1175.         if distance > self.EXCHANGE_LIMIT_RANGE:
  1176.             self.__HideButton(localeInfo.TARGET_BUTTON_EXCHANGE)
  1177.             self.__ArrangeButtonPosition()
  1178.  
  1179.         self.__ArrangeButtonPosition()
  1180.  
  1181.     def __ArrangeButtonPosition(self):
  1182.         showingButtonCount = len(self.showingButtonList)
  1183.  
  1184.         pos = -(showingButtonCount / 2) * 68
  1185.         if 0 == showingButtonCount % 2:
  1186.             pos += 34
  1187.  
  1188.         for button in self.showingButtonList:
  1189.             button.SetPosition(pos, 33)
  1190.             pos += 68
  1191.  
  1192.         self.SetSize(max(150, showingButtonCount * 75), 65)
  1193.         self.UpdatePosition()
  1194.         if app.ENABLE_ELEMENT_ADD:
  1195.             self.AdjustPositionElementImage()
  1196.  
  1197.     def OnUpdate(self):
  1198.         if app.ENABLE_POISON_GAUGE_EFFECT:
  1199.             if self.hpGauge and self.hpGauge.IsShow():
  1200.                 if chrmgrm2g.HasAffectByVID(self.GetTargetVID(), chr.AFFECT_POISON):
  1201.                     self.hpPoisonGauge.Show()
  1202.                 else:
  1203.                     self.hpPoisonGauge.Hide()
  1204.  
  1205.         if playerm2g2.IsMainCharacterIndex(self.vid):
  1206.             self.__ShowMainCharacterMenu()
  1207.  
  1208.         if app.ENABLE_TARGET_AFFECT_SHOWER:
  1209.             self.UpdateTargetAffectIconContainerPosition(self.vid)
  1210.  
  1211.         if self.isShowButton:
  1212.  
  1213.             exchangeButton = self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE]
  1214.             distance = playerm2g2.GetCharacterDistance(self.vid)
  1215.  
  1216.             if distance < 0:
  1217.                 if app.WJ_NEW_USER_CARE:
  1218.                     playerm2g2.ClearTarget()
  1219.                     self.Close()
  1220.                 return
  1221.  
  1222.             if exchangeButton.IsShow():
  1223.                 if distance > self.EXCHANGE_LIMIT_RANGE:
  1224.                     self.RefreshButton()
  1225.  
  1226.             else:
  1227.                 if distance < self.EXCHANGE_LIMIT_RANGE:
  1228.                     self.RefreshButton()
  1229.  
  1230.     if app.ENABLE_MESSENGER_BLOCK:
  1231.         def __OnBlock(self):
  1232.             m2netm2g.SendMessengerBlockAddByVIDPacket(self.vid)
  1233.  
  1234.         def __OnBlockRemove(self):
  1235.             self.questionDialog = uiCommon.QuestionDialog()
  1236.             self.questionDialog.SetText(localeInfo.MESSENGER_DO_YOU_DELETE)
  1237.             self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnBlockRemove))
  1238.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnBlockRemoveClose))
  1239.             self.questionDialog.Open()
  1240.  
  1241.         def OnBlockRemove(self):
  1242.             m2netm2g.SendMessengerBlockRemoveByVIDPacket(self.vid)
  1243.             self.OnBlockRemoveClose()
  1244.  
  1245.         def OnBlockRemoveClose(self):
  1246.             self.questionDialog.Close()
  1247.             self.questionDialog = None
  1248.             return True
  1249.  
  1250.     if app.ENABLE_ELEMENT_ADD:
  1251.         def __HideAllElementImg(self):
  1252.             for elementImg in self.elementImgDict.values():
  1253.                 elementImg.Hide()
  1254.  
  1255.         def AdjustPositionElementImage(self):
  1256.             xElementImgPos = 0
  1257.             for element in self.element_enchants_dict:
  1258.                 (element_value) = self.element_enchants_dict[element]
  1259.                 if element_value:
  1260.                     self.elementImgDict[element].SetPosition(0 + xElementImgPos, self.GetHeight())
  1261.                     self.elementImgDict[element].Show()
  1262.                     xElementImgPos += self.elementImgDict[element].GetWidth()
  1263.                 else:
  1264.                     self.elementImgDict[element].Hide()
  1265.  
  1266.         def ShowElementImg(self, element_enchants_dict):
  1267.             xElementImgPos = 0
  1268.             self.element_enchants_dict = element_enchants_dict
  1269.             for element in element_enchants_dict:
  1270.                 (element_value) = element_enchants_dict[element]
  1271.                 if element_value:
  1272.                     self.elementImgDict[element].SetPosition(0 + xElementImgPos, self.GetHeight())
  1273.                     self.elementImgDict[element].Show()
  1274.                     xElementImgPos += self.elementImgDict[element].GetWidth()
  1275.                 else:
  1276.                     self.elementImgDict[element].Hide()
  1277.  
  1278.     if app.ENABLE_ACCUMULATE_DAMAGE_DISPLAY:
  1279.         def RefreshAccumulateCount(self, vid):
  1280.             accumulate_count = playerm2g2.GetAccumulateDamageByVID(vid)
  1281.             if accumulate_count:
  1282.                 self.damage_display.SetText( localeInfo.TARGET_TOOLTIP_ATTACK_COUNT % accumulate_count )
  1283.                 self.damage_display.Show()
  1284.             else:
  1285.                 self.damage_display.Hide()
  1286.  
  1287.     if app.ENABLE_12ZI:
  1288.         def __OnReviveQustionDialog(self):
  1289.             m2netm2g.SendChatPacket("/revivedialog %d" % (self.vid))
  1290.  
  1291.         def OpenReviveDialog(self, vid, itemcount):
  1292.             self.questionDialog = uiCommon.QuestionDialog()
  1293.             if playerm2g2.IsMainCharacterIndex(vid):
  1294.                 self.questionDialog.SetText(localeInfo.REVIVE_SELF_QUESTION % (itemcount))
  1295.             else:
  1296.                 self.questionDialog.SetText(localeInfo.REVIVE_QUESTION % (chr.GetNameByVID(vid), itemcount))
  1297.  
  1298.             self.questionDialog.SetAcceptEvent(lambda arg=vid: self.OnRivive(arg))
  1299.             self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnQuestionDialogClose))
  1300.             self.questionDialog.Open()
  1301.  
  1302.         def OnRivive(self, virId):
  1303.             m2netm2g.SendChatPacket("/revive %d" % (virId))
  1304.             self.OnQuestionDialogClose()
  1305.  
  1306.         def OnQuestionDialogClose(self):
  1307.             self.questionDialog.Close()
  1308.             self.questionDialog = None
  1309.             return True
  1310.  
  1311. if app.ENABLE_TARGET_AFFECT_SHOWER:
  1312.     class TargetAffectIconContainer(ui.Window):
  1313.         class TargetAffectIcon(ui.ExpandedImageBox):
  1314.             def __init__(self, affectNum, duration):
  1315.                 ui.ExpandedImageBox.__init__(self)
  1316.  
  1317.                 self.affectNum = affectNum
  1318.                 self.duration = duration
  1319.                 self.lastUpdateTime = app.GetGlobalTime()
  1320.  
  1321.                 self.AFFECT_DATA_DICT = {
  1322.                     chr.AFFECT_POISON : (localeInfo.SKILL_TOXICDIE, "d:/ymir work/ui/skill/common/affect/poison.sub"),
  1323.                     chr.AFFECT_BLEEDING : (localeInfo.SKILL_BLEEDING, "d:/ymir work/ui/skill/common/affect/poison.sub"),
  1324.                     chr.AFFECT_SLOW : (localeInfo.SKILL_SLOW, "d:/ymir work/ui/skill/common/affect/slow.sub"),
  1325.                     chr.AFFECT_STUN : (localeInfo.SKILL_STUN, "d:/ymir work/ui/skill/common/affect/stun.sub"),
  1326.                     chr.AFFECT_FIRE : (localeInfo.SKILL_FIRE, "d:/ymir work/ui/skill/sura/hwayeom_03.sub",),
  1327.                 }
  1328.  
  1329.                 import uiToolTip
  1330.                 self.toolTip = uiToolTip.ToolTip(100)
  1331.                 self.toolTip.HideToolTip()
  1332.  
  1333.                 if self.AFFECT_DATA_DICT.has_key(affectNum):
  1334.                     self.affectName = self.AFFECT_DATA_DICT[affectNum][0]
  1335.  
  1336.                     image = self.AFFECT_DATA_DICT[affectNum][1]
  1337.                     self.LoadImage(image)
  1338.  
  1339.                     self.SetScale(0.9, 0.9)
  1340.  
  1341.             def __del__(self):
  1342.                 ui.ExpandedImageBox.__del__(self)
  1343.  
  1344.             def GetAffectNum(self):
  1345.                 return self.affectNum
  1346.  
  1347.             def SetDuration(self, duration):
  1348.                 self.duration = duration
  1349.                 self.lastUpdateTime = app.GetGlobalTime()
  1350.                 self.RefreshToolTip()
  1351.  
  1352.             def GetDuration(self):
  1353.                 return self.duration
  1354.  
  1355.             def RefreshToolTip(self):
  1356.                 if self.toolTip.IsShow():
  1357.                     self.toolTip.ClearToolTip()
  1358.                     self.toolTip.SetTitle(self.affectName)
  1359.                     self.toolTip.AppendTextLine(localeInfo.TOOLTIP_SKILL_DURATION % self.duration)
  1360.                     self.toolTip.ResizeToolTip()
  1361.  
  1362.             def OnMouseOverIn(self):
  1363.                 self.toolTip.ShowToolTip()
  1364.                 self.RefreshToolTip()
  1365.  
  1366.             def OnMouseOverOut(self):
  1367.                 self.toolTip.HideToolTip()
  1368.  
  1369.             def HideToolTip(self):
  1370.                 self.toolTip.HideToolTip()
  1371.  
  1372.             def GetLastUpdatTime(self):
  1373.                 return self.lastUpdateTime
  1374.  
  1375.         def __init__(self):
  1376.             ui.Window.__init__(self)
  1377.             self.affectIcons = {}
  1378.  
  1379.         def __del__(self):
  1380.             ui.Window.__del__(self)
  1381.  
  1382.         def SetAffect(self, affectNum, duration):
  1383.             if self.affectIcons.has_key(affectNum):
  1384.                 if duration > 0:
  1385.                     self.UpdateAffect(affectNum, duration)
  1386.                 else:
  1387.                     self.RemoveAffect(affectNum)
  1388.             elif duration > 0:
  1389.                 self.AddAffect(affectNum, duration)
  1390.  
  1391.         def AddAffect(self, affectNum, duration):
  1392.             affectIcon = self.affectIcons.get(affectNum)
  1393.             if not affectIcon:
  1394.                 affectIcon = self.TargetAffectIcon(affectNum, duration)
  1395.                 affectIcon.SetParent(self)
  1396.                 affectIcon.Show()
  1397.                 self.affectIcons[affectNum] = affectIcon
  1398.                 self.AdjustSize()
  1399.  
  1400.         def RemoveAffect(self, affectNum):
  1401.             if self.affectIcons.has_key(affectNum):
  1402.                 del self.affectIcons[affectNum]
  1403.  
  1404.             self.AdjustSize()
  1405.  
  1406.         def UpdateAffect(self, affectNum, duration):
  1407.             affectIcon = self.affectIcons.get(affectNum)
  1408.             if affectIcon:
  1409.                 affectIcon.SetDuration(duration)
  1410.  
  1411.         def AdjustSize(self):
  1412.             i = 0
  1413.             space = 3
  1414.             for affectNum in self.affectIcons.keys():
  1415.                 affectIcon = self.affectIcons.get(affectNum)
  1416.                 if affectIcon:
  1417.                     affectIcon.SetPosition((32 * 0.7 + space) * i, 0)
  1418.                     i += 1
  1419.  
  1420.             self.SetSize((32 * 0.7 + space) * (i+1), 32 * 0.7)
  1421.  
  1422.         def HasActiveAffects(self):
  1423.             return any(self.affectIcons)
  1424.  
  1425.         def OnUpdate(self):
  1426.             for affectNum in self.affectIcons.keys():
  1427.                 affectIcon = self.affectIcons.get(affectNum)
  1428.                 if not affectIcon:
  1429.                     continue
  1430.  
  1431.                 timeDif = (app.GetGlobalTime() - affectIcon.GetLastUpdatTime()) / 1000
  1432.                 if timeDif < 1:
  1433.                     continue
  1434.  
  1435.                 restDuration = affectIcon.GetDuration() - timeDif
  1436.                 if restDuration > 0:
  1437.                     affectIcon.SetDuration(restDuration)
  1438.                 else:
  1439.                     self.RemoveAffect(affectNum)
  1440.  
  1441. if app.ENABLE_DEFENSE_WAVE:
  1442.     class AllianceTargetBoard(ui.ThinBoard):
  1443.         class TextToolTip(ui.Window):
  1444.             def __init__(self):
  1445.                 ui.Window.__init__(self, "TOP_MOST")
  1446.  
  1447.                 textLine = ui.TextLine()
  1448.                 textLine.SetParent(self)
  1449.                 textLine.SetHorizontalAlignCenter()
  1450.                 textLine.SetOutline()
  1451.                 textLine.Show()
  1452.                 self.textLine = textLine
  1453.  
  1454.             def __del__(self):
  1455.                 ui.Window.__del__(self)
  1456.  
  1457.             def SetText(self, text):
  1458.                 self.textLine.SetText(text)
  1459.  
  1460.             def OnRender(self):
  1461.                 (mouseX, mouseY) = wndMgr.GetMousePosition()
  1462.                 self.textLine.SetPosition(mouseX, mouseY + 30)
  1463.  
  1464.         def __init__(self):
  1465.             ui.ThinBoard.__init__(self)
  1466.  
  1467.             name = ui.TextLine()
  1468.             name.SetParent(self)
  1469.             name.SetDefaultFontName()
  1470.             name.SetOutline()
  1471.             name.Show()
  1472.  
  1473.             hpGauge = ui.Gauge()
  1474.             hpGauge.SetParent(self)
  1475.             hpGauge.MakeGauge(80, "red")
  1476.             hpGauge.SetPosition(10, 25)
  1477.             hpGauge.SetOverEvent(ui.__mem_func__(self.IsIn))
  1478.             hpGauge.SetOverOutEvent(ui.__mem_func__(self.IsOut))
  1479.             hpGauge.Hide()
  1480.  
  1481.             self.name = name
  1482.             self.hpGauge = hpGauge
  1483.             if app.ENABLE_POISON_GAUGE_EFFECT:
  1484.                 self.hpPoisonGauge = hpPoisonGauge
  1485.  
  1486.             self.toolTipHP = self.TextToolTip()
  1487.             self.toolTipHP.Hide()
  1488.  
  1489.             self.Initialize()
  1490.             self.ResetTargetBoard()
  1491.  
  1492.         def __del__(self):
  1493.             ui.ThinBoard.__del__(self)
  1494.  
  1495.         def Initialize(self):
  1496.             self.nameLength = 0
  1497.             self.vid = 0
  1498.  
  1499.         def Destroy(self):
  1500.             self.name = None
  1501.             self.hpGauge = None
  1502.             if app.ENABLE_POISON_GAUGE_EFFECT:
  1503.                 self.hpPoisonGauge = None
  1504.             self.tooltipHP = None
  1505.  
  1506.             self.Initialize()
  1507.  
  1508.         def Close(self):
  1509.             self.Initialize()
  1510.             self.tooltipHP.Hide()
  1511.             self.Hide()
  1512.  
  1513.         def ResetTargetBoard(self):
  1514.             self.Initialize()
  1515.  
  1516.             self.name.SetPosition(0, 13)
  1517.             self.name.SetHorizontalAlignCenter()
  1518.             self.name.SetWindowHorizontalAlignCenter()
  1519.  
  1520.             self.hpGauge.Hide()
  1521.             if app.ENABLE_POISON_GAUGE_EFFECT:
  1522.                 self.hpPoisonGauge.Hide()
  1523.             self.SetSize(100, 40)
  1524.  
  1525.         def SetTargetVID(self, vid):
  1526.             self.vid = vid
  1527.  
  1528.         def SetTarget(self, vid):
  1529.             self.SetTargetVID(vid)
  1530.  
  1531.             name = chr.GetNameByVID(vid)
  1532.             self.SetTargetName(name)
  1533.  
  1534.         def GetTargetVID(self):
  1535.             return self.vid
  1536.  
  1537.         def SetTargetName(self, name):
  1538.             self.nameLength = len(name)
  1539.             self.name.SetText(name)
  1540.  
  1541.         def SetHP(self, hp, hpMax):
  1542.             hp = min(hp, hpMax)
  1543.             if hp > 0:
  1544.                 self.SetSize(100, self.GetHeight())
  1545.  
  1546.                 if localeInfo.IsARABIC():
  1547.                     self.name.SetPosition(self.GetWidth() - 10, 10)
  1548.                 else:
  1549.                     self.name.SetPosition(10, 10)
  1550.  
  1551.                 self.name.SetWindowHorizontalAlignLeft()
  1552.                 self.name.SetHorizontalAlignLeft()
  1553.                 self.hpGauge.Show()
  1554.                 self.UpdatePosition()
  1555.  
  1556.             self.hpGauge.SetPercentage(hp, hpMax)
  1557.             self.toolTipHP.SetText("%s : %d / %d" % (localeInfo.TASKBAR_HP, hp, hpMax))
  1558.  
  1559.         def UpdatePosition(self):
  1560.             # NOTE : y = miniMap + serverInfo Height
  1561.             self.SetPosition(wndMgr.GetScreenWidth() - self.GetWidth() - 18, 250)
  1562.  
  1563.         def IsOut(self):
  1564.             if self.toolTipHP:
  1565.                 self.toolTipHP.Hide()
  1566.  
  1567.         def IsIn(self):
  1568.             if self.toolTipHP:
  1569.                 self.toolTipHP.Show()
  1570.  
  1571.         # NOTE : Unused.
  1572.         def SetMouseEvent(self):
  1573.             pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement