WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Lua to hide default Arena Frames? (https://www.wowinterface.com/forums/showthread.php?t=56246)

Xancepants 05-27-18 10:47 AM

Lua to hide default Arena Frames?
 
Hello all!
I'm using the addon GladiusEx, which is a replacement for Blizzard's default Arena Frames, but there is no option to hide the default arena frames. I've dug through a lot of forums and found numerous different suggestions, but have yet to find one that works. Is there a simple /console command or CVAR that I haven't come across yet? Or perhaps a Lua script to turn them off?


Here is what I've tried so far:

Lua Code:
  1. --[Hide Default Blizzard Arena Frames]
  2. showArenaEnemyFrames = 0
  3. SetCVar("showArenaEnemyFrames", 0)
  4. LoadAddOn("Blizzard_ArenaUI");ArenaEnemyFrames:Hide();ArenaEnemyFrame1:Hide();ArenaEnemyFrame2:Hide();ArenaEnemyFrame3:Hide();ArenaEnemyFrame4:Hide();ArenaEnemyFrame5:Hide();ArenaEnemyFrame1CastingBar:Hide();ArenaEnemyFrame2CastingBar:Hide();ArenaEnemyFrame3CastingBar:Hide();ArenaEnemyFrame4CastingBar:Hide();ArenaEnemyFrame5CastingBar:Hide();


Any help is appreciated, and thank you in advance! :)

Aftermathhqt 05-27-18 10:55 AM

You can disable them in the Interface Options.. :)

Xancepants 05-27-18 11:03 AM

If you check in game yourself, I believe you'll find that's not true, (at least anymore). You used to be able to, before Blizzard pruned a bunch of things from Interface Options in Legion. I know there is the addon Advanced Interface Options, which essentially brings those back, but I'm hoping to achieve this w/o the use/need of an addon.

Xrystal 05-27-18 11:03 AM

You could try calling this function on each of the Arena Frames. This is called when you adjust the CVAR variable
Lua Code:
  1. function ArenaEnemyFrames_Disable(self)
  2.   self.show = false;
  3.   ArenaEnemyFrames_UpdateVisible();
  4. end

This is the function that calls it in Blizzards addon.
Lua Code:
  1. function ArenaEnemyFrames_CheckEffectiveEnableState(self, cvarUpdate)
  2.   if (C_PvP.IsInBrawl()) then
  3.     ArenaEnemyFrames_Disable(self);
  4.   else
  5.     if ( GetCVarBool("showArenaEnemyFrames") or cvarUpdate ) then
  6.       ArenaEnemyFrames_Enable(self);
  7.     else
  8.       ArenaEnemyFrames_Disable(self);
  9.     end
  10.   end
  11. end

Which is called by the Event Manager function
Lua Code:
  1. if ( (event == "CVAR_UPDATE") and (arg1 == "SHOW_ARENA_ENEMY_FRAMES_TEXT") ) then
  2.     ArenaEnemyFrames_CheckEffectiveEnableState(self, arg2 == "1");

Your code should work I believe but you will need to have an frame to monitor the event ADDON_LOADED so that once you Load Blizzards addon it will trigger the event and its information should be available to use and adjust. I thought the SetCVar would trigger the CVAR_UPDATE event but it is looking for a different CVAR value to what you are setting which could explain why it isn't doing anything noticable. Maybe changing

SetCVar("showArenaEnemyFrames", 0)

to

SetCVar("SHOW_ARENA_ENEMY_FRAMES_TEXT", 0)

and see how that works, then try the ADDON_LOADED steps I suggested.

Xancepants 05-27-18 11:25 AM

I added the line SetCVar("SHOW_ARENA_ENEMY_FRAMES_TEXT", 0), which when you enter the arena the frames still show, but once the gates open then the default frames disappear, which works just fine for me! :)

Thank you a ton!

Vrul 05-27-18 12:49 PM

SetCVar has a third parameter that is used to trigger the CVAR_UPDATE event and is the value passed as the first arg. So you would want to use
Code:

SetCVar('showArenaEnemyFrames', 0, 'SHOW_ARENA_ENEMY_FRAMES_TEXT')
to trigger that OnEvent handler (provided that Blizzard_ArenaUI is loaded).

I'm not sure why setting that CVar before Blizzard_ArenaUI is loaded isn't working though, unless some other code is unparenting ArenaEnemyFrame1-5 from ArenaEnemyFrames.

Cogwerkz 05-28-18 09:10 AM

Another thing to keep in mind when disabling things using CVars, is that you have to make sure the CVar is changed after the blizzard user settings are fully loaded for your character, or it will likely have no effect.

I usually add a check for VARIABLES_LOADED whenever I change CVars, as this is when the blizzard settings have been loaded.

Quote:

Originally Posted by Vrul (Post 328150)
SetCVar
I'm not sure why setting that CVar before Blizzard_ArenaUI is loaded isn't working though, unless some other code is unparenting ArenaEnemyFrame1-5 from ArenaEnemyFrames.

Probably the above. If we change the CVar when our addon is loaded, there's a chance that the blizzard saved variables are loaded at a later point, thus rendering our CVar change useless as we did it too early in the loading process. The Blizzard_ArenaUI isn't loaded until much later, and the VARIABLES_LOADED event has probably fired long before this, thus the CVar change will have effect.


All times are GMT -6. The time now is 12:04 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI