ESO Lua File v100011

ingame/contacts/keyboard/friendslist_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
-----------------
--Friends Manager
-----------------
local ZO_KeyboardFriendsListManager = ZO_SocialListKeyboard:Subclass()
function ZO_KeyboardFriendsListManager:New(control)
    local manager = ZO_SocialListKeyboard.New(self, control)
    manager:Initialize(control)
    return manager
end
function ZO_KeyboardFriendsListManager:Initialize(control)
    FRIENDS_LIST_MANAGER:AddList(self)
    control:SetHandler("OnEffectivelyHidden", function() self:OnEffectivelyHidden() end)
    self.lastUpdateTime = 0
    self.playerAlliance = GetUnitAlliance("player")
    self:SetEmptyText(GetString(SI_FRIENDS_LIST_PANEL_NO_FRIENDS_MESSAGE))
    self.sortHeaderGroup:SelectHeaderByKey("status")
    ZO_ScrollList_AddDataType(self.list, FRIEND_DATA, "ZO_FriendsListRow", 30, function(control, data) self:SetupRow(control, data) end)
    ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
    self.searchBox = GetControl(control, "SearchBox")
    self.searchBox:SetHandler("OnTextChanged", function() self:OnSearchTextChanged() end)
    self.sortFunction = function(listEntry1, listEntry2) return self:CompareFriends(listEntry1, listEntry2) end
        
    FRIENDS_LIST_SCENE = ZO_Scene:New("friendsList", SCENE_MANAGER)
    FRIENDS_LIST_SCENE:RegisterCallback("StateChange",  function(oldState, newState)
                                                            if(newState == SCENE_SHOWING) then      
                                                                self:PerformDeferredInitialization()
                                                                KEYBIND_STRIP:AddKeybindButtonGroup(self.staticKeybindStripDescriptor)
                                                                KEYBIND_STRIP:AddKeybindButtonGroup(self.keybindStripDescriptor)
                                                            elseif(newState == SCENE_HIDDEN) then      
                                                                KEYBIND_STRIP:RemoveKeybindButtonGroup(self.staticKeybindStripDescriptor)                                                          
                                                                KEYBIND_STRIP:RemoveKeybindButtonGroup(self.keybindStripDescriptor)
                                                            end
                                                        end)
end
function ZO_KeyboardFriendsListManager:PerformDeferredInitialization()
    if self.staticKeybindStripDescriptor ~= nil then return end
    self:RefreshData()
end
function ZO_KeyboardFriendsListManager:InitializeKeybindDescriptors()
    self.staticKeybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_CENTER,
        -- Add Friend
        {
            name = GetString(SI_FRIENDS_LIST_PANEL_ADD_FRIEND),
            keybind = "UI_SHORTCUT_PRIMARY",
        
            callback = function()
                ZO_Dialogs_ShowDialog("REQUEST_FRIEND")
            end,
        },
    }
    
    self.keybindStripDescriptor =
    {
        alignment = KEYBIND_STRIP_ALIGN_RIGHT,
        -- Whisper
        {
            name = GetString(SI_SOCIAL_LIST_PANEL_WHISPER),
            keybind = "UI_SHORTCUT_SECONDARY",
        
            callback = function()
                local data = ZO_ScrollList_GetData(self.mouseOverRow)
                StartChatInput("", CHAT_CHANNEL_WHISPER, data.displayName)
            end,
            visible = function()
                if(self.mouseOverRow) then
                    local data = ZO_ScrollList_GetData(self.mouseOverRow)
                    return data.hasCharacter and data.online
                end
                return false
            end
        },
        -- Invite to Group
        {
            name = GetString(SI_FRIENDS_LIST_PANEL_INVITE),
            keybind = "UI_SHORTCUT_TERTIARY",
        
            callback = function()
                local data = ZO_ScrollList_GetData(self.mouseOverRow)
                local NOT_SENT_FROM_CHAT = false
                local DISPLAY_INVITED_MESSAGE = true
                TryGroupInviteByName(data.characterName, NOT_SENT_FROM_CHAT, DISPLAY_INVITED_MESSAGE)
            end,
            visible = function()
                if(self.mouseOverRow) then
                    local data = ZO_ScrollList_GetData(self.mouseOverRow)
                    if(data.hasCharacter and data.online and data.alliance == self.playerAlliance) then                        
                        return true
                    end
                end
                return false
            end
        },  
    }    
end
function ZO_KeyboardFriendsListManager:OnEffectivelyHidden()
    ZO_Dialogs_ReleaseDialog("REQUEST_FRIEND")
end
function ZO_KeyboardFriendsListManager:OnNumOnlineChanged()
    if(FRIENDS_ONLINE) then
        FRIENDS_ONLINE:Update()
    end
end
function ZO_KeyboardFriendsListManager:OnNumTotalFriendsChanged()
    if(FRIENDS_ONLINE) then
        FRIENDS_ONLINE:Update()
    end
end
--Local XML
--------------
function ZO_KeyboardFriendsListManager:FriendsButton_OnMouseEnter(control)
    InitializeTooltip(InformationTooltip, control, TOPLEFT, 0, 0, BOTTOMRIGHT)
    SetTooltipText(InformationTooltip, zo_strformat(SI_FRIENDS_ONLINE_TOOLTIP, FRIENDS_LIST_MANAGER:GetNumOnline(), GetNumFriends()))
