Advertisement
Guest User

uiinventory

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