ESO Lua File v100011

ingame/zo_loot/gamepad/lootcommon_gamepad.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
ZO_GAMEPAD_LOOT_PANEL_LEFT = ZO_GAMEPAD_QUADRANT_3_RIGHT - ZO_GAMEPAD_DEFAULT_PANEL_WIDTH
local STOLEN_ICON_TEXTURE = "EsoUI/Art/Inventory/inventory_stolenItem_icon.dds"
ZO_Loot_Gamepad_Base = ZO_Object:Subclass()
function ZO_Loot_Gamepad_Base:InitializeKeybindStripDescriptorsMixin(areEthereal)
    local lootBackupKeybind = KEYBIND_STRIP:GenerateGamepadBackButtonDescriptor(
            function() 
                EndLooting()
            end)
    lootBackupKeybind.order = 3
    lootBackupKeybind.ethereal = areEthereal
    self.keybindStripDescriptor = {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        { -- Exit Button
            name = GetString(SI_EXIT_BUTTON),
            keybind = "UI_SHORTCUT_EXIT",
            callback =  function()
                EndLooting()
            end,
            ethereal = areEthereal
        },
        { -- Take Selected
            name = GetString(SI_LOOT_TAKE),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                self:LootSelected()
            end,
            ethereal = areEthereal
        },
        { -- Take All
            name = GetString(SI_LOOT_TAKE_ALL),
            keybind = "UI_SHORTCUT_SECONDARY",
            callback =  function()
                LOOT_SHARED:LootAllItems()
            end,
            ethereal = areEthereal
        },
        lootBackupKeybind
    }
end
function ZO_Loot_Gamepad_Base:OnSelectionChanged(list, selectedData, oldSelectedData)
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    if selectedData then
        if selectedData.money then 
            self:HideTooltip()
        else
            self:ShowTooltip(selectedData)
        end
        self:UpdateButtonTextOnSelection(selectedData)
    end
end
function ZO_Loot_Gamepad_Base:HideTooltip()
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
    GAMEPAD_TOOLTIPS:HideBg(GAMEPAD_RIGHT_TOOLTIP)
end
function ZO_Loot_Gamepad_Base:ShowTooltip(selectedData)
    GAMEPAD_TOOLTIPS:ClearTooltip(GAMEPAD_RIGHT_TOOLTIP)
    GAMEPAD_TOOLTIPS:Reset(GAMEPAD_RIGHT_TOOLTIP)
    GAMEPAD_TOOLTIPS:SetBottomRailHidden(GAMEPAD_RIGHT_TOOLTIP, true)
    if selectedData.isQuest then
        GAMEPAD_TOOLTIPS:LayoutQuestItem(GAMEPAD_RIGHT_TOOLTIP, selectedData)
    else
        local itemLink = GetLootItemLink(selectedData.lootId)
        local NOT_EQUIPPED = false
        local FORCE_FULL_DURABILITY = true
        GAMEPAD_TOOLTIPS:LayoutItem(GAMEPAD_RIGHT_TOOLTIP, itemLink, NOT_EQUIPPED, nil, FORCE_FULL_DURABILITY)
    end
    GAMEPAD_TOOLTIPS:ShowBg(GAMEPAD_RIGHT_TOOLTIP)
end
function ZO_Loot_Gamepad_Base:LootSelected()
    local item = self.itemList:GetSelectedData()
    if item then
        if item.money then
            LootMoney()
        else
            LootItemById(item.lootId)
        end
    end
end
function ZO_Loot_Gamepad_Base:Show()
    assert(false) -- must override
end
function ZO_Loot_Gamepad_Base:HasLootItems()
    local unownedMoney, ownedMoney = GetLootMoney()
    return unownedMoney > 0 or ownedMoney > 0 or GetNumLootItems() > 0
