epsezoya

uitarget

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