Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 47.48 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. if app.ENABLE_SASH_SYSTEM:
  25. import sash
  26. ITEM_FLAG_APPLICABLE = 1 << 14
  27.  
  28. class CostumeWindow(ui.ScriptWindow):
  29.  
  30. def __init__(self, wndInventory):
  31. import exception
  32.  
  33. if not app.ENABLE_COSTUME_SYSTEM:
  34. exception.Abort("What do you do?")
  35. return
  36.  
  37. if not wndInventory:
  38. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  39. return
  40.  
  41. ui.ScriptWindow.__init__(self)
  42.  
  43. self.isLoaded = 0
  44. self.wndInventory = wndInventory;
  45.  
  46. self.__LoadWindow()
  47.  
  48. def __del__(self):
  49. ui.ScriptWindow.__del__(self)
  50.  
  51. def Show(self):
  52. self.__LoadWindow()
  53. self.RefreshCostumeSlot()
  54.  
  55. ui.ScriptWindow.Show(self)
  56.  
  57. def Close(self):
  58. self.Hide()
  59.  
  60. def __LoadWindow(self):
  61. if self.isLoaded == 1:
  62. return
  63.  
  64. self.isLoaded = 1
  65.  
  66. try:
  67. pyScrLoader = ui.PythonScriptLoader()
  68. pyScrLoader.LoadScriptFile(self, "UIScript/CostumeWindow.py")
  69. except:
  70. import exception
  71. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  72.  
  73. try:
  74. wndEquip = self.GetChild("CostumeSlot")
  75. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  76.  
  77. except:
  78. import exception
  79. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  80.  
  81. ## Equipment
  82. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  83. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  84. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  85. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  86. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  87. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  88.  
  89. self.wndEquip = wndEquip
  90.  
  91. def RefreshCostumeSlot(self):
  92. getItemVNum=player.GetItemIndex
  93.  
  94. for i in xrange(item.COSTUME_SLOT_COUNT):
  95. slotNumber = item.COSTUME_SLOT_START + i
  96. self.wndEquip.SetItemSlot(slotNumber, getItemVNum(slotNumber), 0)
  97.  
  98. self.wndEquip.RefreshSlot()
  99.  
  100. class BeltInventoryWindow(ui.ScriptWindow):
  101.  
  102. def __init__(self, wndInventory):
  103. import exception
  104.  
  105. if not app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  106. exception.Abort("What do you do?")
  107. return
  108.  
  109. if not wndInventory:
  110. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  111. return
  112.  
  113. ui.ScriptWindow.__init__(self)
  114.  
  115. self.isLoaded = 0
  116. self.wndInventory = wndInventory;
  117.  
  118. self.wndBeltInventoryLayer = None
  119. self.wndBeltInventorySlot = None
  120. self.expandBtn = None
  121. self.minBtn = None
  122.  
  123. self.__LoadWindow()
  124.  
  125. def __del__(self):
  126. ui.ScriptWindow.__del__(self)
  127.  
  128. def Show(self, openBeltSlot = FALSE):
  129. self.__LoadWindow()
  130. self.RefreshSlot()
  131.  
  132. ui.ScriptWindow.Show(self)
  133.  
  134. if openBeltSlot:
  135. self.OpenInventory()
  136. else:
  137. self.CloseInventory()
  138.  
  139. def Close(self):
  140. self.Hide()
  141.  
  142. def IsOpeningInventory(self):
  143. return self.wndBeltInventoryLayer.IsShow()
  144.  
  145. def OpenInventory(self):
  146. self.wndBeltInventoryLayer.Show()
  147. self.expandBtn.Hide()
  148.  
  149. if localeInfo.IsARABIC() == 0:
  150. self.AdjustPositionAndSize()
  151.  
  152. def CloseInventory(self):
  153. self.wndBeltInventoryLayer.Hide()
  154. self.expandBtn.Show()
  155.  
  156. if localeInfo.IsARABIC() == 0:
  157. self.AdjustPositionAndSize()
  158.  
  159. ## 현재 인벤토리 위치를 기준으로 BASE 위치를 계산, 리턴.. 숫자 하드코딩하기 정말 싫지만 방법이 없다..
  160. def GetBasePosition(self):
  161. x, y = self.wndInventory.GetGlobalPosition()
  162. return x - 148, y + 241
  163.  
  164. def AdjustPositionAndSize(self):
  165. bx, by = self.GetBasePosition()
  166.  
  167. if self.IsOpeningInventory():
  168. self.SetPosition(bx, by)
  169. self.SetSize(self.ORIGINAL_WIDTH, self.GetHeight())
  170.  
  171. else:
  172. self.SetPosition(bx + 138, by);
  173. self.SetSize(10, self.GetHeight())
  174.  
  175. def __LoadWindow(self):
  176. if self.isLoaded == 1:
  177. return
  178.  
  179. self.isLoaded = 1
  180.  
  181. try:
  182. pyScrLoader = ui.PythonScriptLoader()
  183. pyScrLoader.LoadScriptFile(self, "UIScript/BeltInventoryWindow.py")
  184. except:
  185. import exception
  186. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  187.  
  188. try:
  189. self.ORIGINAL_WIDTH = self.GetWidth()
  190. wndBeltInventorySlot = self.GetChild("BeltInventorySlot")
  191. self.wndBeltInventoryLayer = self.GetChild("BeltInventoryLayer")
  192. self.expandBtn = self.GetChild("ExpandBtn")
  193. self.minBtn = self.GetChild("MinimizeBtn")
  194.  
  195. self.expandBtn.SetEvent(ui.__mem_func__(self.OpenInventory))
  196. self.minBtn.SetEvent(ui.__mem_func__(self.CloseInventory))
  197.  
  198. if localeInfo.IsARABIC() :
  199. self.expandBtn.SetPosition(self.expandBtn.GetWidth() - 2, 15)
  200. self.wndBeltInventoryLayer.SetPosition(self.wndBeltInventoryLayer.GetWidth() - 5, 0)
  201. self.minBtn.SetPosition(self.minBtn.GetWidth() + 3, 15)
  202.  
  203. for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  204. slotNumber = item.BELT_INVENTORY_SLOT_START + i
  205. wndBeltInventorySlot.SetCoverButton(slotNumber, "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  206. "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  207. "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  208. "d:/ymir work/ui/game/belt_inventory/slot_disabled.tga", FALSE, FALSE)
  209.  
  210. except:
  211. import exception
  212. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  213.  
  214. ## Equipment
  215. wndBeltInventorySlot.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  216. wndBeltInventorySlot.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  217. wndBeltInventorySlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  218. wndBeltInventorySlot.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  219. wndBeltInventorySlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  220. wndBeltInventorySlot.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  221.  
  222. self.wndBeltInventorySlot = wndBeltInventorySlot
  223.  
  224. def RefreshSlot(self):
  225. getItemVNum=player.GetItemIndex
  226.  
  227. for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  228. slotNumber = item.BELT_INVENTORY_SLOT_START + i
  229. self.wndBeltInventorySlot.SetItemSlot(slotNumber, getItemVNum(slotNumber), player.GetItemCount(slotNumber))
  230. self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(slotNumber, TRUE)
  231.  
  232. avail = "0"
  233.  
  234. if player.IsAvailableBeltInventoryCell(slotNumber):
  235. self.wndBeltInventorySlot.EnableCoverButton(slotNumber)
  236. else:
  237. self.wndBeltInventorySlot.DisableCoverButton(slotNumber)
  238.  
  239. self.wndBeltInventorySlot.RefreshSlot()
  240.  
  241.  
  242. class InventoryWindow(ui.ScriptWindow):
  243.  
  244. USE_TYPE_TUPLE = ("USE_CLEAN_SOCKET", "USE_CHANGE_ATTRIBUTE", "USE_ADD_ATTRIBUTE", "USE_ADD_ATTRIBUTE2", "USE_ADD_ACCESSORY_SOCKET", "USE_PUT_INTO_ACCESSORY_SOCKET", "USE_PUT_INTO_BELT_SOCKET", "USE_PUT_INTO_RING_SOCKET")
  245.  
  246. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  247. USE_TYPE_TUPLE = USE_TYPE_TUPLE + ("USE_RESET_LOOK_VNUM",)
  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.Hide()
  393. self.DSSButton.SetEvent(ui.__mem_func__(self.ClickDSSButton))
  394.  
  395. # Costume Button
  396. if self.costumeButton:
  397. self.costumeButton.SetEvent(ui.__mem_func__(self.ClickCostumeButton))
  398.  
  399. self.wndCostume = None
  400.  
  401. #####
  402.  
  403. ## Refresh
  404. if app.ENABLE_SASH_SYSTEM:
  405. self.listAttachedSashs = []
  406. self.SetInventoryPage(0)
  407. self.SetEquipmentPage(0)
  408. self.RefreshItemSlot()
  409. self.RefreshStatus()
  410.  
  411. def Destroy(self):
  412. self.ClearDictionary()
  413.  
  414. self.dlgPickMoney.Destroy()
  415. self.dlgPickMoney = 0
  416.  
  417. self.refineDialog.Destroy()
  418. self.refineDialog = 0
  419.  
  420. self.attachMetinDialog.Destroy()
  421. self.attachMetinDialog = 0
  422.  
  423. self.tooltipItem = None
  424. self.wndItem = 0
  425. self.wndEquip = 0
  426. self.dlgPickMoney = 0
  427. self.wndMoney = 0
  428. self.wndMoneySlot = 0
  429. self.questionDialog = None
  430. self.mallButton = None
  431. self.DSSButton = None
  432. self.interface = None
  433.  
  434. if self.wndCostume:
  435. self.wndCostume.Destroy()
  436. self.wndCostume = 0
  437.  
  438. if self.wndBelt:
  439. self.wndBelt.Destroy()
  440. self.wndBelt = None
  441.  
  442. self.inventoryTab = []
  443. self.equipmentTab = []
  444.  
  445. def Hide(self):
  446. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  447. self.OnCloseQuestionDialog()
  448. return
  449. if None != self.tooltipItem:
  450. self.tooltipItem.HideToolTip()
  451.  
  452. if self.wndCostume:
  453. self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow() # 인벤토리 창이 닫힐 때 코스츔이 열려 있었는가?
  454. self.wndCostume.Close()
  455.  
  456. if self.wndBelt:
  457. self.isOpenedBeltWindowWhenClosingInventory = self.wndBelt.IsOpeningInventory() # 인벤토리 창이 닫힐 때 벨트 인벤토리도 열려 있었는가?
  458. print "Is Opening Belt Inven?? ", self.isOpenedBeltWindowWhenClosingInventory
  459. self.wndBelt.Close()
  460.  
  461. if self.dlgPickMoney:
  462. self.dlgPickMoney.Close()
  463.  
  464. wndMgr.Hide(self.hWnd)
  465.  
  466.  
  467. def Close(self):
  468. self.Hide()
  469.  
  470. # def SetInventoryPage(self, page):
  471. # self.inventoryTab[self.inventoryPageIndex].SetUp()
  472. # self.inventoryPageIndex = page
  473. # self.RefreshBagSlotWindow()
  474.  
  475. def SetInventoryPage(self, page):
  476. self.inventoryTab[self.inventoryPageIndex].SetUp()
  477. self.inventoryPageIndex = page
  478. self.inventoryTab[self.inventoryPageIndex].Down()
  479. self.RefreshBagSlotWindow()
  480.  
  481. def SetEquipmentPage(self, page):
  482. self.equipmentPageIndex = page
  483. self.equipmentTab[1-page].SetUp()
  484. self.RefreshEquipSlotWindow()
  485.  
  486. def ClickMallButton(self):
  487. print "click_mall_button"
  488. net.SendChatPacket("/click_mall")
  489.  
  490. # DSSButton
  491. def ClickDSSButton(self):
  492. print "click_dss_button"
  493. self.interface.ToggleDragonSoulWindow()
  494.  
  495. def ClickCostumeButton(self):
  496. print "Click Costume Button"
  497. if self.wndCostume:
  498. if self.wndCostume.IsShow():
  499. self.wndCostume.Hide()
  500. else:
  501. self.wndCostume.Show()
  502. else:
  503. self.wndCostume = CostumeWindow(self)
  504. self.wndCostume.Show()
  505.  
  506. def OpenPickMoneyDialog(self):
  507.  
  508. if mouseModule.mouseController.isAttached():
  509.  
  510. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  511. if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  512.  
  513. if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  514. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  515. snd.PlaySound("sound/ui/money.wav")
  516.  
  517. mouseModule.mouseController.DeattachObject()
  518.  
  519. else:
  520. curMoney = player.GetElk()
  521.  
  522. if curMoney <= 0:
  523. return
  524.  
  525. self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  526. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  527. self.dlgPickMoney.Open(curMoney)
  528. self.dlgPickMoney.SetMax(7) # 인벤토리 990000 제한 버그 수정
  529.  
  530. def OnPickMoney(self, money):
  531. mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  532.  
  533. def OnPickItem(self, count):
  534. itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  535. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  536. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  537.  
  538. def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  539. if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local) or (app.ENABLE_NEW_EQUIPMENT_SYSTEM and player.IsBeltInventorySlot(local)):
  540. return local
  541.  
  542. return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  543.  
  544. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  545. def OnUpdate(self):
  546. self.RefreshBagSlotWindow()
  547.  
  548. for i in xrange(player.INVENTORY_PAGE_SIZE):
  549. GlobalSlot = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  550.  
  551. if player.GetItemLook(GlobalSlot):
  552. self.wndItem.EnableSlotCoverImage(i)
  553. else:
  554. self.wndItem.DisableSlotCoverImage(i)
  555.  
  556. if player.FindActivedChangeLookSlot(0) == GlobalSlot or player.FindActivedChangeLookSlot(1) == GlobalSlot:
  557. self.wndItem.ActivateChangeLookSlot(i)
  558. else:
  559. self.wndItem.DeactivateChangeLookSlot(i)
  560. # Sash Lennt
  561. #def RefreshBagSlotWindow(self):
  562. #is_activated = 0
  563. #getItemVNum=player.GetItemIndex
  564. #getItemCount=player.GetItemCount
  565. #setItemVNum=self.wndItem.SetItemSlot
  566. #for i in xrange(player.INVENTORY_PAGE_SIZE*2):
  567. #slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  568. #itemCount = getItemCount(slotNumber)
  569. #if 0 == itemCount:
  570. #self.wndItem.ClearSlot(i)
  571. #continue
  572. #elif 1 == itemCount:
  573. #itemCount = 0
  574.  
  575. #itemVnum = getItemVNum(slotNumber)
  576. #setItemVNum(i, itemVnum, itemCount)
  577. #if constInfo.IS_AUTO_POTION(itemVnum):
  578. #metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  579. #if slotNumber >= player.INVENTORY_PAGE_SIZE:
  580. #slotNumber -= player.INVENTORY_PAGE_SIZE
  581.  
  582. #isActivated = 0 != metinSocket[0]
  583. #if isActivated:
  584. #self.wndItem.ActivateSlot(i)
  585. #potionType = 0;
  586. #if constInfo.IS_AUTO_POTION_HP(itemVnum):
  587. #potionType = player.AUTO_POTION_TYPE_HP
  588. #elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  589. #potionType = player.AUTO_POTION_TYPE_SP
  590.  
  591. #usedAmount = int(metinSocket[1])
  592. #totalAmount = int(metinSocket[2])
  593. #player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  594. #else:
  595. #self.wndItem.DeactivateSlot(i)
  596. #self.wndItem.DeactivateSlot(slotNumber) Das bleibt auskommentiert
  597. #elif constInfo.IS_ACCE_ITEM(itemVnum, 1) == TRUE:
  598. #metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  599. #isActivated = metinSocket[0]
  600. #if isActivated == 1:
  601. #player.SetAcceInfo(isActivated, i)
  602. #self.wndItem.ActivateAcceSlot(i)
  603. #else:
  604. #self.wndItem.DeactivateAcceSlot(i)
  605.  
  606. #self.wndItem.RefreshSlot()
  607. #if self.wndBelt:
  608. #self.wndBelt.RefreshSlot()
  609.  
  610. def RefreshBagSlotWindow(self):
  611. getItemVNum=player.GetItemIndex
  612. getItemCount=player.GetItemCount
  613. setItemVNum=self.wndItem.SetItemSlot
  614.  
  615. for i in xrange(player.INVENTORY_PAGE_SIZE):
  616. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  617.  
  618. itemCount = getItemCount(slotNumber)
  619. # itemCount == 0이면 소켓을 비운다.
  620. if 0 == itemCount:
  621. self.wndItem.ClearSlot(i)
  622. continue
  623. elif 1 == itemCount:
  624. itemCount = 0
  625.  
  626. itemVnum = getItemVNum(slotNumber)
  627. setItemVNum(i, itemVnum, itemCount)
  628.  
  629. ## 자동물약 (HP: #72723 ~ #72726, SP: #72727 ~ #72730) 특수처리 - 아이템인데도 슬롯에 활성화/비활성화 표시를 위한 작업임 - [hyo]
  630. if constInfo.IS_AUTO_POTION(itemVnum):
  631. # metinSocket - [0] : 활성화 여부, [1] : 사용한 양, [2] : 최대 용량
  632. metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  633.  
  634. if slotNumber >= player.INVENTORY_PAGE_SIZE:
  635. slotNumber -= player.INVENTORY_PAGE_SIZE
  636.  
  637. isActivated = 0 != metinSocket[0]
  638.  
  639. if isActivated:
  640. self.wndItem.ActivateSlot(slotNumber)
  641. potionType = 0;
  642. if constInfo.IS_AUTO_POTION_HP(itemVnum):
  643. potionType = player.AUTO_POTION_TYPE_HP
  644. elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  645. potionType = player.AUTO_POTION_TYPE_SP
  646.  
  647. usedAmount = int(metinSocket[1])
  648. totalAmount = int(metinSocket[2])
  649. player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  650.  
  651. else:
  652. self.wndItem.DeactivateSlot(slotNumber)
  653. if app.ENABLE_SASH_SYSTEM:
  654. slotNumberChecked = 0
  655. if not constInfo.IS_AUTO_POTION(itemVnum):
  656. #if app.ENABLE_HIGHLIGHT_SYSTEM:
  657. #if not slotNumber in self.listHighlightedSlot:
  658. #self.wndItem.DeactivateSlot(i)
  659. #else:
  660. self.wndItem.DeactivateSlot(i)
  661.  
  662. for j in xrange(sash.WINDOW_MAX_MATERIALS):
  663. (isHere, iCell) = sash.GetAttachedItem(j)
  664. if isHere:
  665. if iCell == slotNumber:
  666. self.wndItem.ActivateSlot(i, (36.00 / 255.0), (222.00 / 255.0), (3.00 / 255.0), 1.0)
  667. if not slotNumber in self.listAttachedSashs:
  668. self.listAttachedSashs.append(slotNumber)
  669.  
  670. slotNumberChecked = 1
  671. else:
  672. if slotNumber in self.listAttachedSashs and not slotNumberChecked:
  673. self.wndItem.DeactivateSlot(i)
  674. self.listAttachedSashs.remove(slotNumber)
  675. self.wndItem.RefreshSlot()
  676.  
  677. if self.wndBelt:
  678. self.wndBelt.RefreshSlot()
  679.  
  680. def RefreshEquipSlotWindow(self):
  681. getItemVNum=player.GetItemIndex
  682. getItemCount=player.GetItemCount
  683. setItemVNum=self.wndEquip.SetItemSlot
  684. for i in xrange(player.EQUIPMENT_PAGE_COUNT):
  685. slotNumber = player.EQUIPMENT_SLOT_START + i
  686. itemCount = getItemCount(slotNumber)
  687. if itemCount <= 1:
  688. itemCount = 0
  689. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  690. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  691. if player.GetItemLook(slotNumber):
  692. self.wndEquip.EnableSlotCoverImage(slotNumber)
  693. else:
  694. self.wndEquip.DisableSlotCoverImage(slotNumber)
  695.  
  696. if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  697. for i in xrange(player.NEW_EQUIPMENT_SLOT_COUNT):
  698. slotNumber = player.NEW_EQUIPMENT_SLOT_START + i
  699. itemCount = getItemCount(slotNumber)
  700. if itemCount <= 1:
  701. itemCount = 0
  702. setItemVNum(slotNumber, getItemVNum(slotNumber), itemCount)
  703. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  704. if player.GetItemLook(slotNumber):
  705. self.wndEquip.EnableSlotCoverImage(slotNumber)
  706. else:
  707. self.wndEquip.DisableSlotCoverImage(slotNumber)
  708. print "ENABLE_NEW_EQUIPMENT_SYSTEM", slotNumber, itemCount, getItemVNum(slotNumber)
  709.  
  710.  
  711.  
  712. self.wndEquip.RefreshSlot()
  713.  
  714. if self.wndCostume:
  715. self.wndCostume.RefreshCostumeSlot()
  716.  
  717. def RefreshItemSlot(self):
  718. self.RefreshBagSlotWindow()
  719. self.RefreshEquipSlotWindow()
  720.  
  721. def RefreshStatus(self):
  722. money = player.GetElk()
  723. self.wndMoney.SetText(localeInfo.NumberToMoneyString(money))
  724.  
  725. def SetItemToolTip(self, tooltipItem):
  726. self.tooltipItem = tooltipItem
  727.  
  728. def SellItem(self):
  729. if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  730. if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  731. ## 용혼석도 팔리게 하는 기능 추가하면서 인자 type 추가
  732. net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY)
  733. snd.PlaySound("sound/ui/money.wav")
  734. self.OnCloseQuestionDialog()
  735.  
  736. def OnDetachMetinFromItem(self):
  737. if None == self.questionDialog:
  738. return
  739.  
  740. #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  741. self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  742. self.OnCloseQuestionDialog()
  743.  
  744. def OnCloseQuestionDialog(self):
  745. if not self.questionDialog:
  746. return
  747.  
  748. self.questionDialog.Close()
  749. self.questionDialog = None
  750. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  751.  
  752. ## Slot Event
  753. def SelectEmptySlot(self, selectedSlotPos):
  754. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  755. if constInfo.BusySlots():
  756. return
  757. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  758. return
  759.  
  760. selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  761.  
  762. if mouseModule.mouseController.isAttached():
  763.  
  764. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  765. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  766. attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  767. attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  768.  
  769. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  770. itemCount = player.GetItemCount(attachedSlotPos)
  771. attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  772. self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  773.  
  774. if item.IsRefineScroll(attachedItemIndex):
  775. self.wndItem.SetUseMode(FALSE)
  776.  
  777. elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  778. mouseModule.mouseController.RunCallBack("INVENTORY")
  779.  
  780. elif player.SLOT_TYPE_SHOP == attachedSlotType:
  781. net.SendShopBuyPacket(attachedSlotPos)
  782.  
  783. elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  784.  
  785. if player.ITEM_MONEY == attachedItemIndex:
  786. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  787. snd.PlaySound("sound/ui/money.wav")
  788.  
  789. else:
  790. net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  791.  
  792. elif player.SLOT_TYPE_MALL == attachedSlotType:
  793. net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  794.  
  795. mouseModule.mouseController.DeattachObject()
  796.  
  797. def SelectItemSlot(self, itemSlotIndex):
  798. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  799. return
  800.  
  801. itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  802.  
  803. if mouseModule.mouseController.isAttached():
  804. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  805. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  806. attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  807.  
  808. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  809. self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  810.  
  811. mouseModule.mouseController.DeattachObject()
  812.  
  813. else:
  814.  
  815. curCursorNum = app.GetCursor()
  816. if app.SELL == curCursorNum:
  817. self.__SellItem(itemSlotIndex)
  818.  
  819. elif app.BUY == curCursorNum:
  820. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  821.  
  822. elif app.IsPressed(app.DIK_LALT):
  823. link = player.GetItemLink(itemSlotIndex)
  824. ime.PasteString(link)
  825.  
  826. elif app.IsPressed(app.DIK_LSHIFT):
  827. itemCount = player.GetItemCount(itemSlotIndex)
  828.  
  829. if itemCount > 1:
  830. self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  831. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  832. self.dlgPickMoney.Open(itemCount)
  833. self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  834. #else:
  835. #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  836. #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  837.  
  838. elif app.IsPressed(app.DIK_LCONTROL):
  839. itemIndex = player.GetItemIndex(itemSlotIndex)
  840.  
  841. if TRUE == item.CanAddToQuickSlotItem(itemIndex):
  842. player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  843. else:
  844. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  845.  
  846. else:
  847. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  848. itemCount = player.GetItemCount(itemSlotIndex)
  849. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  850.  
  851. if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):
  852. self.wndItem.SetUseMode(TRUE)
  853. else:
  854. self.wndItem.SetUseMode(FALSE)
  855.  
  856. snd.PlaySound("sound/ui/pick.wav")
  857.  
  858. def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  859. if srcItemSlotPos == dstItemSlotPos:
  860. return
  861.  
  862. elif item.IsRefineScroll(srcItemVID):
  863. self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  864. self.wndItem.SetUseMode(FALSE)
  865.  
  866. elif item.IsMetin(srcItemVID):
  867. self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  868.  
  869. elif item.IsDetachScroll(srcItemVID):
  870. self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  871.  
  872. elif item.IsKey(srcItemVID):
  873. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  874.  
  875. elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  876. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  877.  
  878. elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  879. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  880.  
  881. else:
  882. #snd.PlaySound("sound/ui/drop.wav")
  883.  
  884. ## 이동시킨 곳이 장착 슬롯일 경우 아이템을 사용해서 장착 시킨다 - [levites]
  885. if player.IsEquipmentSlot(dstItemSlotPos):
  886.  
  887. ## 들고 있는 아이템이 장비일때만
  888. if item.IsEquipmentVID(srcItemVID):
  889. self.__UseItem(srcItemSlotPos)
  890.  
  891. else:
  892. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  893. #net.SendItemMovePacket(srcItemSlotPos, dstItemSlotPos, 0)
  894.  
  895. def __SellItem(self, itemSlotPos):
  896. if not player.IsEquipmentSlot(itemSlotPos):
  897. self.sellingSlotNumber = itemSlotPos
  898. itemIndex = player.GetItemIndex(itemSlotPos)
  899. itemCount = player.GetItemCount(itemSlotPos)
  900.  
  901.  
  902. self.sellingSlotitemIndex = itemIndex
  903. self.sellingSlotitemCount = itemCount
  904.  
  905. item.SelectItem(itemIndex)
  906. ## 안티 플레그 검사 빠져서 추가
  907. ## 20140220
  908. if item.IsAntiFlag(item.ANTIFLAG_SELL):
  909. popup = uiCommon.PopupDialog()
  910. popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  911. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  912. popup.Open()
  913. self.popup = popup
  914. return
  915.  
  916. itemPrice = item.GetISellItemPrice()
  917.  
  918. if item.Is1GoldItem():
  919. itemPrice = itemCount / itemPrice / 5
  920. else:
  921. itemPrice = itemPrice * itemCount / 5
  922.  
  923. item.GetItemName(itemIndex)
  924. itemName = item.GetItemName()
  925.  
  926. self.questionDialog = uiCommon.QuestionDialog()
  927. self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  928. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  929. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  930. self.questionDialog.Open()
  931. self.questionDialog.count = itemCount
  932.  
  933. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  934.  
  935. def __OnClosePopupDialog(self):
  936. self.pop = None
  937.  
  938. def RefineItem(self, scrollSlotPos, targetSlotPos):
  939.  
  940. scrollIndex = player.GetItemIndex(scrollSlotPos)
  941. targetIndex = player.GetItemIndex(targetSlotPos)
  942.  
  943. if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  944. return
  945.  
  946. ###########################################################
  947. self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  948. #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  949. return
  950. ###########################################################
  951.  
  952. ###########################################################
  953. #net.SendRequestRefineInfoPacket(targetSlotPos)
  954. #return
  955. ###########################################################
  956.  
  957. result = player.CanRefine(scrollIndex, targetSlotPos)
  958.  
  959. if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  960. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  961. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  962.  
  963. elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  964. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  965. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  966.  
  967. elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  968. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  969. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  970.  
  971. elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  972. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  973. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  974.  
  975. elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  976. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  977.  
  978. if player.REFINE_OK != result:
  979. return
  980.  
  981. self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  982. # Sash Lennt
  983. #def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  984. #scrollIndex = player.GetItemIndex(scrollSlotPos)
  985. #targetIndex = player.GetItemIndex(targetSlotPos)
  986. #if constInfo.IS_ACCE_ITEM_DETACH(scrollIndex) == TRUE:
  987. #item.SelectItem(targetIndex)
  988. #if item.GetItemSubType() == item.COSTUME_TYPE_ACCE:
  989. #if self.GetAcceAttribute(targetSlotPos) == 0:
  990. #return
  991.  
  992. #self.questionDialog = uiCommon.QuestionDialog()
  993. #self.questionDialog.SetText(localeInfo.ACCE_DO_YOU_REMOVE_ATTR)
  994. #self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  995. #self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  996. #self.questionDialog.Open()
  997. #self.questionDialog.sourcePos = scrollSlotPos
  998. #self.questionDialog.targetPos = targetSlotPos
  999. #else:
  1000. #return
  1001. #else:
  1002. #if not player.CanDetach(scrollIndex, targetSlotPos):
  1003. #chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  1004. #return
  1005.  
  1006. #self.questionDialog = uiCommon.QuestionDialog()
  1007. #self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  1008. #self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  1009. #self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  1010. #self.questionDialog.Open()
  1011. #self.questionDialog.sourcePos = scrollSlotPos
  1012. #self.questionDialog.targetPos = targetSlotPos
  1013.  
  1014. #def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  1015. #scrollIndex = player.GetItemIndex(scrollSlotPos)
  1016. #targetIndex = player.GetItemIndex(targetSlotPos)
  1017.  
  1018. #if not player.CanDetach(scrollIndex, targetSlotPos):
  1019. #chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  1020. #return
  1021.  
  1022. #self.questionDialog = uiCommon.QuestionDialog()
  1023. #self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  1024. #self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  1025. #self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  1026. #self.questionDialog.Open()
  1027. #self.questionDialog.sourcePos = scrollSlotPos
  1028. #self.questionDialog.targetPos = targetSlotPos
  1029.  
  1030. def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  1031. scrollIndex = player.GetItemIndex(scrollSlotPos)
  1032. targetIndex = player.GetItemIndex(targetSlotPos)
  1033. if app.ENABLE_SASH_SYSTEM:
  1034. if not player.CanDetach(scrollIndex, targetSlotPos):
  1035. item.SelectItem(scrollIndex)
  1036. if item.GetValue(0) == sash.CLEAN_ATTR_VALUE0:
  1037. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SASH_FAILURE_CLEAN)
  1038. else:
  1039. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  1040.  
  1041. return
  1042. else:
  1043. if not player.CanDetach(scrollIndex, targetSlotPos):
  1044. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  1045. return
  1046.  
  1047. self.questionDialog = uiCommon.QuestionDialog()
  1048. self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  1049. if app.ENABLE_SASH_SYSTEM:
  1050. item.SelectItem(targetIndex)
  1051. if item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_SASH:
  1052. item.SelectItem(scrollIndex)
  1053. if item.GetValue(0) == sash.CLEAN_ATTR_VALUE0:
  1054. self.questionDialog.SetText(localeInfo.SASH_DO_YOU_CLEAN)
  1055.  
  1056. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  1057. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  1058. self.questionDialog.Open()
  1059. self.questionDialog.sourcePos = scrollSlotPos
  1060. self.questionDialog.targetPos = targetSlotPos
  1061.  
  1062. def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  1063. metinIndex = player.GetItemIndex(metinSlotPos)
  1064. targetIndex = player.GetItemIndex(targetSlotPos)
  1065.  
  1066. item.SelectItem(metinIndex)
  1067. itemName = item.GetItemName()
  1068.  
  1069. result = player.CanAttachMetin(metinIndex, targetSlotPos)
  1070.  
  1071. if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  1072. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  1073.  
  1074. if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  1075. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  1076.  
  1077. elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  1078. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  1079.  
  1080. elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  1081. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  1082.  
  1083. if player.ATTACH_METIN_OK != result:
  1084. return
  1085.  
  1086. self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  1087.  
  1088.  
  1089.  
  1090. def OverOutItem(self):
  1091. self.wndItem.SetUsableItem(FALSE)
  1092. if None != self.tooltipItem:
  1093. self.tooltipItem.HideToolTip()
  1094.  
  1095. def OverInItem(self, overSlotPos):
  1096. overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  1097. self.wndItem.SetUsableItem(FALSE)
  1098.  
  1099. if mouseModule.mouseController.isAttached():
  1100. attachedItemType = mouseModule.mouseController.GetAttachedType()
  1101. if player.SLOT_TYPE_INVENTORY == attachedItemType:
  1102.  
  1103. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  1104. attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  1105.  
  1106. if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos):
  1107. self.wndItem.SetUsableItem(TRUE)
  1108. self.ShowToolTip(overSlotPos)
  1109. return
  1110.  
  1111. self.ShowToolTip(overSlotPos)
  1112.  
  1113.  
  1114. def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  1115. "다른 아이템에 사용할 수 있는 아이템인가?"
  1116.  
  1117. if item.IsRefineScroll(srcItemVNum):
  1118. return TRUE
  1119. elif item.IsMetin(srcItemVNum):
  1120. return TRUE
  1121. elif item.IsDetachScroll(srcItemVNum):
  1122. return TRUE
  1123. elif item.IsKey(srcItemVNum):
  1124. return TRUE
  1125. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1126. return TRUE
  1127. else:
  1128. if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  1129. return TRUE
  1130.  
  1131. return FALSE
  1132.  
  1133. def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  1134. "대상 아이템에 사용할 수 있는가?"
  1135.  
  1136. if srcSlotPos == dstSlotPos:
  1137. return FALSE
  1138.  
  1139. if item.IsRefineScroll(srcItemVNum):
  1140. if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  1141. return TRUE
  1142. elif item.IsMetin(srcItemVNum):
  1143. if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  1144. return TRUE
  1145. elif item.IsDetachScroll(srcItemVNum):
  1146. if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  1147. return TRUE
  1148. elif item.IsKey(srcItemVNum):
  1149. if player.CanUnlock(srcItemVNum, dstSlotPos):
  1150. return TRUE
  1151.  
  1152. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1153. return TRUE
  1154.  
  1155. else:
  1156. useType=item.GetUseType(srcItemVNum)
  1157.  
  1158. if "USE_CLEAN_SOCKET" == useType:
  1159. if self.__CanCleanBrokenMetinStone(dstSlotPos):
  1160. return TRUE
  1161. elif "USE_CHANGE_ATTRIBUTE" == useType:
  1162. if self.__CanChangeItemAttrList(dstSlotPos):
  1163. return TRUE
  1164. elif "USE_ADD_ATTRIBUTE" == useType:
  1165. if self.__CanAddItemAttr(dstSlotPos):
  1166. return TRUE
  1167. elif "USE_ADD_ATTRIBUTE2" == useType:
  1168. if self.__CanAddItemAttr(dstSlotPos):
  1169. return TRUE
  1170. elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  1171. if self.__CanAddAccessorySocket(dstSlotPos):
  1172. return TRUE
  1173. elif "USE_RESET_LOOK_VNUM" == useType:
  1174. if not app.ENABLE_CHANGE_LOOK_SYSTEM:
  1175. return FALSE
  1176.  
  1177. if self.__CanResetLookVnum(dstSlotPos):
  1178. return TRUE
  1179. elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:
  1180. if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  1181. return TRUE;
  1182. elif "USE_PUT_INTO_BELT_SOCKET" == useType:
  1183. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1184. print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum
  1185.  
  1186. item.SelectItem(dstItemVNum)
  1187.  
  1188. if item.ITEM_TYPE_BELT == item.GetItemType():
  1189. return TRUE
  1190.  
  1191. return FALSE
  1192.  
  1193. def __CanCleanBrokenMetinStone(self, dstSlotPos):
  1194. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1195. if dstItemVNum == 0:
  1196. return FALSE
  1197.  
  1198. item.SelectItem(dstItemVNum)
  1199.  
  1200. if item.ITEM_TYPE_WEAPON != item.GetItemType():
  1201. return FALSE
  1202.  
  1203. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1204. if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  1205. return TRUE
  1206.  
  1207. return FALSE
  1208.  
  1209. def __CanChangeItemAttrList(self, dstSlotPos):
  1210. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1211. if dstItemVNum == 0:
  1212. return FALSE
  1213.  
  1214. item.SelectItem(dstItemVNum)
  1215.  
  1216. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1217. return FALSE
  1218.  
  1219. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1220. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1221. return TRUE
  1222.  
  1223. return FALSE
  1224.  
  1225. def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  1226. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1227. if dstItemVNum == 0:
  1228. return FALSE
  1229.  
  1230. item.SelectItem(dstItemVNum)
  1231.  
  1232. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1233. return FALSE
  1234.  
  1235. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1236. return FALSE
  1237.  
  1238. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1239. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1240.  
  1241. if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1242. return FALSE
  1243.  
  1244. if curCount>=maxCount:
  1245. return FALSE
  1246.  
  1247. return TRUE
  1248.  
  1249. def __CanAddAccessorySocket(self, dstSlotPos):
  1250. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1251. if dstItemVNum == 0:
  1252. return FALSE
  1253.  
  1254. item.SelectItem(dstItemVNum)
  1255.  
  1256. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1257. return FALSE
  1258.  
  1259. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1260. return FALSE
  1261.  
  1262. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1263. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1264.  
  1265. ACCESSORY_SOCKET_MAX_SIZE = 3
  1266. if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1267. return FALSE
  1268.  
  1269. return TRUE
  1270.  
  1271. def __CanAddItemAttr(self, dstSlotPos):
  1272. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1273. if dstItemVNum == 0:
  1274. return FALSE
  1275.  
  1276. item.SelectItem(dstItemVNum)
  1277.  
  1278. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1279. return FALSE
  1280.  
  1281. attrCount = 0
  1282. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1283. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1284. attrCount += 1
  1285.  
  1286. if attrCount<4:
  1287. return TRUE
  1288.  
  1289. return FALSE
  1290.  
  1291. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  1292. def __CanResetLookVnum(self, dstSlotPos):
  1293. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1294. if dstItemVNum == 0:
  1295. return FALSE
  1296.  
  1297. if player.GetItemLook(dstSlotPos):
  1298. return TRUE
  1299.  
  1300. return FALSE
  1301.  
  1302. def ShowToolTip(self, slotIndex):
  1303. if None != self.tooltipItem:
  1304. self.tooltipItem.SetInventoryItem(slotIndex)
  1305.  
  1306. def OnTop(self):
  1307. if None != self.tooltipItem:
  1308. self.tooltipItem.SetTop()
  1309.  
  1310. def OnPressEscapeKey(self):
  1311. self.Close()
  1312. return TRUE
  1313.  
  1314. #def UseItemSlot(self, slotIndex):
  1315. #if app.ENABLE_CHANGE_LOOK_SYSTEM:
  1316. #if constInfo.BusySlots():
  1317. #return
  1318. #curCursorNum = app.GetCursor()
  1319. #if app.SELL == curCursorNum:
  1320. #return
  1321.  
  1322. #if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  1323. #return
  1324.  
  1325. #slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1326.  
  1327. #if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1328. #if self.wndDragonSoulRefine.IsShow():
  1329. #self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1330. #return
  1331.  
  1332. #self.__UseItem(slotIndex)
  1333. #mouseModule.mouseController.DeattachObject()
  1334. #self.OverOutItem()
  1335.  
  1336. def UseItemSlot(self, slotIndex):
  1337. if app.ENABLE_CHANGE_LOOK_SYSTEM:
  1338. if constInfo.BusySlots():
  1339. return
  1340. curCursorNum = app.GetCursor()
  1341. if app.SELL == curCursorNum:
  1342. return
  1343. if constInfo.GET_ITEM_DROP_QUESTION_DIALOG_STATUS():
  1344. return
  1345.  
  1346. slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1347. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1348. if self.wndDragonSoulRefine.IsShow():
  1349. self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1350. return
  1351.  
  1352. if app.ENABLE_SASH_SYSTEM:
  1353. if self.isShowSashWindow():
  1354. sash.Add(player.INVENTORY, slotIndex, 255)
  1355. return
  1356.  
  1357. self.__UseItem(slotIndex)
  1358. mouseModule.mouseController.DeattachObject()
  1359. self.OverOutItem()
  1360.  
  1361. def __UseItem(self, slotIndex):
  1362. ItemVNum = player.GetItemIndex(slotIndex)
  1363. item.SelectItem(ItemVNum)
  1364. if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE):
  1365. self.questionDialog = uiCommon.QuestionDialog()
  1366. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1367. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1368. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1369. self.questionDialog.Open()
  1370. self.questionDialog.slotIndex = slotIndex
  1371.  
  1372. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  1373.  
  1374. else:
  1375. self.__SendUseItemPacket(slotIndex)
  1376. #net.SendItemUsePacket(slotIndex)
  1377.  
  1378. def __UseItemQuestionDialog_OnCancel(self):
  1379. self.OnCloseQuestionDialog()
  1380.  
  1381. def __UseItemQuestionDialog_OnAccept(self):
  1382. self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1383. self.OnCloseQuestionDialog()
  1384.  
  1385. def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1386. # 개인상점 열고 있는 동안 아이템 사용 방지
  1387. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1388. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1389. return
  1390.  
  1391. net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1392.  
  1393. def __SendUseItemPacket(self, slotPos):
  1394. # 개인상점 열고 있는 동안 아이템 사용 방지
  1395. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1396. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1397. return
  1398.  
  1399. net.SendItemUsePacket(slotPos)
  1400.  
  1401. def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1402. # 개인상점 열고 있는 동안 아이템 사용 방지
  1403. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1404. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1405. return
  1406.  
  1407. net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
  1408.  
  1409. def SetDragonSoulRefineWindow(self, wndDragonSoulRefine):
  1410. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1411. self.wndDragonSoulRefine = wndDragonSoulRefine
  1412.  
  1413. if app.ENABLE_SASH_SYSTEM:
  1414. def SetSashWindow(self, wndSashCombine, wndSashAbsorption):
  1415. self.wndSashCombine = wndSashCombine
  1416. self.wndSashAbsorption = wndSashAbsorption
  1417.  
  1418. def isShowSashWindow(self):
  1419. if self.wndSashCombine:
  1420. if self.wndSashCombine.IsShow():
  1421. return 1
  1422.  
  1423. if self.wndSashAbsorption:
  1424. if self.wndSashAbsorption.IsShow():
  1425. return 1
  1426.  
  1427. return 0
  1428.  
  1429. def OnMoveWindow(self, x, y):
  1430. # print "Inventory Global Pos : ", self.GetGlobalPosition()
  1431. if self.wndBelt:
  1432. # print "Belt Global Pos : ", self.wndBelt.GetGlobalPosition()
  1433. self.wndBelt.AdjustPositionAndSize()
  1434. # Sash Lennt
  1435. #def GetAcceAttribute(self, srcSlotPos):
  1436. #result = 0
  1437. #attrSlot = []
  1438. #for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1439. #attrSlot.append(player.GetItemAttribute(srcSlotPos, i))
  1440.  
  1441. #if 0 != attrSlot:
  1442. #for c in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  1443. #type = attrSlot[c][0]
  1444. #if type != 0:
  1445. #result = result + 1
  1446.  
  1447. #return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement