MrP0wers

uiinventory.py

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