Back to Home

ESO Lua File v101044

ingame/groupfinder/keyboard/groupfinder_applicationlist_keyboard.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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
------------------------------------------
--Group Finder Applications List Keyboard
------------------------------------------
ZO_KEYBOARD_GROUP_FINDER_APPLICATIONS_LIST_EXPIRES_WIDTH = 85
local APPLICATION_DATA = 1
--------------------------------------------------------------
-- ZO_GroupFinder_ApplicationsManagementPanel_Keyboard
--------------------------------------------------------------
ZO_GroupFinder_ApplicationsManagementPanel_Keyboard = ZO_GroupFinder_BasePanel_Keyboard:Subclass()
function ZO_GroupFinder_ApplicationsManagementPanel_Keyboard:Initialize(control)
    ZO_GroupFinder_BasePanel_Keyboard.Initialize(self, control)
    self.list = ZO_GroupFinder_ApplicationsList_Keyboard:New(control:GetNamedChild("List"), self:GetFragment())
    self.editButton = control:GetNamedChild("ButtonContainerEditGroupButton")
    self.myListingControl = control:GetNamedChild("GroupListing")
    self.myListingData = ZO_GroupListingUserTypeData:New(GROUP_FINDER_GROUP_LISTING_USER_TYPE_CREATED_GROUP_LISTING)
    self.myListingControl:SetHandler("OnMouseEnter", function()
        InitializeTooltip(GroupFinderGroupListingTooltip, self.myListingControl, RIGHT, -15, 0, LEFT)
        ZO_GroupFinderGroupListingTooltip_SetGroupFinderListing(GroupFinderGroupListingTooltip, self.myListingData)
    end)
    self.myListingControl:SetHandler("OnMouseExit", function()
        ClearTooltip(GroupFinderGroupListingTooltip)
    end)
    self.roleControlPool = ZO_ControlPool:New("ZO_GroupFinder_RoleIconTemplate_Keyboard", control)
    local function OnUpdateGroupListing(result)
        if result == GROUP_FINDER_ACTION_RESULT_SUCCESS then
            self:RefreshListing()
        end
    end
    EVENT_MANAGER:RegisterForEvent("GroupFinder_ApplicationsManagementPanel", EVENT_GROUP_FINDER_UPDATE_GROUP_LISTING_RESULT, OnUpdateGroupListing)
    local function OnRefreshApplication()
        if self:GetFragment():IsShowing() then
            self.editButton:SetEnabled(ZO_GroupFinder_CanDoCreateEdit(self.myListingData))
        end
    end
    GROUP_FINDER_APPLICATIONS_LIST_MANAGER:RegisterCallback("ApplicationsListUpdated", OnRefreshApplication)
   self.editButton:SetHandler("OnMouseEnter", function()
        local canDoCreateEdit, disabledString = ZO_GroupFinder_CanDoCreateEdit(self.myListingData)
        if not canDoCreateEdit then
            InitializeTooltip(InformationTooltip, self.editButton, BOTTOMLEFT, 0, 0, TOPLEFT)
            SetTooltipText(InformationTooltip, ZO_ERROR_COLOR:Colorize(disabledString))
        end
    end)
    self.editButton:SetHandler("OnMouseExit", function()
        ClearTooltip(InformationTooltip)
    end)
end
function ZO_GroupFinder_ApplicationsManagementPanel_Keyboard:Show()
    ZO_GroupFinder_BasePanel_Keyboard.Show(self)
    self:RefreshListing()
end
function ZO_GroupFinder_ApplicationsManagementPanel_Keyboard:RefreshListing()
    self.roleControlPool:ReleaseAllObjects()
    ZO_GroupFinder_Shared.SetUpGroupListingFromData(self.myListingControl, self.roleControlPool, self.myListingData, ZO_GROUP_LISTING_ROLE_CONTROL_PADDING)
    if self.myListingData:DoesGroupAutoAcceptRequests() then
        self.list:SetNoApplicationsText(GetString(SI_GROUP_FINDER_APPLICATIONS_AUTO_ACCEPT_EMPTY_TEXT))
    else
        self.list:SetNoApplicationsText(GetString(SI_GROUP_FINDER_APPLICATIONS_EMPTY_TEXT))
    end
    self.editButton:SetEnabled(ZO_GroupFinder_CanDoCreateEdit(self.myListingData))
