ESO Lua File v100010

ingame/group/gamepad/zo_grouplist_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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
----------------------------------
--Group List Gamepad
----------------------------------
ZO_GroupList_Gamepad = ZO_Object.MultiSubclass(ZO_GroupList_Base, ZO_PagedList)
function ZO_GroupList_Gamepad:New(control)
    local manager = ZO_Object.New(self)
    manager:Initialize(control)
    return manager
end
function ZO_GroupList_Gamepad:Initialize(control)
    self.control = control
    self.vertMovementController = ZO_MovementController:New(MOVEMENT_CONTROLLER_DIRECTION_VERTICAL)
    ZO_PagedList.Initialize(self, control, self.vertMovementController)
    ZO_GroupList_Base.Initialize(self, control)
    local SORT_KEYS =
    {
        ["groupIndex"] = { isNumeric = true },
        ["characterName"] = { },
        ["id"] = { },
        ["zone"] = { tiebreaker = "displayName" },
        ["class"] = { tiebreaker = "displayName" },
        ["veteranRank"] = { tiebreaker = "displayName", isNumeric = true},
        ["level"] = { tiebreaker = "veteranRank", isNumeric = true },
    }
    self:SetupSort(SORT_KEYS, "position", ZO_SORT_ORDER_DOWN)
    self.sortHeaderGroup:SetColors(ZO_SELECTED_TEXT, ZO_DISABLED_TEXT, ZO_DISABLED_TEXT, ZO_DISABLED_TEXT)
    local function OnSelected()
        KEYBIND_STRIP:UpdateKeybindButtonGroup(self.listKeybinds)
    end
    self.headersSelected = false
    self:AddDataTemplate("ZO_GroupListRow_Gamepad", 65, function(control, data, selected) self:SetupGroupEntry(control, data, selected) end)
end
function ZO_GroupList_Gamepad:InitializeKeybinds()
    self.listKeybinds = {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        {
            --Select Member
            name = GetString(SI_GAMEPAD_SELECT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            visible = function()
                local data = self:GetSelectedData()
                if data then
                    return not data.isPlayer
                end
                return false
            end,
            callback = function()
                if self.onMemberSelectedCallback then
                    self.onMemberSelectedCallback()
                end
            end,
        }
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.listKeybinds, GAME_NAVIGATION_TYPE_BUTTON, function()
        if self.onBackCallback then
            self.onBackCallback()
        end
    end)
    self.sortHeaderKeybinds = {
        alignment = KEYBIND_STRIP_ALIGN_LEFT,
        --Sort
        {
            name = GetString(SI_GAMEPAD_SORT_OPTION),
            keybind = "UI_SHORTCUT_PRIMARY",
            callback = function()
                self.sortHeaderGroup:SortBySelected()
            end,
        },
    }
    ZO_Gamepad_AddBackNavigationKeybindDescriptors(self.sortHeaderKeybinds, GAME_NAVIGATION_TYPE_BUTTON, function()
        if self.onBackCallback then
            self.onBackCallback()
        end
    end)
end
function ZO_GroupList_Gamepad:SelectList()
    self.headersSelected = false
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.sortHeaderKeybinds)
    DIRECTIONAL_INPUT:Deactivate(self)
    ZO_PagedList.Activate(self)
    KEYBIND_STRIP:AddKeybindButtonGroup(self.listKeybinds)
end
function ZO_GroupList_Gamepad:SelectHeaders()
    self.headersSelected = true
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.listKeybinds)
    ZO_PagedList.Deactivate(self)
    DIRECTIONAL_INPUT:Activate(self)
    self:ActivateHeader()
    KEYBIND_STRIP:AddKeybindButtonGroup(self.sortHeaderKeybinds)
end
function ZO_GroupList_Gamepad:UpdateDirectionalInput()
    local vertResult = self.vertMovementController:CheckMovement()
    if vertResult == MOVEMENT_CONTROLLER_MOVE_NEXT then
        self:SelectList()
    end
