vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --ColorPicker ID |
2 | local num; |
||
3 | |||
4 | local function outline2int(key) |
||
5 | if (SAVars[key].outline == "THICKOUTLINE") then |
||
6 | return 3; |
||
7 | elseif (SAVars[key].outline == "OUTLINE") then |
||
8 | return 2; |
||
9 | else |
||
10 | return 1; |
||
11 | end |
||
12 | end |
||
13 | |||
14 | local function int2outline(int) |
||
15 | if (int == 3) then |
||
16 | return "THICKOUTLINE"; |
||
17 | elseif (int == 2) then |
||
18 | return "OUTLINE"; |
||
19 | else |
||
20 | return ""; |
||
21 | end |
||
22 | end |
||
23 | |||
24 | local function int2outlinetext(int) |
||
25 | if (int == 3) then |
||
26 | return "Thick"; |
||
27 | elseif (int == 2) then |
||
28 | return "Normal"; |
||
29 | else |
||
30 | return "None"; |
||
31 | end |
||
32 | end |
||
33 | |||
34 | local function checked2bool(int) |
||
35 | if (int) then |
||
36 | return true; |
||
37 | else |
||
38 | return false; |
||
39 | end |
||
40 | end |
||
41 | |||
42 | function SAO_MainFrame_OnLoad() |
||
43 | tinsert(UISpecialFrames,"SAO_MainFrame"); |
||
44 | |||
45 | PanelTemplates_SetNumTabs(SAO_MainFrame, 4); |
||
46 | SAO_MainFrame.selectedTab=1; |
||
47 | PanelTemplates_UpdateTabs(SAO_MainFrame); |
||
48 | |||
49 | SAO_OptionFrame1:Show(); |
||
50 | end |
||
51 | |||
52 | function SAO_CheckButton_OnLoad(str) |
||
53 | local buttonText = getglobal(this:GetName().."Text"); |
||
54 | buttonText:SetText(str); |
||
55 | -- buttonText:SetWidth(buttonText:GetStringWidth() + 5); |
||
56 | end |
||
57 | |||
58 | function SAO_CheckButton_OnClick() |
||
59 | if ( this:GetChecked() ) then |
||
60 | PlaySound("igMainMenuOptionCheckBoxOn"); |
||
61 | else |
||
62 | PlaySound("igMainMenuOptionCheckBoxOff"); |
||
63 | end |
||
64 | end |
||
65 | |||
66 | function SAO_MainFrame_OnShow() |
||
67 | PlaySound("igMainMenuClose"); |
||
68 | end |
||
69 | |||
70 | function SAO_MainFrame_OnHide() |
||
71 | PlaySound("igMainMenuClose"); |
||
72 | end |
||
73 | |||
74 | local function HideAllOptionFrames() |
||
75 | SAO_OptionFrame1:Hide(); |
||
76 | SAO_OptionFrame2:Hide(); |
||
77 | SAO_OptionFrame3:Hide(); |
||
78 | SAO_OptionFrame4:Hide(); |
||
79 | end |
||
80 | |||
81 | function SAO_MainFrameTab_OnClick() |
||
82 | HideAllOptionFrames(); |
||
83 | getglobal("SAO_OptionFrame"..this:GetID()):Show(); |
||
84 | PlaySound("igCharacterInfoTab"); |
||
85 | end |
||
86 | |||
87 | function SAO_OptionFrame_OnShow() |
||
88 | local frame = this:GetName(); |
||
89 | if (frame == "SAO_OptionFrame1") then |
||
90 | SAO_CheckButtonOn:SetChecked(SAVars.on); |
||
91 | SAO_CheckButtonOffOnRest:SetChecked(SAVars.offonrest); |
||
92 | for i = 0, 9 do |
||
93 | getglobal("SAO_CheckButton"..i):SetChecked(SAVars[i].on); |
||
94 | getglobal("SAO_CheckButton"..i.."TO"):SetChecked(SAVars[i].to); |
||
95 | getglobal("SAO_CheckButton"..i.."Short"):SetChecked(SAVars[i].short); |
||
96 | getglobal("SAO_CheckButton"..i.."Color"):SetID(i); |
||
97 | getglobal("SAO_CheckButton"..i.."ColorTexture"):SetVertexColor(SAVars[i].r, SAVars[i].g, SAVars[i].b); |
||
98 | end |
||
99 | else |
||
100 | local key = "alert"..this:GetID()-1; |
||
101 | getglobal(frame.."EditBox1"):SetText(SAVars[key].size); |
||
102 | getglobal(frame.."EditBox2"):SetText(SAVars[key].holdTime); |
||
103 | getglobal(frame.."EditBox3"):SetText(SAVars[key].fadeTime); |
||
104 | getglobal(frame.."EditBox4"):SetText(SAVars[key].lines); |
||
105 | getglobal(frame.."EditBox5"):SetText(SAVars[key].space); |
||
106 | |||
107 | getglobal(frame.."Slider1Text"):SetText(SAO_STR_ALPHA); |
||
108 | getglobal(frame.."Slider1Low"):SetText("0"); |
||
109 | getglobal(frame.."Slider1High"):SetText("1"); |
||
110 | getglobal(frame.."Slider1"):SetMinMaxValues(0, 1); |
||
111 | getglobal(frame.."Slider1"):SetValueStep(0.01); |
||
112 | getglobal(frame.."Slider1"):SetValue(SAVars[key].alpha); |
||
113 | |||
114 | getglobal(frame.."Slider2Text"):SetText(SAO_STR_OUTLINE); |
||
115 | getglobal(frame.."Slider2Low"):SetText("1"); |
||
116 | getglobal(frame.."Slider2High"):SetText("3"); |
||
117 | getglobal(frame.."Slider2"):SetMinMaxValues(1, 3); |
||
118 | getglobal(frame.."Slider2"):SetValueStep(1); |
||
119 | getglobal(frame.."Slider2"):SetValue(outline2int(key)); |
||
120 | |||
121 | local num = this:GetID()-1; |
||
122 | for i = 0, 9 do |
||
123 | getglobal(frame.."CheckButton"..i):SetChecked(false); |
||
124 | if (SAVars[i].alert == num) then |
||
125 | getglobal(frame.."CheckButton"..i):SetChecked(true); |
||
126 | end |
||
127 | end |
||
128 | end |
||
129 | end |
||
130 | |||
131 | function SAO_OptionFrame_OnHide() |
||
132 | local frame = this:GetName(); |
||
133 | if (frame == "SAO_OptionFrame1") then |
||
134 | SAVars.on = checked2bool(SAO_CheckButtonOn:GetChecked()); |
||
135 | SAVars.offonrest = checked2bool(SAO_CheckButtonOffOnRest:GetChecked()); |
||
136 | for i = 0, 9 do |
||
137 | SAVars[i].on = checked2bool(getglobal("SAO_CheckButton"..i):GetChecked()); |
||
138 | SAVars[i].to = checked2bool(getglobal("SAO_CheckButton"..i.."TO"):GetChecked()); |
||
139 | SAVars[i].short = checked2bool(getglobal("SAO_CheckButton"..i.."Short"):GetChecked()); |
||
140 | end |
||
141 | else |
||
142 | local num = this:GetID()-1; |
||
143 | for i = 0, 9 do |
||
144 | if (getglobal(frame.."CheckButton"..i):GetChecked()) then |
||
145 | SAVars[i].alert = num; |
||
146 | end |
||
147 | getglobal(frame.."CheckButton"..i):SetChecked(false); |
||
148 | end |
||
149 | end |
||
150 | end |
||
151 | |||
152 | function SAO_EditBox_OnEditFocusLost(key) |
||
153 | this:HighlightText(0, 0); |
||
154 | |||
155 | local num = (this:GetParent()):GetID()-1; |
||
156 | local val = tonumber(this:GetText()); |
||
157 | |||
158 | if (not key) then |
||
159 | return; |
||
160 | elseif (type(val) ~= "number") then |
||
161 | message(SAO_STR_NAN); |
||
162 | elseif ((val < SALimits[key].min) or (val > SALimits[key].max)) then |
||
163 | this:SetText(SAVars["alert"..num][key]); |
||
164 | message(SAO_STR_MIN..SALimits[key].min..SAO_STR_MAX..SALimits[key].max); |
||
165 | |||
166 | else |
||
167 | SAVars["alert"..num][key] = val; |
||
168 | SA_SMF_UpdateLook(num); |
||
169 | end |
||
170 | end |
||
171 | |||
172 | function SAO_CheckButtonColor_OnClick() |
||
173 | num = this:GetID(); |
||
174 | |||
175 | ColorPickerFrame.hasOpacity = false; |
||
176 | ColorPickerFrame.previousValues = { SAVars[num].r, SAVars[num].g, SAVars[num].b }; |
||
177 | ColorPickerFrame.func = SAO_ColorPickerFrame_Func; |
||
178 | ColorPickerFrame.cancelFunc = SAO_ColorPickerFrame_CancelFunc; |
||
179 | |||
180 | ColorPickerFrame:SetColorRGB(SAVars[num].r, SAVars[num].g, SAVars[num].b); |
||
181 | ColorPickerFrame:Show(); |
||
182 | end |
||
183 | |||
184 | function SAO_ColorPickerFrame_Func() |
||
185 | local red, green, blue = ColorPickerFrame:GetColorRGB(); |
||
186 | getglobal("SAO_CheckButton"..num.."ColorTexture"):SetVertexColor(red, green, blue); |
||
187 | SAVars[num].r = red; |
||
188 | SAVars[num].g = green; |
||
189 | SAVars[num].b = blue; |
||
190 | end |
||
191 | |||
192 | function SAO_ColorPickerFrame_CancelFunc(prevvals) |
||
193 | SAVars[num].r, SAVars[num].g, SAVars[num].b = unpack(prevvals); |
||
194 | getglobal("SAO_CheckButton"..num.."ColorTexture"):SetVertexColor(SAVars[num].r, SAVars[num].g, SAVars[num].b); |
||
195 | end |
||
196 | |||
197 | function SAO_Button_OnClick(k) |
||
198 | local saDrag = getglobal("SA_Drag"..k); |
||
199 | if (saDrag:IsVisible()) then |
||
200 | SAVars["alert"..k].top = saDrag:GetTop(); |
||
201 | SAVars["alert"..k].left = saDrag:GetLeft(); |
||
202 | saDrag:Hide(); |
||
203 | else |
||
204 | saDrag:Show(); |
||
205 | end |
||
206 | end |
||
207 | |||
208 | function SAO_Slider1_OnValueChanged() |
||
209 | local num = (this:GetParent()):GetID()-1; |
||
210 | |||
211 | getglobal(this:GetName().."Value"):SetText(this:GetValue()); |
||
212 | SAVars["alert"..num].alpha = this:GetValue(); |
||
213 | getglobal("SA_SMF"..num):SetAlpha(this:GetValue()); |
||
214 | end |
||
215 | |||
216 | function SAO_Slider2_OnValueChanged() |
||
217 | local num = (this:GetParent()):GetID()-1; |
||
218 | |||
219 | getglobal(this:GetName().."Value"):SetText(int2outlinetext(this:GetValue())); |
||
220 | SAVars["alert"..num].outline = int2outline(this:GetValue()); |
||
221 | SA_SMF_UpdateLook(num); |
||
222 | end |