Thread Tools Display Modes
10-19-10, 11:32 AM   #1
Luponius
A Murloc Raider
Join Date: Oct 2010
Posts: 9
[Solved] KgPanels customization [Fading and visibility]

My UI currently needs some polishing on visual panels and in this case, it's not an aesthetic problem but rather a scripting one.

Long story short, I want to adjust visibility of the panels based on conditions such as being in combat, having a target, and other such stuff as well.

I don't know how much of this is doable but here's my wishlist:

What I'd like to do:
  • Panel for the Chat Frame:
    1. Fades out to 20% when in combat
    2. Goes to 80% visibility if in combat, and mouse is over the frame in question.
    3. [optional] If chat text has faded out, panel fades out completely as well [0% visibility]
  • Panel for the Action Bar:
    1. 0% visibility if [OOC] & [No target selected]
    2. 50% visibility if [OOC] & [Target is selected]
    3. 80% visibility if [In combat] & [No target]
    4. 100% visibility if [In Combat] & [Target Selected]
    5. If any of the above are doable, this should also attempt to modify the parent's [BT4Bar1] visibility to the exact same values mentioned above.
  • Panel for Damage/Threat Meters and Eavesdrop:
    • 0% if [OOC] & [Resting]
    • 50% if [OOC]
    • 75% if [In Combat]
    • 100% if [I'm Dead] (To review statistics of the fight and such)
    • 60% minimum visibility if I mouse over it [Applies only if it's at or beow hte 50% visibility options]
    • This 1 frame I have backing up: [Omen], [Recount] and [Eavesdrop] should also attempt to modify these 3 addons to match visibility, if at all possible.

I'm honestly expecting too much out of this tiny addon lol, but if I can go anywhere near what I mentioned I'd be very happy =]

Last edited by Luponius : 10-23-10 at 02:25 AM. Reason: Solved =]
  Reply With Quote
10-19-10, 07:54 PM   #2
Learza
A Fallenroot Satyr
 
Learza's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2010
Posts: 26
I don't think you can force the panel behavior on it's parent, it's supposed to work the other way round. And because I don't think you can change the alpha of Bartender Bars between more than two values, like say 0% and 100% you either have to be satisfied with those two or maybe take a look at this.
Not sure if you can do it that way because I never used more than 2 alpha values. If it does work with more than two alpha values you only need to get the macro conditions and it should be a solution to all your other requests.
I might be wrong with the panel-parent behavior but I'm fairly certain I remember it correctly.
__________________
  Reply With Quote
10-19-10, 08:15 PM   #3
Ither
A Firelord
 
Ither's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2009
Posts: 497
Most of that can be done with kgPanels scripting. You will need to set on:event tags in order to manipulate certain things.

BT4 does support alpha so you can fade it out at certain levels.
__________________
  Reply With Quote
10-19-10, 11:45 PM   #4
Luponius
A Murloc Raider
Join Date: Oct 2010
Posts: 9
Thanks for the replies =]

Originally Posted by Learza View Post
I don't think you can force the panel behavior on it's parent, it's supposed to work the other way round. And because I don't think you can change the alpha of Bartender Bars between more than two values, like say 0% and 100% you either have to be satisfied with those two or maybe take a look at this.
Not sure if you can do it that way because I never used more than 2 alpha values. If it does work with more than two alpha values you only need to get the macro conditions and it should be a solution to all your other requests.
I might be wrong with the panel-parent behavior but I'm fairly certain I remember it correctly.
I actually read many times that Kgpanels can force behaviour on its parent, as to what kind of behaviour, I so far only read it's viable to show and hide them, but as Storm mentioned, if it does support alpha at extremities, why wouldn't it be able to do the same without those extremities?

Originally Posted by StormCalai View Post
Most of that can be done with kgPanels scripting. You will need to set on:event tags in order to manipulate certain things.

BT4 does support alpha so you can fade it out at certain levels.
The problem I'm facing at this point is quite obvious and hard to get past, I simply have no clue of the data I need to input in onLoad and onEvent to actually gain some functionality. This is my first time looking at any sort of scripting for WoW, and although I'm not a first timer to programming, I can't quite figure out a solid resource that documents the various options we have available... If you have any idea as to what I need to type in, would appreciate it greatly
  Reply With Quote
10-20-10, 09:30 AM   #5
Taryble
A Molten Giant
 
