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. import uiToolTip
  22. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  23. import acce
  24. if app.ENABLE_CHEQUE_SYSTEM:
  25. import uiToolTip
  26. import uiPickETC
  27. if app.ENABLE_CHANGELOOK_SYSTEM:
  28. import changelook
  29. ITEM_MALL_BUTTON_ENABLE = True
  30. ITEM_FLAG_APPLICABLE = 1 << 14
  31. class CostumeWindow(ui.ScriptWindow):
  32. def __init__(self, wndInventory):
  33. import exception
  34. if not app.ENABLE_COSTUME_SYSTEM:
  35. exception.Abort("What do you do?")
  36. return
  37. if not wndInventory:
  38. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  39. return
  40. ui.ScriptWindow.__init__(self)
  41. self.isLoaded = 0
  42. self.wndInventory = wndInventory;
  43. self.__LoadWindow()
  44. def __del__(self):
  45. ui.ScriptWindow.__del__(self)
  46. def Show(self):
  47. self.__LoadWindow()
  48. self.RefreshCostumeSlot()
  49. ui.ScriptWindow.Show(self)
  50. def Close(self):
  51. self.Hide()
  52. def __LoadWindow(self):
  53. if self.isLoaded == 1:
  54. return
  55. self.isLoaded = 1
  56. try:
  57. pyScrLoader = ui.PythonScriptLoader()
  58. pyScrLoader.LoadScriptFile(self, "UIScript/CostumeWindow.py")
  59. except:
  60. import exception
  61. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  62. try:
  63. wndEquip = self.GetChild("CostumeSlot")
  64. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  65. except:
  66. import exception
  67. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  68. ## Equipment
  69. wndEquip.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  70. wndEquip.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  71. wndEquip.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  72. wndEquip.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  73. wndEquip.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  74. wndEquip.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  75. self.wndEquip = wndEquip
  76. def RefreshCostumeSlot(self):
  77. getItemVNum=player.GetItemIndex
  78. for i in xrange(item.COSTUME_SLOT_COUNT):
  79. slotNumber = item.COSTUME_SLOT_START + i
  80. self.wndEquip.SetItemSlot(slotNumber, getItemVNum(slotNumber), 0)
  81. if app.ENABLE_CHANGELOOK_SYSTEM:
  82. itemTransmutedVnum = player.GetItemTransmutation(slotNumber)
  83. if itemTransmutedVnum:
  84. self.wndEquip.DisableCoverButton(slotNumber)
  85. else:
  86. self.wndEquip.EnableCoverButton(slotNumber)
  87. if app.ENABLE_WEAPON_COSTUME_SYSTEM:
  88. self.wndEquip.SetItemSlot(item.COSTUME_SLOT_WEAPON, getItemVNum(item.COSTUME_SLOT_WEAPON), 0)
  89. self.wndEquip.RefreshSlot()
  90. class BeltInventoryWindow(ui.ScriptWindow):
  91. def __init__(self, wndInventory):
  92. import exception
  93. if not app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  94. exception.Abort("What do you do?")
  95. return
  96. if not wndInventory:
  97. exception.Abort("wndInventory parameter must be set to InventoryWindow")
  98. return
  99. ui.ScriptWindow.__init__(self)
  100. self.isLoaded = 0
  101. self.wndInventory = wndInventory;
  102. self.wndBeltInventoryLayer = None
  103. self.wndBeltInventorySlot = None
  104. self.expandBtn = None
  105. self.minBtn = None
  106. self.__LoadWindow()
  107. def __del__(self):
  108. ui.ScriptWindow.__del__(self)
  109. def Show(self, openBeltSlot = False):
  110. self.__LoadWindow()
  111. self.RefreshSlot()
  112. ui.ScriptWindow.Show(self)
  113. if openBeltSlot:
  114. self.OpenInventory()
  115. else:
  116. self.CloseInventory()
  117. def Close(self):
  118. self.Hide()
  119. def IsOpeningInventory(self):
  120. return self.wndBeltInventoryLayer.IsShow()
  121. def OpenInventory(self):
  122. self.wndBeltInventoryLayer.Show()
  123. self.expandBtn.Hide()
  124. if localeInfo.IsARABIC() == 0:
  125. self.AdjustPositionAndSize()
  126. def CloseInventory(self):
  127. self.wndBeltInventoryLayer.Hide()
  128. self.expandBtn.Show()
  129. if localeInfo.IsARABIC() == 0:
  130. self.AdjustPositionAndSize()
  131. def GetBasePosition(self):
  132. x, y = self.wndInventory.GetGlobalPosition()
  133. return x - 148, y + 139
  134. def AdjustPositionAndSize(self):
  135. bx, by = self.GetBasePosition()
  136. if self.IsOpeningInventory():
  137. self.SetPosition(bx, by)
  138. self.SetSize(self.ORIGINAL_WIDTH, self.GetHeight())
  139. else:
  140. self.SetPosition(bx + 138, by);
  141. self.SetSize(10, self.GetHeight())
  142. def __LoadWindow(self):
  143. if self.isLoaded == 1:
  144. return
  145. self.isLoaded = 1
  146. try:
  147. pyScrLoader = ui.PythonScriptLoader()
  148. pyScrLoader.LoadScriptFile(self, "UIScript/BeltInventoryWindow.py")
  149. except:
  150. import exception
  151. exception.Abort("CostumeWindow.LoadWindow.LoadObject")
  152. try:
  153. self.ORIGINAL_WIDTH = self.GetWidth()
  154. wndBeltInventorySlot = self.GetChild("BeltInventorySlot")
  155. self.wndBeltInventoryLayer = self.GetChild("BeltInventoryLayer")
  156. self.expandBtn = self.GetChild("ExpandBtn")
  157. self.minBtn = self.GetChild("MinimizeBtn")
  158. self.expandBtn.SetEvent(ui.__mem_func__(self.OpenInventory))
  159. self.minBtn.SetEvent(ui.__mem_func__(self.CloseInventory))
  160. if localeInfo.IsARABIC() :
  161. self.expandBtn.SetPosition(self.expandBtn.GetWidth() - 2, 15)
  162. self.wndBeltInventoryLayer.SetPosition(self.wndBeltInventoryLayer.GetWidth() - 5, 0)
  163. self.minBtn.SetPosition(self.minBtn.GetWidth() + 3, 15)
  164. for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  165. slotNumber = item.BELT_INVENTORY_SLOT_START + i
  166. wndBeltInventorySlot.SetCoverButton(slotNumber, "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  167. "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  168. "d:/ymir work/ui/game/quest/slot_button_01.sub",\
  169. "d:/ymir work/ui/game/belt_inventory/slot_disabled.tga", False, False)
  170. except:
  171. import exception
  172. exception.Abort("CostumeWindow.LoadWindow.BindObject")
  173. ## Equipment
  174. wndBeltInventorySlot.SetOverInItemEvent(ui.__mem_func__(self.wndInventory.OverInItem))
  175. wndBeltInventorySlot.SetOverOutItemEvent(ui.__mem_func__(self.wndInventory.OverOutItem))
  176. wndBeltInventorySlot.SetUnselectItemSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  177. wndBeltInventorySlot.SetUseSlotEvent(ui.__mem_func__(self.wndInventory.UseItemSlot))
  178. wndBeltInventorySlot.SetSelectEmptySlotEvent(ui.__mem_func__(self.wndInventory.SelectEmptySlot))
  179. wndBeltInventorySlot.SetSelectItemSlotEvent(ui.__mem_func__(self.wndInventory.SelectItemSlot))
  180. self.wndBeltInventorySlot = wndBeltInventorySlot
  181. def RefreshSlot(self):
  182. getItemVNum=player.GetItemIndex
  183. for i in xrange(item.BELT_INVENTORY_SLOT_COUNT):
  184. slotNumber = item.BELT_INVENTORY_SLOT_START + i
  185. self.wndBeltInventorySlot.SetItemSlot(slotNumber, getItemVNum(slotNumber), player.GetItemCount(slotNumber))
  186. self.wndBeltInventorySlot.SetAlwaysRenderCoverButton(slotNumber, True)
  187. avail = "0"
  188. if player.IsAvailableBeltInventoryCell(slotNumber):
  189. self.wndBeltInventorySlot.EnableCoverButton(slotNumber)
  190. else:
  191. self.wndBeltInventorySlot.DisableCoverButton(slotNumber)
  192. self.wndBeltInventorySlot.RefreshSlot()
  193. class InventoryWindow(ui.ScriptWindow):
  194. liHighlightedItems = []
  195. if app.ENABLE_SOULBIND_SYSTEM:
  196. 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_BIND", "USE_UNBIND", "USE_CHANGE_COSTUME_ATTR", "USE_RESET_COSTUME_ATTR")
  197. else:
  198. 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_CHANGE_COSTUME_ATTR", "USE_RESET_COSTUME_ATTR")
  199. questionDialog = None
  200. tooltipItem = None
  201. wndCostume = None
  202. wndBelt = None
  203. dlgPickMoney = None
  204. if app.ENABLE_CHEQUE_SYSTEM:
  205. dlgPickETC = None
  206. interface = None
  207. if app.WJ_ENABLE_TRADABLE_ICON:
  208. bindWnds = []
  209. sellingSlotNumber = -1
  210. isLoaded = 0
  211. isOpenedCostumeWindowWhenClosingInventory = 0
  212. isOpenedBeltWindowWhenClosingInventory = 0
  213. def __init__(self):
  214. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  215. self.wndExpandedMoneyBar = None
  216. ui.ScriptWindow.__init__(self)
  217. self.isOpenedBeltWindowWhenClosingInventory = 0
  218. self.inventoryPageIndex = 0
  219. self.__LoadWindow()
  220. def __del__(self):
  221. ui.ScriptWindow.__del__(self)
  222. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  223. self.wndExpandedMoneyBar = None
  224. def Show(self):
  225. self.__LoadWindow()
  226. ui.ScriptWindow.Show(self)
  227. # ????? ?? ? ???? ?????? ????? ? ? ???? ?? ??? ?.
  228. if self.isOpenedCostumeWindowWhenClosingInventory and self.wndCostume:
  229. self.wndCostume.Show()
  230. # ????? ?? ? ?? ????? ?????? ?? ??? ?.
  231. if self.wndBelt:
  232. self.wndBelt.Show(self.isOpenedBeltWindowWhenClosingInventory)
  233. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  234. if self.wndExpandedMoneyBar:
  235. self.wndExpandedMoneyBar.Show()
  236. def BindInterfaceClass(self, interface):
  237. self.interface = interface
  238. if app.WJ_ENABLE_TRADABLE_ICON:
  239. def BindWindow(self, wnd):
  240. self.bindWnds.append(wnd)
  241. def __LoadWindow(self):
  242. if self.isLoaded == 1:
  243. return
  244. self.isLoaded = 1
  245. try:
  246. pyScrLoader = ui.PythonScriptLoader()
  247. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  248. pyScrLoader.LoadScriptFile(self, "UIScript/InventoryWindowEx.py")
  249. else:
  250. if ITEM_MALL_BUTTON_ENABLE:
  251. pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "InventoryWindow.py")
  252. else:
  253. pyScrLoader.LoadScriptFile(self, "UIScript/InventoryWindow.py")
  254. except:
  255. import exception
  256. exception.Abort("InventoryWindow.LoadWindow.LoadObject")
  257. try:
  258. wndItem = self.GetChild("ItemSlot")
  259. self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close))
  260. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  261. self.EX_INVEN_COVER_IMG_CLOSE = []
  262. self.EX_INVEN_COVER_IMG_OPEN = []
  263. for i in xrange(9):
  264. self.EX_INVEN_COVER_IMG_OPEN.append(self.GetChild("cover_open_" + str(i)))
  265. self.EX_INVEN_COVER_IMG_CLOSE.append(self.GetChild("cover_close_" + str(i)))
  266. self.wndMoney = self.GetChild("Money")
  267. self.wndMoneySlot = self.GetChild("Money_Slot")
  268. self.DepButton = self.GetChild2("DepButton")
  269. if app.ENABLE_CHEQUE_SYSTEM:
  270. self.wndCheque = self.GetChild("Cheque")
  271. self.wndChequeSlot = self.GetChild("Cheque_Slot")
  272. if app.ENABLE_GEM_SYSTEM:
  273. self.wndGem = self.GetChild("Gem")
  274. self.wndGemSlot = self.GetChild("Gem_Slot")
  275. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  276. self.wndMoneyIcon = self.GetChild("Money_Icon")
  277. self.wndMoneyIcon.Hide()
  278. self.wndMoneySlot.Hide()
  279. else:
  280. self.wndMoneyIcon = self.GetChild("Money_Icon")
  281. self.wndChequeIcon = self.GetChild("Cheque_Icon")
  282. self.wndMoneyIcon.SetEvent(ui.__mem_func__(self.EventProgress), "mouse_over_in", 0)
  283. self.wndChequeIcon.SetEvent(ui.__mem_func__(self.EventProgress), "mouse_over_in", 1)
  284. self.wndMoneyIcon.SetEvent(ui.__mem_func__(self.EventProgress), "mouse_over_out", 0)
  285. self.wndChequeIcon.SetEvent(ui.__mem_func__(self.EventProgress), "mouse_over_out", 1)
  286. self.toolTip = uiToolTip.ToolTip()
  287. self.toolTip.ClearToolTip()
  288. if app.ENABLE_CHEQUE_SYSTEM:
  289. self.wndChequeIcon = self.GetChild("Cheque_Icon")
  290. self.wndChequeIcon.Hide()
  291. self.wndChequeSlot.Hide()
  292. if app.ENABLE_GEM_SYSTEM:
  293. self.wndGemIcon = self.GetChild("Gem_Icon")
  294. self.wndGemIcon.Hide()
  295. self.wndGemSlot.Hide()
  296. self.inventoryTab = []
  297. for i in xrange(player.INVENTORY_PAGE_COUNT):
  298. self.inventoryTab.append(self.GetChild("Inventory_Tab_%02d" % (i+1)))
  299. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  300. for i in xrange(9):
  301. self.EX_INVEN_COVER_IMG_CLOSE[i].Hide()
  302. self.EX_INVEN_COVER_IMG_OPEN[i].Hide()
  303. # Belt Inventory Window
  304. self.wndBelt = None
  305. if app.ENABLE_NEW_EQUIPMENT_SYSTEM:
  306. self.wndBelt = BeltInventoryWindow(self)
  307. except:
  308. import exception
  309. exception.Abort("InventoryWindow.LoadWindow.BindObject")
  310. ## Item
  311. wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot))
  312. wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot))
  313. wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot))
  314. wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot))
  315. wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem))
  316. wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem))
  317. ## PickMoneyDialog
  318. dlgPickMoney = uiPickMoney.PickMoneyDialog()
  319. dlgPickMoney.LoadDialog()
  320. dlgPickMoney.Hide()
  321. ## PickETCDialog
  322. if app.ENABLE_CHEQUE_SYSTEM:
  323. dlgPickETC = uiPickETC.PickETCDialog()
  324. dlgPickETC.LoadDialog()
  325. dlgPickETC.Hide()
  326. ## RefineDialog
  327. self.refineDialog = uiRefine.RefineDialog()
  328. self.refineDialog.Hide()
  329. ## AttachMetinDialog
  330. if app.WJ_ENABLE_TRADABLE_ICON:
  331. self.attachMetinDialog = uiAttachMetin.AttachMetinDialog(self)
  332. self.BindWindow(self.attachMetinDialog)
  333. else:
  334. self.attachMetinDialog = uiAttachMetin.AttachMetinDialog()
  335. self.attachMetinDialog.Hide()
  336. ## MoneySlot
  337. if app.ENABLE_CHEQUE_SYSTEM:
  338. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog), 0)
  339. self.wndChequeSlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog), 1)
  340. else:
  341. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))
  342. for i in xrange(player.INVENTORY_PAGE_COUNT):
  343. self.inventoryTab[i].SetEvent(lambda arg=i: self.SetInventoryPage(arg))
  344. self.inventoryTab[0].Down()
  345. self.wndItem = wndItem
  346. self.dlgPickMoney = dlgPickMoney
  347. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  348. for i in xrange(9):
  349. self.EX_INVEN_COVER_IMG_OPEN[i].SetEvent(ui.__mem_func__(self.en_ac))
  350. if app.ENABLE_CHEQUE_SYSTEM:
  351. self.dlgPickETC = dlgPickETC
  352. if self.DepButton:
  353. self.DepButton.SetEvent(ui.__mem_func__(self.ClickDepButton))
  354. #####
  355. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  356. self.listAttachedAcces = []
  357. if app.ENABLE_CHANGELOOK_SYSTEM:
  358. self.listAttachedCl = []
  359. ## Refresh
  360. self.SetInventoryPage(0)
  361. self.RefreshItemSlot()
  362. self.RefreshStatus()
  363. def Destroy(self):
  364. self.ClearDictionary()
  365. self.dlgPickMoney.Destroy()
  366. self.dlgPickMoney = 0
  367. if app.ENABLE_CHEQUE_SYSTEM:
  368. self.dlgPickETC.Destroy()
  369. self.dlgPickETC = 0
  370. self.refineDialog.Destroy()
  371. self.refineDialog = 0
  372. self.attachMetinDialog.Destroy()
  373. self.attachMetinDialog = 0
  374. self.tooltipItem = None
  375. self.wndItem = 0
  376. self.dlgPickMoney = 0
  377. self.wndMoney = 0
  378. self.wndMoneySlot = 0
  379. if app.ENABLE_CHEQUE_SYSTEM:
  380. self.wndCheque = 0
  381. self.wndChequeSlot = 0
  382. self.dlgPickETC = 0
  383. if app.ENABLE_GEM_SYSTEM:
  384. self.wndGem = 0
  385. self.wndGemSlot = 0
  386. self.questionDialog = None
  387. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  388. self.EX_INVEN_COVER_IMG_CLOSE = None
  389. self.EX_INVEN_COVER_IMG_OPEN = None
  390. if app.WJ_ENABLE_TRADABLE_ICON:
  391. self.bindWnds = []
  392. if self.wndBelt:
  393. self.wndBelt.Destroy()
  394. self.wndBelt = None
  395. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  396. self.wndExpandedMoneyBar = None
  397. self.inventoryTab = []
  398. def Hide(self):
  399. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  400. self.OnCloseQuestionDialog()
  401. return
  402. if None != self.tooltipItem:
  403. self.tooltipItem.HideToolTip()
  404. if self.wndCostume:
  405. self.isOpenedCostumeWindowWhenClosingInventory = self.wndCostume.IsShow() # ???? ?? ?? ? ???? ?? ?????
  406. self.wndCostume.Close()
  407. if self.wndBelt:
  408. self.isOpenedBeltWindowWhenClosingInventory = self.wndBelt.IsOpeningInventory() # ???? ?? ?? ? ?? ????? ?? ?????
  409. print "Is Opening Belt Inven?? ", self.isOpenedBeltWindowWhenClosingInventory
  410. self.wndBelt.Close()
  411. if self.dlgPickMoney:
  412. self.dlgPickMoney.Close()
  413. if app.ENABLE_CHEQUE_SYSTEM:
  414. if self.dlgPickETC:
  415. self.dlgPickETC.Close()
  416. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  417. if self.wndExpandedMoneyBar:
  418. self.wndExpandedMoneyBar.Close()
  419. wndMgr.Hide(self.hWnd)
  420. def Close(self):
  421. self.Hide()
  422. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  423. def UpdateInven(self):
  424. page = self.inventoryPageIndex
  425. for i in xrange(9):
  426. inv_plus = player.GetEnvanter() + i
  427. inv_pluss = player.GetEnvanter() - i
  428. if page == 2:
  429. if player.GetEnvanter() > 8:
  430. self.EX_INVEN_COVER_IMG_OPEN[i].Hide()
  431. self.EX_INVEN_COVER_IMG_CLOSE[i].Hide()
  432. else:
  433. self.EX_INVEN_COVER_IMG_OPEN[player.GetEnvanter()].Show()
  434. self.EX_INVEN_COVER_IMG_CLOSE[player.GetEnvanter()].Hide()
  435. if inv_pluss >= 0:
  436. self.EX_INVEN_COVER_IMG_OPEN[inv_pluss].Hide()
  437. self.EX_INVEN_COVER_IMG_CLOSE[inv_pluss].Hide()
  438. if inv_plus < 9:
  439. self.EX_INVEN_COVER_IMG_CLOSE[inv_plus].Show()
  440. self.EX_INVEN_COVER_IMG_OPEN[inv_plus].Hide()
  441. elif page == 3:
  442. if player.GetEnvanter() < 9:
  443. self.EX_INVEN_COVER_IMG_OPEN[i].Hide()
  444. self.EX_INVEN_COVER_IMG_CLOSE[i].Show()
  445. elif player.GetEnvanter() > 17:
  446. self.EX_INVEN_COVER_IMG_OPEN[i].Hide()
  447. self.EX_INVEN_COVER_IMG_CLOSE[i].Hide()
  448. else:
  449. self.EX_INVEN_COVER_IMG_OPEN[player.GetEnvanter()-9].Show()
  450. self.EX_INVEN_COVER_IMG_CLOSE[player.GetEnvanter()-9].Hide()
  451. if inv_pluss >= 0:
  452. self.EX_INVEN_COVER_IMG_OPEN[inv_pluss-9].Hide()
  453. if inv_plus < 18:
  454. self.EX_INVEN_COVER_IMG_CLOSE[inv_plus-9].Show()
  455. else:
  456. self.EX_INVEN_COVER_IMG_OPEN[i].Hide()
  457. self.EX_INVEN_COVER_IMG_CLOSE[i].Hide()
  458. def genislet(self):
  459. net.Envanter_genislet()
  460. self.OnCloseQuestionDialog()
  461. def en_ac(self):
  462. if player.GetEnvanter() < 18:
  463. needkeys = (2,2,2,2,3,3,4,4,4,5,5,5,6,6,6,7,7,7)
  464. self.questionDialog = uiCommon.QuestionDialog()
  465. self.questionDialog.SetText(localeInfo.ENVANTER_GENIS_1 % needkeys[player.GetEnvanter()])
  466. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.genislet))
  467. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  468. self.questionDialog.Open()
  469. def PetInventoryInfo(self):
  470. getItemVNum=player.GetItemIndex
  471. #for i in xrange(player.INVENTORY_PAGE_SIZE):
  472. # slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  473. # itemVnum = getItemVNum(slotNumber)
  474. # self.CheckForDeadPet(itemVnum, slotNumber, i)
  475. #chat.AppendChat(chat.CHAT_TYPE_INFO, ":::")
  476. for indPage in xrange(0, 4):
  477. for i in xrange(player.INVENTORY_PAGE_SIZE):
  478. slotNumber = self.LocalSlotPos(indPage, i)
  479. itemVnum = getItemVNum(slotNumber)
  480. self.CheckForDeadPet(itemVnum, slotNumber, i)
  481. def LocalSlotPos(self, page, local):
  482. return page*player.INVENTORY_PAGE_SIZE + local
  483. def CheckForDeadPet(self, itemVnum, slotNumber, ii):
  484. if self.check_sigillo(itemVnum):
  485. item.SelectItem(itemVnum)
  486. itemName = item.GetItemName()
  487. attrSlot = []
  488. for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  489. attrSlot.append(player.GetItemAttribute(slotNumber, i))
  490. if int(attrSlot[3][1]) == 0:
  491. chat.AppendChat(chat.CHAT_TYPE_INFO, "%s ينام حاليا." % (itemName))
  492. def SetInventoryPage(self, page):
  493. for i in xrange(player.INVENTORY_PAGE_SIZE):
  494. self.listActivePets = []
  495. #slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  496. #itemVnum = getItemVNum(slotNumber)
  497. self.wndItem.DeactivateSlot(i)
  498. #if slotNumber in self.listActivePets:
  499. # self.wndItem.DeactivateSlot(i)
  500. # self.listActivePets.remove(slotNumber)
  501. self.inventoryPageIndex = page
  502. for index in range(len(self.inventoryTab)):
  503. if index == page:
  504. continue
  505. self.inventoryTab[index].SetUp()
  506. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  507. self.UpdateInven()
  508. self.RefreshBagSlotWindow()
  509. def ClickMallButton(self):
  510. print "click_mall_button"
  511. net.SendChatPacket("/click_mall")
  512. def ClickDepButton(self):
  513. print "click_dep_button"
  514. net.SendChatPacket("/click_dep")
  515. # DSSButton
  516. def ClickDSSButton(self):
  517. print "click_dss_button"
  518. self.interface.ToggleDragonSoulWindow()
  519. def ClickCostumeButton(self):
  520. print "Click Costume Button"
  521. if self.wndCostume:
  522. if self.wndCostume.IsShow():
  523. self.wndCostume.Hide()
  524. else:
  525. self.wndCostume.Show()
  526. else:
  527. self.wndCostume = CostumeWindow(self)
  528. self.wndCostume.Show()
  529. if app.ENABLE_CHEQUE_SYSTEM:
  530. def OpenPickMoneyDialog(self, focus_idx = 0):
  531. if mouseModule.mouseController.isAttached():
  532. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  533. if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  534. if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  535. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  536. snd.PlaySound("sound/ui/money.wav")
  537. mouseModule.mouseController.DeattachObject()
  538. else:
  539. curMoney = player.GetElk()
  540. curCheque = player.GetCheque()
  541. if curMoney <= 0 and curCheque <= 0:
  542. return
  543. self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  544. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  545. self.dlgPickMoney.Open(curMoney, curCheque)
  546. self.dlgPickMoney.SetMax(9)
  547. self.dlgPickMoney.SetFocus(focus_idx)
  548. else:
  549. def OpenPickMoneyDialog(self):
  550. if mouseModule.mouseController.isAttached():
  551. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  552. if player.SLOT_TYPE_SAFEBOX == mouseModule.mouseController.GetAttachedType():
  553. if player.ITEM_MONEY == mouseModule.mouseController.GetAttachedItemIndex():
  554. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  555. snd.PlaySound("sound/ui/money.wav")
  556. mouseModule.mouseController.DeattachObject()
  557. else:
  558. curMoney = player.GetElk()
  559. if curMoney <= 0:
  560. return
  561. self.dlgPickMoney.SetTitleName(localeInfo.PICK_MONEY_TITLE)
  562. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickMoney))
  563. self.dlgPickMoney.Open(curMoney)
  564. self.dlgPickMoney.SetMax(9)
  565. if app.ENABLE_CHEQUE_SYSTEM:
  566. def OnPickMoney(self, money, cheque):
  567. if cheque > 0 and money > 0:
  568. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHEQUE_ONLY_VALUE)
  569. return
  570. if cheque > 0:
  571. mouseModule.mouseController.AttacCheque(self, player.SLOT_TYPE_INVENTORY, cheque)
  572. else:
  573. mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  574. else:
  575. def OnPickMoney(self, money):
  576. mouseModule.mouseController.AttachMoney(self, player.SLOT_TYPE_INVENTORY, money)
  577. def OnPickItem(self, count):
  578. if app.ENABLE_CHEQUE_SYSTEM:
  579. itemSlotIndex = self.dlgPickETC.itemGlobalSlotIndex
  580. else:
  581. itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex
  582. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  583. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, count)
  584. def __InventoryLocalSlotPosToGlobalSlotPos(self, local):
  585. if player.IsEquipmentSlot(local) or player.IsCostumeSlot(local) or (app.ENABLE_NEW_EQUIPMENT_SYSTEM and player.IsBeltInventorySlot(local)):
  586. return local
  587. return self.inventoryPageIndex*player.INVENTORY_PAGE_SIZE + local
  588. if app.ENABLE_SLOT_COOLDOWN:
  589. def check_sigillo(self, item_vnum):
  590. for x in range(55701,55710):
  591. if x == item_vnum:
  592. return TRUE
  593. if item_vnum == 55801:
  594. return TRUE
  595. return FALSE
  596. def SetCollTimePetItemSlot(self, slotNumber, itemVnum, ii):
  597. if itemVnum == 0:
  598. return
  599. if self.check_sigillo(itemVnum) == FALSE:
  600. return
  601. item.SelectItem(itemVnum)
  602. itemSubType = item.GetItemSubType()
  603. attrSlot = []
  604. for i in xrange(player.ATTRIBUTE_SLOT_MAX_NUM):
  605. attrSlot.append(player.GetItemAttribute(slotNumber, i))
  606. #sock_time = player.GetItemMetinSocket(player.INVENTORY, slotNumber, 0)
  607. #if slotNumber >= player.INVENTORY_PAGE_SIZE:
  608. # slotNumber -= player.INVENTORY_PAGE_SIZE
  609. limitValue = attrSlot[4][1]
  610. remain_time = max( 0, attrSlot[3][1] )
  611. if itemVnum == 55002 and player.GetItemMetinSocket(player.INVENTORY, slotNumber, 2) == 0:
  612. return
  613. if itemVnum == 55002:
  614. if player.GetItemMetinSocket(player.INVENTORY, slotNumber, 2) != 0:
  615. limitValue = 2592000
  616. else:
  617. limitValue = 60*60*24*7
  618. remain_time = max(0, player.GetItemMetinSocket(player.INVENTORY, slotNumber, 0)-app.GetGlobalTimeStamp())
  619. #if ( (limitValue - remain_time) <= 0 ):
  620. # return
  621. self.wndItem.SetSlotCoolTimeInverse(ii, limitValue, limitValue - remain_time)
  622. #chat.AppendChat(chat.CHAT_TYPE_INFO, "LIMIT:"+str(limitValue))
  623. #chat.AppendChat(chat.CHAT_TYPE_INFO, "HERE TIME:"+str(limitValue - remain_time))
  624. def GetInventoryPageIndex(self):
  625. return self.inventoryPageIndex
  626. if app.WJ_ENABLE_TRADABLE_ICON:
  627. def RefreshMarkSlots(self, localIndex=None):
  628. if not self.interface:
  629. return
  630. if not self.wndItem:
  631. return
  632. onTopWnd = self.interface.GetOnTopWindow()
  633. if localIndex:
  634. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(localIndex)
  635. #if app.ENABLE_FISH_EVENT:
  636. itemIndex = player.GetItemIndex(slotNumber)
  637. if onTopWnd == player.ON_TOP_WND_NONE:
  638. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  639. elif onTopWnd == player.ON_TOP_WND_SHOP:
  640. if player.IsAntiFlagBySlot(slotNumber, item.ANTIFLAG_SELL) or app.ENABLE_SOULBIND_SYSTEM and player.GetItemBind(player.INVENTORY, slotNumber):
  641. self.wndItem.SetUnusableSlotOnTopWnd(localIndex)
  642. else:
  643. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  644. elif onTopWnd == player.ON_TOP_WND_EXCHANGE:
  645. if player.IsAntiFlagBySlot(slotNumber, item.ANTIFLAG_GIVE) or app.ENABLE_SOULBIND_SYSTEM and player.GetItemBind(player.INVENTORY, slotNumber):
  646. self.wndItem.SetUnusableSlotOnTopWnd(localIndex)
  647. else:
  648. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  649. elif onTopWnd == player.ON_TOP_WND_PRIVATE_SHOP:
  650. if player.IsAntiFlagBySlot(slotNumber, item.ITEM_ANTIFLAG_MYSHOP) or app.ENABLE_SOULBIND_SYSTEM and player.GetItemBind(player.INVENTORY, slotNumber):
  651. self.wndItem.SetUnusableSlotOnTopWnd(localIndex)
  652. else:
  653. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  654. elif onTopWnd == player.ON_TOP_WND_SAFEBOX:
  655. if player.IsAntiFlagBySlot(slotNumber, item.ANTIFLAG_SAFEBOX):
  656. self.wndItem.SetUnusableSlotOnTopWnd(localIndex)
  657. else:
  658. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  659. elif onTopWnd == player.ON_TOP_WND_FISH_EVENT:
  660. if itemIndex not in [25106, 25107]:
  661. self.wndItem.SetUnusableSlotOnTopWnd(localIndex)
  662. else:
  663. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  664. elif onTopWnd == player.ON_TOP_WND_BK:
  665. itemIndex = player.GetItemIndex(slotNumber)
  666. if itemIndex != 50300:
  667. self.wndItem.SetUnusableSlotOnTopWnd(localIndex)
  668. else:
  669. self.wndItem.SetUsableSlotOnTopWnd(localIndex)
  670. return
  671. for i in xrange(player.INVENTORY_PAGE_SIZE):
  672. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  673. #if app.ENABLE_FISH_EVENT:
  674. itemIndex = player.GetItemIndex(slotNumber)
  675. if onTopWnd == player.ON_TOP_WND_NONE:
  676. self.wndItem.SetUsableSlotOnTopWnd(i)
  677. elif onTopWnd == player.ON_TOP_WND_SHOP:
  678. if player.IsAntiFlagBySlot(slotNumber, item.ANTIFLAG_SELL) or app.ENABLE_SOULBIND_SYSTEM and player.GetItemBind(player.INVENTORY, slotNumber):
  679. self.wndItem.SetUnusableSlotOnTopWnd(i)
  680. else:
  681. self.wndItem.SetUsableSlotOnTopWnd(i)
  682. elif onTopWnd == player.ON_TOP_WND_EXCHANGE:
  683. if player.IsAntiFlagBySlot(slotNumber, item.ANTIFLAG_GIVE) or app.ENABLE_SOULBIND_SYSTEM and player.GetItemBind(player.INVENTORY, slotNumber):
  684. self.wndItem.SetUnusableSlotOnTopWnd(i)
  685. else:
  686. self.wndItem.SetUsableSlotOnTopWnd(i)
  687. elif onTopWnd == player.ON_TOP_WND_PRIVATE_SHOP:
  688. if player.IsAntiFlagBySlot(slotNumber, item.ITEM_ANTIFLAG_MYSHOP) or app.ENABLE_SOULBIND_SYSTEM and player.GetItemBind(player.INVENTORY, slotNumber):
  689. self.wndItem.SetUnusableSlotOnTopWnd(i)
  690. else:
  691. self.wndItem.SetUsableSlotOnTopWnd(i)
  692. elif onTopWnd == player.ON_TOP_WND_SAFEBOX:
  693. if player.IsAntiFlagBySlot(slotNumber, item.ANTIFLAG_SAFEBOX):
  694. self.wndItem.SetUnusableSlotOnTopWnd(i)
  695. else:
  696. self.wndItem.SetUsableSlotOnTopWnd(i)
  697. elif onTopWnd == player.ON_TOP_WND_FISH_EVENT:
  698. if itemIndex not in [25106, 25107]:
  699. self.wndItem.SetUnusableSlotOnTopWnd(i)
  700. else:
  701. self.wndItem.SetUsableSlotOnTopWnd(i)
  702. elif onTopWnd == player.ON_TOP_WND_BK:
  703. if itemIndex != 50300:
  704. self.wndItem.SetUnusableSlotOnTopWnd(i)
  705. else:
  706. self.wndItem.SetUsableSlotOnTopWnd(i)
  707. def RefreshBagSlotWindow(self):
  708. getItemVNum=player.GetItemIndex
  709. getItemCount=player.GetItemCount
  710. setItemVNum=self.wndItem.SetItemSlot
  711. for i in xrange(player.INVENTORY_PAGE_SIZE):
  712. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  713. itemCount = getItemCount(slotNumber)
  714. # itemCount == 0?? ??? ???.
  715. if 0 == itemCount:
  716. self.wndItem.ClearSlot(i)
  717. continue
  718. elif 1 == itemCount:
  719. itemCount = 0
  720. itemVnum = getItemVNum(slotNumber)
  721. #item.SelectItem(slotNumber)
  722. #itemName = item.GetItemName()
  723. setItemVNum(i, itemVnum, itemCount)
  724. if app.ENABLE_CHANGELOOK_SYSTEM:
  725. itemTransmutedVnum = player.GetItemTransmutation(slotNumber)
  726. if itemTransmutedVnum:
  727. self.wndItem.DisableCoverButton(i)
  728. else:
  729. self.wndItem.EnableCoverButton(i)
  730. if itemVnum == 0 and slotNumber in self.liHighlightedItems:
  731. self.liHightlightedItems.remove(slotNumber)
  732. #if constInfo.a == 1:
  733. # self.CheckForDeadPet(itemVnum, slotNumber, itemName)
  734. ## ???? (HP: #72723 ~ #72726, SP: #72727 ~ #72730) ???? - ?????? ??? ???/???? ??? ?? ??? - [hyo]
  735. if constInfo.IS_AUTO_POTION(itemVnum):
  736. # metinSocket - [0] : ??? ??, [1] : ??? ?, [2] : ?? ??
  737. metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]
  738. isActivated = 0 != metinSocket[0]
  739. if isActivated:
  740. if slotNumber not in self.listActivePets:
  741. self.listActivePets.append(slotNumber)
  742. self.wndItem.ActivateSlot(i)
  743. potionType = 0;
  744. if constInfo.IS_AUTO_POTION_HP(itemVnum):
  745. potionType = player.AUTO_POTION_TYPE_HP
  746. elif constInfo.IS_AUTO_POTION_SP(itemVnum):
  747. potionType = player.AUTO_POTION_TYPE_SP
  748. usedAmount = int(metinSocket[1])
  749. totalAmount = int(metinSocket[2])
  750. player.SetAutoPotionInfo(potionType, isActivated, (totalAmount - usedAmount), totalAmount, self.__InventoryLocalSlotPosToGlobalSlotPos(i))
  751. else:
  752. if slotNumber in self.listActivePets:
  753. self.listActivePets.remove(slotNumber)
  754. self.wndItem.DeactivateSlot(i)
  755. if app.WJ_ENABLE_TRADABLE_ICON:
  756. self.RefreshMarkSlots(i)
  757. #if slotNumber in self.liHighlightedItems:
  758. # self.wndItem.ActivateSlot(i)
  759. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  760. slotNumberChecked = 0
  761. for j in xrange(acce.WINDOW_MAX_MATERIALS):
  762. (isHere, iCell) = acce.GetAttachedItem(j)
  763. if isHere:
  764. if iCell == slotNumber:
  765. self.wndItem.ActivateSlot(i, (36.00 / 255.0), (222.00 / 255.0), (3.00 / 255.0), 1.0)
  766. if not slotNumber in self.listAttachedAcces:
  767. self.listAttachedAcces.append(slotNumber)
  768. slotNumberChecked = 1
  769. else:
  770. if slotNumber in self.listAttachedAcces and not slotNumberChecked:
  771. self.wndItem.DeactivateSlot(i)
  772. self.listAttachedAcces.remove(slotNumber)
  773. if app.ENABLE_SLOT_COOLDOWN:
  774. self.SetCollTimePetItemSlot(slotNumber, itemVnum, i)
  775. if itemVnum >= 53001 and itemVnum <= 53400:
  776. metinSocket = [player.GetItemMetinSocket(slotNumber, j) for j in xrange(player.METIN_SOCKET_MAX_NUM)]# <!> globalSlotNumber may be different <!>
  777. isActivated = 0 != metinSocket[1]
  778. if isActivated:
  779. if not slotNumber in self.listActivePets:
  780. self.wndItem.ActivateSlot(i)
  781. self.listActivePets.append(slotNumber)
  782. else:
  783. if slotNumber in self.listActivePets:
  784. self.listActivePets.remove(slotNumber)
  785. self.wndItem.DeactivateSlot(i)
  786. if app.ENABLE_CHANGELOOK_SYSTEM:
  787. slotClNumberChecked = 0
  788. if not constInfo.IS_AUTO_POTION(itemVnum):
  789. if app.ENABLE_HIGHLIGHT_SYSTEM:
  790. if not slotNumber in self.listHighlightedSlot:
  791. self.wndItem.DeactivateSlot(i)
  792. else:
  793. self.wndItem.DeactivateSlot(i)
  794. for q in xrange(changelook.WINDOW_MAX_MATERIALS):
  795. (isHere, iCell) = changelook.GetAttachedItem(q)
  796. if isHere:
  797. if iCell == slotNumber:
  798. self.wndItem.ActivateSlot(i, (238.00 / 255.0), (11.00 / 255.0), (11.00 / 255.0), 1.0)
  799. if not slotNumber in self.listAttachedCl:
  800. self.listAttachedCl.append(slotNumber)
  801. slotClNumberChecked = 1
  802. else:
  803. if slotNumber in self.listAttachedCl and not slotClNumberChecked:
  804. self.wndItem.DeactivateSlot(i)
  805. self.listAttachedCl.remove(slotNumber)
  806. self.__RefreshHighlights()
  807. constInfo.a = 0
  808. self.wndItem.RefreshSlot()
  809. if self.wndBelt:
  810. self.wndBelt.RefreshSlot()
  811. if app.WJ_ENABLE_TRADABLE_ICON:
  812. map(lambda wnd:wnd.RefreshLockedSlot(), self.bindWnds)
  813. def HighlightSlot(self, slot):
  814. if not slot in self.liHighlightedItems:
  815. self.liHighlightedItems.append(slot)
  816. def __RefreshHighlights(self):
  817. for i in xrange(player.INVENTORY_PAGE_SIZE):
  818. slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i)
  819. if slotNumber in self.liHighlightedItems:
  820. self.wndItem.ActivateSlotOld(i)
  821. def RefreshItemSlot(self):
  822. self.RefreshBagSlotWindow()
  823. #self.RefreshEquipSlotWindow()
  824. def RefreshStatus(self):
  825. money = player.GetElk()
  826. self.wndMoney.SetText(localeInfo.NumberToMoneyString(money))
  827. if app.ENABLE_CHEQUE_SYSTEM:
  828. cheque = player.GetCheque()
  829. self.wndCheque.SetText(str(cheque))
  830. if app.ENABLE_GEM_SYSTEM:
  831. gem = player.GetGem()
  832. self.wndGem.SetText(str(gem))
  833. def SetItemToolTip(self, tooltipItem):
  834. self.tooltipItem = tooltipItem
  835. def SellItem(self):
  836. if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber):
  837. if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber):
  838. ## ???? ??? ?? ?? ????? ?? type ??
  839. net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY)
  840. snd.PlaySound("sound/ui/money.wav")
  841. self.OnCloseQuestionDialog()
  842. def OnDetachMetinFromItem(self):
  843. if None == self.questionDialog:
  844. return
  845. #net.SendItemUseToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  846. self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  847. self.OnCloseQuestionDialog()
  848. def OnCloseQuestionDialog(self):
  849. if not self.questionDialog:
  850. return
  851. self.questionDialog.Close()
  852. self.questionDialog = None
  853. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0)
  854. ## Slot Event
  855. def SelectEmptySlot(self, selectedSlotPos):
  856. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  857. return
  858. selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos)
  859. if mouseModule.mouseController.isAttached():
  860. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  861. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  862. attachedItemCount = mouseModule.mouseController.GetAttachedItemCount()
  863. attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex()
  864. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  865. #@fixme011 BEGIN (block ds equip)
  866. attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
  867. if player.IsDSEquipmentSlot(attachedInvenType, attachedSlotPos):
  868. mouseModule.mouseController.DeattachObject()
  869. return
  870. #@fixme011 END
  871. itemCount = player.GetItemCount(attachedSlotPos)
  872. attachedCount = mouseModule.mouseController.GetAttachedItemCount()
  873. self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount)
  874. if item.IsRefineScroll(attachedItemIndex):
  875. self.wndItem.SetUseMode(False)
  876. elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType:
  877. mouseModule.mouseController.RunCallBack("INVENTORY")
  878. elif player.SLOT_TYPE_SHOP == attachedSlotType:
  879. net.SendShopBuyPacket(attachedSlotPos)
  880. elif player.SLOT_TYPE_SAFEBOX == attachedSlotType:
  881. if player.ITEM_MONEY == attachedItemIndex:
  882. net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount())
  883. snd.PlaySound("sound/ui/money.wav")
  884. else:
  885. net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos)
  886. elif player.SLOT_TYPE_MALL == attachedSlotType:
  887. net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos)
  888. mouseModule.mouseController.DeattachObject()
  889. def SelectItemSlot(self, itemSlotIndex):
  890. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1:
  891. return
  892. itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex)
  893. if mouseModule.mouseController.isAttached():
  894. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  895. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  896. attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  897. #chat.AppendChat(chat.CHAT_TYPE_INFO, "LEL")
  898. if player.SLOT_TYPE_INVENTORY == attachedSlotType:
  899. #@fixme011 BEGIN (block ds equip)
  900. attachedInvenType = player.SlotTypeToInvenType(attachedSlotType)
  901. if player.IsDSEquipmentSlot(attachedInvenType, attachedSlotPos):
  902. mouseModule.mouseController.DeattachObject()
  903. return
  904. #@fixme011 END
  905. self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex)
  906. mouseModule.mouseController.DeattachObject()
  907. else:
  908. curCursorNum = app.GetCursor()
  909. if app.SELL == curCursorNum:
  910. self.__SellItem(itemSlotIndex)
  911. elif app.BUY == curCursorNum:
  912. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO)
  913. elif app.IsPressed(app.DIK_LALT):
  914. link = player.GetItemLink(itemSlotIndex)
  915. ime.PasteString(link)
  916. elif app.IsPressed(app.DIK_LSHIFT):
  917. itemCount = player.GetItemCount(itemSlotIndex)
  918. if itemCount > 1:
  919. if app.ENABLE_CHEQUE_SYSTEM:
  920. self.dlgPickETC.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  921. self.dlgPickETC.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  922. self.dlgPickETC.Open(itemCount)
  923. self.dlgPickETC.itemGlobalSlotIndex = itemSlotIndex
  924. else:
  925. self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE)
  926. self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem))
  927. self.dlgPickMoney.Open(itemCount)
  928. self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex
  929. #else:
  930. #selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  931. #mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum)
  932. elif app.IsPressed(app.DIK_LCONTROL):
  933. itemIndex = player.GetItemIndex(itemSlotIndex)
  934. if True == item.CanAddToQuickSlotItem(itemIndex):
  935. player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex)
  936. else:
  937. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM)
  938. else:
  939. selectedItemVNum = player.GetItemIndex(itemSlotIndex)
  940. itemCount = player.GetItemCount(itemSlotIndex)
  941. mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount)
  942. if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex):
  943. self.wndItem.SetUseMode(True)
  944. else:
  945. self.wndItem.SetUseMode(False)
  946. snd.PlaySound("sound/ui/pick.wav")
  947. def UseTransportBox(self):
  948. self.__SendUseItemToItemPacket(self.questionDialog.src, self.questionDialog.dst)
  949. self.OnCloseQuestionDialog()
  950. def UseProtein(self):
  951. self.__SendUseItemToItemPacket(self.questionDialog.src, self.questionDialog.dst)
  952. self.OnCloseQuestionDialog()
  953. def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos):
  954. if srcItemSlotPos == dstItemSlotPos:
  955. return
  956. itemName = item.GetItemName()
  957. if srcItemVID >= 55701 and srcItemVID <= 55710 and player.GetItemIndex(dstItemSlotPos) == 55002:
  958. self.questionDialog = uiCommon.QuestionDialog()
  959. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_PET_BAG_ITEM)
  960. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.UseTransportBox))
  961. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  962. self.questionDialog.Open()
  963. self.questionDialog.src = srcItemSlotPos
  964. self.questionDialog.dst = dstItemSlotPos
  965. if srcItemVID == 55001 and player.GetItemIndex(dstItemSlotPos) >= 55701 and player.GetItemIndex(dstItemSlotPos) <= 55710:
  966. self.questionDialog = uiCommon.QuestionDialog()
  967. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_PET_FEEDSTUFF_ITEM % (itemName))
  968. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.UseProtein))
  969. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  970. self.questionDialog.Open()
  971. self.questionDialog.src = srcItemSlotPos
  972. self.questionDialog.dst = dstItemSlotPos
  973. if srcItemVID == 76045:
  974. if player.GetItemIndex(dstItemSlotPos) >= 55701 and player.GetItemIndex(dstItemSlotPos) <= 55710:
  975. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  976. return
  977. if app.ENABLE_SOULBIND_SYSTEM:
  978. SrcItemVNum = player.GetItemIndex(srcItemSlotPos)
  979. DstItemVNum = player.GetItemIndex(dstItemSlotPos)
  980. item.SelectItem(SrcItemVNum)
  981. SrcSubType = item.GetItemSubType()
  982. if SrcSubType == item.USE_BIND or SrcSubType == item.USE_UNBIND:
  983. item.SelectItem(DstItemVNum)
  984. if item.GetItemType() == item.ITEM_TYPE_WEAPON or item.GetItemType() == item.ITEM_TYPE_ARMOR or item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_WEAPON or item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_BODY or item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_HAIR or item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_ACCE:
  985. if SrcSubType == item.USE_BIND and player.GetItemBind(dstItemSlotPos) > 1:
  986. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SOULBIND_ALERT3)
  987. elif SrcSubType == item.USE_BIND and player.GetItemBind(dstItemSlotPos) == 1:
  988. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SOULBIND_ALERT2)
  989. elif SrcSubType == item.USE_UNBIND and player.GetItemBind(dstItemSlotPos) > 1:
  990. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SOULBIND_ALERT3)
  991. elif SrcSubType == item.USE_UNBIND and player.GetItemBind(dstItemSlotPos) != 1:
  992. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SOULBIND_ALERT1)
  993. else:
  994. action = "bind"
  995. if SrcSubType == item.USE_UNBIND:
  996. action = "unbind"
  997. self.__SoulBindItem(srcItemSlotPos, dstItemSlotPos, action)
  998. return
  999. else:
  1000. if item.IsRefineScroll(srcItemVID):
  1001. self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  1002. self.wndItem.SetUseMode(FALSE)
  1003. elif item.IsMetin(srcItemVID):
  1004. self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  1005. elif item.IsDetachScroll(srcItemVID):
  1006. self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  1007. elif item.IsKey(srcItemVID):
  1008. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  1009. elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1010. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  1011. elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  1012. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  1013. else:
  1014. if player.IsEquipmentSlot(dstItemSlotPos):
  1015. if item.IsEquipmentVID(srcItemVID):
  1016. self.__UseItem(srcItemSlotPos)
  1017. else:
  1018. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  1019. else:
  1020. if item.IsRefineScroll(srcItemVID):
  1021. self.RefineItem(srcItemSlotPos, dstItemSlotPos)
  1022. self.wndItem.SetUseMode(FALSE)
  1023. elif item.IsMetin(srcItemVID):
  1024. self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos)
  1025. elif item.IsDetachScroll(srcItemVID):
  1026. self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos)
  1027. elif item.IsKey(srcItemVID):
  1028. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  1029. elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1030. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  1031. elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE:
  1032. self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos)
  1033. else:
  1034. if player.IsEquipmentSlot(dstItemSlotPos):
  1035. if item.IsEquipmentVID(srcItemVID):
  1036. self.__UseItem(srcItemSlotPos)
  1037. else:
  1038. self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0)
  1039. def __SellItem(self, itemSlotPos):
  1040. if not player.IsEquipmentSlot(itemSlotPos):
  1041. self.sellingSlotNumber = itemSlotPos
  1042. itemIndex = player.GetItemIndex(itemSlotPos)
  1043. itemCount = player.GetItemCount(itemSlotPos)
  1044. self.sellingSlotitemIndex = itemIndex
  1045. self.sellingSlotitemCount = itemCount
  1046. item.SelectItem(itemIndex)
  1047. ## ?? ??? ?? ??? ??
  1048. ## 20140220
  1049. if item.IsAntiFlag(item.ANTIFLAG_SELL):
  1050. popup = uiCommon.PopupDialog()
  1051. popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM)
  1052. popup.SetAcceptEvent(self.__OnClosePopupDialog)
  1053. popup.Open()
  1054. self.popup = popup
  1055. return
  1056. itemPrice = item.GetISellItemPrice()
  1057. if item.Is1GoldItem():
  1058. itemPrice = itemCount / itemPrice / 5
  1059. else:
  1060. itemPrice = itemPrice * itemCount / 5
  1061. item.GetItemName(itemIndex)
  1062. itemName = item.GetItemName()
  1063. self.questionDialog = uiCommon.QuestionDialog()
  1064. self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice))
  1065. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem))
  1066. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  1067. self.questionDialog.Open()
  1068. self.questionDialog.count = itemCount
  1069. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  1070. def __OnClosePopupDialog(self):
  1071. self.pop = None
  1072. def RefineItem(self, scrollSlotPos, targetSlotPos):
  1073. scrollIndex = player.GetItemIndex(scrollSlotPos)
  1074. targetIndex = player.GetItemIndex(targetSlotPos)
  1075. if player.REFINE_OK != player.CanRefine(scrollIndex, targetSlotPos):
  1076. return
  1077. ###########################################################
  1078. self.__SendUseItemToItemPacket(scrollSlotPos, targetSlotPos)
  1079. #net.SendItemUseToItemPacket(scrollSlotPos, targetSlotPos)
  1080. return
  1081. ###########################################################
  1082. ###########################################################
  1083. #net.SendRequestRefineInfoPacket(targetSlotPos)
  1084. #return
  1085. ###########################################################
  1086. result = player.CanRefine(scrollIndex, targetSlotPos)
  1087. if player.REFINE_ALREADY_MAX_SOCKET_COUNT == result:
  1088. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  1089. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_MORE_SOCKET)
  1090. elif player.REFINE_NEED_MORE_GOOD_SCROLL == result:
  1091. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  1092. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NEED_BETTER_SCROLL)
  1093. elif player.REFINE_CANT_MAKE_SOCKET_ITEM == result:
  1094. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  1095. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_SOCKET_DISABLE_ITEM)
  1096. elif player.REFINE_NOT_NEXT_GRADE_ITEM == result:
  1097. #snd.PlaySound("sound/ui/jaeryun_fail.wav")
  1098. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_UPGRADE_DISABLE_ITEM)
  1099. elif player.REFINE_CANT_REFINE_METIN_TO_EQUIPMENT == result:
  1100. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  1101. if player.REFINE_OK != result:
  1102. return
  1103. self.refineDialog.Open(scrollSlotPos, targetSlotPos)
  1104. def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos):
  1105. scrollIndex = player.GetItemIndex(scrollSlotPos)
  1106. targetIndex = player.GetItemIndex(targetSlotPos)
  1107. if app.ENABLE_ACCE_COSTUME_SYSTEM and app.ENABLE_CHANGELOOK_SYSTEM:
  1108. if not player.CanDetach(scrollIndex, targetSlotPos):
  1109. item.SelectItem(scrollIndex)
  1110. if item.GetValue(0) == acce.CLEAN_ATTR_VALUE0:
  1111. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.ACCE_FAILURE_CLEAN)
  1112. if item.GetValue(0) == changelook.CLEAN_ATTR_VALUE0:
  1113. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.CHANGE_LOOK_FAILURE_CLEAN)
  1114. else:
  1115. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  1116. return
  1117. else:
  1118. if not player.CanDetach(scrollIndex, targetSlotPos):
  1119. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM)
  1120. return
  1121. self.questionDialog = uiCommon.QuestionDialog()
  1122. self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN)
  1123. if app.ENABLE_ACCE_COSTUME_SYSTEM and app.ENABLE_CHANGELOOK_SYSTEM:
  1124. item.SelectItem(targetIndex)
  1125. if item.GetItemType() == item.ITEM_TYPE_COSTUME and item.GetItemSubType() == item.COSTUME_TYPE_ACCE:
  1126. item.SelectItem(scrollIndex)
  1127. if item.GetValue(0) == acce.CLEAN_ATTR_VALUE0:
  1128. self.questionDialog.SetText(localeInfo.ACCE_DO_YOU_CLEAN)
  1129. if item.GetValue(0) == changelook.CLEAN_ATTR_VALUE0:
  1130. self.questionDialog.SetText(localeInfo.CHANGE_LOOK_DO_YOU_CLEAN)
  1131. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem))
  1132. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  1133. self.questionDialog.Open()
  1134. self.questionDialog.sourcePos = scrollSlotPos
  1135. self.questionDialog.targetPos = targetSlotPos
  1136. def AttachMetinToItem(self, metinSlotPos, targetSlotPos):
  1137. metinIndex = player.GetItemIndex(metinSlotPos)
  1138. targetIndex = player.GetItemIndex(targetSlotPos)
  1139. item.SelectItem(metinIndex)
  1140. itemName = item.GetItemName()
  1141. result = player.CanAttachMetin(metinIndex, targetSlotPos)
  1142. if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result:
  1143. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH(itemName))
  1144. if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result:
  1145. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName))
  1146. elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result:
  1147. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName))
  1148. elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result:
  1149. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM)
  1150. if player.ATTACH_METIN_OK != result:
  1151. return
  1152. self.attachMetinDialog.Open(metinSlotPos, targetSlotPos)
  1153. def OverOutItem(self):
  1154. self.wndItem.SetUsableItem(False)
  1155. if None != self.tooltipItem:
  1156. self.tooltipItem.HideToolTip()
  1157. def OverInItem(self, overSlotPos):
  1158. overSlotPosGlobal = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos)
  1159. self.wndItem.SetUsableItem(False)
  1160. if overSlotPosGlobal in self.liHighlightedItems:
  1161. self.liHighlightedItems.remove(overSlotPosGlobal)
  1162. self.wndItem.DeactivateSlotOld(overSlotPos)
  1163. if mouseModule.mouseController.isAttached():
  1164. attachedItemType = mouseModule.mouseController.GetAttachedType()
  1165. if player.SLOT_TYPE_INVENTORY == attachedItemType:
  1166. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  1167. attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex()
  1168. if attachedItemVNum==player.ITEM_MONEY: # @fixme005
  1169. pass
  1170. elif self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPosGlobal):
  1171. self.wndItem.SetUsableItem(True)
  1172. self.ShowToolTip(overSlotPosGlobal)
  1173. return
  1174. self.ShowToolTip(overSlotPosGlobal)
  1175. def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos):
  1176. "?? ???? ??? ? ?? ??????"
  1177. if srcItemVNum >= 55701 and srcItemVNum <= 55710:
  1178. return True
  1179. if srcItemVNum == 55001:
  1180. return True
  1181. if item.IsRefineScroll(srcItemVNum):
  1182. return True
  1183. elif item.IsMetin(srcItemVNum):
  1184. return True
  1185. elif item.IsDetachScroll(srcItemVNum):
  1186. return True
  1187. elif item.IsKey(srcItemVNum):
  1188. return True
  1189. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1190. return True
  1191. else:
  1192. if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE:
  1193. return True
  1194. return False
  1195. def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos):
  1196. "?? ???? ??? ? ????"
  1197. if srcSlotPos == dstSlotPos:
  1198. return False
  1199. if srcItemVNum >= 55701 and srcItemVNum <= 55710 and player.GetItemIndex(dstSlotPos) == 55002:
  1200. return True
  1201. if srcItemVNum == 55001 and player.GetItemIndex(dstSlotPos) >= 55701 and player.GetItemIndex(dstSlotPos) <= 55710:
  1202. return True
  1203. if item.IsRefineScroll(srcItemVNum):
  1204. if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos):
  1205. return True
  1206. elif item.IsMetin(srcItemVNum):
  1207. if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos):
  1208. return True
  1209. elif item.IsDetachScroll(srcItemVNum):
  1210. if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos):
  1211. return True
  1212. elif item.IsKey(srcItemVNum):
  1213. if player.CanUnlock(srcItemVNum, dstSlotPos):
  1214. return True
  1215. elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE:
  1216. return True
  1217. else:
  1218. useType=item.GetUseType(srcItemVNum)
  1219. if "USE_CLEAN_SOCKET" == useType:
  1220. if self.__CanCleanBrokenMetinStone(dstSlotPos):
  1221. return True
  1222. elif "USE_CHANGE_ATTRIBUTE" == useType:
  1223. if self.__CanChangeItemAttrList(dstSlotPos):
  1224. return True
  1225. elif "USE_ADD_ATTRIBUTE" == useType:
  1226. if self.__CanAddItemAttr(dstSlotPos):
  1227. return True
  1228. elif "USE_ADD_ATTRIBUTE2" == useType:
  1229. if self.__CanAddItemAttr(dstSlotPos):
  1230. return True
  1231. elif "USE_ADD_ACCESSORY_SOCKET" == useType:
  1232. if self.__CanAddAccessorySocket(dstSlotPos):
  1233. return True
  1234. elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType:
  1235. if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum):
  1236. return True;
  1237. elif "USE_PUT_INTO_BELT_SOCKET" == useType:
  1238. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1239. print "USE_PUT_INTO_BELT_SOCKET", srcItemVNum, dstItemVNum
  1240. item.SelectItem(dstItemVNum)
  1241. if item.ITEM_TYPE_BELT == item.GetItemType():
  1242. return True
  1243. elif useType == "USE_BIND" or useType == "USE_UNBIND":
  1244. if not app.ENABLE_SOULBIND_SYSTEM:
  1245. return FALSE
  1246. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1247. item.SelectItem(dstItemVNum)
  1248. if item.IsAntiFlag(item.ANTIFLAG_BIND):
  1249. return FALSE
  1250. elif useType == "USE_BIND" and player.GetItemBind(dstSlotPos) == 1:
  1251. return FALSE
  1252. elif useType == "USE_BIND" and player.GetItemBind(dstSlotPos) > 1:
  1253. return FALSE
  1254. elif useType == "USE_UNBIND" and player.GetItemBind(dstSlotPos) != 1:
  1255. return FALSE
  1256. else:
  1257. return TRUE
  1258. elif "USE_CHANGE_COSTUME_ATTR" == useType:
  1259. if self.__CanChangeCostumeAttrList(dstSlotPos):
  1260. return True
  1261. elif "USE_RESET_COSTUME_ATTR" == useType:
  1262. if self.__CanResetCostumeAttr(dstSlotPos):
  1263. return True
  1264. return False
  1265. if app.ENABLE_SOULBIND_SYSTEM:
  1266. def __SoulBindItem(self, scrollSlotPos, targetSlotPos, action = "bind"):
  1267. DstItemVNum = player.GetItemIndex(targetSlotPos)
  1268. item.SelectItem(DstItemVNum)
  1269. item_name = item.GetItemName()
  1270. self.questionDialog = uiCommon.QuestionDialog()
  1271. if action == "bind":
  1272. self.questionDialog.SetText(localeInfo.SOULBIND_ITEM % (item_name))
  1273. else:
  1274. self.questionDialog.SetText(localeInfo.SOULUNBIND_ITEM % (item_name))
  1275. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnAcceptSoulBindItem))
  1276. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog))
  1277. self.questionDialog.Open()
  1278. self.questionDialog.sourcePos = scrollSlotPos
  1279. self.questionDialog.targetPos = targetSlotPos
  1280. def OnAcceptSoulBindItem(self):
  1281. if self.questionDialog == None:
  1282. return
  1283. self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos)
  1284. self.OnCloseQuestionDialog()
  1285. def __CanCleanBrokenMetinStone(self, dstSlotPos):
  1286. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1287. if dstItemVNum == 0:
  1288. return False
  1289. item.SelectItem(dstItemVNum)
  1290. if item.ITEM_TYPE_WEAPON != item.GetItemType():
  1291. return False
  1292. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1293. if player.GetItemMetinSocket(dstSlotPos, i) == constInfo.ERROR_METIN_STONE:
  1294. return True
  1295. return False
  1296. def __CanChangeItemAttrList(self, dstSlotPos):
  1297. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1298. if dstItemVNum == 0:
  1299. return False
  1300. item.SelectItem(dstItemVNum)
  1301. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1302. return False
  1303. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1304. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1305. return True
  1306. return False
  1307. def __CanChangeCostumeAttrList(self, dstSlotPos):
  1308. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1309. if dstItemVNum == 0:
  1310. return False
  1311. item.SelectItem(dstItemVNum)
  1312. if item.GetItemType() != item.ITEM_TYPE_COSTUME:
  1313. return False
  1314. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1315. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1316. return True
  1317. return False
  1318. def __CanResetCostumeAttr(self, dstSlotPos):
  1319. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1320. if dstItemVNum == 0:
  1321. return False
  1322. item.SelectItem(dstItemVNum)
  1323. if item.GetItemType() != item.ITEM_TYPE_COSTUME:
  1324. return False
  1325. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1326. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1327. return True
  1328. return False
  1329. def __CanPutAccessorySocket(self, dstSlotPos, mtrlVnum):
  1330. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1331. if dstItemVNum == 0:
  1332. return False
  1333. item.SelectItem(dstItemVNum)
  1334. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1335. return False
  1336. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1337. return False
  1338. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1339. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1340. if mtrlVnum != constInfo.GET_ACCESSORY_MATERIAL_VNUM(dstItemVNum, item.GetItemSubType()):
  1341. return False
  1342. if curCount>=maxCount:
  1343. return False
  1344. return True
  1345. def __CanAddAccessorySocket(self, dstSlotPos):
  1346. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1347. if dstItemVNum == 0:
  1348. return False
  1349. item.SelectItem(dstItemVNum)
  1350. if item.GetItemType() != item.ITEM_TYPE_ARMOR:
  1351. return False
  1352. if not item.GetItemSubType() in (item.ARMOR_WRIST, item.ARMOR_NECK, item.ARMOR_EAR):
  1353. return False
  1354. curCount = player.GetItemMetinSocket(dstSlotPos, 0)
  1355. maxCount = player.GetItemMetinSocket(dstSlotPos, 1)
  1356. ACCESSORY_SOCKET_MAX_SIZE = 3
  1357. if maxCount >= ACCESSORY_SOCKET_MAX_SIZE:
  1358. return False
  1359. return True
  1360. def __CanAddItemAttr(self, dstSlotPos):
  1361. dstItemVNum = player.GetItemIndex(dstSlotPos)
  1362. if dstItemVNum == 0:
  1363. return False
  1364. item.SelectItem(dstItemVNum)
  1365. if not item.GetItemType() in (item.ITEM_TYPE_WEAPON, item.ITEM_TYPE_ARMOR):
  1366. return False
  1367. attrCount = 0
  1368. for i in xrange(player.METIN_SOCKET_MAX_NUM):
  1369. if player.GetItemAttribute(dstSlotPos, i) != 0:
  1370. attrCount += 1
  1371. if attrCount<4:
  1372. return True
  1373. return False
  1374. def ShowToolTip(self, slotIndex):
  1375. if None != self.tooltipItem:
  1376. self.tooltipItem.SetInventoryItem(slotIndex)
  1377. def OnTop(self):
  1378. if None != self.tooltipItem:
  1379. self.tooltipItem.SetTop()
  1380. if app.WJ_ENABLE_TRADABLE_ICON:
  1381. map(lambda wnd:wnd.RefreshLockedSlot(), self.bindWnds)
  1382. self.RefreshMarkSlots()
  1383. def OnPressEscapeKey(self):
  1384. self.Close()
  1385. return True
  1386. def UseItemSlot(self, slotIndex):
  1387. curCursorNum = app.GetCursor()
  1388. if app.SELL == curCursorNum:
  1389. return
  1390. if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS():
  1391. return
  1392. slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex)
  1393. if mouseModule.mouseController.isAttached():
  1394. attachedSlotType = mouseModule.mouseController.GetAttachedType()
  1395. attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber()
  1396. attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex()
  1397. #chat.AppendChat(chat.CHAT_TYPE_INFO, "-")
  1398. mouseModule.mouseController.DeattachObject()
  1399. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1400. if self.wndDragonSoulRefine.IsShow():
  1401. self.wndDragonSoulRefine.AutoSetItem((player.INVENTORY, slotIndex), 1)
  1402. return
  1403. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  1404. if self.isShowAcceWindow():
  1405. acce.Add(player.INVENTORY, slotIndex, 255)
  1406. return
  1407. if app.ENABLE_CHANGELOOK_SYSTEM:
  1408. if self.isShowChangeLookWindow():
  1409. changelook.Add(player.INVENTORY, slotIndex, 255)
  1410. return
  1411. self.__UseItem(slotIndex)
  1412. mouseModule.mouseController.DeattachObject()
  1413. self.OverOutItem()
  1414. def __UseItem(self, slotIndex):
  1415. ItemVNum = player.GetItemIndex(slotIndex)
  1416. item.SelectItem(ItemVNum)
  1417. #chat.AppendChat(chat.CHAT_TYPE_INFO, "HOLA")
  1418. if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE) or ItemVNum == 55029 or ItemVNum == 55002:
  1419. self.questionDialog = uiCommon.QuestionDialog()
  1420. self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM)
  1421. self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept))
  1422. self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel))
  1423. self.questionDialog.Open()
  1424. self.questionDialog.slotIndex = slotIndex
  1425. constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1)
  1426. else:
  1427. self.__SendUseItemPacket(slotIndex)
  1428. #net.SendItemUsePacket(slotIndex)
  1429. if app.ENABLE_EXTEND_INVEN_SYSTEM:
  1430. if ItemVNum == 72320:
  1431. self.en_ac()
  1432. def __UseItemQuestionDialog_OnCancel(self):
  1433. self.OnCloseQuestionDialog()
  1434. def __UseItemQuestionDialog_OnAccept(self):
  1435. self.__SendUseItemPacket(self.questionDialog.slotIndex)
  1436. self.OnCloseQuestionDialog()
  1437. def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
  1438. # ???? ?? ?? ?? ??? ?? ??
  1439. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1440. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1441. return
  1442. net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
  1443. def __SendUseItemPacket(self, slotPos):
  1444. # ???? ?? ?? ?? ??? ?? ??
  1445. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1446. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP)
  1447. return
  1448. net.SendItemUsePacket(slotPos)
  1449. def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount):
  1450. # ???? ?? ?? ?? ??? ?? ??
  1451. if uiPrivateShopBuilder.IsBuildingPrivateShop():
  1452. chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP)
  1453. return
  1454. net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount)
  1455. def SetDragonSoulRefineWindow(self, wndDragonSoulRefine):
  1456. if app.ENABLE_DRAGON_SOUL_SYSTEM:
  1457. self.wndDragonSoulRefine = wndDragonSoulRefine
  1458. if app.ENABLE_ACCE_COSTUME_SYSTEM:
  1459. def SetAcceWindow(self, wndAcceCombine, wndAcceAbsorption):
  1460. self.wndAcceCombine = wndAcceCombine
  1461. self.wndAcceAbsorption = wndAcceAbsorption
  1462. def isShowAcceWindow(self):
  1463. if self.wndAcceCombine:
  1464. if self.wndAcceCombine.IsShow():
  1465. return 1
  1466. if self.wndAcceAbsorption:
  1467. if self.wndAcceAbsorption.IsShow():
  1468. return 1
  1469. return 0
  1470. if app.ENABLE_CHANGELOOK_SYSTEM:
  1471. def SetChangeLookWindow(self, wndChangeLook):
  1472. self.wndChangeLook = wndChangeLook
  1473. def isShowChangeLookWindow(self):
  1474. if self.wndChangeLook:
  1475. if self.wndChangeLook.IsShow():
  1476. return 1
  1477. return 0
  1478. def OnMoveWindow(self, x, y):
  1479. # print "Inventory Global Pos : ", self.GetGlobalPosition()
  1480. if self.wndBelt:
  1481. # print "Belt Global Pos : ", self.wndBelt.GetGlobalPosition()
  1482. self.wndBelt.AdjustPositionAndSize()
  1483. if app.ENABLE_CHEQUE_SYSTEM:
  1484. def OverInToolTip(self, arg):
  1485. arglen = len(str(arg))
  1486. pos_x, pos_y = wndMgr.GetMousePosition()
  1487. self.toolTip.ClearToolTip()
  1488. self.toolTip.SetThinBoardSize(11 * arglen)
  1489. self.toolTip.SetToolTipPosition(pos_x + 5, pos_y - 5)
  1490. self.toolTip.AppendTextLine(arg, 0xffffff00)
  1491. self.toolTip.Show()
  1492. def OverOutToolTip(self):
  1493. self.toolTip.Hide()
  1494. def EventProgress(self, event_type, idx):
  1495. if "MOUSE_OVER_IN2" == str(event_type):
  1496. if idx == 0 :
  1497. self.OverInToolTip(localeInfo.CHEQUE_SYSTEM_UNIT_YANG)
  1498. elif idx == 1 :
  1499. self.OverInToolTip(localeInfo.CHEQUE_SYSTEM_UNIT_WON)
  1500. elif idx == 2 :
  1501. self.OverInToolTip(localeInfo.GEM_SYSTEM_NAME)
  1502. else:
  1503. return
  1504. elif "MOUSE_OVER_OUT2" == str(event_type) :
  1505. self.OverOutToolTip()
  1506. else:
  1507. return
  1508. if app.ENABLE_EXPANDED_MONEY_TASKBAR:
  1509. def SetExpandedMoneyBar(self, wndBar):
  1510. self.wndExpandedMoneyBar = wndBar
  1511. if self.wndExpandedMoneyBar:
  1512. self.wndMoneySlot = self.wndExpandedMoneyBar.GetMoneySlot()
  1513. self.wndMoney = self.wndExpandedMoneyBar.GetMoney()
  1514. self.wndMoneyIcon = self.wndExpandedMoneyBar.GetMoneyIcon()
  1515. if self.wndMoneyIcon:
  1516. self.wndMoneyIcon.SetEvent(ui.__mem_func__(self.EventProgress), "MOUSE_OVER_IN2", 0)
  1517. self.wndMoneyIcon.SetEvent(ui.__mem_func__(self.EventProgress), "MOUSE_OVER_OUT2", 0)
  1518. if self.wndMoneySlot:
  1519. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog), 0)
  1520. if app.ENABLE_CHEQUE_SYSTEM:
  1521. self.wndChequeIcon = self.wndExpandedMoneyBar.GetChequeIcon()
  1522. if self.wndChequeIcon:
  1523. self.wndChequeIcon.SetEvent(ui.__mem_func__(self.EventProgress), "MOUSE_OVER_IN2", 1)
  1524. self.wndChequeIcon.SetEvent(ui.__mem_func__(self.EventProgress), "MOUSE_OVER_OUT2", 1)
  1525. self.wndChequeSlot = self.wndExpandedMoneyBar.GetChequeSlot()
  1526. if self.wndChequeSlot:
  1527. self.wndChequeSlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog), 1)
  1528. self.wndCheque = self.wndExpandedMoneyBar.GetCheque()
  1529. if app.ENABLE_GEM_SYSTEM:
  1530. self.wndGemIcon = self.wndExpandedMoneyBar.GetGemIcon()
  1531. if self.wndGemIcon:
  1532. self.wndGemIcon.SetEvent(ui.__mem_func__(self.EventProgress), "MOUSE_OVER_IN2", 2)
  1533. self.wndGemIcon.SetEvent(ui.__mem_func__(self.EventProgress), "MOUSE_OVER_OUT2", 2)
  1534. self.wndGemSlot = self.wndExpandedMoneyBar.GetGemSlot()
  1535. if self.wndGemSlot:
  1536. self.wndGemSlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog), 2)
  1537. self.wndGem = self.wndExpandedMoneyBar.GetGem()
  1538. self.toolTip = uiToolTip.ToolTip()
  1539. self.toolTip.ClearToolTip()
  1540. else:
  1541. if self.wndMoneySlot:
  1542. self.wndMoneySlot.SetEvent(ui.__mem_func__(self.OpenPickMoneyDialog))