Back to Home

ESO Lua File v100022

ingame/help/gamepad/help_categories_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
local HelpTutorialsCategoriesGamepad = ZO_HelpTutorialsGamepad:Subclass()
function HelpTutorialsCategoriesGamepad:New(...)
    return ZO_HelpTutorialsGamepad.New(self, ...)
end
function HelpTutorialsCategoriesGamepad:Initialize(control)
    ZO_HelpTutorialsGamepad.Initialize(self, control)
    local helpTutorialsFramgent = ZO_FadeSceneFragment:New(control)
    HELP_TUTORIAL_CATEGORIES_SCENE_GAMEPAD = ZO_Scene:New("helpTutorialsCategoriesGamepad", SCENE_MANAGER)
    HELP_TUTORIAL_CATEGORIES_SCENE_GAMEPAD:AddFragment(helpTutorialsFramgent)
    local function OnStateChanged(...)
        self:OnStateChanged(...)
    end
    HELP_TUTORIAL_CATEGORIES_SCENE_GAMEPAD:RegisterCallback("StateChange", OnStateChanged)
end
function HelpTutorialsCategoriesGamepad:InitializeKeybindStripDescriptors()
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        -- Back
        KEYBIND_STRIP:GetDefaultGamepadBackButtonDescriptor(),
        -- Show Category or filter
        {
            name = function ()
                    return GetString(SI_GAMEPAD_HELP_DETAILS)
            end,
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                    local targetData = self.itemList:GetTargetData()
                    HELP_TUTORIALS_ENTRIES_GAMEPAD:Push(targetData.categoryIndex)
            end,
        },
    }
    ZO_Gamepad_AddListTriggerKeybindDescriptors(self.keybindStripDescriptor, function() return self.itemList end )
end
local function SortByCategory(result1, result2)
    return result1.helpCategoryIndex < result2.helpCategoryIndex
end
function HelpTutorialsCategoriesGamepad:AddListEntry(categoryIndex)
    local categoryName, description, _, _, _, gamepadIcon = GetHelpCategoryInfo(categoryIndex)
    local entryData = ZO_GamepadEntryData:New(categoryName, gamepadIcon)
    entryData:SetIconTintOnSelection(true)
    entryData.categoryIndex = categoryIndex
    entryData.name = categoryName
    self.itemList:AddEntry("ZO_GamepadMenuEntryTemplate", entryData)
end
function HelpTutorialsCategoriesGamepad:IsCategoryEmpty(categoryIndex)
    local numEntries = GetNumHelpEntriesWithinCategory(categoryIndex)
    for helpIndex = 1, numEntries do
        local showOption = select(7, GetHelpInfo(categoryIndex, helpIndex))
        if IsGamepadHelpOption(showOption) then
            return false
        end
    end
    return true
end
function HelpTutorialsCategoriesGamepad:PerformUpdate()
    self.dirty = false
    self.itemList:Clear()
    -- Get the list of categoires we need to show.
    for categoryIndex = 1, GetNumHelpCategories() do
        if not self:IsCategoryEmpty(categoryIndex) then
            self:AddListEntry(categoryIndex)
        end
    end
    self.itemList:Commit()
    -- Update the key bindings.
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
    -- Update the header.
end
    HELP_TUTORIALS_CATEGORIES = HelpTutorialsCategoriesGamepad:New(control)
end