-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathNSUI.lua
More file actions
256 lines (234 loc) · 14 KB
/
NSUI.lua
File metadata and controls
256 lines (234 loc) · 14 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
local _, NSI = ...
local DF = _G["DetailsFramework"]
-- Get references from Core module
local Core = NSI.UI.Core
local NSUI = Core.NSUI
local window_width = Core.window_width
local window_height = Core.window_height
local TABS_LIST = Core.TABS_LIST
local authorsString = Core.authorsString
local options_text_template = Core.options_text_template
local options_dropdown_template = Core.options_dropdown_template
local options_switch_template = Core.options_switch_template
local options_slider_template = Core.options_slider_template
local options_button_template = Core.options_button_template
-- Get UI builder functions from modules
local BuildVersionCheckUI = NSI.UI.VersionCheck.BuildVersionCheckUI
local BuildNicknameEditUI = NSI.UI.Nicknames.BuildNicknameEditUI
local BuildRemindersEditUI = NSI.UI.Reminders.BuildRemindersEditUI
local BuildPersonalRemindersEditUI = NSI.UI.Reminders.BuildPersonalRemindersEditUI
local BuildCooldownsEditUI = NSI.UI.Cooldowns.BuildCooldownsEditUI
local BuildPASoundEditUI = NSI.UI.PrivateAuras.BuildPASoundEditUI
local BuildExportStringUI = NSI.UI.General.BuildExportStringUI
local BuildImportStringUI = NSI.UI.General.BuildImportStringUI
-- Get options builders from modules
local BuildGeneralOptions = NSI.UI.Options.General.BuildOptions
local BuildGeneralCallback = NSI.UI.Options.General.BuildCallback
local BuildNicknamesOptions = NSI.UI.Options.Nicknames.BuildOptions
local BuildNicknamesCallback = NSI.UI.Options.Nicknames.BuildCallback
local BuildSetupManagerOptions = NSI.UI.Options.SetupManager.BuildOptions
local BuildSetupManagerCallback = NSI.UI.Options.SetupManager.BuildCallback
local BuildReminderOptions = NSI.UI.Options.Reminders.BuildOptions
local BuildReminderNoteOptions = NSI.UI.Options.Reminders.BuildNoteOptions
local BuildReminderCallback = NSI.UI.Options.Reminders.BuildCallback
local BuildReminderNoteCallback = NSI.UI.Options.Reminders.BuildNoteCallback
local BuildAssignmentsOptions = NSI.UI.Options.Assignments.BuildOptions
local BuildAssignmentsCallback = NSI.UI.Options.Assignments.BuildCallback
local BuildEncounterAlertsOptions = NSI.UI.Options.EncounterAlerts.BuildOptions
local BuildEncounterAlertsCallback = NSI.UI.Options.EncounterAlerts.BuildCallback
local BuildReadyCheckOptions = NSI.UI.Options.ReadyCheck.BuildOptions
local BuildRaidBuffMenu = NSI.UI.Options.ReadyCheck.BuildRaidBuffMenu
local BuildReadyCheckCallback = NSI.UI.Options.ReadyCheck.BuildCallback
local BuildPrivateAurasOptions = NSI.UI.Options.PrivateAuras.BuildOptions
local BuildPrivateAurasCallback = NSI.UI.Options.PrivateAuras.BuildCallback
local BuildQoLOptions = NSI.UI.Options.QoL.BuildOptions
local BuildQoLCallback = NSI.UI.Options.QoL.BuildCallback
local BuildWAImportsOptions = NSI.UI.Options.WAImports.BuildOptions
local BuildWACallback = NSI.UI.Options.WAImports.BuildCallback
function NSUI:Init()
NSI.IsBuilding = true
-- Create the scale bar
DF:CreateScaleBar(NSUI, NSRT.NSUI)
local scale = math.max(NSRT.NSUI.scale, 0.6) -- prevent negative numbers
NSUI:SetScale(scale)
-- Create the tab container
local tabContainer = DF:CreateTabContainer(NSUI, "Northern Sky", "NSUI_TabsTemplate", TABS_LIST, {
width = window_width,
height = window_height - 5,
backdrop_color = { 0, 0, 0, 0.2 },
backdrop_border_color = { 0.1, 0.1, 0.1, 0.4 }
})
tabContainer:SetPoint("CENTER", NSUI, "CENTER", 0, 0)
NSUI.MenuFrame = tabContainer -- Store reference for later access
-- Get tab frames
local general_tab = tabContainer:GetTabFrameByName("General")
local nicknames_tab = tabContainer:GetTabFrameByName("Nicknames")
local cooldowns_tab = tabContainer:GetTabFrameByName("Cooldowns")
local versions_tab = tabContainer:GetTabFrameByName("Versions")
local setupmanager_tab = tabContainer:GetTabFrameByName("SetupManager")
local reminder_tab = tabContainer:GetTabFrameByName("Reminders")
local reminder_note_tab = tabContainer:GetTabFrameByName("Reminders-Note")
local assignments_tab = tabContainer:GetTabFrameByName("Assignments")
local encounteralerts_tab = tabContainer:GetTabFrameByName("EncounterAlerts")
local readycheck_tab = tabContainer:GetTabFrameByName("ReadyCheck")
local privateaura_tab = tabContainer:GetTabFrameByName("PrivateAura")
local QoL_tab = tabContainer:GetTabFrameByName("QoL")
local WAImports_tab = tabContainer:GetTabFrameByName("WAImports")
-- Generic text display
NSI.NSRTFrame.generic_display = CreateFrame("Frame", nil, NSI.NSRTFrame, "BackdropTemplate")
NSI.NSRTFrame.generic_display:Hide()
NSI.NSRTFrame.generic_display:SetPoint(NSRT.Settings.GenericDisplay.Anchor, NSI.NSRTFrame, NSRT.Settings.GenericDisplay.relativeTo, NSRT.Settings.GenericDisplay.xOffset, NSRT.Settings.GenericDisplay.yOffset)
NSI.NSRTFrame.generic_display.Text = NSI.NSRTFrame.generic_display:CreateFontString(nil, "OVERLAY")
NSI.NSRTFrame.generic_display.Text:SetFont(NSI.LSM:Fetch("font", NSRT.Settings.GlobalFont), NSRT.Settings.GlobalFontSize, "OUTLINE")
NSI.NSRTFrame.generic_display.Text:SetPoint("TOPLEFT", NSI.NSRTFrame.generic_display, "TOPLEFT", 0, 0)
NSI.NSRTFrame.generic_display.Text:SetJustifyH("LEFT")
NSI.NSRTFrame.generic_display.Text:SetText("Things that might be displayed here:\nReady Check Module\nAssignments on Pull\n")
NSI.NSRTFrame.generic_display:SetSize(NSI.NSRTFrame.generic_display.Text:GetStringWidth(), NSI.NSRTFrame.generic_display.Text:GetStringHeight())
NSI:MoveFrameInit(NSI.NSRTFrame.generic_display, "Generic")
-- Frame to display secret text
NSI.NSRTFrame.SecretDisplay = CreateFrame("Frame", nil, NSI.NSRTFrame, "BackdropTemplate")
NSI.NSRTFrame.SecretDisplay:Hide()
NSI.NSRTFrame.SecretDisplay:SetPoint(NSRT.Settings.GenericDisplay.Anchor, NSI.NSRTFrame, NSRT.Settings.GenericDisplay.relativeTo, NSRT.Settings.GenericDisplay.xOffset, NSRT.Settings.GenericDisplay.yOffset)
NSI.NSRTFrame.SecretDisplay.Text = NSI.NSRTFrame.SecretDisplay:CreateFontString(nil, "OVERLAY")
NSI.NSRTFrame.SecretDisplay.Text:SetFont(NSI.LSM:Fetch("font", NSRT.Settings.GlobalFont), NSRT.Settings.GlobalEncounterFontSize, "OUTLINE")
NSI.NSRTFrame.SecretDisplay.Text:SetPoint("TOPLEFT", NSI.NSRTFrame.generic_display, "TOPLEFT", 0, 0)
NSI.NSRTFrame.SecretDisplay.Text:SetJustifyH("LEFT")
NSI.NSRTFrame.SecretDisplay.Text:SetText("")
NSI.NSRTFrame.SecretDisplay:SetSize(2000, 2000)
-- Build options tables from modules
local general_options1_table = BuildGeneralOptions()
local nicknames_options1_table = BuildNicknamesOptions()
local setupmanager_options1_table = BuildSetupManagerOptions()
local reminder_options1_table = BuildReminderOptions()
local reminder_note_options1_table = BuildReminderNoteOptions()
local assignments_options1_table = BuildAssignmentsOptions()
local encounteralerts_options1_table = BuildEncounterAlertsOptions()
local readycheck_options1_table = BuildReadyCheckOptions()
local RaidBuffMenu = BuildRaidBuffMenu()
local privateaura_options1_table = BuildPrivateAurasOptions()
local QoL_options1_table = BuildQoLOptions()
local WAImports_options1_table = BuildWAImportsOptions()
-- Build callbacks
local general_callback = BuildGeneralCallback()
local nicknames_callback = BuildNicknamesCallback()
local setupmanager_callback = BuildSetupManagerCallback()
local reminder_callback = BuildReminderCallback()
local reminder_note_callback = BuildReminderNoteCallback()
local assignments_callback = BuildAssignmentsCallback()
local encounteralerts_callback = BuildEncounterAlertsCallback()
local readycheck_callback = BuildReadyCheckCallback()
local privateaura_callback = BuildPrivateAurasCallback()
local QoL_callback = BuildQoLCallback()
local WAImports_callback = BuildWACallback()
-- Build options menu for each tab
DF:BuildMenu(general_tab, general_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
general_callback)
DF:BuildMenu(nicknames_tab, nicknames_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
nicknames_callback)
DF:BuildMenu(setupmanager_tab, setupmanager_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
setupmanager_callback)
DF:BuildMenu(reminder_tab, reminder_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
reminder_callback)
DF:BuildMenu(reminder_note_tab, reminder_note_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
reminder_note_callback)
DF:BuildMenu(assignments_tab, assignments_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
assignments_callback)
DF:BuildMenu(encounteralerts_tab, encounteralerts_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
encounteralerts_callback)
DF:BuildMenu(readycheck_tab, readycheck_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
readycheck_callback)
DF:BuildMenu(NSI.RaidBuffCheck, RaidBuffMenu, 2, -30, 40, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
nil)
DF:BuildMenu(privateaura_tab, privateaura_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
privateaura_callback)
DF:BuildMenu(QoL_tab, QoL_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
QoL_callback)
DF:BuildMenu(WAImports_tab, WAImports_options1_table, 10, -100, window_height - 10, false, options_text_template,
options_dropdown_template, options_switch_template, true, options_slider_template, options_button_template,
WAImports_callback)
NSI.RaidBuffCheck:SetMovable(false)
NSI.RaidBuffCheck:EnableMouse(false)
-- Build UI components from modules
NSUI.version_scrollbox = BuildVersionCheckUI(versions_tab)
NSUI.nickname_frame = BuildNicknameEditUI()
NSUI.cooldowns_frame = BuildCooldownsEditUI()
NSUI.reminders_frame = BuildRemindersEditUI()
NSUI.pasound_frame = BuildPASoundEditUI()
NSUI.personal_reminders_frame = BuildPersonalRemindersEditUI()
NSUI.export_string_popup = BuildExportStringUI()
NSUI.import_string_popup = BuildImportStringUI()
-- Version Number in status bar
local versionNumber = " v"..C_AddOns.GetAddOnMetadata("NorthernSkyRaidTools", "Version")
--@debug@
if versionNumber == " v@project-version@" then
versionNumber = " Dev Build"
end
--@end-debug@
local versionTitle = C_AddOns.GetAddOnMetadata("NorthernSkyRaidTools", "Title")
local statusBarText = versionTitle .. versionNumber .. " | |cFFFFFFFF" .. (authorsString) .. "|r"
NSUI.StatusBar.authorName:SetText(statusBarText)
NSI.IsBuilding = false
end
function NSUI:ToggleOptions()
if NSUI:IsShown() then
NSUI:Hide()
else
NSUI:Show()
end
end
function NSI:NickNamesSyncPopup(unit, nicknametable)
local popup = DF:CreateSimplePanel(UIParent, 300, 120, "Sync Nicknames", "SyncNicknamesPopup", {
DontRightClickClose = true
})
popup:SetPoint("CENTER", UIParent, "CENTER", 0, 0)
local label = DF:CreateLabel(popup, NSAPI:Shorten(unit) .. " is attempting to sync their nicknames with you.", 11)
label:SetPoint("TOPLEFT", popup, "TOPLEFT", 10, -30)
label:SetPoint("BOTTOMRIGHT", popup, "BOTTOMRIGHT", -10, 40)
label:SetJustifyH("CENTER")
local cancel_button = DF:CreateButton(popup, function() popup:Hide() end, 130, 20, "Cancel")
cancel_button:SetPoint("BOTTOMLEFT", popup, "BOTTOMLEFT", 10, 10)
cancel_button:SetTemplate(options_button_template)
local accept_button = DF:CreateButton(popup, function()
NSI:SyncNickNamesAccept(nicknametable)
popup:Hide()
end, 130, 20, "Accept")
accept_button:SetPoint("BOTTOMRIGHT", popup, "BOTTOMRIGHT", -10, 10)
accept_button:SetTemplate(options_button_template)
return popup
end
function NSI:DisplayText(text, duration)
if self:Restricted() then return end
if self.NSRTFrame and self.NSRTFrame.generic_display then
self.NSRTFrame.generic_display.Text:SetText(text)
self.NSRTFrame.generic_display:Show()
self.NSRTFrame.generic_display.Text:Show()
if self.TextHideTimer then
self.TextHideTimer:Cancel()
self.TextHideTimer = nil
end
self.TextHideTimer = C_Timer.NewTimer(duration or 10, function() self.NSRTFrame.generic_display:Hide() end)
end
end
function NSI:DisplaySecretText(format, Hide, args)
if self.NSRTFrame and self.NSRTFrame.SecretDisplay then
if Hide then
self.NSRTFrame.SecretDisplay:Hide()
self.NSRTFrame.SecretDisplay.Text:Hide()
return
end
self.NSRTFrame.SecretDisplay.Text:SetFormattedText(format or "%s", unpack(args or {}))
self.NSRTFrame.SecretDisplay:Show()
self.NSRTFrame.SecretDisplay.Text:Show()
end
end