ESO Lua File v100011

ingame/guild/gamepad/guildroster_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
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
-----------------
-- Guild Roster
-----------------
ZO_GamepadGuildRosterManager = ZO_GamepadSocialListPanel:Subclass()
    GUILD_ROSTER_GAMEPAD = ZO_GamepadGuildRosterManager:New(control)
end
function ZO_GamepadGuildRosterManager:New(control)
    local panel = ZO_GamepadSocialListPanel.New(self, control)
    return panel
end
function ZO_GamepadGuildRosterManager:Initialize(control)
    ZO_GamepadSocialListPanel.Initialize(self, control)
    GUILD_ROSTER_MANAGER:AddList(self)
    self:SetupSort(GUILD_ROSTER_ENTRY_SORT_KEYS, "status", ZO_SORT_ORDER_DOWN)
    self:AddDataTemplate("ZO_GamepadGuildRosterRow", 64, function(control, data, selected) self:SetupRow(control, data, selected) end)
    self.sortHeaderGroup:SelectHeaderByKey("status")
    local ALWAYS_ANIMATE = true
    GUILD_ROSTER_GAMEPAD_FRAGMENT = ZO_FadeSceneFragment:New(control, ALWAYS_ANIMATE)
    GUILD_ROSTER_GAMEPAD_FRAGMENT:RegisterCallback("StateChange", function(oldState, newState)
                                                        if newState == SCENE_FRAGMENT_SHOWING then  
                                                            local FADE_IN = false
                                                            GAMEPAD_NAV_QUADRANT_1_BACKGROUND_FRAGMENT:FadeRightDivider(FADE_IN)
                                                        elseif newState == SCENE_FRAGMENT_SHOWN then
                                                            self:PerformDeferredInitialization()
                                                            self:ActivatePanel()
                                                        elseif newState == SCENE_FRAGMENT_HIDING then  
                                                            self:DeactivateAll()
                                                            local FADE_IN = true
                                                            GAMEPAD_NAV_QUADRANT_1_BACKGROUND_FRAGMENT:FadeRightDivider(FADE_IN)
                                                        end
                                                    end)
end
function ZO_GamepadGuildRosterManager:PerformDeferredInitialization()
    if self.keybindStripDescriptor ~= nil then return end
    self:RefreshData()
end
function ZO_GamepadGuildRosterManager:GetAddKeybind()
    local keybind  =  {
        name = GetString(SI_GUILD_INVITE_ACTION),
        keybind = "UI_SHORTCUT_SECONDARY",
        callback = function()
            local guildId = GUILD_ROSTER_MANAGER:GetGuildId()
            local name = GetGuildName(guildId)
            local dialogData = {guildId = guildId} 
            ZO_Dialogs_ShowGamepadDialog(GAMEPAD_GUILD_INVITE_DIALOG_NAME, dialogData, {mainTextParams = {name}})
        end,
        visible = function()
            return DoesPlayerHaveGuildPermission(GUILD_ROSTER_MANAGER:GetGuildId(), GUILD_PERMISSION_INVITE)
        end
    }
    return keybind
end
function ZO_GamepadGuildRosterManager:SetupRow(control, data, selected)
    self:ColorRow(control, data, selected)
    GUILD_ROSTER_MANAGER:SetupGuildMember(control, data, selected)
end
function ZO_GamepadGuildRosterManager:LayoutTooltip(tooltipManager, tooltip, data)
    local guildId = GUILD_ROSTER_MANAGER:GetGuildId()
    tooltipManager:LayoutGuildMember(tooltip, data.displayName, data.characterName, data.class, data.gender, guildId, data.rankIndex, data.note)
end
-----------------
-- Overrides from ZO_PagedList
function ZO_GamepadGuildRosterManager:BuildMasterList()
    -- The master list lives in the GUILD_ROSTER_MANAGER and is built there
end
function ZO_GamepadGuildRosterManager:FilterList()
    self:Clear()
    local searchTerm = self:GetSearchTerm()
    local masterList = GUILD_ROSTER_MANAGER:GetMasterList()
    for i = 1, #masterList do
        local data = masterList[i]
        if(searchTerm == "" or GUILD_ROSTER_MANAGER:IsMatch(searchTerm, data)) then
            self:AddEntry("ZO_GamepadGuildRosterRow", data)
        end
    end    
end
function ZO_GamepadGuildRosterManager:ColorRow(control, data, selected)
    local textColor, iconColor, textColor2 = self:GetRowColors(data, selected)
    GUILD_ROSTER_MANAGER:ColorRow(control, data, textColor, iconColor, textColor2)
end
-----------------
-- Options
-----------------
function ZO_GamepadGuildRosterManager:SetupOptions(socialData)
    self.socialData = socialData
    self.playerData = GUILD_ROSTER_MANAGER:GetPlayerData()
    self.playerAlliance = GUILD_ROSTER_MANAGER:GetPlayerAlliance()
    self.guildId = GUILD_ROSTER_MANAGER:GetGuildId()
    self.guildName = GUILD_ROSTER_MANAGER:GetGuildName()
    self.guildAlliance = GUILD_ROSTER_MANAGER:GetGuildAlliance()
    self.noteChangedCallback = GUILD_ROSTER_MANAGER:GetNoteEditedFunction()
