Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ui
- import net
- import localeInfo
- import player
- import item
- import constInfo
- import uiSpecialStorage
- class QuickSell(ui.Window):
- QUICK_SELL_WIDTH = 133
- def __init__(self):
- ui.Window.__init__(self)
- self.cancelButton = None
- self.sellPrice = None
- self.sellItemSelectedCount = None
- self.sellPriceBG = None
- self.sellItemSelectedCountBG = None
- self.sellButton = None
- self.SetSize(133, 37)
- self.SetCenterPosition()
- self.AddFlag("float")
- self.Hide()
- self.BoardInterface()
- self.wndSpecialStorage = uiSpecialStorage.SpecialStorageWindow()
- def __del__(self):
- ui.Window.__del__(self)
- def Destroy(self):
- self.Hide()
- self.ResetWindow()
- player.RefreshInventory()
- def Close(self):
- self.Hide()
- self.ResetWindow()
- player.RefreshInventory()
- def Open(self):
- self.SetTop()
- self.Show()
- def ResetWindow(self):
- constInfo.QUICK_SELL_ITEMS = []
- constInfo.QUICK_SELL_ITEMS_STONE = []
- self.UpdatePrice()
- def __InventoryLocalSlotPosToGlobalSlotPos(self, slotIndex):
- return self.wndSpecialStorage.inventoryPageIndex * player.SPECIAL_PAGE_SIZE + slotIndex
- def AppendSellSlot(self, slotIndex):
- if slotIndex in constInfo.QUICK_SELL_ITEMS:
- return
- if slotIndex in constInfo.QUICK_SELL_ITEMS_STONE:
- return
- if player.IsEquipmentSlot(slotIndex):
- return
- if player.GetItemIndex(player.INVENTORY, slotIndex) != 0:
- itemVnum = player.GetItemIndex(player.INVENTORY, slotIndex)
- inventory_type = player.INVENTORY
- slot_list = constInfo.QUICK_SELL_ITEMS
- elif player.GetItemIndex(player.STONE_INVENTORY, slotIndex) != 0:
- itemVnum = player.GetItemIndex(player.STONE_INVENTORY, slotIndex)
- inventory_type = player.STONE_INVENTORY
- slot_list = constInfo.QUICK_SELL_ITEMS_STONE
- # Normal Inventory
- # itemVnum = player.GetItemIndex(player.INVENTORY, slotIndex)
- # Special Inventory
- # itemVnum = player.GetItemIndex(player.STONE_INVENTORY, slotIndex)
- if itemVnum == 0:
- return
- item.SelectItem(itemVnum)
- if item.IsAntiFlag(item.ITEM_ANTIFLAG_SELL):
- return
- if not self.IsShow():
- self.Open()
- slot_list.append(slotIndex)
- def RemoveSellSlot(self, slotIndex):
- if slotIndex in constInfo.QUICK_SELL_ITEMS:
- constInfo.QUICK_SELL_ITEMS.remove(slotIndex)
- if len(constInfo.QUICK_SELL_ITEMS) == 0:
- self.Close()
- elif slotIndex in constInfo.QUICK_SELL_ITEMS_STONE:
- constInfo.QUICK_SELL_ITEMS_STONE.remove(slotIndex)
- if len(constInfo.QUICK_SELL_ITEMS_STONE) == 0:
- self.Close()
- def BoardInterface(self):
- self.Board = ui.MakeImageBox(self, "d:/ymir work/ui/game/quick_sell/quick_sell_base_board.tga", 0, 0)
- self.sellButton = ui.MakeButton(self, self.QUICK_SELL_WIDTH / 2 - 52, 100 - 81, "", "d:/ymir work/ui/game/quick_sell/", "accept_1.tga", "accept_2.tga", "accept_3.tga")
- self.sellButton.SetEvent(self.__OnClickSellButton)
- self.cancelButton = ui.MakeButton(self, self.QUICK_SELL_WIDTH / 2 + 27, 100 - 81, "","d:/ymir work/ui/game/quick_sell/", "cancel_1.tga","cancel_2.tga", "cancel_3.tga")
- self.cancelButton.SetEvent(self.Close)
- self.sellPrice = ui.MakeTextLineNew(self, 0, 2, "")
- self.sellPrice.SetWindowHorizontalAlignCenter()
- self.sellPrice.SetHorizontalAlignCenter()
- def AdjustPosition(self, x, y):
- self.SetPosition(x, y)
- def UpdatePrice(self):
- price = 0
- selected_count = 0
- # Normal Inventory
- for itemSlotIndex in constInfo.QUICK_SELL_ITEMS:
- itemIndex = player.GetItemIndex(player.INVENTORY, itemSlotIndex)
- if itemIndex == 0:
- continue
- item.SelectItem(itemIndex)
- itemPrice = item.GetISellItemPrice()
- itemCount = player.GetItemCount(player.INVENTORY, itemSlotIndex)
- if item.Is1GoldItem():
- itemPrice = itemCount / itemPrice
- else:
- itemPrice = itemPrice * max(1, itemCount)
- price += itemPrice
- selected_count += 1
- # Special Inventory
- for itemSlotIndex in constInfo.QUICK_SELL_ITEMS_STONE:
- itemIndex = player.GetItemIndex(player.STONE_INVENTORY, itemSlotIndex)
- if itemIndex == 0:
- continue
- item.SelectItem(itemIndex)
- itemPrice = item.GetISellItemPrice()
- itemCount = player.GetItemCount(player.STONE_INVENTORY, itemSlotIndex)
- if item.Is1GoldItem():
- itemPrice = itemCount / itemPrice
- else:
- itemPrice = itemPrice * max(1, itemCount)
- price += itemPrice
- selected_count += 1
- self.sellPrice.SetText("|Eemoji/key_selected_sell|e " + "%d " % selected_count + "|Eemoji/key_money_icon|e "+localeInfo.NumberToDecimalStringQuickSell(price))
- self.sellPrice.SetHorizontalAlignCenter()
- def __OnClickSellButton(self):
- # Normal Inventory
- for itemSlotIndex in constInfo.QUICK_SELL_ITEMS:
- self.sellingSlotNumber = itemSlotIndex
- itemIndex = player.GetItemIndex(player.INVENTORY, itemSlotIndex)
- itemCount = player.GetItemCount(player.INVENTORY, itemSlotIndex)
- self.sellingSlotitemIndex = itemIndex
- self.sellingSlotitemCount = itemCount
- net.SendShopSellPacketNew(self.sellingSlotNumber, self.sellingSlotitemCount, player.INVENTORY)
- # Special Inventory
- for itemSlotIndex in constInfo.QUICK_SELL_ITEMS_STONE:
- self.sellingSlotNumber = itemSlotIndex
- itemIndex = player.GetItemIndex(player.STONE_INVENTORY, itemSlotIndex)
- itemCount = player.GetItemCount(player.STONE_INVENTORY, itemSlotIndex)
- self.sellingSlotitemIndex = itemIndex
- self.sellingSlotitemCount = itemCount
- net.SendShopSellPacketNew(self.sellingSlotNumber, self.sellingSlotitemCount, player.STONE_INVENTORY)
- constInfo.QUICK_SELL_ITEMS = []
- constInfo.QUICK_SELL_ITEMS_STONE = []
- self.Close()
- player.RefreshInventory()
- def OnPressEscapeKey(self):
- self.Close()
- player.RefreshInventory()
- return True
- def OnPressExitKey(self):
- self.Close()
- player.RefreshInventory()
- return True
Add Comment
Please, Sign In to add comment