Thread Tools Display Modes
05-19-11, 07:58 PM   #1
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
Hiding Unitframes

I have tried everything I can find in this massive forum post, and my eyes hurt. What I am trying to do is add a function to my unit frames. I want my player frame to hide.

I want it to ONLY show if
-I am NOT at full health and mana
-I am in a party or raid
-I am in a BG/Arena

I am using Ouf_Drk.

I can get it in the Lua, I just need someone to put it up here so I can cut, and paste it.. I am willing to pay with my first born, OR human blood (Up to 11.7 Litres) .. :P
  Reply With Quote
05-19-11, 08:47 PM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
I'd start with oUF_BarFader (plugin) and maybe modify it to match your conditions or live with the default settings.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
05-19-11, 11:03 PM   #3
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
oUF_BarFader is outdated but easy to fix.

UNIT_FOCUS, UNIT_ENERGY, UNIT_RAGE, UNIT_MANA and UNIT_RUNIC_POWER got merged into UNIT_POWER.

UNIT_HAPPINESS, GetPetHappiness(), UnitMana(), UnitManaMax() are no more.

For party/raid check you could try registering PARTY_LEADER_CHANGED (not sure right now if this gets fired upon joining a raid) and check GetNumPartyMembers() and GetNumRaidMembers(). Alternatively use PARTY_MEMBERS_CHANGED and RAID_ROSTER_UPDATE if PARTY_LEADER_CHANGED is not fired as wished.

You then have to add oUF_BarFader as OptDep to the .toc of your layout and set 'self.BarFade = true' and 'self.BarFadeMinAlpha = 0' for your player frame.
  Reply With Quote
05-19-11, 11:31 PM   #4
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
Thank you Soooo MUCH!
  Reply With Quote
05-19-11, 11:46 PM   #5
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
Originally Posted by Rainrider View Post
oUF_BarFader is outdated but easy to fix.

UNIT_FOCUS, UNIT_ENERGY, UNIT_RAGE, UNIT_MANA and UNIT_RUNIC_POWER got merged into UNIT_POWER.

UNIT_HAPPINESS, GetPetHappiness(), UnitMana(), UnitManaMax() are no more.

For party/raid check you could try registering PARTY_LEADER_CHANGED (not sure right now if this gets fired upon joining a raid) and check GetNumPartyMembers() and GetNumRaidMembers(). Alternatively use PARTY_MEMBERS_CHANGED and RAID_ROSTER_UPDATE if PARTY_LEADER_CHANGED is not fired as wished.

You then have to add oUF_BarFader as OptDep to the .toc of your layout and set 'self.BarFade = true' and 'self.BarFadeMinAlpha = 0' for your player frame.
So .. do I change all instances of (UNIT_FOCUS, UNIT_ENERGY, UNIT_RAGE, UNIT_MANA and UNIT_RUNIC_POWER)

Into (UNIT_POWER) ?

Okay and This is my Player frame infor from Core.Lua Where do I put (self.BarFade = true' and 'self.BarFadeMinAlpha = 0)

UnitSpecific = {
player = function(self)
-- unit specifics
self.mystyle = "player"
lib.addHealthBar(self)
lib.addPowerBar(self)
lib.addPortrait(self)

-- Set frame size
self:SetScale(cfg.frameScale)
self:SetWidth(250)
self:SetHeight(53)

-- Set statusbars specifics
self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
self.Health:SetSize(250, 33)
self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))

self.Power:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 0, 0)
self.Power:SetSize(250, 15)
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorClass = true
self.Power.bg.multiplier = 0.3
self.Power.frequentUpdates = true

lib.addTextTags(self, 17)
lib.ThreatBar(self)
lib.AltPowerBar(self)

lib.addIcons(self)

lib.addClassBar(self)

-- Buffs and Debuffs
if cfg.showPlayerBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.player) end
if cfg.showPlayerDebuffs then lib.addDebuffs(self,cfg.auras.DEBUFFPOSITIONS.player) end

lib.addCastBar(self, false)

-- Plugins
lib.addCombatFeedback(self)
end,

Thanx :P

Last edited by gezus : 05-19-11 at 11:53 PM.
  Reply With Quote
05-20-11, 01:42 AM   #6
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
Okay .. I totally got it working 99.9%

Now the only issue I have is when I target something the target frame comes up, and then the player frame comes up about 2 seconds later. I would love it if I could fix this to be instant.

I realize that it's purely esthetic's, but alas tis more fun to love the UI you use :P ..

Anyways, What I did was removed the "fade effect" So Bar appear and disappear instantly, and work perfectly the way I want. Just the simple fact that the player frame responds slower than the target frame.

I would appreciate anymore help, and I promise I will stop bothering you all :P
  Reply With Quote
05-20-11, 07:26 AM   #7
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
Well, post your code, can't help without seeing what you've done.
  Reply With Quote
05-20-11, 09:42 AM   #8
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
Originally Posted by Rainrider View Post
Well, post your code, can't help without seeing what you've done.
Okay .. here is the code from Core.Lua inside the oUF_Drk folder.
local addon, ns = ...

local cfg = ns.cfg
local lib = ns.lib

-----------------------------
-- STYLE FUNCTIONS
-----------------------------

local bgMulti = 0.4

-- Hide Blizzard stuff
if cfg.hideRaidFrame then
CompactRaidFrameManager:UnregisterAllEvents()
CompactRaidFrameManager:Hide()
end

if cfg.hideRaidFrameContainer then
CompactRaidFrameContainer:UnregisterAllEvents()
CompactRaidFrameContainer:Hide()
end

if cfg.hideBuffFrame then
BuffFrame:Hide()
end

if cfg.hideWeaponEnchants then
TemporaryEnchantFrame:Hide()
end

-- Menus
local dropdown = CreateFrame("Frame", "MyAddOnUnitDropDownMenu", UIParent, "UIDropDownMenuTemplate")

UIDropDownMenu_Initialize(dropdown, function(self)
local unit = self:GetParent().unit
if not unit then return end

local menu, name, id
if UnitIsUnit(unit, "player") then
menu = "SELF"
elseif UnitIsUnit(unit, "vehicle") then
menu = "VEHICLE"
elseif UnitIsUnit(unit, "pet") then
menu = "PET"
elseif UnitIsPlayer(unit) then
id = UnitInRaid(unit)
if id then
menu = "RAID_PLAYER"
name = GetRaidRosterInfo(id)
elseif UnitInParty(unit) then
menu = "PARTY"
else
menu = "PLAYER"
end
else
menu = "TARGET"
name = RAID_TARGET_ICON
end
if menu then
UnitPopup_ShowMenu(self, menu, unit, name, id)
end
end, "MENU")

local menu = function(self)
dropdown:SetParent(self)
ToggleDropDownMenu(1, nil, dropdown, "cursor", 0, 0)
end

UnitSpecific = {
player = function(self)
-- unit specifics
self.mystyle = "player"
lib.addHealthBar(self)
lib.addPowerBar(self)
lib.addPortrait(self)

-- Set frame size
self:SetScale(cfg.frameScale)
self:SetWidth(250)
self:SetHeight(53)

-- Set statusbars specifics
self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
self.Health:SetSize(250, 33)
self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))

self.Power:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 0, 0)
self.Power:SetSize(250, 15)
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorClass = true
self.Power.bg.multiplier = 0.3
self.Power.frequentUpdates = true
self.BarFade = true
self.BarFadeMinAlpha = -1

lib.addTextTags(self, 17)
lib.ThreatBar(self)
lib.AltPowerBar(self)

lib.addIcons(self)

lib.addClassBar(self)

-- Buffs and Debuffs
if cfg.showPlayerBuffs then lib.addBuffs(self, cfg.auras.BUFFPOSITIONS.player) end
if cfg.showPlayerDebuffs then lib.addDebuffs(self,cfg.auras.DEBUFFPOSITIONS.player) end