end
function ZO_GroupList_Gamepad:SetOnMemberSelectedCallback(callback)
end
function ZO_GroupList_Gamepad:SetOnBackCallback(callback)
end
--ZO_GroupList_Base overrides
do
    local CACHED_NAMES = {}
    local CACHED_ZONES = {}
    function ZO_GroupList_Gamepad:SetupGroupEntry(control, data, selected)
        data.control = control
    
        local groupIndexControl = control:GetNamedChild("GroupIndex")
        groupIndexControl:GetNamedChild("LeaderIcon"):SetHidden(not data.leader)
    
        local groupIndex = ZO_Group_GetGroupIndexFromUnitTag(data.unitTag)
        data.groupIndex = groupIndex
        groupIndexControl:GetNamedChild("Number"):SetText(groupIndex)
    
        local nameControl = control:GetNamedChild("Name")
        local rawName = data.rawCharacterName
        local characterName = CACHED_NAMES[rawName] or zo_strformat(SI_GAMEPAD_GROUP_LIST_CHARACTER_NAME_FORMAT, rawName)
        CACHED_NAMES[rawName] = characterName
    
        nameControl:SetText(characterName)
        nameControl:SetAlpha(data.online and ZO_GAMEPAD_TEXT_SELECTED_ALPHA or ZO_GAMEPAD_TEXT_UNSELECTED_ALPHA)
    
        if IsConsoleUI() then
            local accountName, consoleId, wasFound = GetConsoleInfoFromCharName(characterName)
            if wasFound then
                data.id = accountName
                control:GetNamedChild("Id"):SetText(accountName)
            end
        end
    
        local zoneText = CACHED_ZONES[data.zone] or zo_strformat(SI_SOCIAL_LIST_LOCATION_FORMAT, data.zone)
        CACHED_ZONES[data.zone] = zoneText
        control:GetNamedChild("Zone"):SetText(zoneText)
    
        local classIcon = control:GetNamedChild("Class"):GetNamedChild("Icon")
        local classTexture = GetClassIcon(data.class)
        classIcon:SetHidden(not classTexture)
        if(classTexture) then
            classIcon:SetTexture(classTexture)
        end
    
        control:GetNamedChild("Level"):GetNamedChild("Text"):SetText(GetLevelOrVeteranRankStringNoIcon(data.level, data.veteranRank))
    
        local veteranIcon = control:GetNamedChild("Level"):GetNamedChild("VeteranIcon")
        if data.veteranRank and data.veteranRank > 0 then
            veteranIcon:SetHidden(false)
            veteranIcon:SetTexture(GetVeteranRankIcon())
        else
            veteranIcon:SetHidden(true)
        end
    
        local dpsIcon = control:GetNamedChild("Roles"):GetNamedChild("DPS")
        local healIcon = control:GetNamedChild("Roles"):GetNamedChild("Heal")
        local tankIcon = control:GetNamedChild("Roles"):GetNamedChild("Tank")
        dpsIcon:SetTexture(GAMEPAD_LFG_OPTION_INFO[LFG_ROLE_DPS].icon)
        healIcon:SetTexture(GAMEPAD_LFG_OPTION_INFO[LFG_ROLE_HEAL].icon)
        tankIcon:SetTexture(GAMEPAD_LFG_OPTION_INFO[LFG_ROLE_TANK].icon)
    
        dpsIcon:SetAlpha(data.isDps and ZO_GAMEPAD_ICON_SELECTED_ALPHA or ZO_GAMEPAD_ICON_UNSELECTED_ALPHA)
        healIcon:SetAlpha(data.isHeal and ZO_GAMEPAD_ICON_SELECTED_ALPHA or ZO_GAMEPAD_ICON_UNSELECTED_ALPHA)
        tankIcon:SetAlpha(data.isTank and ZO_GAMEPAD_ICON_SELECTED_ALPHA or ZO_GAMEPAD_ICON_UNSELECTED_ALPHA)
    end
end
--ZO_PagedList overrides
function ZO_GroupList_Gamepad:BuildMasterList()
    self:Clear()
    local data = GROUP_LIST_MANAGER:GetData()
    for i = 1, #data do
        self:AddEntry("ZO_GroupListRow_Gamepad", data[i])
    end
end
function ZO_GroupList_Gamepad:Activate()
    if self.headersSelected then
        self:SelectHeaders()
    else
        self:SelectList()
    end
end
function ZO_GroupList_Gamepad:Deactivate()
    ZO_PagedList.Deactivate(self)
    DIRECTIONAL_INPUT:Deactivate(self)
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.listKeybinds)
    KEYBIND_STRIP:RemoveKeybindButtonGroup(self.sortHeaderKeybinds)
end
--XML calls
function ZO_GroupListHeader_Initialize(control, textEnum, sortKey, textAlignment)
    ZO_SortHeader_Initialize(control, GetString(textEnum), sortKey, ZO_SORT_ORDER_UP, textAlignment, nil, "ZO_GroupListHeaderHighlight_Gamepad")
end