WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   nUI: Developer Chat (https://www.wowinterface.com/forums/forumdisplay.php?f=96)
-   -   Target level on HUD (https://www.wowinterface.com/forums/showthread.php?t=21057)

wreck 03-12-09 10:50 AM

Target level on HUD
 
Could you add the target's level to the HUD? I know this information is in the Unit Frame, but it would be really handy to have it right up there next to the target name since that is where I get most of the information when looking at a new target.

Smirge 03-16-09 03:03 PM

Quote:

Originally Posted by wreck (Post 119927)
Could you add the target's level to the HUD? I know this information is in the Unit Frame, but it would be really handy to have it right up there next to the target name since that is where I get most of the information when looking at a new target.

actually i second that :) would be very nice to have most info in the HUD

Petrah 03-17-09 04:46 PM

Would it be possible to add this as an optional plugin for nUI instead of adding it to the core of nUI?

spiel2001 03-17-09 05:26 PM

It could be done that way by twiddling the HUD skins in the same way that the aura buttons plugin twiddles the unit frame skins.

wreck 03-18-09 11:07 AM

Could you point me to where the target name/class information is rendered for the HUD? I could look at making a plugin that would do this.

spiel2001 03-18-09 12:10 PM

Quote:

Originally Posted by wreck (Post 120714)
Could you point me to where the target name/class information is rendered for the HUD? I could look at making a plugin that would do this.

Well... to see how a level element is created in a unit frame look for the key word ["Level"] in the file [ Interface > AddOns > nUI > Layouts > Default > UnitPanels > Solo > nUI_UnitSkin_SoloPlayer.lua ]

To see how to modify existing default layouts from a mod, check out http://www.wowinterface.com/download...raButtons.html which modifies the existing unit frame skins for the player, target, pet and vehicle to change their aura displays from bars to buttons. You will, of course, have to replace the unit frame skin references with HUD skin references.

Then all you have to do is spin through the HUD element skins you want to add the ["Level"] element to in in the same way.

wreck 03-20-09 11:47 AM

Ok, I made the modification to the HUD lua, just to understand how to do it. Next I need to figure out how to do the same thing in a Mod. Overriding the original HUD display seems the way to go.

Still learning lua, and I haven't had much time this week to play with it. I need to figure out if it is possible to simply add the element to the existing skin features, or if it will be necessary to override the entire skin.

spiel2001 03-20-09 12:04 PM

Quote:

Originally Posted by wreck (Post 121030)
Ok, I made the modification to the HUD lua, just to understand how to do it. Next I need to figure out how to do the same thing in a Mod. Overriding the original HUD display seems the way to go.

Still learning lua, and I haven't had much time this week to play with it. I need to figure out if it is possible to simply add the element to the existing skin features, or if it will be necessary to override the entire skin.

The easy way is to just add it to the existing skins. That way if I change something else about the skin, your mod won't break.

Look at the aura buttons mod... it will show you how to do it.

wreck 03-20-09 12:18 PM

Quote:

Originally Posted by spiel2001 (Post 121034)
The easy way is to just add it to the existing skins. That way if I change something else about the skin, your mod won't break.

Look at the aura buttons mod... it will show you how to do it.

Yea, but the aura buttons mod replace the existing aura scheme. Very different from adding an element to an existing skin. That's the trick I'm trying to figure out.

spiel2001 03-20-09 12:55 PM

Quote:

Originally Posted by wreck (Post 121035)
Yea, but the aura buttons mod replace the existing aura scheme. Very different from adding an element to an existing skin. That's the trick I'm trying to figure out.

Not really...

Code:

local myLevelBlock =
{
    anchor =
    {
    -- definitions
    },

    options =
    {
    -- definitions
    },
};

if nUI_UnitSkins[skinName] then
    nUI_UnitSkins[skinName].elements["Level"] = myLevelBlock;
end


wreck 03-21-09 11:35 PM

Ok, still not working. First I tried the following, basicallly filling in with details that I found.
Code:

local myLevelBlock =
{
        anchor =
        {
            anchor_pt  = "TOPLEFT",
            relative_to = "$parent_Power",
            xOfs        = 80,
            yOfs        = 0,
        },               
        options =
        {
            enabled = true,
            size    = 35,
            inset  = 0,
            strata  = nil,
            level  = 2,
           
            label =
            {
                enabled    = true,
                fontsize    = 16,
                justifyH    = "RIGHT",
                justifyV    = "MIDDLE",
                anchor_pt  = "RIGHT",
                xOfs        = 0,
                yOfs        = 1,                                       
                color      = { r = 0, g = 0.83, b = 0, a = 1 },
            },
        },
};
if nUI_UnitSkins[skinName] then
        nUI_UnitSkins[skinName].elements["Level"] = myLevelBlock;
end

I also tried the following to see if we need to hook into an event. Still no joy.

Code:

local myLevelBlock =
{
        anchor =
        {
            anchor_pt  = "TOPLEFT",
            relative_to = "$parent_Power",
            xOfs        = 80,
            yOfs        = 0,
        },               
        options =
        {
            enabled = true,
            size    = 35,
            inset  = 0,
            strata  = nil,
            level  = 2,
           
            label =
            {
                enabled    = true,
                fontsize    = 16,
                justifyH    = "RIGHT",
                justifyV    = "MIDDLE",
                anchor_pt  = "RIGHT",
                xOfs        = 0,
                yOfs        = 1,                                       
                color      = { r = 0, g = 0.83, b = 0, a = 1 },
            },
        },
};

local frame = CreateFrame( "Frame", "nUI_HUDLevel", UIParent );

local function onEvent()
      if nUI_UnitSkins[skinName] then
        nUI_UnitSkins[skinName].elements["Level"] = myLevelBlock;
      end
end

frame:SetScript( "OnEvent", onEvent );
frame:RegisterEvent( "VARIABLES_LOADED" );

If I take the Level Block and add it directly to the Skin code in nUI it works just the way I want it to. Just can't get the add on to do the any thing.

spiel2001 03-21-09 11:52 PM

Okay.. first of all.. it should be hooked into an event and it should be executed on the "ADDON_LOADED" event so that we're sure it does not try to update nUI's default layout tables until after we know that have been loaded and initialized and before any user customization is applied which occurs in the "VARIABLES_LOADED" event.

Second, and this may sound silly... but did you ever give "skinName" a value?

Code:

local skins =
{
    [1] = "PlayerTarget",
    [2] = "HealthPower",
};

for i in pairs( skins ) do
    local skinName = skins[i];

    if nUI_UnitSkins[skinName] then
        nUI_UnitSkins[skinName].elements["Level"] = myLevelBlock;
    end
end


wreck 03-23-09 10:55 AM

Still no joy. It seems to me that matching the nUI_UnitSkin[] by the name "PlayerTarget" is simply wrong. The skin names are completely different in the nUI/Main/constants.lua file. I tried making them match as per nUI_Aurabuttons code, but still got no matches. I put in some logging and this seems to be the essential problem. Nothing I tried matched a skin name, so I never see it add the Level block.

For me it is no longer worth the effort. For my own use it is much much simpler to add the Level block directly to the nUI code. So I guess I'll do that for my wife and I for now and not share :(

spiel2001 03-23-09 11:21 AM

Post what you have so far at an attachment and I'll fix it for you.

wreck 03-23-09 05:23 PM

1 Attachment(s)
Ok, I made an attachment. Have a look and tell me what I'm missing.

The version I'm sending hasn't been tested. I tried several things and still got nothing to work, so this is kind of where I said give me my java compiler.:p
--
Stev

spiel2001 03-23-09 06:18 PM

1 Attachment(s)
Wow... you were REALLY close... this worked for me, hopefully it does for you as well.

wreck 03-23-09 08:55 PM

1 Attachment(s)
Yep that worked. So I was on the right track. Just had to match against the right part of the enumerated list, eh?

For those interested, the attachment to this message will work if you want to try it out. Make sure you enable the addon after unzipping to your Addons folder.

spiel2001 03-23-09 09:25 PM

I might suggest two things...

1) Post this in the nUI Customization forum for those who look in there
2) Consider uploading it to http://www.wowinterface.com/downloads/cat133.html

Glad it's working :D -- Like I said, you were REALLY close.

Good job!

wreck 03-24-09 11:08 AM

It'll have to wait until I have time to add a screen shot preview as it appears they expect one for uploads here.


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

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