end
--------------------------------------------------------------
-- ZO_GroupFinder_ApplicationsList_Keyboard
--------------------------------------------------------------
ZO_GroupFinder_ApplicationsList_Keyboard = ZO_SortFilterList:Subclass()
function ZO_GroupFinder_ApplicationsList_Keyboard:Initialize(control, fragment)
    ZO_SortFilterList.Initialize(self, control)
    self.fragment = fragment
end
function ZO_GroupFinder_ApplicationsList_Keyboard:RegisterForEvents()
    GROUP_FINDER_APPLICATIONS_LIST_MANAGER:RegisterCallback("ApplicationsListUpdated", function() self:RefreshData() end)
    self.fragment:RegisterCallback("StateChange", function(...) self:OnStateChange(...) end)
end
function ZO_GroupFinder_ApplicationsList_Keyboard:InitializeSortFilterList(control)
    ZO_SortFilterList.InitializeSortFilterList(self, control)
    self.noApplicationsRow = control:GetNamedChild("NoApplicationsRow")
    self.noApplicationsRowMessage = self.noApplicationsRow:GetNamedChild("Message")
    self.masterList = {}
    local ROW_HEIGHT = 30
    ZO_ScrollList_AddDataType(self.list, APPLICATION_DATA, "ZO_GroupFinder_ApplicationsListRow_Keyboard", ROW_HEIGHT, function(entryControl, data) self:SetupGroupApplicationEntry(entryControl, data) end)
    self.sortFunction = function(listEntry1, listEntry2) return self:CompareApplications(listEntry1, listEntry2) end
    self.sortHeaderGroup:SelectHeaderByKey("GetEndTimeSeconds")
    ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
end
function ZO_GroupFinder_ApplicationsList_Keyboard:InitializeKeybindDescriptors()
    self.keybindStripDescriptor =
    {
        -- Reject Application
        {
            name = GetString(SI_GROUP_FINDER_REJECT_APPLICATION),
            keybind = "UI_SHORTCUT_NEGATIVE",
            visible = function()
                return self.mouseOverRow ~= nil
            end,
            enabled = function()
                local data = ZO_ScrollList_GetData(self.mouseOverRow)
                if data then
                    return not data:IsInPendingState()
                end
                return false
            end,
            callback = function()
                local data = ZO_ScrollList_GetData(self.mouseOverRow)
                if data then
                    RequestResolveGroupListingApplication(RESOLVE_GROUP_LISTING_APPLICATION_REQUEST_REJECT, data:GetCharacterId())
                end
            end,
        },
        -- Accept Application
        {
            name = GetString(SI_GROUP_FINDER_ACCEPT_APPLICATION),
            keybind = "UI_SHORTCUT_PRIMARY",
            visible = function()
                return self.mouseOverRow ~= nil
            end,
            enabled = function()
                local data = ZO_ScrollList_GetData(self.mouseOverRow)
                if data then
                    return not data:IsInPendingState()
                end
                return false
            end,
            callback = function()
                local data = ZO_ScrollList_GetData(self.mouseOverRow)
                if data then
                    RequestResolveGroupListingApplication(RESOLVE_GROUP_LISTING_APPLICATION_REQUEST_APPROVE, data:GetCharacterId())
                end
            end,
        },
    }
end
function ZO_GroupFinder_ApplicationsList_Keyboard:OnStateChange(oldState, newState)
    if newState == SCENE_FRAGMENT_SHOWING then
        KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
    elseif newState == SCENE_FRAGMENT_SHOWN then
        self:RefreshData()
        ZO_SetGroupFinderIsNewApplication(false)
    elseif newState == SCENE_FRAGMENT_HIDDEN then
        KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
    end
end
function ZO_GroupFinder_ApplicationsList_Keyboard:SetupGroupApplicationEntry(control, data)
    ZO_SortFilterList.SetupRow(self, control, data)
    --Order matters: AttachToList should be called before AssignApplicationData
    control.object:AttachToList(self)
end
--ZO_SortFilterList overrides
function ZO_GroupFinder_ApplicationsList_Keyboard:BuildMasterList()
    self.masterList = GROUP_FINDER_APPLICATIONS_LIST_MANAGER:GetApplicationsData()
    --If the master list is empty, show the empty row
    local hasEntries = #self.masterList > 0
    self.noApplicationsRow:SetHidden(hasEntries)
    KEYBIND_STRIP:UpdateKeybindButtonGroup(self.keybindStripDescriptor)
end
function ZO_GroupFinder_ApplicationsList_Keyboard:FilterScrollList()
    -- No real filtering...just show everything in the master list
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    ZO_ClearNumericallyIndexedTable(scrollData)
    for _, data in ipairs(self.masterList) do
        table.insert(scrollData, ZO_ScrollList_CreateDataEntry(APPLICATION_DATA, ZO_EntryData:New(data)))
    end
end
function ZO_GroupFinder_ApplicationsList_Keyboard:SortScrollList()
    if self.currentSortKey ~= nil and self.currentSortOrder ~= nil then
        local scrollData = ZO_ScrollList_GetDataList(self.list)
        table.sort(scrollData, self.sortFunction)
    end
    self:RefreshVisible()
end
function ZO_GroupFinder_ApplicationsList_Keyboard:RefreshData()
    if self.fragment:IsShowing() then
        ZO_SortFilterList.RefreshData(self)
    end
end
function ZO_GroupFinder_ApplicationsList_Keyboard:CompareApplications(listEntry1, listEntry2)
    return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, GROUP_FINDER_APPLICATIONS_LIST_ENTRY_SORT_KEYS, self.currentSortOrder)
end
function ZO_GroupFinder_ApplicationsList_Keyboard:SetNoApplicationsText(text)
    self.noApplicationsRowMessage:SetText(text)
end
function ZO_GroupFinder_ApplicationsList_Keyboard:Row_OnMouseDoubleClick(control, button)
    if button == MOUSE_BUTTON_INDEX_LEFT and self.mouseOverRow then
        local data = ZO_ScrollList_GetData(self.mouseOverRow)
        if data then
            RequestResolveGroupListingApplication(RESOLVE_GROUP_LISTING_APPLICATION_REQUEST_APPROVE, data:GetCharacterId())
        end
    end
end
-------------------------------------
--Group Finder Applications List Row
-------------------------------------
ZO_GroupFinder_ApplicationsListRow = ZO_InitializingObject:Subclass()
function ZO_GroupFinder_ApplicationsListRow:Initialize(control)
    control.object = self
    self.control = control
    self.background = control:GetNamedChild("BG")
    self.characterNameLabel = control:GetNamedChild("CharacterName")
    local roleControls =
    {
        [LFG_ROLE_DPS] = control:GetNamedChild("RoleDPS"),
        [LFG_ROLE_TANK] = control:GetNamedChild("RoleTank"),
        [LFG_ROLE_HEAL] = control:GetNamedChild("RoleHeal"),
    }
    self.roleControls = roleControls
    self.classIcon = control:GetNamedChild("ClassIcon")
    self.levelLabel = control:GetNamedChild("Level")
    self.championIcon = control:GetNamedChild("Champion")
    self.expiresLabel = control:GetNamedChild("Expires")
    self.noteControl = control:GetNamedChild("Note")
    --Create the shared input group
    self.inputGroup = ZO_MouseInputGroup:New(control)
    local function OnRowChildMouseExit()
        ClearTooltip(InformationTooltip)
    end
    --Set up the mouse over behavior for the character name
    local function OnCharacterNameMouseEnter(nameControl)
        if self.data then
            InitializeTooltip(InformationTooltip, nameControl, BOTTOMLEFT, 0, 0, TOPLEFT)
            SetTooltipText(InformationTooltip, self.data:GetDisplayName())
        end
    end
    self.characterNameLabel:SetHandler("OnMouseEnter", OnCharacterNameMouseEnter)
    self.characterNameLabel:SetHandler("OnMouseExit", OnRowChildMouseExit)
    self.inputGroup:Add(self.characterNameLabel, ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
    --Set up the mouse over behavior for the class icon
    local function OnClassIconMouseEnter(iconControl)
        if self.data then
            InitializeTooltip(InformationTooltip, iconControl, BOTTOM, 0, 0)
            SetTooltipText(InformationTooltip, self.data:GetClassName())
        end
    end
    self.classIcon:SetHandler("OnMouseEnter", OnClassIconMouseEnter)
    self.classIcon:SetHandler("OnMouseExit", OnRowChildMouseExit)
    self.inputGroup:Add(self.classIcon, ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
    
    --Set up the mouse over behavior for the role controls
    for roleType, roleControl in pairs(self.roleControls) do
        roleControl:SetHandler("OnMouseEnter", function()
            InitializeTooltip(InformationTooltip, roleControl, BOTTOM)
            SetTooltipText(InformationTooltip, GetString("SI_LFGROLE", roleType))
        end)
        roleControl:SetHandler("OnMouseExit", OnRowChildMouseExit)
        self.inputGroup:Add(roleControl, ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
    end
    --Set up the mouse over behavior for the note button
    local function OnNoteControlMouseEnter(noteControl)
        if self.data then
            InitializeTooltip(InformationTooltip, noteControl, BOTTOM, 0, 0)
            SetTooltipText(InformationTooltip, self.data:GetNote())
        end
    end
    self.noteControl:SetHandler("OnMouseEnter", OnNoteControlMouseEnter)
    self.noteControl:SetHandler("OnMouseExit", OnRowChildMouseExit)
    self.inputGroup:Add(self.noteControl, ZO_MOUSE_INPUT_GROUP_MOUSE_OVER)
    self.control:SetHandler("OnUpdate", function(_, currentTime) self:OnUpdate(currentTime) end)
end
function ZO_GroupFinder_ApplicationsListRow:OnUpdate(currentTime)
    if self.data then
        if self.data:IsInPendingState() then
            self.expiresLabel:SetText(GetString(SI_GROUP_FINDER_APPLICATION_PENDING))
        else
            self.expiresLabel:SetText(ZO_FormatTimeLargestTwo(self.data:GetTimeRemainingSeconds(), TIME_FORMAT_STYLE_DESCRIPTIVE_MINIMAL))
        end
    end
end
function ZO_GroupFinder_ApplicationsListRow:AttachToList(list)
    self.list = list
end
function ZO_GroupFinder_ApplicationsListRow:AssignApplicationData(data)
    self.data = data
    local level = data:GetLevel()
    local championPoints = data:GetChampionPoints()
    self.levelLabel:SetText(ZO_GetLevelOrChampionPointsStringNoIcon(level, championPoints))
    self.championIcon:SetHidden(championPoints == 0)
    self:SetupRoleControl(LFG_ROLE_DPS)
    self:SetupRoleControl(LFG_ROLE_HEAL)
    self:SetupRoleControl(LFG_ROLE_TANK)
    --Only show the note if there is one
    local note = data:GetNote()
    self.noteControl:SetHidden(note == "")
end
do
    local ROLE_SELECTION_TO_ICON = 
    {
        [LFG_ROLE_TANK] =
        {
            [true] = "EsoUI/Art/LFG/LFG_tank_down.dds",
            [false] = "EsoUI/Art/LFG/LFG_tank_disabled.dds",
        },
        [LFG_ROLE_HEAL] =
        {
            [true] = "EsoUI/Art/LFG/LFG_healer_down.dds",
            [false] = "EsoUI/Art/LFG/LFG_healer_disabled.dds",
        },
        [LFG_ROLE_DPS] =
        {
            [true] = "EsoUI/Art/LFG/LFG_dps_down.dds",
            [false] = "EsoUI/Art/LFG/LFG_dps_disabled.dds",
        },
    }
    function ZO_GroupFinder_ApplicationsListRow:SetupRoleControl(roleType)
        local assignedRole = self.data:GetRole()
        local enabled = roleType == assignedRole
        self.roleControls[roleType]:SetTexture(ROLE_SELECTION_TO_ICON[roleType][enabled])
    end
end
function ZO_GroupFinder_ApplicationsListRow:EnterRow()
end
function ZO_GroupFinder_ApplicationsListRow:ExitRow()
end
function ZO_GroupFinder_ApplicationsListRow:OnMouseUp(control, button, upInside)
    if button == MOUSE_BUTTON_INDEX_RIGHT and upInside then
        ClearMenu()
        if self.data then
            if not self.data:IsInPendingState() then
                AddMenuItem(GetString(SI_GROUP_FINDER_ACCEPT_APPLICATION), function() RequestResolveGroupListingApplication(RESOLVE_GROUP_LISTING_APPLICATION_REQUEST_APPROVE, self.data:GetCharacterId()) end)
                AddMenuItem(GetString(SI_GROUP_FINDER_REJECT_APPLICATION), function() RequestResolveGroupListingApplication(RESOLVE_GROUP_LISTING_APPLICATION_REQUEST_REJECT, self.data:GetCharacterId()) end)
            end
            if IsChatSystemAvailableForCurrentPlatform() then
                AddMenuItem(GetString(SI_SOCIAL_LIST_SEND_MESSAGE), function() StartChatInput("", CHAT_CHANNEL_WHISPER, self.data:GetDisplayName()) end)
            end
            AddMenuItem(GetString(SI_FRIEND_MENU_IGNORE), function() AddIgnore(self.data:GetDisplayName()) end)
            self.list:ShowMenu(control)
        end
    end
end
function ZO_GroupFinder_ApplicationsListRow:OnMouseDoubleClick(control, button)
end
--------------
--Global XML
---------------
    ZO_GroupFinder_ApplicationsListRow:New(control)
end
end