forked from Daeymien/GuildTithe-Reborn
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathGuildTitheGUI.lua
More file actions
executable file
·342 lines (299 loc) · 16 KB
/
GuildTitheGUI.lua
File metadata and controls
executable file
·342 lines (299 loc) · 16 KB
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
338
339
340
341
342
-- New GUI based on AceGUI. Better adapts to ElvUI, easier to work with
local AceGUI = LibStub("AceGUI-3.0")
-- The main GUI window. This is replacing the original XML-based window with something much cleaner.
-- This window automatically skins itself for ElvUI, too, natively.
function GuildTitheReincarnated.DrawMainUIFrame()
if not GuildTithe_SavedDB.GUIIsShown then
GuildTitheReincarnated.GTSettingsFrame = AceGUI:Create("Frame")
GuildTitheReincarnated.GTSettingsFrame:SetCallback("OnClose",function(widget)
GuildTithe_SavedDB.GUIIsShown = false
AceGUI:Release(widget)
end)
GuildTitheReincarnated.GTSettingsFrame:SetPoint("CENTER", UIParent)
GuildTitheReincarnated.GTSettingsFrame:SetTitle("GuildTithe Options")
GuildTitheReincarnated.GTSettingsFrame:SetWidth(650)
if IsInGuild() then
GuildTitheReincarnated.GTSettingsFrame:SetHeight(730)
else
GuildTitheReincarnated.GTSettingsFrame:SetHeight(800) --increased height to display no-guild warning
end
GuildTitheReincarnated.GTSettingsFrame:SetStatusText(GuildTitheReincarnated.version)
GuildTitheReincarnated.GTSettingsFrame:SetLayout("Flow")
-- When we find that ESC press, we need to note that the GUI is hiding now.
local GTESCDetector = KeyPressFrame or CreateFrame("Frame", "KeyPressFrame", UIParent)
local function KeyInput(self, key)
if key == "ESCAPE" and GuildTithe_SavedDB.GUIIsShown == true then
GuildTithe_SavedDB.GUIIsShown = false
end
end
GTESCDetector:SetScript("OnKeyDown", KeyInput)
GTESCDetector:SetPropagateKeyboardInput(true)
-- Register with GUI to close when ESC pressed
_G["GTGUIFrame"] = GuildTitheReincarnated.GTSettingsFrame.frame
tinsert(UISpecialFrames, "GTGUIFrame")
-- Loot category checkboxes
local CheckboxHeader = AceGUI:Create("Heading")
CheckboxHeader:SetText("Allow Collection From")
CheckboxHeader:SetRelativeWidth(1.0)
GuildTitheReincarnated.GTSettingsFrame:AddChild(CheckboxHeader)
local QuestRewardsToggle = AceGUI:Create("CheckBox")
QuestRewardsToggle:SetType("checkbox")
QuestRewardsToggle:SetValue(GuildTithe_SavedDB.CollectFrom["Quest"])
QuestRewardsToggle:SetTriState(false)
QuestRewardsToggle:SetLabel("Quest Rewards")
QuestRewardsToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleCheckboxChange("Quest", value)
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(QuestRewardsToggle)
local LootedMoneyToggle = AceGUI:Create("CheckBox")
LootedMoneyToggle:SetType("checkbox")
LootedMoneyToggle:SetValue(GuildTithe_SavedDB.CollectFrom["Loot"])
LootedMoneyToggle:SetTriState(false)
LootedMoneyToggle:SetLabel("Looted Money")
LootedMoneyToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleCheckboxChange("Loot", value)
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(LootedMoneyToggle)
local MerchantsToggle = AceGUI:Create("CheckBox")
MerchantsToggle:SetValue(GuildTithe_SavedDB.CollectFrom["Merchant"])
MerchantsToggle:SetType("checkbox")
MerchantsToggle:SetTriState(false)
MerchantsToggle:SetLabel("Merchants")
MerchantsToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleCheckboxChange("Merchant", value)
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(MerchantsToggle)
local MailToggle = AceGUI:Create("CheckBox")
MailToggle:SetValue(GuildTithe_SavedDB.CollectFrom["Merchant"])
MailToggle:SetType("checkbox")
MailToggle:SetTriState(false)
MailToggle:SetLabel("Mail")
MailToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleCheckboxChange("Mail", value)
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(MailToggle)
local TradeToggle = AceGUI:Create("CheckBox")
TradeToggle:SetValue(GuildTithe_SavedDB.CollectFrom["Trade"])
TradeToggle:SetType("checkbox")
TradeToggle:SetTriState(false)
TradeToggle:SetLabel("Trade")
TradeToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleCheckboxChange("Trade", value)
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(TradeToggle)
local PercentagesHeader = AceGUI:Create("Heading")
PercentagesHeader:SetText("Percentage To Collect From")
PercentagesHeader:SetRelativeWidth(1.0)
GuildTitheReincarnated.GTSettingsFrame:AddChild(PercentagesHeader)
local QuestRewardsSlider = AceGUI:Create("Slider")
QuestRewardsSlider:SetSliderValues(0.01,1,0.01)
QuestRewardsSlider:SetValue(GuildTitheReincarnated.round(GuildTithe_SavedDB.CollectSource["Quest"])/100)
QuestRewardsSlider:SetCallback("OnMouseUp",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleSliderChange("Quest", math.floor((value*100)+0.5))
end
)
QuestRewardsSlider:SetRelativeWidth(1.0)
QuestRewardsSlider:SetIsPercent(true)
QuestRewardsSlider:SetLabel("Quest Rewards")
GuildTitheReincarnated.GTSettingsFrame:AddChild(QuestRewardsSlider)
local LootedMoneySlider = AceGUI:Create("Slider")
LootedMoneySlider:SetSliderValues(0.01,1,0.01)
LootedMoneySlider:SetValue(GuildTitheReincarnated.round(GuildTithe_SavedDB.CollectSource["Loot"])/100)
LootedMoneySlider:SetCallback("OnMouseUp",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleSliderChange("Loot", math.floor((value*100)+0.5))
end
)
LootedMoneySlider:SetRelativeWidth(1.0)
LootedMoneySlider:SetIsPercent(true)
LootedMoneySlider:SetLabel("Looted Money")
GuildTitheReincarnated.GTSettingsFrame:AddChild(LootedMoneySlider)
local MerchantsSlider = AceGUI:Create("Slider")
MerchantsSlider:SetSliderValues(0.01,1,0.01)
MerchantsSlider:SetValue(GuildTitheReincarnated.round(GuildTithe_SavedDB.CollectSource["Merchant"])/100)
MerchantsSlider:SetCallback("OnMouseUp",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleSliderChange("Merchant", math.floor((value*100)+0.5))
end
)
MerchantsSlider:SetRelativeWidth(1.0)
MerchantsSlider:SetIsPercent(true)
MerchantsSlider:SetLabel("Merchants")
GuildTitheReincarnated.GTSettingsFrame:AddChild(MerchantsSlider)
local MailSlider = AceGUI:Create("Slider")
MailSlider:SetSliderValues(0.01,1,0.01)
MailSlider:SetValue(GuildTitheReincarnated.round(GuildTithe_SavedDB.CollectSource["Mail"])/100)
MailSlider:SetCallback("OnMouseUp",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleSliderChange("Mail", math.floor((value*100)+0.5))
end
)
MailSlider:SetRelativeWidth(1.0)
MailSlider:SetIsPercent(true)
MailSlider:SetLabel("Mail")
GuildTitheReincarnated.GTSettingsFrame:AddChild(MailSlider)
local TradesSlider = AceGUI:Create("Slider")
TradesSlider:SetSliderValues(0.01,1,0.01)
TradesSlider:SetValue(GuildTitheReincarnated.round(GuildTithe_SavedDB.CollectSource["Trade"])/100)
TradesSlider:SetCallback("OnMouseUp",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleSliderChange("Trade", math.floor((value*100)+0.5))
end
)
TradesSlider:SetRelativeWidth(1.0)
TradesSlider:SetIsPercent(true)
TradesSlider:SetLabel("Trade")
GuildTitheReincarnated.GTSettingsFrame:AddChild(TradesSlider)
local DepositSettingsHeader = AceGUI:Create("Heading")
DepositSettingsHeader:SetText("Deposit Tithe To")
DepositSettingsHeader:SetRelativeWidth(1.0)
GuildTitheReincarnated.GTSettingsFrame:AddChild(DepositSettingsHeader)
-- Bottom Row
local BottomRowText = AceGUI:Create("SimpleGroup")
GuildTitheReincarnated.GTSettingsFrame:AddChild(BottomRowText)
-- Deposit Explainer
local DepositExplainer = AceGUI:Create("Label")
DepositExplainer:SetText("GuildTithe will deposit the accumulated tithe into the first enabled bank it encounters. By default, only the guild bank is selected.")
DepositExplainer:SetColor(1,1,1)
BottomRowText:AddChild(DepositExplainer)
-- No-guild warning
if not IsInGuild() then
local NoGuild = AceGUI:Create("Label")
NoGuild:SetText("This character is not in a guild. GuildTithe will do nothing if warband bank deposit is not enabled.")
NoGuild:SetColor(1,0,0)
BottomRowText:AddChild(NoGuild)
end
-- Deposit Settings Group
local DepositSettingsGroup = AceGUI:Create("SimpleGroup")
GuildTitheReincarnated.GTSettingsFrame:AddChild(DepositSettingsGroup)
-- Deposit settings checkboxes
local GuildDepositToggle = AceGUI:Create("CheckBox")
GuildDepositToggle:SetValue(GuildTithe_SavedDB.DepositToGuild)
GuildDepositToggle:SetType("checkbox")
GuildDepositToggle:SetTriState(false)
GuildDepositToggle:SetLabel("Guild Bank")
GuildDepositToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleDepositChange("Guild", value)
end
)
DepositSettingsGroup:AddChild(GuildDepositToggle)
local AccountDepositToggle = AceGUI:Create("CheckBox")
AccountDepositToggle:SetType("checkbox")
AccountDepositToggle:SetValue(GuildTithe_SavedDB.DepositToAccount)
AccountDepositToggle:SetTriState(false)
AccountDepositToggle:SetLabel("Warband Bank")
AccountDepositToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated:HandleDepositChange("Account", value)
end
)
DepositSettingsGroup:AddChild(AccountDepositToggle)
local CurrentTitheDisplay = AceGUI:Create("SFX-Info")
local TotalTitheDisplay = AceGUI:Create("SFX-Info")
local LastTitheAmountDisplay = AceGUI:Create("SFX-Info")
local LastTitheDisplayString, CurrentTitheDisplayString, TotalTitheDisplayString = ""
local function UpdateTitheDisplays()
-- Tithes
CurrentTitheDisplayString = GuildTitheReincarnated.PrettyPrint(GuildTithe_SavedDB.CurrentTithe, GuildTithe_SavedDB.PrettyLDB)
TotalTitheDisplayString = GuildTitheReincarnated.PrettyPrint(GuildTithe_SavedDB.TotalTithe, GuildTithe_SavedDB.PrettyLDB)
LastTitheDisplayString = GuildTitheReincarnated.PrettyPrint(GuildTithe_SavedDB.AmountOfLastDeposit, GuildTithe_SavedDB.PrettyLDB)
-- Last tithe deposited
if GuildTithe_SavedDB.AmountOfLastDeposit == -1 then
LastTitheDisplayString = "This tracking will begin with the next deposit."
else
LastTitheDisplayString = LastTitheDisplayString .. " (deposited to " .. GuildTithe_SavedDB.TypeOfLastDeposit .. ")"
end
CurrentTitheDisplay:SetText(CurrentTitheDisplayString)
TotalTitheDisplay:SetText(TotalTitheDisplayString)
LastTitheAmountDisplay:SetText(LastTitheDisplayString)
GuildTitheReincarnated.GTSettingsFrame:DoLayout()
end
local StatusDisplayHeader = AceGUI:Create("Heading")
StatusDisplayHeader:SetText("Tithes")
StatusDisplayHeader:SetRelativeWidth(1.0)
GuildTitheReincarnated.GTSettingsFrame:AddChild(StatusDisplayHeader)
-- Status Display
local StatusDisplay = AceGUI:Create("SimpleGroup")
GuildTitheReincarnated.GTSettingsFrame:AddChild(StatusDisplay)
UpdateTitheDisplays()
CurrentTitheDisplay:SetLabel("Current")
CurrentTitheDisplay:SetText(CurrentTitheDisplayString)
StatusDisplay:AddChild(CurrentTitheDisplay)
TotalTitheDisplay:SetLabel("Total")
TotalTitheDisplay:SetText(TotalTitheDisplayString)
StatusDisplay:AddChild(TotalTitheDisplay)
LastTitheAmountDisplay:SetLabel("Last Tithe")
LastTitheAmountDisplay:SetText(LastTitheDisplayString)
GuildTitheReincarnated.GTSettingsFrame:AddChild(LastTitheAmountDisplay)
local LastTitheDateDisplay = AceGUI:Create("SFX-Info")
LastTitheDateDisplay:SetLabel("Deposited")
if GuildTithe_SavedDB.TimeOfLastDeposit == -1 then
LastTitheDateDisplay:SetText("This tracking will begin with the next deposit.")
else
LastTitheDateDisplay:SetText(GuildTithe_SavedDB.TimeOfLastDeposit .. " (local time)")
end
GuildTitheReincarnated.GTSettingsFrame:AddChild(LastTitheDateDisplay)
-- Toggles Display
local TogglesHeader = AceGUI:Create("Heading")
TogglesHeader:SetText("Settings")
TogglesHeader:SetRelativeWidth(1.0)
GuildTitheReincarnated.GTSettingsFrame:AddChild(TogglesHeader)
-- Minimap button control
local MinimapButtonToggle = AceGUI:Create("CheckBox")
MinimapButtonToggle:SetValue(not GuildTithe_SavedDB.HideMinimapIcon) -- "yes" hides
MinimapButtonToggle:SetType("checkbox")
MinimapButtonToggle:SetTriState(false)
MinimapButtonToggle:SetLabel("Minimap Icon")
MinimapButtonToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated.ToggleMinimapIcon()
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(MinimapButtonToggle)
-- Pretty currency display control
local PrettyLDBModeToggle = AceGUI:Create("CheckBox")
PrettyLDBModeToggle:SetValue(GuildTithe_SavedDB.PrettyLDB) -- "yes" hides
PrettyLDBModeToggle:SetType("checkbox")
PrettyLDBModeToggle:SetTriState(false)
PrettyLDBModeToggle:SetLabel("Graphical Coin Strings")
PrettyLDBModeToggle:SetCallback("OnValueChanged",
function(widget,callbackName,value)
GuildTitheReincarnated.TogglePrettyLDB()
UpdateTitheDisplays()
end
)
GuildTitheReincarnated.GTSettingsFrame:AddChild(PrettyLDBModeToggle)
--About section
local ProjectInfo = AceGUI:Create("Heading")
ProjectInfo:SetText("Addon Info")
ProjectInfo:SetRelativeWidth(1.0)
GuildTitheReincarnated.GTSettingsFrame:AddChild(ProjectInfo)
local AuthorNameDisplay = AceGUI:Create("SFX-Info")
AuthorNameDisplay:SetLabel("Maintainer")
AuthorNameDisplay:SetText("Miragosa")
GuildTitheReincarnated.GTSettingsFrame:AddChild(AuthorNameDisplay)
local ProjectURLDisplay = AceGUI:Create("SFX-Info-URL")
ProjectURLDisplay:SetLabel("Source")
ProjectURLDisplay:SetText("https://github.com/raptormama/GuildTithe-Reincarnated")
ProjectURLDisplay:SetDisabled(false)
GuildTitheReincarnated.GTSettingsFrame:AddChild(ProjectURLDisplay)
local CurseURLDisplay = AceGUI:Create("SFX-Info-URL")
CurseURLDisplay:SetLabel("Curse")
CurseURLDisplay:SetText("https://www.curseforge.com/wow/addons/guildtithe-reincarnated")
CurseURLDisplay:SetDisabled(false)
GuildTitheReincarnated.GTSettingsFrame:AddChild(CurseURLDisplay)
GuildTithe_SavedDB.GUIIsShown = true
end
end