Back to Home

ESO Lua File v101042

ingame/housingeditor/gamepad/housingfurniturebrowser_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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
ZO_HousingFurnitureBrowser_Gamepad = ZO_Object.MultiSubclass(ZO_HousingFurnitureBrowser_Base, ZO_Gamepad_ParametricList_Screen)
function ZO_HousingFurnitureBrowser_Gamepad:New(...)
    return ZO_HousingFurnitureBrowser_Base.New(self, ...)
end
function ZO_HousingFurnitureBrowser_Gamepad:Initialize(control)
    GAMEPAD_HOUSING_FURNITURE_BROWSER_SCENE = ZO_Scene:New("gamepad_housing_furniture_scene", SCENE_MANAGER)
    ZO_HousingFurnitureBrowser_Base.Initialize(self, control, "gamepad_housing_furniture_scene")
    local ACTIVATE_ON_SHOW = true
    ZO_Gamepad_ParametricList_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_CREATE, ACTIVATE_ON_SHOW, GAMEPAD_HOUSING_FURNITURE_BROWSER_SCENE)
    SYSTEMS:RegisterGamepadRootScene("housing_furniture_browser", GAMEPAD_HOUSING_FURNITURE_BROWSER_SCENE)
    self.occupantControl = control:GetNamedChild("Occupants")
    self.visitorPermissionsControl = control:GetNamedChild("Visitors")
    self.banListPermissionsControl = control:GetNamedChild("BanList")
    self.guildVisitorPermissionsControl = control:GetNamedChild("GuildVisitors")
    self.guildBanListPermissionsControl = control:GetNamedChild("GuildBanList")
    self.OnRefreshActions = function()
        SCREEN_NARRATION_MANAGER:QueueParametricListEntry(self:GetCurrentList())
    end
    self.nextListId = 0
    self.placementPanel = ZO_HousingFurniturePlacement_Gamepad:New(self)
    self.productsPanel = ZO_HousingFurnitureProducts_Gamepad:New(self)
    self.retrievalPanel = ZO_HousingFurnitureRetrieval_Gamepad:New(self)
    self.settingsPanel = ZO_HousingFurnitureSettings_Gamepad:New(self)
    self.currentPanel = self.placementPanel
    
end
function ZO_HousingFurnitureBrowser_Gamepad:PerformUpdate()
    --Do nothing. We manager the update state in a more nuanced way.
end
--Overridden
function ZO_HousingFurnitureBrowser_Gamepad:OnEnterHeader()
    -- override function for implementation specific functionality
    -- Swap keybinds to text search keybinds if there is a text search
    if self.textSearchHeaderFocus and self.mode ~= HOUSING_BROWSER_MODE.SETTINGS then
        if self.currentPanel.currentList and self.currentPanel.currentList.keybinds then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.currentPanel.currentList.keybinds)
        end
        if self.textSearchKeybindStripDescriptor then
            KEYBIND_STRIP:AddKeybindButtonGroup(self.textSearchKeybindStripDescriptor)
        end
    end
end
--Overridden
function ZO_HousingFurnitureBrowser_Gamepad:OnLeaveHeader()
    -- override function for implementation specific functionality
    -- Swap keybinds from text search keybinds if there is a text search
    if self.textSearchHeaderFocus and mode ~= HOUSING_BROWSER_MODE.SETTINGS then
        self:SetTextSearchFocused(false)
        if self.textSearchKeybindStripDescriptor then
            KEYBIND_STRIP:RemoveKeybindButtonGroup(self.textSearchKeybindStripDescriptor)
        end
        if self.currentPanel.currentList and self.currentPanel.currentList.keybinds and self:IsShowing() then
            KEYBIND_STRIP:AddKeybindButtonGroup(self.currentPanel.currentList.keybinds)
        end
    end
end
function ZO_HousingFurnitureBrowser_Gamepad:UpdatePlaceablePanel()
    self.placementPanel:UpdateLists()
end
--Overridden
function ZO_HousingFurnitureBrowser_Gamepad:UpdateRetrievablePanel()
    self.retrievalPanel:UpdateLists()
end
--Overridden
function ZO_HousingFurnitureBrowser_Gamepad:UpdateRetrievablePanelDistancesAndHeadings()
    self.retrievalPanel:UpdateLists()
end
--Overridden
function ZO_HousingFurnitureBrowser_Gamepad:UpdateRetrievablePanelHeadings()
    --Gamepad doesn't show headings so do nothing
end
--Overridden
function ZO_HousingFurnitureBrowser_Gamepad:UpdateProductsPanel()
    self.productsPanel:UpdateLists()
