ESO Lua File v100010

ingame/group/zo_group.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
-----------------
--Group List
-----------------
local ZO_GroupListManager = ZO_GroupListManager_Shared:Subclass()
local GROUP_DATA = 1
function ZO_GroupListManager:Initialize(control)
    self.noGroupRow = GetControl(control, "NoGroupRow")
    self.memberCount = GetControl(control, "GroupMembersCount")
    ZO_ScrollList_AddDataType(self.list, GROUP_DATA, "ZO_GroupListRow", 30, function(control, data) self:SetupGroupEntry(control, data) end)
    self.headers = {}
    local headersParent = GetControl(control, "Headers")
    local numHeaders = headersParent:GetNumChildren()
    for i = 1, numHeaders do
        self.headers[i] = headersParent:GetChild(i)
    end
    ZO_ScrollList_EnableHighlight(self.list, "ZO_ThinListHighlight")
    ZO_GroupListManager_Shared.Initialize(self, control)
end
function ZO_GroupListManager:New(control)
    local manager = ZO_GroupListManager_Shared.New(self, control)
    GROUP_LIST_SCENE = ZO_Scene:New("groupList", SCENE_MANAGER)
    GROUP_LIST_SCENE:RegisterCallback("StateChange",  function(oldState, newState)
                                                            if(newState == SCENE_SHOWING) then
                                                                KEYBIND_STRIP:AddKeybindButtonGroup(manager.keybindStripDescriptor)
                                                            elseif(newState == SCENE_HIDDEN) then
                                                                KEYBIND_STRIP:RemoveKeybindButtonGroup(manager.keybindStripDescriptor)
                                                            end
                                                        end)
    return manager
end
function ZO_GroupListManager:TryShowJumpToGroupLeaderPrompt()
    --The location of the group leader may not be available immediately
    if(self.pendingJumpToGroupLeaderPrompt) then
        local groupLeaderUnitTag = GetGroupLeaderUnitTag()
        local groupLeaderZoneName = GetUnitZone(groupLeaderUnitTag)
        if(groupLeaderZoneName ~= "") then
            self.pendingJumpToGroupLeaderPrompt = nil
            if(IsGroupMemberInRemoteRegion(groupLeaderUnitTag)) then
                if(CanJumpToGroupMember(groupLeaderUnitTag)) then
                    if(GetUnitZone("player") == groupLeaderZoneName) then
                        ZO_Dialogs_ShowDialog("JUMP_TO_GROUP_LEADER_OCCURANCE_PROMPT", nil, {mainTextParams = {groupLeaderZoneName}})
                    else
                        ZO_Dialogs_ShowDialog("JUMP_TO_GROUP_LEADER_WORLD_PROMPT", nil, {mainTextParams = {groupLeaderZoneName}})
                    end
                end
            end
        end
    end
end
function ZO_GroupListManager:InitializeKeybindDescriptors()
    self.keybindStripDescriptor =
    {
        -- Invite to Group
        {
            alignment = KEYBIND_STRIP_ALIGN_CENTER,
            name = GetString(SI_GROUP_WINDOW_INVITE_PLAYER),
            keybind = "UI_SHORTCUT_PRIMARY",
        
            callback = function()
                ZO_Dialogs_ShowDialog("GROUP_INVITE")
            end,
            visible = function()
                return self.groupSize == 0 or (self.playerIsLeader and self.groupSize < GROUP_SIZE_MAX)
            end
        },
        -- Whisper
        {
            alignment = KEYBIND_STRIP_ALIGN_RIGHT,
            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.characterName)
            end,
            visible = function()
                if(self.mouseOverRow) then
                    local data = ZO_ScrollList_GetData(self.mouseOverRow)
                    return not data.isPlayer and data.characterName and data.online
                end
                return false
            end
        },
        -- Leave Group
        {
            alignment = KEYBIND_STRIP_ALIGN_CENTER,
            name = GetString(SI_GROUP_LEAVE),
            keybind = "UI_SHORTCUT_NEGATIVE",
        
            callback = function()
                GroupLeave()
            end,
            visible = function()
                return self.groupSize and self.groupSize > 0
            end
        },
    }
end
function ZO_GroupListManager:OnEffectivelyHidden()
    ZO_Dialogs_ReleaseDialog("GROUP_INVITE")
end
function ZO_GroupListManager:GetRowColors(data, mouseIsOver)
    return ZO_SocialList.GetRowColors(self, data, mouseIsOver)
end
function ZO_GroupListManager:GroupListRow_OnMouseUp(control, button, upInside)
    if(button == 2 and upInside) then
        ClearMenu()
        local data = ZO_ScrollList_GetData(control)
        if data then
            if data.isPlayer then
                AddMenuItem(GetString(SI_GROUP_LIST_MENU_LEAVE_GROUP), function() GroupLeave() end)
            elseif data.online then
                AddMenuItem(GetString(SI_SOCIAL_LIST_PANEL_WHISPER), function() StartChatInput("", CHAT_CHANNEL_WHISPER, data.characterName) end)
                AddMenuItem(GetString(SI_SOCIAL_MENU_JUMP_TO_PLAYER), function() JumpToGroupMember(data.characterName) end)
            end
            if(self.playerIsLeader) then
                if data.isPlayer then
                    AddMenuItem(GetString(SI_GROUP_LIST_MENU_DISBAND_GROUP), function() GroupDisband() end)
                else
                    if data.online then
                        AddMenuItem(GetString(SI_GROUP_LIST_MENU_PROMOTE_TO_LEADER), function() GroupPromote(data.unitTag) end)
                    end
                    AddMenuItem(GetString(SI_GROUP_LIST_MENU_KICK_FROM_GROUP), function() GroupKick(data.unitTag) end)
                end
            end
            self:ShowMenu(control)
        end
    end
end
function ZO_GroupListManager:Status_OnMouseEnter(control)
    local row = control:GetParent()
    local data = ZO_ScrollList_GetData(row)
    if(data.leader) then
        InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
        SetTooltipText(InformationTooltip, GetString(SI_GROUP_LIST_PANEL_LEADER_TOOLTIP))
    end
    self:EnterRow(row)
end
function ZO_GroupListManager:Status_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
function ZO_GroupListManager:Role_OnMouseEnter(control)
    local row = control:GetParent()
    if(control.role) then
        InitializeTooltip(InformationTooltip, control, BOTTOM, 0, 0)
        SetTooltipText(InformationTooltip, GetString("SI_LFGROLE", control.role))
    end
    self:EnterRow(row)
end
function ZO_GroupListManager:Role_OnMouseExit(control)
    ClearTooltip(InformationTooltip)
end
--Global XML
---------------
    GROUP_LIST:Row_OnMouseEnter(control)
end
    GROUP_LIST:Row_OnMouseExit(control)
end
function ZO_GroupListRow_OnMouseUp(control, button, upInside)
    GROUP_LIST:GroupListRow_OnMouseUp(control, button, upInside)
end
    ZO_SocialList.Class_OnMouseEnter(GROUP_LIST, control)
end
    ZO_SocialList.Class_OnMouseExit(GROUP_LIST, control)
end
    GROUP_LIST:Status_OnMouseEnter(control)
end
    GROUP_LIST:Status_OnMouseExit(control)
end
    GROUP_LIST:Role_OnMouseEnter(control)
end
    GROUP_LIST:Role_OnMouseExit(control)
end
    GROUP_LIST = ZO_GroupListManager:New(self)
end