View difference between Paste ID: s2FC8iib and 7LU99sL2
SHOW: | | - or go back to the newest paste.
1
local backpackStore = CreateBackpackStoreWindow("backpackStore", "UIParent")
2
backpackStore:Show(false)
3
backpackStore:AddAnchor("CENTER", "UIParent", 0, 0)
4
local function ShowBackpackStoreWindow(show)
5
  if not show then
6
    backpackStore:Show(false)
7
    return
8
  end
9
  local info = X2Equipment:GetBackPackGoodsInfo("player")
10
  if info == nil then
11
    AddMessageToSysMsgWindow(locale.store_backpack.noGoods)
12
    backpackStore:Show(false)
13
    return
14
  end
15
  local slotIdx = ES_BACKPACK
16
  local tooltip = X2Equipment:GetEquippedItemTooltipText("player", slotIdx)
17
  if tooltip == nil then
18
    return
19
  end
20
  backpackStore.itemIcon:SetItemInfo(tooltip)
21
  local str = string.format([[
22
23
|m%d;]], tonumber(tooltip.refund))
24
  backpackStore.itemPrice:SetText(str)
25
  backpackStore.itemPrice:SetHeight(backpackStore.itemPrice:GetTextHeight())
26-
  backpackStore:Show(show)
26+
27
  backpackStore:Show(false)
28
end
29
ADDON:RegisterContentTriggerFunc(UIC_TRADER, ShowBackpackStoreWindow)
30
local function LeftButtonLeftClickFunc()
31
  X2Store:SellBackPackGoods()
32
  backpackStore:Show(false)
33
end
34
backpackStore.leftButton:SetHandler("OnClick", LeftButtonLeftClickFunc)
35
backpackStore.rightButton:SetHandler("OnClick", function()
36
  backpackStore:Show(false)
37
end)
38
local events = {
39
  NPC_INTERACTION_END = function()
40
    backpackStore:Show(false)
41
  end,
42
  UNIT_EQUIPMENT_CHANGED = function(equipSlot)
43
    if backpackStore:IsVisible() == false then
44
      return
45
    end
46
    if equipSlot == ES_BACKPACK then
47
      backpackStore:Show(false)
48
    end
49
  end
50
}
51
backpackStore:SetHandler("OnEvent", function(this, event, ...)
52
  events[event](...)
53
end)
54
backpackStore:RegisterEvent("NPC_INTERACTION_END")
55
backpackStore:RegisterEvent("UNIT_EQUIPMENT_CHANGED")