-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI.lua
191 lines (167 loc) · 7.38 KB
/
GUI.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
local GUI = {}
_G["PowerRaidGUI"] = GUI
_G["PowerRaidGUI_Shown"] = false
local AceGUI = LibStub("AceGUI-3.0")
local L = LibStub("AceLocale-3.0"):GetLocale("PowerRaid");
LibStub("AceHook-3.0"):Embed(GUI)
local frame = nil
local tabGroup = nil
GUI.RaidBuffsTabId = "raid_buffs"
GUI.WorldBuffsTabId = "world_buffs"
GUI.PaladinBuffsTabId = "paladin_buffs"
GUI.RaidItemsTabId = "raid_items"
GUI.ConsumablesTabId = "consumables"
GUI.TalentsTabId = "talents"
GUI.SettingsTabId = "settings"
GUI.tabIdsToTabNames = {
[GUI.RaidBuffsTabId] = L["Raid Buffs"],
[GUI.WorldBuffsTabId] = L["World Buffs"],
[GUI.PaladinBuffsTabId] = L["Paladin Buffs"],
[GUI.RaidItemsTabId] = L["Raid Items"],
[GUI.ConsumablesTabId] = L["Consumables"],
[GUI.TalentsTabId] = L["Talents"],
[GUI.SettingsTabId] = L["Settings"],
}
function GUI:ReloadCurrentTab()
if PowerRaidGUI_Shown then
tabGroup:SelectTab(PowerRaid.db.char.currentTab)
end
end
function GUI:Toggle()
if(frame and frame:IsShown()) then
PowerRaidGUI_Shown = false
frame:Hide()
else
if not frame then
GUI:SetUpGUI()
else
tabGroup:SelectTab(PowerRaid.db.char.currentTab)
end
PowerRaidGUI_Shown = true
frame:Show()
end
end
function GUI:GetReportSettingsDialog(tabId)
local tabName = PowerRaidGUI.tabIdsToTabNames[tabId]
if not reportSettingsDialogFrame then
reportSettingsDialogFrame = AceGUI:Create("Frame")
_G["PowerRaidGUI_reportSettingsDialogFrame"] = reportSettingsDialogFrame
reportSettingsDialogFrame:Hide()
reportSettingsDialogFrame:SetWidth(500)
reportSettingsDialogFrame:SetHeight(300)
reportSettingsDialogFrame:EnableResize(false)
reportSettingsDialogFrame:SetLayout("Fill")
tinsert(UISpecialFrames, "PowerRaidGUI_reportSettingsDialogFrame")
local reportDialogGroup = AceGUI:Create("SimpleGroup")
reportDialogGroup:SetFullWidth(true)
reportDialogGroup:SetFullHeight(true)
reportDialogGroup:SetLayout("List")
reportSettingsDialogFrame:AddChild(reportDialogGroup)
local reportTypeDropdown = AceGUI:Create("Dropdown")
reportTypeDropdown:SetWidth(250)
reportSettingsDialogFrame.reportTypeDropdown = reportTypeDropdown
reportDialogGroup:AddChild(reportTypeDropdown)
local reportDropdown = AceGUI:Create("Dropdown")
reportDropdown:SetWidth(250)
reportSettingsDialogFrame.reportDropdown = reportDropdown
reportDialogGroup:AddChild(reportDropdown)
local showUnknownCheckbox = AceGUI:Create("CheckBox")
showUnknownCheckbox:SetLabel(L["showUnknownLabel"])
showUnknownCheckbox:SetFullWidth(true)
reportSettingsDialogFrame.showUnknownCheckbox = showUnknownCheckbox
reportDialogGroup:AddChild(showUnknownCheckbox)
local showUnknownDescLabel = AceGUI:Create("Label")
showUnknownDescLabel:SetText(L["showUnknownDesc"])
showUnknownDescLabel:SetFullWidth(true)
reportDialogGroup:AddChild(showUnknownDescLabel)
local reportExample = AceGUI:Create("Label")
reportExample:SetFullWidth(true)
reportExample:SetHeight(150)
reportSettingsDialogFrame.reportExample = reportExample
reportDialogGroup:AddChild(reportExample)
end
reportSettingsDialogFrame:SetTitle(format(L["ReportDialogSettingsTitle"], tabName))
local function UpdateReportExampleText()
reportSettingsDialogFrame.reportExample:SetText(GetReportTypeExample(tabId,
PowerRaid.db.char.currentReportOutputTypes[tabId],
PowerRaid.db.char.currentReportOutputChannels[tabId],
PowerRaid.db.char.reportUnknownPlayers[tabId]))
end
local reportType = PowerRaid.db.char.currentReportOutputTypes[tabId]
reportSettingsDialogFrame.reportTypeDropdown:SetLabel(format(L["ReportDialogSettingsTypeLabel"], tabName))
reportSettingsDialogFrame.reportTypeDropdown:SetList(GetReportTypes(tabId, tabName), GetReportTypesOrder(tabId))
reportSettingsDialogFrame.reportTypeDropdown:SetValue(reportType)
reportSettingsDialogFrame.reportTypeDropdown:SetCallback("OnValueChanged", function(widget, event, key)
PowerRaid.db.char.currentReportOutputTypes[tabId] = key
UpdateReportExampleText()
end)
local reportChannel = PowerRaid.db.char.currentReportOutputChannels[tabId]
reportSettingsDialogFrame.reportDropdown:SetLabel(format(L["ReportDialogSettingsChannelLabel"], tabName))
reportSettingsDialogFrame.reportDropdown:SetList(GetChatChannels(tabId))
reportSettingsDialogFrame.reportDropdown:SetValue(reportChannel)
reportSettingsDialogFrame.reportDropdown:SetCallback("OnValueChanged", function(widget, event, key)
PowerRaid.db.char.currentReportOutputChannels[tabId] = key
UpdateReportExampleText()
end)
local reportUnknownPlayers = PowerRaid.db.char.reportUnknownPlayers[tabId]
reportSettingsDialogFrame.showUnknownCheckbox:SetValue(reportUnknownPlayers)
reportSettingsDialogFrame.showUnknownCheckbox:SetCallback("OnValueChanged", function()
PowerRaid.db.char.reportUnknownPlayers[tabId] = reportSettingsDialogFrame.showUnknownCheckbox:GetValue()
UpdateReportExampleText()
end)
reportSettingsDialogFrame.reportExample:SetText(GetReportTypeExample(tabId, reportType, reportChannel, reportUnknownPlayers))
return reportSettingsDialogFrame;
end
local function SelectGroup(container, event, group)
container:ReleaseChildren()
PowerRaid.db.char.currentTab = group
if group == GUI.SettingsTabId then
SettingsTab:DrawSettings(container)
elseif group == GUI.RaidBuffsTabId then
RaidBuffsTab:DrawBuffs(container)
elseif group == GUI.WorldBuffsTabId then
WorldBuffsTab:DrawBuffs(container)
elseif group == GUI.RaidItemsTabId then
RaidItemsTab:DrawRaidItems(container)
elseif group == GUI.TalentsTabId then
TalentsTab:DrawTalents(container)
elseif group == GUI.ConsumablesTabId then
ConsumablesTab:DrawConsumables(container)
elseif group == GUI.PaladinBuffsTabId then
PaladinBuffsTab:DrawBuffs(container)
end
end
function GUI:SelectTab(tab)
tabGroup:SelectTab(tab)
end
function GUI:SetUpGUI()
frame = AceGUI:Create("Frame")
_G["PowerRaidGUI_frame"] = frame
frame:Hide()
frame:EnableResize(false)
frame:SetWidth(840)
frame:SetTitle("Power Raid")
local specName = GetLocalizedSpecName(PowerRaid.thisPlayerSpec)
if not specName then
specName = L["Unknown Spec"]
end
frame:SetStatusText(format("v%s %s: %s %s: %s",
PowerRaid.version,
L["Spec"], specName,
L["Class"], PowerRaid.allClasses[PowerRaid.thisPlayerClass]))
tinsert(UISpecialFrames, "PowerRaidGUI_frame")
frame:SetLayout("Fill")
tabGroup = AceGUI:Create("TabGroup")
local tabIds = {GUI.RaidBuffsTabId, GUI.WorldBuffsTabId, GUI.RaidItemsTabId, GUI.ConsumablesTabId, GUI.TalentsTabId, GUI.SettingsTabId}
if PowerRaid.faction == "Alliance" then
table.insert(tabIds, 3, GUI.PaladinBuffsTabId)
end
local tabs = {}
for _, tabId in pairs(tabIds) do
table.insert(tabs, {value = tabId, text = GUI.tabIdsToTabNames[tabId]})
end
tabGroup:SetTabs(tabs)
tabGroup:SetCallback("OnGroupSelected", SelectGroup)
tabGroup:SelectTab(PowerRaid.db.char.currentTab)
frame:AddChild(tabGroup)
end