import ui import player import mouseModule import net import app import snd import item import player import chat import grp import uiScriptLocale import uiRefine import uiAttachMetin import uiPickMoney import uiCommon import uiPrivateShopBuilder import localeInfo import constInfo import osfInfo import ime import wndMgr if app.ENABLE_CHEQUE_SYSTEM: import uiToolTip import uiPickETC ITEM_MALL_BUTTON_ENABLE = True ITEM_FLAG_APPLICABLE = 1 << 14 class SpecialInventoryWindow(ui.ScriptWindow): 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" ) questionDialog = None tooltipItem = None dlgPickMoney = None if app.ENABLE_CHEQUE_SYSTEM: dlgPickETC = None sellingSlotNumber = -1 isLoaded = 0 interface = None inventoryPageIndex = 0 def __init__(self): ui.ScriptWindow.__init__(self) self.__LoadWindow() def __del__(self): ui.ScriptWindow.__del__(self) def Show(self, category = 0): self.__LoadWindow() ui.ScriptWindow.Show(self) self.RefreshItemSlot() def BindInterfaceClass(self, interface): from _weakref import proxy self.interface = proxy(interface) def __LoadWindow(self): if self.isLoaded == 1: return self.isLoaded = 1 try: pyScrLoader = ui.PythonScriptLoader() pyScrLoader.LoadScriptFile(self, uiScriptLocale.LOCALE_UISCRIPT_PATH + "SpecialInventoryWindow.py") except: import exception exception.Abort("SpecialInventoryWindow.LoadWindow.LoadObject") try: wndItem = self.GetChild("ItemSlot") self.GetChild("TitleBar").SetCloseEvent(ui.__mem_func__(self.Close)) self.titleName = self.GetChild("TitleName") if app.ENABLE_SORT_INVENTORY: self.sortInventoryButton = self.GetChild2("SortInventoryButton") self.SkillBookButton = self.GetChild("SkillBookButton") self.UpgradeItemsButton = self.GetChild("UpgradeItemsButton") self.stoneButton = self.GetChild("StoneButton") self.GiftBoxButton = self.GetChild("GiftBoxButton") self.inventoryTab = [] self.inventoryTab.append(self.GetChild("Inventory_Tab_01")) self.inventoryTab.append(self.GetChild("Inventory_Tab_02")) self.inventoryTab.append(self.GetChild("Inventory_Tab_03")) self.inventoryTab.append(self.GetChild("Inventory_Tab_04")) self.inventoryTab.append(self.GetChild("Inventory_Tab_05")) self.dlgQuestion = uiCommon.QuestionDialog2() self.dlgQuestion.Close() if app.WJ_ENABLE_PICKUP_ITEM_EFFECT: self.listHighlightedSlot = [] except: import exception exception.Abort("SpecialInventoryWindow.LoadWindow.BindObject") ## Item wndItem.SetSelectEmptySlotEvent(ui.__mem_func__(self.SelectEmptySlot)) wndItem.SetSelectItemSlotEvent(ui.__mem_func__(self.SelectItemSlot)) wndItem.SetUnselectItemSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetUseSlotEvent(ui.__mem_func__(self.UseItemSlot)) wndItem.SetOverInItemEvent(ui.__mem_func__(self.OverInItem)) wndItem.SetOverOutItemEvent(ui.__mem_func__(self.OverOutItem)) self.SkillBookButton.SetEvent(lambda arg=0: self.SetInventoryType(arg)) self.UpgradeItemsButton.SetEvent(lambda arg=1: self.SetInventoryType(arg)) self.stoneButton.SetEvent(lambda arg=2: self.SetInventoryType(arg)) self.GiftBoxButton.SetEvent(lambda arg=3: self.SetInventoryType(arg)) self.SkillBookButton.Down() ## PickMoneyDialog dlgPickMoney = uiPickMoney.PickMoneyDialog() dlgPickMoney.LoadDialog() dlgPickMoney.Hide() ## PickETCDialog if app.ENABLE_CHEQUE_SYSTEM: dlgPickETC = uiPickETC.PickETCDialog() dlgPickETC.LoadDialog() dlgPickETC.Hide() self.dlgPickETC = dlgPickETC ## AttachMetinDialog self.attachMetinDialog = uiAttachMetin.AttachMetinDialog() self.attachMetinDialog.Hide() for inven_index in range(player.SPECIAL_INVENTORY_PAGE_COUNT): self.inventoryTab[inven_index].SetEvent(lambda arg=inven_index: self.SetInventoryPage(arg)) self.inventoryTab[0].Down() self.wndItem = wndItem self.dlgPickMoney = dlgPickMoney if app.ENABLE_SORT_INVENTORY: if self.sortInventoryButton: self.sortInventoryButton.SetEvent(ui.__mem_func__(self.SortInventoryButton)) ## Refresh self.SetInventoryType(0) self.SetInventoryPage(0) self.RefreshItemSlot() def Destroy(self): self.ClearDictionary() self.dlgPickMoney.Destroy() self.dlgPickMoney = 0 if app.ENABLE_CHEQUE_SYSTEM: self.dlgPickETC.Destroy() self.dlgPickETC = 0 self.attachMetinDialog.Destroy() self.attachMetinDialog = 0 self.tooltipItem = None self.wndItem = 0 self.dlgPickMoney = 0 self.questionDialog = None self.interface = None self.inventoryTab = [] self.inventoryPageIndex = 0 def Hide(self): if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS(): self.OnCloseQuestionDialog() return if None != self.tooltipItem: self.tooltipItem.HideToolTip() if self.dlgPickMoney: self.dlgPickMoney.Close() if app.ENABLE_CHEQUE_SYSTEM: if self.dlgPickETC: self.dlgPickETC.Close() wndMgr.Hide(self.hWnd) def Close(self): self.Hide() def SetInventoryPage(self, page): self.inventoryPageIndex = page for index in range(len(self.inventoryTab)): if index == page: continue self.inventoryTab[index].SetUp() self.RefreshBagSlotWindow() def SetInventoryType(self, type): self.inventoryType = int(type) if type == 0: self.SkillBookButton.Down() self.UpgradeItemsButton.SetUp() self.stoneButton.SetUp() self.GiftBoxButton.SetUp() self.titleName.SetText(localeInfo.SPECIAL_INVENTORY_SKILL_BOOK) elif type == 2: self.stoneButton.Down() self.GiftBoxButton.SetUp() self.UpgradeItemsButton.SetUp() self.SkillBookButton.SetUp() self.titleName.SetText(localeInfo.SPECIAL_INVENTORY_STONE) elif type == 3: self.GiftBoxButton.Down() self.stoneButton.SetUp() self.UpgradeItemsButton.SetUp() self.SkillBookButton.SetUp() self.titleName.SetText(localeInfo.SPECIAL_INVENTORY_CHEST) else: self.UpgradeItemsButton.Down() self.SkillBookButton.SetUp() self.stoneButton.SetUp() self.GiftBoxButton.SetUp() self.titleName.SetText(localeInfo.SPECIAL_INVENTORY_MATERIAL) self.RefreshBagSlotWindow() if app.ENABLE_SORT_INVENTORY: def SortInventoryButton(self): self.questionDialog = uiCommon.QuestionDialog() self.questionDialog.SetText(localeInfo.SPECIAL_INVENTORY_DO_YOU_SORT) self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnSortInventoryItems)) self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog)) self.questionDialog.Open() constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1) def OnSortInventoryItems(self): if None == self.questionDialog: return net.SendChatPacket("/sort_special_inventory %d" % self.inventoryType) snd.PlaySound("sound/ui/pickup_item_in_inventory.wav") self.OnCloseQuestionDialog() def OnPickItem(self, count): if app.ENABLE_CHEQUE_SYSTEM: itemSlotIndex = self.dlgPickETC.itemGlobalSlotIndex else: itemSlotIndex = self.dlgPickMoney.itemGlobalSlotIndex selectedItemVNum = player.GetItemIndex(itemSlotIndex) if self.inventoryType == 0: mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_SKILL_BOOK_INVENTORY, itemSlotIndex, selectedItemVNum, count) elif self.inventoryType == 1: mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY, itemSlotIndex, selectedItemVNum, count) elif self.inventoryType == 2: mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_STONE_INVENTORY, itemSlotIndex, selectedItemVNum, count) elif self.inventoryType == 3: mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_GIFT_BOX_INVENTORY, itemSlotIndex, selectedItemVNum, count) def __InventoryLocalSlotPosToGlobalSlotPos(self, local): if self.inventoryType == 0: return self.inventoryPageIndex * player.SPECIAL_INVENTORY_PAGE_SIZE + local + item.SKILL_BOOK_INVENTORY_SLOT_START elif self.inventoryType == 1: return self.inventoryPageIndex * player.SPECIAL_INVENTORY_PAGE_SIZE + local + item.UPGRADE_ITEMS_INVENTORY_SLOT_START elif self.inventoryType == 2: return self.inventoryPageIndex * player.SPECIAL_INVENTORY_PAGE_SIZE + local + item.STONE_INVENTORY_SLOT_START elif self.inventoryType == 3: return self.inventoryPageIndex * player.SPECIAL_INVENTORY_PAGE_SIZE + local + item.GIFT_BOX_INVENTORY_SLOT_START def RefreshBagSlotWindow(self): if not self.wndItem: return getItemVNum = player.GetItemIndex getItemCount = player.GetItemCount setItemVNum = self.wndItem.SetItemSlot for i in xrange(self.wndItem.GetSlotCount()): self.wndItem.DeactivateSlot(i) if app.WJ_ENABLE_TRADABLE_ICON: if self.interface: onTopWindow = self.interface.GetOnTopWindow() for i in xrange(player.SPECIAL_INVENTORY_PAGE_SIZE): slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i) itemCount = getItemCount(slotNumber) if 0 == itemCount: self.wndItem.ClearSlot(i) continue elif 1 == itemCount: itemCount = 0 itemVnum = getItemVNum(slotNumber) setItemVNum(i, itemVnum, itemCount) if app.WJ_ENABLE_TRADABLE_ICON: if itemVnum and self.interface and onTopWindow: if self.interface.MarkUnusableInvenSlotOnTopWnd(onTopWindow, slotNumber): self.wndItem.SetUnusableSlotOnTopWnd(i) else: self.wndItem.SetUsableSlotOnTopWnd(i) else: self.wndItem.SetUsableSlotOnTopWnd(i) if app.WJ_ENABLE_PICKUP_ITEM_EFFECT: self.__HighlightSlot_Refresh() self.wndItem.RefreshSlot() def RefreshItemSlot(self): self.RefreshBagSlotWindow() def SetItemToolTip(self, tooltipItem): self.tooltipItem = tooltipItem def SellItem(self): if self.sellingSlotitemIndex == player.GetItemIndex(self.sellingSlotNumber): if self.sellingSlotitemCount == player.GetItemCount(self.sellingSlotNumber): net.SendShopSellPacketNew(self.sellingSlotNumber, self.questionDialog.count, player.INVENTORY) snd.PlaySound("sound/ui/money.wav") self.OnCloseQuestionDialog() def OnDetachMetinFromItem(self): if None == self.questionDialog: return self.__SendUseItemToItemPacket(self.questionDialog.sourcePos, self.questionDialog.targetPos) self.OnCloseQuestionDialog() def OnCloseQuestionDialog(self): if not self.questionDialog: return self.questionDialog.Close() self.questionDialog = None constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(0) def SelectEmptySlot(self, selectedSlotPos): if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1: return selectedSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(selectedSlotPos) if mouseModule.mouseController.isAttached(): attachedSlotType = mouseModule.mouseController.GetAttachedType() attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() attachedItemCount = mouseModule.mouseController.GetAttachedItemCount() attachedItemIndex = mouseModule.mouseController.GetAttachedItemIndex() if player.SLOT_TYPE_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_SKILL_BOOK_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_STONE_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_GIFT_BOX_INVENTORY == attachedSlotType: itemCount = player.GetItemCount(attachedSlotPos) attachedCount = mouseModule.mouseController.GetAttachedItemCount() self.__SendMoveItemPacket(attachedSlotPos, selectedSlotPos, attachedCount) if item.IsRefineScroll(attachedItemIndex): self.interface.SetUseItemMode(False) elif player.SLOT_TYPE_PRIVATE_SHOP == attachedSlotType: mouseModule.mouseController.RunCallBack("INVENTORY") elif player.SLOT_TYPE_SHOP == attachedSlotType: net.SendShopBuyPacket(attachedSlotPos) elif player.SLOT_TYPE_SAFEBOX == attachedSlotType: if player.ITEM_MONEY == attachedItemIndex: net.SendSafeboxWithdrawMoneyPacket(mouseModule.mouseController.GetAttachedItemCount()) snd.PlaySound("sound/ui/money.wav") else: net.SendSafeboxCheckoutPacket(attachedSlotPos, selectedSlotPos) elif player.SLOT_TYPE_MALL == attachedSlotType: net.SendMallCheckoutPacket(attachedSlotPos, selectedSlotPos) mouseModule.mouseController.DeattachObject() def SelectItemSlot(self, itemSlotIndex): if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS() == 1: return itemSlotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(itemSlotIndex) if mouseModule.mouseController.isAttached(): attachedSlotType = mouseModule.mouseController.GetAttachedType() attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() attachedItemVID = mouseModule.mouseController.GetAttachedItemIndex() if player.SLOT_TYPE_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_SKILL_BOOK_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_STONE_INVENTORY == attachedSlotType or\ player.SLOT_TYPE_GIFT_BOX_INVENTORY == attachedSlotType: self.__DropSrcItemToDestItemInInventory(attachedItemVID, attachedSlotPos, itemSlotIndex) chat.AppendChat(chat.CHAT_TYPE_INFO, "Item is in slot %d" % itemSlotIndex) mouseModule.mouseController.DeattachObject() else: curCursorNum = app.GetCursor() if app.SELL == curCursorNum: self.__SellItem(itemSlotIndex) elif app.BUY == curCursorNum: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.SHOP_BUY_INFO) elif app.IsPressed(app.DIK_LALT): link = player.GetItemLink(itemSlotIndex) ime.PasteString(link) elif app.IsPressed(app.DIK_LSHIFT): itemCount = player.GetItemCount(itemSlotIndex) if itemCount > 1: if app.ENABLE_CHEQUE_SYSTEM: self.dlgPickETC.SetTitleName(localeInfo.PICK_ITEM_TITLE) self.dlgPickETC.SetAcceptEvent(ui.__mem_func__(self.OnPickItem)) self.dlgPickETC.Open(itemCount) self.dlgPickETC.itemGlobalSlotIndex = itemSlotIndex else: self.dlgPickMoney.SetTitleName(localeInfo.PICK_ITEM_TITLE) self.dlgPickMoney.SetAcceptEvent(ui.__mem_func__(self.OnPickItem)) self.dlgPickMoney.Open(itemCount) self.dlgPickMoney.itemGlobalSlotIndex = itemSlotIndex elif app.IsPressed(app.DIK_LCONTROL): itemIndex = player.GetItemIndex(itemSlotIndex) if True == item.CanAddToQuickSlotItem(itemIndex): player.RequestAddToEmptyLocalQuickSlot(player.SLOT_TYPE_INVENTORY, itemSlotIndex) else: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.QUICKSLOT_REGISTER_DISABLE_ITEM) else: selectedItemVNum = player.GetItemIndex(itemSlotIndex) itemCount = player.GetItemCount(itemSlotIndex) mouseModule.mouseController.AttachObject(self, player.SLOT_TYPE_INVENTORY, itemSlotIndex, selectedItemVNum, itemCount) if self.__IsUsableItemToItem(selectedItemVNum, itemSlotIndex): self.interface.SetUseItemMode(True) else: self.interface.SetUseItemMode(False) snd.PlaySound("sound/ui/pick.wav") def __DropSrcItemToDestItemInInventory(self, srcItemVID, srcItemSlotPos, dstItemSlotPos): if srcItemSlotPos == dstItemSlotPos: return ## 악세서리 창이 열려있으면 ## 아이템 이동 금지. if app.ENABLE_ACCE_COSTUME_SYSTEM: if player.GetAcceRefineWindowOpen() == 1: return if app.ENABLE_CHANGE_LOOK_SYSTEM: if player.GetChangeLookWindowOpen() == 1: return ## [MT-462] player.GetItemIndex(srcItemSlotPos) if player.GetItemIndex(srcItemSlotPos) == player.GetItemIndex(dstItemSlotPos) \ and (player.GetItemFlags(srcItemSlotPos) & item.ITEM_FLAG_STACKABLE) \ and player.IsEquipmentSlot(dstItemSlotPos) == False: self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0) return if app.ENABLE_SOUL_BIND_SYSTEM: # cyh itemseal 2013 11 08 if item.IsSealScroll(srcItemVID): if player.CanSealItem(srcItemVID, player.INVENTORY, dstItemSlotPos): self.__OpenQuestionDialog(srcItemSlotPos, dstItemSlotPos) if item.IsRefineScroll(srcItemVID): self.RefineItem(srcItemSlotPos, dstItemSlotPos) self.interface.SetUseItemMode(False) elif item.IsMetin(srcItemVID): self.AttachMetinToItem(srcItemSlotPos, dstItemSlotPos) elif item.IsDetachScroll(srcItemVID): self.DetachMetinFromItem(srcItemSlotPos, dstItemSlotPos) elif item.IsKey(srcItemVID): self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos) elif (player.GetItemFlags(srcItemSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE: self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos) elif item.GetUseType(srcItemVID) in self.USE_TYPE_TUPLE: self.__SendUseItemToItemPacket(srcItemSlotPos, dstItemSlotPos) else: self.__SendMoveItemPacket(srcItemSlotPos, dstItemSlotPos, 0) def __SellItem(self, itemSlotPos): self.sellingSlotNumber = itemSlotPos itemIndex = player.GetItemIndex(itemSlotPos) itemCount = player.GetItemCount(itemSlotPos) self.sellingSlotitemIndex = itemIndex self.sellingSlotitemCount = itemCount item.SelectItem(itemIndex) ## 안티 플레그 검사 빠져서 추가 ## 20140220 if item.IsAntiFlag(item.ANTIFLAG_SELL): popup = uiCommon.PopupDialog() popup.SetText(localeInfo.SHOP_CANNOT_SELL_ITEM) popup.SetAcceptEvent(self.__OnClosePopupDialog) popup.Open() self.popup = popup return itemPrice = item.GetISellItemPrice() if item.Is1GoldItem(): itemPrice = itemCount / itemPrice / 5 else: itemPrice = itemPrice * itemCount / 5 item.GetItemName(itemIndex) itemName = item.GetItemName() self.questionDialog = uiCommon.QuestionDialog() self.questionDialog.SetText(localeInfo.DO_YOU_SELL_ITEM(itemName, itemCount, itemPrice)) self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.SellItem)) self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog)) self.questionDialog.Open() self.questionDialog.count = itemCount constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1) def __OnClosePopupDialog(self): self.pop = None def DetachMetinFromItem(self, scrollSlotPos, targetSlotPos): scrollIndex = player.GetItemIndex(scrollSlotPos) targetIndex = player.GetItemIndex(targetSlotPos) if not player.CanDetach(scrollIndex, targetSlotPos): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_METIN_INSEPARABLE_ITEM) return self.questionDialog = uiCommon.QuestionDialog() self.questionDialog.SetText(localeInfo.REFINE_DO_YOU_SEPARATE_METIN) self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.OnDetachMetinFromItem)) self.questionDialog.SetCancelEvent(ui.__mem_func__(self.OnCloseQuestionDialog)) self.questionDialog.Open() self.questionDialog.sourcePos = scrollSlotPos self.questionDialog.targetPos = targetSlotPos def AttachMetinToItem(self, metinSlotPos, targetSlotPos): metinIndex = player.GetItemIndex(metinSlotPos) targetIndex = player.GetItemIndex(targetSlotPos) item.SelectItem(metinIndex) itemName = item.GetItemName() result = player.CanAttachMetin(metinIndex, targetSlotPos) if player.ATTACH_METIN_NOT_MATCHABLE_ITEM == result: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_CAN_NOT_ATTACH % (itemName)) if player.ATTACH_METIN_NO_MATCHABLE_SOCKET == result: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_SOCKET(itemName)) elif player.ATTACH_METIN_NOT_EXIST_GOLD_SOCKET == result: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_NO_GOLD_SOCKET(itemName)) elif player.ATTACH_METIN_CANT_ATTACH_TO_EQUIPMENT == result: chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.REFINE_FAILURE_EQUIP_ITEM) if player.ATTACH_METIN_OK != result: return self.attachMetinDialog.Open(metinSlotPos, targetSlotPos) def OverOutItem(self): self.wndItem.SetUsableItem(False) if None != self.tooltipItem: self.tooltipItem.HideToolTip() def OverInItem(self, overSlotPos): if app.WJ_ENABLE_PICKUP_ITEM_EFFECT: overInvenSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos) self.wndItem.SetUsableItem(False) getItemVNum = player.GetItemIndex itemVnum = getItemVNum(overInvenSlotPos) self.DelHighlightSlot(overInvenSlotPos) if mouseModule.mouseController.isAttached(): attachedItemType = mouseModule.mouseController.GetAttachedType() if player.SLOT_TYPE_INVENTORY == attachedItemType or\ player.SLOT_TYPE_SKILL_BOOK_INVENTORY == attachedItemType or\ player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY == attachedItemType or\ player.SLOT_TYPE_STONE_INVENTORY == attachedItemType or\ player.SLOT_TYPE_GIFT_BOX_INVENTORY == attachedItemType: attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex() if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overInvenSlotPos): self.wndItem.SetUsableItem(True) self.ShowToolTip(overInvenSlotPos) return self.ShowToolTip(overInvenSlotPos) else: overSlotPos = self.__InventoryLocalSlotPosToGlobalSlotPos(overSlotPos) self.wndItem.SetUsableItem(False) if mouseModule.mouseController.isAttached(): attachedItemType = mouseModule.mouseController.GetAttachedType() if player.SLOT_TYPE_INVENTORY == attachedItemType or\ player.SLOT_TYPE_SKILL_BOOK_INVENTORY == attachedItemType or\ player.SLOT_TYPE_UPGRADE_ITEMS_INVENTORY == attachedItemType or\ player.SLOT_TYPE_STONE_INVENTORY == attachedItemType or\ player.SLOT_TYPE_GIFT_BOX_INVENTORY == attachedItemType: attachedSlotPos = mouseModule.mouseController.GetAttachedSlotNumber() attachedItemVNum = mouseModule.mouseController.GetAttachedItemIndex() if self.__CanUseSrcItemToDstItem(attachedItemVNum, attachedSlotPos, overSlotPos): self.wndItem.SetUsableItem(True) self.ShowToolTip(overSlotPos) return self.ShowToolTip(overSlotPos) def __IsUsableItemToItem(self, srcItemVNum, srcSlotPos): if item.IsRefineScroll(srcItemVNum): return True elif item.IsMetin(srcItemVNum): return True elif item.IsDetachScroll(srcItemVNum): return True elif item.IsKey(srcItemVNum): return True elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE: return True else: if item.GetUseType(srcItemVNum) in self.USE_TYPE_TUPLE: return True return False def __CanUseSrcItemToDstItem(self, srcItemVNum, srcSlotPos, dstSlotPos): if srcSlotPos == dstSlotPos: return False if item.IsRefineScroll(srcItemVNum): if player.REFINE_OK == player.CanRefine(srcItemVNum, dstSlotPos): return True elif item.IsMetin(srcItemVNum): if player.ATTACH_METIN_OK == player.CanAttachMetin(srcItemVNum, dstSlotPos): return True elif item.IsDetachScroll(srcItemVNum): if player.DETACH_METIN_OK == player.CanDetach(srcItemVNum, dstSlotPos): return True elif item.IsKey(srcItemVNum): if player.CanUnlock(srcItemVNum, dstSlotPos): return True elif (player.GetItemFlags(srcSlotPos) & ITEM_FLAG_APPLICABLE) == ITEM_FLAG_APPLICABLE: return True else: useType=item.GetUseType(srcItemVNum) if "USE_CLEAN_SOCKET" == useType: if self.__CanCleanBrokenMetinStone(dstSlotPos): return True elif "USE_CHANGE_ATTRIBUTE" == useType: if self.__CanChangeItemAttrList(dstSlotPos): return True elif "USE_ADD_ATTRIBUTE" == useType: if self.__CanAddItemAttr(dstSlotPos): return True elif "USE_ADD_ATTRIBUTE2" == useType: if self.__CanAddItemAttr(dstSlotPos): return True elif "USE_ADD_ACCESSORY_SOCKET" == useType: if self.__CanAddAccessorySocket(dstSlotPos): return True elif "USE_PUT_INTO_ACCESSORY_SOCKET" == useType: if self.__CanPutAccessorySocket(dstSlotPos, srcItemVNum): return True; elif "USE_PUT_INTO_BELT_SOCKET" == useType: dstItemVNum = player.GetItemIndex(dstSlotPos) item.SelectItem(dstItemVNum) if item.ITEM_TYPE_BELT == item.GetItemType(): return True elif "USE_CHANGE_COSTUME_ATTR" == useType: if self.__CanChangeCostumeAttrList(dstSlotPos): return True elif "USE_RESET_COSTUME_ATTR" == useType: if self.__CanResetCostumeAttr(dstSlotPos): return True else: pass return False def ShowToolTip(self, slotIndex): if None != self.tooltipItem: self.tooltipItem.SetInventoryItem(slotIndex) def OnTop(self): if None != self.tooltipItem: self.tooltipItem.SetTop() def OnPressEscapeKey(self): self.Close() return True def UseItemSlot(self, slotIndex): curCursorNum = app.GetCursor() if app.SELL == curCursorNum: return if constInfo.GET_ITEM_QUESTION_DIALOG_STATUS(): return slotIndex = self.__InventoryLocalSlotPosToGlobalSlotPos(slotIndex) self.__UseItem(slotIndex) mouseModule.mouseController.DeattachObject() self.OverOutItem() def __UseItem(self, slotIndex): ItemVNum = player.GetItemIndex(slotIndex) item.SelectItem(ItemVNum) if app.WJ_ENABLE_TRADABLE_ICON: if self.interface.AttachInvenItemToOtherWindowSlot(slotIndex): return if item.IsFlag(item.ITEM_FLAG_CONFIRM_WHEN_USE): self.questionDialog = uiCommon.QuestionDialog() self.questionDialog.SetText(localeInfo.INVENTORY_REALLY_USE_ITEM2) self.questionDialog.SetAcceptEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnAccept)) self.questionDialog.SetCancelEvent(ui.__mem_func__(self.__UseItemQuestionDialog_OnCancel)) self.questionDialog.Open() self.questionDialog.slotIndex = slotIndex constInfo.SET_ITEM_QUESTION_DIALOG_STATUS(1) else: self.__SendUseItemPacket(slotIndex) def __UseItemQuestionDialog_OnCancel(self): self.OnCloseQuestionDialog() def __UseItemQuestionDialog_OnAccept(self): self.__SendUseItemPacket(self.questionDialog.slotIndex) self.OnCloseQuestionDialog() def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos): if uiPrivateShopBuilder.IsBuildingPrivateShop(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP) return if self.interface.IsShowDlgQuestionWindow(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DONT_USE_ITEM_WHEN_SHOW_CONFIRM) return net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos) def __SendUseItemPacket(self, slotPos): if uiPrivateShopBuilder.IsBuildingPrivateShop(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.USE_ITEM_FAILURE_PRIVATE_SHOP) return if self.interface.IsShowDlgQuestionWindow(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DONT_USE_ITEM_WHEN_SHOW_CONFIRM) return net.SendItemUsePacket(slotPos) def __SendMoveItemPacket(self, srcSlotPos, dstSlotPos, srcItemCount): if uiPrivateShopBuilder.IsBuildingPrivateShop(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.MOVE_ITEM_FAILURE_PRIVATE_SHOP) return if self.interface.IsShowDlgQuestionWindow(): chat.AppendChat(chat.CHAT_TYPE_INFO, localeInfo.DONT_USE_ITEM_WHEN_SHOW_CONFIRM) return net.SendItemMovePacket(srcSlotPos, dstSlotPos, srcItemCount) if app.WJ_ENABLE_PICKUP_ITEM_EFFECT: def HighlightSlot(self, slot): if not slot in self.listHighlightedSlot: self.listHighlightedSlot.append(slot) def DelHighlightSlot(self, inventorylocalslot): if inventorylocalslot in self.listHighlightedSlot: if inventorylocalslot >= player.SPECIAL_INVENTORY_PAGE_SIZE: self.wndItem.DeactivateSlot(inventorylocalslot - (self.inventoryPageIndex * player.SPECIAL_INVENTORY_PAGE_SIZE)) else: self.wndItem.DeactivateSlot(inventorylocalslot) self.listHighlightedSlot.remove(inventorylocalslot) self.RefreshBagSlotWindow() # hot fix def __HighlightSlot_Refresh(self): for i in xrange(self.wndItem.GetSlotCount()): slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i) if slotNumber in self.listHighlightedSlot: self.wndItem.ActivateSlot(i) def __HighlightSlot_Clear(self): for i in xrange(self.wndItem.GetSlotCount()): slotNumber = self.__InventoryLocalSlotPosToGlobalSlotPos(i) if slotNumber in self.listHighlightedSlot: self.wndItem.DeactivateSlot(i) self.listHighlightedSlot.remove(slotNumber) def IsDlgQuestionShow(self): if self.dlgQuestion.IsShow(): return True else: return False def SetUseItemMode(self, bUse): self.wndItem.SetUseMode(bUse) def CancelDlgQuestion(self): self.__Cancel() def GetInventoryPageIndex(self): return self.inventoryPageIndex def GetInventoryType(self): return self.inventoryType