end
--Overridden
function  ZO_HousingFurnitureBrowser_Gamepad:GetFooterNarration()
    if HOUSE_INFORMATION_FRAGMENT_GAMEPAD:IsShowing() then
        return HOUSE_INFORMATION_GAMEPAD:GetNarrationText()
    end
end
function ZO_HousingFurnitureBrowser_Gamepad:InitializeHeader()
    local tabBarEntries =
    {
        {
            text = function() 
                if self.titleText then
                    return self.titleText
                else
                    return GetString(SI_HOUSING_FURNITURE_TAB_PLACE)
                end
            end,
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.PLACEMENT)
            end,
            visible = function()
                return HOUSING_EDITOR_STATE:IsLocalPlayerHouseOwner()
            end,
        },
        {
            text = GetString(SI_HOUSING_FURNITURE_TAB_PURCHASE),
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.PRODUCTS)
            end,
            visible = function()
                return HOUSING_EDITOR_STATE:IsLocalPlayerHouseOwner()
            end,
        },
        {
            text = function()
                if HOUSING_EDITOR_STATE:IsLocalPlayerHouseOwner() then
                    return GetString(SI_HOUSING_FURNITURE_TAB_RETRIEVAL)
                else
                    return GetString(SI_HOUSING_FURNITURE_TAB_FURNITURE_LIST)
                end
            end,
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.RETRIEVAL)
            end,
            visible = function()
                return HOUSING_EDITOR_STATE:CanLocalPlayerBrowseFurniture()
            end,
        },
        {
            text = GetString(SI_HOUSING_FURNITURE_TAB_SETTINGS),
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.SETTINGS)
            end,
            visible = function()
                return HOUSING_EDITOR_STATE:CanLocalPlayerViewSettings()
            end,
        },
    }
    self.headerData =
    {
        tabBarEntries = tabBarEntries,
    }
    ZO_GamepadGenericHeader_Initialize(self.header, ZO_GAMEPAD_HEADER_TABBAR_CREATE)
    self.textSearchKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Select
        {
            keybind = "UI_SHORTCUT_PRIMARY",
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            visible = function()
                return not ZO_CraftingUtils_IsPerformingCraftProcess()
            end,
            callback = function()
                self:SetTextSearchFocused(true)
            end,
        },
    }
    local function OnTextChanged(editBox)
        local text = editBox:GetText()
        if self.mode == HOUSING_BROWSER_MODE.PLACEMENT then
            SHARED_FURNITURE:SetPlaceableTextFilter(text)
        elseif self.mode == HOUSING_BROWSER_MODE.RETRIEVAL then
            SHARED_FURNITURE:SetRetrievableTextFilter(text)
        elseif self.mode == HOUSING_BROWSER_MODE.PRODUCTS then
            SHARED_FURNITURE:SetMarketProductTextFilter(text)
        end
    end
    -- Order matters
    self:AddSearch(self.textSearchKeybindStripDescriptor, OnTextChanged)
    self.headerTextFilterControl = self.textSearchHeaderControl:GetNamedChild("Filter")
    self.headerTextFilterEditBox = self.headerTextFilterControl:GetNamedChild("SearchEdit")
end
function ZO_HousingFurnitureBrowser_Gamepad:RequestNewList()
    local newList
    if self.nextListId == 0 then
        newList = self:GetMainList()
    else
        newList = self:AddList("SubList" .. self.nextListId)
    end
    self.nextListId = self.nextListId + 1
    return newList
end
function ZO_HousingFurnitureBrowser_Gamepad:IsShowing()
    return GAMEPAD_HOUSING_FURNITURE_BROWSER_SCENE:IsShowing()
end
function ZO_HousingFurnitureBrowser_Gamepad:OnShowing()
    ZO_Gamepad_ParametricList_Screen.OnShowing(self)
    ZO_HousingFurnitureBrowser_Base.OnShowing(self)
    --Enter browsing mode if we aren't already
    local currentMode = GetHousingEditorMode()
    if currentMode ~= HOUSING_EDITOR_MODE_BROWSE then
        HousingEditorRequestModeChange(HOUSING_EDITOR_MODE_BROWSE)
    end
    self.settingsPanel:UpdateLists()
    ITEM_PREVIEW_GAMEPAD:RegisterCallback("RefreshActions", self.OnRefreshActions)
end
function ZO_HousingFurnitureBrowser_Gamepad:OnShow()
    ZO_Gamepad_ParametricList_Screen.OnShow(self)
    
    if self.currentPanel and self.currentPanel.UpdateCurrentKeybinds then
        -- Only attempt to call UpdateCurrentKeybinds if the current panel
        -- has such a function; the Settings panel manages its own keybinds
        -- via different events internally.
        self.currentPanel:UpdateCurrentKeybinds()
    end
