-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathAutoBarConfig.lua
More file actions
232 lines (169 loc) · 6.07 KB
/
AutoBarConfig.lua
File metadata and controls
232 lines (169 loc) · 6.07 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
--
-- AutoBarConfig
--
-- Config options in the standard place
--
-- http://muffinmangames.com
--
local _, AB = ...
local types = AB.types ---@class ABTypes
local code = AB.code ---@class ABCode
local AutoBar = AutoBar
local L = AutoBarGlobalDataObject.locale
local _
local UI = AB.UITK
AB.AutoBarConfig = {}
local ABC = AB.AutoBarConfig
ABC.Debug = {} --table to store stuff related to the Debug Frame
ABC.main_panel_category = nil
ABC.debug_frame_category = nil
ABC.main_panel = CreateFrame( "Frame", "AutoBarConfig", UIParent );
ABC.main_panel.name = "AutoBar";
if InterfaceOptions_AddCategory then
InterfaceOptions_AddCategory(ABC.main_panel)
else
local layout
ABC.main_panel_category, layout = _G.Settings.RegisterCanvasLayoutCategory(ABC.main_panel, ABC.main_panel.name)
_G.Settings.RegisterAddOnCategory(ABC.main_panel_category)
end
-- Categories panel
local max_categories_in_list = 29
local function update_visible_categories()
end
ABC.categories_panel = CreateFrame( "Frame", "AutoBarConfig_Categories", ABC.main_panel, BackdropTemplateMixin and "BackdropTemplate");
ABC.categories_panel.name = "Custom Categories";
ABC.categories_panel.parent = ABC.main_panel.name;
ABC.categories_panel:SetBackdrop({
bgFile = "Interface/ChatFrame/ChatFrameBackground",
tile = false,
insets = { left = 3, right = 3, top = 3, bottom = 3 },
})
ABC.categories_panel:SetBackdropColor(0.1, 0.1, 0.15, 0.9);
ABC.categories_panel:EnableMouse(true)
ABC.categories_panel:EnableMouseWheel(true)
ABC.categories_panel:SetScript("OnMouseWheel", function(self, p_delta)
local s_min, s_max = ABC.category_slider:GetMinMaxValues()
local val = ABC.category_slider:GetValue()
local new_value = Clamp(val - (p_delta * 3), s_min, s_max)
ABC.category_slider:SetValue(new_value)
end)
--InterfaceOptions_AddCategory(ABC.categories_panel);
ABC.category_slider = UI.create_slider(ABC.categories_panel, {min = 1, max = max_categories_in_list});
ABC.categories_panel.buttonlist = {}
for i = 1, max_categories_in_list do
local b = CreateFrame("Button", nil, ABC.categories_panel, BackdropTemplateMixin and "BackdropTemplate");
b:SetSize(180, 16)
if(i == 1) then
b:SetPoint("TOPLEFT", 6, -6)
else
b:SetPoint("TOPLEFT", ABC.categories_panel.buttonlist[i-1], "BOTTOMLEFT", 0, -2)
end
b:SetBackdrop({bgFile = "Interface/ChatFrame/ChatFrameBackground", tile = false})
b:SetBackdropColor(0, 0.7, 0, 1)
b:RegisterForClicks("LeftButtonUp", "RightButtonUp")
ABC.categories_panel.buttonlist[i] = b
end
ABC.category_slider.my_button_up:SetPoint("TOPLEFT", ABC.categories_panel.buttonlist[1], "TOPRIGHT", 5, 0)
local height = (max_categories_in_list - 2) * 16 + (max_categories_in_list * 2)
ABC.category_slider:SetSize(20, height);
ABC.category_slider:SetScript("OnValueChanged", function (self, value)
update_visible_categories()
end)
local AceGUI = LibStub("AceGUI-3.0")
ABC.DebugFrame = AceGUI:Create("BlizOptionsGroup")
ABC.DebugFrame:SetName("Debug", "AutoBar")
ABC.DebugFrame:SetLayout("Fill")
if InterfaceOptions_AddCategory then
InterfaceOptions_AddCategory(ABC.DebugFrame.frame)
else
local layout
ABC.debug_frame_category, layout = _G.Settings.RegisterCanvasLayoutSubcategory(ABC.main_panel_category, ABC.DebugFrame.frame, ABC.DebugFrame.frame.name)
_G.Settings.RegisterAddOnCategory(ABC.debug_frame_category)
end
--local function print_map_ids()
--local res = "";
-- for i = 1, 4000 do
-- local map_info = C_Map.GetMapInfo(i);
-- if(map_info) then
-- res = res .. "|n" .. tostring(i) .. " " .. map_info.name;
-- end
-- end
--
-- return res;
--end
local function find_nameless_categories()
local nameless = ""
for key in pairs(AutoBarCategoryList) do
if(AutoBarGlobalDataObject.locale[key] == nil) then
nameless = nameless .. "|n" .. key
end
end
return nameless
end
local function find_nameless_buttons()
local nameless = ""
for key in pairs(AutoBar.Class) do
if(AutoBarGlobalDataObject.locale[key] == nil) then
nameless = nameless .. "|n" .. key
end
end
return nameless
end
local function set_nameless_category_text(p_widget)
local edit_box_cat = p_widget:GetUserData("edit_box_cat")
edit_box_cat:SetText(find_nameless_categories())
local edit_box_btn = p_widget:GetUserData("edit_box_btn")
edit_box_btn:SetText(find_nameless_buttons())
-- edit_box:SetText(print_map_ids())
end
-- function that draws the widgets for the first tab
local function DrawGroupNamelessCategories(container)
local button = AceGUI:Create("Button")
button:SetText("Find Nameless Categories/Buttons")
button:SetWidth(200)
button:SetCallback("OnClick", set_nameless_category_text)
container:AddChild(button)
local edit_box_cat = AceGUI:Create("MultiLineEditBox")
edit_box_cat:SetNumLines(15)
edit_box_cat:SetFullWidth(true)
edit_box_cat:DisableButton(true)
edit_box_cat:SetLabel(nil)
container:AddChild(edit_box_cat)
local edit_box_btn = AceGUI:Create("MultiLineEditBox")
edit_box_btn:SetNumLines(15)
edit_box_btn:SetFullWidth(true)
edit_box_btn:DisableButton(true)
edit_box_btn:SetLabel('')
container:AddChild(edit_box_btn)
button:SetUserData("edit_box_cat", edit_box_cat)
button:SetUserData("edit_box_btn", edit_box_btn)
end
-- function that draws the widgets for the second tab
local function DrawGroupWarnings(container)
local edit_box = AceGUI:Create("MultiLineEditBox")
edit_box:SetNumLines(28)
edit_box:SetFullWidth(true)
edit_box:DisableButton(true)
edit_box:SetLabel("")
container:AddChild(edit_box)
edit_box:SetText(code.get_warning_log_string())
end
-- Callback function for OnGroupSelected
local function SelectGroup(container, event, group)
container:ReleaseChildren()
if group == "tab1" then
DrawGroupNamelessCategories(container)
elseif group == "tab2" then
DrawGroupWarnings(container)
end
end
local tab = AceGUI:Create("TabGroup")
tab:SetLayout("Flow")
-- Setup which tabs to show
tab:SetTabs({{text="Nameless Categories", value="tab1"}, {text="Warnings", value="tab2"}})
-- Register callback
tab:SetCallback("OnGroupSelected", SelectGroup)
-- Set initial Tab (this will fire the OnGroupSelected callback)
tab:SelectTab("tab1")
-- add to the frame container
ABC.DebugFrame:AddChild(tab)