Advertisement
Guest User

uitarget.py

a guest
Nov 3rd, 2022
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.43 KB | None | 0 0
  1. import app
  2. import ui
  3. import player
  4. import net
  5. import wndMgr
  6. import messenger
  7. import guild
  8. import chr
  9. import nonplayer
  10. import localeInfo
  11. import constInfo
  12. import interfaceModule
  13. import uiToolTip
  14. import item
  15.  
  16. if app.ENABLE_SEND_TARGET_INFO:
  17. def HAS_FLAG(value, flag):
  18. return (value & flag) == flag
  19.  
  20. class TargetBoard(ui.ThinBoard):
  21. if app.ENABLE_SEND_TARGET_INFO:
  22. class InfoBoard(ui.ThinBoard):
  23. class ItemListBoxItem(ui.ListBoxExNew.Item):
  24. def __init__(self, width):
  25. ui.ListBoxExNew.Item.__init__(self)
  26.  
  27. image = ui.ExpandedImageBox()
  28. image.SetParent(self)
  29. image.Show()
  30. self.image = image
  31.  
  32. nameLine = ui.TextLine()
  33. nameLine.SetParent(self)
  34. nameLine.SetPosition(32 + 5, 0)
  35. nameLine.Show()
  36. self.nameLine = nameLine
  37.  
  38. self.SetSize(width, 32 + 5)
  39.  
  40. def LoadImage(self, image, name = None):
  41. self.image.LoadImage(image)
  42. self.SetSize(self.GetWidth(), self.image.GetHeight() + 5 * (self.image.GetHeight() / 32))
  43. if name != None:
  44. self.SetText(name)
  45.  
  46. def SetText(self, text):
  47. self.nameLine.SetText(text)
  48.  
  49. def RefreshHeight(self):
  50. ui.ListBoxExNew.Item.RefreshHeight(self)
  51. self.image.SetRenderingRect(0.0, 0.0 - float(self.removeTop) / float(self.GetHeight()), 0.0, 0.0 - float(self.removeBottom) / float(self.GetHeight()))
  52. self.image.SetPosition(0, - self.removeTop)
  53.  
  54. MAX_ITEM_COUNT = 5
  55.  
  56. EXP_BASE_LVDELTA = [
  57. 1, # -15 0
  58. 5, # -14 1
  59. 10, # -13 2
  60. 20, # -12 3
  61. 30, # -11 4
  62. 50, # -10 5
  63. 70, # -9 6
  64. 80, # -8 7
  65. 85, # -7 8
  66. 90, # -6 9
  67. 92, # -5 10
  68. 94, # -4 11
  69. 96, # -3 12
  70. 98, # -2 13
  71. 100, # -1 14
  72. 100, # 0 15
  73. 105, # 1 16
  74. 110, # 2 17
  75. 115, # 3 18
  76. 120, # 4 19
  77. 125, # 5 20
  78. 130, # 6 21
  79. 135, # 7 22
  80. 140, # 8 23
  81. 145, # 9 24
  82. 150, # 10 25
  83. 155, # 11 26
  84. 160, # 12 27
  85. 165, # 13 28
  86. 170, # 14 29
  87. 180, # 15 30
  88. ]
  89.  
  90. RACE_FLAG_TO_NAME = {
  91. 1 << 0 : localeInfo.TARGET_INFO_RACE_ANIMAL,
  92. 1 << 1 : localeInfo.TARGET_INFO_RACE_UNDEAD,
  93. 1 << 2 : localeInfo.TARGET_INFO_RACE_DEVIL,
  94. 1 << 3 : localeInfo.TARGET_INFO_RACE_HUMAN,
  95. 1 << 4 : localeInfo.TARGET_INFO_RACE_ORC,
  96. 1 << 5 : localeInfo.TARGET_INFO_RACE_MILGYO,
  97. }
  98.  
  99. SUB_RACE_FLAG_TO_NAME = {
  100. 1 << 11 : localeInfo.TARGET_INFO_RACE_ELEC,
  101. 1 << 12 : localeInfo.TARGET_INFO_RACE_FIRE,
  102. 1 << 13 : localeInfo.TARGET_INFO_RACE_ICE,
  103. 1 << 14 : localeInfo.TARGET_INFO_RACE_WIND,
  104. 1 << 15 : localeInfo.TARGET_INFO_RACE_EARTH,
  105. 1 << 16 : localeInfo.TARGET_INFO_RACE_DARK,
  106. }
  107.  
  108. STONE_START_VNUM = 28030
  109. STONE_LAST_VNUM = 28042
  110.  
  111. BOARD_WIDTH = 250
  112.  
  113. def __init__(self):
  114. ui.ThinBoard.__init__(self)
  115.  
  116. self.HideCorners(self.LT)
  117. self.HideCorners(self.RT)
  118. self.HideLine(self.T)
  119.  
  120. self.race = 0
  121. self.hasItems = False
  122.  
  123. self.itemTooltip = uiToolTip.ItemToolTip()
  124. self.itemTooltip.HideToolTip()
  125.  
  126. self.stoneImg = None
  127. self.stoneVnum = None
  128. self.lastStoneVnum = 0
  129. self.nextStoneIconChange = 0
  130.  
  131. self.SetSize(self.BOARD_WIDTH, 0)
  132.  
  133. def __del__(self):
  134. ui.ThinBoard.__del__(self)
  135.  
  136. def __UpdatePosition(self, targetBoard):
  137. self.SetPosition(targetBoard.GetLeft() + (targetBoard.GetWidth() - self.GetWidth()) / 2, targetBoard.GetBottom() - 17)
  138.  
  139. def Open(self, targetBoard, race):
  140. self.__LoadInformation(race)
  141.  
  142. self.SetSize(self.BOARD_WIDTH, self.yPos + 10)
  143. self.__UpdatePosition(targetBoard)
  144.  
  145. self.Show()
  146.  
  147. def Refresh(self):
  148. self.__LoadInformation(self.race)
  149. self.SetSize(self.BOARD_WIDTH, self.yPos + 10)
  150.  
  151. def Close(self):
  152. self.itemTooltip.HideToolTip()
  153. self.Hide()
  154.  
  155. def __LoadInformation(self, race):
  156. self.yPos = 7
  157. self.children = []
  158. self.race = race
  159. self.stoneImg = None
  160. self.stoneVnum = None
  161. self.nextStoneIconChange = 0
  162.  
  163. self.__LoadInformation_Default(race)
  164. self.__LoadInformation_Race(race)
  165. self.__LoadInformation_Drops(race)
  166.  
  167. def __LoadInformation_Default_GetHitRate(self, race):
  168. attacker_dx = nonplayer.GetMonsterDX(race)
  169. attacker_level = nonplayer.GetMonsterLevel(race)
  170.  
  171. self_dx = player.GetStatus(player.DX)
  172. self_level = player.GetStatus(player.LEVEL)
  173.  
  174. iARSrc = min(90, (attacker_dx * 4 + attacker_level * 2) / 6)
  175. iERSrc = min(90, (self_dx * 4 + self_level * 2) / 6)
  176.  
  177. fAR = (float(iARSrc) + 210.0) / 300.0
  178. fER = (float(iERSrc) * 2 + 5) / (float(iERSrc) + 95) * 3.0 / 10.0
  179.  
  180. return fAR - fER
  181.  
  182. def __LoadInformation_Default(self, race):
  183. self.AppendSeperator()
  184. self.AppendTextLine(localeInfo.TARGET_INFO_MAX_HP % str(nonplayer.GetMonsterMaxHP(race)))
  185.  
  186. # calc att damage
  187. monsterLevel = nonplayer.GetMonsterLevel(race)
  188. fHitRate = self.__LoadInformation_Default_GetHitRate(race)
  189. iDamMin, iDamMax = nonplayer.GetMonsterDamage(race)
  190. iDamMin = int((iDamMin + nonplayer.GetMonsterST(race)) * 2 * fHitRate) + monsterLevel * 2
  191. iDamMax = int((iDamMax + nonplayer.GetMonsterST(race)) * 2 * fHitRate) + monsterLevel * 2
  192. iDef = player.GetStatus(player.DEF_GRADE) * (100 + player.GetStatus(player.DEF_BONUS)) / 100
  193. fDamMulti = nonplayer.GetMonsterDamageMultiply(race)
  194. iDamMin = int(max(0, iDamMin - iDef) * fDamMulti)
  195. iDamMax = int(max(0, iDamMax - iDef) * fDamMulti)
  196. if iDamMin < 1:
  197. iDamMin = 1
  198. if iDamMax < 5:
  199. iDamMax = 5
  200. self.AppendTextLine(localeInfo.TARGET_INFO_DAMAGE % (str(iDamMin), str(iDamMax)))
  201.  
  202. idx = min(len(self.EXP_BASE_LVDELTA) - 1, max(0, (monsterLevel + 15) - player.GetStatus(player.LEVEL)))
  203. iExp = nonplayer.GetMonsterExp(race) * self.EXP_BASE_LVDELTA[idx] / 100
  204. self.AppendTextLine(localeInfo.TARGET_INFO_EXP % str(iExp))
  205.  
  206. def __LoadInformation_Race(self, race):
  207. dwRaceFlag = nonplayer.GetMonsterRaceFlag(race)
  208. self.AppendSeperator()
  209.  
  210. mainrace = ""
  211. subrace = ""
  212. for i in xrange(17):
  213. curFlag = 1 << i
  214. if HAS_FLAG(dwRaceFlag, curFlag):
  215. if self.RACE_FLAG_TO_NAME.has_key(curFlag):
  216. mainrace += self.RACE_FLAG_TO_NAME[curFlag] + ", "
  217. elif self.SUB_RACE_FLAG_TO_NAME.has_key(curFlag):
  218. subrace += self.SUB_RACE_FLAG_TO_NAME[curFlag] + ", "
  219. if nonplayer.IsMonsterStone(race):
  220. mainrace += localeInfo.TARGET_INFO_RACE_METIN + ", "
  221. if mainrace == "":
  222. mainrace = localeInfo.TARGET_INFO_NO_RACE
  223. else:
  224. mainrace = mainrace[:-2]
  225. if subrace == "":
  226. subrace = localeInfo.TARGET_INFO_NO_RACE
  227. else:
  228. subrace = subrace[:-2]
  229.  
  230. self.AppendTextLine(localeInfo.TARGET_INFO_MAINRACE % mainrace)
  231. self.AppendTextLine(localeInfo.TARGET_INFO_SUBRACE % subrace)
  232.  
  233. def __LoadInformation_Drops(self, race):
  234. self.AppendSeperator()
  235.  
  236. if race in constInfo.MONSTER_INFO_DATA:
  237. if len(constInfo.MONSTER_INFO_DATA[race]["items"]) == 0:
  238. self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)
  239. else:
  240. itemListBox = ui.ListBoxExNew(32 + 5, self.MAX_ITEM_COUNT)
  241. itemListBox.SetSize(self.GetWidth() - 15 * 2 - ui.ScrollBar.SCROLLBAR_WIDTH, (32 + 5) * self.MAX_ITEM_COUNT)
  242. height = 0
  243. for curItem in constInfo.MONSTER_INFO_DATA[race]["items"]:
  244. if curItem.has_key("vnum_list"):
  245. height += self.AppendItem(itemListBox, curItem["vnum_list"], curItem["count"])
  246. else:
  247. height += self.AppendItem(itemListBox, curItem["vnum"], curItem["count"])
  248. if height < itemListBox.GetHeight():
  249. itemListBox.SetSize(itemListBox.GetWidth(), height)
  250. self.AppendWindow(itemListBox, 15)
  251. itemListBox.SetBasePos(0)
  252.  
  253. if len(constInfo.MONSTER_INFO_DATA[race]["items"]) > itemListBox.GetViewItemCount():
  254. itemScrollBar = ui.ScrollBar()
  255. itemScrollBar.SetParent(self)
  256. itemScrollBar.SetPosition(itemListBox.GetRight(), itemListBox.GetTop())
  257. itemScrollBar.SetScrollBarSize(32 * self.MAX_ITEM_COUNT + 5 * (self.MAX_ITEM_COUNT - 1))
  258. itemScrollBar.SetMiddleBarSize(float(self.MAX_ITEM_COUNT) / float(height / (32 + 5)))
  259. itemScrollBar.Show()
  260. itemListBox.SetScrollBar(itemScrollBar)
  261. else:
  262. self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)
  263.  
  264. def AppendTextLine(self, text):
  265. textLine = ui.TextLine()
  266. textLine.SetParent(self)
  267. textLine.SetWindowHorizontalAlignCenter()
  268. textLine.SetHorizontalAlignCenter()
  269. textLine.SetText(text)
  270. textLine.SetPosition(0, self.yPos)
  271. textLine.Show()
  272.  
  273. self.children.append(textLine)
  274. self.yPos += 17
  275.  
  276. def AppendSeperator(self):
  277. img = ui.ImageBox()
  278. img.LoadImage("d:/ymir work/ui/target/seperator.tga")
  279. self.AppendWindow(img)
  280. img.SetPosition(img.GetLeft(), img.GetTop() - 15)
  281. self.yPos -= 15
  282.  
  283. def AppendItem(self, listBox, vnums, count):
  284. if type(vnums) == int:
  285. vnum = vnums
  286. else:
  287. vnum = vnums[0]
  288.  
  289. item.SelectItem(vnum)
  290. itemName = item.GetItemName()
  291. if type(vnums) != int and len(vnums) > 1:
  292. vnums = sorted(vnums)
  293. realName = itemName[:itemName.find("+")]
  294. if item.GetItemType() == item.ITEM_TYPE_METIN:
  295. realName = localeInfo.TARGET_INFO_STONE_NAME
  296. itemName = realName + "+0 - +4"
  297. else:
  298. itemName = realName + "+" + str(vnums[0] % 10) + " - +" + str(vnums[len(vnums) - 1] % 10)
  299. vnum = vnums[len(vnums) - 1]
  300.  
  301. myItem = self.ItemListBoxItem(listBox.GetWidth())
  302. myItem.LoadImage(item.GetIconImageFileName())
  303. if count <= 1:
  304. myItem.SetText(itemName)
  305. else:
  306. myItem.SetText("%dx %s" % (count, itemName))
  307. myItem.SAFE_SetOverInEvent(self.OnShowItemTooltip, vnum)
  308. myItem.SAFE_SetOverOutEvent(self.OnHideItemTooltip)
  309. listBox.AppendItem(myItem)
  310.  
  311. if item.GetItemType() == item.ITEM_TYPE_METIN:
  312. self.stoneImg = myItem
  313. self.stoneVnum = vnums
  314. self.lastStoneVnum = self.STONE_LAST_VNUM + vnums[len(vnums) - 1] % 1000 / 100 * 100
  315.  
  316. return myItem.GetHeight()
  317.  
  318. def OnShowItemTooltip(self, vnum):
  319. item.SelectItem(vnum)
  320. if item.GetItemType() == item.ITEM_TYPE_METIN:
  321. self.itemTooltip.isStone = True
  322. self.itemTooltip.isBook = False
  323. self.itemTooltip.isBook2 = False
  324. self.itemTooltip.SetItemToolTip(self.lastStoneVnum)
  325. else:
  326. self.itemTooltip.isStone = False
  327. self.itemTooltip.isBook = True
  328. self.itemTooltip.isBook2 = True
  329. self.itemTooltip.SetItemToolTip(vnum)
  330.  
  331. def OnHideItemTooltip(self):
  332. self.itemTooltip.HideToolTip()
  333.  
  334. def AppendWindow(self, wnd, x = 0, width = 0, height = 0):
  335. if width == 0:
  336. width = wnd.GetWidth()
  337. if height == 0:
  338. height = wnd.GetHeight()
  339.  
  340. wnd.SetParent(self)
  341. if x == 0:
  342. wnd.SetPosition((self.GetWidth() - width) / 2, self.yPos)
  343. else:
  344. wnd.SetPosition(x, self.yPos)
  345. wnd.Show()
  346.  
  347. self.children.append(wnd)
  348. self.yPos += height + 5
  349.  
  350. def OnUpdate(self):
  351. if self.stoneImg != None and self.stoneVnum != None and app.GetTime() >= self.nextStoneIconChange:
  352. nextImg = self.lastStoneVnum + 1
  353. if nextImg % 100 > self.STONE_LAST_VNUM % 100:
  354. nextImg -= (self.STONE_LAST_VNUM - self.STONE_START_VNUM) + 1
  355. self.lastStoneVnum = nextImg
  356. self.nextStoneIconChange = app.GetTime() + 2.5
  357.  
  358. item.SelectItem(nextImg)
  359. itemName = item.GetItemName()
  360. realName = itemName[:itemName.find("+")]
  361. realName = realName + "+0 - +4"
  362. self.stoneImg.LoadImage(item.GetIconImageFileName(), realName)
  363.  
  364. if self.itemTooltip.IsShow() and self.itemTooltip.isStone:
  365. self.itemTooltip.SetItemToolTip(nextImg)
  366.  
  367. BUTTON_NAME_LIST = (
  368. localeInfo.TARGET_BUTTON_WHISPER,
  369. localeInfo.TARGET_BUTTON_EXCHANGE,
  370. localeInfo.TARGET_BUTTON_FIGHT,
  371. localeInfo.TARGET_BUTTON_ACCEPT_FIGHT,
  372. localeInfo.TARGET_BUTTON_AVENGE,
  373. localeInfo.TARGET_BUTTON_FIGHT2,
  374. localeInfo.TARGET_BUTTON_ACCEPT_FIGHT2,
  375. localeInfo.TARGET_BUTTON_AVENGE2,
  376. localeInfo.TARGET_BUTTON_FRIEND,
  377. localeInfo.TARGET_BUTTON_INVITE_PARTY,
  378. localeInfo.TARGET_BUTTON_LEAVE_PARTY,
  379. localeInfo.TARGET_BUTTON_EXCLUDE,
  380. localeInfo.TARGET_BUTTON_INVITE_GUILD,
  381. localeInfo.TARGET_BUTTON_DISMOUNT,
  382. localeInfo.TARGET_BUTTON_EXIT_OBSERVER,
  383. localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT,
  384. localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY,
  385. localeInfo.TARGET_BUTTON_BUILDING_DESTROY,
  386. localeInfo.TARGET_BUTTON_EMOTION_ALLOW,
  387. localeInfo.TARGET_BUTTON_DICE,
  388. localeInfo.COMMAND_MAP1,
  389. localeInfo.TARGET_BUTTON_KICK,
  390. "VOTE_BLOCK_CHAT",
  391. )
  392.  
  393. GRADE_NAME = {
  394. nonplayer.PAWN : localeInfo.TARGET_LEVEL_PAWN,
  395. nonplayer.S_PAWN : localeInfo.TARGET_LEVEL_S_PAWN,
  396. nonplayer.KNIGHT : localeInfo.TARGET_LEVEL_KNIGHT,
  397. nonplayer.S_KNIGHT : localeInfo.TARGET_LEVEL_S_KNIGHT,
  398. nonplayer.BOSS : localeInfo.TARGET_LEVEL_BOSS,
  399. nonplayer.KING : localeInfo.TARGET_LEVEL_KING,
  400. }
  401. EXCHANGE_LIMIT_RANGE = 3000
  402. DICE_LIMIT_RANGE = 5000
  403.  
  404. def __init__(self):
  405. ui.ThinBoard.__init__(self)
  406.  
  407. name = ui.TextLine()
  408. name.SetParent(self)
  409. name.SetDefaultFontName()
  410. name.SetOutline()
  411. name.Show()
  412.  
  413. hpGauge = ui.DynamicGauge()
  414. hpGauge.SetParent(self)
  415. hpGauge.MakeGauge ( 130 , "red" , "purple" )
  416. hpGauge.Hide()
  417. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  418. hpDecimal = ui.TextLine()
  419. hpDecimal.SetParent(hpGauge)
  420. hpDecimal.SetDefaultFontName()
  421. hpDecimal.SetPosition(5, 5)
  422. hpDecimal.SetOutline()
  423. hpDecimal.Hide()
  424.  
  425. closeButton = ui.Button()
  426. closeButton.SetParent(self)
  427. closeButton.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  428. closeButton.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  429. closeButton.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  430. closeButton.SetPosition(30, 13)
  431.  
  432. if localeInfo.IsARABIC():
  433. hpGauge.SetPosition(55, 17)
  434. hpGauge.SetWindowHorizontalAlignLeft()
  435. closeButton.SetWindowHorizontalAlignLeft()
  436. else:
  437. hpGauge.SetPosition(175, 17)
  438. hpGauge.SetWindowHorizontalAlignRight()
  439. closeButton.SetWindowHorizontalAlignRight()
  440.  
  441. if app.ENABLE_SEND_TARGET_INFO:
  442. infoButton = ui.Button()
  443. infoButton.SetParent(self)
  444. infoButton.SetUpVisual("d:/ymir work/ui/target/pattern/q_mark_01.tga")
  445. infoButton.SetOverVisual("d:/ymir work/ui/target/pattern/q_mark_02.tga")
  446. infoButton.SetDownVisual("d:/ymir work/ui/target/pattern/q_mark_01.tga")
  447. infoButton.SetEvent(ui.__mem_func__(self.OnPressedInfoButton))
  448. infoButton.Hide()
  449.  
  450. infoBoard = self.InfoBoard()
  451. infoBoard.Hide()
  452. infoButton.showWnd = infoBoard
  453.  
  454. closeButton.SetEvent(ui.__mem_func__(self.OnPressedCloseButton))
  455. closeButton.Show()
  456.  
  457. self.buttonDict = {}
  458. self.showingButtonList = []
  459. for buttonName in self.BUTTON_NAME_LIST:
  460. button = ui.Button()
  461. button.SetParent(self)
  462.  
  463. if localeInfo.IsARABIC():
  464. button.SetUpVisual("d:/ymir work/ui/public/Small_Button_01.sub")
  465. button.SetOverVisual("d:/ymir work/ui/public/Small_Button_02.sub")
  466. button.SetDownVisual("d:/ymir work/ui/public/Small_Button_03.sub")
  467. else:
  468. button.SetUpVisual("d:/ymir work/ui/public/small_thin_button_01.sub")
  469. button.SetOverVisual("d:/ymir work/ui/public/small_thin_button_02.sub")
  470. button.SetDownVisual("d:/ymir work/ui/public/small_thin_button_03.sub")
  471.  
  472. button.SetWindowHorizontalAlignCenter()
  473. button.SetText(buttonName)
  474. button.Hide()
  475. self.buttonDict[buttonName] = button
  476. self.showingButtonList.append(button)
  477.  
  478. self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER].SetEvent(ui.__mem_func__(self.OnWhisper))
  479. self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE].SetEvent(ui.__mem_func__(self.OnExchange))
  480. self.buttonDict[localeInfo.TARGET_BUTTON_DICE].SetEvent(ui.__mem_func__(self.OnDice))
  481.  
  482. self.buttonDict[localeInfo.COMMAND_MAP1].SetEvent(ui.__mem_func__(self.OnMap1))
  483. self.buttonDict[localeInfo.TARGET_BUTTON_KICK].SetEvent(ui.__mem_func__(self.OnKick))
  484.  
  485. self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT].SetEvent(ui.__mem_func__(self.OnPVPNormal))
  486. self.buttonDict[localeInfo.TARGET_BUTTON_ACCEPT_FIGHT].SetEvent(ui.__mem_func__(self.OnPVPNormal))
  487. self.buttonDict[localeInfo.TARGET_BUTTON_AVENGE].SetEvent(ui.__mem_func__(self.OnPVPNormal))
  488.  
  489. self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT2].SetEvent(ui.__mem_func__(self.OnPVPAvansat))
  490. self.buttonDict[localeInfo.TARGET_BUTTON_ACCEPT_FIGHT2].SetEvent(ui.__mem_func__(self.OnPVPAvansat))
  491. self.buttonDict[localeInfo.TARGET_BUTTON_AVENGE2].SetEvent(ui.__mem_func__(self.OnPVPAvansat))
  492.  
  493.  
  494. self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  495. self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  496. self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyInvite))
  497. self.buttonDict[localeInfo.TARGET_BUTTON_LEAVE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyExit))
  498. self.buttonDict[localeInfo.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))
  499.  
  500. self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_GUILD].SAFE_SetEvent(self.__OnGuildAddMember)
  501. self.buttonDict[localeInfo.TARGET_BUTTON_DISMOUNT].SAFE_SetEvent(self.__OnDismount)
  502. self.buttonDict[localeInfo.TARGET_BUTTON_EXIT_OBSERVER].SAFE_SetEvent(self.__OnExitObserver)
  503. self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT].SAFE_SetEvent(self.__OnViewEquipment)
  504. self.buttonDict[localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY].SAFE_SetEvent(self.__OnRequestParty)
  505. self.buttonDict[localeInfo.TARGET_BUTTON_BUILDING_DESTROY].SAFE_SetEvent(self.__OnDestroyBuilding)
  506. self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW].SAFE_SetEvent(self.__OnEmotionAllow)
  507.  
  508. self.buttonDict["VOTE_BLOCK_CHAT"].SetEvent(ui.__mem_func__(self.__OnVoteBlockChat))
  509.  
  510. self.name = name
  511. self.hpGauge = hpGauge
  512. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  513. self.hpDecimal = hpDecimal
  514. if app.ENABLE_SEND_TARGET_INFO:
  515. self.infoButton = infoButton
  516. if app.ENABLE_SEND_TARGET_INFO:
  517. self.vnum = 0
  518. self.closeButton = closeButton
  519. self.nameString = 0
  520. self.nameLength = 0
  521. self.vid = 0
  522. self.eventWhisper = None
  523. self.isShowButton = False
  524.  
  525. self.__Initialize()
  526. self.ResetTargetBoard()
  527.  
  528. def __del__(self):
  529. ui.ThinBoard.__del__(self)
  530.  
  531. print "===================================================== DESTROYED TARGET BOARD"
  532.  
  533. def __Initialize(self):
  534. self.nameString = ""
  535. self.nameLength = 0
  536. self.vid = 0
  537. if app.ENABLE_SEND_TARGET_INFO:
  538. self.vnum = 0
  539. self.isShowButton = False
  540.  
  541. def Destroy(self):
  542. self.eventWhisper = None
  543. if app.ENABLE_SEND_TARGET_INFO:
  544. self.infoButton = None
  545. self.closeButton = None
  546. self.showingButtonList = None
  547. self.buttonDict = None
  548. self.name = None
  549. self.hpGauge = None
  550. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  551. self.hpDecimal = None
  552. self.__Initialize()
  553.  
  554. if app.ENABLE_SEND_TARGET_INFO:
  555. def RefreshMonsterInfoBoard(self):
  556. if not self.infoButton.showWnd.IsShow():
  557. return
  558.  
  559. self.infoButton.showWnd.Refresh()
  560.  
  561. def OnPressedInfoButton(self):
  562. net.SendTargetInfoLoad(player.GetTargetVID())
  563. if self.infoButton.showWnd.IsShow():
  564. self.infoButton.showWnd.Close()
  565. elif self.vnum != 0:
  566. self.infoButton.showWnd.Open(self, self.vnum)
  567.  
  568. def OnPressedCloseButton(self):
  569. player.ClearTarget()
  570. self.Close()
  571.  
  572. def Close(self):
  573. self.__Initialize()
  574. self.Hide()
  575. if app.ENABLE_SEND_TARGET_INFO:
  576. self.infoButton.showWnd.Close()
  577.  
  578. def Open(self, vid, name):
  579. if vid:
  580. if not constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD():
  581. if not player.IsSameEmpire(vid):
  582. self.Hide()
  583. return
  584.  
  585. if vid != self.GetTargetVID():
  586. self.ResetTargetBoard()
  587. self.SetTargetVID(vid)
  588. self.SetTargetName(name)
  589.  
  590. if player.IsMainCharacterIndex(vid):
  591. self.__ShowMainCharacterMenu()
  592. elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  593. self.Hide()
  594. else:
  595. self.RefreshButton()
  596. self.Show()
  597. else:
  598. self.HideAllButton()
  599. self.__ShowButton(localeInfo.TARGET_BUTTON_WHISPER)
  600. self.__ShowButton("VOTE_BLOCK_CHAT")
  601. self.__ArrangeButtonPosition()
  602. self.SetTargetName(name)
  603. self.Show()
  604.  
  605. def Refresh(self):
  606. if self.IsShow():
  607. if self.IsShowButton():
  608. self.RefreshButton()
  609.  
  610. def RefreshByVID(self, vid):
  611. if vid == self.GetTargetVID():
  612. self.Refresh()
  613.  
  614. def RefreshByName(self, name):
  615. if name == self.GetTargetName():
  616. self.Refresh()
  617.  
  618. def __ShowMainCharacterMenu(self):
  619. canShow=0
  620.  
  621. self.HideAllButton()
  622.  
  623. if player.IsMountingHorse():
  624. self.__ShowButton(localeInfo.TARGET_BUTTON_DISMOUNT)
  625. canShow=1
  626.  
  627. if player.IsObserverMode():
  628. self.__ShowButton(localeInfo.TARGET_BUTTON_EXIT_OBSERVER)
  629. canShow=1
  630.  
  631. if canShow:
  632. self.__ArrangeButtonPosition()
  633. self.Show()
  634. else:
  635. self.Hide()
  636.  
  637. def __ShowNameOnlyMenu(self):
  638. self.HideAllButton()
  639.  
  640. def SetWhisperEvent(self, event):
  641. self.eventWhisper = event
  642.  
  643. def UpdatePosition(self):
  644. self.SetPosition(wndMgr.GetScreenWidth()/2 - self.GetWidth()/2, 10)
  645.  
  646. def ResetTargetBoard(self):
  647.  
  648. for btn in self.buttonDict.values():
  649. btn.Hide()
  650.  
  651. self.__Initialize()
  652.  
  653. self.name.SetPosition(0, 13)
  654. self.name.SetHorizontalAlignCenter()
  655. self.name.SetWindowHorizontalAlignCenter()
  656. self.hpGauge.Hide()
  657. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  658. self.hpDecimal.Hide()
  659. if app.ENABLE_SEND_TARGET_INFO:
  660. self.infoButton.Hide()
  661. self.infoButton.showWnd.Close()
  662. self.SetSize(250, 40)
  663.  
  664. def SetTargetVID(self, vid):
  665. self.vid = vid
  666. if app.ENABLE_SEND_TARGET_INFO:
  667. self.vnum = 0
  668.  
  669. def SetEnemyVID(self, vid):
  670. self.SetTargetVID(vid)
  671.  
  672. name = chr.GetNameByVID(vid)
  673. level = nonplayer.GetLevelByVID(vid)
  674. grade = nonplayer.GetGradeByVID(vid)
  675. if app.ENABLE_SEND_TARGET_INFO:
  676. vnum = nonplayer.GetRaceNumByVID(vid)
  677.  
  678. nameFront = ""
  679. if -1 != level:
  680. nameFront += "Lv." + str(level) + " "
  681. if self.GRADE_NAME.has_key(grade):
  682. nameFront += "(" + self.GRADE_NAME[grade] + ") "
  683.  
  684. self.SetTargetName(nameFront + name)
  685.  
  686. if app.ENABLE_SEND_TARGET_INFO:
  687. (textWidth, textHeight) = self.name.GetTextSize()
  688.  
  689. self.infoButton.SetPosition(textWidth + 25, 12)
  690. self.infoButton.SetWindowHorizontalAlignLeft()
  691.  
  692. self.vnum = vnum
  693. self.infoButton.Show()
  694.  
  695. def GetTargetVID(self):
  696. return self.vid
  697.  
  698. def GetTargetName(self):
  699. return self.nameString
  700.  
  701. def SetTargetName(self, name):
  702. self.nameString = name
  703. self.nameLength = len(name)
  704. self.name.SetText(name)
  705.  
  706. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  707. def SetHP(self, hpPercentage, iMinHP, iMaxHP):
  708. if not self.hpGauge.IsShow():
  709. if app.ENABLE_VIEW_TARGET_PLAYER_HP:
  710. showingButtonCount = len(self.showingButtonList)
  711. if showingButtonCount > 0:
  712. if chr.GetInstanceType(self.vid) == chr.INSTANCE_TYPE_PLAYER:
  713. self.SetSize(max(150 + 75 * 3, showingButtonCount * 75), self.GetHeight())
  714. else:
  715. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  716. else:
  717. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  718. else:
  719. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  720.  
  721. if localeInfo.IsARABIC():
  722. self.name.SetPosition( self.GetWidth()-23, 13)
  723. else:
  724. self.name.SetPosition(23, 13)
  725.  
  726. self.name.SetWindowHorizontalAlignLeft()
  727. self.name.SetHorizontalAlignLeft()
  728. self.hpGauge.Show()
  729. self.UpdatePosition()
  730.  
  731. self.hpGauge.SetPercentage(hpPercentage, 100)
  732. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  733. iMinHPText = '.'.join([i - 3 < 0 and str(iMinHP)[:i] or str(iMinHP)[i-3:i] for i in range(len(str(iMinHP)) % 3, len(str(iMinHP))+1, 3) if i])
  734. iMaxHPText = '.'.join([i - 3 < 0 and str(iMaxHP)[:i] or str(iMaxHP)[i-3:i] for i in range(len(str(iMaxHP)) % 3, len(str(iMaxHP))+1, 3) if i])
  735. self.hpDecimal.SetText(str(iMinHPText) + "/" + str(iMaxHPText))
  736. (textWidth, textHeight)=self.hpDecimal.GetTextSize()
  737. if localeInfo.IsARABIC():
  738. self.hpDecimal.SetPosition(120 / 2 + textWidth / 2, -13)
  739. else:
  740. self.hpDecimal.SetPosition(130 / 2 - textWidth / 2, -13)
  741.  
  742. self.hpDecimal.Show()
  743. else:
  744. def SetHP(self, hpPercentage):
  745. if not self.hpGauge.IsShow():
  746. if app.ENABLE_VIEW_TARGET_PLAYER_HP:
  747. showingButtonCount = len(self.showingButtonList)
  748. if showingButtonCount > 0:
  749. if chr.GetInstanceType(self.GetTargetVID) != chr.INSTANCE_TYPE_PLAYER:
  750. if showingButtonCount != 1:
  751. self.SetSize(max(150, showingButtonCount * 75), self.GetHeight())
  752. else:
  753. self.SetSize(max(150, 2 * 75), self.GetHeight())
  754. else:
  755. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  756. else:
  757. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  758. else:
  759. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  760.  
  761. if localeInfo.IsARABIC():
  762. self.name.SetPosition( self.GetWidth()-23, 13)
  763. else:
  764. self.name.SetPosition(23, 13)
  765.  
  766. self.name.SetWindowHorizontalAlignLeft()
  767. self.name.SetHorizontalAlignLeft()
  768. self.hpGauge.Show()
  769. self.UpdatePosition()
  770.  
  771. def ShowDefaultButton(self):
  772.  
  773. self.isShowButton = True
  774. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER])
  775. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
  776. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_DICE])
  777. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW])
  778. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT])
  779. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT2])
  780. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT])
  781. for button in self.showingButtonList:
  782. button.Show()
  783.  
  784. def HideAllButton(self):
  785. self.isShowButton = False
  786. for button in self.showingButtonList:
  787. button.Hide()
  788. self.showingButtonList = []
  789.  
  790. def __ShowButton(self, name):
  791.  
  792. if not self.buttonDict.has_key(name):
  793. return
  794.  
  795. self.buttonDict[name].Show()
  796. self.showingButtonList.append(self.buttonDict[name])
  797.  
  798. def __HideButton(self, name):
  799.  
  800. if not self.buttonDict.has_key(name):
  801. return
  802.  
  803. button = self.buttonDict[name]
  804. button.Hide()
  805.  
  806. for btnInList in self.showingButtonList:
  807. if btnInList == button:
  808. self.showingButtonList.remove(button)
  809. break
  810.  
  811. def OnWhisper(self):
  812. if None != self.eventWhisper:
  813. self.eventWhisper(self.nameString)
  814.  
  815. def __IsSpecialMap(self):
  816. import background
  817. Blocked_MAPS = [
  818. "season1/metin2_map_oxevent",
  819. "metin2_map_duel",
  820. "metin2_map_duel2"
  821. ]
  822.  
  823. if str(background.GetCurrentMapName()) in Blocked_MAPS:
  824. return TRUE
  825.  
  826. return FALSE
  827.  
  828. def OnExchange(self):
  829. import chat
  830. if self.__IsSpecialMap():
  831. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_NEGOT)
  832. return
  833.  
  834. net.SendExchangeStartPacket(self.vid)
  835.  
  836. def OnDice(self):
  837. import chat
  838. if self.__IsSpecialMap():
  839. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_BARBUT)
  840. return
  841.  
  842. net.SendDiceStartPacket(self.vid)
  843.  
  844.  
  845. def OnPVPNormal(self):
  846. import chat
  847. if self.__IsSpecialMap():
  848. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_REVANSA)
  849. return
  850.  
  851. net.SendChatPacket("/pvp %d 0" % (self.vid))
  852.  
  853. def OnPVPAvansat(self):
  854. import chat
  855. if self.__IsSpecialMap():
  856. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_REVANSA)
  857. return
  858.  
  859. net.SendChatPacket("/pvp %d 1" % (self.vid))
  860.  
  861. def OnAppendToMessenger(self):
  862. import chat
  863. if self.__IsSpecialMap():
  864. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_CERERE_FRND)
  865. return
  866.  
  867. net.SendMessengerAddByVIDPacket(self.vid)
  868.  
  869. def OnPartyInvite(self):
  870. import chat
  871. if self.__IsSpecialMap():
  872. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_GRUPA)
  873. return
  874.  
  875. net.SendPartyInvitePacket(self.vid)
  876.  
  877. def OnPartyExit(self):
  878. net.SendPartyExitPacket()
  879.  
  880. def OnPartyRemove(self):
  881. net.SendPartyRemovePacket(self.vid)
  882.  
  883. def __OnGuildAddMember(self):
  884. import chat
  885. if self.__IsSpecialMap():
  886. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MAPA_FARA_ADD_GUILD)
  887. return
  888.  
  889. net.SendGuildAddMemberPacket(self.vid)
  890.  
  891. def __OnDismount(self):
  892. net.SendChatPacket("/unmount")
  893.  
  894. def __OnExitObserver(self):
  895. net.SendChatPacket("/observer_exit")
  896.  
  897. def __OnViewEquipment(self):
  898. net.SendChatPacket("/view_equip " + str(self.vid))
  899.  
  900. def __OnRequestParty(self):
  901. net.SendChatPacket("/party_request " + str(self.vid))
  902.  
  903. def __OnDestroyBuilding(self):
  904. net.SendChatPacket("/build d %d" % (self.vid))
  905.  
  906. def __OnEmotionAllow(self):
  907. net.SendChatPacket("/emotion_allow %d" % (self.vid))
  908.  
  909. def __OnVoteBlockChat(self):
  910. cmd = "/vote_block_chat %s" % (self.nameString)
  911. net.SendChatPacket(cmd)
  912.  
  913. def OnPressEscapeKey(self):
  914. self.OnPressedCloseButton()
  915. return True
  916.  
  917. def IsShowButton(self):
  918. return self.isShowButton
  919.  
  920. def RefreshButton(self):
  921.  
  922. self.HideAllButton()
  923.  
  924. if chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  925. #self.__ShowButton(localeInfo.TARGET_BUTTON_BUILDING_DESTROY)
  926. #self.__ArrangeButtonPosition()
  927. return
  928.  
  929. if player.IsPVPInstance(self.vid) or player.IsObserverMode():
  930. # PVP_INFO_SIZE_BUG_FIX
  931. self.SetSize(200 + 7*self.nameLength, 40)
  932. self.UpdatePosition()
  933. # END_OF_PVP_INFO_SIZE_BUG_FIX
  934. return
  935.  
  936. self.ShowDefaultButton()
  937.  
  938. gamemasta = player.GetName()
  939. if gamemasta.find("[#Tinolex]")!=-1 or gamemasta.find("[#Soloer]")!=-1 or gamemasta.find("[GM]")!=-1 or gamemasta.find("[H]")!=-1:
  940. self.__ShowButton(localeInfo.COMMAND_MAP1)
  941. self.__ShowButton(localeInfo.TARGET_BUTTON_KICK)
  942.  
  943. if guild.MainPlayerHasAuthority(guild.AUTH_ADD_MEMBER):
  944. if not guild.IsMemberByName(self.nameString):
  945. if 0 == chr.GetGuildID(self.vid):
  946. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_GUILD)
  947.  
  948. if not messenger.IsFriendByName(self.nameString):
  949. self.__ShowButton(localeInfo.TARGET_BUTTON_FRIEND)
  950.  
  951. if player.IsPartyMember(self.vid):
  952.  
  953. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  954. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT2)
  955.  
  956. if player.IsPartyLeader(self.vid):
  957. self.__ShowButton(localeInfo.TARGET_BUTTON_LEAVE_PARTY)
  958. elif player.IsPartyLeader(player.GetMainCharacterIndex()):
  959. self.__ShowButton(localeInfo.TARGET_BUTTON_EXCLUDE)
  960.  
  961. else:
  962. if player.IsPartyMember(player.GetMainCharacterIndex()):
  963. if player.IsPartyLeader(player.GetMainCharacterIndex()):
  964. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  965. else:
  966. if chr.IsPartyMember(self.vid):
  967. self.__ShowButton(localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY)
  968. else:
  969. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  970.  
  971. if player.IsRevengeInstance(self.vid):
  972. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  973. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT2)
  974. self.__ShowButton(localeInfo.TARGET_BUTTON_AVENGE)
  975. self.__ShowButton(localeInfo.TARGET_BUTTON_AVENGE2)
  976. elif player.IsChallengeInstance(self.vid):
  977. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  978. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT2)
  979. self.__ShowButton(localeInfo.TARGET_BUTTON_ACCEPT_FIGHT)
  980. self.__ShowButton(localeInfo.TARGET_BUTTON_ACCEPT_FIGHT2)
  981. elif player.IsCantFightInstance(self.vid):
  982. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  983. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT2)
  984.  
  985. if not player.IsSameEmpire(self.vid):
  986. self.__HideButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  987. self.__HideButton(localeInfo.TARGET_BUTTON_FRIEND)
  988. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  989. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT2)
  990.  
  991. # if not player.IsSameEmpire(self.vid): //remove for duel all empire
  992. # self.__HideButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  993. # self.__HideButton(localeInfo.TARGET_BUTTON_FRIEND)
  994. # self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  995.  
  996. distance = player.GetCharacterDistance(self.vid)
  997. if distance > self.EXCHANGE_LIMIT_RANGE:
  998. self.__HideButton(localeInfo.TARGET_BUTTON_EXCHANGE)
  999. self.__ArrangeButtonPosition()
  1000.  
  1001. if distance > self.DICE_LIMIT_RANGE:
  1002. self.__HideButton(localeInfo.TARGET_BUTTON_DICE)
  1003. self.__ArrangeButtonPosition()
  1004.  
  1005. self.__ArrangeButtonPosition()
  1006.  
  1007. def __ArrangeButtonPosition(self):
  1008. showingButtonCount = len(self.showingButtonList)
  1009. pos = -(showingButtonCount / 2) * 68
  1010. if 0 == showingButtonCount % 2:
  1011. pos += 34
  1012.  
  1013. for button in self.showingButtonList:
  1014. button.SetPosition(pos, 33)
  1015. pos += 68
  1016.  
  1017. if app.ENABLE_VIEW_TARGET_PLAYER_HP:
  1018. if showingButtonCount <= 2:
  1019. self.SetSize(max(150 + 125, showingButtonCount * 75), 65)
  1020. else:
  1021. self.SetSize(max(150, showingButtonCount * 75), 65)
  1022. else:
  1023. self.SetSize(max(150, showingButtonCount * 75), 65)
  1024.  
  1025. self.UpdatePosition()
  1026.  
  1027. def OnUpdate(self):
  1028. if self.isShowButton:
  1029. exchangeButton = self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE]
  1030. distance = player.GetCharacterDistance(self.vid)
  1031. diceButton = self.buttonDict[localeInfo.TARGET_BUTTON_DICE]
  1032.  
  1033. if distance < 0:
  1034. return
  1035.  
  1036. if diceButton.IsShow():
  1037. if distance > self.DICE_LIMIT_RANGE:
  1038. self.RefreshButton()
  1039. else:
  1040. if distance < self.DICE_LIMIT_RANGE:
  1041. self.RefreshButton()
  1042.  
  1043. if exchangeButton.IsShow():
  1044. if distance > self.EXCHANGE_LIMIT_RANGE:
  1045. self.RefreshButton()
  1046.  
  1047. else:
  1048. if distance < self.EXCHANGE_LIMIT_RANGE:
  1049. self.RefreshButton()
  1050.  
  1051. def OnMap1(self):
  1052. net.SendChatPacket("/map1 " + str(chr.GetNameByVID(self.vid)))
  1053.  
  1054. def OnKick(self):
  1055. net.SendChatPacket("/dc " + str(chr.GetNameByVID(self.vid)))
  1056.  
  1057. if app.ENABLE_SHIP_DEFENSE:
  1058. class AllianceTargetBoard(ui.ThinBoard):
  1059. class TextToolTip(ui.Window):
  1060. def __init__(self):
  1061. ui.Window.__init__(self, "TOP_MOST")
  1062.  
  1063. textLine = ui.TextLine()
  1064. textLine.SetParent(self)
  1065. textLine.SetHorizontalAlignCenter()
  1066. textLine.SetOutline()
  1067. textLine.Show()
  1068. self.textLine = textLine
  1069.  
  1070. def __del__(self):
  1071. ui.Window.__del__(self)
  1072.  
  1073. def SetText(self, text):
  1074. self.textLine.SetText(text)
  1075.  
  1076. def OnRender(self):
  1077. (mouseX, mouseY) = wndMgr.GetMousePosition()
  1078. self.textLine.SetPosition(mouseX, mouseY + 30)
  1079.  
  1080. def __init__(self):
  1081. ui.ThinBoard.__init__(self)
  1082.  
  1083. name = ui.TextLine()
  1084. name.SetParent(self)
  1085. name.SetDefaultFontName()
  1086. name.SetOutline()
  1087. name.Show()
  1088.  
  1089. hpGauge = ui.Gauge()
  1090. hpGauge.SetParent(self)
  1091. hpGauge.MakeGauge(80, "red")
  1092. hpGauge.SetPosition(10, 25)
  1093. hpGauge.OnMouseOverIn = ui.__mem_func__(hpGauge.ShowToolTip)
  1094. hpGauge.OnMouseOverOut = ui.__mem_func__(hpGauge.HideToolTip)
  1095. hpGauge.SetShowToolTipEvent(hpGauge.OnMouseOverIn)
  1096. hpGauge.SetHideToolTipEvent(hpGauge.OnMouseOverOut)
  1097. hpGauge.Hide()
  1098.  
  1099. self.name = name
  1100. self.hpGauge = hpGauge
  1101.  
  1102. self.toolTipHP = self.TextToolTip()
  1103. self.toolTipHP.Hide()
  1104.  
  1105. self.Initialize()
  1106. self.ResetTargetBoard()
  1107.  
  1108. def __del__(self):
  1109. ui.ThinBoard.__del__(self)
  1110.  
  1111. def Initialize(self):
  1112. self.nameLength = 0
  1113. self.vid = 0
  1114.  
  1115. def Destroy(self):
  1116. self.name = None
  1117. self.hpGauge = None
  1118. self.tooltipHP = None
  1119.  
  1120. self.Initialize()
  1121.  
  1122. def Close(self):
  1123. self.Initialize()
  1124. self.tooltipHP.Hide()
  1125. self.Hide()
  1126.  
  1127. def ResetTargetBoard(self):
  1128. self.Initialize()
  1129.  
  1130. self.name.SetPosition(0, 13)
  1131. self.name.SetHorizontalAlignCenter()
  1132. self.name.SetWindowHorizontalAlignCenter()
  1133.  
  1134. self.hpGauge.Hide()
  1135. self.SetSize(100, 40)
  1136.  
  1137. def SetTargetVID(self, vid):
  1138. self.vid = vid
  1139.  
  1140. def SetTarget(self, vid):
  1141. self.SetTargetVID(vid)
  1142.  
  1143. name = chr.GetNameByVID(vid)
  1144. self.SetTargetName(name)
  1145.  
  1146. def GetTargetVID(self):
  1147. return self.vid
  1148.  
  1149. def SetTargetName(self, name):
  1150. self.nameLength = len(name)
  1151. self.name.SetText(name)
  1152.  
  1153. def SetHP(self, hp, hpMax):
  1154. hp = min(hp, hpMax)
  1155. if hp > 0:
  1156. self.SetSize(100, self.GetHeight())
  1157.  
  1158. if localeInfo.IsARABIC():
  1159. self.name.SetPosition(self.GetWidth() - 10, 10)
  1160. else:
  1161. self.name.SetPosition(10, 10)
  1162.  
  1163. self.name.SetWindowHorizontalAlignLeft()
  1164. self.name.SetHorizontalAlignLeft()
  1165. self.hpGauge.Show()
  1166. self.UpdatePosition()
  1167.  
  1168. self.hpGauge.SetPercentage(hp, hpMax)
  1169. self.hpGauge.SetToolTipText("%s : %d / %d" % (localeInfo.TASKBAR_HP, hp, hpMax))
  1170.  
  1171. def UpdatePosition(self):
  1172. # NOTE : y = miniMap + serverInfo Height
  1173. self.SetPosition(wndMgr.GetScreenWidth() - self.GetWidth() - 18, 250)
  1174.  
  1175. def IsOut(self):
  1176. if self.toolTipHP:
  1177. self.toolTipHP.Hide()
  1178.  
  1179. def IsIn(self):
  1180. if self.toolTipHP:
  1181. self.toolTipHP.Show()
  1182.  
  1183. # NOTE : Unused.
  1184. def SetMouseEvent(self):
  1185. pass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement