elws

zzz

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