Back to Home

ESO Lua File v100033

libraries/zo_tile/gamepad/actiontile_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
----
-- ZO_ActionTile_Gamepad
----
-----------
-- This class should be dual inherited after an ZO_ActionTile to create a complete tile. This class should NOT subclass an ZO_ActionTile
--
-- Note: Since this is expected to be the second class of a dual inheritance it does not have it's own New function
-----------
ZO_ActionTile_Gamepad = ZO_Tile_Gamepad:Subclass()
function ZO_ActionTile_Gamepad:InitializePlatform()
    ZO_Tile_Gamepad.InitializePlatform(self)
    self.actionKeybindDescriptor = 
    {
        name = GetString(SI_GAMEPAD_SELECT_OPTION),
        keybind = "UI_SHORTCUT_PRIMARY",
        sound = function()
             if self:IsActionAvailable() then
                return SOUNDS.DIALOG_ACCEPT
            else
                return SOUNDS.DIALOG_DECLINE
            end
        end,
        visible = function()
            return self:IsActionAvailable()
        end,
        callback = function()
            if self.actionCallback and self:IsActionAvailable() then
                self.actionCallback()
            end
        end
    }
end
function ZO_ActionTile_Gamepad:PostInitializePlatform()
    self.selection = self.container:GetNamedChild("Selection")
end
function ZO_ActionTile_Gamepad:OnSelectionChanged()
end
function ZO_ActionTile_Gamepad:SetSelected(isSelected)
    local oldSelected = self:IsSelected()
    ZO_Tile_Gamepad.SetSelected(self, isSelected)
    -- Set hidden state if current keybind button's descriptor matches tile's descriptor after the keybind has been updated
    if self.keybindButton and self.keybindButton:GetKeybindButtonDescriptorReference() == self.actionKeybindDescriptor then
        if oldSelected ~= isSelected then
            self.keybindButton:SetHidden(not (isSelected and self:IsActionAvailable()))
        end
    end
end
function ZO_ActionTile_Gamepad:SetKeybindButton(keybindButton)
    self.keybindButton = keybindButton
end
function ZO_ActionTile_Gamepad:SetActionAvailable(available)
    ZO_ActionTile.SetActionAvailable(self, available)
    if self.keybindButton then
        self.keybindButton:SetHidden(not self:IsActionAvailable())
    end
end
function ZO_ActionTile_Gamepad:SetActionText(actionText)
    ZO_ActionTile.SetActionText(self, actionText)
    self.actionKeybindDescriptor.name = actionText
end
function ZO_ActionTile_Gamepad:SetActionSound(actionSound)
    ZO_ActionTile.SetActionSound(self, actionSound)
    self.actionKeybindDescriptor.sound = actionSound
end
function ZO_ActionTile_Gamepad:SetKeybindKey(key)
    self.actionKeybindDescriptor.keybind = key
end
function ZO_ActionTile_Gamepad:UpdateKeybindButton()
    if self.keybindButton and self:IsSelected() then
        self.keybindButton:SetKeybindButtonDescriptor(self.actionKeybindDescriptor)
    end
end
function ZO_ActionTile_Gamepad:GetFocusEntryData()
    if not self.focusEntryData then
        self.focusEntryData =
        {
            activate = function()
                self:SetSelected(true)
            end,
            deactivate = function()
                self:SetSelected(false)
            end,
            highlight = self.selection,
        }
    end
    return self.focusEntryData
end
function ZO_ActionTile_Gamepad:GetKeybindDescriptor()
    return self.actionKeybindDescriptor
end