Guest User

uiinventory.py

a guest
Mar 3rd, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.69 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 방지
  17. import locale
  18. import localeInfo
  19. import constInfo
  20. import ime
  21. import wndMgr
  22. import background
  23.  
  24. ITEM_MALL_BUTTON_ENABLE = True
  25.  
  26.  
  27.  
  28. ITEM_FLAG_APPLICABLE = 1 << 14
  29.  
  30. class CostumeWindow(ui.ScriptWindow):
  31.  
  32. def __init__(self, wndInventory):
  33. import exception
  34.  
  35. if not app.ENABLE_COSTUME_SYSTEM:
  36. exception.Abort("What do you do?")
  37. return
  38.  
  39. if not wndInventory:
  40. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  41. return
  42.  
  43. ui.ScriptWindow.__init__(self)
  44.  
  45. self.isLoaded = 0
  46. self.wndInventory = wndInventory;
  47.  
  48. self.__LoadWindow()
  49.  
  50. def __del__(self):
  51. ui.ScriptWindow.__del__(self)
  52.  
  53. def Show(self):
  54. self.__LoadWindow()
  55. self.RefreshCostumeSlot()
  56.  
  57. ui.ScriptWindow.Show(self)
  58.  
  59. def Close(self):
  60. self.Hide()
  61.  
  62. def __LoadWindow(self):
  63. if self.isLoaded == 1:
  64. return
  65.  
  66. self.isLoaded = 1
  67.  
  68. try:
  69. pyScrLoader = ui.PythonScriptLoader()
  70. pyScrLoader.LoadScriptFile(self, "UIScript/CostumeWindow.py")
  71. except:
  72. import exception
  73. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  74.  
  75. try:
  76. wndEquip = self.GetChild("CostumeSlot")
  77. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  78.  
  79. except:
  80. import exception
  81. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  82.  
  83. ## Equipment
  84. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  85. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  86. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  87. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  88. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  89. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  90.  
  91. self.wndEquip = wndEquip
  92.  
  93. def RefreshCostumeSlot(self):
  94. getItemVNum=player.GetItemIndex
  95.  
  96. for i in xrange(item.COSTUME_SLOT_COUNT):
  97. slotNumber = item.COSTUME_SLOT_START + i
  98. self.wndEquip.SetItemSlot(slotNumber, getItemVNum(slotNumber), 0)
  99.  
  100. self.wndEquip.RefreshSlot()
  101.  
  102. class BeltInventoryWindow(ui.ScriptWindow):
  103.  
  104. def __init__(self, wndInventory):
  105. import exception
  106.  
  107. if not app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  108. exception.Abort("What do you do?")
  109. return
  110.  
  111. if not wndInventory:
  112. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  113. return
  114.  
  115. ui.ScriptWindow.__init__(self)
  116.  
  117. self.isLoaded = 0
  118. self.wndInventory = wndInventory;
  119.  
  120. self.wndBeltInventoryLayer = None
  121. self.wndBeltInventorySlot = None
  122. self.expandBtn = None
  123. self.minBtn = None
  124.  
  125. self.__LoadWindow()
  126.  
  127. def __del__(self):
  128. ui.ScriptWindow.__del__(self)
  129.  
  130. def Show(self, openBeltSlot = False):
  131. self.__LoadWindow()
  132. self.RefreshSlot()
  133.  
  134. ui.ScriptWindow.Show(self)
  135.  
  136. if openBeltSlot:
  137. self.OpenInventory()
  138. else:
  139. self.CloseInventory()
  140.  
  141. def Close(self):
  142. self.Hide()
  143.  
  144. def IsOpeningInventory(self):
  145. return self.wndBeltInventoryLayer.IsShow()
  146.  
  147. def OpenInventory(self):
  148. self.wndBeltInventoryLayer.Show()
  149. self.expandBtn.Hide()
  150.  
  151. self.AdjustPositionAndSize()
  152.  
  153. def CloseInventory(self):
  154. self.wndBeltInventoryLayer.Hide()
  155. self.expandBtn.Show()
  156.  
  157. self.AdjustPositionAndSize()
  158.  
  159. ## 현재 인벤토리 위치를 기준으로 BASE 위치를 계산, 리턴.. 숫자 하드코딩하기 정말 싫지만 방법이 없다..
  160. def GetBasePosition(self):
  161. x, y = self.wndInventory.GetGlobalPosition()
  162. return x - 148, y + 241
  163.  
  164. def AdjustPositionAndSize(self):
  165. bx, by = self.GetBasePosition()
  166.  
  167. if self.IsOpeningInventory():
  168. self.SetPosition(bx, by)
  169. self.SetSize(self.ORIGINAL_WIDTH, self.GetHeight())
  170.  
  171. else:
  172. self.SetPosition(bx + 138, by);
  173. self.SetSize(10, self.GetHeight())
  174.  
  175. def __LoadWindow(self):
  176. if self.isLoaded == 1:
  177. return
  178.  
  179. self.isLoaded = 1
  180.  
  181. try:
  182. pyScrLoader = ui.PythonScriptLoader()
  183. except:
  184. import exception
  185. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  186.  
  187. try:
  188. self.ORIGINAL_WIDTH = self.GetWidth()
  189. except:
  190. import exception
  191. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  192.  
  193. ## Equipment
  194. wndBeltInventorySlot.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  195. wndBeltInventorySlot.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  196. wndBeltInventorySlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  197. wndBeltInventorySlot.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  198. wndBeltInventorySlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  199. wndBeltInventorySlot.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  200.  
  201. self.wndBeltInventorySlot = wndBeltInventorySlot
  202.  
  203. def RefreshSlot(self):
  204. getItemVNum=player.GetItemIndex
  205.  
  206. for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  207. slotNumber = item.BELT_INVENTORY_SLOT_START + i
  208. self.wndBeltInventorySlot.SetItemSlot(slotNumber, getItemVNum(slotNumber), player.GetItemCount(slotNumber))
  209. self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(slotNumber, True)
  210.  
  211. avail = "0"
  212.  
  213. if player.IsAvailableBeltInventoryCell(slotNumber):
  214. self.wndBeltInventorySlot.EnableCoverButton(slotNumber)
  215. else:
  216. self.wndBeltInventorySlot.DisableCoverButton(slotNumber)
  217.  
  218. self.wndBeltInventorySlot.RefreshSlot()
  219.  
  220. class InventoryWindow(ui.ScriptWindow):
  221.  
  222. USE_TYPE_TUPLE = ("USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ATTRIBUTE2", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET", "USE_PUT_INTO_BELT_SOCKET", "USE_PUT_INTO_RING_SOCKET")
  223.  
  224. questionDialog = None
  225. tooltipItem = None
  226. wndCostume = None
  227. wndBelt = None
  228. dlgPickMoney = None
  229.  
  230. sellingSlotNumber = -1
  231. isLoaded = 0
  232. isOpenedCostumeWindowWhenClosingInventory = 0 # 인벤토리 닫을 때 코스츔이 열려있었는지 여부-_-; 네이밍 ㅈㅅ
  233. isOpenedBeltWindowWhenClosingInventory = 0 # 인벤토리 닫을 때 벨트 인벤토리가 열려있었는지 여부-_-; 네이밍 ㅈㅅ
  234.  
  235. def __init__(self):
  236. ui.ScriptWindow.__init__(self)
  237. self.OpenBoniSwitcherEvent = lambda : None
  238. self.__LoadWindow()
  239.  
  240. def __del__(self):
  241. ui.ScriptWindow.__del__(self)
  242.  
  243. def Show(self):
  244. self.__LoadWindow()
  245.  
  246. ui.ScriptWindow.Show(self)
  247.  
  248. # 인벤토리를 닫을 때 코스츔이 열려있었다면 인벤토리를 열 때 코스츔도 같이 열도록 함.
  249. if self.isOpenedCostumeWindowWhenClosingInventory and self.wndCostume:
  250. self.wndCostume.Show()
  251.  
  252. # 인벤토리를 닫을 때 벨트 인벤토리가 열려있었다면 같이 열도록 함.
  253. if self.wndBelt:
  254. self.wndBelt.Show(self.isOpenedBeltWindowWhenClosingInventory)
  255.  
  256. def BindInterfaceClass(self, interface):
  257. self.interface = interface
  258.  
  259. def __LoadWindow(self):
  260. if self.isLoaded == 1:
  261. return
  262.  
  263. self.isLoaded = 1
  264.  
  265. try:
  266. pyScrLoader = ui.PythonScriptLoader()
  267.  
  268. if ITEM_MALL_BUTTON_ENABLE:
  269. pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "InventoryWindow.py")
  270. else:
  271. pyScrLoader.LoadScriptFile(self, "UIScript/InventoryWindow.py")
  272. except:
  273. import exception
  274. exception.Abort("InventoryWindow.LoadWindow.LoadObject")
  275.  
  276. try:
  277. wndItem = self.GetChild("ItemSlot")
  278. wndEquip = self.GetChild("EquipmentSlot")
  279. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  280. self.wndMoney = self.GetChild("Money")
  281. self.wndMoneySlot = self.GetChild("Money_Slot")
  282. self.mallButton = self.GetChild2("MallButton")
  283. self.DSSButton = self.GetChild2("DSSButton")
  284. self.costumeButton = self.GetChild2("CostumeButton")
  285.  
  286. self.inventoryTab = []
  287. self.inventoryTab.append(self.GetChild("Inventory_Tab_01"))
  288. self.inventoryTab.append(self.GetChild("Inventory_Tab_02"))
  289. self.inventoryTab.append(self.GetChild("Inventory_Tab_03"))
  290. self.inventoryTab.append(self.GetChild("Inventory_Tab_04"))
  291.  
  292. self.equipmentTab = []
  293. self.equipmentTab.append(self.GetChild("Equipment_Tab_01"))
  294. self.equipmentTab.append(self.GetChild("Equipment_Tab_02"))
  295.  
  296. if self.costumeButton and not app.ENABLE_COSTUME_SYSTEM:
  297. self.costumeButton.Hide()
  298. self.costumeButton.Destroy()
  299. self.costumeButton = 0
  300.  
  301. except:
  302. import exception
  303. exception.Abort("InventoryWindow.LoadWindow.BindObject")
  304.  
  305. ## Item
  306. wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  307. wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  308. wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  309. wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  310. wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  311. wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  312.  
  313. ## Equipment
  314. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  315. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  316. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  317. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  318. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  319. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  320.  
  321. ## PickMoneyDialog
  322. dlgPickMoney = uiPickMoney.PickMoneyDialog()
  323. dlgPickMoney.LoadDialog()
  324. dlgPickMoney.Hide()
  325.  
  326. ## RefineDialog
  327. self.refineDialog = uiRefine.RefineDialog()
  328. self.refineDialog.Hide()
  329.  
  330. ## AttachMetinDialog
  331. self.attachMetinDialog = uiAttachMetin.AttachMetinDialog()
  332. self.attachMetinDialog.Hide()
  333.  
  334. ## MoneySlot
  335. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
  336.  
  337. self.inventoryTab[0].SetEvent(lambda arg=0: self.SetInventoryPage(arg))
  338. self.inventoryTab[1].SetEvent(lambda arg=1: self.SetInventoryPage(arg))
  339. self.inventoryTab[2].SetEvent(lambda arg=2: self.SetInventoryPage(arg))
  340. self.inventoryTab[3].SetEvent(lambda arg=3: self.SetInventoryPage(arg))
  341. self.inventoryTab[0].Down()
  342. self.inventoryPageIndex = 0
  343.  
  344. self.equipmentTab[0].SetEvent(lambda arg=0: self.SetEquipmentPage(arg))
  345. self.equipmentTab[1].SetEvent(lambda arg=1: self.SetEquipmentPage(arg))
  346. self.equipmentTab[0].Down()
  347. self.equipmentTab[0].Hide()
  348. self.equipmentTab[1].Hide()
  349.  
  350. self.wndItem = wndItem
  351. self.wndEquip = wndEquip
  352. self.dlgPickMoney = dlgPickMoney
  353.  
  354. # MallButton
  355. if self.mallButton:
  356. self.mallButton.SetEvent(ui.__mem_func__(self.ClickMallButton))
  357.  
  358. if self.DSSButton:
  359. self.DSSButton.SetEvent(ui.__mem_func__(self.ClickDSSButton))
  360.  
  361. # Costume Button
  362. if self.costumeButton:
  363. self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))
  364.  
  365. self.wndCostume = None
  366.  
  367. #####
  368.  
  369. ## Refresh
  370. self.SetInventoryPage(0)
  371. self.SetEquipmentPage(0)
  372. self.RefreshItemSlot()
  373. self.RefreshStatus()
  374.  
  375. def Destroy(self):
  376. self.ClearDictionary()
  377.  
  378. self.dlgPickMoney.Destroy()
  379. self.dlgPickMoney = 0
  380.  
  381. self.refineDialog.Destroy()
  382. self.refineDialog = 0
  383.  
  384. self.attachMetinDialog.Destroy()
  385. self.attachMetinDialog = 0
  386.  
  387. self.tooltipItem = None
  388. self.wndItem = 0
  389. self.wndEquip = 0
  390. self.dlgPickMoney = 0
  391. self.wndMoney = 0
  392. self.wndMoneySlot = 0
  393. self.questionDialog = None
  394. self.mallButton = None
  395. self.DSSButton = None
  396. self.interface = None
  397.  
  398. if self.wndCostume:
  399. self.wndCostume.Destroy()
  400. self.wndCostume = 0
  401.  
  402. if self.wndBelt:
  403. self.wndBelt.Destroy()
  404. self.wndBelt = None
  405.  
  406. self.inventoryTab = []
  407. self.equipmentTab = []
  408.  
  409. def Hide(self):
  410. if None != self.tooltipItem:
  411. self.tooltipItem.HideToolTip()
  412.  
  413. if self.wndCostume:
  414. self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow() # 인벤토리 창이 닫힐 때 코스츔이 열려 있었는가?
  415. self.wndCostume.Close()
  416.  
  417. if self.wndBelt:
  418. self.isOpenedBeltWindowWhenClosingInventory = self.wndBelt.IsOpeningInventory() # 인벤토리 창이 닫힐 때 벨트 인벤토리도 열려 있었는가?
  419. print "Is Opening Belt Inven?? ", self.isOpenedBeltWindowWhenClosingInventory
  420. self.wndBelt.Close()
  421.  
  422. if self.dlgPickMoney:
  423. self.dlgPickMoney.Close()
  424.  
  425. self.OnCloseQuestionDialog()
  426.  
  427. wndMgr.Hide(self.hWnd)
  428.  
  429.  
  430. def Close(self):
  431. self.Hide()
  432.  
  433. def SetInventoryPage(self, page):
  434. self.inventoryTab[self.inventoryPageIndex].SetUp()
  435. self.inventoryPageIndex = page
  436. self.inventoryTab[self.inventoryPageIndex].Down()
  437. self.RefreshBagSlotWindow()
  438.  
  439. def SetEquipmentPage(self, page):
  440. self.equipmentPageIndex = page
  441. self.equipmentTab[1-page].SetUp()
  442. self.RefreshEquipSlotWindow()
  443.  
  444. def ClickMallButton(self):
  445. print "click_mall_button"
  446. net.SendChatPacket("/click_mall")
  447.  
  448. # DSSButton
  449. def ClickDSSButton(self):
  450. print "click_dss_button"
  451. self.interface.ToggleDragonSoulWindow()
  452.  
  453. def ClickCostumeButton(self):
  454. print "Click Costume Button"
  455. if self.wndCostume:
  456. if self.wndCostume.IsShow():
  457. self.wndCostume.Hide()
  458. else:
  459. self.wndCostume.Show()
  460. else:
  461. self.wndCostume = CostumeWindow(self)
  462. self.wndCostume.Show()
  463.  
  464. def OpenPickMoneyDialog(self):
  465.  
  466. if mouseModule.mouseController.isAttached():
  467.  
  468. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  469. if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  470.  
  471. if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  472. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  473. snd.PlaySound("sound/ui/money.wav")
  474.  
  475. mouseModule.mouseController.DeattachObject()
  476.  
  477. else:
  478. curMoney = player.GetElk()
  479.  
  480. if curMoney <= 0:
  481. return
  482.  
  483. self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  484. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  485. self.dlgPickMoney.Open(curMoney)
  486. self.dlgPickMoney.SetMax(7) # 인벤토리 990000 제한 버그 수정
  487.  
  488. def OnPickMoney(self, money):
  489. mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  490.  
  491. def OnPickItem(self, count):
  492. itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  493. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  494. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  495.  
  496. def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  497.  
  498. if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local) or player.IsBeltInventorySlot(local):
  499. return local
  500.  
  501. return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  502.  
  503. def RefreshBagSlotWindow(self):
  504. getItemVNum=player.GetItemIndex
  505. getItemCount=player.GetItemCount
  506. setItemVNum=self.wndItem.SetItemSlot
  507.  
  508. for i in xrange(player.INVENTORY_PAGE_SIZE):
  509. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  510.  
  511. itemCount = getItemCount(slotNumber)
  512. # itemCount == 0이면 소켓을 비운다.
  513. if 0 == itemCount:
  514. self.wndItem.ClearSlot(i)
  515. continue
  516. elif 1 == itemCount:
  517. itemCount = 0
  518.  
  519. itemVnum = getItemVNum(slotNumber)
  520. setItemVNum(i, itemVnum, itemCount)
  521.  
  522. ## 자동물약 (HP: #72723 ~ #72726, SP: #72727 ~ #72730) 특수처리 - 아이템인데도 슬롯에 활성화/비활성화 표시를 위한 작업임 - [hyo]
  523. if constInfo.IS_AUTO_POTION(itemVnum):
  524. # metinSocket - [0] : 활성화 여부, [1] : 사용한 양, [2] : 최대 용량
  525. metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  526.  
  527. if slotNumber >= player.INVENTORY_PAGE_SIZE:
  528. slotNumber -= player.INVENTORY_PAGE_SIZE
  529.  
  530. isActivated = 0 != metinSocket[0]
  531.  
  532. if isActivated:
  533. self.wndItem.ActivateSlot(slotNumber)
  534. potionType = 0;
  535. if constInfo.IS_AUTO_POTION_HP(itemVnum):
  536. potionType = player.AUTO_POTION_TYPE_HP
  537. elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  538. potionType = player.AUTO_POTION_TYPE_SP
  539.  
  540. usedAmount = int(metinSocket[1])
  541. totalAmount = int(metinSocket[2])
  542. player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  543.  
  544. else:
  545. self.wndItem.DeactivateSlot(slotNumber)
  546.  
  547. self.wndItem.RefreshSlot()
  548.  
  549. if self.wndBelt:
  550. self.wndBelt.RefreshSlot()
  551.  
  552. def RefreshEquipSlotWindow(self):
  553. getItemVNum=player.GetItemIndex
  554. getItemCount=player.GetItemCount
  555. setItemVNum=self.wndEquip.SetItemSlot
  556. for i in xrange(player.EQUIPMENT_PAGE_COUNT):
  557. slotNumber = player.EQUIPMENT_SLOT_START + i
  558. itemCount = getItemCount(slotNumber)
  559. if itemCount <= 1:
  560. itemCount = 0
  561. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  562.  
  563. if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  564. for i in xrange(player.NEW_EQUIPMENT_SLOT_COUNT):
  565. slotNumber = player.NEW_EQUIPMENT_SLOT_START + i
  566. itemCount = getItemCount(slotNumber)
  567. if itemCount <= 1:
  568. itemCount = 0
  569. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  570. print "ENABLE_NEW_EQUIPMENT_SYSTEM", slotNumber, itemCount, getItemVNum(slotNumber)
  571.  
  572.  
  573.  
  574. self.wndEquip.RefreshSlot()
  575.  
  576. if self.wndCostume:
  577. self.wndCostume.RefreshCostumeSlot()
  578.  
  579. def RefreshItemSlot(self):
  580. self.RefreshBagSlotWindow()
  581. self.RefreshEquipSlotWindow()
  582.  
  583. def RefreshStatus(self):
  584. money = player.GetElk()
  585. self.wndMoney.SetText(localeInfo.NumberToMoneyString(money))
  586.  
  587. def SetItemToolTip(self, tooltipItem):
  588. self.tooltipItem = tooltipItem
  589.  
  590. def SellItem(self):
  591. if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  592. if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  593. net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count)
  594. snd.PlaySound("sound/ui/money.wav")
  595. self.OnCloseQuestionDialog()
  596.  
  597. def OnDetachMetinFromItem(self):
  598. if None == self.questionDialog:
  599. return
  600.  
  601. #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  602. self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  603. self.OnCloseQuestionDialog()
  604.  
  605. def OnCloseQuestionDialog(self):
  606. if self.questionDialog:
  607. self.questionDialog.Close()
  608.  
  609. self.questionDialog = None
  610.  
  611. ## Slot Event
  612. def SelectEmptySlot(self, selectedSlotPos):
  613. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
  614. return
  615.  
  616. selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  617.  
  618. if mouseModule.mouseController.isAttached():
  619.  
  620. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  621. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  622. attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  623. attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  624.  
  625. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  626. itemCount = player.GetItemCount(attachedSlotPos)
  627. attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  628. self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  629.  
  630. if item.IsRefineScroll(attachedItemIndex):
  631. self.wndItem.SetUseMode(False)
  632.  
  633. elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  634. mouseModule.mouseController.RunCallBack("INVENTORY")
  635.  
  636. elif player.SLOT_TYPE_SHOP == attachedSlotType:
  637. net.SendShopBuyPacket(attachedSlotPos)
  638.  
  639. elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  640.  
  641. if player.ITEM_MONEY == attachedItemIndex:
  642. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  643. snd.PlaySound("sound/ui/money.wav")
  644.  
  645. else:
  646. net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  647.  
  648. elif player.SLOT_TYPE_MALL == attachedSlotType:
  649. net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  650.  
  651. mouseModule.mouseController.DeattachObject()
  652.  
  653. def SelectItemSlot(self, itemSlotIndex):
  654. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS() == 1:
  655. return
  656.  
  657. itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  658.  
  659. if mouseModule.mouseController.isAttached():
  660. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  661. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  662. attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  663.  
  664. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  665. self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  666.  
  667. mouseModule.mouseController.DeattachObject()
  668.  
  669. else:
  670.  
  671. curCursorNum = app.GetCursor()
  672. if app.SELL == curCursorNum:
  673. self.__SellItem(itemSlotIndex)
  674.  
  675. elif app.BUY == curCursorNum:
  676. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  677.  
  678. elif app.IsPressed(app.DIK_LALT):
  679. link = player.GetItemLink(itemSlotIndex)
  680. ime.PasteString(link)
  681.  
  682. elif app.IsPressed(app.DIK_LSHIFT):
  683. itemCount = player.GetItemCount(itemSlotIndex)
  684.  
  685. if itemCount > 1:
  686. self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  687. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  688. self.dlgPickMoney.Open(itemCount)
  689. self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  690. #else:
  691. #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  692. #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  693.  
  694. elif app.IsPressed(app.DIK_LCONTROL):
  695. itemIndex = player.GetItemIndex(itemSlotIndex)
  696.  
  697. if True == item.CanAddToQuickSlotItem(itemIndex):
  698. player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  699. else:
  700. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  701.  
  702. else:
  703. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  704. itemCount = player.GetItemCount(itemSlotIndex)
  705. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  706.  
  707. if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):
  708. self.wndItem.SetUseMode(True)
  709. else:
  710. self.wndItem.SetUseMode(False)
  711.  
  712. snd.PlaySound("sound/ui/pick.wav")
  713.  
  714. def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  715. if srcItemSlotPos == dstItemSlotPos:
  716. return
  717.  
  718. if item.IsRefineScroll(srcItemVID):
  719. self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  720. self.wndItem.SetUseMode(False)
  721.  
  722. elif item.IsMetin(srcItemVID):
  723. self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  724.  
  725. elif item.IsDetachScroll(srcItemVID):
  726. self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  727.  
  728. elif item.IsKey(srcItemVID):
  729. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  730.  
  731. elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  732. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  733.  
  734. elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  735. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  736.  
  737. else:
  738. #snd.PlaySound("sound/ui/drop.wav")
  739.  
  740. ## 이동시킨 곳이 장착 슬롯일 경우 아이템을 사용해서 장착 시킨다 - [levites]
  741. if player.IsEquipmentSlot(dstItemSlotPos):
  742.  
  743. ## 들고 있는 아이템이 장비일때만
  744. if item.IsEquipmentVID(srcItemVID):
  745. self.__UseItem(srcItemSlotPos)
  746.  
  747. else:
  748. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  749. #net.SendItemMovePacket(srcItemSlotPos, dstItemSlotPos, 0)
  750.  
  751. def __SellItem(self, itemSlotPos):
  752. if not player.IsEquipmentSlot(itemSlotPos):
  753. self.sellingSlotNumber = itemSlotPos
  754. itemIndex = player.GetItemIndex(itemSlotPos)
  755. itemCount = player.GetItemCount(itemSlotPos)
  756.  
  757.  
  758. self.sellingSlotitemIndex = itemIndex
  759. self.sellingSlotitemCount = itemCount
  760.  
  761. item.SelectItem(itemIndex)
  762. itemPrice = item.GetISellItemPrice()
  763.  
  764. if item.Is1GoldItem():
  765. itemPrice = itemCount / itemPrice / 5
  766. else:
  767. itemPrice = itemPrice * itemCount / 5
  768.  
  769. item.GetItemName(itemIndex)
  770. itemName = item.GetItemName()
  771.  
  772. self.questionDialog = uiCommon.QuestionDialog()
  773. self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  774. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  775. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  776. self.questionDialog.Open()
  777. self.questionDialog.count = itemCount
  778.  
  779. def RefineItem(self, scrollSlotPos, targetSlotPos):
  780.  
  781. scrollIndex = player.GetItemIndex(scrollSlotPos)
  782. targetIndex = player.GetItemIndex(targetSlotPos)
  783.  
  784. if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  785. return
  786.  
  787. ###########################################################
  788. self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  789. #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  790. return
  791. ###########################################################
  792.  
  793. ###########################################################
  794. #net.SendRequestRefineInfoPacket(targetSlotPos)
  795. #return
  796. ###########################################################
  797.  
  798. result = player.CanRefine(scrollIndex, targetSlotPos)
  799.  
  800. if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  801. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  802. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  803.  
  804. elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  805. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  806. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  807.  
  808. elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  809. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  810. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  811.  
  812. elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  813. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  814. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  815.  
  816. elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  817. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  818.  
  819. if player.REFINE_OK != result:
  820. return
  821.  
  822. self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  823.  
  824. def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  825. scrollIndex = player.GetItemIndex(scrollSlotPos)
  826. targetIndex = player.GetItemIndex(targetSlotPos)
  827.  
  828. if not player.CanDetach(scrollIndex, targetSlotPos):
  829. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  830. return
  831.  
  832. self.questionDialog = uiCommon.QuestionDialog()
  833. self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  834. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  835. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  836. self.questionDialog.Open()
  837. self.questionDialog.sourcePos = scrollSlotPos
  838. self.questionDialog.targetPos = targetSlotPos
  839.  
  840. def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  841. metinIndex = player.GetItemIndex(metinSlotPos)
  842. targetIndex = player.GetItemIndex(targetSlotPos)
  843.  
  844. item.SelectItem(metinIndex)
  845. itemName = item.GetItemName()
  846.  
  847. result = player.CanAttachMetin(metinIndex, targetSlotPos)
  848.  
  849. if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  850. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  851.  
  852. if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  853. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  854.  
  855. elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  856. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  857.  
  858. elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  859. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  860.  
  861. if player.ATTACH_METIN_OK != result:
  862. return
  863.  
  864. self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  865.  
  866.  
  867.  
  868. def OverOutItem(self):
  869. self.wndItem.SetUsableItem(False)
  870. if None != self.tooltipItem:
  871. self.tooltipItem.HideToolTip()
  872.  
  873. def OverInItem(self, overSlotPos):
  874. overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  875. self.wndItem.SetUsableItem(False)
  876.  
  877. if mouseModule.mouseController.isAttached():
  878. attachedItemType = mouseModule.mouseController.GetAttachedType()
  879. if player.SLOT_TYPE_INVENTORY == attachedItemType:
  880.  
  881. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  882. attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  883.  
  884. if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos):
  885. self.wndItem.SetUsableItem(True)
  886. self.ShowToolTip(overSlotPos)
  887. return
  888.  
  889. self.ShowToolTip(overSlotPos)
  890.  
  891.  
  892. def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  893. "다른 아이템에 사용할 수 있는 아이템인가?"
  894.  
  895. if item.IsRefineScroll(srcItemVNum):
  896. return True
  897. elif item.IsMetin(srcItemVNum):
  898. return True
  899. elif item.IsDetachScroll(srcItemVNum):
  900. return True
  901. elif item.IsKey(srcItemVNum):
  902. return True
  903. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  904. return True
  905. else:
  906. if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  907. return True
  908.  
  909. return False
  910.  
  911. def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  912. "대상 아이템에 사용할 수 있는가?"
  913.  
  914. if srcSlotPos == dstSlotPos:
  915. return False
  916.  
  917. if item.IsRefineScroll(srcItemVNum):
  918. if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  919. return True
  920. elif item.IsMetin(srcItemVNum):
  921. if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  922. return True
  923. elif item.IsDetachScroll(srcItemVNum):
  924. if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  925. return True
  926. elif item.IsKey(srcItemVNum):
  927. if player.CanUnlock(srcItemVNum, dstSlotPos):
  928. return True
  929.  
  930. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  931. return True
  932.  
  933. else:
  934. useType=item.GetUseType(srcItemVNum)
  935.  
  936. if "USE_CLEAN_SOCKET" == useType:
  937. if self.__CanCleanBrokenMetinStone(dstSlotPos):
  938. return True
  939. elif "USE_CHANGE_ATTRIBUTE" == useType:
  940. if self.__CanChangeItemAttrList(dstSlotPos):
  941. return True
  942. elif "USE_ADD_ATTRIBUTE" == useType:
  943. if self.__CanAddItemAttr(dstSlotPos):
  944. return True
  945. elif "USE_ADD_ATTRIBUTE2" == useType:
  946. if self.__CanAddItemAttr(dstSlotPos):
  947. return True
  948. elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  949. if self.__CanAddAccessorySocket(dstSlotPos):
  950. return True
  951. elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:
  952. if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  953. return True;
  954. elif "USE_PUT_INTO_BELT_SOCKET" == useType:
  955. dstItemVNum = player.GetItemIndex(dstSlotPos)
  956. print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum
  957.  
  958. item.SelectItem(dstItemVNum)
  959.  
  960. if item.ITEM_TYPE_BELT == item.GetItemType():
  961. return True
  962.  
  963. return False
  964.  
  965. def __CanCleanBrokenMetinStone(self, dstSlotPos):
  966. dstItemVNum = player.GetItemIndex(dstSlotPos)
  967. if dstItemVNum == 0:
  968. return False
  969.  
  970. item.SelectItem(dstItemVNum)
  971.  
  972. if item.ITEM_TYPE_WEAPON != item.GetItemType():
  973. return False
  974.  
  975. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  976. if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  977. return True
  978.  
  979. return False
  980.  
  981. def __CanChangeItemAttrList(self, dstSlotPos):
  982. dstItemVNum = player.GetItemIndex(dstSlotPos)
  983. if dstItemVNum == 0:
  984. return False
  985.  
  986. item.SelectItem(dstItemVNum)
  987.  
  988. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  989. return False
  990.  
  991. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  992. if player.GetItemAttribute(dstSlotPos, i) != 0:
  993. return True
  994.  
  995. return False
  996.  
  997. def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  998. dstItemVNum = player.GetItemIndex(dstSlotPos)
  999. if dstItemVNum == 0:
  1000. return False
  1001.  
  1002. item.SelectItem(dstItemVNum)
  1003.  
  1004. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1005. return False
  1006.  
  1007. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1008. return False
  1009.  
  1010. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1011. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1012.  
  1013. if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1014. return False
  1015.  
  1016. if curCount>=maxCount:
  1017. return False
  1018.  
  1019. return True
  1020.  
  1021. def __CanAddAccessorySocket(self, dstSlotPos):
  1022. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1023. if dstItemVNum == 0:
  1024. return False
  1025.  
  1026. item.SelectItem(dstItemVNum)
  1027.  
  1028. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1029. return False
  1030.  
  1031. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1032. return False
  1033.  
  1034. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1035. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1036.  
  1037. ACCESSORY_SOCKET_MAX_SIZE = 3
  1038. if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1039. return False
  1040.  
  1041. return True
  1042.  
  1043. def __CanAddItemAttr(self, dstSlotPos):
  1044. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1045. if dstItemVNum == 0:
  1046. return False
  1047.  
  1048. item.SelectItem(dstItemVNum)
  1049.  
  1050. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1051. return False
  1052.  
  1053. attrCount = 0
  1054. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1055. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1056. attrCount += 1
  1057.  
  1058. if attrCount<4:
  1059. return True
  1060.  
  1061. return False
  1062.  
  1063. def ShowToolTip(self, slotIndex):
  1064. if None != self.tooltipItem:
  1065. self.tooltipItem.SetInventoryItem(slotIndex)
  1066.  
  1067. def OnTop(self):
  1068. if None != self.tooltipItem:
  1069. self.tooltipItem.SetTop()
  1070.  
  1071. def OnPressEscapeKey(self):
  1072. self.Close()
  1073. return True
  1074.  
  1075. def UseItemSlot(self, slotIndex):
  1076.  
  1077. curCursorNum = app.GetCursor()
  1078. if app.SELL == curCursorNum:
  1079. return
  1080.  
  1081. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS():
  1082. return
  1083.  
  1084. slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1085.  
  1086. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1087. if self.wndDragonSoulRefine.IsShow():
  1088. self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1089. return
  1090.  
  1091. self.__UseItem(slotIndex)
  1092. mouseModule.mouseController.DeattachObject()
  1093. self.OverOutItem()
  1094.  
  1095. def SetOpenBoniSwitcherEvent(self, event):
  1096. self.OpenBoniSwitcherEvent = ui.__mem_func__(event)
  1097.  
  1098. def __UseItem(self, slotIndex):
  1099. ItemVNum = player.GetItemIndex(slotIndex)
  1100. item.SelectItem(ItemVNum)
  1101. if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE):
  1102. self.questionDialog = uiCommon.QuestionDialog()
  1103. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1104. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1105. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1106. self.questionDialog.Open()
  1107. self.questionDialog.slotIndex = slotIndex
  1108.  
  1109. else:
  1110. self.__SendUseItemPacket(slotIndex)
  1111.  
  1112. def __UseItemQuestionDialog_OnCancel(self):
  1113. self.OnCloseQuestionDialog()
  1114.  
  1115. def __UseItemQuestionDialog_OnAccept(self):
  1116. self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1117.  
  1118. if self.questionDialog:
  1119. self.questionDialog.Close()
  1120. self.questionDialog = None
  1121.  
  1122. def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1123. # 개인상점 열고 있는 동안 아이템 사용 방지
  1124. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1125. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1126. return
  1127.  
  1128. net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1129.  
  1130. def __SendUseItemPacket(self, slotPos):
  1131. # 개인상점 열고 있는 동안 아이템 사용 방지
  1132. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1133. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1134. return
  1135.  
  1136. net.SendItemUsePacket(slotPos)
  1137.  
  1138. def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1139. # 개인상점 열고 있는 동안 아이템 사용 방지
  1140. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1141. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1142. return
  1143.  
  1144. net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
  1145.  
  1146. def SetDragonSoulRefineWindow(self, wndDragonSoulRefine):
  1147. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1148. self.wndDragonSoulRefine = wndDragonSoulRefine
  1149.  
  1150. def OnMoveWindow(self, x, y):
  1151. # print "Inventory Global Pos : ", self.GetGlobalPosition()
  1152. if self.wndBelt:
  1153. # print "Belt Global Pos : ", self.wndBelt.GetGlobalPosition()
  1154. self.wndBelt.AdjustPositionAndSize()
Advertisement
Add Comment
Please, Sign In to add comment