• 0

    posted a message on kgPanels Offical Thread
    Quote from Elvv
    Ey dont mean to spam or anything i posted this a page back and im still looking for help on how to do it, blizzard recently added an event where you have a threatstatus and i want to make it so omen shows and toggles recount if I have a certain threat status on my target.

    http://www.wowwiki.com/API_UnitDetailedThreatSituation is the linky.

    "status
    Integer - returns the threat status for the unit on the mob, or nil if unit is not on mob's threat table. (3 = securely tanking, 2 = insecurely tanking, 1 = not tanking but higher threat than tank, 0 = not tanking and lower threat than tank)
    threatpct "


    The first order of business is figuring out how the UnitDetailedThreatSituation function works.

    isTanking, status, threatpct, rawthreatpct, threatvalue = UnitDetailedThreatSituation("unit", "mob")

    You can use this like the following (from WoWWiki):

    local _,_,threatpct,_,_ = UnitDetailedThreatSituation("player", "target");
    ChatFrame1:AddMessage('You are ' .. tostring(threatpct) .. '% towards aggro.');

    Now you need a basic frame to see if we can print the data out when you want. This particular code tests that you are in combat, and your target can be attacked. For this I'm using UnitCanAttack.

    http://wowprogramming.com/docs/api/UnitCanAttack

    <OnLoad>
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
    self:RegisterEvent("PLAYER_REGEN_ENABLED")
    self:RegisterEvent("PLAYER_TARGET_CHANGED")
    self.in_combat = nil
    self.have_combat_target = nil
    </OnLoad>

    <OnEvent>
    if event == "PLAYER_REGEN_ENABLED" then
    self.in_combat = true
    elseif event == "PLAYER_REGEN_DISABLED" then
    self.in_combat = nil
    elseif event == "PLAYER_TARGET_CHANGED" then
    if UnitCanAttack("player", "target") == true then
    self.have_combat_target = true
    else
    self.have_combat_target = nil
    end
    end
    </OnEvent>

    <OnUpdate>
    if self.in_combat && self.have_combat_target == true then
    _, status, _, _, _ = UnitDetailedThreatSituation("player", "target")
    ChatFrame1:AddMessage('You have ' .. tostring(status) .. ' threat status.');
    end
    </OnUpdate>

    This will spam your chatframe with status data. If this prints out the data when you want it to, then your mostly there.

    The last part is to use the status value to show or hide the frame. For this, use the kgpanels frame finder to determine the name of the frame. Once you have this, you should be able to have an OnUpdate that's like this.

    <OnUpdate>
    if self.in_combat && self.have_combat_target == true then
    _, status, _, _, _ = UnitDetailedThreatSituation("player", "target")
    if status <= 2 then
    OmenFrame:Show()
    else
    OmenFrame:Hide()
    end
    end
    </OnUpdate>

    None of this code is tested, so no guarantee that this will work. Use the AddMessage to print strings to display that you have received events to help troubleshoot.

    Good luck!

    (I really miss the <> and <> brackets in the forum, argh)
    Posted in: General AddOns
  • 0

    posted a message on kgPanels Offical Thread
    I finally got the panel highlighting behavior I want, but I had to modify ZMobDB to do it.

    ---ZMobDB_Setting.lua---

    function ZMobDB_Tooltip_Unit()
    ... Original Function Code ...

    ZMobDB_Frame_Mouseover = ZMobDB_Avatar_GetUnitType(getglobal("ZMobDB_Camera"..this:GetID()):GetChildren());
    end
    -------------------------

    I added the bottom line of code that assigns my ZMobDB_Frame_Mouseover variable. The ZMobDB_Frame_Mouseover is a string that is set to the unit name of the frame that the mouse is over. The ZMobDB_Tooltip_Unit is the OnEnter handler for all the ZMobDB_Frame_* frames.

    ---ZMobDB.lua---
    Frame_Name:SetScript("OnEnter",ZMobDB_Tooltip_Unit); *
    Frame_Name:SetScript("OnLeave", function ()
    ZMobDB_Frame_Mouseover = nil;
    end);
    -----------------

    The * is the original line of code in ZMobDB.lua that registers the OnEnter handler. I placed my OnLeave script after it. Since the ZMobDB addon does not have an OnLeave handler for ZMobDB_Frame_* frames, I needed to make one that would clear the Mouseover state when I leave any of the ZMobDB_Frame_* frames.

    With this in place, I can use that variable to show or hide the appropriate highlight panel for the given unit.

    ---kgPlayerZMobHPanel---

    <OnLoad>
    local frame = kgPanels:FetchFrame( "kgPlayerZMobPanel" )

    if frame then
    self.bg:ClearAllPoints()
    self.bg:SetAllPoints(frame)
    end

    local _, rclass = UnitClass("player")
    local color = RAID_CLASS_COLORS[rclass]
    self.bg:SetVertexColor(color.r, color.g, color.b, self.bg:GetAlpha())
    self.bg:SetBlendMode("BLEND")
    </OnLoad>

    <OnUpdate>
    local frame = kgPanels:FetchFrame( "kgPlayerZMobHPanel2" )

    if ZMobDB_Frame_Mouseover == "player" then
    frame:Show()
    else
    frame:Hide()
    end
    </OnUpdate>

    ---kgPlayerZMobHPanel2---

    <OnLoad>
    local frame = kgPanels:FetchFrame( "kgPlayerZMobPanel" )

    if frame then
    self.bg:ClearAllPoints()
    self.bg:SetAllPoints(frame)
    end

    local _, rclass = UnitClass("player")
    local color = RAID_CLASS_COLORS[rclass]
    self.bg:SetVertexColor(color.r, color.g, color.b, self.bg:GetAlpha())
    self.bg:SetBlendMode("ADD")

    self:Hide()
    </OnLoad>

    Not moused over ZMobDB_Frame_player: http://i34.tinypic.com/ve0nli.jpg

    Moused over ZMobDB_Frame_player: http://i33.tinypic.com/2dtu82v.jpg

    For some reason, I couldn't get kgPlayerZMobHPanel2's OnUpdate to work, so I used the OnUpdate from kgPlayerZMobHPanel and used kgPanels:FetchFrame to show/hide the highlight. Don't quite understand why.

    Overall it works pretty good. The ZMob frame is still "cliqueable" which is good. If there are any tips on implementation details that may improve the solution, mostly if I can avoid directly editing the ZMobDB addon code, I'm open to hear 'em.

    EDIT:

    I found that using MouseIsOver is a way that I can get around modifying ZMobDB. There is an update with 3.3 that should add a UI API call to find out if you are moused over any frame. This will give the highlight effect but without the issues of intercepting another panels events. The new update for kgPlayerZMobHPanel is the following.

    ---kgPlayerZMobHPanel---

    <OnUpdate>
    local frame = kgPanels:FetchFrame( "kgPlayerZMobHPanel2" )

    if MouseIsOver( ZMobDB_Frame_player ) then
    frame:Show()
    else
    frame:Hide()
    end
    </OnUpdate>

    Still can't figure out why I can't do this in kgPlayerZMobHPanel2's OnUpdate though.
    Posted in: General AddOns
  • 0

    posted a message on kgPanels Offical Thread
    Alrighty, I got some stuff figured out, but still don't have the behavior I want.

    Apparently, the clique-enabled frame ZMobDB_Frame_player is only active when the Hold Windows option in ZMob is enabled. If it is not enabled, you can move and resize the ZMob frame, and then re-enable Hold Windows to use clique on it. It caused a good deal of confusion when trying to attach kgpanels to them.

    I tried putting a kgpanel in a strata lower than ZMob_Frame_player using OnEnter and OnLeave to show and hide the class color highlight panel. The panel lit up as I entered the kgPlayerZMobBGPanel, but when I entered the ZMobDB_Frame_player frame that is on top of kgPlayerZMobBGPanel, it triggered kgPlayerZMobBGPanel's OnLeave event causing my highlight to disappear while in ZMobDB_Frame_player. As soon as I left ZMobDB_Frame_player, the highlight showed up again until I left kgPlayerZMobBGPanel.

    Unfortunately, I would like the highlight to stay while I'm inside ZMobDB_Frame_player, but haven't come up with a scheme that will get that to work. Is there any way to maintain a state when traveling from kgPlayerZMobBGPanel into ZMobDB_Frame_player?

    I'll play with it a little more, but I'm out of ideas at the moment.

    -- Edit

    Any chance that using some combination of these attributes may work?

    SetAttribute("AddChild", frame);
    SetAttribute("*childstate-OnEnter", "enter");
    SetAttribute("*childstate-OnLeave", "leave");

    Still investigating...
    Posted in: General AddOns
  • 0

    posted a message on kgPanels Offical Thread
    Quote from kagaro
    setting it underneath the frame you want to click on (i believe you have a big empty spot in the middle to show through) would accomplish what you want since as you mouse over it shows the background area and as your mouse passes over teh click frame its higher so get the mouse event.


    Yes I think that will work the way I want. Now just need to get home from work to try it out :D

    If I can get that to work, I'll see if I can use a kgPanel OnLoad to create a clique-enabled proxy frame to take the place of a missing ZMobDB_Frame_player so clique actually works on the portrait.
    Posted in: General AddOns
  • 0

    posted a message on kgPanels Offical Thread
    Quote from Seerah
    I'm curious - since your kgpanel is basically just a border, why don't you put the panel below the frame you want to use click-casting on instead of above?


    Hmm, the more I think about it, the more I think it could work.

    There were a couple of quirks that I had issues with. The first is that the border texture does not fill the entire frame. It is about 212x212 in a 256x256 tga file. I originally tried to tie that with the OnEnter/OnLeave script, but the panel would light up too early as it would enter the transparent area around the art. I placed border textures over ZMobDB_Camera0 because that's what I usually do to hide any border differences.

    To try to solve this problem, rather than editing the textures to fill the 256x256 area, I tried to make a panel that was transparent but the same size that was on top of the ZMobDB_Camera0 and listened for mouse Enter/Leave events. If I placed the panel underneath ZMob, it didn't seem to light up. I'm guessing that ZMobDB player portrait handled all the mouse events. If I put it on top, it would light up, but ZMob wouldn't respond to mouse events.

    (Unfortunately, ZMob doesn't respond to clique as is because the ZMobDB_Frame_* frames are missing. Not sure what patch that happened, but I'm still stuck with a cliqueless portrait until that gets resolved if ever. The frame still responds in config mode where I can move and zoom and alter the camera, but this did not work when I had the kgpanel intercepting mouse events directly over it.)

    However, if I can place a proxy frame that handles the mouse events to be slightly larger than the ZMobDB_Camera0, and place it below that frame's strata/level, I should be able to make it appear that it is lighting up when mousing over the panel. Here is my new panel layering scheme.

    kgPlayerBGPanel
    kgPlayerHActionPanel - make it a few pixels larger than ZMobDB_Camera0 and listen to OnEnter and OnLeave mouse events
    ZMobDB_Camera0
    kgPlayerBorderPanel - Can still overlay ZMobDB_Camera0 since its not intercepting mouse events.
    kgPlayerHPanel - Highlight Border panel using class color
    kgPlayerHPanel2 - kgPlayerHActionPanel will cause this to show OnEnter and hide OnLeave

    I think this layering may give me the behavior I'm looking for. I'll give it a whirl and see how it comes out. Thanks for the suggestion.
    Posted in: General AddOns
  • 0

    posted a message on kgPanels Offical Thread
    I'm trying to setup a panel that has an OnEnter/OnLeave script that overlays a frame that I want to be able to use clique on.

    Here is my frame stack for my ZMobDB_Frame_player frame in order of framestrata and level.

    kgPlayerBGPanel - A panel that fills in the space between the health and mana bars
    ZMobDB_Frame_player - The frame that is registered with clique
    kgPlayerBorderPanel - A panel that has a modified STeam texture border
    kgPlayerHPanel - A panel that renders a class-colored highlight on the kgPlayerBorderPanel texture
    kgPlayerHPanel2 - A panel that has the same texture kgPlayerHPanel that when overlaid makes the class color brighter.
    kgPlayerHPanel3 - A transparent panel that is shaped to overlay the ZMob_Camera0 frame that intercepts mouse events and has a OnEnter and OnLeave script like the following.

    <>
    ---kgPlayerHPanel3---

    <OnEnter>
    local f = kgPanels:FetchFrame( "kgPlayerHPanel2" )
    if f ~= nil then
    f:Show()
    end

    <OnLeave>
    local f = kgPanels:FetchFrame( "kgPlayerHPanel2" )
    if f ~= nil then
    f:Hide()
    end
    <
    >

    Here's a link to the before and after screenshots of what I'm trying to accomplish. The frame is enlarged for better visualization.

    http://i35.tinypic.com/30m3f5e.jpg

    And with the highlight

    http://i38.tinypic.com/2upcwwn.jpg

    The only issue is that the kgpanel intercepts the mouse click and I would still like to use clique on the ZMobDB_Frame_player frame. I found this code in that is supposed to hook the frame into responding to clique.

    <>
    ClickCastFrames = ClickCastFrames or {};
    ClickCastFrames[ZMobDB_Frame_player] = true;
    <
    >

    (Actually, there is an issue with the latest ZMobDB where the ZMobDB_Frame_player is not actually there, at least the kgPanels frame finder cannot pick it up. Just ZMobDB_Camera0 and ZMobDB_Camera0_Avatar and they can not be registered with clique using ClickCastFrames.)

    The issue I believe is that "cliqueable" frames are created using the following template.

    CreateFrame("BUTTON", "NAME", UIParent, "SecureUnitButtonTemplate");

    Did a quick test by putting the code from http://www.wowwiki.com/API_RegisterUnitWatch in an OnLoad kgpanel script and it made a red square in the center that responded to clique. The "Myself" frame showed up in clique, and it responded to my clicks.

    <>
    ---kgCliqueTestPanel---

    <OnLoad>
    cfp = CreateFrame("BUTTON", "Myself", UIParent, "SecureUnitButtonTemplate");
    cfp:SetAttribute("unit", "player");
    cfp:SetWidth(50);
    cfp:SetHeight(50);
    cfp:SetPoint("CENTER");
    cfp:SetFrameStrata("HIGH");
    local tex = cfp:CreateTexture();
    tex:SetAllPoints( cfp );
    tex:SetTexture(1,0,0);
    RegisterUnitWatch(cfp);

    -- This is how you register the frame with clique
    ClickCastFrames = ClickCastFrames or {};
    ClickCastFrames[cfp] = true;
    <
    >

    I still don't understand all the caveats of the panel code above, but it appears to work with clique.

    So what I'm after is either

    1. Intercept just the mouse enter and leave events while sending the actual mouse clicks down to the frame below. I would test this with PitBull by overlaying the kgPlayerHPanel3 panel over PitBullUnitFrame1 as this works with clique and see if I can pass the mouse clicks down from kgPlayerHPanel3 down to PitBullUnitFrame1 that will end up in casting spells. I haven't come across anything that does this yet.

    2. Create a kgpanel that I can make "cliqueable", or use its OnLoad as a proxy to create a "cliqueable" panel and add OnEnter and OnLeave scripts to hide and show kgPlayerHPanel2. I think this is feasible, and it may get around the current ZMobDB problem where ZMobDB_Frame_player is not showing, hence my problem using clique on a ZMobDB frame.

    I know that this is a rather difficult problem and I'm working to try to figure out a way to implement what I want, but any nudges from someone with more experience than me in the right direction would be helpful.
    Posted in: General AddOns
  • 0

    posted a message on kgPanels Offical Thread
    Quote from Bajenfan
    Hi!

    I would like some help with getting my Pet bar to be attached to my action bar and then be woved up when im in combat since my action bar then have 2 rows instead of 1 ?



    This is how it looks now and I would like it to sit right on top of the action bar.



    And then when im in combat it should move up to be on top of that second bar.

    Any help would be greatful.

    -Strongbow-


    My suggestion would be to use a panel that changes anchor or offset of the petbar respective to the proper action bar. kgpanels has a mechanism to keybind the frame finder when its config window is open. Use that to find the names of the frames.

    1. Find name of the petbar frame and the first actionbar.
    2. Figure out how to anchor the petbar to the actionbar using a kgpanel script.

    http://www.wowwiki.com/API_Region_SetPoint

    In this case, you want to anchor the bottom of the petbar to the top of your actionbar.

    ---kgPetAnchorPanel---

    <OnLoad>
    ?PetActionBar?:SetPoint( "BOTTOM", ?ActionBar1?, "TOP", 0, 0 )

    Use the frame finder to find out what to replace for ?PetActionBar? and ?ActionBar1?. If you want this frame to be a border for your ?PetActionBar?, parent it to the frame in the panel options. It should then show and hide whenever the ?PetActionBar? does. If not, you can just have an empty texture and empty border and it will be a hidden frame that modifies your ?PetActionBar? (or add a self:Hide() in the <OnLoad> handler).

    If you use an addon for your barframes, add it as a dependency under the script dependency option.

    3. Listen to events that put you in and out of combat.

    From the sample script on the first page, gives you a method to determine whether or not your are in combat.

    <OnLoad>
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
    self:RegisterEvent("PLAYER_REGEN_ENABLED")

    <OnEvent>
    if event == "PLAYER_REGEN_ENABLED" then
    -- Out of Combat
    elseif event == "PLAYER_REGEN_DISABLED" then
    -- In Combat
    end

    This uses the player regen as a flag to determine whether you have entered combat, since when you enter combat, your regen is disabled.

    4. Determine how to move the PetActionBar when in or out of combat.

    Combine steps 2 and 3 to change the anchor of the PetActionBar to the right ActionBar.

    ---kgPetAnchorPanel---

    <OnLoad>
    self:RegisterEvent("PLAYER_REGEN_DISABLED")
    self:RegisterEvent("PLAYER_REGEN_ENABLED")
    ?PetActionBar?:SetPoint( "BOTTOM", ?ActionBar1?, "TOP", 0, 0 )

    <OnEvent>
    if event == "PLAYER_REGEN_ENABLED" then
    -- Out of Combat
    ?PetActionBar?:SetPoint( "BOTTOM", ?ActionBar1?, "TOP", 0, 0 )
    elseif event == "PLAYER_REGEN_DISABLED" then
    -- In Combat
    ?PetActionBar?:SetPoint( "BOTTOM", ?ActionBar2?, "TOP", 0, 0 )
    end

    Assuming that the frames for the actionbar 1 and 2 are separate, this should be enough to get close to the behavior you want. Play around with the SetPoint arguments to evaluate how it works. Another option is to simply parent it to UIParent, and use offsets to place it at the right spot.

    <OnEvent>
    if event == "PLAYER_REGEN_ENABLED" then
    -- Out of Combat
    ?PetActionBar?:SetPoint( "BOTTOM", UIParent, "BOTTOM", 0, 50 )
    elseif event == "PLAYER_REGEN_DISABLED" then
    -- In Combat
    ?PetActionBar?:SetPoint( "BOTTOM", UIParent, "BOTTOM", 0, 100 )
    end

    None of this is tested, so you may have to play around with it to get it to work the way that you want.

    Good luck!
    Posted in: General AddOns
  • To post a comment, please or register a new account.