Advertisement
Guest User

Untitled

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