Originally Posted by joeyo
omg!? how did i miss this well they say learn something new everyday.i truly am thankful as ive spent i think close to all day today trying to get this working right lol
unfortunately i still cannot get the pet frame to not show on login. it seems that once i start combat or even target something it will then follow the .lua and act as intended.
so all i have left with the pet frame is to set it to not show within login and to get rid of the damage numbers and threat circle around the portrait but i have yet to look into that.
|
If you want it to hide on login, you'll need to wait for the PLAYER_ENTERING_WORLD event:
Code:
function fHandler_OnEvent(self, event, addon)
if event == "PLAYER_ENTERING_WORLD" then
--Your code here
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent", fHandler_OnEvent)
If you are using that hacked down version of the ImprovedBlizzardUI I posted in the other thread and want to add more frames, don't make a complete new addon just add additional frames:
Code:
--[[
Stripped from ImprovedBlizzardUI by Theroxis
Modified to ONLY hide/unhide the player frame.
modules\frames\player.lua
Styles, Scales and Repositions the Player Unit Frame.
Disables Player Portrait Spam
]]
local PlayerUnitFrame = CreateFrame('Frame', nil, UIParent);
local ForceShown = false
--[[
Hides the Player Frame when you are out of combat, have no target and are at full health.
@ param boolean $hide Should we hide the frame
@ return void
]]
local function HidePlayer(hide)
if (InCombatLockdown() == false) then
if (hide and UnitHealth('player') == UnitHealthMax('player') and UnitExists('target') == false and (not ForceShown)) then
PlayerFrame:Hide();
PetFrame:Hide();
PetFrameManaBar:SetScript("OnShow", PetFrameManaBar.Hide)
else
PlayerFrame:Show();
PetFrame:Show();
PetFrameManaBar:SetScript("OnShow", PetFrameManaBar.Show)
end
end
end
--[[
Handles the WoW API Events Registered Below
@ param Frame $self The Frame that is handling the event
@ param string $event The WoW API Event that has been triggered
@ param arg $... The arguments of the Event
@ return void
]]
local function HandleEvents (self, event, ...)
if (event == 'PLAYER_ENTERING_WORLD' or event == 'PLAYER_LOGIN' or event == 'ADDON_LOADED') then
HidePlayer(true);
end
if (event == 'PLAYER_REGEN_DISABLED') then
HidePlayer(false);
elseif (event == 'PLAYER_REGEN_ENABLED' or event == 'UNIT_HEALTH') then
HidePlayer(true);
end
if (event == 'PLAYER_TARGET_CHANGED') then
if (UnitExists('target')) then
HidePlayer(false);
else
HidePlayer(true);
end
end
if (event == 'UNIT_EXITED_VEHICLE' and ... == 'player') then
StyleFrames();
end
end
function TogglePlayerFrameHide()
ForceShown = not ForceShown
HidePlayer(true)
end
-- Register the Modules Events
PlayerUnitFrame:SetScript('OnEvent', HandleEvents);
PlayerUnitFrame:RegisterEvent('PLAYER_ENTERING_WORLD');
PlayerUnitFrame:RegisterEvent('PLAYER_LOGIN');
PlayerUnitFrame:RegisterEvent('UNIT_HEALTH');
PlayerUnitFrame:RegisterEvent('PLAYER_REGEN_DISABLED');
PlayerUnitFrame:RegisterEvent('PLAYER_REGEN_ENABLED');
PlayerUnitFrame:RegisterEvent('PLAYER_TARGET_CHANGED');
PlayerUnitFrame:RegisterEvent('UNIT_EXITED_VEHICLE');
PlayerUnitFrame:RegisterEvent('ADDON_LOADED');
Obviously I'm not exactly certain what you desire in this; if you want to wait until your pet's health is full then you could just wrap the PetFrame show and hide functions in a conditional, so they aren't hidden until the pet is at full health as well.
Also you can use the state driver with an OnShow hook like the example above:
Code:
RegisterStateDriver(PetFrame,"visibility","[combat,@pet,exists] show;hide")
PetFrameManaBar:SetScript("OnShow", function()
if PetFrame:IsVisible() then
PetFrameManaBar:Show()
else
PetFrameManaBar:Hide()
end
end)
Note that the last solution is probably the most elegant for working around the quirky mana bar behavior. It let's the bar show if the frame itself is visible, but hides it if not.