vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function DFM_Add_LoDFunc() |
2 | DFM_LoDFrame_Func:ClearFocus(); |
||
3 | local func = DFM_LoDFrame_Func:GetText(); |
||
4 | if (not getglobal(func)) then return; end |
||
5 | tinsert(DFM_Settings.LoadOnDemandFunctions, func); |
||
6 | DFM_LoDMenu_Update(); |
||
7 | RunScript(string.gsub(DFM_LODHOOKFUNC, "$f", func)); |
||
8 | DL_Hook(func, "DFM"); |
||
9 | end |
||
10 | |||
11 | function DFM_AddNewFrame() |
||
12 | local frame = DFM_Options_AddFrame:GetText(); |
||
13 | local name = DFM_Options_AddName:GetText(); |
||
14 | if (name == "") then name = nil; end |
||
15 | local header = DFM_Options_AddHeader:GetText(); |
||
16 | if (header == "") then header = nil; end |
||
17 | local children = DFM_Options_AddChildren:GetChecked(); |
||
18 | local updateFlag; |
||
19 | if (DFM_SELECTED_INDEX and frame == DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame) then |
||
20 | updateFlag = 1; |
||
21 | end |
||
22 | DFM_Add_Frame(frame, name, header, children, nil, updateFlag); |
||
23 | DFM_Options_AddFrame:SetText(""); |
||
24 | DFM_Options_AddName:SetText(""); |
||
25 | DFM_Options_AddHeader:SetText(""); |
||
26 | DFM_Options_AddFrame:ClearFocus(); |
||
27 | DFM_Options_AddName:ClearFocus(); |
||
28 | DFM_Options_AddHeader:ClearFocus(); |
||
29 | DFM_Options_AddChildren:SetChecked(0); |
||
30 | end |
||
31 | |||
32 | function DFM_CheckBox_OnClick() |
||
33 | local value; |
||
34 | if (this:GetChecked()) then |
||
35 | value = 1; |
||
36 | end |
||
37 | DFM_Update_Setting(this:GetParent().index, value); |
||
38 | end |
||
39 | |||
40 | function DFM_ColorPicker_OnClick() |
||
41 | local basecolor = DFM_Get_Setting(this:GetParent().index); |
||
42 | if (not basecolor) then return; end |
||
43 | local color = {}; |
||
44 | color.r = basecolor.r; |
||
45 | color.g = basecolor.g; |
||
46 | color.b = basecolor.b; |
||
47 | ColorPickerFrame.hasOpacity = nil; |
||
48 | ColorPickerFrame.previousValues = color; |
||
49 | ColorPickerFrame.cancelFunc = DFM_ColorPicker_ColorCancelled; |
||
50 | ColorPickerFrame.opacityFunc = DFM_ColorPicker_ColorChanged; |
||
51 | ColorPickerFrame.func = DFM_ColorPicker_ColorChanged; |
||
52 | ColorPickerFrame.colorBox = this:GetName(); |
||
53 | ColorPickerFrame.index = this:GetParent().index; |
||
54 | ColorPickerFrame:SetColorRGB(color.r, color.g, color.b); |
||
55 | ColorPickerFrame:ClearAllPoints(); |
||
56 | if (DFM_Options:GetRight() < UIParent:GetWidth() / 2) then |
||
57 | ColorPickerFrame:SetPoint("LEFT", "DFM_Options", "RIGHT", 10, 0); |
||
58 | else |
||
59 | ColorPickerFrame:SetPoint("RIGHT", "DFM_Options", "LEFT", -10, 0); |
||
60 | end |
||
61 | ColorPickerFrame:Show(); |
||
62 | end |
||
63 | |||
64 | function DFM_ColorPicker_ColorCancelled() |
||
65 | local color = ColorPickerFrame.previousValues; |
||
66 | getglobal(ColorPickerFrame.colorBox):SetBackdropColor(color.r, color.g, color.b); |
||
67 | DFM_Update_Setting(ColorPickerFrame.index, color); |
||
68 | end |
||
69 | |||
70 | function DFM_ColorPicker_ColorChanged() |
||
71 | local r, g, b = ColorPickerFrame:GetColorRGB(); |
||
72 | local color = { r=r, g=g, b=b }; |
||
73 | getglobal(ColorPickerFrame.colorBox):SetBackdropColor(color.r, color.g, color.b); |
||
74 | DFM_Update_Setting(ColorPickerFrame.index, color); |
||
75 | end |
||
76 | |||
77 | function DFM_Copy_Settings() |
||
78 | if (not DFM_SELECTED_INDEX) then return; end |
||
79 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
80 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
81 | DFM_BUFFER = {}; |
||
82 | DL_Copy_Table(DFM_Settings[DFM_INDEX][header][frame], DFM_BUFFER); |
||
83 | end |
||
84 | |||
85 | function DFM_Create_NewFrame() |
||
86 | local frameType = DFM_CreateFrameForm_FrameType_Setting:GetText(); |
||
87 | local frame = DFM_CreateFrameForm_AddFrame:GetText(); |
||
88 | local name = DFM_CreateFrameForm_AddName:GetText(); |
||
89 | local header = DFM_CreateFrameForm_AddHeader:GetText(); |
||
90 | if (header == "" or (not header)) then |
||
91 | header = DFM_TEXT.UserAdded; |
||
92 | end |
||
93 | if (name == "" or (not name)) then |
||
94 | name = frame; |
||
95 | end |
||
96 | DFM_Add_Frame(frame, name, header, nil, 1, nil, 1); |
||
97 | DFM_Settings[DFM_INDEX][header][frame].customFrame = 1; |
||
98 | DFM_Settings[DFM_INDEX][header][frame].frameType = frameType; |
||
99 | DFM_Initialize_Frame(header, frame); |
||
100 | DFM_CreateFrameForm_FrameType_Setting:SetText("Frame"); |
||
101 | DFM_CreateFrameForm_AddFrame:SetText(""); |
||
102 | DFM_CreateFrameForm_AddName:SetText(""); |
||
103 | DFM_CreateFrameForm_AddHeader:SetText(""); |
||
104 | DFM_Update_FrameList(); |
||
105 | DFM_FrameMenu_Update(); |
||
106 | DL_Feedback("Custom frame named "..name.." created beneath the "..header.." header."); |
||
107 | end |
||
108 | |||
109 | function DFM_Delete_LoDFunc() |
||
110 | local index = this:GetParent().index; |
||
111 | local func = DFM_Settings.LoadOnDemandFunctions[index]; |
||
112 | table.remove(DFM_Settings.LoadOnDemandFunctions, index); |
||
113 | DFM_LoDMenu_Update(); |
||
114 | local oldFunc = getglobal("DFM_Old_"..func); |
||
115 | func = getglobal(func); |
||
116 | func = oldFunc; |
||
117 | oldFunc = nil; |
||
118 | end |
||
119 | |||
120 | function DFM_Delete_Profile(index) |
||
121 | if (not index) then |
||
122 | if (DFM_Options) then |
||
123 | index = DFM_Options_LoadProfile_Setting:GetText(); |
||
124 | if (not index or index == "") then return; end |
||
125 | else |
||
126 | return; |
||
127 | end |
||
128 | end |
||
129 | if (index == "Default") then |
||
130 | DL_Error("You cannot delete the Default profile."); |
||
131 | return; |
||
132 | elseif (index == DFM_INDEX) then |
||
133 | DL_Error("You cannot delete the profile you're currently using."); |
||
134 | return; |
||
135 | end |
||
136 | DFM_Settings[index] = nil; |
||
137 | DFM_Update_Profiles(); |
||
138 | DFM_Options_LoadProfile_Setting:SetText(""); |
||
139 | end |
||
140 | |||
141 | function DFM_DropMenu_OnClick() |
||
142 | if (DFM_DropMenu.controlbox) then |
||
143 | getglobal(DFM_DropMenu.controlbox):SetText(getglobal(this:GetName().."_Text"):GetText()); |
||
144 | end |
||
145 | DFM_DropMenu:Hide(); |
||
146 | if (DFM_DropMenu.index == "point" or DFM_DropMenu.index == "to") then |
||
147 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
148 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
149 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then return; end |
||
150 | DFM_Settings[DFM_INDEX][header][frame].Location[DFM_DropMenu.index] = this.value; |
||
151 | DFM_Initialize_FrameLocation(header, frame); |
||
152 | elseif (DFM_DropMenu.index == "headeroption") then |
||
153 | DFM_Settings[DFM_INDEX][DFM_FRAME_LIST[DFM_DropMenu.subindex].text] = nil; |
||
154 | DFM_SELECTED_INDEX = nil; |
||
155 | DFM_OPTIONS_LIST = {}; |
||
156 | DFM_Update_FrameList(); |
||
157 | DFM_FrameMenu_Update(); |
||
158 | DFM_OptionsMenu_Update(); |
||
159 | DFM_ReloadUIFrame:Show(); |
||
160 | elseif (DFM_DropMenu.index == "FRAMETYPE") then |
||
161 | return; |
||
162 | elseif (DFM_DropMenu.index ~= "profile") then |
||
163 | DFM_Update_Setting(DFM_DropMenu.index, this.value); |
||
164 | end |
||
165 | end |
||
166 | |||
167 | function DFM_EditBox_OnEnterPressed(scrollMenu) |
||
168 | local value; |
||
169 | if (this.number) then |
||
170 | value = this:GetNumber(); |
||
171 | if (not value) then |
||
172 | value = 0; |
||
173 | end |
||
174 | else |
||
175 | value = this:GetText(); |
||
176 | if (not value) then |
||
177 | value = ""; |
||
178 | end |
||
179 | end |
||
180 | this:ClearFocus(); |
||
181 | this.prevvalue = value; |
||
182 | if (scrollMenu) then |
||
183 | DFM_Update_Setting(this:GetParent():GetParent().index, value); |
||
184 | else |
||
185 | DFM_Update_Setting(this:GetParent().index, value); |
||
186 | end |
||
187 | end |
||
188 | |||
189 | function DFM_FrameFinder_OnUpdate() |
||
190 | local obj = GetMouseFocus(); |
||
191 | local name; |
||
192 | if (obj and obj.GetName) then |
||
193 | name = obj:GetName(); |
||
194 | end |
||
195 | if (this.currentframe ~= name) then |
||
196 | this.currentframe = name; |
||
197 | DFM_FrameFinder_Update(obj); |
||
198 | end |
||
199 | end |
||
200 | |||
201 | function DFM_FrameFinder_Update(frame, setlock) |
||
202 | if (DFM_FINDER_LOCKED and (not setlock)) then return; end |
||
203 | if (setlock) then |
||
204 | DFM_FINDER_LOCKED = true; |
||
205 | DFM_FrameFinder_LockText:SetText(DFM_TEXT.Locked); |
||
206 | end |
||
207 | if (frame) then |
||
208 | local text = DFM_TEXT.MouseIsOver; |
||
209 | if (frame.GetName and frame:GetName()) then |
||
210 | text = text..frame:GetName(); |
||
211 | else |
||
212 | text = text..DFM_TEXT.UnnamedFrame; |
||
213 | end |
||
214 | if (frame.GetParent and frame:GetParent() and frame:GetParent().GetName and frame:GetParent():GetName()) then |
||
215 | text = text..DFM_TEXT.FrameParent..frame:GetParent():GetName(); |
||
216 | if (frame:GetParent().GetParent and frame:GetParent():GetParent() and frame:GetParent():GetParent().GetName and frame:GetParent():GetParent():GetName()) then |
||
217 | text = text..DFM_TEXT.FrameParentParent..frame:GetParent():GetParent():GetName(); |
||
218 | end |
||
219 | end |
||
220 | if (frame.GetChildren) then |
||
221 | local children = {frame:GetChildren()}; |
||
222 | if (children) then |
||
223 | text = text..DFM_TEXT.Children; |
||
224 | for _, child in children do |
||
225 | if (child.GetName and child:GetName()) then |
||
226 | text = text..child:GetName().."\n"; |
||
227 | end |
||
228 | end |
||
229 | end |
||
230 | end |
||
231 | if (frame.GetRegions) then |
||
232 | local children = {frame:GetRegions()}; |
||
233 | if (children) then |
||
234 | text = text..DFM_TEXT.Regions; |
||
235 | for _, child in children do |
||
236 | if (child.GetName and child:GetName()) then |
||
237 | text = text..child:GetName().."\n"; |
||
238 | end |
||
239 | end |
||
240 | end |
||
241 | end |
||
242 | DFM_FrameFinder_ScrollFrame_Text:SetText(text); |
||
243 | else |
||
244 | DFM_FrameFinder_ScrollFrame_Text:SetText(""); |
||
245 | end |
||
246 | end |
||
247 | |||
248 | function DFM_FrameMenu_OnClick() |
||
249 | DFM_DropMenu:Hide(); |
||
250 | DFM_ScrollMenu:Hide(); |
||
251 | for i=1,14 do |
||
252 | button = getglobal("DFM_Options_FrameMenu_Button"..i); |
||
253 | buttontext = getglobal("DFM_Options_FrameMenu_Button"..i.."Text"); |
||
254 | if (button:GetID() == this:GetID()) then |
||
255 | button:SetChecked(1); |
||
256 | buttontext:SetTextColor(1, 0, 0); |
||
257 | buttontext:SetFont("Fonts\\FRIZQT__.TTF", 12); |
||
258 | elseif (button.headerFlag) then |
||
259 | button:SetChecked(0); |
||
260 | buttontext:SetTextColor(1, .82, 0); |
||
261 | buttontext:SetFont("Fonts\\MORPHEUS.ttf", 13); |
||
262 | else |
||
263 | button:SetChecked(0); |
||
264 | if (DFM_FRAME_LIST[button.index] and DFM_FRAME_LIST[button.index].modified) then |
||
265 | buttontext:SetTextColor(0, 1, 1); |
||
266 | else |
||
267 | buttontext:SetTextColor(1, 1, 1); |
||
268 | end |
||
269 | buttontext:SetFont("Fonts\\ARIALN.TTF", 12); |
||
270 | end |
||
271 | end |
||
272 | if (arg1 == "RightButton") then |
||
273 | DFM_FrameMenu_Update(); |
||
274 | local oldIndex = this.index; |
||
275 | if (this.headerFlag) then |
||
276 | this.table = "DFM_HEADER_OPTIONS"; |
||
277 | this.menu = "DFM_DropMenu"; |
||
278 | this.subindex = this.index; |
||
279 | this.index = "headeroption"; |
||
280 | else |
||
281 | this.table = "DFM_HEADERS_LIST"; |
||
282 | this.menu = "DFM_ScrollMenu"; |
||
283 | this.index = "scrolltoheader"; |
||
284 | end |
||
285 | this:SetChecked(0); |
||
286 | DL_Show_Menu(); |
||
287 | DFM_DropMenu.controlbox = nil; |
||
288 | this.index = oldIndex; |
||
289 | elseif (this.headerFlag) then |
||
290 | this:SetChecked(0); |
||
291 | getglobal(this:GetName().."Text"):SetTextColor(1, .82, 0); |
||
292 | getglobal(this:GetName().."Text"):SetFont("Fonts\\MORPHEUS.ttf", 13); |
||
293 | return; |
||
294 | elseif (IsShiftKeyDown()) then |
||
295 | DFM_FrameFinder:Show(); |
||
296 | DFM_FrameFinder_Update(getglobal(DFM_FRAME_LIST[this.index].frame), 1); |
||
297 | DFM_FrameMenu_Update(); |
||
298 | else |
||
299 | DFM_SELECTED_INDEX = this.index; |
||
300 | DFM_Options_AddFrame:SetText(DFM_FRAME_LIST[this.index].frame); |
||
301 | DFM_Options_AddName:SetText(DFM_FRAME_LIST[this.index].text); |
||
302 | DFM_Options_AddHeader:SetText(DFM_FRAME_LIST[this.index].header); |
||
303 | DFM_Options_AddChildren:SetChecked(0); |
||
304 | DFM_Update_OptionsList(); |
||
305 | end |
||
306 | end |
||
307 | |||
308 | function DFM_FrameMenu_Update() |
||
309 | local numOptions = table.getn(DFM_FRAME_LIST); |
||
310 | local offset = FauxScrollFrame_GetOffset(DFM_Options_FrameMenu); |
||
311 | if (not offset) then |
||
312 | offset = 0; |
||
313 | end |
||
314 | local index, button; |
||
315 | |||
316 | for i=1, 14 do |
||
317 | button = getglobal("DFM_Options_FrameMenu_Button"..i); |
||
318 | buttontext = getglobal("DFM_Options_FrameMenu_Button"..i.."Text"); |
||
319 | index = offset + i; |
||
320 | button.index = index; |
||
321 | button.desc = nil; |
||
322 | button.headerFlag = nil; |
||
323 | if ( DFM_FRAME_LIST[index] ) then |
||
324 | buttontext:SetText(DFM_FRAME_LIST[index].text); |
||
325 | buttontext:SetJustifyH("LEFT"); |
||
326 | button:Show(); |
||
327 | if (DFM_FRAME_LIST[index].headerFlag) then |
||
328 | buttontext:SetJustifyH("CENTER"); |
||
329 | button:SetChecked(0); |
||
330 | buttontext:SetTextColor(1, .82, 0); |
||
331 | buttontext:SetFont("Fonts\\MORPHEUS.ttf", 13); |
||
332 | button.headerFlag = true; |
||
333 | elseif (DFM_SELECTED_INDEX == button.index) then |
||
334 | button:SetChecked(1); |
||
335 | buttontext:SetTextColor(1, 0, 0); |
||
336 | buttontext:SetFont("Fonts\\FRIZQT__.TTF", 12); |
||
337 | button.desc = DFM_FRAME_LIST[index].frame; |
||
338 | if (string.len(button.desc) > 23) then |
||
339 | button.desc = string.sub(button.desc, 1, 23).."\n"..string.sub(button.desc, 24); |
||
340 | end |
||
341 | button.desc = button.desc.."\n"..DFM_TEXT.Type..DFM_FRAME_LIST[index].frameType; |
||
342 | else |
||
343 | button:SetChecked(0); |
||
344 | if (DFM_FRAME_LIST[index].modified) then |
||
345 | buttontext:SetTextColor(0, 1, 1); |
||
346 | else |
||
347 | buttontext:SetTextColor(1, 1, 1); |
||
348 | end |
||
349 | buttontext:SetFont("Fonts\\ARIALN.TTF", 12); |
||
350 | button.desc = DFM_FRAME_LIST[index].frame; |
||
351 | if (string.len(button.desc) > 23) then |
||
352 | button.desc = string.sub(button.desc, 1, 23).."\n"..string.sub(button.desc, 24); |
||
353 | end |
||
354 | button.desc = button.desc.."\n"..DFM_TEXT.Type..DFM_FRAME_LIST[index].frameType; |
||
355 | end |
||
356 | else |
||
357 | button:Hide(); |
||
358 | end |
||
359 | end |
||
360 | |||
361 | FauxScrollFrame_Update(DFM_Options_FrameMenu, numOptions, 14, 20 ); |
||
362 | DFM_Options_FrameMenu:Show(); |
||
363 | end |
||
364 | |||
365 | function DFM_Get_LocSettings(header, frame) |
||
366 | if (DFM_Settings[DFM_INDEX][header][frame].Location) then |
||
367 | return DFM_Settings[DFM_INDEX][header][frame].Location; |
||
368 | else |
||
369 | frame = getglobal(frame); |
||
370 | if (frame.GetNumPoints and frame:GetNumPoints()) then |
||
371 | local point, relativeObject, relativePoint, x, y = frame:GetPoint(1); |
||
372 | if (not relativeObject) then |
||
373 | relativeObject = UIParent; |
||
374 | end |
||
375 | return {frame=relativeObject:GetName(), point=point, to=relativePoint, x=DL_round(x, 1), y=DL_round(y, 1)}; |
||
376 | else |
||
377 | local x, y; |
||
378 | if (frame.GetCenter) then |
||
379 | x, y = DL_Get_Offsets(getglobal(frame), UIParent, "CENTER", "CENTER"); |
||
380 | end |
||
381 | if (not x) then x=0; end |
||
382 | if (not y) then y=0; end |
||
383 | x = DL_round(x, 1); |
||
384 | y = DL_round(y, 1); |
||
385 | return {frame="UIParent", point="CENTER", to="CENTER", x=x, y=y}; |
||
386 | end |
||
387 | end |
||
388 | end |
||
389 | |||
390 | function DFM_Get_MethodSetting(method, index) |
||
391 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
392 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
393 | if (DFM_Settings[DFM_INDEX][header][frame]) then |
||
394 | if (DFM_Settings[DFM_INDEX][header][frame][method]) then |
||
395 | return DFM_Settings[DFM_INDEX][header][frame][method][index]; |
||
396 | end |
||
397 | end |
||
398 | end |
||
399 | |||
400 | function DFM_Get_Setting(index) |
||
401 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
402 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
403 | local method = DFM_OPTIONS_LIST[index].method; |
||
404 | local param = DFM_OPTIONS_LIST[index].param; |
||
405 | if (DFM_Settings[DFM_INDEX][header][frame]) then |
||
406 | if (index == 1) then |
||
407 | return DFM_Settings[DFM_INDEX][header][frame].forceHide; |
||
408 | elseif (DFM_Settings[DFM_INDEX][header][frame][method]) then |
||
409 | return DFM_Settings[DFM_INDEX][header][frame][method][param]; |
||
410 | end |
||
411 | end |
||
412 | end |
||
413 | |||
414 | function DFM_Init_Settings(method) |
||
415 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
416 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
417 | if (not DFM_Settings[DFM_INDEX][header][frame][method]) then |
||
418 | DFM_Settings[DFM_INDEX][header][frame][method] = {}; |
||
419 | end |
||
420 | for param,value in DFM_METHODS_LIST[method].options do |
||
421 | if (not DFM_Settings[DFM_INDEX][header][frame][method][param]) then |
||
422 | DFM_Settings[DFM_INDEX][header][frame][method][param] = value.default; |
||
423 | end |
||
424 | end |
||
425 | end |
||
426 | |||
427 | function DFM_LockCheckBox_OnClick() |
||
428 | if (this:GetChecked()) then |
||
429 | DFM_Update_MethodSetting(this.method, "lock", 1); |
||
430 | else |
||
431 | DFM_Update_MethodSetting(this.method, "lock"); |
||
432 | DFM_ReloadUIFrame:Show(); |
||
433 | end |
||
434 | end |
||
435 | |||
436 | function DFM_LockLocationCheckBox_OnClick() |
||
437 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
438 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
439 | if (this:GetChecked()) then |
||
440 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then |
||
441 | DFM_Settings[DFM_INDEX][header][frame].Location = DFM_Get_LocSettings(header, frame); |
||
442 | end |
||
443 | DFM_Settings[DFM_INDEX][header][frame].Location.lock = 1; |
||
444 | else |
||
445 | DFM_Settings[DFM_INDEX][header][frame].Location.lock = nil; |
||
446 | end |
||
447 | DFM_Initialize_FrameLocation(header, frame); |
||
448 | end |
||
449 | |||
450 | function DFM_LoDMenu_Update() |
||
451 | local numOptions = table.getn(DFM_Settings.LoadOnDemandFunctions); |
||
452 | local offset = FauxScrollFrame_GetOffset(DFM_LoDFrame_Menu); |
||
453 | local index, button; |
||
454 | |||
455 | for i=1, 7 do |
||
456 | button = getglobal("DFM_LoDFrame_Menu_Button"..i); |
||
457 | buttontext = getglobal("DFM_LoDFrame_Menu_Button"..i.."_Text"); |
||
458 | index = offset + i; |
||
459 | button.index = index; |
||
460 | if ( DFM_Settings.LoadOnDemandFunctions[index] ) then |
||
461 | buttontext:SetText(DFM_Settings.LoadOnDemandFunctions[index]); |
||
462 | button:Show(); |
||
463 | else |
||
464 | button:Hide(); |
||
465 | end |
||
466 | end |
||
467 | |||
468 | FauxScrollFrame_Update(DFM_LoDFrame_Menu, numOptions, 7, 20 ); |
||
469 | end |
||
470 | |||
471 | function DFM_MinusButton_OnClick() |
||
472 | local value = this:GetParent():GetNumber(); |
||
473 | if (not value) then |
||
474 | value = 0; |
||
475 | end |
||
476 | value = value - 1; |
||
477 | this:GetParent():SetText(value); |
||
478 | DFM_Update_Setting(this:GetParent():GetParent().index, value); |
||
479 | end |
||
480 | |||
481 | function DFM_Nudge(button, dragframe) |
||
482 | if (not DFM_SELECTED_INDEX) then return; end |
||
483 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
484 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
485 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then return; end |
||
486 | if (not DFM_Settings[DFM_INDEX][header][frame].Location.use) then return; end |
||
487 | local dir = this:GetID(); |
||
488 | local amt = 1; |
||
489 | if (button == "RightButton") then |
||
490 | amt = 10; |
||
491 | elseif (button == "MiddleButton") then |
||
492 | amt = 3; |
||
493 | end |
||
494 | local x = DFM_Settings[DFM_INDEX][header][frame].Location.x; |
||
495 | local y = DFM_Settings[DFM_INDEX][header][frame].Location.y; |
||
496 | if (dir == 0) then |
||
497 | DFM_Options_XOffset:SetText(0); |
||
498 | DFM_Options_YOffset:SetText(0); |
||
499 | x = 0; |
||
500 | y = 0; |
||
501 | elseif (dir == 1) then |
||
502 | getglobal(this.updateFrame):SetText(y + amt); |
||
503 | y = y + amt; |
||
504 | elseif (dir == 2) then |
||
505 | getglobal(this.updateFrame):SetText(y - amt); |
||
506 | y = y - amt; |
||
507 | elseif (dir == 3) then |
||
508 | getglobal(this.updateFrame):SetText(x - amt); |
||
509 | x = x - amt; |
||
510 | elseif (dir == 4) then |
||
511 | getglobal(this.updateFrame):SetText(x + amt); |
||
512 | x = x + amt; |
||
513 | end |
||
514 | DFM_Settings[DFM_INDEX][header][frame].Location.x = x; |
||
515 | DFM_Settings[DFM_INDEX][header][frame].Location.y = y; |
||
516 | DFM_Initialize_FrameLocation(header, frame); |
||
517 | if (dragframe or DFM_DRAG_INDEX == DFM_SELECTED_INDEX) then |
||
518 | DFM_Summon_DragFrame(1); |
||
519 | end |
||
520 | end |
||
521 | |||
522 | function DFM_Nudge_OnUpdate(elapsed) |
||
523 | if (not DFM_SELECTED_INDEX) then return; end |
||
524 | if (not this.timer) then |
||
525 | this.timer = 1 / 30; |
||
526 | end |
||
527 | if (this.movingframe) then |
||
528 | this.timer = this.timer - elapsed; |
||
529 | if (this.timer < 0) then |
||
530 | this.timer = 1 / 30; |
||
531 | DFM_Nudge("MiddleButton"); |
||
532 | end |
||
533 | end |
||
534 | end |
||
535 | |||
536 | function DFM_OptionsMenu_OnClick() |
||
537 | DFM_DropMenu:Hide(); |
||
538 | DFM_ScrollMenu:Hide(); |
||
539 | end |
||
540 | |||
541 | function DFM_OptionsMenu_Update() |
||
542 | DFM_DropMenu:Hide(); |
||
543 | DFM_ScrollMenu:Hide(); |
||
544 | local numOptions = table.getn(DFM_OPTIONS_LIST); |
||
545 | local offset = FauxScrollFrame_GetOffset(DFM_Options_OptionsMenu); |
||
546 | if (not offset) then |
||
547 | offset = 0; |
||
548 | end |
||
549 | local index, button, buttonName, border, lockButton, useButton; |
||
550 | |||
551 | for i=1, 7 do |
||
552 | buttonName = "DFM_Options_OptionsMenu_Button"..i; |
||
553 | button = getglobal(buttonName); |
||
554 | border = getglobal(buttonName.."_Border"); |
||
555 | lockButton = getglobal(buttonName.."_Lock"); |
||
556 | useButton = getglobal(buttonName.."_Use"); |
||
557 | helpButton = getglobal(buttonName.."_Help"); |
||
558 | buttontext = getglobal("DFM_Options_OptionsMenu_Button"..i.."_Text"); |
||
559 | index = offset + i; |
||
560 | button.index = index; |
||
561 | button.help = nil; |
||
562 | |||
563 | if ( DFM_OPTIONS_LIST[index] ) then |
||
564 | button:Show(); |
||
565 | buttontext:SetText(DFM_TEXT[DFM_OPTIONS_LIST[index].name]); |
||
566 | button.help = DFM_OPTIONS_LIST[index].help; |
||
567 | |||
568 | for j=1,7 do |
||
569 | getglobal(buttonName.."_"..j):Hide(); |
||
570 | end |
||
571 | local option = getglobal(buttonName.."_"..DFM_OPTIONS_LIST[index].option); |
||
572 | option:Show(); |
||
573 | local offset = buttontext:GetStringWidth() + 9; |
||
574 | buttontext:ClearAllPoints(); |
||
575 | if (option.dynamicPosition) then |
||
576 | buttontext:SetPoint("LEFT", button, "LEFT", 0, 0); |
||
577 | option:ClearAllPoints(); |
||
578 | option:SetPoint("LEFT", button, "LEFT", offset + option.dynamicPosition, 0); |
||
579 | else |
||
580 | buttontext:SetPoint("TOPLEFT", button, "TOPLEFT", 0, 0); |
||
581 | end |
||
582 | |||
583 | local setting = DFM_Get_Setting(index); |
||
584 | if (not setting) then |
||
585 | local frame = getglobal(DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame); |
||
586 | if (DFM_OPTIONS_LIST[index].name == "TextAlpha" and frame.GetTextColor) then |
||
587 | _, _, _, setting = frame:GetTextColor(); |
||
588 | elseif (DFM_OPTIONS_LIST[index].name == "TextureAlpha") then |
||
589 | if (frame.GetVertexColor) then |
||
590 | _, _, _, setting = frame:GetVertexColor(); |
||
591 | else |
||
592 | setting = 1; |
||
593 | end |
||
594 | elseif (DFM_OPTIONS_LIST[index].name == "ShadowAlpha") then |
||
595 | _, _, _, setting = frame:GetShadowColor(); |
||
596 | elseif (DFM_OPTIONS_LIST[index].name == "ShadowOffsetX") then |
||
597 | setting = frame:GetShadowOffset(); |
||
598 | elseif (DFM_OPTIONS_LIST[index].name == "ShadowOffsetY") then |
||
599 | _, setting = frame:GetShadowOffset(); |
||
600 | elseif (DFM_OPTIONS_LIST[index].detection and string.find(DFM_OPTIONS_LIST[index].detection, "FontObject")) then |
||
601 | if (frame[DFM_OPTIONS_LIST[index].detection] and frame[DFM_OPTIONS_LIST[index].detection](frame) and frame[DFM_OPTIONS_LIST[index].detection](frame).GetName and frame[DFM_OPTIONS_LIST[index].detection](frame):GetName()) then |
||
602 | setting = frame[DFM_OPTIONS_LIST[index].detection](frame):GetName(); |
||
603 | else |
||
604 | setting = ""; |
||
605 | end |
||
606 | elseif (DFM_OPTIONS_LIST[index].detection == "GetScrollChild" and frame.GetScrollChild and frame:GetScrollChild() and frame:GetScrollChild().GetName and frame:GetScrollChild():GetName()) then |
||
607 | setting = frame:GetScrollChild():GetName(); |
||
608 | elseif (DFM_OPTIONS_LIST[index].detection and string.find(DFM_OPTIONS_LIST[index].detection, "Color") and frame[DFM_OPTIONS_LIST[index].detection]) then |
||
609 | setting = {}; |
||
610 | setting.r, setting.g, setting.b = frame[DFM_OPTIONS_LIST[index].detection](frame); |
||
611 | elseif (DFM_OPTIONS_LIST[index].detection == "GetParent" and frame.GetParent and frame:GetParent() and frame:GetParent().GetName and frame:GetParent():GetName()) then |
||
612 | setting = frame:GetParent():GetName(); |
||
613 | elseif (DFM_OPTIONS_LIST[index].detection == "GetFont") then |
||
614 | local font, fontHeight = frame:GetFont(); |
||
615 | if (font and DFM_OPTIONS_LIST[index].option == 3) then |
||
616 | setting = font; |
||
617 | elseif (fontHeight and DFM_OPTIONS_LIST[index].option == 4) then |
||
618 | setting = fontHeight; |
||
619 | else |
||
620 | setting = DFM_OPTIONS_LIST[index].default; |
||
621 | end |
||
622 | elseif (DFM_OPTIONS_LIST[index].detection and frame[DFM_OPTIONS_LIST[index].detection]) then |
||
623 | setting = frame[DFM_OPTIONS_LIST[index].detection](frame); |
||
624 | else |
||
625 | setting = DFM_OPTIONS_LIST[index].default; |
||
626 | end |
||
627 | end |
||
628 | |||
629 | if (DFM_OPTIONS_LIST[index].scale) then |
||
630 | setting = setting * DFM_OPTIONS_LIST[index].scale; |
||
631 | end |
||
632 | if (type(setting) == "number") then |
||
633 | setting = DL_round(setting, 1); |
||
634 | end |
||
635 | |||
636 | if (DFM_OPTIONS_LIST[index].option == 1 or DFM_OPTIONS_LIST[index].option == 7) then |
||
637 | DL_Init_EditBox(option, setting); |
||
638 | elseif (DFM_OPTIONS_LIST[index].option == 2) then |
||
639 | option.menu = "DFM_DropMenu"; |
||
640 | option.table = DFM_OPTIONS_LIST[index].table; |
||
641 | option.index = index; |
||
642 | DL_Init_MenuControl(option, setting); |
||
643 | elseif (DFM_OPTIONS_LIST[index].option == 3) then |
||
644 | option.menu = "DFM_ScrollMenu"; |
||
645 | option.table = DFM_OPTIONS_LIST[index].table; |
||
646 | option.index = index; |
||
647 | DL_Init_MenuControl(option, setting, 1); |
||
648 | elseif (DFM_OPTIONS_LIST[index].option == 4) then |
||
649 | option:SetMinMaxValues(DFM_OPTIONS_LIST[index].min, DFM_OPTIONS_LIST[index].max); |
||
650 | getglobal(option:GetName().."Low"):SetText(DFM_OPTIONS_LIST[index].min); |
||
651 | getglobal(option:GetName().."High"):SetText(DFM_OPTIONS_LIST[index].max); |
||
652 | option:SetValue(setting); |
||
653 | getglobal(option:GetName().."_Display"):SetText(setting); |
||
654 | elseif (DFM_OPTIONS_LIST[index].option == 5) then |
||
655 | DL_Init_CheckBox(option, setting); |
||
656 | elseif (DFM_OPTIONS_LIST[index].option == 6) then |
||
657 | DL_Init_ColorPicker(option, setting); |
||
658 | end |
||
659 | |||
660 | if (DFM_OPTIONS_LIST[index + 1] and DFM_OPTIONS_LIST[index + 1].method == DFM_OPTIONS_LIST[index].method) then |
||
661 | border:Hide(); |
||
662 | else |
||
663 | border:Show(); |
||
664 | end |
||
665 | |||
666 | if (index == 1 or DFM_OPTIONS_LIST[index - 1].method == DFM_OPTIONS_LIST[index].method) then |
||
667 | useButton:Hide(); |
||
668 | lockButton:Hide(); |
||
669 | if (index == 1) then |
||
670 | helpButton:Show(); |
||
671 | else |
||
672 | helpButton:Hide(); |
||
673 | end |
||
674 | else |
||
675 | useButton.method = DFM_OPTIONS_LIST[index].method; |
||
676 | lockButton.method = DFM_OPTIONS_LIST[index].method; |
||
677 | useButton:Show(); |
||
678 | lockButton:Show(); |
||
679 | helpButton:Show(); |
||
680 | DL_Init_CheckBox(useButton, DFM_Get_MethodSetting(useButton.method, "use")); |
||
681 | DL_Init_CheckBox(lockButton, DFM_Get_MethodSetting(lockButton.method, "lock")); |
||
682 | end |
||
683 | if (not button.help) then |
||
684 | helpButton:Hide(); |
||
685 | end |
||
686 | else |
||
687 | button:Hide(); |
||
688 | end |
||
689 | end |
||
690 | |||
691 | FauxScrollFrame_Update(DFM_Options_OptionsMenu, numOptions, 7, 40); |
||
692 | DFM_Options_OptionsMenu:Show(); |
||
693 | end |
||
694 | |||
695 | function DFM_Paste_Settings() |
||
696 | if (not DFM_BUFFER) then return; end |
||
697 | local buffer = {}; |
||
698 | DL_Copy_Table(DFM_BUFFER, buffer); |
||
699 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
700 | local frameName = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
701 | local frame = getglobal(frameName); |
||
702 | for method in buffer do |
||
703 | if (tonumber(method)) then |
||
704 | local m = DFM_METHODS_LIST[method].method; |
||
705 | if (not frame[m]) then |
||
706 | buffer[method] = nil; |
||
707 | end |
||
708 | end |
||
709 | end |
||
710 | local oldName = DFM_Settings[DFM_INDEX][header][frameName].name; |
||
711 | DFM_Settings[DFM_INDEX][header][frameName] = {}; |
||
712 | DL_Copy_Table(buffer, DFM_Settings[DFM_INDEX][header][frameName]); |
||
713 | DFM_Settings[DFM_INDEX][header][frameName].name = oldName; |
||
714 | DFM_Initialize_Frame(header, frameName); |
||
715 | DFM_OptionsMenu_Update(); |
||
716 | DFM_Update_LocationSettings(); |
||
717 | DFM_ReloadUIFrame:Show(); |
||
718 | end |
||
719 | |||
720 | function DFM_PlusButton_OnClick() |
||
721 | local value = this:GetParent():GetNumber(); |
||
722 | if (not value) then |
||
723 | value = 0; |
||
724 | end |
||
725 | value = value + 1; |
||
726 | this:GetParent():SetText(value); |
||
727 | DFM_Update_Setting(this:GetParent():GetParent().index, value); |
||
728 | end |
||
729 | |||
730 | function DFM_Remove_Frame() |
||
731 | if (not DFM_SELECTED_INDEX) then return; end |
||
732 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
733 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
734 | if (DFM_Settings[DFM_INDEX][header][frame].customFrame) then |
||
735 | local f = getglobal(frame); |
||
736 | f:Hide(); |
||
737 | f.Show = function() end; |
||
738 | if (f.UnregisterAllEvents) then |
||
739 | f:UnregisterAllEvents(); |
||
740 | end |
||
741 | end |
||
742 | DFM_Settings[DFM_INDEX][header][frame] = nil; |
||
743 | DFM_SELECTED_INDEX = nil; |
||
744 | DFM_OPTIONS_LIST = {}; |
||
745 | DFM_Update_FrameList(); |
||
746 | DFM_FrameMenu_Update(); |
||
747 | DFM_OptionsMenu_Update(); |
||
748 | DFM_ReloadUIFrame:Show(); |
||
749 | end |
||
750 | |||
751 | function DFM_Reset_Frame() |
||
752 | if (not DFM_SELECTED_INDEX) then return; end |
||
753 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
754 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
755 | local oldName = DFM_Settings[DFM_INDEX][header][frame].name; |
||
756 | DFM_Settings[DFM_INDEX][header][frame] = {name=oldName}; |
||
757 | DFM_OptionsMenu_Update(); |
||
758 | DFM_Update_LocationSettings(); |
||
759 | DFM_ReloadUIFrame:Show(); |
||
760 | end |
||
761 | |||
762 | function DFM_ScrollMenu_OnClick() |
||
763 | this:GetParent():Hide(); |
||
764 | if (DFM_ScrollMenu.index == "scrolltoheader") then |
||
765 | DFM_Options_FrameMenuScrollBar:SetValue(20 * (this.value - 1)); |
||
766 | else |
||
767 | local text = ""; |
||
768 | local list = getglobal(DFM_ScrollMenu.table); |
||
769 | for _, value in list do |
||
770 | if (value.value == this.value) then |
||
771 | text = value.text; |
||
772 | end |
||
773 | end |
||
774 | getglobal(DFM_ScrollMenu.controlbox):SetText(text); |
||
775 | DFM_Update_Setting(DFM_ScrollMenu.index, this.value); |
||
776 | end |
||
777 | end |
||
778 | |||
779 | function DFM_ScrollMenu_Update() |
||
780 | local list = getglobal(this:GetParent().table); |
||
781 | if (not list) then return; end |
||
782 | local numOptions = table.getn(list); |
||
783 | local offset = FauxScrollFrame_GetOffset(DFM_ScrollMenu_ScrollFrame); |
||
784 | if (not offset) then offset = 0; end |
||
785 | local index, button; |
||
786 | |||
787 | for i=1, 10 do |
||
788 | button = getglobal("DFM_ScrollMenu_Button"..i); |
||
789 | buttontext = getglobal("DFM_ScrollMenu_Button"..i.."Text"); |
||
790 | index = offset + i; |
||
791 | if ( list[index] ) then |
||
792 | buttontext:SetText(list[index].text); |
||
793 | button:Show(); |
||
794 | button:SetChecked(0); |
||
795 | button.value = list[index].value; |
||
796 | button.desc = list[index].desc; |
||
797 | else |
||
798 | button:Hide(); |
||
799 | end |
||
800 | end |
||
801 | |||
802 | FauxScrollFrame_Update(DFM_ScrollMenu_ScrollFrame, numOptions, 10, 20 ); |
||
803 | end |
||
804 | |||
805 | function DFM_Slider_OnValueChanged() |
||
806 | if (not DFM_INITIALIZED) then return; end |
||
807 | local optionIndex = this:GetParent().index; |
||
808 | local setting = DFM_Get_Setting(optionIndex); |
||
809 | if (not setting) then return; end |
||
810 | if (DFM_OPTIONS_LIST[optionIndex].scale) then |
||
811 | setting = setting * DFM_OPTIONS_LIST[optionIndex].scale; |
||
812 | end |
||
813 | if (setting == this:GetValue()) then return; end |
||
814 | local min, max = this:GetMinMaxValues(); |
||
815 | if (setting < min or setting > max) then |
||
816 | return; |
||
817 | end |
||
818 | local value = this:GetValue(); |
||
819 | value = DL_round(value, 2); |
||
820 | getglobal(this:GetName().."_Display"):SetText(value); |
||
821 | if (DFM_OPTIONS_LIST[optionIndex].scale) then |
||
822 | value = value / DFM_OPTIONS_LIST[optionIndex].scale; |
||
823 | end |
||
824 | DFM_Update_Setting(optionIndex, value); |
||
825 | end |
||
826 | |||
827 | function DFM_SliderEditBox_OnEnterPressed() |
||
828 | local value = this:GetNumber(); |
||
829 | local optionIndex = this:GetParent():GetParent().index; |
||
830 | if (not value) then value = 0; end |
||
831 | local min, max = this:GetParent():GetMinMaxValues(); |
||
832 | if (this:GetParent().minlocked and value < min) then value = min; end |
||
833 | if (this:GetParent().maxlocked and value > max) then value = max; end |
||
834 | this:SetText(value); |
||
835 | if (value >= min and value <= max) then |
||
836 | this:GetParent():SetValue(value); |
||
837 | end |
||
838 | this:ClearFocus(); |
||
839 | if (DFM_OPTIONS_LIST[optionIndex].scale) then |
||
840 | value = value / DFM_OPTIONS_LIST[optionIndex].scale; |
||
841 | end |
||
842 | DFM_Update_Setting(optionIndex, value); |
||
843 | end |
||
844 | |||
845 | function DFM_Start_Dragging() |
||
846 | local frame = getglobal(DFM_DragFrame.frameindex); |
||
847 | if (not frame) then return; end |
||
848 | frame:ClearAllPoints(); |
||
849 | if (frame.DFM_SetPoint) then |
||
850 | frame:DFM_SetPoint("CENTER", this, "CENTER", 0, 0); |
||
851 | else |
||
852 | frame:SetPoint("CENTER", this, "CENTER", 0, 0); |
||
853 | end |
||
854 | this:StartMoving(); |
||
855 | end |
||
856 | |||
857 | function DFM_Stop_Dragging() |
||
858 | this:StopMovingOrSizing(); |
||
859 | if (not DFM_DRAG_INDEX) then return; end |
||
860 | local header = DFM_FRAME_LIST[DFM_DRAG_INDEX].header; |
||
861 | local frame = DFM_FRAME_LIST[DFM_DRAG_INDEX].frame; |
||
862 | local settings = DFM_Settings[DFM_INDEX][header][frame].Location; |
||
863 | local x, y = DL_Get_Offsets(DFM_DragFrame, getglobal(settings.frame), settings.point, settings.to); |
||
864 | settings.x = x; |
||
865 | settings.y = y; |
||
866 | DFM_Initialize_FrameLocation(header, frame); |
||
867 | if (DFM_DRAG_INDEX == DFM_SELECTED_INDEX) then |
||
868 | DFM_Update_LocationSettings(); |
||
869 | end |
||
870 | end |
||
871 | |||
872 | function DFM_Summon_DragFrame(override) |
||
873 | if (not DFM_SELECTED_INDEX) then return; end |
||
874 | if (DFM_DragFrame:IsVisible() and (not override)) then |
||
875 | DFM_Stop_Dragging(); |
||
876 | DFM_DragFrame:Hide(); |
||
877 | DFM_DRAG_INDEX = nil; |
||
878 | return; |
||
879 | end |
||
880 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
881 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
882 | local settings = DFM_Settings[DFM_INDEX][header][frame].Location; |
||
883 | if (not settings) then return; end |
||
884 | if (not settings.use) then return; end |
||
885 | DFM_DragFrame.frameindex = frame; |
||
886 | DFM_DragFrame_FrameName:SetText(frame); |
||
887 | frame = getglobal(frame); |
||
888 | local height = frame:GetHeight(); |
||
889 | local width = frame:GetWidth(); |
||
890 | if (height < 50) then height = 50; end |
||
891 | if (width < 50) then width = 50; end |
||
892 | local scale; |
||
893 | if (frame.GetEffectiveScale) then |
||
894 | scale = frame:GetEffectiveScale(); |
||
895 | else |
||
896 | scale = 1; |
||
897 | end |
||
898 | DFM_DragFrame:SetHeight(height); |
||
899 | DFM_DragFrame:SetWidth(width); |
||
900 | DFM_DragFrame:SetScale(scale); |
||
901 | DFM_DragFrame:ClearAllPoints(); |
||
902 | DFM_DragFrame:SetPoint(settings.point, settings.frame, settings.to, settings.x, settings.y); |
||
903 | DFM_DragFrame:Show(); |
||
904 | DFM_DRAG_INDEX = DFM_SELECTED_INDEX; |
||
905 | end |
||
906 | |||
907 | function DFM_Update_AnchorFrame() |
||
908 | this:ClearFocus(); |
||
909 | local value = this:GetText(); |
||
910 | if ((not value) or value == "" or (not getglobal(value))) then |
||
911 | this:SetText(this.prevvalue); |
||
912 | return; |
||
913 | end |
||
914 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
915 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
916 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then |
||
917 | this:SetText(this.prevvalue); |
||
918 | else |
||
919 | DFM_Settings[DFM_INDEX][header][frame].Location.frame = value; |
||
920 | DFM_Initialize_FrameLocation(header, frame); |
||
921 | end |
||
922 | end |
||
923 | |||
924 | function DFM_Update_FrameList() |
||
925 | DFM_FRAME_LIST = {}; |
||
926 | DFM_HEADERS_LIST = {}; |
||
927 | local headers = {}; |
||
928 | local index = 1; |
||
929 | for header in DFM_Settings[DFM_INDEX] do |
||
930 | headers[index] = header; |
||
931 | index = index + 1; |
||
932 | end |
||
933 | DL_Sort(headers); |
||
934 | |||
935 | index = 0; |
||
936 | hindex = 0; |
||
937 | for _, header in headers do |
||
938 | hindex = hindex + 1; |
||
939 | index = index + 1; |
||
940 | DFM_HEADERS_LIST[hindex] = {text=header, value=index}; |
||
941 | DFM_FRAME_LIST[index] = {text=header, headerFlag=true}; |
||
942 | |||
943 | local frames = {}; |
||
944 | local frameRealName = {}; |
||
945 | local i = 0; |
||
946 | for frame in DFM_Settings[DFM_INDEX][header] do |
||
947 | if (getglobal(frame)) then |
||
948 | i = i + 1; |
||
949 | frames[i] = DFM_Settings[DFM_INDEX][header][frame].name; |
||
950 | frameRealName[frames[i]] = frame; |
||
951 | end |
||
952 | end |
||
953 | DL_Sort(frames); |
||
954 | for i=1, table.getn(frames) do |
||
955 | index = index + 1; |
||
956 | local frameType = ""; |
||
957 | local frame = getglobal(frameRealName[frames[i]]); |
||
958 | if (frame.GetFrameType) then |
||
959 | frameType = frame:GetFrameType(); |
||
960 | elseif (frame.SetFont) then |
||
961 | frameType = "FontString"; |
||
962 | else |
||
963 | frameType = "Texture"; |
||
964 | end |
||
965 | DFM_FRAME_LIST[index] = {text=frames[i], header=header, frame=frameRealName[frames[i]], frameType=frameType}; |
||
966 | for m,v in DFM_Settings[DFM_INDEX][header][frameRealName[frames[i]]] do |
||
967 | if (tonumber(m) and v.use) then |
||
968 | DFM_FRAME_LIST[index].modified = 1; |
||
969 | elseif (m == "Location" and v.use) then |
||
970 | DFM_FRAME_LIST[index].modified = 1; |
||
971 | elseif (m == "forceHide" and v) then |
||
972 | DFM_FRAME_LIST[index].modified = 1; |
||
973 | elseif (m == "customFrame") then |
||
974 | DFM_FRAME_LIST[index].modified = 1; |
||
975 | end |
||
976 | end |
||
977 | end |
||
978 | end |
||
979 | end |
||
980 | |||
981 | function DFM_Update_LocationSettings() |
||
982 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
983 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
984 | local settings = DFM_Get_LocSettings(header, frame); |
||
985 | DL_Init_EditBox(DFM_Options_XOffset, settings.x); |
||
986 | DL_Init_EditBox(DFM_Options_YOffset, settings.y); |
||
987 | DL_Init_EditBox(DFM_Options_AnchorFrame, settings.frame); |
||
988 | DL_Init_MenuControl(DFM_Options_AnchorPoint, settings.point); |
||
989 | DL_Init_MenuControl(DFM_Options_AnchorTo, settings.to); |
||
990 | DL_Init_CheckBox(DFM_Options_UseLocation, settings.use); |
||
991 | DL_Init_CheckBox(DFM_Options_LockLocation, settings.lock); |
||
992 | end |
||
993 | |||
994 | function DFM_Update_MethodSetting(method, index, value) |
||
995 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
996 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
997 | if (not DFM_Settings[DFM_INDEX][header][frame]) then |
||
998 | DFM_Settings[DFM_INDEX][header][frame] = {}; |
||
999 | end |
||
1000 | if (not DFM_Settings[DFM_INDEX][header][frame][method]) then |
||
1001 | DFM_Settings[DFM_INDEX][header][frame][method] = {}; |
||
1002 | end |
||
1003 | DFM_Settings[DFM_INDEX][header][frame][method][index] = value; |
||
1004 | DFM_Initialize_Frame(header, frame); |
||
1005 | end |
||
1006 | |||
1007 | function DFM_Update_OptionsList() |
||
1008 | local headertext = string.upper(string.gsub(DFM_TEXT.Options, "$f", DFM_FRAME_LIST[DFM_SELECTED_INDEX].text)); |
||
1009 | DFM_Options_OptionsMenu_OuterBorder_Header:SetText(headertext); |
||
1010 | DFM_OPTIONS_LIST = {}; |
||
1011 | DFM_OPTIONS_LIST[1] = {name="ForceHide", option=5, help="Hides the frame in a way that will keep anything else from being able to show it."}; |
||
1012 | local frame = getglobal(DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame); |
||
1013 | local index = 1; |
||
1014 | for methodIndex,value in DFM_METHODS_LIST do |
||
1015 | if (frame[value.method]) then |
||
1016 | for param,option in value.options do |
||
1017 | index = index + 1; |
||
1018 | DFM_OPTIONS_LIST[index] = {}; |
||
1019 | DL_Copy_Table(option, DFM_OPTIONS_LIST[index]); |
||
1020 | DFM_OPTIONS_LIST[index].method = methodIndex; |
||
1021 | DFM_OPTIONS_LIST[index].param = param; |
||
1022 | DFM_OPTIONS_LIST[index].detection = value.detection; |
||
1023 | DFM_OPTIONS_LIST[index].help = value.help; |
||
1024 | end |
||
1025 | end |
||
1026 | end |
||
1027 | DFM_OptionsMenu_Update(); |
||
1028 | DFM_Update_LocationSettings(); |
||
1029 | end |
||
1030 | |||
1031 | function DFM_Update_Profiles() |
||
1032 | DFM_PROFILES = {}; |
||
1033 | for profile in DFM_Settings do |
||
1034 | if ((not string.find(profile, "INITIALIZED")) and (not string.find(profile, " :: ")) and profile ~= "LoadOnDemandFunctions" and profile ~= "usetooltipanchor" and profile ~= "usecontaineranchors") then |
||
1035 | local i = table.getn(DFM_PROFILES) + 1; |
||
1036 | DFM_PROFILES[i] = { text=profile, value=profile }; |
||
1037 | if (profile == "Default") then |
||
1038 | DFM_PROFILES[i].desc = "This profile will be used initially by any new character you create or characters on whom you haven't loaded Discord Frame Modifier yet."; |
||
1039 | elseif (profile == "Custom") then |
||
1040 | DFM_PROFILES[i].desc = "This profile holds settings from the DFM_Custom.lua file in the mod's folder. CHANGES TO THIS PROFILE WILL NOT BE SAVED. Load this profile and immediately create a new profile if you want to make changes."; |
||
1041 | end |
||
1042 | end |
||
1043 | end |
||
1044 | end |
||
1045 | |||
1046 | function DFM_Update_Setting(index, value) |
||
1047 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
1048 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
1049 | local method = DFM_OPTIONS_LIST[index].method; |
||
1050 | local param = DFM_OPTIONS_LIST[index].param; |
||
1051 | if (index == 1) then |
||
1052 | DFM_Settings[DFM_INDEX][header][frame].forceHide = value; |
||
1053 | if (not value) then |
||
1054 | DFM_ReloadUIFrame:Show(); |
||
1055 | end |
||
1056 | else |
||
1057 | if (not DFM_Settings[DFM_INDEX][header][frame][method]) then |
||
1058 | DFM_Settings[DFM_INDEX][header][frame][method] = {}; |
||
1059 | end |
||
1060 | DFM_Settings[DFM_INDEX][header][frame][method][param] = value; |
||
1061 | end |
||
1062 | DFM_Initialize_Frame(header, frame); |
||
1063 | end |
||
1064 | |||
1065 | function DFM_Update_XOffset() |
||
1066 | this:ClearFocus(); |
||
1067 | local value = this:GetNumber(); |
||
1068 | if (not value or value == "") then |
||
1069 | value = 0; |
||
1070 | this:SetText(0); |
||
1071 | end |
||
1072 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
1073 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
1074 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then |
||
1075 | this:SetText(this.prevvalue); |
||
1076 | return; |
||
1077 | end |
||
1078 | DFM_Settings[DFM_INDEX][header][frame].Location.x = value; |
||
1079 | DFM_Initialize_FrameLocation(header, frame); |
||
1080 | end |
||
1081 | |||
1082 | function DFM_Update_YOffset() |
||
1083 | this:ClearFocus(); |
||
1084 | local value = this:GetNumber(); |
||
1085 | if (not value or value == "") then |
||
1086 | value = 0; |
||
1087 | this:SetText(0); |
||
1088 | end |
||
1089 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
1090 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
1091 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then |
||
1092 | this:SetText(this.prevvalue); |
||
1093 | return; |
||
1094 | end |
||
1095 | DFM_Settings[DFM_INDEX][header][frame].Location.y = value; |
||
1096 | DFM_Initialize_FrameLocation(header, frame); |
||
1097 | end |
||
1098 | |||
1099 | function DFM_UseCheckBox_OnClick() |
||
1100 | if (this:GetChecked()) then |
||
1101 | DFM_Init_Settings(this.method); |
||
1102 | DFM_Update_MethodSetting(this.method, "use", 1); |
||
1103 | DFM_OptionsMenu_Update(); |
||
1104 | else |
||
1105 | DFM_Update_MethodSetting(this.method, "use"); |
||
1106 | DFM_ReloadUIFrame:Show(); |
||
1107 | end |
||
1108 | end |
||
1109 | |||
1110 | function DFM_UseLocationCheckBox_OnClick() |
||
1111 | local header = DFM_FRAME_LIST[DFM_SELECTED_INDEX].header; |
||
1112 | local frame = DFM_FRAME_LIST[DFM_SELECTED_INDEX].frame; |
||
1113 | if (this:GetChecked()) then |
||
1114 | if (not DFM_Settings[DFM_INDEX][header][frame].Location) then |
||
1115 | DFM_Settings[DFM_INDEX][header][frame].Location = DFM_Get_LocSettings(header, frame); |
||
1116 | end |
||
1117 | DFM_Settings[DFM_INDEX][header][frame].Location.use = 1; |
||
1118 | DFM_Initialize_FrameLocation(header, frame); |
||
1119 | else |
||
1120 | DFM_Settings[DFM_INDEX][header][frame].Location.use = nil; |
||
1121 | DFM_ReloadUIFrame:Show(); |
||
1122 | end |
||
1123 | end |