vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CEBRogueClass = "Rogue";
2 CEBDruidClass = "Druid";
3 CEBMsg1 = "ComboEnergyBar available commands:";
4 CEBMsg2 = "/ceb show -> to show the panel";
5 CEBMsg3 = "/ceb hide -> to hide the panel";
6 CEBMsg4 = "/ceb combat -> to show the panel only when you are in combat and hide it otherwise";
7 if (GetLocale() == "frFR") then
8 -- Thanks to Morgeagnac e Arkantor for the French translation
9 CEBRogueClass = "Voleur";
10 CEBDruidClass = "Druide";
11 CEBMsg1 = "Commandements disponibles pour la ComboEnergyBar:";
12 CEBMsg2 = "/ceb show -> pour montrer la barre combo";
13 CEBMsg3 = "/ceb hide -> pour cacher la barre combo";
14 CEBMsg4 = "pour cacher la barre combo, mais pour qu'elle apparaisse automatiquement quand vous entrez en combat et se cache quand vous quittez le combat";
15 elseif (GetLocale() == "deDE") then
16 -- Thanks to Cherub and Dwain for the German translation
17 CEBRogueClass = "Schurke";
18 CEBDruidClass = "Druide";
19 CEBMsg1 = "Befehle fuer ComboEnergyBar:";
20 CEBMsg2 = "/ceb show -> ComboBar anzeigen";
21 CEBMsg3 = "/ceb hide -> ComboBar verstecken";
22 CEBMsg4 = "/ceb combat -> ComboBar verstecken wird im kampf automatisch angezeigt und nach dem kampf wieder versteckt";
23 end
24 local incombat = false;
25 local incatform = false;
26 local combobarenabled = true;
27 local baseBorderY = -1;
28 local baseBarY = -3;
29 local ComboEnergyBar_Version = 1.0;
30 local ComboEnergyBar_DefaultConfig = {
31 show = false,
32 combat = true,
33 version = ComboEnergyBar_Version
34 };
35  
36 function ComboEnergyBar_CheckCatForm()
37 local cl = UnitClass("player");
38 if (cl == CEBRogueClass) then
39 return true;
40 elseif (cl == CEBDruidClass) then
41 local res = false;
42 local i = 0;
43 while GetPlayerBuffTexture(i) do
44 local BuffTexture = GetPlayerBuffTexture(i);
45 if (string.find(BuffTexture, "Ability_Druid_CatForm", 1, true)) then
46 res = true;
47 end
48 i = i + 1;
49 end
50 return res;
51 else
52 return false;
53 end
54 end
55  
56 function ComboEnergyBar_MoveTargetBar(state)
57 if (ComboEnergyBarFrame:IsVisible()) then
58 local targetBorderY = baseBorderY;
59 local targetBarY = baseBarY;
60 local comboBorderY = baseBorderY;
61 local comboBarY = baseBarY;
62  
63 if (state == "below") then
64 targetBorderY = targetBorderY -5;
65 targetBarY = targetBarY -5;
66 else
67 comboBorderY = comboBorderY -5;
68 comboBarY = comboBarY -5;
69 end
70  
71 local i = 0;
72 local width = 3;
73 for i = 1, 5 do
74 local obj = getglobal("ComboEnergyBarBorder" .. i);
75 obj:SetPoint("TOPLEFT", "ComboEnergyBarFrame", "TOPLEFT", width, comboBorderY);
76  
77 obj = getglobal("ComboEnergyBarBorder" .. i .. "Texture");
78 obj:SetPoint("TOPLEFT", "ComboEnergyBarBorder" .. i, "TOPLEFT", width, comboBorderY);
79  
80 obj = getglobal("CEB" .. i);
81 obj:SetPoint("TOPLEFT", "ComboEnergyBarBorder" .. i, "TOPLEFT", width + 2, comboBarY);
82  
83 width = width + 10;
84 end
85 end
86 end
87  
88 function ComboEnergyBar_OnLoad()
89 for i = 1, 5, 1 do
90 local barname = getglobal("ComboEnergyBarCombo"..i);
91 barname:SetStatusBarColor(1, 0, 0);
92 barname:SetMinMaxValues(0, 1);
93 barname:SetValue(0);
94 end
95 this:RegisterEvent("PLAYER_COMBO_POINTS");
96 this:RegisterEvent("UNIT_HEALTH");
97 this:RegisterEvent("UNIT_MAXHEALTH");
98 this:RegisterEvent("UNIT_MAXENERGY");
99 this:RegisterEvent("UNIT_AURA");
100 this:RegisterEvent("VARIABLES_LOADED");
101 this:RegisterEvent("PLAYER_ENTER_COMBAT");
102 this:RegisterEvent("PLAYER_LEAVE_COMBAT");
103 this:RegisterEvent("PLAYER_TARGET_CHANGED");
104 this:RegisterEvent("PLAYER_ENTERING_WORLD");
105 SlashCmdList["ComboEnergyBarCOMMAND"] = ComboEnergyBar_SlashHandler;
106 SLASH_ComboEnergyBarCOMMAND1 = "/ceb";
107 end
108  
109 function ComboEnergyBar_Toggle()
110 local mainframe = getglobal("ComboEnergyBarFrame");
111 if (not combobarenabled) then
112 if (mainframe:IsVisible()) then
113 mainframe:Hide();
114 end
115 return;
116 end
117 if (ComboEnergyBar_Config.show) then
118 if (not mainframe:IsVisible()) then
119 mainframe:Show();
120 end
121 return;
122 else
123 if (not ComboEnergyBar_Config.combat) then
124 if (mainframe:IsVisible()) then
125 mainframe:Hide();
126 end
127 return;
128 else
129 if (incombat and incatform) then
130 if (not mainframe:IsVisible()) then
131 mainframe:Show();
132 return;
133 end
134 else
135 if mainframe:IsVisible() then
136 mainframe:Hide();
137 return;
138 end
139 end
140 end
141 end
142 end
143  
144 function CEB_Toggle(arg)
145 if( arg == 1 ) then
146 ComboEnergyBar_Config.show = true;
147 elseif( arg == 0) then
148 ComboEnergyBar_Config.show = false;
149 else
150 DEFAULT_CHAT_FRAME:AddMessage("CEB_Toggle(arg) returned invalid arg.");
151 end
152 ComboEnergyBar_Toggle();
153 end
154  
155 function CEB_Combat()
156 ComboEnergyBar_Config.show = false;
157 ComboEnergyBar_Config.combat = true;
158 ComboEnergyBar_Toggle();
159 end
160  
161 function ComboEnergyBar_SlashHandler(msg)
162 local cmd = string.lower(msg);
163 if (cmd == "show") then
164 ComboEnergyBar_Config.show = true;
165 ComboEnergyBar_Config.combat = false;
166 ComboEnergyBar_Toggle();
167 return;
168 elseif (cmd == "hide") then
169 ComboEnergyBar_Config.show = false;
170 ComboEnergyBar_Config.combat = false;
171 ComboEnergyBar_Toggle();
172 return;
173 elseif (cmd == "combat") then
174 ComboEnergyBar_Config.show = false;
175 ComboEnergyBar_Config.combat = true;
176 ComboEnergyBar_Toggle();
177 return;
178 end
179 if (DEFAULT_CHAT_FRAME) then
180 DEFAULT_CHAT_FRAME:AddMessage(CEBMsg1);
181 DEFAULT_CHAT_FRAME:AddMessage(CEBMsg2);
182 DEFAULT_CHAT_FRAME:AddMessage(CEBMsg3);
183 DEFAULT_CHAT_FRAME:AddMessage(CEBMsg4);
184 end
185 end
186  
187 function ComboEnergyBarUpdateComboBar()
188 local combo = GetComboPoints();
189 local combobar = {0, 0, 0, 0, 0};
190 local barcolor = {[0] = {1, 0, 0}, {1, 0, 0}, {1, 0, 0}, {1, 1, 0}, {1, 1, 0}, {0, 1, 0}};
191 for i = 1, combo, 1 do
192 combobar[i] = 1;
193 end
194 for i = 1, 5, 1 do
195 local barname = getglobal("ComboEnergyBarCombo"..i);
196 barname:SetStatusBarColor(barcolor[combo][1], barcolor[combo][2], barcolor[combo][3]);
197 barname:SetValue(combobar[i]);
198 end
199 end
200  
201 function ComboEnergyBar_OnEvent(event)
202 if (event == "PLAYER_COMBO_POINTS") then
203 ComboEnergyBarUpdateComboBar();
204 elseif (event == "PLAYER_ENTER_COMBAT") then
205 incombat = true;
206 ComboEnergyBar_Toggle();
207 elseif (event == "PLAYER_LEAVE_COMBAT") then
208 incombat = false;
209 ComboEnergyBar_Toggle();
210 elseif ((event == "UNIT_AURA") and (arg1 == "player")) then
211 incatform = ComboEnergyBar_CheckCatForm();
212 ComboEnergyBar_Toggle();
213 elseif (event == "PLAYER_TARGET_CHANGED") then
214  
215 elseif (event == "VARIABLES_LOADED") then
216 if ((not ComboEnergyBar_Config) or (not ComboEnergyBar_Config.version) or (ComboEnergyBar_Config.version ~= ComboEnergyBar_Version)) then
217 ComboEnergyBar_Config = ComboEnergyBar_DefaultConfig;
218 end
219 if (UltimateUI_RegisterConfiguration) then
220 CEB_RegisterUltimateUI();
221 end
222 ComboEnergyBar_Toggle();
223 elseif (event == "PLAYER_ENTERING_WORLD") then
224 local cl = UnitClass("player");
225 if ((cl ~= CEBRogueClass) and (cl ~= CEBDruidClass)) then
226 this:UnregisterEvent("PLAYER_COMBO_POINTS");
227 this:UnregisterEvent("UNIT_HEALTH");
228 this:UnregisterEvent("UNIT_MAXHEALTH");
229 this:UnregisterEvent("UNIT_ENERGY");
230 this:UnregisterEvent("UNIT_MAXENERGY");
231 this:UnregisterEvent("UNIT_AURA");
232 this:UnregisterEvent("VARIABLES_LOADED");
233 this:UnregisterEvent("PLAYER_ENTER_COMBAT");
234 this:UnregisterEvent("PLAYER_LEAVE_COMBAT");
235 this:UnregisterEvent("PLAYER_TARGET_CHANGED");
236 this:UnregisterEvent("PLAYER_ENTERING_WORLD");
237 combobarenabled = false;
238 ComboEnergyBar_Toggle();
239 else
240 incatform = ComboEnergyBar_CheckCatForm();
241 ComboEnergyBarUpdateComboBar();
242 end
243 end
244 end
245  
246 function CEB_RegisterUltimateUI()
247 UltimateUI_RegisterConfiguration(
248 "UUI_CEB",
249 "SECTION",
250 "Combo Energy Bar",
251 "Options to configure Combo Energy Bar."
252 );
253 UltimateUI_RegisterConfiguration(
254 "UUI_CEB_SEPARATOR",
255 "SEPARATOR",
256 "ComboEnergyBar",
257 "Options to configure Combo Energy Bar."
258 );
259 UltimateUI_RegisterConfiguration(
260 "UUI_CEB_ENABLE",
261 "CHECKBOX",
262 "Enable / Disable",
263 "Check or uncheck this box to enable or disable ComboEnergyBar.",
264 CEB_Toggle,
265 1
266 );
267 UltimateUI_RegisterConfiguration(
268 "UUI_CEB_COMBAT",
269 "CHECKBOX",
270 "Show only in combat",
271 "Check or uncheck this box to show CEB while in combat.",
272 CEB_Combat,
273  
274 );
275 end
276  
277 function ComboEnergyBarboolean()
278 if combobarenabled then
279 DEFAULT_CHAT_FRAME:AddMessage("combobar enabled");
280 else
281 DEFAULT_CHAT_FRAME:AddMessage("combobar not enabled");
282 end
283 if incombat then
284 DEFAULT_CHAT_FRAME:AddMessage("in combat");
285 else
286 DEFAULT_CHAT_FRAME:AddMessage("not in combat");
287 end
288 if incatform then
289 DEFAULT_CHAT_FRAME:AddMessage("in cat form");
290 else
291 DEFAULT_CHAT_FRAME:AddMessage("not in cat form");
292 end
293 local cl = UnitClass("player");
294 if cl == CEBRogueClass then
295 DEFAULT_CHAT_FRAME:AddMessage(CEBRogueClass);
296 elseif cl == CEBDruidClass then
297 DEFAULT_CHAT_FRAME:AddMessage(CEBDruidClass);
298 else
299 DEFAULT_CHAT_FRAME:AddMessage("classe non supportata");
300 end
301 DEFAULT_CHAT_FRAME:AddMessage(cl);
302 end