forked from stpain/guildbook
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dialogs.lua
337 lines (299 loc) · 10.9 KB
/
Dialogs.lua
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
--[==[
Copyright ©2020 Samuel Thomas Pain
The contents of this addon, excluding third-party resources, are
copyrighted to their authors with all rights reserved.
This addon is free to use and the authors hereby grants you the following rights:
1. You may make modifications to this addon for private use only, you
may not publicize any portion of this addon.
2. Do not modify the name of this addon, including the addon folders.
3. This copyright notice shall be included in all copies or substantial
portions of the Software.
All rights not explicitly addressed in this license are reserved by
the copyright holders.
]==]--
local addonName, Guildbook = ...
local L = Guildbook.Locales
local PRINT = Guildbook.PRINT
StaticPopupDialogs['Error'] = {
text = '|cffC41F3BError|r: %s',
button1 = 'Yes',
--button2 = 'Cancel',
OnAccept = function(self, data)
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['Reload'] = {
text = 'Settings have changed and a UI reload is required!',
button1 = 'Reload UI',
--button2 = 'Cancel',
OnAccept = function(self)
ReloadUI()
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['GuildbookDeleteGuild'] = {
text = 'Delete all data for %s',
button1 = 'Yes',
button2 = 'Cancel',
OnAccept = function(self, data)
GUILDBOOK_GLOBAL['GuildRosterCache'][data.Guild] = nil
GUILDBOOK_GLOBAL['Calendar'][data.Guild] = nil
GUILDBOOK_GLOBAL['CalendarDeleted'][data.Guild] = nil
print('All data for '..data.Guild..' deleted')
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['GuildbookResetCharacter'] = {
text = 'Reset data for '..select(1, UnitName("player"))..' to default values?',
button1 = 'Reset',
button2 = 'Cancel',
OnAccept = function(self)
wipe(GUILDBOOK_CHARACTER)
local guildName = Guildbook:GetGuildName()
if GUILDBOOK_GLOBAL and GUILDBOOK_GLOBAL['GuildRosterCache'] and GUILDBOOK_GLOBAL['GuildRosterCache'][guildName] then
GUILDBOOK_GLOBAL['GuildRosterCache'][guildName][UnitGUID('player')] = nil
end
GUILDBOOK_CHARACTER = Guildbook.Data.DefaultCharacterSettings
Guildbook.DEBUG("error", "ResetCharacterData", "set character saved var table to default values")
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['GuildbookResetCacheCharacter'] = {
text = 'Reset data for %s?',
button1 = 'Reset',
button2 = 'Cancel',
OnAccept = function(self, t)
wipe(GUILDBOOK_CHARACTER)
local guildName = Guildbook:GetGuildName()
if GUILDBOOK_GLOBAL and GUILDBOOK_GLOBAL['GuildRosterCache'] and GUILDBOOK_GLOBAL['GuildRosterCache'][guildName] then
GUILDBOOK_GLOBAL['GuildRosterCache'][guildName][t.guid] = nil
end
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['GuildbookResetGlobalSettings'] = {
text = 'Reset global settings to default values? \n\nThis will delete all data about all guilds you are a member of.',
button1 = 'Reset',
button2 = 'Cancel',
OnAccept = function(self)
if GUILDBOOK_GLOBAL then
wipe(GUILDBOOK_GLOBAL)
GUILDBOOK_GLOBAL = Guildbook.Data.DefaultGlobalSettings
GuildbookOptionsDebugCB:SetChecked(GUILDBOOK_GLOBAL['Debug'])
end
ReloadUI()
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['GuildbookGatheringDatabaseEditObject'] = {
text = '-',
button1 = 'Update',
button2 = 'Cancel',
hasEditBox = true,
OnShow = function(self)
self.button1:Disable()
end,
EditBoxOnTextChanged = function(self)
if self:GetText() ~= '' then
if(self:GetText():match("%W")) then
self:GetParent().button1:Disable()
end
self:GetParent().button1:Enable()
end
end,
OnAccept = function(self, data, data2) --data is the gameObject and data2 is the key within the object
if tostring(type(data[data2])) == 'number' then
data[data2] = tonumber(self.editBox:GetText())
else
data[data2] = tostring(self.editBox:GetText())
end
PRINT(Guildbook.FONT_COLOUR, tostring('updated game object field: '..data2..' with new value: '..self.editBox:GetText()))
Guildbook.OptionsInterface.GatheringDatabase.RefreshListView()
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['MainCharacterAddAltCharacter'] = {
text = L["DIALOG_MAIN_CHAR_ADD"],
button1 = 'Update',
button2 = 'Cancel',
hasEditBox = true,
OnShow = function(self)
self.button1:Disable()
end,
EditBoxOnTextChanged = function(self)
if self:GetText() ~= '' then
local guid = Guildbook:GetGuildMemberGUID(self:GetText())
local dialogText = _G[self:GetParent():GetName().."Text"]
if guid then
local character = Guildbook:GetCharacterFromCache(guid)
dialogText:SetText(string.format(L["DIALOG_MAIN_CHAR_ADD_FOUND"], character.Name, character.Level, L[character.Class]))
self:GetParent().button1:Enable()
else
dialogText:SetText(L["DIALOG_MAIN_CHAR_ADD"])
self:GetParent().button1:Disable()
end
end
end,
-- will look at having this just set the alt/main stuff when my brain is working, for now it just adds the guid to the alt characters table where it can then be set
OnAccept = function(self)
local guid = Guildbook:GetGuildMemberGUID(self.editBox:GetText())
if guid then
GUILDBOOK_GLOBAL.myCharacters[guid] = true
end
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['MainCharacterRemoveAltCharacter'] = {
text = L["DIALOG_MAIN_CHAR_REMOVE"],
button1 = 'Update',
button2 = 'Cancel',
hasEditBox = true,
OnShow = function(self)
self.button1:Disable()
end,
EditBoxOnTextChanged = function(self)
if self:GetText() ~= '' then
local guid = Guildbook:GetGuildMemberGUID(self:GetText())
local dialogText = _G[self:GetParent():GetName().."Text"]
if guid then
local character = Guildbook:GetCharacterFromCache(guid)
dialogText:SetText(string.format(L["DIALOG_MAIN_CHAR_ADD_FOUND"], character.Name, character.Level, L[character.Class]))
self:GetParent().button1:Enable()
else
dialogText:SetText(L["DIALOG_MAIN_CHAR_REMOVE"])
self:GetParent().button1:Disable()
end
end
end,
OnAccept = function(self)
local guid = Guildbook:GetGuildMemberGUID(self.editBox:GetText())
if guid then
GUILDBOOK_GLOBAL.myCharacters[guid] = nil
end
end,
OnCancel = function(self)
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
}
StaticPopupDialogs['GuildbookUpdateAvailable'] = {
text = 'Guildbook: %s',
button1 = 'OK',
hasEditBox = true,
OnShow = function(self)
--self.icon:SetTexture(132049)
self.icon:SetTexture(nil)
self.editBox:SetMaxLetters(50)
--self.editBox:SetWidth(300)
self.editBox:SetText('https://www.curseforge.com/wow/addons/guildbook')
self.editBox:HighlightText()
end,
OnAccept = function(self)
end,
}
StaticPopupDialogs['GuildbookUpdates'] = {
text = 'Guildbook Version: %s\n\n'..L["UPDATE_NEWS"],
button1 = L["DIALOG_SHOW_UPDATES"],
button2 = L["DIALOG_DONT_SHOW_UPDATES"],
OnAccept = function(self)
GUILDBOOK_GLOBAL.showUpdateNews = true;
end,
OnCancel = function(self)
GUILDBOOK_GLOBAL.showUpdateNews = false;
end,
timeout = 0,
whileDead = true,
hideOnEscape = false,
preferredIndex = 3,
showAlert = true,
}
---this popup was an attempt at having the addon auto scan a players professions
---its not used at the moment as there is a slight 'clunk' during log in and i wasnt happy with it
StaticPopupDialogs['GuildbookFirstLoad'] = {
text = L["DIALOG_CHARACTER_FIRST_LOAD"],
button1 = "",
OnShow = function(self, t)
local button1 = _G[self:GetName().."Button1"]
button1:Click()
end,
OnAccept = function(self, t)
local engProf = Guildbook:GetEnglishProf(GUILDBOOK_CHARACTER.Profession1)
if engProf == "Skinning" or engProf == "Herbalism" then
else
CastSpellByName(engProf)
C_Timer.After(0.01, function()
if TradeSkillFrame and TradeSkillFrame:IsVisible() then
TradeSkillFrameCloseButton:Click()
end
if CraftFrame and CraftFrame:IsVisible() then
CraftFrameCloseButton:Click()
end
if GUILDBOOK_CHARACTER and GUILDBOOK_CHARACTER.Profession2 then
local engProf = Guildbook:GetEnglishProf(GUILDBOOK_CHARACTER.Profession2)
if engProf == "Skinning" or engProf == "Herbalism" then
else
CastSpellByName(engProf)
C_Timer.After(0.01, function()
if TradeSkillFrame and TradeSkillFrame:IsVisible() then
TradeSkillFrameCloseButton:Click()
end
if CraftFrame and CraftFrame:IsVisible() then
CraftFrameCloseButton:Click()
end
end)
end
end
end)
end
end,
}
---this popup is used to confirm the user wants to remove a tradeskill recipe item from the loaded profession
---its a plaster to fix an issue of items loading into the wrong professions
StaticPopupDialogs['GuildbookDeleteRecipeFromCharacters'] = {
text = "%s",
button1 = "OK",
button2 = "Cancel",
OnAccept = function(self, t)
if t.itemLink and t.characters then
for _, guid in ipairs(t.characters) do
local character = Guildbook:GetCharacterFromCache(guid)
if character and character[t.prof] then
--character[t.prof][t.recipeID] = nil;
print(string.format("removed %s from %s for %s, with index %s", t.itemLink, character.Name, t.prof, t.listviewIndex))
end
end
--t.listview.DataProvider:Removeindex(t.listviewIndex)
end
end,
}