Advertisement
Guest User

Untitled

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