lib.addCastBar(self, false)

-- Plugins
lib.addCombatFeedback(self)
end,

target = function(self)
-- unit specifics
self.mystyle = "target"
lib.addHealthBar(self)
lib.addPowerBar(self)
lib.addPortrait(self)

-- Set frame size
self:SetScale(cfg.frameScale)
self:SetWidth(250)
self:SetHeight(53)

-- Set statusbars specifics
self.Health:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 0)
self.Health:SetSize(250, 33)
self.Health:SetStatusBarColor(unpack(cfg.healthBarColor))
self.Health.bg:SetVertexColor(unpack(cfg.healthBgColor))

self.Power:SetPoint('BOTTOMLEFT', self, 'BOTTOMLEFT', 0, 0)
self.Power:SetSize(250, 15)
self.Power.colorTapping = true
self.Power.colorDisconnected = true
self.Power.colorHappiness = false
self.Power.colorReaction = true
self.Power.colorClass = true
self.Power.bg.multiplier = 0.3


lib.addTextTags(self, 17)

lib.addIcons(self)
And here is the code from oUF_BarFader.Lua
--[[

Shared:
- BarFade [boolean]
- BarFadeMinAlpha [value] default: 0
- BarFadeMaxAlpha [value] default: 1

--]]

local function pending(self, unit)
local num, str = UnitPowerType(unit)
if(self.Castbar and (self.Castbar.casting or self.Castbar.channeling)) then return true end
if(UnitAffectingCombat(unit)) then return true end
if(unit == 'pet' and GetPetHappiness() and GetPetHappiness() < 3) then return true end
if(UnitExists(unit..'target')) then return true end
if(UnitHealth(unit) < UnitHealthMax(unit)) then return true end
if((str == 'RAGE' or str == 'RUNIC_POWER') and UnitPower(unit) > 0) then return true end
if((str ~= 'RAGE' and str ~= 'RUNIC_POWER') and UnitMana(unit) < UnitManaMax(unit)) then return true end
end

local function update(self, event, unit)
if(unit and unit ~= self.unit) then return end

if(not pending(self, self.unit)) then
UIFrameFadeOut(self, 0, self:GetAlpha(), self.BarFaderMinAlpha or 0)
else
UIFrameFadeIn(self, 0, self:GetAlpha(), self.BarFaderMaxAlpha or 1)
end
end

local function enable(self, unit)
if(unit and self.BarFade) then
update(self)

self:RegisterEvent('UNIT_COMBAT', update)
self:RegisterEvent('UNIT_TARGET', update)
self:RegisterEvent('UNIT_POWER', update)
self:RegisterEvent('UNIT_HEALTH', update)
self:RegisterEvent('UNIT_POWER', update)


