Back to Home

ESO Lua File v100019

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
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.visitorPermissionsControl = control:GetNamedChild("Visitors")
    self.banListPermissionsControl = control:GetNamedChild("BanList")
    self.guildVisitorPermissionsControl = control:GetNamedChild("GuildVisitors")
    self.guildBanListPermissionsControl = control:GetNamedChild("GuildBanList")
    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
    
    self:InitializeHeader()
    self:SetListsUseTriggerKeybinds(true)
end
function ZO_HousingFurnitureBrowser_Gamepad:PerformUpdate()
    --Do nothing. We manager the update state in a more nuanced way.
end
--Overridden
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
function ZO_HousingFurnitureBrowser_Gamepad:InitializeHeader()
    local tabBarEntries =
    {
        {
            text = GetString(SI_HOUSING_FURNITURE_TAB_PLACE),
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.PLACEMENT)
            end,
        },
        {
            text = GetString(SI_HOUSING_FURNITURE_TAB_PURCHASE),
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.PRODUCTS)
            end,
        },
        {
            text = GetString(SI_HOUSING_FURNITURE_TAB_RETRIEVAL),
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.RETRIEVAL)
            end,
        },
        {
            text = GetString(SI_HOUSING_FURNITURE_TAB_SETTINGS),
            callback = function()
                self:SetMode(HOUSING_BROWSER_MODE.SETTINGS)
            end,
        },
    }
    self.categoryHeaderData =
    {
        tabBarEntries = tabBarEntries,
    }
    ZO_GamepadGenericHeader_Initialize(self.header, ZO_GAMEPAD_HEADER_TABBAR_CREATE)
    local headerContainer = self:GetHeaderContainer()
    self.headerTextFilterControl = headerContainer:GetNamedChild("Filter")
    self.headerTextFilterEditBox = self.headerTextFilterControl:GetNamedChild("SearchEdit")
    self.headerTextFilterHighlight = self.headerTextFilterControl:GetNamedChild("Highlight")
    self.headerTextFilterIcon = self.headerTextFilterControl:GetNamedChild("Icon")
    self.headerBGTexture = self.headerTextFilterControl:GetNamedChild("BG")
    self.headerTextFilterEditBox:SetHandler("OnTextChanged", function(editBox)
        ZO_EditDefaultText_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)
    ZO_PreHookHandler(self.headerTextFilterEditBox, "OnFocusGained", function(editBox)
        self:DeactivateCurrentList()
        self.headerTextFilterHighlight:SetHidden(false)
        self.headerTextFilterIcon:SetColor(ZO_SELECTED_TEXT:UnpackRGBA())
        self.headerBGTexture:SetHidden(false)
    end)
    ZO_PreHookHandler(self.headerTextFilterEditBox, "OnFocusLost", function(editBox)
        self.headerTextFilterHighlight:SetHidden(true)
        self.headerTextFilterIcon:SetColor(ZO_DISABLED_TEXT:UnpackRGBA())
        self.headerBGTexture:SetHidden(true)
        self:ActivateCurrentList()
    end)
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:OnShowing()
    ZO_Gamepad_ParametricList_Screen.OnShowing(self)
    ZO_HousingFurnitureBrowser_Base.OnShowing(self)
    ZO_GamepadGenericHeader_Activate(self.header)
    self.settingsPanel:UpdateLists()
end
function ZO_HousingFurnitureBrowser_Gamepad:OnHiding()
    ZO_Gamepad_ParametricList_Screen.OnHiding(self)
    ZO_HousingFurnitureBrowser_Base.OnHiding(self)
end
function ZO_HousingFurnitureBrowser_Gamepad:OnHide()
    self:SetMode(HOUSING_BROWSER_MODE.NONE)
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: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 then
            self.categoryHeaderData.data1HeaderText = GetString(SI_GAMEPAD_INVENTORY_CAPACITY)
            self.categoryHeaderData.data1Text = zo_strformat(SI_GAMEPAD_INVENTORY_CAPACITY_FORMAT, GetNumBagUsedSlots(BAG_BACKPACK), GetBagSize(BAG_BACKPACK))
        else
            self.categoryHeaderData.data1HeaderText = nil
            self.categoryHeaderData.data1Text = nil
        end
        ZO_GamepadGenericHeader_Refresh(self.header, self.categoryHeaderData)
    end
end
--
--[[ XML Functions ]]
--
    GAMEPAD_HOUSING_FURNITURE_BROWSER = ZO_HousingFurnitureBrowser_Gamepad:New(control)
end