Back to Home

ESO Lua File v100019

ingame/contacts/keyboard/socialdialogs_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
--Request Friend Dialog
------------------------
local function RequestFriendDialogSetup(dialog, data)
    if(data and data.name) then
        GetControl(dialog, "NameEdit"):SetText(zo_strformat("<<1>>", data.name))
    else
        GetControl(dialog, "NameEdit"):SetText("")
    end
    GetControl(dialog, "MessageEdit"):SetText("")
end
    ZO_Dialogs_RegisterCustomDialog("REQUEST_FRIEND",   
    {
        customControl = self,
        setup = RequestFriendDialogSetup,
        title =
        {
            text = SI_REQUEST_FRIEND_DIALOG_TITLE,
        },        
        buttons =
        {
            [1] =
            {
                control =   GetControl(self, "Request"),
                text =      SI_REQUEST_FRIEND_DIALOG_REQUEST,
                callback =  function(dialog)
                                local name = GetControl(dialog, "NameEdit"):GetText()
                                local message = GetControl(dialog, "MessageEdit"):GetText()
                                if(name ~= "") then
                                    RequestFriend(name, message)
                                end
                            end,
            },
        
            [2] =
            {
                control =   GetControl(self, "Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
    local friendFields = ZO_RequiredTextFields:New()
    friendFields:AddButton(GetControl(self, "Request"))
    friendFields:AddTextField(GetControl(self, "NameEdit"))
end
--Edit Note Dialog
-------------------
local function EditNoteDialogSetup(dialog, data)
    GetControl(dialog, "DisplayName"):SetText(data.displayName)
    GetControl(dialog, "NoteEdit"):SetText(data.note)
end
    ZO_Dialogs_RegisterCustomDialog("EDIT_NOTE",   
    {
        customControl = self,
        setup = EditNoteDialogSetup,
        title =
        {
            text = SI_EDIT_NOTE_DIALOG_TITLE,
        },
        buttons =
        {
            [1] =
            {
                control =   GetControl(self, "Save"),
                text =      SI_SAVE,
                callback =  function(dialog)
                                local data = dialog.data
                                local note = GetControl(dialog, "NoteEdit"):GetText()
                                if(note ~= data.note) then
                                    data.changedCallback(data.displayName, note)
                                end
                            end,
            },
        
            [2] =
            {
                control =   GetControl(self, "Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
end
function ZO_EditNoteDialog_Hide(owner)
    if(not owner or ZO_EditNoteDialog.owner == owner) then
        ZO_EditNoteDialog:SetHidden(true)
    end
end
--Create Guild Dialog
---------------------
local function CreateGuildDialogSetup(dialog)
    local playerAlliance = GetUnitAlliance("player")
    local playerAllianceEntry = dialog.entries[playerAlliance]
    dialog.OnAllianceSelected(nil, nil, playerAllianceEntry)
    dialog.nameEdit:Clear()
end
    ZO_Dialogs_RegisterCustomDialog("CREATE_GUILD",   
    {
        title =
        {
            text = SI_PROMPT_TITLE_GUILD_CREATE,
        },
        customControl = self,
        setup = CreateGuildDialogSetup,
        buttons =
        {
            [1] =
            {
                control =   GetControl(self, "Create"),
                text =      SI_DIALOG_CREATE,
                callback =  function(dialog)
                                local guildName = dialog.nameEdit:GetText()
                                if(guildName and guildName ~= "") then
                                    GuildCreate(guildName, dialog.selectedAlliance)
                                end
                            end,
            },
        
            [2] =
            {
                control =   GetControl(self, "Cancel"),
                text =      SI_DIALOG_CANCEL,
            }
        }
    })
    
    local allianceComboBoxControl = GetControl(self, "Alliance")
    self.allianceComboBox = ZO_ComboBox_ObjectFromContainer(allianceComboBoxControl)
    self.allianceComboBox:SetSortsItems(false)
    self.allianceComboBox:SetFont("ZoFontHeader")
    self.allianceComboBox:SetSpacing(4)
    self.nameEdit = GetControl(self, "NameEdit")
    SetupEditControlForNameValidation(self.nameEdit)
    self.createButton = GetControl(self, "Create")
    self.OnAllianceSelected = function(_, entryText, entry)
        self.selectedAlliance = entry.alliance
        self.allianceComboBox:SetSelectedItemText(entry.allianceText)
    end
    self.entries = {}
    local playerAlliance = GetUnitAlliance("player")
    for i = 1, NUM_ALLIANCES do
        local allianceText = zo_iconTextFormat(GetAllianceBannerIcon(i), 24, 24, GetAllianceName(i))
        local entry = self.allianceComboBox:CreateItemEntry(allianceText, self.OnAllianceSelected)
        entry.alliance = i
        entry.allianceText = allianceText
          table.insert(self.entries, entry)
    end
    self.allianceComboBox:AddItem(self.entries[playerAlliance])
    for i = 1, NUM_ALLIANCES do
        if(i ~= playerAlliance) then
            self.allianceComboBox:AddItem(self.entries[i])
        end
    end
    local allianceRules = GetControl(self, "AllianceRules")
    allianceRules:SetText(zo_strformat(SI_GUILD_CREATE_DIALOG_ALLIANCE_RULES, GetAllianceName(playerAlliance)))
    local createGuildFields = ZO_RequiredTextFields:New()
    createGuildFields:AddButton(self.createButton)
    createGuildFields:SetBoolean("ValidName", false)
    self.createGuildFields = createGuildFields
    self.nameInstructions = ZO_ValidNameInstructions:New(GetControl(self, "NameInstructions"))
end
    local dialog = self:GetParent():GetParent()
    local violations = { IsValidGuildName(self:GetText()) }
    local noViolations = #violations == 0
    if noViolations then
        dialog.nameInstructions:Hide()
    else
        dialog.nameInstructions:Show(dialog.nameEdit, violations)
    end
    dialog.createGuildFields:SetBoolean("ValidName", noViolations)
end
    local dialog = self:GetParent():GetParent()    
    dialog.nameInstructions:Hide()
end
function ZO_GuildEditBox_FocusGained(editControl)
    if IsInGamepadPreferredMode() then
        ZO_GamepadEditBox_FocusGained(self)
    end
end
-- Report Player Confirmation Dialog
------------------------------------
local reasonToString =
{
    [REPORT_PLAYER_REASON_BEHAVIOR] = GetString(SI_DIALOG_BUTTON_REPORT_PLAYER),
    [REPORT_PLAYER_REASON_MAIL_SPAM] = GetString(SI_DIALOG_BUTTON_REPORT_MAIL_SPAM),
    [REPORT_PLAYER_REASON_CHAT_SPAM] = GetString(SI_DIALOG_BUTTON_REPORT_CHAT_SPAM),
    [REPORT_PLAYER_REASON_BOTTING] = GetString(SI_DIALOG_BUTTON_REPORT_BOTTING),
}
local function SetupReportDialog(dialog)
    dialog:GetNamedChild("Header"):SetText(zo_strformat(SI_DIALOG_TEXT_REPORT_PLAYER_MAIN, dialog.data.rawName))
    dialog:GetNamedChild("ReportSpam"):SetText(reasonToString[dialog.data.reason] or GetString(SI_DIALOG_BUTTON_REPORT_QUICK))
end
    ZO_Dialogs_RegisterCustomDialog("REPORT_PLAYER",
    {
        customControl = self,
        setup = SetupReportDialog,
        title =
        {
            text = SI_DIALOG_TITLE_REPORT_PLAYER,
        },
        buttons =
        {
            {
                keybind = "DIALOG_SECONDARY",
                control = self:GetNamedChild("OpenTicket"),
                text = reasonToString[REPORT_PLAYER_REASON_BEHAVIOR],
                callback = function(dialog)
                         HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD:OpenAskForHelp(CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_REPORT_PLAYER, CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_HARASSMENT, dialog.data.name)
                end,
            },
            {
                keybind = "DIALOG_PRIMARY",
                control = self:GetNamedChild("ReportSpam"),
                callback = function(dialog)
                    local data = dialog.data
                    HELP_CUSTOMER_SERVICE_ASK_FOR_HELP_KEYBOARD:OpenAskForHelp(CUSTOMER_SERVICE_ASK_FOR_HELP_CATEGORY_REPORT_PLAYER, CUSTOMER_SERVICE_ASK_FOR_HELP_REPORT_PLAYER_SUBCATEGORY_OTHER, data.name)
                    if(data.customCallback) then
                        data.customCallback()
                    end
                end,
            },
            {
                keybind = "DIALOG_NEGATIVE",
                control = self:GetNamedChild("Cancel"),
                text = SI_DIALOG_BUTTON_REPORT_CANCEL,
            },
        },
    })
    local function SetupFullWidthButtonBinds(button)
        button:SetUsingCustomAnchors(true)
        local keybind = button:GetNamedChild("KeyLabel")
        local label = button:GetNamedChild("NameLabel")
        keybind:ClearAnchors()
        keybind:SetAnchor(LEFT, button, LEFT, 10, 0)
        label:ClearAnchors()
        label:SetAnchor(LEFT, keybind, RIGHT, 15, 0)
    end
    SetupFullWidthButtonBinds(self:GetNamedChild("ReportSpam"))
    SetupFullWidthButtonBinds(self:GetNamedChild("OpenTicket"))
end
function ZO_ReportPlayerDialog_Show(playerName, reason, rawName, optionalCallback)
    ZO_Dialogs_ShowDialog("REPORT_PLAYER", {name = playerName, reason = reason, rawName = rawName or playerName, customCallback = optionalCallback})
end