Back to Home

ESO Lua File v100024

ingame/help/gamepad/help_entries_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
local HelpTutorialsEntriesGamepad = ZO_HelpTutorialsGamepad:Subclass()
function HelpTutorialsEntriesGamepad:New(...)
    return ZO_HelpTutorialsGamepad.New(self, ...)
end
function HelpTutorialsEntriesGamepad:Initialize(control)
    ZO_HelpTutorialsGamepad.Initialize(self, control)
    local helpEntriesFragment = ZO_FadeSceneFragment:New(control)
    HELP_TUTORIALS_ENTRIES_GAMEPAD = ZO_Scene:New("helpTutorialsEntriesGamepad", SCENE_MANAGER)
    HELP_TUTORIALS_ENTRIES_GAMEPAD:AddFragment(helpEntriesFragment)
    local function OnStateChanged(...)
        self:OnStateChanged(...)
    end
    HELP_TUTORIALS_ENTRIES_GAMEPAD:RegisterCallback("StateChange", OnStateChanged)
    self.tutorialBox = control:GetNamedChild("TutorialText")
    self.scrollContainer = self.tutorialBox:GetNamedChild("HelpTextContainer")
    local messageContainer = self.tutorialBox:GetNamedChild("HelpMessageContainer")
    self.description1 = messageContainer:GetNamedChild("DetailsBody1")
    self.description2 = messageContainer:GetNamedChild("DetailsBody2")
    self.image = messageContainer:GetNamedChild("DetailsImage")
end
function HelpTutorialsEntriesGamepad:InitializeEvents()
    ZO_HelpTutorialsGamepad.InitializeEvents(self)
    local function OnShowSpecificPage(eventId, helpCategoryIndex, helpIndex)
        if IsInGamepadPreferredMode() then
            -- ideally we would do a push here, but that is currently not playing
            -- well with opening help from the Crown Store
            -- specifically: attempting to gift from the furniture browser with gifting locked
            self:Show(helpCategoryIndex, helpIndex)
        end
    end
    self.control:RegisterForEvent(EVENT_HELP_SHOW_SPECIFIC_PAGE, OnShowSpecificPage)
end
function HelpTutorialsEntriesGamepad:SelectOrQueueHelpEntry(categoryIndex, helpIndex)
    if self.categoryIndex ~= categoryIndex then
        self.dirty = true
        self.showHelpIndex = helpIndex
    else
        self:SelectHelpEntry(helpIndex)
    end
    self.categoryIndex = categoryIndex
end
function HelpTutorialsEntriesGamepad:Push(categoryIndex, helpIndex)
    self:SelectOrQueueHelpEntry(categoryIndex, helpIndex)
    SCENE_MANAGER:Push("helpTutorialsEntriesGamepad")
end
function HelpTutorialsEntriesGamepad:Show(categoryIndex, helpIndex)
    self:SelectOrQueueHelpEntry(categoryIndex, helpIndex)
    SCENE_MANAGER:Show("helpTutorialsEntriesGamepad")
end
function HelpTutorialsEntriesGamepad:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        KEYBIND_STRIP:GetDefaultGamepadBackButtonDescriptor(),
    }
    ZO_Gamepad_AddListTriggerKeybindDescriptors(self.keybindStripDescriptor, function() return self.itemList end )
end
function HelpTutorialsEntriesGamepad:AddHelpEntry(categoryIndex, helpIndex)
    local helpName, _, _, _, _, _, showOption = GetHelpInfo(categoryIndex, helpIndex)
    if IsGamepadHelpOption(showOption) then
        local entryData = ZO_GamepadEntryData:New(helpName)
        entryData.helpIndex = helpIndex
        self.itemList:AddEntry("ZO_GamepadMenuEntryTemplate", entryData)
    end
end
function HelpTutorialsEntriesGamepad:PerformUpdate()
    self.dirty = false
    -- Add the entries.
    self.itemList:Clear()
    if self.searchString and self.searchString ~= "" then
        for i = 1, #self.searchResults do
            local searchResult = self.searchResults[i]
            if searchResult and searchResult.helpCategoryIndex == self.categoryIndex then
                self:AddHelpEntry(self.categoryIndex, searchResult.helpIndex)
            end
        end
    else
        for helpIndex = 1, GetNumHelpEntriesWithinCategory(self.categoryIndex) do
            self:AddHelpEntry(self.categoryIndex, helpIndex)
        end
    end
    self.itemList:SetKeyForNextCommit(self.categoryIndex)
    self.itemList:Commit()
    -- Update the key bindings.
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    -- Update the header.
    local categoryName, _, _, _, _ = GetHelpCategoryInfo(self.categoryIndex)
    self.headerData.titleText = categoryName
    self:SetupSearchHeaderData(self.searchString, self.headerData)
    if self.showHelpIndex then
        self:SelectHelpEntry(self.showHelpIndex)
        self.showHelpIndex = nil
    end
end
function HelpTutorialsEntriesGamepad:SelectHelpEntry(helpIndex)
    for i = 1, self.itemList:GetNumEntries() do
        local data = self.itemList:GetEntryData(i)
        if data.helpIndex == helpIndex then
            self.itemList:SetSelectedIndexWithoutAnimation(i)
            return
        end
    end
end
function HelpTutorialsEntriesGamepad:OnSelectionChanged(list, selectedData, oldSelectedData)
    if not selectedData then
        return
    end
    self.scrollContainer:ResetToTop()
    local _, keyboardDescription1, keyboardDescription2, image, gamepadDescription1, gamepadDescription2 = GetHelpInfo(self.categoryIndex, selectedData.helpIndex)
    local description1 = gamepadDescription1 ~= "" and gamepadDescription1 or keyboardDescription1
    local description2 = gamepadDescription2 ~= "" and gamepadDescription2 or keyboardDescription2
    self.description1:SetText(description1)
    if image then
        self.image:SetHidden(false)
        self.image:SetTexture(image)
    else
        self.image:SetHidden(true)
        self.image:SetHeight(0)
    end
    self.description2:SetText(description2)
end
function HelpTutorialsEntriesGamepad:OnHide()
    ZO_HelpTutorialsGamepad.OnHide(self)
end
local GAMEPAD_HELP_MAX_IMAGE_WIDTH = 767
    -- when hidden we directly manipulate the height, so don't apply constraints in those cases
    if not control:IsHidden() then
        ZO_ResizeTextureWidthAndMaintainAspectRatio(control, GAMEPAD_HELP_MAX_IMAGE_WIDTH)
    end
end
    HELP_TUTORIALS_ENTRIES_GAMEPAD = HelpTutorialsEntriesGamepad:New(control)
end