end
function ZO_Loot_Gamepad_Base:UpdateList()
    self.itemList:Clear()
    self.itemCount = 0
    local STOLEN = true
    -- Assume there are no non-stolen items present until proven otherwise.
    self.nonStolenItemsPresent = false
    -- Add unowned gold and items
    local unownedMoney, ownedMoney = GetLootMoney()
    if unownedMoney > 0 then
        local moneyEntry = ZO_GamepadEntryData:New(GetString(SI_CURRENCY_GOLD), LOOT_MONEY_ICON)
        moneyEntry.money = unownedMoney
        moneyEntry:InitializeLootVisualData(lootId, unownedMoney, nil, nil, nil, not STOLEN)
        self.itemList:AddEntry("ZO_GamepadItemSubEntryTemplate", moneyEntry)
        self.itemCount = self.itemCount + 1
        self.nonStolenItemsPresent = true
    end
    local numLootItems = GetNumLootItems()
    self:UpdateListAddLootItems(numLootItems, not STOLEN)
    -- Add owned gold and items
    if ownedMoney > 0 then
        local moneyEntry = ZO_GamepadEntryData:New(GetString(SI_CURRENCY_GOLD), LOOT_MONEY_ICON)
        moneyEntry.money = ownedMoney
        moneyEntry:InitializeLootVisualData(lootId, ownedMoney, nil, nil, nil, STOLEN)
        moneyEntry:AddIcon(STOLEN_ICON_TEXTURE)
        self.itemList:AddEntry("ZO_GamepadItemSubEntryTemplate", moneyEntry)
        self.itemCount = self.itemCount + 1
    end
    self:UpdateListAddLootItems(numLootItems, STOLEN)
    self.itemCount = self.itemCount + numLootItems
    if self.intialLootUpdate then
        self.itemList:CommitWithoutReselect()
    else
        self.itemList:Commit()
    end
    
    -- this text deponds on the list itself
end
function ZO_Loot_Gamepad_Base:UpdateListAddLootItems(numLootItems, addStolenItems)
    for i = 1, numLootItems do
        local lootId, name, icon, count, quality, value, isQuest, isStolen = GetLootItemInfo(i)
            
        -- only add stolen items or non stolen items
        if addStolenItems == isStolen then
            name = zo_strformat(SI_TOOLTIP_ITEM_NAME, name)
            local lootEntry = ZO_GamepadEntryData:New(name, icon)
            lootEntry:InitializeLootVisualData(lootId, count, quality, value, isQuest, isStolen)
            if isStolen then
                lootEntry:AddIcon(STOLEN_ICON_TEXTURE)
            end
            self.itemList:AddEntry("ZO_GamepadItemSubEntryTemplate", lootEntry)
            if not isStolen then
                self.nonStolenItemsPresent = true
            end
        end
    end
end
function ZO_Loot_Gamepad_Base:UpdateLootWindow(name, actionName, isOwned)
    if not self.isInitialized then
        self:DeferredInitialize()
    end
    self:SetTitle(name)
    self.intialLootUpdate = self.control:IsControlHidden()
    self:Update(isOwned)
    if self.intialLootUpdate then
        self:Show()
    elseif not self:HasLootItems() then
        self:Hide()
    end
end
-- Overridden in LootPickup
function ZO_Loot_Gamepad_Base:UpdateButtonTextOnSelection(selectedData)
end
function ZO_Loot_Gamepad_Base:UpdateAllControlText()
end
--------------------------
-- ZO_Loot_Common_Gamepad
--------------------------
local ZO_Loot_Common_Gamepad = ZO_Object:Subclass()
function ZO_Loot_Common_Gamepad:UpdateLootWindow(name, actionName, isOwned)
    if not SCENE_MANAGER:IsSceneOnStack("gamepad_inventory_root") then
        LOOT_WINDOW_GAMEPAD:UpdateLootWindow(name, actionName, isOwned)
    else
        LOOT_INVENTORY_WINDOW_GAMEPAD:UpdateLootWindow(name, actionName, isOwned)
    end
end
function ZO_Loot_Common_Gamepad:Hide()
    LOOT_WINDOW_GAMEPAD:Hide()
    LOOT_INVENTORY_WINDOW_GAMEPAD:Hide()
end
function ZO_Loot_Common_Gamepad:AreNonStolenItemsPresent()
    return (LOOT_WINDOW_GAMEPAD.nonStolenItemsPresent == true)
end
--[[ Globals ]]--
LOOT_COMMON_GAMEPAD = ZO_Loot_Common_Gamepad:New()
SYSTEMS:RegisterGamepadObject("loot", LOOT_COMMON_GAMEPAD)