if(self.Castbar) then
self:RegisterEvent('UNIT_SPELLCAST_START', update)
self:RegisterEvent('UNIT_SPELLCAST_FAILED', update)
self:RegisterEvent('UNIT_SPELLCAST_STOP', update)
self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', update)
self:RegisterEvent('UNIT_SPELLCAST_DELAYED', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED', update)
self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', update)
end

return true
end
end

local function disable(self)
if(self.BarFade) then
self:UnregisterEvent('UNIT_COMBAT', update)
self:UnregisterEvent('UNIT_TARGET', update)
self:UnregisterEvent('UNIT_FOCUS', update)
self:UnregisterEvent('UNIT_HEALTH', update)
self:UnregisterEvent('UNIT_POWER', update)


if(self.Castbar) then
self:UnregisterEvent('UNIT_SPELLCAST_START', update)
self:UnregisterEvent('UNIT_SPELLCAST_FAILED', update)
self:UnregisterEvent('UNIT_SPELLCAST_STOP', update)
self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', update)
self:UnregisterEvent('UNIT_SPELLCAST_DELAYED', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_START', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED', update)
self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', update)
end
end
end

oUF:AddElement('BarFader', update, enable, disable)
Thanx again gang, it's truly appreciated.
  Reply With Quote
05-20-11, 12:40 PM   #9
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
From my previous post:

UNIT_HAPPINESS, GetPetHappiness(), UnitMana(), UnitManaMax() are no more.
From your code:
lua Code:
  1. if(unit == 'pet' and GetPetHappiness() and GetPetHappiness() < 3) then return true end
  2. ...
  3. if((str == 'RAGE' or str == 'RUNIC_POWER') and UnitPower(unit) > 0) then return true end
  4. if((str ~= 'RAGE' and str ~= 'RUNIC_POWER') and UnitMana(unit) < UnitManaMax(unit)) then return true end
  5. end
  Reply With Quote
05-20-11, 06:51 PM   #10
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
Originally Posted by Rainrider View Post
From my previous post:



From your code:
lua Code:
  1. if(unit == 'pet' and GetPetHappiness() and GetPetHappiness() < 3) then return true end
  2. ...
  3. if((str == 'RAGE' or str == 'RUNIC_POWER') and UnitPower(unit) > 0) then return true end
  4. if((str ~= 'RAGE' and str ~= 'RUNIC_POWER') and UnitMana(unit) < UnitManaMax(unit)) then return true end
  5. end
Thats all well and good, but as I said, it works fine the way I have it atm. Unless you are telling me that removing these 5 lines will fix the lag I am experiencing with the Player frame appearing?

Removing or changing any one of the lines in your quote completely prevent the mod from working at all. I have to replace them exactly the way they currently are to get back to where they where working properly.

You say that these things (UNIT_HAPPINESS, GetPetHappiness(), UnitMana(), UnitManaMax() are no more. But I am confused as to what to do with them. Replace them? Delete them? ..

Sorry for my derpiness. And as always your help is greatly appreciated.

Last edited by gezus : 05-20-11 at 07:19 PM.
  Reply With Quote
05-21-11, 10:56 AM   #11
Rainrider
A Firelord
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 454
To be honest, I don't know why it lags so much for you. The only proposal I have left is to upvalue the function used in pending.

Apparently UnitMana and UnitManaMax are still there (they're just the same as UnitPower and UnitPowerMax). That's why you didn't get any errors there. You have enabled BarFader for the player frame only, that's why you didn't noticed the error GetPetHappiness() produces.

p3lim has a typo and checks for self.BarFaderMinAlpha instead of self.BarFadeMinAlpha, but that way you just got the default value of 0.25 and again no probs.

Frame fading-in on casts does not function (that's a race condition I believe. You could test this with bandaging yourself and using the hearthstone)

Here the code that worked for me
(typo in self.BarFaderMinAlpha fixed, blizz funcs as upvalues, removed useless events, removed GetPetHappiness, used UnitPower instead of UnitMana)
lua Code:
  1. --[[
  2.  
  3.     Shared:
  4.      - BarFade [boolean]
  5.      - BarFadeMinAlpha [value] default: 0.25
  6.      - BarFadeMaxAlpha [value] default: 1
  7.  
  8. --]]
  9.  
  10. local UnitPowerType = UnitPowerType
  11. local UnitAffectingCombat = UnitAffectingCombat
  12. local UnitExists = UnitExists
  13. local UnitHealth = UnitHealth
  14. local UnitHealthMax = UnitHealthMax
  15. local UnitPower = UnitPower
  16. local UnitPowerMax = UnitPowerMax
  17.  
  18. local function pending(self, unit)
  19.     local num, str = UnitPowerType(unit)
  20.     if(self.Castbar and (self.Castbar.casting or self.Castbar.channeling)) then return true end
  21.     if(UnitAffectingCombat(unit)) then return true end
  22.     if(UnitExists(unit..'target')) then return true end
  23.     if(UnitHealth(unit) < UnitHealthMax(unit)) then return true end
  24.     if((str == 'RAGE' or str == 'RUNIC_POWER') and UnitPower(unit) > 0) then return true end
  25.     if(str ~= 'RAGE' and str ~= 'RUNIC_POWER' and UnitPower(unit) < UnitPowerMax(unit)) then return true end
  26. end
  27.  
  28. local function update(self, event, unit)
  29.     if(unit and unit ~= self.unit) then return end
  30.     if(not pending(self, self.unit)) then
  31.         self:SetAlpha(self.BarFadeMinAlpha or 0.25)
  32.     else
  33.         self:SetAlpha(self.BarFadeMaxAlpha or 1)
  34.     end
  35. end
  36.  
  37. local function enable(self, unit)
  38.     if(unit and self.BarFade) then
  39.         update(self)
  40.  
  41.         self:RegisterEvent('UNIT_COMBAT', update)
  42.         self:RegisterEvent('UNIT_TARGET', update)
  43.         self:RegisterEvent('UNIT_HEALTH', update)
  44.         self:RegisterEvent('UNIT_POWER', update)
  45.  
  46.         if(self.Castbar) then
  47.             self:RegisterEvent('UNIT_SPELLCAST_START', update)
  48.             self:RegisterEvent('UNIT_SPELLCAST_FAILED', update)
  49.             self:RegisterEvent('UNIT_SPELLCAST_STOP', update)
  50.             self:RegisterEvent('UNIT_SPELLCAST_INTERRUPTED', update)
  51.             self:RegisterEvent('UNIT_SPELLCAST_DELAYED', update)
  52.             self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_START', update)
  53.             self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', update)
  54.             self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED', update)
  55.             self:RegisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', update)
  56.         end
  57.  
  58.         return true
  59.     end
  60. end
  61.  
  62. local function disable(self)
  63.     if(self.BarFade) then
  64.         self:UnregisterEvent('UNIT_COMBAT', update)
  65.         self:UnregisterEvent('UNIT_TARGET', update)
  66.         self:UnregisterEvent('UNIT_HEALTH', update)
  67.         self:UnregisterEvent('UNIT_POWER', update)
  68.  
  69.         if(self.Castbar) then
  70.             self:UnregisterEvent('UNIT_SPELLCAST_START', update)
  71.             self:UnregisterEvent('UNIT_SPELLCAST_FAILED', update)
  72.             self:UnregisterEvent('UNIT_SPELLCAST_STOP', update)
  73.             self:UnregisterEvent('UNIT_SPELLCAST_INTERRUPTED', update)
  74.             self:UnregisterEvent('UNIT_SPELLCAST_DELAYED', update)
  75.             self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_START', update)
  76.             self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_UPDATE', update)
  77.             self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_INTERRUPTED', update)
  78.             self:UnregisterEvent('UNIT_SPELLCAST_CHANNEL_STOP', update)
  79.         end
  80.     end
  81. end
  82.  
  83. oUF:AddElement('BarFader', update, enable, disable)

There is a small lag when fading in/out, but it's half a second or less for me. Upvalueing the funcs does not make a difference for me either.
  Reply With Quote
05-21-11, 11:19 PM   #12
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
cool man, I definitely appreciate your continued response. I'll give your code a go and see what happens.

Brb :P

Okay .. working exactly like I want, but still the quick lag. I made a super quick fraps vid just to show you what I mean, in case I wasn't explaining it properly.

http://www.youtube.com/watch?v=EN4rPZ3BZLE

Last edited by gezus : 05-22-11 at 09:37 AM.
  Reply With Quote
05-22-11, 12:20 PM   #13
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 918
That has been like that forever with BarFader. You will learn to live with it. Not that it's game breaking, anyway.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

  Reply With Quote
05-22-11, 06:58 PM   #14
gezus
A Deviate Faerie Dragon
Join Date: Oct 2008
Posts: 11
yeah thats what I assumed, all good. just thought it was worth a shot.

On a side note. works well and I love it :P
  Reply With Quote
03-02-12, 04:25 AM   #15
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Due to the high amount of requests, I have updated the plug-in.
http://www.wowinterface.com/download...-oUFFader.html
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Hiding Unitframes


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