Guest User

uiinventory.py

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