Taryble's Avatar
Join Date: Jan 2009
Posts: 811
Honestly, WoWWiki probably has the most complete reference to the WoW API's of any website source. There is also a website on Programming for WoW, that hosts a lot of the FrameXML and Lua code provided for constants and Blizzard's UI elements. (wowprogramming.com)

between those, and the sites listed as Lua resources on WoWWiki's "Lua" page, and programming experience, you should be able to figure out what's needed.
__________________
-- Taryble
  Reply With Quote
10-21-10, 10:25 AM   #6
Luponius
A Murloc Raider
Join Date: Oct 2010
Posts: 9
Been digging around for quite a while now, no results that worked, although I hope I'm picking a few good leads here... The issues I'm facing are to find the correct events that need be tested for to fire the conditions. The following is what I need, and what I found:

Checking if a target is selected
Code:
UNIT_TARGET	Fires when a unit's target changes
PLAYER_TARGET_CHANGED	Fires when the player changes targets
Technically, the description seems to indicate both may not be what I need. Still, if I can test to see if player_target_changed defaults to "no target" somehow I could use that as a "no target selected" event. I want this to happen similar to Pitbull, in fact exactly the same, "If target selected, set this alpha:" kind of concept. If you got the right one would appreciate help on this

Checking if player's in combat or not
Code:
PLAYER_REGEN_DISABLED	Fires when the player enters combat status
PLAYER_REGEN_ENABLED	Fires when the player leaves combat status
Quite positive that's right, the description is very straight forward here. Still need to figure out how multiple conditions are checked with AND and OR conditionals (Mostly need to figure out the right syntax for LUA)

Changing Color Settings:
Code:
OnLoad

local _, class = UnitClass("player");
	if class == "WARRIOR" then
        self.bg:SetVertexColor(0.95, 0.23, 0.23, self.bg:GetAlpha())
Sadly this is the part I barely got any information on. The above is all I could scrounge up which has a relation to changing alpha, and even then, this doesn't quite change the alpha but uses what's already there, if I am interpreting it correctly. Maybe it's something like self:SetAlpha(0.5) for setting visibility to 50% or something, and I'll have to give it a shot when I get some time.

I'd appreciate any help on any of the above, LUA is a first time thing for me, and researching seems to only get me so far without checking into the language itself. If nothing turns up and nobody has any idea on what I can attempt, I'll probably start looking into Pitbull4 code to see how target checks are carried out and how alpha values are set, in hopes of applying that to kgPanels.
  Reply With Quote
10-21-10, 11:09 AM   #7
Kagaro
A Cyclonian
AddOn Author - Click to view addons
Join Date: Sep 2006
Posts: 45
Originally Posted by Luponius View Post
Been digging around for quite a while now, no results that worked, although I hope I'm picking a few good leads here... The issues I'm facing are to find the correct events that need be tested for to fire the conditions. The following is what I need, and what I found:

Checking if a target is selected
Code:
UNIT_TARGET	Fires when a unit's target changes
PLAYER_TARGET_CHANGED	Fires when the player changes targets
Technically, the description seems to indicate both may not be what I need. Still, if I can test to see if player_target_changed defaults to "no target" somehow I could use that as a "no target selected" event. I want this to happen similar to Pitbull, in fact exactly the same, "If target selected, set this alpha:" kind of concept. If you got the right one would appreciate help on this

Checking if player's in combat or not
Code:
PLAYER_REGEN_DISABLED	Fires when the player enters combat status
PLAYER_REGEN_ENABLED	Fires when the player leaves combat status
Quite positive that's right, the description is very straight forward here. Still need to figure out how multiple conditions are checked with AND and OR conditionals (Mostly need to figure out the right syntax for LUA)

Changing Color Settings:
Code:
OnLoad

local _, class = UnitClass("player");
	if class == "WARRIOR" then
        self.bg:SetVertexColor(0.95, 0.23, 0.23, self.bg:GetAlpha())
Sadly this is the part I barely got any information on. The above is all I could scrounge up which has a relation to changing alpha, and even then, this doesn't quite change the alpha but uses what's already there, if I am interpreting it correctly. Maybe it's something like self:SetAlpha(0.5) for setting visibility to 50% or something, and I'll have to give it a shot when I get some time.

I'd appreciate any help on any of the above, LUA is a first time thing for me, and researching seems to only get me so far without checking into the language itself. If nothing turns up and nobody has any idea on what I can attempt, I'll probably start looking into Pitbull4 code to see how target checks are carried out and how alpha values are set, in hopes of applying that to kgPanels.
self:SetAlpha()changes the frame, self.bg.SetVertexColor(...) was changing the color on the backgrund.
  Reply With Quote
