Back to Home

ESO Lua File v100031

ingame/help/gamepad/help_common_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
--[[Basic screen]]--
ZO_HelpTutorialsGamepad = ZO_Gamepad_ParametricList_Screen:Subclass()
function ZO_HelpTutorialsGamepad:New(...)
    return ZO_Gamepad_ParametricList_Screen.New(self, ...)
end
function ZO_HelpTutorialsGamepad:Initialize(control, activateOnShow)
    ZO_Gamepad_ParametricList_Screen.Initialize(self, control, ZO_GAMEPAD_HEADER_TABBAR_DONT_CREATE, activateOnShow)
    self.itemList = ZO_Gamepad_ParametricList_Screen.GetMainList(self)
    self.headerData = {
             titleText = GetString(SI_HELP_TUTORIALS),
        }
end
function ZO_HelpTutorialsGamepad:InitializeEvents()
    local function UpdateHelp()
        self:Update()
    end
    self.control:RegisterForEvent(EVENT_HELP_INITIALIZED, UpdateHelp)
end
function ZO_HelpTutorialsGamepad:SetupSearchHeaderData(searchString, headerData)
    if searchString and searchString ~= "" then
        headerData.data1HeaderText = GetString(SI_GAMEPAD_HELP_SEARCH)
        headerData.data1Text = searchString
    else
        headerData.data1HeaderText = nil
        headerData.data1Text = nil
    end
end
--[[Tutorial Info Display]]--
ZO_HelpTutorialsDisplay_Gamepad = ZO_Object:Subclass()
function ZO_HelpTutorialsDisplay_Gamepad:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_HelpTutorialsDisplay_Gamepad:Initialize(control)
    self.control = control
    HELP_TUTORIAL_DISPLAY_FRAGMENT_GAMEPAD = ZO_FadeSceneFragment:New(control)
    self.scrollContainer = control:GetNamedChild("HelpTextContainer")
    local messageContainer = self.scrollContainer:GetNamedChild("ScrollChild"):GetNamedChild("HelpMessageContainer")
    self.description1Label = messageContainer:GetNamedChild("DetailsBody1")
    self.description2Label = messageContainer:GetNamedChild("DetailsBody2")
    self.imageTexture = messageContainer:GetNamedChild("DetailsImage")
end
function ZO_HelpTutorialsDisplay_Gamepad:ShowHelp(helpCategoryIndex, helpIndex)
    if helpCategoryIndex ~= self.helpCategoryIndex or helpIndex ~= self.helpIndex then
        self.helpCategoryIndex = helpCategoryIndex
        self.helpIndex = helpIndex
        local _, description1, description2, image, gamepadDescription1, gamepadDescription2 = GetHelpInfo(helpCategoryIndex, helpIndex)
        local description1 = gamepadDescription1 == "" and description1 or gamepadDescription1
        local description2 = gamepadDescription2 == "" and description2 or gamepadDescription2
        self.description1Label:SetText(description1)
        if image then
            self.imageTexture:SetHidden(false)
            self.imageTexture:SetTexture(image)
        else
            self.imageTexture:SetHidden(true)
            self.imageTexture:SetHeight(0)
        end
        self.description2Label:SetText(description2)
    end
    self.scrollContainer:ResetToTop()
    SCENE_MANAGER:AddFragment(HELP_TUTORIAL_DISPLAY_FRAGMENT_GAMEPAD)
end
function ZO_HelpTutorialsDisplay_Gamepad:Hide()
    SCENE_MANAGER:RemoveFragment(HELP_TUTORIAL_DISPLAY_FRAGMENT_GAMEPAD)
end
--[[Overlay Dialog View]]--
ESO_Dialogs["HELP_TUTORIALS_OVERLAY_DIALOG"] =
{
    gamepadInfo =
    {
        dialogType = GAMEPAD_DIALOGS.PARAMETRIC,
        allowRightStickPassThrough = true,
    },
    title =
    {
        text = SI_HELP_TUTORIALS,
    },
    parametricList = {}, -- Generated Dynamically
    setup = function(dialog)
        local parametricList = dialog.info.parametricList
        ZO_ClearNumericallyIndexedTable(parametricList)
        local systemFilters = HELP_MANAGER:GetShowingOverlaySceneSystemFilters()
        for helpCategoryIndex = 1, GetNumHelpCategories() do
            local categoryName = GetHelpCategoryInfo(helpCategoryIndex)
            for helpIndex = 1, GetNumHelpEntriesWithinCategory(helpCategoryIndex) do
                local helpName, _, _, _, _, _, showOption = GetHelpInfo(helpCategoryIndex, helpIndex)
                if IsGamepadHelpOption(showOption) then
                    local passesSystemFilter = true
                    if systemFilters and #systemFilters > 0 then
                        if not ZO_IsElementInNumericallyIndexedTable(systemFilters, GetUISystemAssociatedWithHelpEntry(helpCategoryIndex, helpIndex)) then
                            passesSystemFilter = false
                        end
                    end
                    if passesSystemFilter then
                        local entryData = ZO_GamepadEntryData:New(helpName)
                        entryData.setup = ZO_SharedGamepadEntry_OnSetup
                        entryData.helpCategoryIndex = helpCategoryIndex
                        entryData.helpIndex = helpIndex
                        local listItem =
                        {
                            template = "ZO_GamepadItemEntryTemplate",
                            entryData = entryData,
                            header = categoryName,
                        }
                        -- Clear so only the first one gets the header
                        categoryName = nil
                        table.insert(parametricList, listItem)
                    end
                end
            end
        end
        local IS_VISIBLE = true
        HELP_MANAGER:OnOverlayVisibilityChanged(IS_VISIBLE)
        dialog:setupFunc()
    end,
    parametricListOnSelectionChangedCallback = function(dialog, list)
        local targetData = list:GetTargetData()
        if targetData then
            HELP_TUTORIAL_DISPLAY_GAMEPAD:ShowHelp(targetData.helpCategoryIndex, targetData.helpIndex)
        else
            HELP_TUTORIAL_DISPLAY_GAMEPAD:Hide()
        end
    end,
    onHidingCallback = function()
        HELP_TUTORIAL_DISPLAY_GAMEPAD:Hide()
    end,
    finishedCallback = function()
        local IS_NOT_VISIBLE = false
        HELP_MANAGER:OnOverlayVisibilityChanged(IS_NOT_VISIBLE)
    end,
    buttons =
    {
        {
            keybind = "DIALOG_NEGATIVE",
            text = SI_GAMEPAD_BACK_OPTION,
            callback =  function(dialog)
                ZO_Dialogs_ReleaseDialogOnButtonPress("HELP_TUTORIALS_OVERLAY_DIALOG")
            end
        },
    },
}
--[[Global XML]]--
    HELP_TUTORIAL_DISPLAY_GAMEPAD = ZO_HelpTutorialsDisplay_Gamepad:New(control)
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