Advertisement
Guest User

Untitled

a guest
Nov 26th, 2020
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.83 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 uiToolTip
  13. import item
  14. if app.ENABLE_SEND_TARGET_INFO:
  15. def HAS_FLAG(value, flag):
  16. return (value & flag) == flag
  17.  
  18. class TargetBoard(ui.ThinBoard):
  19. if app.ENABLE_SEND_TARGET_INFO:
  20. class InfoBoard(ui.ThinBoard):
  21. class ItemListBoxItem(ui.ListBoxExNew.Item):
  22. def __init__(self, width):
  23. ui.ListBoxExNew.Item.__init__(self)
  24.  
  25. image = ui.ExpandedImageBox()
  26. image.SetParent(self)
  27. image.Show()
  28. self.image = image
  29.  
  30. nameLine = ui.TextLine()
  31. nameLine.SetParent(self)
  32. nameLine.SetPosition(32 + 5, 0)
  33. nameLine.Show()
  34. self.nameLine = nameLine
  35.  
  36. self.SetSize(width, 32 + 5)
  37.  
  38. def LoadImage(self, image, name = None):
  39. self.image.LoadImage(image)
  40. self.SetSize(self.GetWidth(), self.image.GetHeight() + 5 * (self.image.GetHeight() / 32))
  41. if name != None:
  42. self.SetText(name)
  43.  
  44. def SetText(self, text):
  45. self.nameLine.SetText(text)
  46.  
  47. def RefreshHeight(self):
  48. ui.ListBoxExNew.Item.RefreshHeight(self)
  49. self.image.SetRenderingRect(0.0, 0.0 - float(self.removeTop) / float(self.GetHeight()), 0.0, 0.0 - float(self.removeBottom) / float(self.GetHeight()))
  50. self.image.SetPosition(0, - self.removeTop)
  51.  
  52. MAX_ITEM_COUNT = 5
  53.  
  54. EXP_BASE_LVDELTA = [
  55. 1, # -15 0
  56. 5, # -14 1
  57. 10, # -13 2
  58. 20, # -12 3
  59. 30, # -11 4
  60. 50, # -10 5
  61. 70, # -9 6
  62. 80, # -8 7
  63. 85, # -7 8
  64. 90, # -6 9
  65. 92, # -5 10
  66. 94, # -4 11
  67. 96, # -3 12
  68. 98, # -2 13
  69. 100, # -1 14
  70. 100, # 0 15
  71. 105, # 1 16
  72. 110, # 2 17
  73. 115, # 3 18
  74. 120, # 4 19
  75. 125, # 5 20
  76. 130, # 6 21
  77. 135, # 7 22
  78. 140, # 8 23
  79. 145, # 9 24
  80. 150, # 10 25
  81. 155, # 11 26
  82. 160, # 12 27
  83. 165, # 13 28
  84. 170, # 14 29
  85. 180, # 15 30
  86. ]
  87.  
  88. RACE_FLAG_TO_NAME = {
  89. 1 << 0 : localeInfo.TARGET_INFO_RACE_ANIMAL,
  90. 1 << 1 : localeInfo.TARGET_INFO_RACE_UNDEAD,
  91. 1 << 2 : localeInfo.TARGET_INFO_RACE_DEVIL,
  92. 1 << 3 : localeInfo.TARGET_INFO_RACE_HUMAN,
  93. 1 << 4 : localeInfo.TARGET_INFO_RACE_ORC,
  94. 1 << 5 : localeInfo.TARGET_INFO_RACE_MILGYO,
  95. }
  96.  
  97. SUB_RACE_FLAG_TO_NAME = {
  98. 1 << 11 : localeInfo.TARGET_INFO_RACE_ELEC,
  99. 1 << 12 : localeInfo.TARGET_INFO_RACE_FIRE,
  100. 1 << 13 : localeInfo.TARGET_INFO_RACE_ICE,
  101. 1 << 14 : localeInfo.TARGET_INFO_RACE_WIND,
  102. 1 << 15 : localeInfo.TARGET_INFO_RACE_EARTH,
  103. 1 << 16 : localeInfo.TARGET_INFO_RACE_DARK,
  104. 1 << 23 : localeInfo.TARGET_INFO_RACE_METIN,
  105. }
  106.  
  107. STONE_START_VNUM = 28030
  108. STONE_LAST_VNUM = 28042
  109.  
  110. BOARD_WIDTH = 250
  111.  
  112. def __init__(self):
  113. ui.ThinBoard.__init__(self)
  114.  
  115. self.HideCorners(self.LT)
  116. self.HideCorners(self.RT)
  117. self.HideLine(self.T)
  118.  
  119. self.race = 0
  120. self.hasItems = False
  121.  
  122. self.itemTooltip = uiToolTip.ItemToolTip()
  123. self.itemTooltip.HideToolTip()
  124.  
  125. self.stoneImg = None
  126. self.stoneVnum = None
  127. self.lastStoneVnum = 0
  128. self.nextStoneIconChange = 0
  129.  
  130. self.itemScrollBar = None
  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.itemScrollBar = None
  164. self.__LoadInformation_Default(race)
  165. self.__LoadInformation_Race(race)
  166. self.__LoadInformation_Drops(race)
  167.  
  168. def __LoadInformation_Default_GetHitRate(self, race):
  169. attacker_dx = nonplayer.GetMonsterDX(race)
  170. attacker_level = nonplayer.GetMonsterLevel(race)
  171.  
  172. self_dx = player.GetStatus(player.DX)
  173. self_level = player.GetStatus(player.LEVEL)
  174.  
  175. iARSrc = min(90, (attacker_dx * 4 + attacker_level * 2) / 6)
  176. iERSrc = min(90, (self_dx * 4 + self_level * 2) / 6)
  177.  
  178. fAR = (float(iARSrc) + 210.0) / 300.0
  179. fER = (float(iERSrc) * 2 + 5) / (float(iERSrc) + 95) * 3.0 / 10.0
  180.  
  181. return fAR - fER
  182.  
  183. def __LoadInformation_Default(self, race):
  184. self.AppendSeperator()
  185. self.AppendTextLine(localeInfo.TARGET_INFO_MAX_HP % str(nonplayer.GetMonsterMaxHP(race)))
  186.  
  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.  
  240. else:
  241. itemListBox = ui.ListBoxExNew(32 + 5, self.MAX_ITEM_COUNT)
  242. itemListBox.SetSize(self.GetWidth() - 15 * 2 - ui.ScrollBar.SCROLLBAR_WIDTH, (32 + 5) * self.MAX_ITEM_COUNT)
  243. height = 0
  244. for curItem in constInfo.MONSTER_INFO_DATA[race]["items"]:
  245. if curItem.has_key("vnum_list"):
  246. height += self.AppendItem(itemListBox, curItem["vnum_list"], curItem["count"])
  247. else:
  248. height += self.AppendItem(itemListBox, curItem["vnum"], curItem["count"])
  249. if height < itemListBox.GetHeight():
  250. itemListBox.SetSize(itemListBox.GetWidth(), height)
  251. self.AppendWindow(itemListBox, 15)
  252. itemListBox.SetBasePos(0)
  253.  
  254. if len(constInfo.MONSTER_INFO_DATA[race]["items"]) > itemListBox.GetViewItemCount():
  255. itemScrollBar = ui.ScrollBar()
  256. itemScrollBar.SetParent(self)
  257. itemScrollBar.SetPosition(itemListBox.GetRight(), itemListBox.GetTop())
  258. itemScrollBar.SetScrollBarSize(32 * self.MAX_ITEM_COUNT + 5 * (self.MAX_ITEM_COUNT - 1))
  259. itemScrollBar.SetMiddleBarSize(float(self.MAX_ITEM_COUNT) / float(height / (32 + 5)))
  260. itemScrollBar.Show()
  261. itemListBox.SetScrollBar(itemScrollBar)
  262. else:
  263. self.AppendTextLine(localeInfo.TARGET_INFO_NO_ITEM_TEXT)
  264.  
  265. def AppendTextLine(self, text):
  266. textLine = ui.TextLine()
  267. textLine.SetParent(self)
  268. textLine.SetWindowHorizontalAlignCenter()
  269. textLine.SetHorizontalAlignCenter()
  270. textLine.SetText(text)
  271. textLine.SetPosition(0, self.yPos)
  272. textLine.Show()
  273.  
  274. self.children.append(textLine)
  275. self.yPos += 17
  276.  
  277. def AppendSeperator(self):
  278. img = ui.ImageBox()
  279. img.LoadImage("d:/ymir work/ui/seperator.tga")
  280. self.AppendWindow(img)
  281. img.SetPosition(img.GetLeft(), img.GetTop() - 15)
  282. self.yPos -= 15
  283.  
  284. def AppendItem(self, listBox, vnums, count):
  285. if type(vnums) == int:
  286. vnum = vnums
  287. else:
  288. vnum = vnums[0]
  289.  
  290. item.SelectItem(vnum)
  291. itemName = item.GetItemName()
  292. if type(vnums) != int and len(vnums) > 1:
  293. vnums = sorted(vnums)
  294. realName = itemName[:itemName.find("+")]
  295. if item.GetItemType() == item.ITEM_TYPE_METIN:
  296. realName = localeInfo.TARGET_INFO_STONE_NAME
  297. itemName = realName + "+0 - +4"
  298. else:
  299. itemName = realName + "+" + str(vnums[0] % 10) + " - +" + str(vnums[len(vnums) - 1] % 10)
  300. vnum = vnums[len(vnums) - 1]
  301.  
  302. myItem = self.ItemListBoxItem(listBox.GetWidth())
  303. myItem.LoadImage(item.GetIconImageFileName())
  304. if count <= 1:
  305. myItem.SetText(itemName)
  306. else:
  307. myItem.SetText("%dx %s" % (count, itemName))
  308. myItem.SAFE_SetOverInEvent(self.OnShowItemTooltip, vnum)
  309. myItem.SAFE_SetOverOutEvent(self.OnHideItemTooltip)
  310. listBox.AppendItem(myItem)
  311.  
  312. if item.GetItemType() == item.ITEM_TYPE_METIN:
  313. self.stoneImg = myItem
  314. self.stoneVnum = vnums
  315. self.lastStoneVnum = self.STONE_LAST_VNUM + vnums[len(vnums) - 1] % 1000 / 100 * 100
  316.  
  317. return myItem.GetHeight()
  318.  
  319. def OnShowItemTooltip(self, vnum):
  320. item.SelectItem(vnum)
  321. if item.GetItemType() == item.ITEM_TYPE_METIN:
  322. self.itemTooltip.isStone = True
  323. self.itemTooltip.isBook = False
  324. self.itemTooltip.isBook2 = False
  325. self.itemTooltip.SetItemToolTip(self.lastStoneVnum)
  326. else:
  327. self.itemTooltip.isStone = False
  328. self.itemTooltip.isBook = True
  329. self.itemTooltip.isBook2 = True
  330. self.itemTooltip.SetItemToolTip(vnum)
  331.  
  332. def OnHideItemTooltip(self):
  333. self.itemTooltip.HideToolTip()
  334.  
  335. def AppendWindow(self, wnd, x = 0, width = 0, height = 0):
  336. if width == 0:
  337. width = wnd.GetWidth()
  338. if height == 0:
  339. height = wnd.GetHeight()
  340.  
  341. wnd.SetParent(self)
  342. if x == 0:
  343. wnd.SetPosition((self.GetWidth() - width) / 2, self.yPos)
  344. else:
  345. wnd.SetPosition(x, self.yPos)
  346. wnd.Show()
  347.  
  348. self.children.append(wnd)
  349. self.yPos += height + 5
  350.  
  351. def OnRunMouseWheel(self, nLen):
  352. if self.itemScrollBar.IsShow():
  353. if nLen > 0:
  354. self.itemScrollBar.OnUp()
  355. else:
  356. self.itemScrollBar.OnDown()
  357. def OnUpdate(self):
  358. if self.stoneImg != None and self.stoneVnum != None and app.GetTime() >= self.nextStoneIconChange:
  359. nextImg = self.lastStoneVnum + 1
  360. if nextImg % 100 > self.STONE_LAST_VNUM % 100:
  361. nextImg -= (self.STONE_LAST_VNUM - self.STONE_START_VNUM) + 1
  362. self.lastStoneVnum = nextImg
  363. self.nextStoneIconChange = app.GetTime() + 2.5
  364.  
  365. item.SelectItem(nextImg)
  366. itemName = item.GetItemName()
  367. realName = itemName[:itemName.find("+")]
  368. realName = realName + "+0 - +4"
  369. self.stoneImg.LoadImage(item.GetIconImageFileName(), realName)
  370.  
  371. if self.itemTooltip.IsShow() and self.itemTooltip.isStone:
  372. self.itemTooltip.SetItemToolTip(nextImg)
  373.  
  374. BUTTON_NAME_LIST = (
  375. localeInfo.TARGET_BUTTON_WHISPER,
  376. localeInfo.TARGET_BUTTON_EXCHANGE,
  377. localeInfo.TARGET_BUTTON_FIGHT,
  378. localeInfo.TARGET_BUTTON_ACCEPT_FIGHT,
  379. localeInfo.TARGET_BUTTON_AVENGE,
  380. localeInfo.TARGET_BUTTON_FRIEND,
  381. localeInfo.TARGET_BUTTON_INVITE_PARTY,
  382. localeInfo.TARGET_BUTTON_LEAVE_PARTY,
  383. localeInfo.TARGET_BUTTON_EXCLUDE,
  384. localeInfo.TARGET_BUTTON_INVITE_GUILD,
  385. localeInfo.TARGET_BUTTON_DISMOUNT,
  386. localeInfo.TARGET_BUTTON_EXIT_OBSERVER,
  387. localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT,
  388. localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY,
  389. localeInfo.TARGET_BUTTON_BUILDING_DESTROY,
  390. localeInfo.TARGET_BUTTON_EMOTION_ALLOW,
  391. "VOTE_BLOCK_CHAT",
  392. )
  393.  
  394. GRADE_NAME = {
  395. nonplayer.PAWN : localeInfo.TARGET_LEVEL_PAWN,
  396. nonplayer.S_PAWN : localeInfo.TARGET_LEVEL_S_PAWN,
  397. nonplayer.KNIGHT : localeInfo.TARGET_LEVEL_KNIGHT,
  398. nonplayer.S_KNIGHT : localeInfo.TARGET_LEVEL_S_KNIGHT,
  399. nonplayer.BOSS : localeInfo.TARGET_LEVEL_BOSS,
  400. nonplayer.KING : localeInfo.TARGET_LEVEL_KING,
  401. }
  402. EXCHANGE_LIMIT_RANGE = 3000
  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.Gauge()
  414. hpGauge.SetParent(self)
  415. hpGauge.MakeGauge(130, "red")
  416. hpGauge.Hide()
  417.  
  418. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  419. hpDecimal = ui.TextLine()
  420. hpDecimal.SetParent(hpGauge)
  421. hpDecimal.SetDefaultFontName()
  422. hpDecimal.SetPosition(5, 5)
  423. hpDecimal.SetOutline()
  424. hpDecimal.Hide()
  425.  
  426. closeButton = ui.Button()
  427. closeButton.SetParent(self)
  428. closeButton.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  429. closeButton.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  430. closeButton.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  431. closeButton.SetPosition(30, 13)
  432.  
  433. if localeInfo.IsARABIC():
  434. hpGauge.SetPosition(55, 17)
  435. hpGauge.SetWindowHorizontalAlignLeft()
  436. closeButton.SetWindowHorizontalAlignLeft()
  437. else:
  438. hpGauge.SetPosition(175, 17)
  439. hpGauge.SetWindowHorizontalAlignRight()
  440. closeButton.SetWindowHorizontalAlignRight()
  441.  
  442. if app.ENABLE_SEND_TARGET_INFO:
  443. infoButton = ui.Button()
  444. infoButton.SetParent(self)
  445. infoButton.SetUpVisual("d:/ymir work/ui/pattern/q_mark_01.tga")
  446. infoButton.SetOverVisual("d:/ymir work/ui/pattern/q_mark_02.tga")
  447. infoButton.SetDownVisual("d:/ymir work/ui/pattern/q_mark_01.tga")
  448. infoButton.SetEvent(ui.__mem_func__(self.OnPressedInfoButton))
  449. infoButton.Hide()
  450.  
  451. infoBoard = self.InfoBoard()
  452. infoBoard.Hide()
  453. infoButton.showWnd = infoBoard
  454. closeButton.SetEvent(ui.__mem_func__(self.OnPressedCloseButton))
  455. closeButton.Show()
  456. if app.ENABLE_HIDE_COSTUME_SYSTEM:
  457. import uiToolTip
  458. self.toolTip = uiToolTip.ToolTip(160)
  459. self.toolTip.HideToolTip()
  460.  
  461. HideCostume = ui.ImageBox()
  462. HideCostume.SetParent(self)
  463. HideCostume.SetPosition(0,0)
  464. HideCostume.LoadImage("Modulo/HideCostume/button_show_0.tga")
  465. HideCostume.OnMouseOverIn = ui.__mem_func__(self.OnMouseOverInHideCostume)
  466. HideCostume.OnMouseOverOut = ui.__mem_func__(self.OnMouseOverOutHideCostume)
  467. HideCostume.Hide()
  468.  
  469. self.buttonDict = {}
  470. self.showingButtonList = []
  471. for buttonName in self.BUTTON_NAME_LIST:
  472. button = ui.Button()
  473. button.SetParent(self)
  474.  
  475. if localeInfo.IsARABIC():
  476. button.SetUpVisual("d:/ymir work/ui/public/Small_Button_01.sub")
  477. button.SetOverVisual("d:/ymir work/ui/public/Small_Button_02.sub")
  478. button.SetDownVisual("d:/ymir work/ui/public/Small_Button_03.sub")
  479. else:
  480. button.SetUpVisual("d:/ymir work/ui/public/small_thin_button_01.sub")
  481. button.SetOverVisual("d:/ymir work/ui/public/small_thin_button_02.sub")
  482. button.SetDownVisual("d:/ymir work/ui/public/small_thin_button_03.sub")
  483.  
  484. button.SetWindowHorizontalAlignCenter()
  485. button.SetText(buttonName)
  486. button.Hide()
  487. self.buttonDict[buttonName] = button
  488. self.showingButtonList.append(button)
  489.  
  490. self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER].SetEvent(ui.__mem_func__(self.OnWhisper))
  491. self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE].SetEvent(ui.__mem_func__(self.OnExchange))
  492. self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
  493. self.buttonDict[localeInfo.TARGET_BUTTON_ACCEPT_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
  494. self.buttonDict[localeInfo.TARGET_BUTTON_AVENGE].SetEvent(ui.__mem_func__(self.OnPVP))
  495. self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  496. self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  497. self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyInvite))
  498. self.buttonDict[localeInfo.TARGET_BUTTON_LEAVE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyExit))
  499. self.buttonDict[localeInfo.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))
  500.  
  501. self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_GUILD].SAFE_SetEvent(self.__OnGuildAddMember)
  502. self.buttonDict[localeInfo.TARGET_BUTTON_DISMOUNT].SAFE_SetEvent(self.__OnDismount)
  503. self.buttonDict[localeInfo.TARGET_BUTTON_EXIT_OBSERVER].SAFE_SetEvent(self.__OnExitObserver)
  504. self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT].SAFE_SetEvent(self.__OnViewEquipment)
  505. self.buttonDict[localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY].SAFE_SetEvent(self.__OnRequestParty)
  506. self.buttonDict[localeInfo.TARGET_BUTTON_BUILDING_DESTROY].SAFE_SetEvent(self.__OnDestroyBuilding)
  507. self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW].SAFE_SetEvent(self.__OnEmotionAllow)
  508.  
  509. self.buttonDict["VOTE_BLOCK_CHAT"].SetEvent(ui.__mem_func__(self.__OnVoteBlockChat))
  510.  
  511. self.name = name
  512. self.hpGauge = hpGauge
  513. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  514. self.hpDecimal = hpDecimal
  515. if app.ENABLE_SEND_TARGET_INFO:
  516. self.infoButton = infoButton
  517. if app.ENABLE_SEND_TARGET_INFO:
  518. self.vnum = 0
  519. self.closeButton = closeButton
  520. if app.ENABLE_HIDE_COSTUME_SYSTEM:
  521. self.HideCostume = HideCostume
  522. self.nameString = 0
  523. self.nameLength = 0
  524. self.vid = 0
  525. self.eventWhisper = None
  526. self.isShowButton = False
  527.  
  528. self.__Initialize()
  529. self.ResetTargetBoard()
  530.  
  531. def __del__(self):
  532. ui.ThinBoard.__del__(self)
  533.  
  534. print "===================================================== DESTROYED TARGET BOARD"
  535.  
  536. def __Initialize(self):
  537. self.nameString = ""
  538. self.nameLength = 0
  539. self.vid = 0
  540. if app.ENABLE_SEND_TARGET_INFO:
  541. self.vnum = 0
  542. self.isShowButton = False
  543.  
  544. def Destroy(self):
  545. self.eventWhisper = None
  546. if app.ENABLE_SEND_TARGET_INFO:
  547. self.infoButton = None
  548. self.closeButton = None
  549. self.showingButtonList = None
  550. self.buttonDict = None
  551. self.name = None
  552. self.hpGauge = None
  553. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  554. self.hpDecimal = None
  555. if app.ENABLE_HIDE_COSTUME_SYSTEM:
  556. self.HideCostume = None
  557. self.__Initialize()
  558. if app.ENABLE_SEND_TARGET_INFO:
  559. def RefreshMonsterInfoBoard(self):
  560. if not self.infoButton.showWnd.IsShow():
  561. return
  562.  
  563. self.infoButton.showWnd.Refresh()
  564.  
  565. def OnPressedInfoButton(self):
  566. net.SendTargetInfoLoad(player.GetTargetVID())
  567. if self.infoButton.showWnd.IsShow():
  568. self.infoButton.showWnd.Close()
  569. elif self.vnum != 0:
  570. self.infoButton.showWnd.Open(self, self.vnum)
  571.  
  572. def OnPressedCloseButton(self):
  573. player.ClearTarget()
  574. self.Close()
  575.  
  576. def Close(self):
  577. self.__Initialize()
  578. if app.ENABLE_SEND_TARGET_INFO:
  579. self.infoButton.Hide()
  580. self.infoButton.showWnd.Close()
  581. self.Hide()
  582.  
  583. def Open(self, vid, name):
  584. if vid:
  585. if not constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD():
  586. if not player.IsSameEmpire(vid):
  587. self.Hide()
  588. return
  589.  
  590. if vid != self.GetTargetVID():
  591. self.ResetTargetBoard()
  592. self.SetTargetVID(vid)
  593. self.SetTargetName(name)
  594.  
  595. if player.IsMainCharacterIndex(vid):
  596. self.__ShowMainCharacterMenu()
  597. elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  598. self.Hide()
  599. else:
  600. self.RefreshButton()
  601. self.Show()
  602. else:
  603. self.HideAllButton()
  604. self.__ShowButton(localeInfo.TARGET_BUTTON_WHISPER)
  605. self.__ShowButton("VOTE_BLOCK_CHAT")
  606. self.__ArrangeButtonPosition()
  607. self.SetTargetName(name)
  608. self.Show()
  609.  
  610. def Refresh(self):
  611. if self.IsShow():
  612. if self.IsShowButton():
  613. self.RefreshButton()
  614.  
  615. def RefreshByVID(self, vid):
  616. if vid == self.GetTargetVID():
  617. self.Refresh()
  618.  
  619. def RefreshByName(self, name):
  620. if name == self.GetTargetName():
  621. self.Refresh()
  622.  
  623. def __ShowMainCharacterMenu(self):
  624. canShow=0
  625.  
  626. self.HideAllButton()
  627.  
  628. if player.IsMountingHorse():
  629. self.__ShowButton(localeInfo.TARGET_BUTTON_DISMOUNT)
  630. canShow=1
  631.  
  632. if player.IsObserverMode():
  633. self.__ShowButton(localeInfo.TARGET_BUTTON_EXIT_OBSERVER)
  634. canShow=1
  635.  
  636. if canShow:
  637. self.__ArrangeButtonPosition()
  638. self.Show()
  639. else:
  640. self.Hide()
  641.  
  642. def __ShowNameOnlyMenu(self):
  643. self.HideAllButton()
  644.  
  645. def SetWhisperEvent(self, event):
  646. self.eventWhisper = event
  647.  
  648. def UpdatePosition(self):
  649. self.SetPosition(wndMgr.GetScreenWidth()/2 - self.GetWidth()/2, 10)
  650.  
  651. def ResetTargetBoard(self):
  652.  
  653. for btn in self.buttonDict.values():
  654. btn.Hide()
  655.  
  656. self.__Initialize()
  657.  
  658. self.name.SetPosition(0, 13)
  659. self.name.SetHorizontalAlignCenter()
  660. self.name.SetWindowHorizontalAlignCenter()
  661. self.hpGauge.Hide()
  662. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  663. self.hpDecimal.Hide()
  664. if app.ENABLE_HIDE_COSTUME_SYSTEM:
  665. self.HideCostume.Hide()
  666. if app.ENABLE_SEND_TARGET_INFO:
  667. self.infoButton.Hide()
  668. self.infoButton.showWnd.Close()
  669. self.SetSize(250, 40)
  670.  
  671. def SetTargetVID(self, vid):
  672. self.vid = vid
  673. if app.ENABLE_SEND_TARGET_INFO:
  674. self.vnum = 0
  675.  
  676. def SetEnemyVID(self, vid):
  677. self.SetTargetVID(vid)
  678. if app.ENABLE_SEND_TARGET_INFO:
  679. vnum = nonplayer.GetRaceNumByVID(vid)
  680.  
  681. name = chr.GetNameByVID(vid)
  682. level = nonplayer.GetLevelByVID(vid)
  683. grade = nonplayer.GetGradeByVID(vid)
  684.  
  685. nameFront = ""
  686. if -1 != level:
  687. nameFront += "Lv." + str(level) + " "
  688. if self.GRADE_NAME.has_key(grade):
  689. nameFront += "(" + self.GRADE_NAME[grade] + ") "
  690.  
  691. self.SetTargetName(nameFront + name)
  692. if app.ENABLE_SEND_TARGET_INFO:
  693. (textWidth, textHeight) = self.name.GetTextSize()
  694.  
  695. self.infoButton.SetPosition(textWidth + 25, 12)
  696. self.infoButton.SetWindowHorizontalAlignLeft()
  697.  
  698. self.vnum = vnum
  699. self.infoButton.Show()
  700. def GetTargetVID(self):
  701. return self.vid
  702.  
  703. def GetTargetName(self):
  704. return self.nameString
  705.  
  706. def SetTargetName(self, name):
  707. self.nameString = name
  708. self.nameLength = len(name)
  709. self.name.SetText(name)
  710.  
  711. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  712. def SetHP(self, hpPercentage, iMinHP, iMaxHP):
  713. if not self.hpGauge.IsShow():
  714. if app.ENABLE_VIEW_TARGET_PLAYER_HP:
  715. if self.showingButtonList:
  716. showingButtonCount = len(self.showingButtonList)
  717. else:
  718. showingButtonCount = 0
  719.  
  720. if showingButtonCount > 0:
  721. if chr.GetInstanceType(self.vid) == chr.INSTANCE_TYPE_PLAYER:
  722. self.SetSize(max(150 + 75 * 3, 7 * 75), self.GetHeight())
  723. else:
  724. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  725. else:
  726. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  727. else:
  728. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  729.  
  730. if localeInfo.IsARABIC():
  731. self.name.SetPosition( self.GetWidth()-23, 13)
  732. else:
  733. self.name.SetPosition(23, 13)
  734.  
  735. self.name.SetWindowHorizontalAlignLeft()
  736. self.name.SetHorizontalAlignLeft()
  737. self.hpGauge.Show()
  738. self.UpdatePosition()
  739.  
  740. self.hpGauge.SetPercentage(hpPercentage, 100)
  741. if app.ENABLE_VIEW_TARGET_DECIMAL_HP:
  742. 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])
  743. 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])
  744. self.hpDecimal.SetText(str(iMinHPText) + "/" + str(iMaxHPText))
  745. (textWidth, textHeight)=self.hpDecimal.GetTextSize()
  746. if localeInfo.IsARABIC():
  747. self.hpDecimal.SetPosition(120 / 2 + textWidth / 2, -13)
  748. else:
  749. self.hpDecimal.SetPosition(130 / 2 - textWidth / 2, -13)
  750.  
  751. self.hpDecimal.Show()
  752. else:
  753. def SetHP(self, hpPercentage):
  754. if not self.hpGauge.IsShow():
  755. if app.ENABLE_VIEW_TARGET_PLAYER_HP:
  756. if self.showingButtonList:
  757. showingButtonCount = len(self.showingButtonList)
  758. else:
  759. showingButtonCount = 0
  760.  
  761. if showingButtonCount > 0:
  762. if chr.GetInstanceType(self.GetTargetVID) != chr.INSTANCE_TYPE_PLAYER:
  763. if showingButtonCount != 1:
  764. self.SetSize(max(150, 7 * 75), self.GetHeight())
  765. else:
  766. self.SetSize(max(150, 2 * 75), self.GetHeight())
  767. else:
  768. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  769. else:
  770. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  771. else:
  772. self.SetSize(200 + 7*self.nameLength, self.GetHeight())
  773.  
  774. if localeInfo.IsARABIC():
  775. self.name.SetPosition( self.GetWidth()-23, 13)
  776. else:
  777. self.name.SetPosition(23, 13)
  778.  
  779. self.name.SetWindowHorizontalAlignLeft()
  780. self.name.SetHorizontalAlignLeft()
  781. self.hpGauge.Show()
  782. self.UpdatePosition()
  783.  
  784. if app.ENABLE_HIDE_COSTUME_SYSTEM:
  785. def SetCostumeHide(self, costumeHide):
  786. c_h=costumeHide.split("|")
  787. armor = c_h[0]
  788. hair = c_h[1]
  789.  
  790. if app.ENABLE_HIDE_COSTUME_SYSTEM_WEAPON_COSTUME:
  791. weapon = c_h[2]
  792.  
  793. if app.ENABLE_HIDE_COSTUME_SYSTEM_ACCE:
  794. acce = c_h[3]
  795.  
  796.  
  797. self.toolTip.ClearToolTip()
  798. self.toolTip.SetTitle("Hide Costume Info")
  799. self.toolTip.AppendTextLine("Armor: %s"%(self.GetInfoHide(armor)))
  800. self.toolTip.AppendTextLine("Hair: %s"%(self.GetInfoHide(hair)))
  801. if app.ENABLE_HIDE_COSTUME_SYSTEM_WEAPON_COSTUME:
  802. self.toolTip.AppendTextLine("Weapon: %s"%(self.GetInfoHide(weapon)))
  803. if app.ENABLE_HIDE_COSTUME_SYSTEM_ACCE:
  804. self.toolTip.AppendTextLine("Sash: %s"%(self.GetInfoHide(acce)))
  805.  
  806.  
  807. def GetInfoHide(self,index):
  808. if int(index) == 0:
  809. return "|cFF1EBD11|hShow"
  810. return "|cFFDB1A1A|hHide"
  811.  
  812. def OnMouseOverInHideCostume(self):
  813. self.toolTip.ShowToolTip()
  814.  
  815. def OnMouseOverOutHideCostume(self):
  816. self.toolTip.HideToolTip()
  817.  
  818. def ShowDefaultButton(self):
  819.  
  820. self.isShowButton = True
  821. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER])
  822. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
  823. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT])
  824. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW])
  825. for button in self.showingButtonList:
  826. button.Show()
  827.  
  828. def HideAllButton(self):
  829. self.isShowButton = False
  830. for button in self.showingButtonList:
  831. button.Hide()
  832. self.showingButtonList = []
  833.  
  834. def __ShowButton(self, name):
  835.  
  836. if not self.buttonDict.has_key(name):
  837. return
  838.  
  839. self.buttonDict[name].Show()
  840. self.showingButtonList.append(self.buttonDict[name])
  841.  
  842. def __HideButton(self, name):
  843.  
  844. if not self.buttonDict.has_key(name):
  845. return
  846.  
  847. button = self.buttonDict[name]
  848. button.Hide()
  849.  
  850. for btnInList in self.showingButtonList:
  851. if btnInList == button:
  852. self.showingButtonList.remove(button)
  853. break
  854.  
  855. def OnWhisper(self):
  856. if None != self.eventWhisper:
  857. self.eventWhisper(self.nameString)
  858.  
  859. def OnExchange(self):
  860. net.SendExchangeStartPacket(self.vid)
  861.  
  862. def OnPVP(self):
  863. net.SendChatPacket("/pvp %d" % (self.vid))
  864.  
  865. def OnAppendToMessenger(self):
  866. net.SendMessengerAddByVIDPacket(self.vid)
  867.  
  868. def OnPartyInvite(self):
  869. net.SendPartyInvitePacket(self.vid)
  870.  
  871. def OnPartyExit(self):
  872. net.SendPartyExitPacket()
  873.  
  874. def OnPartyRemove(self):
  875. net.SendPartyRemovePacketVID(self.vid)
  876.  
  877. def __OnGuildAddMember(self):
  878. net.SendGuildAddMemberPacket(self.vid)
  879.  
  880. def __OnDismount(self):
  881. net.SendChatPacket("/unmount")
  882.  
  883. def __OnExitObserver(self):
  884. net.SendChatPacket("/observer_exit")
  885.  
  886. def __OnViewEquipment(self):
  887. net.SendChatPacket("/view_equip " + str(self.vid))
  888.  
  889. def __OnRequestParty(self):
  890. net.SendChatPacket("/party_request " + str(self.vid))
  891.  
  892. def __OnDestroyBuilding(self):
  893. net.SendChatPacket("/build d %d" % (self.vid))
  894.  
  895. def __OnEmotionAllow(self):
  896. net.SendChatPacket("/emotion_allow %d" % (self.vid))
  897.  
  898. def __OnVoteBlockChat(self):
  899. cmd = "/vote_block_chat %s" % (self.nameString)
  900. net.SendChatPacket(cmd)
  901.  
  902. def OnPressEscapeKey(self):
  903. self.OnPressedCloseButton()
  904. return True
  905.  
  906. def IsShowButton(self):
  907. return self.isShowButton
  908.  
  909. def RefreshButton(self):
  910.  
  911. self.HideAllButton()
  912.  
  913. if chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  914. #self.__ShowButton(localeInfo.TARGET_BUTTON_BUILDING_DESTROY)
  915. #self.__ArrangeButtonPosition()
  916. return
  917.  
  918. if app.ENABLE_HIDE_COSTUME_SYSTEM:
  919. self.HideCostume.SetPosition(self.nameLength + 32, 14)
  920. self.HideCostume.SetWindowHorizontalAlignCenter()
  921. self.HideCostume.Show()
  922.  
  923. if player.IsPVPInstance(self.vid) or player.IsObserverMode():
  924. # PVP_INFO_SIZE_BUG_FIX
  925. self.SetSize(200 + 7*self.nameLength, 40)
  926. self.UpdatePosition()
  927. # END_OF_PVP_INFO_SIZE_BUG_FIX
  928. return
  929.  
  930. self.ShowDefaultButton()
  931.  
  932. if guild.MainPlayerHasAuthority(guild.AUTH_ADD_MEMBER):
  933. if not guild.IsMemberByName(self.nameString):
  934. if 0 == chr.GetGuildID(self.vid):
  935. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_GUILD)
  936.  
  937. if not messenger.IsFriendByName(self.nameString):
  938. self.__ShowButton(localeInfo.TARGET_BUTTON_FRIEND)
  939.  
  940. if player.IsPartyMember(self.vid):
  941.  
  942. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  943.  
  944. if player.IsPartyLeader(self.vid):
  945. self.__ShowButton(localeInfo.TARGET_BUTTON_LEAVE_PARTY)
  946. elif player.IsPartyLeader(player.GetMainCharacterIndex()):
  947. self.__ShowButton(localeInfo.TARGET_BUTTON_EXCLUDE)
  948.  
  949. else:
  950. if player.IsPartyMember(player.GetMainCharacterIndex()):
  951. if player.IsPartyLeader(player.GetMainCharacterIndex()):
  952. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  953. else:
  954. if chr.IsPartyMember(self.vid):
  955. self.__ShowButton(localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY)
  956. else:
  957. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  958.  
  959. if player.IsRevengeInstance(self.vid):
  960. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  961. self.__ShowButton(localeInfo.TARGET_BUTTON_AVENGE)
  962. elif player.IsChallengeInstance(self.vid):
  963. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  964. self.__ShowButton(localeInfo.TARGET_BUTTON_ACCEPT_FIGHT)
  965. elif player.IsCantFightInstance(self.vid):
  966. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  967.  
  968. if not player.IsSameEmpire(self.vid):
  969. self.__HideButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  970. self.__HideButton(localeInfo.TARGET_BUTTON_FRIEND)
  971. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  972.  
  973. distance = player.GetCharacterDistance(self.vid)
  974. if distance > self.EXCHANGE_LIMIT_RANGE:
  975. self.__HideButton(localeInfo.TARGET_BUTTON_EXCHANGE)
  976. self.__ArrangeButtonPosition()
  977.  
  978. self.__ArrangeButtonPosition()
  979.  
  980. def __ArrangeButtonPosition(self):
  981. showingButtonCount = len(self.showingButtonList)
  982. pos = -(showingButtonCount / 2) * 68
  983. if 0 == showingButtonCount % 2:
  984. pos += 34
  985.  
  986. for button in self.showingButtonList:
  987. button.SetPosition(pos, 33)
  988. pos += 68
  989.  
  990. if app.ENABLE_VIEW_TARGET_PLAYER_HP:
  991. if showingButtonCount <= 2:
  992. self.SetSize(max(150 + 125, showingButtonCount * 75), 65)
  993. else:
  994. self.SetSize(max(150, showingButtonCount * 75), 65)
  995. else:
  996. self.SetSize(max(150, showingButtonCount * 75), 65)
  997.  
  998. self.UpdatePosition()
  999.  
  1000. def OnUpdate(self):
  1001. if self.isShowButton:
  1002.  
  1003. exchangeButton = self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE]
  1004. distance = player.GetCharacterDistance(self.vid)
  1005.  
  1006. if distance < 0:
  1007. return
  1008.  
  1009. if exchangeButton.IsShow():
  1010. if distance > self.EXCHANGE_LIMIT_RANGE:
  1011. self.RefreshButton()
  1012.  
  1013. else:
  1014. if distance < self.EXCHANGE_LIMIT_RANGE:
  1015. self.RefreshButton()
  1016.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement