Thread Tools Display Modes
10-29-11, 11:34 PM   #1
ikomiko
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 9
Adding Classcolor to default ArenaFrames

Hi, i have a question.

I can't test atm. this little code in arena, thats why i want to know if it's right.

lua Code:
  1. local function whoa_arenaColors()
  2.     if not InCombatLockdown() then
  3.         local numOpponents = GetNumArenaOpponents()
  4.         if numOpponents > 0 then
  5.             for i = 1, numOpponents do
  6.                 color = RAID_CLASS_COLORS[select(2, UnitClass("arena"..i))]
  7.                 if color then
  8.                     _G["ArenaEnemyFrame"..i.."HealthBar"]:SetStatusBarColor(color.r, color.g, color.b)
  9.                     _G["ArenaEnemyFrame"..i.."HealthBar"].lockColor = true
  10.                 end
  11.             end    
  12.         end
  13.     end
  14. end
  15.  
  16. local w = CreateFrame("Frame", nil, UIParent)
  17. w:RegisterEvent("PLAYER_ENTERING_WORLD")
  18.  
  19.  
  20.  
  21. function w:OnEvent(event, ...)
  22.     if event == "PLAYER_ENTERING_WORLD" then
  23.        
  24.         whoa_arenaColors()
  25.  
  26. end
  27. w:SetScript("OnEvent", w.OnEvent)
  Reply With Quote
10-30-11, 02:16 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
From what I see in the ArenaUI code, you'll need to stop ArenaEnemyFrame_Unlock() from clearing the color lock. You also need to actually check if ArenaUI is loaded since it is LoD. Here's code I would suggest running.

lua Code:
  1. local function HookArenaUI()
  2.     hooksecurefunc("ArenaEnemyFrame_Unlock",function(self)
  3.         local color=RAID_CLASS_COLORS[select(2,UnitClass(self.unit)) or ""];
  4.         if color then
  5.             self.healthbar:SetStatusBarColor(color.r,color.g,color.b);
  6.             self.healthbar.lockColor=true;
  7.         end
  8.     end);
  9. end
  10.  
  11. if IsAddOnLoaded("Blizzard_ArenaUI") then
  12.     HookArenaUI();
  13. else
  14.     local hookframe=CreateFrame("Frame");
  15.     hookframe:RegisterEvent("ADDON_LOADED");
  16.     hookframe:SetScript("OnEvent",function(self,event,arg)
  17.         if arg=="Blizzard_ArenaUI" then
  18.             self:UnregisterEvent(event);
  19.             self:SetScript("OnEvent",nil);
  20.             HookArenaUI();
  21.         end
  22.     );
  23. end



Optionally, if this is all the code you'll have in an addon, you should add these to your ToC and use the following snip of code from the one above.

Code:
## LoadOnDemand: 1
## LoadWith: Blizzard_ArenaUI
lua Code:
  1. hooksecurefunc("ArenaEnemyFrame_Unlock",function(self)
  2.     local color=RAID_CLASS_COLORS[select(2,UnitClass(self.unit)) or ""];
  3.     if color then
  4.         self.healthbar:SetStatusBarColor(color.r,color.g,color.b);
  5.         self.healthbar.lockColor=true;
  6.     end
  7. end);
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
10-30-11, 06:18 PM   #3
ikomiko
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Oct 2011
Posts: 9
hi, i thank you so much for response, thats great.

iam working atm. on a Arena Testmode to see if the functions are working.
atm i can make arena frames visible, i tried to make manabar and classcolor visible, too. but it doesn't work.

here's the code.

lua Code:
  1. SLASH_BAF1 = "/baf"
  2. SlashCmdList["BAF"] = function(msg, editBox)
  3.     if not IsAddOnLoaded("Blizzard_ArenaUI") then
  4.         LoadAddOn("Blizzard_ArenaUI")
  5.     end
  6.     for i=1, MAX_ARENA_ENEMIES do
  7.    
  8.     _G["ArenaEnemyFrame"..i.."CastingBar"]:Show()
  9.     _G["ArenaEnemyFrame"..i.."ManaBar"]:Show()
  10.     end
  11.  
  12.     ArenaEnemyFrame1ManaBar:Show()
  13.     ArenaEnemyFrames:Show()
  14.     local arenaFrame
  15.     for i = 1, MAX_ARENA_ENEMIES do
  16.         arenaFrame = _G["ArenaEnemyFrame"..i]
  17.         arenaFrame.classPortrait:SetTexture("Interface\\TargetingFrame\\UI-Classes-Circles")
  18.         arenaFrame.classPortrait:SetTexCoord(unpack(CLASS_ICON_TCOORDS["WARLOCK"]))
  19.         arenaFrame.name:SetText("Dispelme")
  20.         arenaFrame:Show()
  21.        
  22.         CooldownFrame_SetTimer(trinkets["arena"..i], GetTime(), 120, 1)
  23.     end
  24. end
  25.  
  26. events:SetScript("OnEvent", function(self, event, ...) return self[event](self, ...) end)
  27. events:RegisterEvent("ADDON_LOADED")
  28. events:RegisterEvent("PLAYER_ENTERING_WORLD")
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Adding Classcolor to default ArenaFrames


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off