end
function ZO_KeyboardFriendsListManager:FriendsButton_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
function ZO_KeyboardFriendsListManager:FriendsButton_OnClicked(control)
    if(not ZO_Dialogs_IsShowingDialog()) then
        MAIN_MENU:ShowScene("friendsList")
    end
end
-----------------
-- Overrides from ZO_SortFilterList
function ZO_KeyboardFriendsListManager:BuildMasterList()
    -- The master list lives in the FRIENDS_LIST_MANAGER and is built there
end
function ZO_KeyboardFriendsListManager:FilterScrollList()
  
    local scrollData = ZO_ScrollList_GetDataList(self.list)
    ZO_ClearNumericallyIndexedTable(scrollData)
    
    local searchTerm = self:GetSearchTerm()
    local masterList = FRIENDS_LIST_MANAGER:GetMasterList()
    for i = 1, #masterList do
        local data = masterList[i]
        if(searchTerm == "" or FRIENDS_LIST_MANAGER:IsMatch(searchTerm, data)) then
            table.insert(scrollData, ZO_ScrollList_CreateDataEntry(FRIEND_DATA, data))
        end
    end    
end
function ZO_KeyboardFriendsListManager: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_KeyboardFriendsListManager:SetupRow(control, data)
    ZO_SortFilterList.SetupRow(self, control, data)
    FRIENDS_LIST_MANAGER:SetupFriendEntry(control, data) 
end
function ZO_KeyboardFriendsListManager:GetSearchTerm()
    return self.searchBox:GetText()
end
function ZO_KeyboardFriendsListManager:CompareFriends(listEntry1, listEntry2)
    return ZO_TableOrderingFunction(listEntry1.data, listEntry2.data, self.currentSortKey, FRIENDS_LIST_ENTRY_SORT_KEYS, self.currentSortOrder)
end
function ZO_KeyboardFriendsListManager:FriendsListRow_OnMouseUp(control, button, upInside)
    if(button == 2 and upInside) then
        ClearMenu()
        local data = ZO_ScrollList_GetData(control)
        if data then
            AddMenuItem(GetString(SI_SOCIAL_MENU_EDIT_NOTE),    function()
                                                                    ZO_Dialogs_ShowDialog("EDIT_NOTE", {displayName = data.displayName, note = data.note, changedCallback = FRIENDS_LIST_MANAGER:GetNoteEditedFunction()})
                                                                end)
            AddMenuItem(GetString(SI_SOCIAL_MENU_SEND_MAIL), function() MAIL_SEND:ComposeMailTo(data.displayName) end)
            if(data.hasCharacter and data.online) then
                AddMenuItem(GetString(SI_SOCIAL_LIST_SEND_MESSAGE), function() StartChatInput("", CHAT_CHANNEL_WHISPER, data.displayName) end)            
                if(data.alliance == self.playerAlliance) then
                    AddMenuItem(GetString(SI_SOCIAL_MENU_INVITE), function() 
                        local NOT_SENT_FROM_CHAT = false
                        local DISPLAY_INVITED_MESSAGE = true
                        TryGroupInviteByName(data.characterName, NOT_SENT_FROM_CHAT, DISPLAY_INVITED_MESSAGE) 
                    end)
                    AddMenuItem(GetString(SI_SOCIAL_MENU_JUMP_TO_PLAYER), function() JumpToFriend(data.displayName) end)
                end     
            end
            AddMenuItem(GetString(SI_FRIEND_MENU_REMOVE_FRIEND), function() ZO_Dialogs_ShowDialog("CONFIRM_REMOVE_FRIEND", {displayName = data.displayName}, {mainTextParams = {data.displayName}}) end)
            AddMenuItem(GetString(SI_FRIEND_MENU_IGNORE), function() AddIgnore(data.displayName) end)
        
            self:ShowMenu(control)
        end
    end
end
function ZO_KeyboardFriendsListManager:OnSearchTextChanged()
    self:RefreshFilters()
end
function ZO_KeyboardFriendsListManager:UnlockSelection()
    ZO_SortFilterList.UnlockSelection(self)
    self:RefreshVisible()
end
--Global XML
---------------
    FRIENDS_LIST:Row_OnMouseEnter(control)
end
    FRIENDS_LIST:Row_OnMouseExit(control)
end
function ZO_FriendsListRow_OnMouseUp(control, button, upInside)
    FRIENDS_LIST:FriendsListRow_OnMouseUp(control, button, upInside)
end
    FRIENDS_LIST:Note_OnMouseEnter(control)
end
    FRIENDS_LIST:Note_OnMouseExit(control)
end
    FRIENDS_LIST:Note_OnClicked(control, FRIENDS_LIST_MANAGER:GetNoteEditedFunction())
end
    FRIENDS_LIST:DisplayName_OnMouseEnter(control)
end
    FRIENDS_LIST:DisplayName_OnMouseExit(control)
end
    FRIENDS_LIST:Alliance_OnMouseEnter(control)
end
    FRIENDS_LIST:Alliance_OnMouseExit(control)
end
    FRIENDS_LIST:Status_OnMouseEnter(control)
end
    FRIENDS_LIST:Status_OnMouseExit(control)
end
    FRIENDS_LIST:Class_OnMouseEnter(control)
end
    FRIENDS_LIST:Class_OnMouseExit(control)
end
    FRIENDS_LIST:Veteran_OnMouseEnter(control)
end
    FRIENDS_LIST:Veteran_OnMouseExit(control)
end
    FRIENDS_LIST = ZO_KeyboardFriendsListManager:New(self)
end