vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | function CT_RABoss_OnLoad() |
2 | this.elapsed = 0; |
||
3 | this:RegisterEvent("VARIABLES_LOADED"); |
||
4 | this:RegisterEvent("PLAYER_ENTERING_WORLD"); |
||
5 | end |
||
6 | |||
7 | -- Function to open option sets frame |
||
8 | function CT_RABoss_OnClick() |
||
9 | CT_RAMenuFrameHome:Hide(); |
||
10 | ShowUIPanel(CT_RAMenuFrameBoss); |
||
11 | end |
||
12 | |||
13 | -- Hook old ShowHome() function to also hide boss mods |
||
14 | CT_RABoss_oldCT_RAMenu_ShowHome = CT_RAMenu_ShowHome; |
||
15 | function CT_RABoss_newCT_RAMenu_ShowHome() |
||
16 | CT_RABoss_oldCT_RAMenu_ShowHome(); |
||
17 | CT_RAMenuFrameBoss:Hide(); |
||
18 | end |
||
19 | CT_RAMenu_ShowHome = CT_RABoss_newCT_RAMenu_ShowHome; |
||
20 | |||
21 | -- Hook old OnShow() function to also scale boss mods |
||
22 | CT_RABoss_oldCT_RAMenu_OnShow = CT_RAMenu_OnShow; |
||
23 | function CT_RABoss_newCT_RAMenu_OnShow() |
||
24 | CT_RABoss_oldCT_RAMenu_OnShow(); |
||
25 | -- Reposition the top menu button in CTRA |
||
26 | CT_RAMenuFrameHomeButton1:SetPoint("TOPLEFT", 20, -208); |
||
27 | CT_RAMenuFrameHomeButton7:SetScale(0.9111); |
||
28 | CT_RAMenuFrameHomeButton7Description:SetText("Several features to aid you in killing raid bosses."); |
||
29 | CT_RAMenuFrameHomeButton7Text:SetText("Boss Mods"); |
||
30 | end |
||
31 | CT_RAMenu_OnShow = CT_RABoss_newCT_RAMenu_OnShow; |
||
32 | |||
33 | function CT_RAMenuBoss_SortTable(t1, t2) |
||
34 | local locs = { }; |
||
35 | for k, v in CT_RABoss_Locations do |
||
36 | locs[v[1]] = k; |
||
37 | end |
||
38 | if ( t1[2] and t2[2] ) then |
||
39 | return locs[t1[1]] < locs[t2[1]]; |
||
40 | else |
||
41 | local loc1, loc2; |
||
42 | if ( t1[2] ) then |
||
43 | loc1 = locs[t1[1]]; |
||
44 | else |
||
45 | loc1 = locs[t1[4]]; |
||
46 | end |
||
47 | if ( t2[2] ) then |
||
48 | loc2 = locs[t2[1]]; |
||
49 | else |
||
50 | loc2 = locs[t2[4]]; |
||
51 | end |
||
52 | if ( loc1 == loc2 ) then |
||
53 | if ( t1[2] or t2[2] ) then |
||
54 | return (t1[2]); |
||
55 | else |
||
56 | return t1[1] < t2[1]; |
||
57 | end |
||
58 | else |
||
59 | return loc1 < loc2; |
||
60 | end |
||
61 | end |
||
62 | end |
||
63 | |||
64 | function CT_RAMenuBoss_CalculateEntries() |
||
65 | local locIndexes = { }; |
||
66 | local tbl = { }; |
||
67 | local numPerLoc = { }; |
||
68 | |||
69 | -- Calculate number of mods per location |
||
70 | for k, v in CT_RABoss_Mods do |
||
71 | local loc = v["location"]; |
||
72 | if ( not loc ) then |
||
73 | loc = "Other"; |
||
74 | end |
||
75 | if ( not numPerLoc[loc] ) then |
||
76 | numPerLoc[loc] = 1; |
||
77 | else |
||
78 | numPerLoc[loc] = numPerLoc[loc] + 1; |
||
79 | end |
||
80 | end |
||
81 | -- Populate the locIndexes table with the locations we have |
||
82 | for k, v in CT_RABoss_Locations do |
||
83 | -- Only add if there are mods for it |
||
84 | if ( numPerLoc[v[1]] ) then |
||
85 | locIndexes[v[1]] = v[2]; |
||
86 | tinsert(tbl, { v[1], 1, v[2] }); |
||
87 | end |
||
88 | end |
||
89 | |||
90 | -- Calculate which records to add |
||
91 | for k, v in CT_RABoss_Mods do |
||
92 | if ( not v["location"] ) then |
||
93 | v["location"] = "Other"; |
||
94 | end |
||
95 | if ( locIndexes[v["location"]] and locIndexes[v["location"]] == 1 ) then |
||
96 | tinsert(tbl, { k, nil, v, v["location"] }); |
||
97 | end |
||
98 | end |
||
99 | |||
100 | -- Sort the table |
||
101 | table.sort(tbl, CT_RAMenuBoss_SortTable); |
||
102 | |||
103 | return tbl, numPerLoc; |
||
104 | end |
||
105 | |||
106 | function CT_RAMenuBoss_ToggleHeader(name) |
||
107 | for k, v in CT_RABoss_Locations do |
||
108 | if ( v[1] == name ) then |
||
109 | if ( v[2] == 1 ) then |
||
110 | CT_RABoss_Locations[k][2] = 0; |
||
111 | else |
||
112 | CT_RABoss_Locations[k][2] = 1; |
||
113 | end |
||
114 | break; |
||
115 | end |
||
116 | end |
||
117 | CT_RAMenuBoss_Update(); |
||
118 | end |
||
119 | |||
120 | function CT_RAMenuBoss_Update() |
||
121 | local tbl, numPerLoc = CT_RAMenuBoss_CalculateEntries(); |
||
122 | local numEntries = getn(tbl); |
||
123 | -- ScrollFrame update |
||
124 | FauxScrollFrame_Update(CT_RAMenuFrameBossScrollFrame, numEntries, 10, 25 ); |
||
125 | |||
126 | for i=1, 10, 1 do |
||
127 | local obj = getglobal("CT_RAMenuFrameBossMod" .. i); |
||
128 | local nameText = getglobal("CT_RAMenuFrameBossMod" .. i .. "Name"); |
||
129 | local descriptText = getglobal("CT_RAMenuFrameBossMod" .. i .. "Descript"); |
||
130 | local statusText = getglobal("CT_RAMenuFrameBossMod" .. i .. "Status"); |
||
131 | local line = getglobal("CT_RAMenuFrameBossMod" .. i .. "Line"); |
||
132 | local dropdown = getglobal("CT_RAMenuFrameBossMod" .. i .. "Menu"); |
||
133 | local plusMinus = getglobal("CT_RAMenuFrameBossMod" .. i .. "ShowHide"); |
||
134 | local prevLine = getglobal("CT_RAMenuFrameBossMod" .. i-1 .. "Line"); |
||
135 | |||
136 | local index = i + FauxScrollFrame_GetOffset(CT_RAMenuFrameBossScrollFrame); |
||
137 | if ( index <= numEntries ) then |
||
138 | obj:Show(); |
||
139 | line:Hide(); |
||
140 | if ( not tbl[index][2] ) then |
||
141 | -- Not a header |
||
142 | obj.header = nil; |
||
143 | nameText:SetText(tbl[index][1]); |
||
144 | nameText:SetTextColor(0.5, 0.5, 0.5); |
||
145 | nameText:ClearAllPoints(); |
||
146 | nameText:SetPoint("TOPLEFT", obj:GetName(), "TOPLEFT", 45, 0); |
||
147 | plusMinus:Hide(); |
||
148 | if ( tbl[index][3]["status"] ) then |
||
149 | statusText:SetText("On"); |
||
150 | statusText:SetTextColor(0, 1, 0); |
||
151 | else |
||
152 | statusText:SetText("Off"); |
||
153 | statusText:SetTextColor(1, 0, 0); |
||
154 | end |
||
155 | if ( tbl[index][3]["descript"] ) then |
||
156 | descriptText:SetText(tbl[index][3]["descript"]); |
||
157 | else |
||
158 | descriptText:SetText(""); |
||
159 | end |
||
160 | obj.index = tbl[index][1]; |
||
161 | if ( not obj.hasBeenInitialized ) then |
||
162 | UIDropDownMenu_Initialize(dropdown, CT_RAMenuBoss_InitDropDown, "MENU"); |
||
163 | obj.hasBeenInitialized = 1; |
||
164 | end |
||
165 | else |
||
166 | if ( prevLine ) then |
||
167 | prevLine:Show(); |
||
168 | end |
||
169 | -- Header |
||
170 | obj.header = 1; |
||
171 | obj.headername = tbl[index][1]; |
||
172 | local num = numPerLoc[tbl[index][1]]; |
||
173 | if ( not num ) then |
||
174 | num = 0; |
||
175 | end |
||
176 | plusMinus:Show(); |
||
177 | if ( tbl[index][3] == 1 ) then |
||
178 | if ( obj.mouseIsOver ) then |
||
179 | GameTooltip:SetText("Click to contract"); |
||
180 | end |
||
181 | plusMinus:SetText("-"); |
||
182 | obj.expanded = 1; |
||
183 | else |
||
184 | if ( obj.mouseIsOver ) then |
||
185 | GameTooltip:SetText("Click to expand"); |
||
186 | end |
||
187 | plusMinus:SetText("+"); |
||
188 | obj.expanded = nil; |
||
189 | end |
||
190 | nameText:SetText(tbl[index][1] .. " (" .. num .. ")"); |
||
191 | nameText:SetTextColor(1, 1, 1); |
||
192 | nameText:ClearAllPoints(); |
||
193 | nameText:SetPoint("LEFT", obj:GetName(), "LEFT", 12, 0); |
||
194 | statusText:SetText(""); |
||
195 | descriptText:SetText(""); |
||
196 | end |
||
197 | else |
||
198 | obj:Hide(); |
||
199 | end |
||
200 | end |
||
201 | end |
||
202 | |||
203 | function CT_RAMenuBoss_InitDropDown() |
||
204 | local modName = getglobal(UIDROPDOWNMENU_INIT_MENU):GetParent().index; |
||
205 | local info = {}; |
||
206 | |||
207 | info.text = modName; |
||
208 | info.isTitle = 1; |
||
209 | info.justifyH = "CENTER"; |
||
210 | info.notCheckable = 1; |
||
211 | UIDropDownMenu_AddButton(info); |
||
212 | |||
213 | info = { }; |
||
214 | info.text = "Enable mod"; |
||
215 | info.tooltipTitle = "Enable mod"; |
||
216 | info.tooltipText = "Enables the mod, turning on all enabled options."; |
||
217 | info.checked = CT_RABoss_Mods[modName]["status"]; |
||
218 | info.func = CT_RABoss_EnableMod; |
||
219 | info.keepShownOnClick = 1; |
||
220 | info.value = modName; |
||
221 | UIDropDownMenu_AddButton(info); |
||
222 | |||
223 | if ( CT_RABoss_DropDown[modName] ) then |
||
224 | for k, v in CT_RABoss_DropDown[modName] do |
||
225 | info = { }; |
||
226 | info.value = { modName, v[3] }; |
||
227 | info.keepShownOnClick = 1; |
||
228 | if ( type(v[1]) == "string" ) then |
||
229 | info.text = v[1]; |
||
230 | elseif ( type(v[1]) == "table" ) then |
||
231 | info.text = v[1][1]; |
||
232 | info.tooltipTitle = v[1][1]; |
||
233 | info.tooltipText = v[1][2]; |
||
234 | end |
||
235 | if ( type(getglobal(v[2])) == "function" ) then |
||
236 | info.checked = getglobal(v[2])(modName, v[3]); |
||
237 | else |
||
238 | info.checked = getglobal(v[2]); |
||
239 | end |
||
240 | info.func = getglobal(v[4]); |
||
241 | UIDropDownMenu_AddButton(info); |
||
242 | end |
||
243 | end |
||
244 | end |
||
245 | |||
246 | function CT_RABoss_LoadMods() |
||
247 | for k, v in CT_RABoss_ModsToLoad do |
||
248 | if ( getglobal(v) ) then |
||
249 | getglobal(v)(); |
||
250 | end |
||
251 | end |
||
252 | end |
||
253 | |||
254 | -- Slash command to enable/disable debug |
||
255 | CT_RA_RegisterSlashCmd("/rabossdebug", "Toggles boss mod debugging.", 15, "RABOSSDEBUG", function(msg) |
||
256 | local level; |
||
257 | if ( strlen(msg) > 0 and tonumber(msg) >= 1 and tonumber(msg) <= 5 ) then |
||
258 | level = tonumber(msg); |
||
259 | end |
||
260 | if ( not level ) then |
||
261 | if ( CT_RABoss_DebugLevels["enableDebug"] ) then |
||
262 | CT_RA_Print("<CTRaid> Boss mod debugging is now |c00FF0000disabled|r.", 1, 0.5, 0); |
||
263 | CT_RABoss_DebugLevels["enableDebug"] = false; |
||
264 | else |
||
265 | CT_RA_Print("<CTRaid> Boss mod debugging is now |c0000FF00enabled.", 1, 0.5, 0); |
||
266 | CT_RABoss_DebugLevels["enableDebug"] = true; |
||
267 | end |
||
268 | else |
||
269 | if ( CT_RABoss_DebugLevels[level] ) then |
||
270 | CT_RA_Print("<CTRaid> Boss mod debugging for |c00FFFFFFlevel " .. level .. "|r is now |c00FF0000disabled|r.", 1, 0.5, 0); |
||
271 | CT_RABoss_DebugLevels[level] = false; |
||
272 | else |
||
273 | CT_RA_Print("<CTRaid> Boss mod debugging for |c00FFFFFFlevel " .. level .. "|r is now |c0000FF00enabled.", 1, 0.5, 0); |
||
274 | CT_RABoss_DebugLevels[level] = true; |
||
275 | end |
||
276 | end |
||
277 | end, "/rabossdebug", "/rabd"); |