10-21-10, 03:32 PM   #8
Luponius
A Murloc Raider
Join Date: Oct 2010
Posts: 9
Thanks on the SetAlpha() correction. So far this is where I'm at with the code:

Code:
onLoad:
-------
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("UNIT_TARGET")

onEvent:
--------
if event == "PLAYER_REGEN_DISABLED" and UnitExists("target") then
    Self:SetAlpha(1)
    self:GetParent():SetAlpha(0.9)
elseif event == "PLAYER_REGEN_DISABLED" then
    Self:SetAlpha (0.8)
    self:GetParent():SetAlpha(0.7)
elseif event == "PLAYER_REGEN_ENABLED" and UnitExists ("target") then
    Self:SetAlpha (0.5)
    self:GetParent():SetAlpha(0.4)
else
    Self:SetAlpha (0)
    self:GetParent():SetAlpha(0)
I also found this posted by you, Kagaro:
Changing a frame based on Target

OnLoad

self:RegisterEvent("UNIT_TARGET")
self:Hide()

OnEvent

if UnitExists("target") == nil then
self:Hide()
return
end


I guess that explains my mistake with the target checks, I assumed it automatically returns a positive if i have a target and a negative if i don't. Should of included == nil. Will try that when I can.

Last edited by Luponius : 10-22-10 at 01:37 AM.
  Reply With Quote
10-22-10, 09:21 AM   #9
Luponius
A Murloc Raider
Join Date: Oct 2010
Posts: 9
Tried the following with no success [Panel shows fully visible for a split second as soon as I enter combat, and disappears very quickly after that. No real clue what's gone wrong in this case, appreciate any insight.
Code:
if (event == "PLAYER_REGEN_DISABLED") and (UnitExists("target") == nil) then
    self:SetAlpha(0.8)
    self:GetParent():SetAlpha(0.7)
elseif (event == "PLAYER_REGEN_DISABLED") then
    self:SetAlpha (1)
    self:GetParent():SetAlpha(0.9)
elseif (event == "PLAYER_REGEN_ENABLED" and UnitExists ("target") == nil) then
    self:SetAlpha (0)
    self:GetParent():SetAlpha(0)
else
    self:SetAlpha (0.5)
    self:GetParent():SetAlpha(0)
end
  Reply With Quote
10-23-10, 02:24 AM   #10
Luponius
A Murloc Raider
Join Date: Oct 2010
Posts: 9
Shameless triple post following, but I fixed the issue and took it a step further as well thanks to a guildie. I acquired full functionality for the action bar panel, and added fading as well. Below is the code for onLoad onEvent and onUpdate for anybody who's interested:

onLoad:
Code:
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("UNIT_TARGET")

self.inCombat = false
self.fadeTo = 0
onEvent:
Code:
if (event == "PLAYER_REGEN_DISABLED") then
    self.inCombat = true
elseif (event == "PLAYER_REGEN_ENABLED") then
    self.inCombat = false
end

if self.inCombat then
    if (UnitExists ("target") == nil) then
        self.fadeTo = 0.7
    else
        self.fadeTo = 1
    end
else
    if (UnitExists ("target") == nil) then
        self.fadeTo = 0
    else
        self.fadeTo = 0.5
    end
end
onUpdate:
Code:
local selfAlpha = self:GetParent():GetAlpha()

if ( selfAlpha ~= self.fadeTo ) then
    if ( selfAlpha > self.fadeTo ) then
        if ( selfAlpha - self.fadeTo < 0.1 ) then
            self:GetParent():SetAlpha(self.fadeTo)
        else
            self:GetParent():SetAlpha(selfAlpha - 0.1 )
        end
    else
        if ( self.fadeTo - selfAlpha < 0.1 ) then
            self:GetParent():SetAlpha(self.fadeTo)
        else
            self:GetParent():SetAlpha(selfAlpha + 0.1 )
        end
    end
end
The problem was I should of made a variable to store whether I'm in combat or not. Triggering a Target_Unit event when in combat would mean the program doesn't know if the character is in combat or not when going through the Event code. Declaring an inCombat var in onLoad was the solution to the main issue. Coding the rest of the program cleanly and in an organized fashion that made sense was also the other end of the coin
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » kgpanels customization


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