vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_PlayerSpells = { };
2 CT_ModVersion = 1.854;
3 CT_Mods = { };
4 CT_Options = { };
5 CT_MovableFrames = { };
6 CT_KeyBindings = { };
7 CT_MF_ShowFrames = nil;
8 CT_MASTERMOD_CPTITLE = CT_MASTERMOD_CPTITLE .. " v" .. CT_ModVersion;
9  
10 function CT_GetPlayerSpells()
11 CT_PlayerSpells = { };
12 for i = 1, GetNumSpellTabs(), 1 do
13 local name, texture, offset, numSpells = GetSpellTabInfo(i);
14 for y = 1, numSpells, 1 do
15 local spellName, rankName = GetSpellName(offset+y, BOOKTYPE_SPELL);
16 local useless, useless, rank = string.find(rankName, "(%d+)");
17 if ( tonumber(rank) ) then
18 if ( not CT_PlayerSpells[spellName] or CT_PlayerSpells[spellName]["rank"] < tonumber(rank) ) then
19 CT_PlayerSpells[spellName] = { ["rank"] = tonumber(rank), ["tab"] = i, ["spell"] = y+offset };
20 end
21 end
22 end
23 end
24 end
25  
26 function CT_AddMovable(frame, name, point, relpoint, relframe, xOffset, yOffset, lockfunc, resetfunc)
27 if ( not frame or not name or not point or not relpoint or not relframe or not xOffset or not yOffset ) then
28 return nil;
29 end
30  
31 tinsert(CT_MovableFrames, {
32 ["frame"] = frame,
33 ["name"] = name,
34 ["point"] = point,
35 ["relpoint"] = relpoint,
36 ["relframe"] = relframe,
37 ["x"] = xOffset,
38 ["y"] = yOffset,
39 ["lockfunc"] = lockfunc,
40 ["resetfunc"] = resetfunc
41 });
42 return 1;
43 end
44  
45 function CT_ResetMovables()
46 for key, val in CT_MovableFrames do
47 getglobal(val["frame"]):ClearAllPoints();
48 getglobal(val["frame"]):SetPoint(val["point"], val["relframe"], val["relpoint"], val["x"], val["y"]);
49 if ( val["resetfunc"] ) then
50 val["resetfunc"]();
51 end
52 end
53 end
54  
55 function CT_ResetFrameByName(name)
56 for key, val in CT_MovableFrames do
57 if ( val["frame"] == name ) then
58 getglobal(val["frame"]):ClearAllPoints();
59 getglobal(val["frame"]):SetPoint(val["point"], val["relframe"], val["relpoint"], val["x"], val["y"]);
60 if ( val["resetfunc"] ) then
61 val["resetfunc"]();
62 end
63 end
64 end
65 end
66  
67 function CT_LockMovables(status)
68 CT_MF_ShowFrames = status;
69 for key, val in CT_MovableFrames do
70 if ( val["lockfunc"] ) then
71 val["lockfunc"](status);
72 end
73 end
74 end
75  
76 function CT_Replace(text, search, replace)
77 if ( search == replace) then return text; end
78 local searchedtext = "";
79 local textleft = text;
80 while ( strfind ( textleft, search, 1) ) do
81 searchedtext = searchedtext .. strsub ( textleft, 1, strfind( textleft, search, 1)-1 ) .. replace;
82 textleft = strsub ( textleft, strfind( textleft, search, 1)+strlen(search) );
83 end
84 if ( strlen(textleft) > 0 ) then
85 searchedtext = searchedtext .. textleft;
86 end
87 return searchedtext;
88 end
89  
90 function CT_Print(msg, r, g, b, frame)
91 if ( not r ) then r=1.0; end;
92 if ( not g ) then g=1.0; end;
93 if ( not b ) then b=1.0; end;
94 if ( frame ) then
95 frame:AddMessage(msg,r,g,b);
96 else
97 DEFAULT_CHAT_FRAME:AddMessage(msg, r, g, b);
98 end
99 end
100  
101 function CT_RegisterMod(modName, modDescript, modType, modIcon, modTooltip, modStatus, modValue, modFunc, modInitFunction, modOrder, modOnDisplay)
102 local temp = { };
103 if ( modName and strlen(modName) > 0 ) then temp["modName"] = modName; else temp["modName"] = ""; end
104 if ( modDescript and strlen(modDescript) > 0 ) then temp["modDescript"] = modDescript; else temp["modDescript"] = ""; end
105 if ( modTooltip and strlen(modTooltip) > 0 ) then temp["modTooltip"] = modTooltip; else temp["modTooltip"] = ""; end
106 if ( modIcon and strlen(modIcon) > 0 ) then temp["modIcon"] = modIcon; else temp["modIcon"] = "Interface\\Icons\\INV_Misc_QuestionMark"; end
107 if ( modStatus ) then temp["modStatus"] = modStatus; else temp["modStatus"] = "off"; end
108 if ( modValue ) then temp["modValue"] = modValue; end
109 if ( modFunc ) then temp["modFunc"] = modFunc; end
110 if ( modInitFunction ) then temp["modInitFunc"] = modInitFunction; end
111 if ( modType ) then temp["modType"] = modType; else temp["modType"] = 1; end
112 if ( modOnDisplay ) then temp["modOnDisplay"] = modOnDisplay; end
113 if ( modOrder ) then
114 temp["modOrder"] = modOrder;
115 else
116 local usedNum = { };
117 local numInCategory = 0;
118 for key, val in CT_Mods do
119 if ( val["modType"] == temp["modType"] ) then
120 usedNum[val["modOrder"]] = 1;
121 end
122 end
123 local i = 1;
124 while ( usedNum[i] ) do
125 i = i + 1;
126 end
127 temp["modOrder"] = i;
128 end
129 CT_Mods[modName] = temp;
130 end
131  
132 function CT_GetModStatus(modName)
133 if ( CT_Mods[modName] ) then
134 return CT_Mods[modName]["modStatus"];
135 end
136 end
137  
138 function CT_SetModStatus(modName, status)
139 CT_Mods[modName]["modStatus"] = status;
140 CT_SaveInfoName(modName);
141 end
142  
143 function CT_GetModValue(modName)
144 if ( CT_Mods[modName] ) then
145 return CT_Mods[modName]["modValue"];
146 end
147 end
148  
149 function CT_SetModValue(modName, value)
150 CT_Mods[modName]["modValue"] = value;
151 CT_SaveInfoName(modName);
152 end
153  
154 function CT_SaveInfoName(modName)
155 if ( not CT_Options[UnitName("player")] ) then
156 CT_Options[UnitName("player")] = { };
157 end
158 CT_Options[UnitName("player")][modName] = { };
159 for key, val in CT_Mods[modName] do
160 if ( key == "modStatus" or key == "modValue" or key == "hasBeenDisplayed" ) then
161 CT_Options[UnitName("player")][modName][key] = val;
162 end
163 end
164 end
165  
166 function CT_Master_OnEvent(event)
167 if ( event == "VARIABLES_LOADED" ) then
168 if ( not CT_Options["version"] ) then
169 CT_Options = { };
170 CT_Options["version"] = CT_ModVersion;
171 CT_Print("<CTMod> " .. CT_MASTERMOD_FIRSTLOAD, 0.3, 1.0, 0.3);
172 else
173 CT_Options["version"] = CT_ModVersion;
174 if ( CT_Options[UnitName("player")] ) then
175 for key, val in CT_Options[UnitName("player")] do
176 if ( key ~= "version" ) then
177 if ( CT_Mods[key] ) then
178 for k, v in val do
179 CT_Mods[key][k] = v;
180 end
181 end
182 end
183 end
184 for key, val in CT_Mods do
185 if ( val["modInitFunc"] ) then
186 val["modInitFunc"](key);
187 end
188 end
189 end
190 end
191 --CT_SetKeyBindings(UnitName("player").."@"..GetCVar("realmName"));
192 CT_LockMovables(CT_MF_ShowFrames);
193 end
194  
195 if ( event == "SPELLS_CHANGED" ) then
196 CT_GetPlayerSpells();
197 end
198 end
199  
200 function CT_Master_UnregisterMod(name)
201 CT_Mods[name] = nil;
202 end
203  
204 function CT_LinkFrameDrag(frame, drag, point, relative, x, y)
205 frame:ClearAllPoints();
206 frame:SetPoint(point, drag:GetName(), relative, x, y);
207 end
208  
209 CT_oldToggleFramerate = ToggleFramerate;
210 function CT_newToggleFramerate()
211 if ( CTFramerate:IsVisible() ) then
212 CTFramerate:Hide();
213 else
214 CTFramerate:Show()
215  
216 end
217 CT_Master_GlobalFrame.fpsTime = 0;
218 end
219 ToggleFramerate = CT_newToggleFramerate;
220  
221 function CT_Master_GlobalFrame_OnUpdate(elapsed)
222 if ( CTFramerate:IsVisible() ) then
223 local timeLeft = this.fpsTime - elapsed
224 if ( timeLeft <= 0 ) then
225 this:SetScale(UIParent:GetScale());
226 this.fpsTime = FRAMERATE_FREQUENCY;
227 CTFramerateText:SetText(format("%.1f", GetFramerate()));
228 else
229 this.fpsTime = timeLeft;
230 end
231 end
232 end
233  
234 SLASH_PRI1 = "/pri";
235 SlashCmdList["PRI"] = function(msg)
236 RunScript("CT_Print(" .. msg .. ")");
237 end
238  
239 SLASH_CTUNLOCK1 = "/ctunlock";
240 SlashCmdList["CTUNLOCK"] = function(msg)
241 CT_Print("<CTMod> " .. CT_MASTERMOD_UNLOCKED, 1, 1, 0);
242 CT_LockMovables(1);
243 CT_SetModStatus(CT_MASTERMOD_MODNAME_UNLOCK, "on");
244 end
245  
246 SLASH_CTUNLOCK1 = "/ctlock";
247 SlashCmdList["CTLOCK"] = function(msg)
248 CT_Print("<CTMod> " .. CT_MASTERMOD_LOCKED, 1, 1, 0);
249 CT_LockMovables(nil);
250 CT_SetModStatus(CT_MASTERMOD_MODNAME_UNLOCK, "off");
251 end
252  
253 function CT_SetKeyBindings(name, force )
254 if ( CT_KeyBindings[name] and not force ) then
255 for k, v in CT_KeyBindings[name] do
256 SetBinding(v[1], v[2]);
257 end
258 else
259 CT_KeyBindings[name] = { };
260 for i = 1, GetNumBindings(), 1 do
261 CT_SaveKeyBinding(name, GetBinding(i));
262 end
263 end
264 end
265  
266 function CT_SaveKeyBinding(name, command, ...)
267 for i = 1, arg.n, 1 do
268 tinsert(CT_KeyBindings[name], { arg[i], command });
269 end
270 end
271  
272 CT_oldResetBindings = ResetBindings;
273 function CT_newResetBindings()
274 CT_oldResetBindings();
275 CT_SetKeyBindings(UnitName("player").."@"..GetCVar("realmName"), 1);
276 end
277 --ResetBindings = CT_newResetBindings;
278  
279 CT_oldSaveBindings = SaveBindings;
280 function CT_newSaveBindings()
281 CT_oldSaveBindings();
282 CT_SetKeyBindings(UnitName("player").."@"..GetCVar("realmName"), 1);
283 end
284 --SaveBindings = CT_newSaveBindings;
285  
286 CT_oldSetItemRef = SetItemRef;
287 function CT_newSetItemRef(link, text, button)
288 if ( strsub(link, 1, 6) == "player" ) then
289 local name = strsub(link, 8);
290 if ( name and (strlen(name) > 0) ) then
291 name = gsub(name, "([^%s]*)%s+([^%s]*)", "%2");
292 if ( IsControlKeyDown() ) then
293 for i = 1, GetNumRaidMembers(), 1 do
294 if ( UnitName("raid" .. i) == name ) then
295 TargetUnit("raid" .. i);
296 return;
297 end
298 end
299 for i = 1, GetNumPartyMembers(), 1 do
300 if ( UnitName("party" .. i) == name ) then
301 TargetUnit("party" .. i);
302 return;
303 end
304 end
305 TargetByName(name);
306 return;
307 end
308 end
309 end
310 CT_oldSetItemRef(link, text, button);
311 end
312 SetItemRef = CT_newSetItemRef;
313  
314 BINDING_HEADER_CT_TARGETLAST = "Target Last Target";
315 BINDING_NAME_CT_TARGETLASTTARGET = "Target Last Target";
316 BINDING_NAME_CT_TARGETLASTTARGET = "Target Last Target";