end
function ZO_HousingFurnitureBrowser_Gamepad:OnHiding()
    ZO_Gamepad_ParametricList_Screen.OnHiding(self)
    ZO_HousingFurnitureBrowser_Base.OnHiding(self)
end
function ZO_HousingFurnitureBrowser_Gamepad:OnHide()
    ZO_Gamepad_ParametricList_Screen.OnHide(self)
    self:SetMode(HOUSING_BROWSER_MODE.NONE)
    ITEM_PREVIEW_GAMEPAD:UnregisterCallback("RefreshActions", self.OnRefreshActions)
end
function ZO_HousingFurnitureBrowser_Gamepad:SetMode(mode)
    if self.mode ~= mode then
        if self.currentPanel then
            self.currentPanel:OnHiding()
        end
        self.mode = mode
        if mode == HOUSING_BROWSER_MODE.PLACEMENT then
            self.currentPanel = self.placementPanel
            self.headerTextFilterControl:SetHidden(false)
            self.headerTextFilterEditBox:SetText(SHARED_FURNITURE:GetPlaceableTextFilter())
        elseif mode == HOUSING_BROWSER_MODE.PRODUCTS then
            self.currentPanel = self.productsPanel
            self.headerTextFilterControl:SetHidden(false)
            self.headerTextFilterEditBox:SetText(SHARED_FURNITURE:GetMarketProductTextFilter())
        elseif mode == HOUSING_BROWSER_MODE.RETRIEVAL then
            self.currentPanel = self.retrievalPanel
            self.headerTextFilterControl:SetHidden(false)
            self.headerTextFilterEditBox:SetText(SHARED_FURNITURE:GetRetrievableTextFilter())
        elseif mode == HOUSING_BROWSER_MODE.SETTINGS then
            self.currentPanel = self.settingsPanel
            self.headerTextFilterControl:SetHidden(true)
        elseif mode == HOUSING_BROWSER_MODE.NONE then
            self.currentPanel = nil
            self.headerTextFilterControl:SetHidden(true)
        end
        if self.currentPanel then
            self.currentPanel:OnShowing()
            self:RefreshCategoryHeaderData()
        end
    end
end
function ZO_HousingFurnitureBrowser_Gamepad:IsTextFilterActive()
    return self.headerTextFilterEditBox:HasFocus()
end
function ZO_HousingFurnitureBrowser_Gamepad:GetTextFilter()
    local textFilter = ""
    if self.mode == HOUSING_BROWSER_MODE.PLACEMENT then
        textFilter = SHARED_FURNITURE:GetPlaceableTextFilter()
    elseif self.mode == HOUSING_BROWSER_MODE.RETRIEVAL then
        textFilter = SHARED_FURNITURE:GetRetrievableTextFilter()
    elseif self.mode == HOUSING_BROWSER_MODE.PRODUCTS then
        textFilter = SHARED_FURNITURE:GetMarketProductTextFilter()
    end
    return textFilter
end
function ZO_HousingFurnitureBrowser_Gamepad:ResetTextFilter()
    self.headerTextFilterEditBox:SetText("")
end
function ZO_HousingFurnitureBrowser_Gamepad:SelectTextFilter()
    self.headerTextFilterEditBox:TakeFocus()
end
do
    function ZO_HousingFurnitureBrowser_Gamepad:RefreshCategoryHeaderData()
        local mode = self.mode
        if (mode == HOUSING_BROWSER_MODE.PLACEMENT or mode == HOUSING_BROWSER_MODE.PRODUCTS or mode == HOUSING_BROWSER_MODE.RETRIEVAL) and HOUSING_EDITOR_STATE:IsLocalPlayerHouseOwner() then
            self.headerData.data1HeaderText = GetString(SI_GAMEPAD_INVENTORY_CAPACITY)
            self.headerData.data1Text = zo_strformat(SI_GAMEPAD_INVENTORY_CAPACITY_FORMAT, GetNumBagUsedSlots(BAG_BACKPACK), GetBagSize(BAG_BACKPACK))
        else
            self.headerData.data1HeaderText = nil
            self.headerData.data1Text = nil
        end
        ZO_GamepadGenericHeader_Refresh(self.header, self.headerData)
    end
end
function ZO_HousingFurnitureBrowser_Gamepad:SetTitleText(text)
    self.titleText = text
end
--
--[[ XML Functions ]]
--
    GAMEPAD_HOUSING_FURNITURE_BROWSER = ZO_HousingFurnitureBrowser_Gamepad:New(control)
end