Kyuukyoku

Untitled

Apr 18th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 38.75 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. self.inventoryTab.append(self.GetChild("Inventory_Tab_03"))
  314. self.inventoryTab.append(self.GetChild("Inventory_Tab_04"))
  315.  
  316. self.equipmentTab = []
  317. self.equipmentTab.append(self.GetChild("Equipment_Tab_01"))
  318. self.equipmentTab.append(self.GetChild("Equipment_Tab_02"))
  319.  
  320. if self.costumeButton and not app.ENABLE_COSTUME_SYSTEM:
  321. self.costumeButton.Hide()
  322. self.costumeButton.Destroy()
  323. self.costumeButton = 0
  324.  
  325. # Belt Inventory Window
  326. self.wndBelt = None
  327.  
  328. if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  329. self.wndBelt = BeltInventoryWindow(self)
  330.  
  331. except:
  332. import exception
  333. exception.Abort("InventoryWindow.LoadWindow.BindObject")
  334.  
  335. ## Item
  336. wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  337. wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  338. wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  339. wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  340. wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  341. wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  342.  
  343. ## Equipment
  344. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  345. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  346. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  347. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  348. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  349. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  350.  
  351. ## PickMoneyDialog
  352. dlgPickMoney = uiPickMoney.PickMoneyDialog()
  353. dlgPickMoney.LoadDialog()
  354. dlgPickMoney.Hide()
  355.  
  356. ## RefineDialog
  357. self.refineDialog = uiRefine.RefineDialog()
  358. self.refineDialog.Hide()
  359.  
  360. ## AttachMetinDialog
  361. self.attachMetinDialog = uiAttachMetin.AttachMetinDialog()
  362. self.attachMetinDialog.Hide()
  363.  
  364. ## MoneySlot
  365. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
  366.  
  367. self.inventoryTab[0].SetEvent(lambda arg=0: self.SetInventoryPage(arg))
  368. self.inventoryTab[1].SetEvent(lambda arg=1: self.SetInventoryPage(arg))
  369. self.inventoryTab[2].SetEvent(lambda arg=2: self.SetInventoryPage(arg))
  370. self.inventoryTab[3].SetEvent(lambda arg=3: self.SetInventoryPage(arg))
  371. self.inventoryTab[0].Down()
  372. self.inventoryPageIndex = 0
  373.  
  374. self.equipmentTab[0].SetEvent(lambda arg=0: self.SetEquipmentPage(arg))
  375. self.equipmentTab[1].SetEvent(lambda arg=1: self.SetEquipmentPage(arg))
  376. self.equipmentTab[0].Down()
  377. self.equipmentTab[0].Hide()
  378. self.equipmentTab[1].Hide()
  379.  
  380. self.wndItem = wndItem
  381. self.wndEquip = wndEquip
  382. self.dlgPickMoney = dlgPickMoney
  383.  
  384. # MallButton
  385. if self.mallButton:
  386. self.mallButton.SetEvent(ui.__mem_func__(self.ClickMallButton))
  387.  
  388. if self.DSSButton:
  389. self.DSSButton.SetEvent(ui.__mem_func__(self.ClickDSSButton))
  390.  
  391. # Costume Button
  392. if self.costumeButton:
  393. self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))
  394.  
  395. self.wndCostume = None
  396.  
  397. #####
  398.  
  399. ## Refresh
  400. self.SetInventoryPage(0)
  401. self.SetEquipmentPage(0)
  402. self.RefreshItemSlot()
  403. self.RefreshStatus()
  404.  
  405. def Destroy(self):
  406. self.ClearDictionary()
  407.  
  408. self.dlgPickMoney.Destroy()
  409. self.dlgPickMoney = 0
  410.  
  411. self.refineDialog.Destroy()
  412. self.refineDialog = 0
  413.  
  414. self.attachMetinDialog.Destroy()
  415. self.attachMetinDialog = 0
  416.  
  417. self.tooltipItem = None
  418. self.wndItem = 0
  419. self.wndEquip = 0
  420. self.dlgPickMoney = 0
  421. self.wndMoney = 0
  422. self.wndMoneySlot = 0
  423. self.questionDialog = None
  424. self.mallButton = None
  425. self.DSSButton = None
  426. self.interface = None
  427.  
  428. if self.wndCostume:
  429. self.wndCostume.Destroy()
  430. self.wndCostume = 0
  431.  
  432. if self.wndBelt:
  433. self.wndBelt.Destroy()
  434. self.wndBelt = None
  435.  
  436. self.inventoryTab = []
  437. self.equipmentTab = []
  438.  
  439. def Hide(self):
  440. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  441. self.OnCloseQuestionDialog()
  442. return
  443. if None != self.tooltipItem:
  444. self.tooltipItem.HideToolTip()
  445.  
  446. if self.wndCostume:
  447. self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow() # 인벤토리 창이 닫힐 때 코스츔이 열려 있었는가?
  448. self.wndCostume.Close()
  449.  
  450. if self.wndBelt:
  451. self.isOpenedBeltWindowWhenClosingInventory = self.wndBelt.IsOpeningInventory() # 인벤토리 창이 닫힐 때 벨트 인벤토리도 열려 있었는가?
  452. print "Is Opening Belt Inven?? ", self.isOpenedBeltWindowWhenClosingInventory
  453. self.wndBelt.Close()
  454.  
  455. if self.dlgPickMoney:
  456. self.dlgPickMoney.Close()
  457.  
  458. wndMgr.Hide(self.hWnd)
  459.  
  460.  
  461. def Close(self):
  462. self.Hide()
  463.  
  464. def SetInventoryPage(self, page):
  465. self.inventoryTab[self.inventoryPageIndex].SetUp()
  466. self.inventoryPageIndex = page
  467. self.inventoryTab[self.inventoryPageIndex].Down()
  468. self.RefreshBagSlotWindow()
  469.  
  470. def SetEquipmentPage(self, page):
  471. self.equipmentPageIndex = page
  472. self.equipmentTab[1-page].SetUp()
  473. self.RefreshEquipSlotWindow()
  474.  
  475. def ClickMallButton(self):
  476. print "click_mall_button"
  477. net.SendChatPacket("/click_mall")
  478.  
  479. # DSSButton
  480. def ClickDSSButton(self):
  481. print "click_dss_button"
  482. self.interface.ToggleDragonSoulWindow()
  483.  
  484. def ClickCostumeButton(self):
  485. print "Click Costume Button"
  486. if self.wndCostume:
  487. if self.wndCostume.IsShow():
  488. self.wndCostume.Hide()
  489. else:
  490. self.wndCostume.Show()
  491. else:
  492. self.wndCostume = CostumeWindow(self)
  493. self.wndCostume.Show()
  494.  
  495. def OpenPickMoneyDialog(self):
  496.  
  497. if mouseModule.mouseController.isAttached():
  498.  
  499. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  500. if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  501.  
  502. if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  503. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  504. snd.PlaySound("sound/ui/money.wav")
  505.  
  506. mouseModule.mouseController.DeattachObject()
  507.  
  508. else:
  509. curMoney = player.GetElk()
  510.  
  511. if curMoney <= 0:
  512. return
  513.  
  514. self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  515. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  516. self.dlgPickMoney.Open(curMoney)
  517. self.dlgPickMoney.SetMax(7) # 인벤토리 990000 제한 버그 수정
  518.  
  519. def OnPickMoney(self, money):
  520. mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  521.  
  522. def OnPickItem(self, count):
  523. itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  524. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  525. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  526.  
  527. def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  528. if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local) or (app.ENABLE_NEW_EQUIPMENT_SYSTEM and player.IsBeltInventorySlot(local)):
  529. return local
  530.  
  531. return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  532.  
  533. def RefreshBagSlotWindow(self):
  534. getItemVNum=player.GetItemIndex
  535. getItemCount=player.GetItemCount
  536. setItemVNum=self.wndItem.SetItemSlot
  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*self.inventoryPageIndex:
  558. slotNumber -= player.INVENTORY_PAGE_SIZE*self.inventoryPageIndex
  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. self.wndItem.RefreshSlot()
  578.  
  579. if self.wndBelt:
  580. self.wndBelt.RefreshSlot()
  581.  
  582. def RefreshEquipSlotWindow(self):
  583. getItemVNum=player.GetItemIndex
  584. getItemCount=player.GetItemCount
  585. setItemVNum=self.wndEquip.SetItemSlot
  586. for i in xrange(player.EQUIPMENT_PAGE_COUNT):
  587. slotNumber = player.EQUIPMENT_SLOT_START + i
  588. itemCount = getItemCount(slotNumber)
  589. if itemCount <= 1:
  590. itemCount = 0
  591. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  592.  
  593. if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  594. for i in xrange(player.NEW_EQUIPMENT_SLOT_COUNT):
  595. slotNumber = player.NEW_EQUIPMENT_SLOT_START + i
  596. itemCount = getItemCount(slotNumber)
  597. if itemCount <= 1:
  598. itemCount = 0
  599. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  600. print "ENABLE_NEW_EQUIPMENT_SYSTEM", slotNumber, itemCount, getItemVNum(slotNumber)
  601.  
  602.  
  603.  
  604. self.wndEquip.RefreshSlot()
  605.  
  606. if self.wndCostume:
  607. self.wndCostume.RefreshCostumeSlot()
  608.  
  609. def RefreshItemSlot(self):
  610. self.RefreshBagSlotWindow()
  611. self.RefreshEquipSlotWindow()
  612.  
  613. def RefreshStatus(self):
  614. money = player.GetElk()
  615. self.wndMoney.SetText(localeInfo.NumberToMoneyString(money))
  616.  
  617. def SetItemToolTip(self, tooltipItem):
  618. self.tooltipItem = tooltipItem
  619.  
  620. def SellItem(self):
  621. if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  622. if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  623. ## 용혼석도 팔리게 하는 기능 추가하면서 인자 type 추가
  624. net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY)
  625. snd.PlaySound("sound/ui/money.wav")
  626. self.OnCloseQuestionDialog()
  627.  
  628. def OnDetachMetinFromItem(self):
  629. if None == self.questionDialog:
  630. return
  631.  
  632. #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  633. self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  634. self.OnCloseQuestionDialog()
  635.  
  636. def OnCloseQuestionDialog(self):
  637. if not self.questionDialog:
  638. return
  639.  
  640. self.questionDialog.Close()
  641. self.questionDialog = None
  642. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  643.  
  644. ## Slot Event
  645. def SelectEmptySlot(self, selectedSlotPos):
  646. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  647. return
  648.  
  649. selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  650.  
  651. if mouseModule.mouseController.isAttached():
  652.  
  653. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  654. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  655. attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  656. attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  657.  
  658. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  659. itemCount = player.GetItemCount(attachedSlotPos)
  660. attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  661. self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  662.  
  663. if item.IsRefineScroll(attachedItemIndex):
  664. self.wndItem.SetUseMode(False)
  665.  
  666. elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  667. mouseModule.mouseController.RunCallBack("INVENTORY")
  668.  
  669. elif player.SLOT_TYPE_SHOP == attachedSlotType:
  670. net.SendShopBuyPacket(attachedSlotPos)
  671.  
  672. elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  673.  
  674. if player.ITEM_MONEY == attachedItemIndex:
  675. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  676. snd.PlaySound("sound/ui/money.wav")
  677.  
  678. else:
  679. net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  680.  
  681. elif player.SLOT_TYPE_MALL == attachedSlotType:
  682. net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  683.  
  684. mouseModule.mouseController.DeattachObject()
  685.  
  686. def SelectItemSlot(self, itemSlotIndex):
  687. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  688. return
  689.  
  690. itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  691.  
  692. if mouseModule.mouseController.isAttached():
  693. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  694. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  695. attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  696.  
  697. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  698. self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  699.  
  700. mouseModule.mouseController.DeattachObject()
  701.  
  702. else:
  703.  
  704. curCursorNum = app.GetCursor()
  705. if app.SELL == curCursorNum:
  706. self.__SellItem(itemSlotIndex)
  707.  
  708. elif app.BUY == curCursorNum:
  709. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  710.  
  711. elif app.IsPressed(app.DIK_LALT):
  712. link = player.GetItemLink(itemSlotIndex)
  713. ime.PasteString(link)
  714.  
  715. elif app.IsPressed(app.DIK_LSHIFT):
  716. itemCount = player.GetItemCount(itemSlotIndex)
  717.  
  718. if itemCount > 1:
  719. self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  720. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  721. self.dlgPickMoney.Open(itemCount)
  722. self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  723. #else:
  724. #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  725. #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  726.  
  727. elif app.IsPressed(app.DIK_LCONTROL):
  728. itemIndex = player.GetItemIndex(itemSlotIndex)
  729.  
  730. if True == item.CanAddToQuickSlotItem(itemIndex):
  731. player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  732. else:
  733. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  734.  
  735. else:
  736. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  737. itemCount = player.GetItemCount(itemSlotIndex)
  738. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  739.  
  740. if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):
  741. self.wndItem.SetUseMode(True)
  742. else:
  743. self.wndItem.SetUseMode(False)
  744.  
  745. snd.PlaySound("sound/ui/pick.wav")
  746.  
  747. def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  748. if srcItemSlotPos == dstItemSlotPos:
  749. return
  750.  
  751. elif item.IsRefineScroll(srcItemVID):
  752. self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  753. self.wndItem.SetUseMode(False)
  754.  
  755. elif item.IsMetin(srcItemVID):
  756. self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  757.  
  758. elif item.IsDetachScroll(srcItemVID):
  759. self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  760.  
  761. elif item.IsKey(srcItemVID):
  762. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  763.  
  764. elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  765. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  766.  
  767. elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  768. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  769.  
  770. else:
  771. #snd.PlaySound("sound/ui/drop.wav")
  772.  
  773. ## 이동시킨 곳이 장착 슬롯일 경우 아이템을 사용해서 장착 시킨다 - [levites]
  774. if player.IsEquipmentSlot(dstItemSlotPos):
  775.  
  776. ## 들고 있는 아이템이 장비일때만
  777. if item.IsEquipmentVID(srcItemVID):
  778. self.__UseItem(srcItemSlotPos)
  779.  
  780. else:
  781. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  782. #net.SendItemMovePacket(srcItemSlotPos, dstItemSlotPos, 0)
  783.  
  784. def __SellItem(self, itemSlotPos):
  785. if not player.IsEquipmentSlot(itemSlotPos):
  786. self.sellingSlotNumber = itemSlotPos
  787. itemIndex = player.GetItemIndex(itemSlotPos)
  788. itemCount = player.GetItemCount(itemSlotPos)
  789.  
  790.  
  791. self.sellingSlotitemIndex = itemIndex
  792. self.sellingSlotitemCount = itemCount
  793.  
  794. item.SelectItem(itemIndex)
  795. ## 안티 플레그 검사 빠져서 추가
  796. ## 20140220
  797. if item.IsAntiFlag(item.ANTIFLAG_SELL):
  798. popup = uiCommon.PopupDialog()
  799. popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  800. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  801. popup.Open()
  802. self.popup = popup
  803. return
  804.  
  805. itemPrice = item.GetISellItemPrice()
  806.  
  807. if item.Is1GoldItem():
  808. itemPrice = itemCount / itemPrice / 5
  809. else:
  810. itemPrice = itemPrice * itemCount / 5
  811.  
  812. item.GetItemName(itemIndex)
  813. itemName = item.GetItemName()
  814.  
  815. self.questionDialog = uiCommon.QuestionDialog()
  816. self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  817. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  818. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  819. self.questionDialog.Open()
  820. self.questionDialog.count = itemCount
  821.  
  822. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  823.  
  824. def __OnClosePopupDialog(self):
  825. self.pop = None
  826.  
  827. def RefineItem(self, scrollSlotPos, targetSlotPos):
  828.  
  829. scrollIndex = player.GetItemIndex(scrollSlotPos)
  830. targetIndex = player.GetItemIndex(targetSlotPos)
  831.  
  832. if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  833. return
  834.  
  835. ###########################################################
  836. self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  837. #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  838. return
  839. ###########################################################
  840.  
  841. ###########################################################
  842. #net.SendRequestRefineInfoPacket(targetSlotPos)
  843. #return
  844. ###########################################################
  845.  
  846. result = player.CanRefine(scrollIndex, targetSlotPos)
  847.  
  848. if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  849. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  850. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  851.  
  852. elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  853. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  854. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  855.  
  856. elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  857. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  858. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  859.  
  860. elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  861. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  862. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  863.  
  864. elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  865. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  866.  
  867. if player.REFINE_OK != result:
  868. return
  869.  
  870. self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  871.  
  872. def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  873. scrollIndex = player.GetItemIndex(scrollSlotPos)
  874. targetIndex = player.GetItemIndex(targetSlotPos)
  875.  
  876. if not player.CanDetach(scrollIndex, targetSlotPos):
  877. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  878. return
  879.  
  880. self.questionDialog = uiCommon.QuestionDialog()
  881. self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  882. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  883. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  884. self.questionDialog.Open()
  885. self.questionDialog.sourcePos = scrollSlotPos
  886. self.questionDialog.targetPos = targetSlotPos
  887.  
  888. def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  889. metinIndex = player.GetItemIndex(metinSlotPos)
  890. targetIndex = player.GetItemIndex(targetSlotPos)
  891.  
  892. item.SelectItem(metinIndex)
  893. itemName = item.GetItemName()
  894.  
  895. result = player.CanAttachMetin(metinIndex, targetSlotPos)
  896.  
  897. if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  898. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  899.  
  900. if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  901. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  902.  
  903. elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  904. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  905.  
  906. elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  907. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  908.  
  909. if player.ATTACH_METIN_OK != result:
  910. return
  911.  
  912. self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  913.  
  914.  
  915.  
  916. def OverOutItem(self):
  917. self.wndItem.SetUsableItem(False)
  918. if None != self.tooltipItem:
  919. self.tooltipItem.HideToolTip()
  920.  
  921. def OverInItem(self, overSlotPos):
  922. overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  923. self.wndItem.SetUsableItem(False)
  924.  
  925. if mouseModule.mouseController.isAttached():
  926. attachedItemType = mouseModule.mouseController.GetAttachedType()
  927. if player.SLOT_TYPE_INVENTORY == attachedItemType:
  928.  
  929. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  930. attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  931.  
  932. if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos):
  933. self.wndItem.SetUsableItem(True)
  934. self.ShowToolTip(overSlotPos)
  935. return
  936.  
  937. self.ShowToolTip(overSlotPos)
  938.  
  939.  
  940. def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  941. "다른 아이템에 사용할 수 있는 아이템인가?"
  942.  
  943. if item.IsRefineScroll(srcItemVNum):
  944. return True
  945. elif item.IsMetin(srcItemVNum):
  946. return True
  947. elif item.IsDetachScroll(srcItemVNum):
  948. return True
  949. elif item.IsKey(srcItemVNum):
  950. return True
  951. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  952. return True
  953. else:
  954. if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  955. return True
  956.  
  957. return False
  958.  
  959. def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  960. "대상 아이템에 사용할 수 있는가?"
  961.  
  962. if srcSlotPos == dstSlotPos:
  963. return False
  964.  
  965. if item.IsRefineScroll(srcItemVNum):
  966. if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  967. return True
  968. elif item.IsMetin(srcItemVNum):
  969. if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  970. return True
  971. elif item.IsDetachScroll(srcItemVNum):
  972. if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  973. return True
  974. elif item.IsKey(srcItemVNum):
  975. if player.CanUnlock(srcItemVNum, dstSlotPos):
  976. return True
  977.  
  978. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  979. return True
  980.  
  981. else:
  982. useType=item.GetUseType(srcItemVNum)
  983.  
  984. if "USE_CLEAN_SOCKET" == useType:
  985. if self.__CanCleanBrokenMetinStone(dstSlotPos):
  986. return True
  987. elif "USE_CHANGE_ATTRIBUTE" == useType:
  988. if self.__CanChangeItemAttrList(dstSlotPos):
  989. return True
  990. elif "USE_ADD_ATTRIBUTE" == useType:
  991. if self.__CanAddItemAttr(dstSlotPos):
  992. return True
  993. elif "USE_ADD_ATTRIBUTE2" == useType:
  994. if self.__CanAddItemAttr(dstSlotPos):
  995. return True
  996. elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  997. if self.__CanAddAccessorySocket(dstSlotPos):
  998. return True
  999. elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:
  1000. if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  1001. return TRUE;
  1002. elif "USE_PUT_INTO_BELT_SOCKET" == useType:
  1003. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1004. print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum
  1005.  
  1006. item.SelectItem(dstItemVNum)
  1007.  
  1008. if item.ITEM_TYPE_BELT == item.GetItemType():
  1009. return True
  1010.  
  1011. return False
  1012.  
  1013. def __CanCleanBrokenMetinStone(self, dstSlotPos):
  1014. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1015. if dstItemVNum == 0:
  1016. return False
  1017.  
  1018. item.SelectItem(dstItemVNum)
  1019.  
  1020. if item.ITEM_TYPE_WEAPON != item.GetItemType():
  1021. return False
  1022.  
  1023. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1024. if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  1025. return True
  1026.  
  1027. return False
  1028.  
  1029. def __CanChangeItemAttrList(self, dstSlotPos):
  1030. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1031. if dstItemVNum == 0:
  1032. return False
  1033.  
  1034. item.SelectItem(dstItemVNum)
  1035.  
  1036. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1037. return False
  1038.  
  1039. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1040. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1041. return True
  1042.  
  1043. return False
  1044.  
  1045. def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  1046. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1047. if dstItemVNum == 0:
  1048. return False
  1049.  
  1050. item.SelectItem(dstItemVNum)
  1051.  
  1052. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1053. return False
  1054.  
  1055. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1056. return False
  1057.  
  1058. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1059. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1060.  
  1061. if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1062. return False
  1063.  
  1064. if curCount>=maxCount:
  1065. return False
  1066.  
  1067. return True
  1068.  
  1069. def __CanAddAccessorySocket(self, dstSlotPos):
  1070. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1071. if dstItemVNum == 0:
  1072. return False
  1073.  
  1074. item.SelectItem(dstItemVNum)
  1075.  
  1076. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1077. return False
  1078.  
  1079. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1080. return False
  1081.  
  1082. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1083. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1084.  
  1085. ACCESSORY_SOCKET_MAX_SIZE = 3
  1086. if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1087. return False
  1088.  
  1089. return True
  1090.  
  1091. def __CanAddItemAttr(self, dstSlotPos):
  1092. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1093. if dstItemVNum == 0:
  1094. return False
  1095.  
  1096. item.SelectItem(dstItemVNum)
  1097.  
  1098. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1099. return False
  1100.  
  1101. attrCount = 0
  1102. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1103. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1104. attrCount += 1
  1105.  
  1106. if attrCount<4:
  1107. return True
  1108.  
  1109. return False
  1110.  
  1111. def ShowToolTip(self, slotIndex):
  1112. if None != self.tooltipItem:
  1113. self.tooltipItem.SetInventoryItem(slotIndex)
  1114.  
  1115. def OnTop(self):
  1116. if None != self.tooltipItem:
  1117. self.tooltipItem.SetTop()
  1118.  
  1119. def OnPressEscapeKey(self):
  1120. self.Close()
  1121. return True
  1122.  
  1123. def UseItemSlot(self, slotIndex):
  1124. curCursorNum = app.GetCursor()
  1125. if app.SELL == curCursorNum:
  1126. return
  1127.  
  1128. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  1129. return
  1130.  
  1131. slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1132.  
  1133. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1134. if self.wndDragonSoulRefine.IsShow():
  1135. self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1136. return
  1137.  
  1138. self.__UseItem(slotIndex)
  1139. mouseModule.mouseController.DeattachObject()
  1140. self.OverOutItem()
  1141.  
  1142. def __UseItem(self, slotIndex):
  1143. ItemVNum = player.GetItemIndex(slotIndex)
  1144. item.SelectItem(ItemVNum)
  1145. if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE):
  1146. self.questionDialog = uiCommon.QuestionDialog()
  1147. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1148. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1149. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1150. self.questionDialog.Open()
  1151. self.questionDialog.slotIndex = slotIndex
  1152.  
  1153. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  1154.  
  1155. else:
  1156. self.__SendUseItemPacket(slotIndex)
  1157. #net.SendItemUsePacket(slotIndex)
  1158.  
  1159. def __UseItemQuestionDialog_OnCancel(self):
  1160. self.OnCloseQuestionDialog()
  1161.  
  1162. def __UseItemQuestionDialog_OnAccept(self):
  1163. self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1164. self.OnCloseQuestionDialog()
  1165.  
  1166. def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1167. # 개인상점 열고 있는 동안 아이템 사용 방지
  1168. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1169. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1170. return
  1171.  
  1172. net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1173.  
  1174. def __SendUseItemPacket(self, slotPos):
  1175. # 개인상점 열고 있는 동안 아이템 사용 방지
  1176. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1177. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1178. return
  1179.  
  1180. net.SendItemUsePacket(slotPos)
  1181.  
  1182. def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1183. # 개인상점 열고 있는 동안 아이템 사용 방지
  1184. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1185. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1186. return
  1187.  
  1188. net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
  1189.  
  1190. def SetDragonSoulRefineWindow(self, wndDragonSoulRefine):
  1191. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1192. self.wndDragonSoulRefine = wndDragonSoulRefine
  1193.  
  1194. def OnMoveWindow(self, x, y):
  1195. # print "Inventory Global Pos : ", self.GetGlobalPosition()
  1196. if self.wndBelt:
  1197. # print "Belt Global Pos : ", self.wndBelt.GetGlobalPosition()
  1198. self.wndBelt.AdjustPositionAndSize()
Advertisement
Add Comment
Please, Sign In to add comment