Guest User

Untitled

a guest
Sep 4th, 2016
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 39.29 KB | None | 0 0
  1. import ui
  2. import player
  3. import mouseModule
  4. import net
  5. import app
  6. import snd
  7. import item
  8. import player
  9. import chat
  10. import grp
  11. import uiScriptLocale
  12. import uiRefine
  13. import uiAttachMetin
  14. import uiPickMoney
  15. import uiCommon
  16. import uiPrivateShopBuilder # ItemMove avoid personal store heat during
  17. import uiOfflineShopBuilder
  18. import uiOfflineShop
  19. import localeInfo
  20. import constInfo
  21. import ime
  22. import event
  23. from bonusswitcher import Bot
  24. from uitp import TeleportDialog
  25. import uibonus
  26. from uibiolog import BiologDialog
  27.  
  28.  
  29.  
  30. ITEM_MALL_BUTTON_ENABLE = TRUE
  31.  
  32. CHECK_ACTIVE_PICKUP = 0
  33.  
  34. ITEM_FLAG_APPLICABLE = 1 << 14
  35.  
  36. class CostumeWindow(ui.ScriptWindow):
  37.  
  38. def __init__(self, wndInventory):
  39. import exception
  40.  
  41. if not app.ENABLE_COSTUME_SYSTEM:
  42. exception.Abort("What do you do?")
  43. return
  44.  
  45. if not wndInventory:
  46. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  47. return
  48.  
  49. ui.ScriptWindow.__init__(self)
  50.  
  51. self.isLoaded = 0
  52. self.wndInventory = wndInventory;
  53.  
  54. self.__LoadWindow()
  55.  
  56. def __del__(self):
  57. ui.ScriptWindow.__del__(self)
  58.  
  59. def Show(self):
  60. self.__LoadWindow()
  61. self.RefreshCostumeSlot()
  62.  
  63. ui.ScriptWindow.Show(self)
  64.  
  65. def Close(self):
  66. self.Hide()
  67.  
  68. def __LoadWindow(self):
  69. if self.isLoaded == 1:
  70. return
  71.  
  72. self.isLoaded = 1
  73.  
  74. try:
  75. pyScrLoader = ui.PythonScriptLoader()
  76. pyScrLoader.LoadScriptFile(self, "UIScript/CostumeWindow.py")
  77. except:
  78. import exception
  79. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  80.  
  81. try:
  82. wndEquip = self.GetChild("CostumeSlot")
  83. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  84. costume = self.GetChild("costume")
  85. self.costume = costume
  86.  
  87.  
  88. except:
  89. import exception
  90. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  91.  
  92. ## Equipment
  93. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  94. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  95. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  96. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  97. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  98. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  99. self.costume.SetEvent(ui.__mem_func__(self.__costume))
  100.  
  101. self.wndEquip = wndEquip
  102.  
  103. def RefreshCostumeSlot(self):
  104. getItemVNum=player.GetItemIndex
  105.  
  106. for i in xrange(item.COSTUME_SLOT_COUNT):
  107. slotNumber = item.COSTUME_SLOT_START + i
  108. self.wndEquip.SetItemSlot(slotNumber, getItemVNum(slotNumber), 0)
  109.  
  110. self.wndEquip.RefreshSlot()
  111.  
  112. def __costume(self):
  113. constInfo.costume = 1
  114. event.QuestButtonClick(int(constInfo.QUEST_INDEX_06))
  115. net.SendQuestInputStringPacket(str(constInfo.costume))
  116.  
  117.  
  118. class InventoryWindow(ui.ScriptWindow):
  119.  
  120. USE_TYPE_TUPLE = ("USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ATTRIBUTE2", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET")
  121.  
  122. def __init__(self):
  123. ui.ScriptWindow.__init__(self)
  124. constInfo.NEWITEMS = constInfo.SAVENEWITEMS
  125. self.questionDialog = None
  126. self.tooltipItem = None
  127. self.sellingSlotNumber = -1
  128. self.isLoaded = 0
  129. self.isOpenedCostumeWindowWhenClosingInventory = 0 # When closing inventory Costume whether this was an open -_-; Naming ¤¸¤µ
  130. self.switchbot = Bot()
  131. self.switchbot.Hide()
  132. self.teleport = TeleportDialog()
  133. self.teleport.Hide()
  134. self.biolog = BiologDialog()
  135. self.__LoadWindow()
  136.  
  137.  
  138. def __del__(self):
  139. ui.ScriptWindow.__del__(self)
  140.  
  141. def Show(self):
  142. self.__LoadWindow()
  143.  
  144. ui.ScriptWindow.Show(self)
  145.  
  146. # Do so even when you close your inventory Costume Costume as heat when it is open iteotdamyeon open inventory
  147. if self.isOpenedCostumeWindowWhenClosingInventory and self.wndCostume:
  148. self.wndCostume.Show()
  149.  
  150. def BindInterfaceClass(self, interface):
  151. self.interface = interface
  152.  
  153. def __LoadWindow(self):
  154. if self.isLoaded == 1:
  155. return
  156.  
  157. self.isLoaded = 1
  158.  
  159. try:
  160. pyScrLoader = ui.PythonScriptLoader()
  161.  
  162. if ITEM_MALL_BUTTON_ENABLE:
  163. pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "InventoryWindow.py")
  164. else:
  165. pyScrLoader.LoadScriptFile(self, "UIScript/InventoryWindow.py")
  166. except:
  167. import exception
  168. exception.Abort("InventoryWindow.LoadWindow.LoadObject")
  169.  
  170. try:
  171. wndItem = self.GetChild("ItemSlot")
  172. wndEquip = self.GetChild("EquipmentSlot")
  173. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  174. self.wndMoney = self.GetChild("Money")
  175. self.wndMoneySlot = self.GetChild("Money_Slot")
  176. self.wndMds = self.GetChild("Mds")
  177. self.wndMdsSlot = self.GetChild("Mds_Slot")
  178. self.mallButton = self.GetChild2("MallButton")
  179. self.costumeButton = self.GetChild2("CostumeButton")
  180. self.offlineShopButton = self.GetChild2("OfflineShopButton")
  181. self.AntyExp = self.GetChild2("AntyExp")
  182. self.poli = self.GetChild2("poli")
  183. self.bs = self.GetChild2("bs")
  184. self.bonusinfo = self.GetChild2("bonusinfo")
  185. self.podnoszenie = self.GetChild2("podnoszenie")
  186. self.Teleport = self.GetChild2("Teleport")
  187. self.biolog = self.GetChild2("zapis")
  188. self.biolog.textedit = self.GetChild2("btext")
  189. self.biolog.itemjaki = self.GetChild2("bitem")
  190. self.biolog.index = self.GetChild2("bindex")
  191. self.biolog.st = self.GetChild2("bstatus")
  192. self.biolog.input = self.GetChild2("czy_to_buttonik")
  193. self.__Inputget3 = self.GetChild2("getBiologinputbegin")
  194. self.__Inputget4 = self.GetChild2("getBiologinputend")
  195.  
  196.  
  197.  
  198. self.inventoryTab = []
  199. self.inventoryTab.append(self.GetChild("Inventory_Tab_01"))
  200. self.inventoryTab.append(self.GetChild("Inventory_Tab_02"))
  201. self.inventoryTab.append(self.GetChild("Inventory_Tab_03"))
  202. self.inventoryTab.append(self.GetChild("Inventory_Tab_04"))
  203.  
  204. self.equipmentTab = []
  205. self.equipmentTab.append(self.GetChild("Equipment_Tab_01"))
  206. self.equipmentTab.append(self.GetChild("Equipment_Tab_02"))
  207.  
  208. # if self.costumeButton and not app.ENABLE_COSTUME_SYSTEM:
  209. # self.costumeButton.Hide()
  210. # self.costumeButton.Destroy()
  211. # self.costumeButton = 0
  212.  
  213. except:
  214. import exception
  215. exception.Abort("InventoryWindow.LoadWindow.BindObject")
  216.  
  217. ## Item
  218. wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  219. wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  220. wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  221. wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  222. wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  223. wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  224.  
  225. ## Equipment
  226. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  227. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  228. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  229. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  230. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  231. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  232.  
  233. ## PickMoneyDialog
  234. dlgPickMoney = uiPickMoney.PickMoneyDialog()
  235. dlgPickMoney.LoadDialog()
  236. dlgPickMoney.Hide()
  237.  
  238. ## RefineDialog
  239. self.refineDialog = uiRefine.RefineDialog()
  240. self.refineDialog.Hide()
  241.  
  242. ## AttachMetinDialog
  243. self.attachMetinDialog = uiAttachMetin.AttachMetinDialog()
  244. self.attachMetinDialog.Hide()
  245.  
  246. ## MoneySlot
  247. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
  248.  
  249. self.inventoryTab[0].SetEvent(lambda arg=0: self.SetInventoryPage(arg))
  250. self.inventoryTab[1].SetEvent(lambda arg=1: self.SetInventoryPage(arg))
  251. self.inventoryTab[2].SetEvent(lambda arg=2: self.SetInventoryPage(arg))
  252. self.inventoryTab[3].SetEvent(lambda arg=3: self.SetInventoryPage(arg))
  253. self.inventoryTab[0].Down()
  254. self.inventoryPageIndex = 0
  255.  
  256. self.equipmentTab[0].SetEvent(lambda arg=0: self.SetEquipmentPage(arg))
  257. self.equipmentTab[1].SetEvent(lambda arg=1: self.SetEquipmentPage(arg))
  258. self.equipmentTab[0].Down()
  259. self.equipmentTab[0].Hide()
  260. self.equipmentTab[1].Hide()
  261.  
  262. self.wndItem = wndItem
  263. self.wndEquip = wndEquip
  264. self.dlgPickMoney = dlgPickMoney
  265.  
  266. # MallButton
  267. if self.mallButton:
  268. self.mallButton.SetEvent(ui.__mem_func__(self.ClickMallButton))
  269.  
  270. # Costume Button
  271. if self.costumeButton:
  272. self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))
  273. # Offline Shop Button
  274. if (self.offlineShopButton):
  275. self.offlineShopButton.SetEvent(ui.__mem_func__(self.ClickOfflineShopButton))
  276.  
  277. if self.AntyExp:
  278. self.AntyExp.SetEvent(ui.__mem_func__(self.ClickAntyExp))
  279.  
  280. if self.poli:
  281. self.poli.SetEvent(ui.__mem_func__(self.Clickpoli))
  282.  
  283. if self.bs:
  284. self.bs.SetEvent(ui.__mem_func__(self.Clickbs))
  285.  
  286. if self.bonusinfo:
  287. self.bonusinfo.SetEvent(ui.__mem_func__(self.Clickbonusinfo))
  288. if self.podnoszenie:
  289. self.podnoszenie.SetEvent(ui.__mem_func__(self.Clickpodnoszenie))
  290. if self.Teleport:
  291. self.Teleport.SetEvent(ui.__mem_func__(self.ClickTeleport))
  292. if self.biolog:
  293. self.biolog.SetEvent(ui.__mem_func__(self.ClickBiolog))
  294.  
  295. self.wndCostume = None
  296. self.movedSlot = -1
  297.  
  298. #####
  299.  
  300. ## Refresh
  301. self.SetInventoryPage(0)
  302. self.SetEquipmentPage(0)
  303. self.RefreshItemSlot()
  304. self.RefreshStatus()
  305.  
  306. def Destroy(self):
  307. self.ClearDictionary()
  308.  
  309. self.dlgPickMoney.Destroy()
  310. self.dlgPickMoney = 0
  311.  
  312. self.refineDialog.Destroy()
  313. self.refineDialog = 0
  314.  
  315. self.attachMetinDialog.Destroy()
  316. self.attachMetinDialog = 0
  317.  
  318. self.tooltipItem = None
  319. self.wndItem = 0
  320. self.wndEquip = 0
  321. self.dlgPickMoney = 0
  322. self.wndMoney = 0
  323. self.wndMoneySlot = 0
  324. self.wndMds = 0
  325. self.wndMdsSlot = 0
  326. self.questionDialog = None
  327. self.mallButton = None
  328. self.bs = None
  329. self.interface = None
  330. self.Biolog = None
  331.  
  332.  
  333. if self.wndCostume:
  334. self.wndCostume.Destroy()
  335. self.wndCostume = 0
  336.  
  337. self.inventoryTab = []
  338. self.equipmentTab = []
  339.  
  340. def Close(self):
  341. if None != self.tooltipItem:
  342. self.tooltipItem.HideToolTip()
  343.  
  344. if self.wndCostume:
  345. self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow() # Could you open the inventory window is closed costumes?
  346. self.wndCostume.Close()
  347.  
  348. self.OnCloseQuestionDialog()
  349. self.dlgPickMoney.Close()
  350. self.Hide()
  351.  
  352. def SetInventoryPage(self, page):
  353. self.inventoryTab[self.inventoryPageIndex].SetUp()
  354. self.inventoryPageIndex = page
  355. self.inventoryTab[self.inventoryPageIndex].Down()
  356. self.RefreshBagSlotWindow()
  357.  
  358. def SetEquipmentPage(self, page):
  359. self.equipmentPageIndex = page
  360. self.equipmentTab[1-page].SetUp()
  361. self.RefreshEquipSlotWindow()
  362.  
  363. def ClickMallButton(self):
  364. self.choix = ui.BoardWithTitleBar()
  365. self.choix.SetSize(210, 80)
  366. self.choix.SetCenterPosition()
  367. self.choix.AddFlag('float')
  368. self.choix.AddFlag('movable')
  369. self.choix.SetTitleName("Wybierz Magazyn")
  370. self.choix.Show()
  371.  
  372. self.EntrepotIs = ui.Button()
  373. self.EntrepotIs.SetEvent(self.OpenIs)
  374. self.EntrepotIs.SetParent(self.choix)
  375. self.EntrepotIs.SetPosition(35, 40)
  376. self.EntrepotIs.SetUpVisual("d:/ymir work/ui/public/middle_button_01.sub")
  377. self.EntrepotIs.SetOverVisual("d:/ymir work/ui/public/middle_button_02.sub")
  378. self.EntrepotIs.SetDownVisual("d:/ymir work/ui/public/middle_button_03.sub")
  379. self.EntrepotIs.SetText("ItemShop")
  380. self.EntrepotIs.SetToolTipText("Otworz ItemShop")
  381. self.EntrepotIs.Show()
  382.  
  383. self.Magasinier = ui.Button()
  384. self.Magasinier.SetEvent(self._normal_mall)
  385. self.Magasinier.SetParent(self.choix)
  386. self.Magasinier.SetPosition(105, 40)
  387. self.Magasinier.SetUpVisual("d:/ymir work/ui/public/middle_button_01.sub")
  388. self.Magasinier.SetOverVisual("d:/ymir work/ui/public/middle_button_02.sub")
  389. self.Magasinier.SetDownVisual("d:/ymir work/ui/public/middle_button_03.sub")
  390. self.Magasinier.SetText("Magazyn")
  391. self.Magasinier.SetToolTipText("Otworz magazyn")
  392. self.Magasinier.Show()
  393.  
  394. def ClickAntyExp(self):
  395. import event
  396. qid = constInfo.antiexp
  397. event.QuestButtonClick(qid)
  398.  
  399. def Clickpoli(self):
  400. import event
  401. qid = constInfo.poli
  402. event.QuestButtonClick(qid)
  403.  
  404. def Clickbs(self):
  405. if self.switchbot.bot_shown == 1:
  406. self.switchbot.Hide()
  407. else:
  408. self.switchbot.Show()
  409. # END_switchbot
  410. def Clickbonusinfo(self):
  411. self.bonusinfo = uibonus.BonusPage()
  412. if constInfo.bonusdialog == 0:
  413. constInfo.bonusdialog = 1
  414. self.bonusinfo.Show()
  415. elif constInfo.bonusdialog == 1:
  416. constInfo.bonusdialog = 0
  417. self.bonusinfo.Hide()
  418. def Clickpodnoszenie(self):
  419. global CHECK_ACTIVE_PICKUP
  420. if CHECK_ACTIVE_PICKUP == 0:
  421. CHECK_ACTIVE_PICKUP = 1
  422. constInfo.ENABLE_PICKUP = 1
  423. chat.AppendChat(chat.CHAT_TYPE_INFO, "<AutoPickUP> Aktywowano podnoszenie przedmiotów.")
  424. else:
  425. CHECK_ACTIVE_PICKUP = 0
  426. constInfo.ENABLE_PICKUP = 0
  427. chat.AppendChat(chat.CHAT_TYPE_INFO, "<AutoPickUP> Dezaktywowano podnoszenie przedmiotów.")
  428.  
  429. def MapNames(self, data):
  430. constInfo.MAP_NAME = data
  431. wndTp=self.teleport
  432. wndTp.UpdateMaps()
  433.  
  434. def TeleportQuest(self, vid=0):
  435. constInfo.TP_QUEST = int(vid)
  436. self.wndTeleport = self.teleport
  437. self.wndTeleport.UpdateMaps()
  438.  
  439. def ClickTeleport(self):
  440. self.wndTeleport = self.teleport
  441. self.wndTeleport.Show()
  442. self.wndTeleport.UpdateMaps()
  443. def ClickBiolog(self):
  444. self.wndBiolog = self.biolog
  445. self.wndBiolog.Open()
  446. pass
  447. def __Inputget3(self):
  448. constInfo.INPUT_IGNORE = 1
  449.  
  450. def __Inputget4(self):
  451. self.biolog.czy = 0
  452. constInfo.INPUT_IGNORE = 0
  453.  
  454. def OpenIs(self):
  455. self.EntrepotIs.Hide()
  456. self.choix.Hide()
  457. self.Magasinier.Hide()
  458. net.SendChatPacket("/click_mall")
  459.  
  460. def _normal_mall(self):
  461. self.EntrepotIs.Hide()
  462. self.Magasinier.Hide()
  463. self.choix.Hide()
  464. net.SendChatPacket("/click_safebox")
  465.  
  466. # Offline Shop Button
  467. def ClickOfflineShopButton(self):
  468. print "click_offline_shop_button"
  469. self.interface.ToggleOfflineShopAdminPanelWindow()
  470.  
  471. def ClickCostumeButton(self):
  472. print "Click Costume Button"
  473. if self.wndCostume:
  474. if self.wndCostume.IsShow():
  475. self.wndCostume.Hide()
  476. else:
  477. self.wndCostume.Show()
  478. else:
  479. self.wndCostume = CostumeWindow(self)
  480. self.wndCostume.Show()
  481.  
  482. def OpenPickMoneyDialog(self):
  483.  
  484. if mouseModule.mouseController.isAttached():
  485.  
  486. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  487. if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  488.  
  489. if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  490. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  491. snd.PlaySound("sound/ui/money.wav")
  492.  
  493. mouseModule.mouseController.DeattachObject()
  494.  
  495. else:
  496. curMoney = player.GetElk()
  497.  
  498. if curMoney <= 0:
  499. return
  500.  
  501. self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  502. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  503. self.dlgPickMoney.Open(curMoney)
  504. self.dlgPickMoney.SetMax(7) # Bug fixes inventory restrictions 990000
  505.  
  506. def OnPickMoney(self, money):
  507. mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  508.  
  509. def OnPickItem(self, count):
  510. itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  511. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  512. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  513.  
  514. def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  515.  
  516. if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local):
  517. return local
  518.  
  519. return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  520.  
  521. def RefreshBagSlotWindow(self):
  522. getItemVNum=player.GetItemIndex
  523. getItemCount=player.GetItemCount
  524. setItemVNum=self.wndItem.SetItemSlot
  525.  
  526. for i in xrange(player.INVENTORY_PAGE_SIZE*4):
  527. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  528.  
  529. itemCount = getItemCount(slotNumber)
  530.  
  531. if itemCount == 0 and slotNumber in constInfo.NEWITEMS:
  532. constInfo.NEWITEMS.remove(slotNumber)
  533.  
  534. if 0 == itemCount:
  535. self.wndItem.ClearSlot(i)
  536. continue
  537. elif 1 == itemCount:
  538. itemCount = 0
  539.  
  540.  
  541. itemVnum = getItemVNum(slotNumber)
  542. setItemVNum(i, itemVnum, itemCount)
  543. self.wndItem.EnableCoverButton(i)
  544. if slotNumber in constInfo.NEWITEMS:
  545. self.wndItem.SetCoverButton(i, "d:/ymir work/ui/game/quest/slot_button_00.sub",\
  546. "d:/ymir work/ui/game/quest/slot_button_00.sub",\
  547. "d:/ymir work/ui/game/quest/slot_button_00.sub",\
  548. "d:/ymir work/ui/new_icon.tga", FALSE, FALSE)
  549. self.wndItem.DisableCoverButton(i)
  550.  
  551. if constInfo.IS_AUTO_POTION(itemVnum):
  552. metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  553.  
  554. if slotNumber >= player.INVENTORY_PAGE_SIZE*self.inventoryPageIndex:
  555. slotNumber -= player.INVENTORY_PAGE_SIZE*self.inventoryPageIndex
  556.  
  557.  
  558. isActivated = 0 != metinSocket[0]
  559.  
  560. if isActivated:
  561. self.wndItem.ActivateSlot(i)
  562. potionType = 0;
  563. if constInfo.IS_AUTO_POTION_HP(itemVnum):
  564. potionType = player.AUTO_POTION_TYPE_HP
  565. elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  566. potionType = player.AUTO_POTION_TYPE_SP
  567.  
  568. usedAmount = int(metinSocket[1])
  569. totalAmount = int(metinSocket[2])
  570. player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  571.  
  572. else:
  573. self.wndItem.DeactivateSlot(i)
  574.  
  575.  
  576. self.wndItem.RefreshSlot()
  577.  
  578.  
  579. def RefreshEquipSlotWindow(self):
  580. getItemVNum=player.GetItemIndex
  581. getItemCount=player.GetItemCount
  582. setItemVNum=self.wndEquip.SetItemSlot
  583. for i in xrange(player.EQUIPMENT_PAGE_COUNT):
  584. slotNumber = player.EQUIPMENT_SLOT_START + i
  585. itemCount = getItemCount(slotNumber)
  586. if self.movedSlot in constInfo.NEWITEMS:
  587. constInfo.NEWITEMS.remove(self.movedSlot)
  588. if itemCount <= 1:
  589. itemCount = 0
  590. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  591.  
  592. self.wndEquip.RefreshSlot()
  593.  
  594. if self.wndCostume:
  595. self.wndCostume.RefreshCostumeSlot()
  596.  
  597. def RefreshItemSlot(self):
  598. self.RefreshBagSlotWindow()
  599. self.RefreshEquipSlotWindow()
  600.  
  601. def RefreshStatus(self):
  602. money = player.GetElk()
  603. self.wndMoney.SetText(localeInfo.NumberToMoneyString(money))
  604. import constInfo
  605. self.wndMds.SetText(str(constInfo.ep) + " PO")
  606.  
  607. def OnUpdate(self):
  608. import constInfo
  609. self.wndMds.SetText(str(constInfo.ep) + " PO")
  610.  
  611. def SetItemToolTip(self, tooltipItem):
  612. self.tooltipItem = tooltipItem
  613.  
  614. def SellItem(self):
  615.  
  616. if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  617. if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  618. ## ???? ??? ?? ?? ????? ?? type ??
  619. net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY)
  620. snd.PlaySound("sound/ui/money.wav")
  621. self.OnCloseQuestionDialog()
  622.  
  623. def OnDetachMetinFromItem(self):
  624. if None == self.questionDialog:
  625. return
  626.  
  627. #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  628. self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  629. self.OnCloseQuestionDialog()
  630.  
  631. def OnCloseQuestionDialog(self):
  632. if self.questionDialog:
  633. self.questionDialog.Close()
  634.  
  635. self.questionDialog = None
  636.  
  637.  
  638. ## Slot Event
  639. def SelectEmptySlot(self, selectedSlotPos):
  640. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
  641. return
  642.  
  643. selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  644.  
  645. if mouseModule.mouseController.isAttached():
  646.  
  647. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  648. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  649. attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  650. attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  651.  
  652. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  653. itemCount = player.GetItemCount(attachedSlotPos)
  654. attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  655. self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  656.  
  657. if item.IsRefineScroll(attachedItemIndex):
  658. self.wndItem.SetUseMode(FALSE)
  659.  
  660. elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  661. mouseModule.mouseController.RunCallBack("INVENTORY")
  662. elif player.SLOT_TYPE_OFFLINE_SHOP == attachedSlotType:
  663. mouseModule.mouseController.RunCallBack("INVENTORY")
  664.  
  665. elif player.SLOT_TYPE_SHOP == attachedSlotType:
  666. net.SendShopBuyPacket(attachedSlotPos)
  667.  
  668. elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  669.  
  670. if player.ITEM_MONEY == attachedItemIndex:
  671. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  672. snd.PlaySound("sound/ui/money.wav")
  673.  
  674. else:
  675. net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  676.  
  677. elif player.SLOT_TYPE_MALL == attachedSlotType:
  678. net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  679.  
  680. mouseModule.mouseController.DeattachObject()
  681.  
  682. def SelectItemSlot(self, itemSlotIndex):
  683. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
  684. return
  685.  
  686. itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  687.  
  688. if mouseModule.mouseController.isAttached():
  689. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  690. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  691. attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  692. itemVnum = player.GetItemIndex(itemSlotIndex)
  693. item.SelectItem(itemVnum)
  694. itemType = item.GetItemType()
  695. itemSubType = item.GetItemSubType()
  696.  
  697. nook = 0
  698. if itemType == 2 and itemSubType != 0:
  699. nook = 1
  700. if attachedItemVID == 25100 and itemType >= 1 and itemType <= 2 and nook != 1:
  701. count = 0
  702. Slots = [player.GetItemMetinSocket(itemSlotIndex, i) for i in xrange(player.METIN_SOCKET_MAX_NUM)]
  703. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  704. if Slots[i] > 20000:
  705. count += 1
  706. if count == 0:
  707. chat.AppendChat(chat.CHAT_TYPE_INFO, "Ten przedmiot nie posiada kamieni dusz!")
  708. mouseModule.mouseController.DeattachObject()
  709. return
  710. else:
  711. import uistonesdialog
  712. self.stones = uistonesdialog.StonesDialog()
  713. self.stones.SetData(itemSlotIndex)
  714. self.stones.Shows()
  715. mouseModule.mouseController.DeattachObject()
  716. return
  717.  
  718. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  719. self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  720.  
  721. mouseModule.mouseController.DeattachObject()
  722.  
  723. else:
  724.  
  725. curCursorNum = app.GetCursor()
  726. if app.SELL == curCursorNum:
  727. self.__SellItem(itemSlotIndex)
  728.  
  729. elif app.BUY == curCursorNum:
  730. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  731.  
  732. elif app.IsPressed(app.DIK_LALT):
  733. link = player.GetItemLink(itemSlotIndex)
  734. ime.PasteString(link)
  735.  
  736. elif app.IsPressed(app.DIK_LSHIFT):
  737. itemCount = player.GetItemCount(itemSlotIndex)
  738.  
  739. if itemCount > 1:
  740. self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  741. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  742. self.dlgPickMoney.Open(itemCount)
  743. self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  744. #else:
  745. #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  746. #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  747.  
  748. elif app.IsPressed(app.DIK_LCONTROL):
  749. itemIndex = player.GetItemIndex(itemSlotIndex)
  750.  
  751. if TRUE == item.CanAddToQuickSlotItem(itemIndex):
  752. player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  753. else:
  754. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  755.  
  756. else:
  757. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  758. itemCount = player.GetItemCount(itemSlotIndex)
  759. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  760.  
  761. if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):
  762. self.wndItem.SetUseMode(TRUE)
  763. else:
  764. self.wndItem.SetUseMode(FALSE)
  765.  
  766. snd.PlaySound("sound/ui/pick.wav")
  767.  
  768. def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  769. if srcItemSlotPos == dstItemSlotPos:
  770. return
  771.  
  772. if player.GetItemIndex(srcItemSlotPos) == player.GetItemIndex(dstItemSlotPos) and not player.IsEquipmentSlot(dstItemSlotPos):
  773. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  774. return
  775.  
  776. if item.IsRefineScroll(srcItemVID):
  777. self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  778. self.wndItem.SetUseMode(FALSE)
  779.  
  780. elif item.IsMetin(srcItemVID):
  781. self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  782.  
  783. elif item.IsDetachScroll(srcItemVID):
  784. self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  785.  
  786. elif item.IsKey(srcItemVID):
  787. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  788.  
  789. elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  790. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  791.  
  792. elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  793. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  794.  
  795. else:
  796. #snd.PlaySound("sound/ui/drop.wav")
  797.  
  798. ## If the slot where the movement was then fitted using the item - [levites]
  799. if player.IsEquipmentSlot(dstItemSlotPos):
  800.  
  801. ## Only items when carrying equipment
  802. if item.IsEquipmentVID(srcItemVID):
  803. self.__UseItem(srcItemSlotPos)
  804.  
  805. else:
  806. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  807. #net.SendItemMovePacket(srcItemSlotPos, dstItemSlotPos, 0)
  808.  
  809. def __SellItem(self, itemSlotPos):
  810. if not player.IsEquipmentSlot(itemSlotPos):
  811. self.sellingSlotNumber = itemSlotPos
  812. itemIndex = player.GetItemIndex(itemSlotPos)
  813. itemCount = player.GetItemCount(itemSlotPos)
  814. self.sellingSlotitemIndex = itemIndex
  815. self.sellingSlotitemCount = itemCount
  816.  
  817. item.SelectItem(itemIndex)
  818. if item.IsAntiFlag(item.ANTIFLAG_SELL):
  819. popup = uiCommon.PopupDialog()
  820. popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  821. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  822. popup.Open()
  823. self.popup = popup
  824. return
  825. itemPrice = item.GetISellItemPrice()
  826.  
  827. if item.Is1GoldItem():
  828. itemPrice = itemCount / itemPrice / 5
  829. else:
  830. itemPrice = itemPrice * itemCount / 5
  831.  
  832. item.GetItemName(itemIndex)
  833. itemName = item.GetItemName()
  834.  
  835. self.questionDialog = uiCommon.QuestionDialog()
  836. self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  837. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  838. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  839. self.questionDialog.Open()
  840. self.questionDialog.count = itemCount
  841.  
  842.  
  843. def __OnClosePopupDialog(self):
  844. self.pop = None
  845. def RefineItem(self, scrollSlotPos, targetSlotPos):
  846.  
  847. scrollIndex = player.GetItemIndex(scrollSlotPos)
  848. targetIndex = player.GetItemIndex(targetSlotPos)
  849.  
  850. if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  851. return
  852.  
  853. ###########################################################
  854. self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  855. #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  856. return
  857. ###########################################################
  858.  
  859. ###########################################################
  860. #net.SendRequestRefineInfoPacket(targetSlotPos)
  861. #return
  862. ###########################################################
  863.  
  864. result = player.CanRefine(scrollIndex, targetSlotPos)
  865.  
  866. if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  867. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  868. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  869.  
  870. elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  871. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  872. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  873.  
  874. elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  875. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  876. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  877.  
  878. elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  879. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  880. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  881.  
  882. elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  883. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  884.  
  885. if player.REFINE_OK != result:
  886. return
  887.  
  888. self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  889.  
  890. def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  891. scrollIndex = player.GetItemIndex(scrollSlotPos)
  892. targetIndex = player.GetItemIndex(targetSlotPos)
  893.  
  894. if not player.CanDetach(scrollIndex, targetSlotPos):
  895. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  896. return
  897.  
  898. self.questionDialog = uiCommon.QuestionDialog()
  899. self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  900. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  901. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  902. self.questionDialog.Open()
  903. self.questionDialog.sourcePos = scrollSlotPos
  904. self.questionDialog.targetPos = targetSlotPos
  905.  
  906. def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  907. metinIndex = player.GetItemIndex(metinSlotPos)
  908. targetIndex = player.GetItemIndex(targetSlotPos)
  909.  
  910. item.SelectItem(metinIndex)
  911. itemName = item.GetItemName()
  912.  
  913. result = player.CanAttachMetin(metinIndex, targetSlotPos)
  914.  
  915. if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  916. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  917.  
  918. if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  919. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  920.  
  921. elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  922. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  923.  
  924. elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  925. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  926.  
  927. if player.ATTACH_METIN_OK != result:
  928. return
  929.  
  930. self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  931.  
  932.  
  933.  
  934. def OverOutItem(self):
  935. self.wndItem.SetUsableItem(FALSE)
  936. if None != self.tooltipItem:
  937. self.tooltipItem.HideToolTip()
  938.  
  939. def OverInItem(self, overSlotPos):
  940. slotPos = overSlotPos
  941. overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  942. self.wndItem.SetUsableItem(FALSE)
  943.  
  944. if mouseModule.mouseController.isAttached():
  945. attachedItemType = mouseModule.mouseController.GetAttachedType()
  946. if player.SLOT_TYPE_INVENTORY == attachedItemType:
  947.  
  948. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  949. attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  950.  
  951. if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos):
  952. self.wndItem.SetUsableItem(TRUE)
  953. self.ShowToolTip(overSlotPos)
  954. return
  955.  
  956. self.ShowToolTip(overSlotPos)
  957. if overSlotPos in constInfo.NEWITEMS:
  958. self.wndItem.EnableCoverButton(slotPos)
  959. constInfo.NEWITEMS.remove(overSlotPos)
  960.  
  961.  
  962. def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  963. "Items that can be applied to other items?"
  964.  
  965. if item.IsRefineScroll(srcItemVNum):
  966. return TRUE
  967. elif item.IsMetin(srcItemVNum):
  968. return TRUE
  969. elif item.IsDetachScroll(srcItemVNum):
  970. return TRUE
  971. elif item.IsKey(srcItemVNum):
  972. return TRUE
  973. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  974. return TRUE
  975. else:
  976. if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  977. return TRUE
  978.  
  979. return FALSE
  980.  
  981. def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  982. "Can you use the target item?"
  983.  
  984. if srcSlotPos == dstSlotPos:
  985. return FALSE
  986.  
  987. if player.GetItemIndex(srcSlotPos) == player.GetItemIndex(dstSlotPos) and not player.IsEquipmentSlot(dstSlotPos):
  988. return TRUE
  989.  
  990. if item.IsRefineScroll(srcItemVNum):
  991. if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  992. return TRUE
  993. elif item.IsMetin(srcItemVNum):
  994. if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  995. return TRUE
  996. elif item.IsDetachScroll(srcItemVNum):
  997. if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  998. return TRUE
  999. elif item.IsKey(srcItemVNum):
  1000. if player.CanUnlock(srcItemVNum, dstSlotPos):
  1001. return TRUE
  1002.  
  1003. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1004. return TRUE
  1005.  
  1006. else:
  1007. useType=item.GetUseType(srcItemVNum)
  1008.  
  1009. if "USE_CLEAN_SOCKET" == useType:
  1010. if self.__CanCleanBrokenMetinStone(dstSlotPos):
  1011. return TRUE
  1012. elif "USE_CHANGE_ATTRIBUTE" == useType:
  1013. if self.__CanChangeItemAttrList(dstSlotPos):
  1014. return TRUE
  1015. elif "USE_ADD_ATTRIBUTE" == useType:
  1016. if self.__CanAddItemAttr(dstSlotPos):
  1017. return TRUE
  1018. elif "USE_ADD_ATTRIBUTE2" == useType:
  1019. if self.__CanAddItemAttr(dstSlotPos):
  1020. return TRUE
  1021. elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  1022. if self.__CanAddAccessorySocket(dstSlotPos):
  1023. return TRUE
  1024. elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:
  1025. if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  1026. return TRUE;
  1027.  
  1028.  
  1029. return FALSE
  1030.  
  1031. def __CanCleanBrokenMetinStone(self, dstSlotPos):
  1032. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1033. if dstItemVNum == 0:
  1034. return FALSE
  1035.  
  1036. item.SelectItem(dstItemVNum)
  1037.  
  1038. if item.ITEM_TYPE_WEAPON != item.GetItemType():
  1039. return FALSE
  1040.  
  1041. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1042. if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  1043. return TRUE
  1044.  
  1045. return FALSE
  1046.  
  1047. def __CanChangeItemAttrList(self, dstSlotPos):
  1048. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1049. if dstItemVNum == 0:
  1050. return FALSE
  1051.  
  1052. item.SelectItem(dstItemVNum)
  1053.  
  1054. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1055. return FALSE
  1056.  
  1057. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1058. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1059. return TRUE
  1060.  
  1061. return FALSE
  1062.  
  1063. def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  1064. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1065. if dstItemVNum == 0:
  1066. return FALSE
  1067.  
  1068. item.SelectItem(dstItemVNum)
  1069.  
  1070. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1071. return FALSE
  1072.  
  1073. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1074. return FALSE
  1075.  
  1076. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1077. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1078.  
  1079. if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1080. return FALSE
  1081.  
  1082. if curCount>=maxCount:
  1083. return FALSE
  1084.  
  1085. return TRUE
  1086.  
  1087. def __CanAddAccessorySocket(self, dstSlotPos):
  1088. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1089. if dstItemVNum == 0:
  1090. return FALSE
  1091.  
  1092. item.SelectItem(dstItemVNum)
  1093.  
  1094. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1095. return FALSE
  1096.  
  1097. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1098. return FALSE
  1099.  
  1100. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1101. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1102.  
  1103. ACCESSORY_SOCKET_MAX_SIZE = 3
  1104. if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1105. return FALSE
  1106.  
  1107. return TRUE
  1108.  
  1109. def __CanAddItemAttr(self, dstSlotPos):
  1110. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1111. if dstItemVNum == 0:
  1112. return FALSE
  1113.  
  1114. item.SelectItem(dstItemVNum)
  1115.  
  1116. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1117. return FALSE
  1118.  
  1119. attrCount = 0
  1120. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1121. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1122. attrCount += 1
  1123.  
  1124. if attrCount<4:
  1125. return TRUE
  1126.  
  1127. return FALSE
  1128.  
  1129. def ShowToolTip(self, slotIndex):
  1130. if None != self.tooltipItem:
  1131. self.tooltipItem.SetInventoryItem(slotIndex)
  1132.  
  1133. def OnTop(self):
  1134. if None != self.tooltipItem:
  1135. self.tooltipItem.SetTop()
  1136.  
  1137. def OnPressEscapeKey(self):
  1138. self.Close()
  1139. return TRUE
  1140.  
  1141. def UseItemSlot(self, slotIndex):
  1142. curCursorNum = app.GetCursor()
  1143. if app.SELL == curCursorNum:
  1144. return
  1145. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS():
  1146. return
  1147.  
  1148. slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1149.  
  1150. self.__UseItem(slotIndex)
  1151. mouseModule.mouseController.DeattachObject()
  1152. self.OverOutItem()
  1153.  
  1154. def __UseItem(self, slotIndex):
  1155. ItemVNum = player.GetItemIndex(slotIndex)
  1156. item.SelectItem(ItemVNum)
  1157. if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE):
  1158. self.questionDialog = uiCommon.QuestionDialog()
  1159. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1160. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1161. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1162. self.questionDialog.Open()
  1163. self.questionDialog.slotIndex = slotIndex
  1164.  
  1165. else:
  1166. self.__SendUseItemPacket(slotIndex)
  1167. #net.SendItemUsePacket(slotIndex)
  1168.  
  1169. def __UseItemQuestionDialog_OnCancel(self):
  1170. self.OnCloseQuestionDialog()
  1171.  
  1172. def __UseItemQuestionDialog_OnAccept(self):
  1173. self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1174.  
  1175. if self.questionDialog:
  1176. self.questionDialog.Close()
  1177. self.questionDialog = None
  1178.  
  1179. def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1180. # Avoid using personal items while open shops
  1181. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1182. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1183. return
  1184. if (uiOfflineShopBuilder.IsBuildingOfflineShop()):
  1185. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_OFFLINE_SHOP)
  1186. return
  1187.  
  1188. if (uiOfflineShop.IsEditingOfflineShop()):
  1189. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_OFFLINE_SHOP)
  1190. return
  1191. net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1192.  
  1193. def __SendUseItemPacket(self, slotPos):
  1194. # Avoid using personal items while open shops
  1195. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1196. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1197. return
  1198. if (uiOfflineShopBuilder.IsBuildingOfflineShop()):
  1199. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_OFFLINE_SHOP)
  1200. return
  1201.  
  1202. if (uiOfflineShop.IsEditingOfflineShop()):
  1203. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_OFFLINE_SHOP)
  1204. return
  1205.  
  1206. net.SendItemUsePacket(slotPos)
  1207.  
  1208. def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1209. self.movedSlot = dstSlotPos
  1210. # Avoid using personal items while open shops
  1211. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1212. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1213. return
  1214. if (uiOfflineShopBuilder.IsBuildingOfflineShop()):
  1215. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_OFFLINE_SHOP)
  1216. return
  1217.  
  1218. if (uiOfflineShop.IsEditingOfflineShop()):
  1219. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_OFFLINE_SHOP)
  1220. return
  1221.  
  1222. net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
Add Comment
Please, Sign In to add comment