vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -- XPerl_OptionsFrame_SelectFrame
2 function XPerl_OptionsFrame_SelectFrame(frame)
3 XPerl_Options:Show()
4  
5 if (frame == "player") then
6 XPerl_Options_Player:Show()
7 XPerl_Options_Party:Hide()
8 XPerl_Options_Raid:Hide()
9  
10 elseif (frame == "party") then
11 XPerl_Options_Player:Hide()
12 XPerl_Options_Party:Show()
13 XPerl_Options_Raid:Hide()
14  
15 elseif (frame == "raid") then
16 XPerl_Options_Player:Hide()
17 XPerl_Options_Party:Hide()
18 XPerl_Options_Raid:Show()
19 end
20 end
21  
22 -- XPerl_OptionsSetMyText
23 function XPerl_OptionsSetMyText(f, str)
24  
25 if (f and str) then
26 local textFrame = getglobal(f:GetName().."Text")
27  
28 if (textFrame) then
29 textFrame:SetText(getglobal(str))
30 f.tooltipText = getglobal(str.."_DESC")
31  
32 elseif (f:GetFrameType() == "Button") then
33 f:SetText(getglobal(str))
34 f.tooltipText = getglobal(str.."_DESC")
35 end
36  
37 setglobal(str, nil)
38 setglobal(str.."_DESC", nil)
39 end
40 end
41  
42 -- XPerl_GetCheck
43 function XPerl_GetCheck(f)
44 if (f:GetChecked()) then
45 return 1
46 else
47 return 0
48 end
49 end
50  
51 -- DisableSlider
52 local function DisableSlider(frame)
53 OptionsFrame_DisableSlider(frame)
54 getglobal(frame:GetName().."Current"):SetVertexColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
55 end
56  
57 -- EnableSlider
58 local function EnableSlider(frame)
59 OptionsFrame_EnableSlider(frame)
60 getglobal(frame:GetName().."Current"):SetVertexColor(0.4, 0.4, 0.80)
61 end
62  
63 -- XPerl_Options_EnableSibling
64 function XPerl_Options_EnableSibling(sibling, check2nd, check3rd)
65  
66 local siblingName = this:GetParent():GetName().."_"..sibling
67 local siblingFrame = getglobal(siblingName)
68 local second = true
69 local condition = "and"
70  
71 if (type(check2nd) == "string") then
72 condition = check2nd
73 check2nd = check3rd
74 end
75 if (check2nd and type(check2nd) == "table") then
76 second = check2nd:GetChecked()
77 end
78  
79 local result
80 if (condition == "and") then
81 result = (this:GetChecked() and second)
82 elseif (condition == "or") then
83 result = (this:GetChecked() or second)
84 end
85  
86 if (siblingFrame) then
87 if (siblingFrame:GetFrameType() == "Button") then
88 if (result) then
89 siblingFrame:Enable()
90 else
91 siblingFrame:Disable()
92 end
93 elseif (siblingFrame:GetFrameType() == "CheckButton") then
94 local textFrame = getglobal(siblingFrame:GetName().."Text")
95 if (result) then
96 siblingFrame:Enable()
97 textFrame:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b)
98 else
99 siblingFrame:Disable()
100 textFrame:SetTextColor(GRAY_FONT_COLOR.r, GRAY_FONT_COLOR.g, GRAY_FONT_COLOR.b)
101 end
102 elseif (siblingFrame:GetFrameType() == "Slider") then
103 if (result) then
104 EnableSlider(siblingFrame)
105 else
106 DisableSlider(siblingFrame)
107 end
108  
109 else
110 DEFAULT_CHAT_FRAME:AddMessage("|c00FF0000X-Perl|r - No code to disable '"..siblingFrame:GetName().."' type: "..siblingFrame:GetFrameType())
111 end
112 else
113 DEFAULT_CHAT_FRAME:AddMessage("|c00FF0000X-Perl|r - No sibling found called '"..siblingName.."'")
114 end
115 end
116  
117 -- XPerl_Options_IncrementSibling
118 function XPerl_Options_IncrementSibling(sibling)
119 local siblingName = this:GetParent():GetName().."_"..sibling
120 local siblingFrame = getglobal(siblingName)
121  
122 if (siblingFrame and siblingFrame:GetFrameType() == "EditBox") then
123 local n = tonumber(siblingFrame:GetText())
124 n = n + 1
125 siblingFrame:SetText(n)
126 return n
127 end
128 end
129  
130 -- XPerl_Options_DecrementSibling
131 function XPerl_Options_DecrementSibling(sibling)
132 local siblingName = this:GetParent():GetName().."_"..sibling
133 local siblingFrame = getglobal(siblingName)
134  
135 if (siblingFrame and siblingFrame:GetFrameType() == "EditBox") then
136 local n = tonumber(siblingFrame:GetText())
137 n = n - 1
138 siblingFrame:SetText(n)
139 return n
140 end
141 end
142  
143 -- XPerl_Options_CheckRadio
144 function XPerl_Options_CheckRadio(buttons)
145 local prefix = this:GetParent():GetName().."_"
146  
147 for i,name in pairs(buttons) do
148 if (prefix..name == this:GetName()) then
149 getglobal(prefix..name):SetChecked(true)
150 else
151 getglobal(prefix..name):SetChecked(false)
152 end
153 end
154 end
155  
156 -- XPerl_Options_GetSiblingChecked
157 function XPerl_Options_GetSiblingChecked(name)
158 local prefix = this:GetParent():GetName().."_"
159 return getglobal(prefix..name):GetChecked()
160 end
161  
162 -- XPerl_Raid_OptionActions
163 function XPerl_Raid_OptionActions()
164 XPerl_Raid_Position()
165 XPerl_Raid_Set_Bits()
166 end
167  
168 -- XPerl_Options_OnUpdate
169 function XPerl_Options_OnUpdate()
170  
171 if (this.Fading) then
172 local alpha = this:GetAlpha()
173 if (this.Fading == "in") then
174 alpha = alpha + (arg1 * 2) -- elapsed * 2 == fade in/out in 1/2 second
175 if (alpha > 1) then
176 alpha = 1
177 end
178 elseif (this.Fading == "out") then
179 alpha = alpha - (arg1 * 2)
180 if (alpha < 0) then
181 alpha = 0
182 end
183 end
184 this:SetAlpha(alpha)
185 if (alpha == 0) then
186 this.Fading = nil
187 this:Hide()
188 elseif (alpha == 1) then
189 this.Fading = nil
190 end
191 else
192 local f = GetMouseFocus()
193 if (f and f:GetName()) then
194 if (f:GetName() == "XPerl_Player_CastClickOverlay" or strfind(f:GetName(), "Target_CastClickOverlay")) then
195 XPerl_OptionsFrame_SelectFrame("player")
196 elseif (strfind(f:GetName(), "XPerl_party%d_CastClickOverlay")) then
197 XPerl_OptionsFrame_SelectFrame("party")
198 elseif (strfind(f:GetName(), "XPerl_raid(%d+)_CastClickOverlay")) then
199 XPerl_OptionsFrame_SelectFrame("raid")
200 end
201 end
202 end
203 end
204  
205 -- XPerl_Options_SetBarTextureHighlight
206 function XPerl_Options_SetBarTextureHighlight()
207  
208 local name = this:GetName()
209 name = string.sub(name, 1, string.len(name) - 1)
210  
211 for i = 0,3 do
212 local f = getglobal(name..i)
213  
214 if (f) then
215 if (XPerlConfig.BarTextures == i) then
216 f:LockHighlight()
217 else
218 f:UnlockHighlight()
219 end
220 else
221 ChatFrame7:AddMessage("No frame called "..name..i)
222 end
223 end
224 end
225  
226 -- XPerl_Options_MaxScaleSet
227 local Sliders = {}
228 function XPerl_Options_MaxScaleSet()
229  
230 for i,slider in pairs(Sliders) do
231 local old = slider:GetValue()
232 local max = math.floor(XPerlConfig.MaximumScale * 100 + 0.5)
233  
234 getglobal(slider:GetName().."High"):SetText(string.format("%d%%", max))
235 slider:SetMinMaxValues(50, max)
236  
237 if (old > max) then
238 slider:SetValue(max)
239 end
240 end
241 end
242  
243 -- XPerl_Options_RegisterScalingSlider
244 function XPerl_Options_RegisterScalingSlider(slider)
245  
246 Sliders[slider:GetName()] = slider
247  
248 getglobal(slider:GetName().."Low"):SetText("50%")
249 getglobal(slider:GetName().."High"):SetText(string.format("%d%%", math.floor((XPerlConfig.MaximumScale or 1.5) * 100 + 0.5)))
250  
251 slider:SetMinMaxValues(50, math.floor(XPerlConfig.MaximumScale * 100 + 0.5))
252 slider:SetValueStep(1)
253 end
254  
255 -- XPerl_Popup
256 function XPerl_Popup(question, onAccept)
257 StaticPopupDialogs["XPERL_QUESTION"] = {
258 text = question,
259 button1 = YES,
260 button2 = NO,
261 OnAccept = onAccept,
262 timeout = 0,
263 whileDead = 1,
264 hideOnEscape = 1,
265 showAlert = 1
266 }
267 StaticPopup_Show("XPERL_QUESTION")
268 end
269  
270 -- Load settings menu
271 local MyIndex = 0
272 local function GetPlayerList()
273 local ret = {}
274 if (XPerlConfig_Global) then
275 local me = GetRealmName().." / "..UnitName("player")
276 for realmName, realmConfig in pairs(XPerlConfig_Global) do
277 for playerName, settings in pairs(realmConfig) do
278 local entry = realmName.." / "..playerName
279  
280 tinsert(ret, {name = entry, config = settings})
281  
282 if (entry == me) then
283 MyIndex = getn(ret)
284 end
285 end
286 end
287 end
288 return ret
289 end
290  
291 -- XPerl_Options_LoadSettings_OnLoad
292 function XPerl_Options_LoadSettings_OnLoad()
293 UIDropDownMenu_Initialize(this, XPerl_Options_LoadSettings_Initialize)
294 UIDropDownMenu_SetSelectedID(this, MyIndex, 1)
295 UIDropDownMenu_SetWidth(140, XPerl_Options_DropDown_LoadSettings)
296 end
297  
298 -- XPerl_Options_LoadSettings_Initialize
299 function XPerl_Options_LoadSettings_Initialize()
300 XPerl_Options_LoadSettings_LoadList(GetScreenResolutions())
301 end
302  
303 -- XPerl_Options_LoadSettings_LoadList
304 function XPerl_Options_LoadSettings_LoadList(...)
305 local info
306 local list = GetPlayerList()
307  
308 for i,entry in pairs(list) do
309 info = {}
310 info.text = entry.name
311 info.func = XPerl_Options_LoadSettings_OnClick
312 UIDropDownMenu_AddButton(info)
313 end
314 end
315  
316 -- CopySelectedSettings
317 local CopyFrom
318 local function CopySelectedSettings()
319 --ChatFrame7:AddMessage("Copying settings from "..CopyFrom)
320 --UIDropDownMenu_SetSelectedID(XPerl_Options_DropDown_LoadSettings, this:GetID(), 1)
321  
322 XPerlConfig = {}
323 XPerl_Defaults()
324  
325 for name,value in pairs(CopyFrom.config) do
326 XPerlConfig[name] = value
327 end
328  
329 XPerl_Options:Hide()
330 XPerl_Options:Show()
331  
332 XPerl_OptionActions()
333 end
334  
335 -- XPerl_Options_LoadSettings_OnClick
336 function XPerl_Options_LoadSettings_OnClick()
337  
338 local list = GetPlayerList()
339  
340 if (this:GetID() ~= MyIndex) then
341 local entry = list[this:GetID()]
342  
343 if (entry) then
344 CopyFrom = entry
345 XPerl_Popup(string.format("Copy settings from %s?", entry.name), CopySelectedSettings)
346 end
347 end
348 end
349  
350 -- XPerl_Options_SetTabColor
351 function XPerl_Options_SetTabColor(tab, color)
352 for i,y in {"Enabled", "Disabled"} do
353 for j,z in {"Left", "Right", "Middle"} do
354 local f = getglobal(tab:GetName()..y..z)
355 f:SetVertexColor(color.r, color.g, color.b, color.a)
356 end
357 end
358 end
359  
360 -- XPerl_Options_EnableTab
361 function XPerl_Options_EnableTab(tab, enable)
362 for i,y in pairs({"Enabled", "Disabled"}) do
363 for j,z in pairs({"Left", "Right", "Middle"}) do
364 local f = getglobal(tab:GetName()..y..z)
365  
366 if ((i == 1 and enable) or (i == 2 and not enable)) then
367 f:Show()
368 else
369 f:Hide()
370 end
371 end
372 end
373 end