Back to Home

ESO Lua File v101038

ingame/inventory/gamepad/zo_gamepadparametricscrolllist_bagssearch_screen.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
ZO_Gamepad_ParametricList_BagsSearch_Screen = ZO_Gamepad_ParametricList_Screen:Subclass()
function ZO_Gamepad_ParametricList_BagsSearch_Screen:Initialize(...)
    ZO_Gamepad_ParametricList_Screen.Initialize(self, ...)
    local function OnTextSearchTextChanged(editBox)
        if self.searchContext then
            TEXT_SEARCH_MANAGER:SetSearchText(self.searchContext, editBox:GetText())
        end
    end
    self:AddSearch(self.textSearchKeybindStripDescriptor, OnTextSearchTextChanged)
    -- Due to addition of text search, navigation of the list is now handled by the screen as opposed to the list itself.
    -- As such, Update handler is needed to update the current list.
    self.control:SetHandler("OnUpdate", function() self:OnUpdate() end)
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:OnUpdate()
    local list = self:GetCurrentList()
    if list then
        local listObject = list.list
        if listObject then
            listObject:OnUpdate()
        end
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:OnUpdatedSearchResults()
    local list = self:GetCurrentList()
    if list then
        list:RefreshList()
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:InitializeKeybindStripDescriptors()
    self.textSearchKeybindStripDescriptor =
    {
        {
            alignment = KEYBIND_STRIP_ALIGN_LEFT,
            keybind = "UI_SHORTCUT_PRIMARY",
            name = function()
                return GetString(SI_GAMEPAD_SELECT_OPTION)
            end,
            callback = function()
                self:SetTextSearchFocused(true)
            end,
        },
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.textSearchKeybindStripDescriptor, GAME_NAVIGATION_TYPE_BUTTON, function()
        self:OnBackButtonClicked()
    end)
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:PerformUpdate()
    if self.dirty then
        self.dirty = false
        self:OnUpdatedSearchResults()
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:OnBackButtonClicked()
    -- Default back functionality, override this function for different behaviour
    SCENE_MANAGER:HideCurrentScene()
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:UpdateSearchText()
    if self.textSearchHeaderFocus and self.searchContext then
        self.textSearchHeaderFocus:UpdateTextForContext(self.searchContext)
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:GetTextSearchText()
    if self.textSearchHeaderFocus then
        return self.textSearchHeaderFocus:GetText()
    end
    return ""
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:IsSlotInSearchTextResults(bagId, slotIndex)
    if self.searchContext then
        return TEXT_SEARCH_MANAGER:IsItemInSearchTextResults(self.searchContext, BACKGROUND_LIST_FILTER_TARGET_BAG_SLOT, bagId, slotIndex)
    end
    -- Return true for every result if we don't have a context search
    return true
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:SetTextSearchContext(context)
    self.searchContext = context
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:ActivateTextSearch()
    if self.searchContext and not TEXT_SEARCH_MANAGER:IsActiveTextSearch(self.searchContext) then
        self:UpdateSearchText()
        local function OnTextSearchResults()
            self.dirty = true
            self:Update()
        end
        self.onTextSearchResults = OnTextSearchResults
        TEXT_SEARCH_MANAGER:ActivateTextSearch(self.searchContext)
        TEXT_SEARCH_MANAGER:RegisterCallback("UpdateSearchResults", OnTextSearchResults)
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:DeactivateTextSearch()
    if self.searchContext then
        TEXT_SEARCH_MANAGER:DeactivateTextSearch(self.searchContext)
        TEXT_SEARCH_MANAGER:UnregisterCallback("UpdateSearchResults", self.onTextSearchResults)
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:SetSearchText()
    if self.searchContext then
        TEXT_SEARCH_MANAGER:SetSearchText(self.searchContext, self:GetTextSearchText())
    end
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:OnShow()
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:OnHiding()
end
function ZO_Gamepad_ParametricList_BagsSearch_Screen:MarkDirtyByBagId(bagId, shouldSuppressSearchUpdate)
    TEXT_SEARCH_MANAGER:MarkDirtyByFilterTargetAndPrimaryKey(BACKGROUND_LIST_FILTER_TARGET_BAG_SLOT, bagId, shouldSuppressSearchUpdate)
end