vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 UIPanelWindows["CT_CPFrame"] = { area = "left", pushable = 1 };
2  
3 CT_CPMovable = nil;
4  
5 local CT_CPTabs = {
6 { "General", "General", "Interface\\Icons\\Spell_Shadow_SoulGem" },
7 { "Hotbar Mods", "Hotbar Mods", "Interface\\Icons\\Ability_Rogue_SliceDice" },
8 { "Party Mods", "Party Mods", "Interface\\Icons\\Spell_Nature_Invisibilty" },
9 { "Player Mods", "Player Mods", "Interface\\Icons\\Ability_Warrior_Revenge" },
10 { "Misc. Mods", "Misc. Mods", "Interface\\Icons\\Spell_Frost_Stun" }
11 };
12  
13 function CT_UnlockCP(movable)
14 local show = CT_CPFrame:IsVisible();
15 CT_CPMovable = movable;
16 HideUIPanel(CT_CPFrame);
17 if ( movable ) then
18 tinsert(UISpecialFrames, "CT_CPFrame");
19 UIPanelWindows["CT_CPFrame"] = nil;
20 CT_CPMoveButton:Show();
21 else
22 CT_CPMoveButton:Hide();
23 for key, val in UISpecialFrames do
24 if ( val == "CT_CPFrame" ) then val = nil; end
25 end
26 UIPanelWindows["CT_CPFrame"] = { area = "left", pushable = 1 };
27 end
28 if ( show ) then
29 ShowUIPanel(CT_CPFrame);
30 end
31 end
32 local NUM_CP_TABS = getn(CT_CPTabs);
33 local MAX_CP_TABS = 8;
34 local MAX_CP_ICONS = 14;
35  
36 function CT_CPSetTab(id)
37 for i = 1, getn(CT_CPTabs), 1 do
38 if ( CT_CPFrame_ShallDisplayTabFlash(i) ) then
39 getglobal("CT_CPTab" .. i .. "Flash"):Show();
40 else
41 getglobal("CT_CPTab" .. i .. "Flash"):Hide();
42 end
43 end
44 if ( CT_CPFrame.currTab == id and CT_CPFrame.currPage == 1 ) then
45 getglobal("CT_CPTab" .. id):SetChecked(1);
46 return;
47 end
48 CT_CPFrame.currPage = 1;
49 if ( CT_CPFrame.currTab) then
50 getglobal("CT_CPTab" .. CT_CPFrame.currTab):SetChecked(nil);
51 end
52 getglobal("CT_CPTab" .. id .. "Flash"):Hide();
53 getglobal("CT_CPTab" .. id):SetChecked(1);
54 if ( CT_CPFrame.currTab ~= id ) then
55 CT_CPFrame_HideSlider();
56 end
57 CT_CPFrame.currTab = id;
58 if ( id == 1 ) then
59 CT_CPGeneralSlider:Show();
60 CT_CPGeneralMoveText:Show();
61 CT_CPGeneralMoveCB:Show();
62 CT_CPPrevPage:Hide();
63 CT_CPNextPage:Hide();
64 CT_CPPageText:SetText("");
65 else
66 CT_CPPageText:SetText("Page 1/"..ceil(CT_CPFrame_GetNumMods()/14));
67 CT_CPGeneralSlider:Hide();
68 CT_CPGeneralMoveText:Hide();
69 CT_CPGeneralMoveCB:Hide();
70 CT_CPPrevPage:Show();
71 CT_CPNextPage:Show();
72 end
73 CT_CPTabText:SetText(CT_CPTabs[id][1]);
74 CT_CPFrame_UpdateButtons();
75 end
76  
77 function CT_CPFrame_OnLoad()
78 CT_CPFrame.currPage = 1;
79 this:RegisterEvent("VARIABLES_LOADED");
80 CT_CPTab_OnClick(1);
81 for i = 1, NUM_CP_TABS, 1 do
82 getglobal("CT_CPTab" .. i).tooltiptext = CT_CPTabs[i][2];
83 getglobal("CT_CPTab" .. i):SetNormalTexture(CT_CPTabs[i][3]);
84 getglobal("CT_CPTabButton" .. i).tooltiptext = CT_CPTabs[i][2];
85 end
86 CT_CPFrame_UpdateButtons();
87 CT_CPWelcomeText:SetText(CT_MASTERMOD_CPWELCOMETEXT);
88 end
89  
90 function CT_CPFrame_OnShow()
91 PlaySound("igSpellBookOpen");
92 CT_CPSetTab(CT_CPFrame.currTab or 1);
93 end
94  
95 function CT_CPFrame_Update()
96 for i = 1, MAX_CP_TABS, 1 do
97 if ( i > NUM_CP_TABS ) then
98 getglobal("CT_CPTab" .. i):Hide();
99 else
100 getglobal("CT_CPTab" .. i):Show();
101 end
102 end
103 end
104  
105 function CT_CPFrame_OnHide()
106 PlaySound("igSpellBookClose");
107 CT_CPFrame_HideSlider();
108 end
109  
110 function CT_CPButton_OnEnter()
111 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
112 if ( GameTooltip:SetText(this.tooltiptext) ) then
113 this.updateTooltip = TOOLTIP_UPDATE_TIME;
114 else
115 this.updateTooltip = nil;
116 end
117 end
118  
119 function CT_CPButton_OnUpdate(elapsed)
120 if ( not this.updateTooltip ) then
121 return;
122 end
123  
124 this.updateTooltip = this.updateTooltip - elapsed;
125 if ( this.updateTooltip > 0 ) then
126 return;
127 end
128  
129 if ( GameTooltip:IsOwned(this) ) then
130 CT_CPButton_OnEnter();
131 else
132 this.updateTooltip = nil;
133 end
134 end
135  
136 function CT_CPButton_OnLoad()
137 local buttonid = this:GetID();
138 this:RegisterForClicks("LeftButtonUp", "RightButtonUp");
139 CT_CPButton_UpdateButton();
140 end
141  
142 function CT_CPButton_OnClick()
143 local value = CT_Mods[this.id];
144 if ( not value or not value["modStatus"] ) then return; end
145 if ( value["modStatus"] == "switch" ) then
146 value["modFunc"](this.id, getglobal("CT_CPButton" .. this:GetID() .. "Count"));
147 CT_SaveInfoName(value["modName"]);
148 this:SetChecked("false");
149 CT_CPFrame_HideSlider();
150 return;
151 elseif ( value["modStatus"] == "slider" ) then
152 value["modFunc"](this.id, this);
153 this:SetChecked("false");
154 return;
155 end
156 CT_CPFrame_HideSlider();
157 if ( value["modStatus"] == "off" ) then
158 CT_SetModStatus(value["modName"], "on");
159 this:SetChecked("true");
160 else
161 this:SetChecked("false");
162 CT_SetModStatus(value["modName"], "off");
163 end
164 if ( value["modFunc"] ) then
165 value["modFunc"](this.id);
166 end
167 end
168  
169 function CT_CPButton_OnShow()
170 CT_CPButton_UpdateButton();
171 end
172  
173 function CT_CPButton_UpdateButton(btn)
174 local button;
175 if ( btn ) then
176 button = btn;
177 else
178 button = this;
179 end
180 local i = button:GetID();
181 local icon = getglobal("CT_CPButton"..i .. "NormalTexture");
182 local iconTexture = getglobal("CT_CPButton"..i.."IconTexture");
183 local iconName = getglobal("CT_CPButton"..i.."Name");
184 local iconDescription = getglobal("CT_CPButton"..i.."SubName");
185 local highlightTexture = getglobal("CT_CPButton"..i.."Highlight");
186 local normalTexture = getglobal("CT_CPButton"..i.."NormalTexture");
187 local iconCount = getglobal("CT_CPButton"..i.."Count");
188 local flash = getglobal("CT_CPButton"..i.."Flash");
189  
190 local modString = getglobal("CT_CPButton"..i.."Name");
191 local descriptString = getglobal("CT_CPButton"..i.."SubName");
192 local modName, modDescript, modIcon, modValue;
193 local modId = CT_CPFrame_GetModID(i);
194 local val = CT_Mods[modId];
195 if ( not val ) then
196 button:Hide();
197 if ( flash ) then
198 flash:Hide();
199 end
200 return;
201 else
202 button:Show();
203 end
204  
205 if ( icon ) then icon:Show(); end
206 if ( iconTexture ) then iconTexture:Show(); iconTexture:SetVertexColor(1.0, 1.0, 1.0); end
207 if ( highlightTexture ) then highlightTexture:SetTexture("Interface\\Buttons\\ButtonHilight-Square"); end
208 if ( modString ) then modString:SetTextColor(NORMAL_FONT_COLOR.r, NORMAL_FONT_COLOR.g, NORMAL_FONT_COLOR.b); end
209 modStatus = val["modStatus"];
210 modName = val["modName"];
211 modDescript = val["modDescript"];
212 modIcon = val["modIcon"];
213 modValue = val["modValue"];
214 button.tooltiptext = val["modTooltip"];
215 button.id = modId;
216  
217 if ( val["modOnDisplay"] and type(val["modOnDisplay"]) == "function" and this:IsVisible() ) then
218 val["modOnDisplay"](modName, modStatus, modValue, iconCount);
219 end
220  
221 if ( not val["hasBeenDisplayed"] and CT_CPFrame.currTab ~= 1 ) then
222 if ( flash ) then
223 flash:Show();
224 end
225 CT_Mods[modId]["hasBeenDisplayed"] = 1;
226 CT_SaveInfoName(modId);
227 elseif ( flash ) then
228 flash:Hide();
229 end
230 if ( iconTexture ) then iconTexture:SetTexture(modIcon); end
231 if ( modString ) then modString:SetText(modName); end
232 if ( descriptString ) then descriptString:SetText(modDescript); end
233 if ( iconCount and modStatus ~= "slider" ) then iconCount:SetText(modValue); elseif ( iconCount ) then iconCount:SetText(""); end
234 if ( modString ) then modString:Show(); end
235 if ( descriptString ) then descriptString:Show(); end
236 if ( modStatus == "disabled" ) then
237 if ( iconTexture ) then iconTexture:SetVertexColor(0.5, 0.5, 0.5); end
238 end
239 if ( btn ) then
240 CT_CPButton_UpdateSelection(btn);
241 else
242 CT_CPButton_UpdateSelection();
243 end
244 end
245  
246 function CT_CPTab_OnClick(id)
247 local update;
248 if ( not id ) then
249 id = this:GetID();
250 end
251 CT_CPSetTab(id);
252 if ( id == 1 ) then
253 -- Show Welcome Text
254 CT_CPWelcomeText:Show();
255 else
256 -- Hide Welcome Text
257 CT_CPWelcomeText:Hide();
258 end
259  
260 CT_CPFrame_Update();
261 end
262  
263 function CT_CPButton_UpdateSelection(btn)
264 local button;
265 if ( btn ) then
266 button = btn;
267 else
268 button = this;
269 end
270 local i = button.id;
271 local status = CT_Mods[i];
272 if ( not status ) then
273 return;
274 else
275 status = status["modStatus"];
276 if ( not status ) then
277 return;
278 end
279 end
280 if ( status == "on" ) then
281 button:SetChecked("true");
282 else
283 button:SetChecked("false");
284 end
285 end
286  
287 function CT_CPFrame_UpdateButtons()
288 local numMods = CT_CPFrame_GetNumMods();
289 if ( numMods > CT_CPFrame.currPage*14 ) then
290 CT_CPNextPage:Enable();
291 else
292 CT_CPNextPage:Disable();
293 end
294 if ( CT_CPFrame.currPage > 1 ) then
295 CT_CPPrevPage:Enable();
296 else
297 CT_CPPrevPage:Disable();
298 end
299 for i = 1, 14, 1 do
300 CT_CPButton_UpdateButton(getglobal("CT_CPButton" .. i));
301 end
302 end
303  
304 function CT_CPFrame_HideButton(btn)
305 local name = btn:GetName();
306 btn:Hide();
307 end
308  
309 function CT_CPFrame_GetNumMods()
310 local counter = 0;
311 for key, val in CT_Mods do
312 if ( key ~= "version" ) then
313 if ( val["modType"] == CT_CPFrame.currTab ) then
314 counter = counter + 1;
315 end
316 end
317 end
318 return counter;
319 end
320  
321 function CT_CPFrame_ChangePage(offset)
322 CT_CPFrame_HideSlider();
323 CT_CPFrame.currPage = CT_CPFrame.currPage + offset;
324 CT_CPPageText:SetText("Page " .. CT_CPFrame.currPage .. "/" .. ceil(CT_CPFrame_GetNumMods()/14));
325 CT_CPFrame_UpdateButtons();
326 end
327  
328 function CT_CPFrame_GetModID(num)
329 local counter = 1;
330 for key, val in CT_Mods do
331 if ( key ~= "version" ) then
332 if ( val["modType"] == CT_CPFrame.currTab and val["modOrder"] == (num+((CT_CPFrame.currPage-1)*14)) ) then
333 return key;
334 end
335 end
336 end
337 return -1;
338 end
339  
340 function CT_CPFrame_ShallDisplayTabFlash(tabId)
341 if ( tabId == 1 ) then
342 return false;
343 end
344 for key, val in CT_Mods do
345 if ( key ~= "version" ) then
346 if ( val["modType"] == tabId and not val["hasBeenDisplayed"] ) then
347 return true;
348 end
349 end
350 end
351 return false;
352 end
353  
354 function CT_CPFrame_ShowSlider(button, modId, value, onChangeFunc, minVal, maxVal, step, lowText, highText, title, tooltipText, showValueInTitle)
355 CT_CPModSliderFrame:ClearAllPoints();
356 CT_CPModSliderFrame:SetPoint("TOP", button:GetName(), "BOTTOM", 0, 10);
357 CT_CPModSliderFrame:Show();
358  
359 CT_CPModSliderFrameSlider:SetMinMaxValues( ( minVal or 0), ( maxVal or 100 ) );
360 CT_CPModSliderFrameSlider:SetValueStep(step or 1);
361 CT_CPModSliderFrameSlider.onChangeFunc = onChangeFunc;
362 CT_CPModSliderFrameSlider.id = modId;
363 CT_CPModSliderFrameSlider.title = ( title or button.id );
364 CT_CPModSliderFrameSlider:SetValue(value);
365  
366 CT_CPModSliderFrameSliderLow:SetText(( lowText or minVal ));
367 CT_CPModSliderFrameSliderHigh:SetText(( highText or maxVal ));
368 CT_CPModSliderFrameSliderText:SetText(title or button.id);
369 CT_CPModSliderFrameSlider.tooltipText = tooltipText;
370 CT_CPModSliderFrameSlider.showValueInTitle = showValueInTitle;
371  
372 if ( showValueInTitle ) then
373 getglobal(CT_CPModSliderFrameSlider:GetName() .. "Text"):SetText(CT_CPModSliderFrameSlider.title .. " - " .. format(showValueInTitle, floor(value*100)/100));
374 else
375 getglobal(CT_CPModSliderFrameSlider:GetName() .. "Text"):SetText(CT_CPModSliderFrameSlider.title);
376 end
377 end
378  
379 function CT_CPFrame_HideSlider()
380 if ( CT_CPModSliderFrame ) then
381 CT_CPModSliderFrame:Hide();
382 end
383 end
384  
385 function CT_CPFrame_IsSliderVisible()
386 return CT_CPModSliderFrame:IsVisible();
387 end
388  
389 SlashCmdList["CTCP"] = function()
390 if ( CT_CPFrame:IsVisible() ) then
391 CT_CPFrame:Hide();
392 else
393 CT_CPFrame:Show();
394 end
395 end
396  
397 SLASH_CTCP1 = "/ctcp";