end
function ZO_GamepadGuildRosterManager:BuildOptionsList(list)
    
    local guildId = self.guildId
    local data = self.socialData
    local dataIndex = data.index
    local playerData = self.playerData
    local playerIndex = playerData.index
    local rankIndex = data.rankIndex
    local playerRankIndex = playerData.rankIndex
    local playerHasHigherRank = playerRankIndex < rankIndex
    local playerIsGuildmaster = IsGuildRankGuildMaster(guildId, playerRankIndex)
    self:AddHeader(list, data.displayName)
    if(DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_PROMOTE)) then
        if(rankIndex > 1) then                
            if(playerRankIndex < (rankIndex - 1)) then
                self:AddOption(list, self:BuildPromoteOption())
            elseif(playerIsGuildmaster) then
                self:AddOption(list, self:BuildPromoteToGuildMasterOption())
            end
        end
    end
    if(DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_DEMOTE)) then
        if(rankIndex < GetNumGuildRanks(guildId)) then
            if(playerHasHigherRank) then
                self:AddOption(list, self:BuildDemoteOption())
            end
        end            
    end
    if(DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_REMOVE)) then
        if(playerHasHigherRank and playerIndex ~= dataIndex) then
            self:AddOption(list, self:BuildRemoveOption())
        end
    end
    if(DoesPlayerHaveGuildPermission(guildId, GUILD_PERMISSION_NOTE_EDIT)) then
    end
    if(dataIndex == playerIndex) then
    else
        if(data.hasCharacter and data.online) then
            self:AddOption(list, self:BuildWhisperOption())
            if(data.alliance == self.playerAlliance) then
                self:AddOption(list, self:BuildInviteToGroupOption())
                self:AddOption(list, self:BuildTravelToPlayerOption())
            end
        end
        if(not IsFriend(data.displayName)) then
            self:AddOption(list, self:BuildAddFriendOption())
        end
    end    
    
end
function ZO_GamepadGuildRosterManager:BuildPromoteOption()
    local callback = function() 
        GuildPromote(self.guildId, self.socialData.displayName); 
        PlaySound(SOUNDS.GUILD_ROSTER_PROMOTE)
        local newRank = self.socialData.rankIndex - 1
        if newRank > 0 then
            local rankText = GetGuildRankCustomName(self.guildId, newRank)
            local rankIcon = zo_iconFormat(GetFinalGuildRankTextureSmall(self.guildId, newRank), 24, 24)
            local alertText = zo_strformat(SI_GAMEPAD_GUILD_NOTIFY_PROMOTED, rankIcon, rankText)
            ZO_Alert(UI_ALERT_CATEGORY_ALERT, nil, alertText)
        end
    end
    return self:BuildOptionEntry(nil, SI_GUILD_PROMOTE, callback)
end
function ZO_GamepadGuildRosterManager:BuildPromoteToGuildMasterOption()
    local callback = function()
        local guildInfo = ZO_PrefixIconNameFormatter(ZO_GetAllianceIconUserAreaDataName(self.guildAlliance), self.guildName)
        local rankName = GetFinalGuildRankName(self.guildId, 2)
        ZO_Dialogs_ShowGamepadDialog("PROMOTE_TO_GUILDMASTER", {guildId = self.guildId, displayName = self.socialData.displayName}, { mainTextParams = { self.socialData.displayName, "", guildInfo, rankName}})  
    end
    return self:BuildOptionEntry(nil, SI_GUILD_PROMOTE, callback)
end
function ZO_GamepadGuildRosterManager:BuildDemoteOption()
    local callback = function()
        GuildDemote(self.guildId, self.socialData.displayName)
        PlaySound(SOUNDS.GUILD_ROSTER_DEMOTE)
        local newRank = self.socialData.rankIndex + 1
        if newRank <= GetNumGuildRanks(self.guildId) then
            local rankText = GetGuildRankCustomName(self.guildId, newRank)
            local rankIcon = zo_iconFormat(GetFinalGuildRankTextureSmall(self.guildId, newRank), 24, 24)
            local alertText = zo_strformat(SI_GAMEPAD_GUILD_NOTIFY_DEMOTED, rankIcon, rankText)
            ZO_Alert(UI_ALERT_CATEGORY_ALERT, nil, alertText)
        end
    end
    return self:BuildOptionEntry(nil, SI_GUILD_DEMOTE, callback)
end
function ZO_GamepadGuildRosterManager:BuildRemoveOption()
    local callback = function()
        local guildInfo = ZO_PrefixIconNameFormatter(ZO_GetAllianceIconUserAreaDataName(self.guildAlliance), self.guildName)
          ZO_Dialogs_ShowGamepadDialog("GUILD_REMOVE_MEMBER", {guildId = self.guildId,  displayName = self.socialData.displayName}, { mainTextParams = { self.socialData.displayName, "", guildInfo }})                                                                
    end
    return self:BuildOptionEntry(nil, SI_GUILD_REMOVE, callback)
end
function ZO_GamepadGuildRosterManager:BuildLeaveGuildOption()
    local callback = function()
        local data = {
            hideSceneOnLeave = true
        }   
        local IS_GAMEPAD = true
        ZO_ShowLeaveGuildDialog(self.guildId, data, IS_GAMEPAD)
    end
    return self:BuildOptionEntry(nil, SI_GUILD_LEAVE, callback)
end
function ZO_GamepadGuildRosterManager:BuildAddFriendOption()
    local callback = function()
        local data = {
            displayName = self.socialData.displayName,
        }
        ZO_Dialogs_ShowGamepadDialog(GAMEPAD_SOCIAL_ADD_FRIEND_DIALOG_NAME, data)
    end
    return self:BuildOptionEntry(nil, SI_SOCIAL_MENU_ADD_FRIEND, callback)
end
function ZO_GamepadGuildRosterManager:BuildShowGamerCardOption()
    if(IsConsoleUI()) then
        local callback = function()
            local accountId = GetGuildMemberAccountId(self.guildId, self.socialData.index)
            ShowGamerCardFromAccountId(accountId)
        end
        return self:BuildOptionEntry(nil, GetGamerCardStringId(), callback)
    end
end