Guest User

Untitled

a guest
Feb 1st, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.90 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 event
  13. import uiToolTip
  14. import item
  15.  
  16. class TargetBoard(ui.ThinBoard):
  17.  
  18. BUTTON_NAME_LIST = (
  19. localeInfo.TARGET_BUTTON_WHISPER,
  20. localeInfo.TARGET_BUTTON_EXCHANGE,
  21. localeInfo.TARGET_BUTTON_FIGHT,
  22. localeInfo.TARGET_BUTTON_ACCEPT_FIGHT,
  23. localeInfo.TARGET_BUTTON_AVENGE,
  24. localeInfo.TARGET_BUTTON_FRIEND,
  25. localeInfo.TARGET_BUTTON_INVITE_PARTY,
  26. localeInfo.TARGET_BUTTON_LEAVE_PARTY,
  27. localeInfo.TARGET_BUTTON_EXCLUDE,
  28. localeInfo.TARGET_BUTTON_INVITE_GUILD,
  29. localeInfo.TARGET_BUTTON_DISMOUNT,
  30. localeInfo.TARGET_BUTTON_EXIT_OBSERVER,
  31. localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT,
  32. localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY,
  33. localeInfo.TARGET_BUTTON_BUILDING_DESTROY,
  34. localeInfo.TARGET_BUTTON_EMOTION_ALLOW,
  35. localeInfo.TARGET_BUTTON_DISCONNECT,
  36. "Zapisz Nick",
  37. "VOTE_BLOCK_CHAT",
  38. )
  39.  
  40. GRADE_NAME = {
  41. nonplayer.PAWN : localeInfo.TARGET_LEVEL_PAWN,
  42. nonplayer.S_PAWN : localeInfo.TARGET_LEVEL_S_PAWN,
  43. nonplayer.KNIGHT : localeInfo.TARGET_LEVEL_KNIGHT,
  44. nonplayer.S_KNIGHT : localeInfo.TARGET_LEVEL_S_KNIGHT,
  45. nonplayer.BOSS : localeInfo.TARGET_LEVEL_BOSS,
  46. nonplayer.KING : localeInfo.TARGET_LEVEL_KING,
  47. }
  48. EXCHANGE_LIMIT_RANGE = 3000
  49.  
  50. game = None
  51. gridSize = [9, 1]
  52.  
  53. def __init__(self):
  54. ui.ThinBoard.__init__(self)
  55.  
  56. self.inputDialog = None
  57.  
  58. tooltipItem = uiToolTip.ItemToolTip()
  59. tooltipItem.Hide()
  60. self.tooltipItem = tooltipItem
  61.  
  62. name = ui.TextLine()
  63. name.SetParent(self)
  64. name.SetDefaultFontName()
  65. name.SetOutline()
  66. name.Show()
  67.  
  68. level = ui.TextLine()
  69. level.SetParent(name)
  70. level.SetDefaultFontName()
  71. level.SetOutline()
  72. level.Hide()
  73.  
  74. hpGauge = ui.Gauge()
  75. hpGauge.SetParent(self)
  76. hpGauge.MakeGauge(130, "red")
  77. hpGauge.Hide()
  78.  
  79. closeButton = ui.Button()
  80. closeButton.SetParent(self)
  81. closeButton.SetUpVisual("d:/ymir work/ui/public/close_button_01.sub")
  82. closeButton.SetOverVisual("d:/ymir work/ui/public/close_button_02.sub")
  83. closeButton.SetDownVisual("d:/ymir work/ui/public/close_button_03.sub")
  84. closeButton.SetPosition(closeButton.GetWidth() + 10, 0)
  85. closeButton.SetWindowHorizontalAlignRight()
  86. closeButton.SetWindowVerticalAlignCenter()
  87. closeButton.SetEvent(ui.__mem_func__(self.OnPressedCloseButton))
  88. closeButton.Show()
  89.  
  90. self.buttonDict = {}
  91. self.showingButtonList = []
  92. for buttonName in self.BUTTON_NAME_LIST:
  93. button = ui.Button()
  94. button.SetParent(self)
  95.  
  96. if localeInfo.IsARABIC():
  97. button.SetUpVisual("d:/ymir work/ui/public/Small_Button_01.sub")
  98. button.SetOverVisual("d:/ymir work/ui/public/Small_Button_02.sub")
  99. button.SetDownVisual("d:/ymir work/ui/public/Small_Button_03.sub")
  100. else:
  101. button.SetUpVisual("d:/ymir work/ui/public/small_thin_button_01.sub")
  102. button.SetOverVisual("d:/ymir work/ui/public/small_thin_button_02.sub")
  103. button.SetDownVisual("d:/ymir work/ui/public/small_thin_button_03.sub")
  104.  
  105. button.SetWindowHorizontalAlignCenter()
  106. button.SetText(buttonName)
  107. button.Hide()
  108. self.buttonDict[buttonName] = button
  109. self.showingButtonList.append(button)
  110.  
  111. self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER].SetEvent(ui.__mem_func__(self.OnWhisper))
  112. self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE].SetEvent(ui.__mem_func__(self.OnExchange))
  113. self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
  114. self.buttonDict[localeInfo.TARGET_BUTTON_ACCEPT_FIGHT].SetEvent(ui.__mem_func__(self.OnPVP))
  115. self.buttonDict[localeInfo.TARGET_BUTTON_AVENGE].SetEvent(ui.__mem_func__(self.OnPVP))
  116. self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  117. self.buttonDict[localeInfo.TARGET_BUTTON_FRIEND].SetEvent(ui.__mem_func__(self.OnAppendToMessenger))
  118. self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyInvite))
  119. self.buttonDict[localeInfo.TARGET_BUTTON_LEAVE_PARTY].SetEvent(ui.__mem_func__(self.OnPartyExit))
  120. self.buttonDict[localeInfo.TARGET_BUTTON_EXCLUDE].SetEvent(ui.__mem_func__(self.OnPartyRemove))
  121.  
  122. self.buttonDict[localeInfo.TARGET_BUTTON_INVITE_GUILD].SAFE_SetEvent(self.__OnGuildAddMember)
  123. self.buttonDict[localeInfo.TARGET_BUTTON_DISMOUNT].SAFE_SetEvent(self.__OnDismount)
  124. self.buttonDict[localeInfo.TARGET_BUTTON_EXIT_OBSERVER].SAFE_SetEvent(self.__OnExitObserver)
  125. self.buttonDict[localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT].SAFE_SetEvent(self.__OnViewEquipment)
  126. self.buttonDict[localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY].SAFE_SetEvent(self.__OnRequestParty)
  127. self.buttonDict[localeInfo.TARGET_BUTTON_BUILDING_DESTROY].SAFE_SetEvent(self.__OnDestroyBuilding)
  128. self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW].SAFE_SetEvent(self.__OnEmotionAllow)
  129. self.buttonDict[localeInfo.TARGET_BUTTON_DISCONNECT].SAFE_SetEvent(self.__OnDisconnect)
  130. self.buttonDict["Zapisz Nick"].SAFE_SetEvent(self.__OnSaveNick)
  131.  
  132. self.buttonDict["VOTE_BLOCK_CHAT"].SetEvent(ui.__mem_func__(self.__OnVoteBlockChat))
  133.  
  134. dropButton = ui.Button()
  135. dropButton.SetParent(self)
  136. dropButton.SetUpVisual("kairos/target/q_mark_01.tga")
  137. dropButton.SetOverVisual("kairos/target/q_mark_02.tga")
  138. dropButton.SetDownVisual("kairos/target/q_mark_03.tga")
  139. dropButton.SetPosition(dropButton.GetWidth() + 26, 33)
  140. dropButton.SetWindowHorizontalAlignRight()
  141. dropButton.SetWindowVerticalAlignBottom()
  142. #dropButton.SetText("Wikipedia dropu")
  143. dropButton.SetEvent(ui.__mem_func__(self.__OnPressDropButton))
  144. dropButton.UpdateRect()
  145. dropButton.Hide()
  146. self.dropButton = dropButton
  147.  
  148. bonusName = ui.TextLine()
  149. bonusName.SetParent(dropButton)
  150. bonusName.SetWindowHorizontalAlignLeft()
  151. bonusName.SetHorizontalAlignLeft()
  152. bonusName.SetOutline()
  153. bonusName.SetPosition(-501, 6)
  154. bonusName.UpdateRect()
  155. bonusName.Hide()
  156. self.bonusName = bonusName
  157.  
  158. self.name = name
  159.  
  160. self.hpGauge = hpGauge
  161. self.closeButton = closeButton
  162. self.nameString = 0
  163. self.nameLength = 0
  164. self.vid = 0
  165. self.eventWhisper = None
  166. self.isShowButton = False
  167.  
  168. self.items = {}
  169. self.globalSlot = []
  170. self.gridSlot = None
  171. self.slotWindow = None
  172. self.game = None
  173.  
  174. self.__Initialize()
  175. self.__InitDropMob()
  176. self.ResetTargetBoard()
  177.  
  178. def __del__(self):
  179. ui.ThinBoard.__del__(self)
  180.  
  181. print "===================================================== DESTROYED TARGET BOARD"
  182.  
  183. def SetMainGame(self, game):
  184. self.game = game
  185.  
  186. def __Initialize(self):
  187. self.nameString = ""
  188. self.nameLength = 0
  189. self.vid = 0
  190. self.isShowButton = False
  191.  
  192. self.currentInfo = {}
  193. self.slots = []
  194.  
  195. if (self.inputDialog):
  196. self.inputDialog.Close()
  197.  
  198. def Destroy(self):
  199. self.dropButton = None
  200. self.eventWhisper = None
  201. self.closeButton = None
  202. self.bonusName = None
  203. self.showingButtonList = None
  204. self.buttonDict = None
  205. self.name = None
  206. self.hpGauge = None
  207.  
  208. self.__Initialize()
  209.  
  210. self.gridSlot = None
  211. self.slotWindow = None
  212. self.game = None
  213.  
  214. def OnPressedCloseButton(self):
  215. player.ClearTarget()
  216. self.Close()
  217.  
  218. def Close(self):
  219. self.__Initialize()
  220. self.__InitDropMob()
  221. self.Hide()
  222.  
  223. if (self.tooltipItem):
  224. self.tooltipItem.Hide()
  225.  
  226. def Open(self, vid, name):
  227. if vid:
  228. if not constInfo.GET_VIEW_OTHER_EMPIRE_PLAYER_TARGET_BOARD():
  229. if not player.IsSameEmpire(vid):
  230. self.Hide()
  231. return
  232.  
  233. if vid != self.GetTargetVID():
  234. self.ResetTargetBoard()
  235. self.SetTargetVID(vid)
  236. self.SetTargetName(name)
  237.  
  238. # Wyświetl informacje o dropie dla zaznaczonego potwora
  239. self.UpdateDropInfo() # Wywołaj tę metodę tutaj
  240.  
  241. if player.IsMainCharacterIndex(vid):
  242. self.__ShowMainCharacterMenu()
  243. elif chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  244. self.Hide()
  245. else:
  246. self.RefreshButton()
  247. self.Show()
  248. else:
  249. self.HideAllButton()
  250. self.__ShowButton(localeInfo.TARGET_BUTTON_WHISPER)
  251. self.__ShowButton("VOTE_BLOCK_CHAT")
  252. self.__ArrangeButtonPosition()
  253. self.SetTargetName(name)
  254. self.Show()
  255.  
  256. def Refresh(self):
  257. if self.IsShow():
  258. if self.IsShowButton():
  259. self.RefreshButton()
  260.  
  261. def RefreshByVID(self, vid):
  262. if vid == self.GetTargetVID():
  263. self.Refresh()
  264.  
  265. def RefreshByName(self, name):
  266. if name == self.GetTargetName():
  267. self.Refresh()
  268.  
  269. def __ShowMainCharacterMenu(self):
  270. canShow=0
  271.  
  272. self.HideAllButton()
  273.  
  274. if player.IsMountingHorse():
  275. self.__ShowButton(localeInfo.TARGET_BUTTON_DISMOUNT)
  276. canShow=1
  277.  
  278. if player.IsObserverMode():
  279. self.__ShowButton(localeInfo.TARGET_BUTTON_EXIT_OBSERVER)
  280. canShow=1
  281.  
  282. if canShow:
  283. self.__ArrangeButtonPosition()
  284. self.Show()
  285. else:
  286. self.Hide()
  287.  
  288. def __ShowNameOnlyMenu(self):
  289. self.HideAllButton()
  290.  
  291. def SetWhisperEvent(self, event):
  292. self.eventWhisper = event
  293.  
  294. def UpdatePosition(self):
  295. self.SetPosition(wndMgr.GetScreenWidth()/2 - self.GetWidth()/2, 10)
  296.  
  297. if (self.slotWindow):
  298. self.slotWindow.SetPosition(0, self.GetHeight() + 15)
  299.  
  300. def ResetTargetBoard(self):
  301. for btn in self.buttonDict.values():
  302. btn.Hide()
  303.  
  304. self.__Initialize()
  305. self.__InitDropMob()
  306.  
  307. self.name.SetPosition(0, 25)
  308. self.name.SetHorizontalAlignCenter()
  309. self.name.SetWindowHorizontalAlignCenter()
  310. self.hpGauge.Hide()
  311. self.dropButton.Hide()
  312. self.bonusName.Hide()
  313.  
  314. #self.dropButton.SetText("Wikipedia Dropu")
  315. self.dropButton.SetUp()
  316. self.dropButton.Enable()
  317.  
  318. self.SetSize(400, 40)
  319.  
  320. def SetTargetVID(self, vid):
  321. self.vid = vid
  322.  
  323. def SetEnemyVID(self, vid):
  324. self.SetTargetVID(vid)
  325.  
  326. name = chr.GetNameByVID(vid)
  327. level = nonplayer.GetLevelByVID(vid)
  328. grade = nonplayer.GetGradeByVID(vid)
  329.  
  330. nameFront = ""
  331. if -1 != level:
  332. nameFront += "Poz." + str(level) + " "
  333. if self.GRADE_NAME.has_key(grade):
  334. nameFront += "(" + self.GRADE_NAME[grade] + ") "
  335.  
  336. self.SetTargetName(nameFront + name)
  337.  
  338. def GetTargetVID(self):
  339. return self.vid
  340.  
  341. def GetTargetName(self):
  342. return self.nameString
  343.  
  344. def SetTargetName(self, name):
  345. self.nameString = name
  346. self.nameLength = len(name)
  347. self.name.SetText(name)
  348.  
  349. def SetHP(self, hpPercentage):
  350. if not self.hpGauge.IsShow():
  351. def __getAI(flag):
  352. name = ['Zwierzeta', 'Nieumarle', 'Diably', 'Ludzie', 'Orki', 'Mistyki', 'Odpornosc na Lod', 'Odpornosc na Ogien']
  353. flags = []
  354. for i in xrange(7, -1, -1): # Zaczynamy od 7, bo mamy 8 elementów w liście 'name'
  355. if (flag & (1 << i)): # Sprawdzamy, czy bit na pozycji i jest ustawiony
  356. try:
  357. flags.insert(0, "%s" % name[i]) # Dodajemy flagi na początek listy
  358. except:
  359. continue
  360. return flags
  361.  
  362.  
  363. flags = __getAI(nonplayer.GetRaceFlagByVID(self.GetTargetVID()))
  364. if len(flags) == 0:
  365. self.bonusName.SetText("Bonusy: Brak")
  366. else:
  367. self.bonusName.SetText("Bonusy: " + ",".join(flags))
  368.  
  369. self.bonusName.UpdateRect()
  370. self.bonusName.Show()
  371.  
  372.  
  373. self.SetSize(550, 48)
  374.  
  375. self.name.SetPosition(6, 9)
  376. self.name.SetWindowHorizontalAlignLeft()
  377. self.name.SetHorizontalAlignLeft()
  378.  
  379. self.hpGauge.Show()
  380. self.closeButton.Show()
  381. self.dropButton.Show()
  382.  
  383. self.UpdatePosition()
  384.  
  385. self.name.SetText(self.nameString + ("[%.2f%%]" % (float(hpPercentage))))
  386.  
  387. self.hpGauge.SetPosition(267, 35)
  388. self.hpGauge.SetWindowVerticalAlignBottom()
  389. self.hpGauge.UpdateRect()
  390. self.hpGauge.MakeGauge(230, "red")
  391. self.hpGauge.SetPercentage(hpPercentage, 100)
  392.  
  393. def ShowDefaultButton(self):
  394.  
  395. self.isShowButton = TRUE
  396. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_WHISPER])
  397. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE])
  398. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_FIGHT])
  399. self.showingButtonList.append(self.buttonDict[localeInfo.TARGET_BUTTON_EMOTION_ALLOW])
  400. if str(player.GetName())[0] == "[":
  401. # self.__ShowButton(localeInfo.TARGET_BUTTON_VIEW_EQUIPMENT)
  402. self.__ShowButton(localeInfo.TARGET_BUTTON_DISCONNECT)
  403. self.__ShowButton("Zapisz Nick")
  404.  
  405. for button in self.showingButtonList:
  406. button.Show()
  407.  
  408. def HideAllButton(self):
  409. self.isShowButton = FALSE
  410. for button in self.showingButtonList:
  411. button.Hide()
  412. self.showingButtonList = []
  413.  
  414. def __ShowButton(self, name):
  415.  
  416. if not self.buttonDict.has_key(name):
  417. return
  418.  
  419. self.buttonDict[name].Show()
  420. self.showingButtonList.append(self.buttonDict[name])
  421.  
  422. def __HideButton(self, name):
  423.  
  424. if not self.buttonDict.has_key(name):
  425. return
  426.  
  427. button = self.buttonDict[name]
  428. button.Hide()
  429.  
  430. for btnInList in self.showingButtonList:
  431. if btnInList == button:
  432. self.showingButtonList.remove(button)
  433. break
  434.  
  435. def OnWhisper(self):
  436. if None != self.eventWhisper:
  437. self.eventWhisper(self.nameString)
  438.  
  439. def OnExchange(self):
  440. net.SendExchangeStartPacket(self.vid)
  441.  
  442. def OnPVP(self):
  443. net.SendChatPacket("/pvp %d" % (self.vid))
  444.  
  445. def OnAppendToMessenger(self):
  446. net.SendMessengerAddByVIDPacket(self.vid)
  447.  
  448. def OnPartyInvite(self):
  449. net.SendPartyInvitePacket(self.vid)
  450.  
  451. def OnPartyExit(self):
  452. net.SendPartyExitPacket()
  453.  
  454. def OnPartyRemove(self):
  455. net.SendPartyRemovePacket(self.vid)
  456.  
  457. def __OnGuildAddMember(self):
  458. net.SendGuildAddMemberPacket(self.vid)
  459.  
  460. def __OnDismount(self):
  461. net.SendChatPacket("/unmount")
  462.  
  463. def __OnExitObserver(self):
  464. net.SendChatPacket("/observer_exit")
  465.  
  466. def __OnViewEquipment(self):
  467. net.SendChatPacket("/view_equip " + str(self.vid))
  468.  
  469. def __OnRequestParty(self):
  470. net.SendChatPacket("/party_request " + str(self.vid))
  471.  
  472. def __OnDestroyBuilding(self):
  473. net.SendChatPacket("/build d %d" % (self.vid))
  474.  
  475. def __OnEmotionAllow(self):
  476. net.SendChatPacket("/emotion_allow %d" % (self.vid))
  477.  
  478. def __OnVoteBlockChat(self):
  479. cmd = "/vote_block_chat %s" % (self.nameString)
  480. net.SendChatPacket(cmd)
  481.  
  482. def __OnDisconnect(self):
  483. net.SendChatPacket("/dc %s" % self.nameString)
  484.  
  485. def __OnSaveNick(self):
  486. import os
  487.  
  488. if os.path.exists("ignore.cfg"):
  489. SaveNickTest = open("ignore.cfg", "r")
  490. SaveNickList = SaveNickTest.read()
  491. SaveNickPlayer = SaveNickList.split(",\n")
  492. SaveNickTest.close()
  493. for i in xrange(str(SaveNickList).count(",\n")):
  494. if str(SaveNickPlayer[i]) != self.nameString:
  495. pass
  496. else:
  497. return
  498.  
  499. SaveNick = open("save_nick.cfg", "a")
  500. SaveNick.write("%s,\n" % self.nameString)
  501. SaveNick.close()
  502. else:
  503. SaveNick = open("ignore.cfg", "w+")
  504. SaveNick.write("%s,\n" % self.nameString)
  505. SaveNick.close()
  506.  
  507. def OnPressEscapeKey(self):
  508. if (self.inputDialog):
  509. self.inputDialog.Close()
  510. self.OnPressedCloseButton()
  511. return True
  512.  
  513. def IsShowButton(self):
  514. return self.isShowButton
  515.  
  516. def RefreshButton(self):
  517.  
  518. self.HideAllButton()
  519.  
  520. if chr.INSTANCE_TYPE_BUILDING == chr.GetInstanceType(self.vid):
  521. #self.__ShowButton(localeInfo.TARGET_BUTTON_BUILDING_DESTROY)
  522. #self.__ArrangeButtonPosition()
  523. return
  524.  
  525. if player.IsPVPInstance(self.vid) or player.IsObserverMode():
  526. # PVP_INFO_SIZE_BUG_FIX
  527. self.SetSize(200 + 7*self.nameLength, 40)
  528. self.UpdatePosition()
  529. # END_OF_PVP_INFO_SIZE_BUG_FIX
  530. return
  531.  
  532. self.ShowDefaultButton()
  533.  
  534. if guild.MainPlayerHasAuthority(guild.AUTH_ADD_MEMBER):
  535. if not guild.IsMemberByName(self.nameString):
  536. if 0 == chr.GetGuildID(self.vid):
  537. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_GUILD)
  538.  
  539. if not messenger.IsFriendByName(self.nameString):
  540. self.__ShowButton(localeInfo.TARGET_BUTTON_FRIEND)
  541.  
  542. if player.IsPartyMember(self.vid):
  543.  
  544. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  545.  
  546. if player.IsPartyLeader(self.vid):
  547. self.__ShowButton(localeInfo.TARGET_BUTTON_LEAVE_PARTY)
  548. elif player.IsPartyLeader(player.GetMainCharacterIndex()):
  549. self.__ShowButton(localeInfo.TARGET_BUTTON_EXCLUDE)
  550.  
  551. else:
  552. if player.IsPartyMember(player.GetMainCharacterIndex()):
  553. if player.IsPartyLeader(player.GetMainCharacterIndex()):
  554. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  555. else:
  556. if chr.IsPartyMember(self.vid):
  557. self.__ShowButton(localeInfo.TARGET_BUTTON_REQUEST_ENTER_PARTY)
  558. else:
  559. self.__ShowButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  560.  
  561. if player.IsRevengeInstance(self.vid):
  562. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  563. self.__ShowButton(localeInfo.TARGET_BUTTON_AVENGE)
  564. elif player.IsChallengeInstance(self.vid):
  565. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  566. self.__ShowButton(localeInfo.TARGET_BUTTON_ACCEPT_FIGHT)
  567. elif player.IsCantFightInstance(self.vid):
  568. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  569.  
  570. if not player.IsSameEmpire(self.vid):
  571. self.__HideButton(localeInfo.TARGET_BUTTON_INVITE_PARTY)
  572. self.__HideButton(localeInfo.TARGET_BUTTON_FRIEND)
  573. self.__HideButton(localeInfo.TARGET_BUTTON_FIGHT)
  574.  
  575. distance = player.GetCharacterDistance(self.vid)
  576. if distance > self.EXCHANGE_LIMIT_RANGE:
  577. self.__HideButton(localeInfo.TARGET_BUTTON_EXCHANGE)
  578. self.__ArrangeButtonPosition()
  579.  
  580. self.__ArrangeButtonPosition()
  581.  
  582. def __ArrangeButtonPosition(self):
  583. showingButtonCount = len(self.showingButtonList)
  584.  
  585. pos = -(showingButtonCount / 2) * 68
  586. if 0 == showingButtonCount % 2:
  587. pos += 34
  588.  
  589. for button in self.showingButtonList:
  590. button.SetPosition(pos, 33)
  591. pos += 68
  592.  
  593. self.SetSize(max(150, showingButtonCount * 75), 65)
  594. self.UpdatePosition()
  595.  
  596. def __OnPressDropButton(self):
  597. if (self.slotWindow):
  598. if (self.slotWindow.IsShow()):
  599. self.slotWindow.Hide()
  600. else:
  601. self.ResetGridSlot()
  602. self.UpdateDropInfo()
  603.  
  604. def UpdateDropInfo(self):
  605. if self.vid:
  606. mobVnum = nonplayer.GetVnumByVID(self.vid)
  607.  
  608. if mobVnum in constInfo.mobDropEmpty:
  609. if (self.dropButton):
  610. #self.dropButton.SetText("Brak informacji")
  611. self.dropButton.Down()
  612. self.dropButton.Disable()
  613. return False
  614.  
  615. for vnum, lsit in constInfo.mobDropTable.items():
  616. if vnum == mobVnum:
  617.  
  618. self.slotWindow.Show()
  619.  
  620. self.UpdateItems()
  621. return True
  622.  
  623. net.SendRequestInformationDropItem()
  624. return True
  625.  
  626. def UpdateItems(self):
  627. self.currentInfo = {}
  628. self.slots = [0] * (self.gridSize[0]*self.gridSize[1])
  629.  
  630. mobVnum = nonplayer.GetVnumByVID(self.vid)
  631. mobDropTable = constInfo.mobDropTable
  632.  
  633. table = mobDropTable.get(mobVnum)
  634. if (table):
  635. for _slot in xrange(self.gridSize[0] * self.gridSize[1]):
  636. self.gridSlot.ClearSlot(_slot)
  637. self.gridSlot.RefreshSlot()
  638.  
  639. for data in table:
  640. self.currentInfo[data[0]] = data[1]
  641.  
  642. for vnum in sorted(self.currentInfo.keys()):
  643. self.AddDropItem(vnum, self.currentInfo[vnum])
  644.  
  645. def AddDropItem(self, itemVnum, count):
  646. if self.gridSlot:
  647. item.SelectItem(itemVnum)
  648. (x, y) = item.GetItemSize()
  649.  
  650. iPos = self.findBlank(y);
  651.  
  652. while (iPos == -1):
  653. self.ExtendGridSlot()
  654. iPos = self.findBlank(y)
  655.  
  656. if (iPos != -1):
  657. self.gridSlot.SetItemSlot(iPos, itemVnum, 0)
  658. for z in xrange(y):
  659. self.slots[iPos + (self.gridSize[0]*z)] = itemVnum
  660.  
  661. self.items[iPos] = [itemVnum, 0]
  662. self.gridSlot.RefreshSlot()
  663.  
  664. def findBlank(self, size):
  665. pos = -1
  666. if size == 1:
  667. for x in xrange(self.gridSize[0]*self.gridSize[1]):
  668. if self.slots[x] == 0:
  669. pos = x
  670. break
  671. elif size == 2:
  672. for x in xrange(self.gridSize[0]*self.gridSize[1]):
  673. if (x+self.gridSize[0]) >= self.gridSize[0]*self.gridSize[1]:
  674. break
  675. else:
  676. if self.slots[x] == 0 and self.slots[x+self.gridSize[0]] == 0:
  677. pos = x
  678. break
  679. elif size == 3:
  680. for x in xrange(self.gridSize[0]*self.gridSize[1]):
  681. if (x+self.gridSize[0]+self.gridSize[0]) >= self.gridSize[0]*self.gridSize[1] or (x+self.gridSize[0]) >= self.gridSize[0]*self.gridSize[1]:
  682. break
  683. else:
  684. if self.slots[x] == 0 and self.slots[x+self.gridSize[0]] == 0 and self.slots[x+self.gridSize[0]+self.gridSize[0]] == 0:
  685. pos = x
  686. break
  687. return pos
  688.  
  689. def ResetGridSlot(self):
  690. self.gridSize[1] = 1
  691. self.slots = [0] * (self.gridSize[0] * self.gridSize[1])
  692. self.items = {}
  693. self.slotWindow.SetSize(10 * 32 + 2 * 5, self.gridSize[1] * 32 + 2 * 5)
  694. self.slotWindow.SetWindowHorizontalAlignCenter()
  695. self.slotWindow.UpdateRect()
  696. self.gridSlot = ui.GridSlotWindow()
  697. self.gridSlot.SetParent(self.slotWindow)
  698. self.gridSlot.SetPosition(0, 0)
  699. self.gridSlot.SetWindowHorizontalAlignCenter()
  700. self.gridSlot.SetWindowVerticalAlignCenter()
  701. self.gridSlot.ArrangeSlot(0, self.gridSize[0], self.gridSize[1], 32, 32, 3, 0)
  702. self.gridSlot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
  703. self.gridSlot.SetOverInItemEvent(ui.__mem_func__(self.__OnOverInItem))
  704. self.gridSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OverOutItem))
  705. self.gridSlot.UpdateRect()
  706. self.gridSlot.Show()
  707. self.gridSlot.RefreshSlot()
  708.  
  709. def ExtendGridSlot(self):
  710. self.gridSize[1] = self.gridSize[1] + 1
  711. self.slots = self.slots + ([0] * self.gridSize[0])
  712. self.slotWindow.SetSize(10 * 32 + 2 * 5, self.gridSize[1] * 32 + 2 * 5)
  713. self.slotWindow.SetWindowHorizontalAlignCenter()
  714. self.slotWindow.UpdateRect()
  715. self.gridSlot = ui.GridSlotWindow()
  716. self.gridSlot.SetParent(self.slotWindow)
  717. self.gridSlot.SetPosition(0, 0)
  718. self.gridSlot.SetWindowHorizontalAlignCenter()
  719. self.gridSlot.SetWindowVerticalAlignCenter()
  720. self.gridSlot.ArrangeSlot(0, self.gridSize[0], self.gridSize[1], 32, 32, 3, 0)
  721. self.gridSlot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
  722. self.gridSlot.SetOverInItemEvent(ui.__mem_func__(self.__OnOverInItem))
  723. self.gridSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OverOutItem))
  724. for x in xrange(self.gridSize[0] * self.gridSize[1]):
  725. if self.items.get(x) > 0:
  726. self.gridSlot.SetItemSlot(x, self.items.get(x)[0], self.items.get(x)[1])
  727. self.gridSlot.UpdateRect()
  728. self.gridSlot.Show()
  729. self.gridSlot.RefreshSlot()
  730.  
  731. def __OnOverInItem(self, slotIndex):
  732. if (self.items.get(slotIndex, (-1, -1))[0] > 0):
  733. self.tooltipItem.SetItemToolTip(self.items[slotIndex][0])
  734. self.tooltipItem.Show()
  735.  
  736. def __OverOutItem(self):
  737. if (self.tooltipItem):
  738. self.tooltipItem.HideToolTip()
  739.  
  740. def __InitDropMob(self):
  741. self.items = {}
  742. self.globalSlot = {}
  743.  
  744. if (self.game):
  745. slotWindow = ui.ThinBoard()
  746. slotWindow.SetParent(self.game)
  747. slotWindow.SetSize(10 * 32 + 2 * 5, self.gridSize[1] * 32 + 2 * 5)
  748. slotWindow.SetWindowHorizontalAlignCenter()
  749. slotWindow.UpdateRect()
  750. slotWindow.Hide()
  751. self.slotWindow = slotWindow
  752. gridSlot = ui.GridSlotWindow()
  753. gridSlot.SetParent(self.slotWindow)
  754. gridSlot.SetPosition(0, 0)
  755. gridSlot.SetWindowHorizontalAlignCenter()
  756. gridSlot.SetWindowVerticalAlignCenter()
  757. gridSlot.ArrangeSlot(0, self.gridSize[0], self.gridSize[1], 32, 32, 3, 0)
  758. gridSlot.SetSlotBaseImage("d:/ymir work/ui/public/Slot_Base.sub", 1.0, 1.0, 1.0, 1.0)
  759. gridSlot.SetOverInItemEvent(ui.__mem_func__(self.__OnOverInItem))
  760. gridSlot.SetOverOutItemEvent(ui.__mem_func__(self.__OverOutItem))
  761. gridSlot.UpdateRect()
  762. gridSlot.Show()
  763.  
  764. for _slot in xrange(self.gridSize[0] * self.gridSize[1]):
  765. gridSlot.ClearSlot(_slot)
  766. self.items[_slot] = -1
  767. gridSlot.RefreshSlot()
  768.  
  769. self.gridSlot = gridSlot
  770.  
  771. def OnUpdate(self):
  772. if self.isShowButton:
  773.  
  774. exchangeButton = self.buttonDict[localeInfo.TARGET_BUTTON_EXCHANGE]
  775. distance = player.GetCharacterDistance(self.vid)
  776.  
  777. if distance < 0:
  778. return
  779.  
  780. if exchangeButton.IsShow():
  781. if distance > self.EXCHANGE_LIMIT_RANGE:
  782. self.RefreshButton()
  783.  
  784. else:
  785. if distance < self.EXCHANGE_LIMIT_RANGE:
  786. self.RefreshButton()
  787.  
  788. if (self.vid):
  789. mobVnum = nonplayer.GetVnumByVID(self.vid)
  790. if (mobVnum):
  791. if (mobVnum in constInfo.mobDropEmpty):
  792. if (self.dropButton):
  793. #self.dropButton.SetText("Brak informacji")
  794. self.dropButton.Down()
  795. self.dropButton.Disable()
  796.  
Add Comment
Please, Sign In to add comment