• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Restore Inventory after hiding Default UI + whatbackground has vertex coloring?

Level 14
Joined
Feb 5, 2018
Messages
582
Hello,

I have played around with the custom UI. I just can't find the parentframe for the inventory, it's 6 backdrops and the 6 slots
which display the item. I first had BlzHideOriginFrames(true). Then I started to hide frames one by one, but after 60 lines
of just hiding UI there were still most of the default UI left :D

So I reverted back to BlzHideOriginFrames(true)

How can I restore the inventory? It's just easier to use the default inventory rather than coding a custom one.

And for the other thing I haven't been able to find a backdrop that lets me change vertex coloring for custom life/mana and xp bars.

Code:
globals
    // =====================================================
    // HERO RESOURCE UI
    // =====================================================

    framehandle HeroResourcePanel = null

    framehandle HeroHPBackground = null
    framehandle HeroHPFill = null
    framehandle HeroHPText = null

    framehandle HeroManaBackground = null
    framehandle HeroManaFill = null
    framehandle HeroManaText = null
    framehandle HeroXPBackground = null
    framehandle HeroXPFill = null
    framehandle HeroXPText = null

    timer HeroResourceTimer = null
endglobals


library HERORESOURCEUI initializer InitHeroResourceUI


globals
    // =====================================================
    // BAR SETTINGS
    // =====================================================

    private constant real HERO_BAR_X       = -0.12000
    private constant real HERO_BAR_Y       = 0.57000

    private constant real HERO_BAR_WIDTH   = 0.18000
    private constant real HERO_BAR_HEIGHT  = 0.01800

    private constant real HERO_BAR_SPACING = 0.00300

    private constant real HERO_XP_X      = 0.31500
    private constant real HERO_XP_Y      = 0.04150

    private constant real HERO_XP_WIDTH  = 0.16400
    private constant real HERO_XP_HEIGHT = 0.01000
endglobals

function GetHeroXPThreshold takes integer level returns integer

    if level <= 1 then
        return 0

    elseif level == 2 then
        return 200

    elseif level == 3 then
        return 500

    elseif level == 4 then
        return 900

    elseif level == 5 then
        return 1400

    elseif level == 6 then
        return 2000

    elseif level == 7 then
        return 2700

    elseif level == 8 then
        return 3500

    elseif level == 9 then
        return 4400

    elseif level == 10 then
        return 5400

    endif

    return 5400 + ((level - 10) * 1000)

endfunction

// =====================================================
// UPDATE HERO HP / MANA / XP
// =====================================================

private function UpdateHeroResourceUI takes nothing returns nothing
    local player p = GetLocalPlayer()
    local integer pid = GetPlayerId(p)
    local unit u = udg_PlayerHero[pid]

    local real hp
    local real maxHP
    local real hpPercent

    local real mana
    local real maxMana
    local real manaPercent

    local integer level
    local integer currentXP
    local integer prevXP
    local integer nextXP

    local integer xpIntoLevel
    local integer xpNeeded

    local real xpPercent

    if u == null then
        set u = null
        set p = null
        return
    endif


    // =====================================================
    // HP
    // =====================================================

    set hp = GetWidgetLife(u)
    set maxHP = I2R(BlzGetUnitMaxHP(u))

    if maxHP > 0.00 then
        set hpPercent = hp / maxHP
    else
        set hpPercent = 0.00
    endif

    if hpPercent < 0.00 then
        set hpPercent = 0.00
    elseif hpPercent > 1.00 then
        set hpPercent = 1.00
    endif

    call BlzFrameSetSize( /*
    / HeroHPFill, /
    / HERO_BAR_WIDTH * hpPercent, /
    */ HERO_BAR_HEIGHT)

    call BlzFrameSetText( /*
    / HeroHPText, /
    / "|cffffffff" + /
    / I2S(R2I(hp)) + /
    / " / " + /
    / I2S(R2I(maxHP)) + /
    */ "|r")


    // =====================================================
    // MANA
    // =====================================================

    set mana = GetUnitState(u, UNIT_STATE_MANA)
    set maxMana = GetUnitState(u, UNIT_STATE_MAX_MANA)

    if maxMana > 0.00 then
        set manaPercent = mana / maxMana
    else
        set manaPercent = 0.00
    endif

    if manaPercent < 0.00 then
        set manaPercent = 0.00
    elseif manaPercent > 1.00 then
        set manaPercent = 1.00
    endif

    call BlzFrameSetSize( /*
    / HeroManaFill, /
    / HERO_BAR_WIDTH * manaPercent, /
    */ HERO_BAR_HEIGHT)

    call BlzFrameSetText( /*
    / HeroManaText, /
    / "|cffffffff" + /
    / I2S(R2I(mana)) + /
    / " / " + /
    / I2S(R2I(maxMana)) + /
    */ "|r")

    // =====================================================
    // XP
    // =====================================================

    set level = GetHeroLevel(u)
    set currentXP = GetHeroXP(u)

    if level <= 1 then
    set prevXP = 0
    else
    set prevXP = GetHeroXPThreshold(level)
    endif

    set nextXP = GetHeroXPThreshold(level + 1)

    set xpIntoLevel = currentXP - prevXP
    set xpNeeded = nextXP - prevXP

    if xpNeeded > 0 then
    set xpPercent = I2R(xpIntoLevel) / I2R(xpNeeded)
    else
    set xpPercent = 1.00
    endif

    if xpPercent < 0.00 then
    set xpPercent = 0.00
    elseif xpPercent > 1.00 then
    set xpPercent = 1.00
    endif

    call BlzFrameSetSize( /*
    / HeroXPFill, /
    / HERO_XP_WIDTH * xpPercent, /
    */ HERO_XP_HEIGHT)

    call BlzFrameSetText( /*
    / HeroXPText, /
    / "|cffffffffLv " + /
    / I2S(level) + /
    / "  " + /
    / I2S(xpIntoLevel) + /
    / " / " + /
    / I2S(xpNeeded) + /
    */ "|r")

    set u = null
    set p = null
endfunction


// =====================================================
// CREATE HERO RESOURCE UI
// =====================================================

private function InitHeroResourceUI takes nothing returns nothing
    local framehandle console

    set console = BlzGetFrameByName("ConsoleUIBackdrop", 0)


    // =====================================================
    // MAIN PANEL
    // =====================================================

    set HeroResourcePanel = BlzCreateFrameByType( /*
    / "FRAME", /
    / "HeroResourcePanel", /
    / console, /
    / "", /
    */ 0)


    // =====================================================
    // HP BACKGROUND
    // =====================================================

    set HeroHPBackground = BlzCreateFrameByType( /*
    / "BACKDROP", /
    / "HeroHPBackground", /
    / HeroResourcePanel, /
    / "", /
    */ 0)

    call BlzFrameSetAbsPoint( /*
    / HeroHPBackground, /
    / FRAMEPOINT_TOPLEFT, /
    / HERO_BAR_X, /
    */ HERO_BAR_Y)

    call BlzFrameSetSize( /*
    / HeroHPBackground, /
    / HERO_BAR_WIDTH, /
    */ HERO_BAR_HEIGHT)

    call BlzFrameSetTexture( /*
    / HeroHPBackground, /
    / "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", /
    / 0, /
    */ true)

    call BlzFrameSetVertexColor( /*
    / HeroHPBackground, /
    */ BlzConvertColor(255, 15, 15, 15))


    // =====================================================
    // HP FILL
    // =====================================================

    set HeroHPFill = BlzCreateFrameByType( /*
    / "BACKDROP", /
    / "HeroHPFill", /
    / HeroHPBackground, /
    / "", /
    */ 0)

    call BlzFrameSetPoint( /*
    / HeroHPFill, /
    / FRAMEPOINT_LEFT, /
    / HeroHPBackground, /
    / FRAMEPOINT_LEFT, /
    / 0.00000, /
    */ 0.00000)

    call BlzFrameSetSize( /*
    / HeroHPFill, /
    / HERO_BAR_WIDTH, /
    */ HERO_BAR_HEIGHT)

    call BlzFrameSetTexture( /*
    / HeroHPFill, /
    / "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", /
    / 0, /
    */ true)

    call BlzFrameSetVertexColor( /*
    / HeroHPFill, /
    */ BlzConvertColor(255, 40, 170, 55))


    // =====================================================
    // HP TEXT
    // =====================================================

    set HeroHPText = BlzCreateFrameByType( /*
    / "TEXT", /
    / "HeroHPText", /
    / HeroHPBackground, /
    / "", /
    */ 0)

    call BlzFrameSetAllPoints(HeroHPText, HeroHPBackground)

    call BlzFrameSetText(HeroHPText, "|cffffffff0 / 0|r")

    call BlzFrameSetTextAlignment( /*
    / HeroHPText, /
    / TEXT_JUSTIFY_MIDDLE, /
    */ TEXT_JUSTIFY_CENTER)

    call BlzFrameSetEnable(HeroHPText, false)


    // =====================================================
    // MANA BACKGROUND
    // =====================================================

    set HeroManaBackground = BlzCreateFrameByType( /*
    / "BACKDROP", /
    / "HeroManaBackground", /
    / HeroResourcePanel, /
    / "", /
    */ 0)

    call BlzFrameSetAbsPoint( /*
    / HeroManaBackground, /
    / FRAMEPOINT_TOPLEFT, /
    / HERO_BAR_X, /
    */ HERO_BAR_Y - HERO_BAR_HEIGHT - HERO_BAR_SPACING)

    call BlzFrameSetSize( /*
    / HeroManaBackground, /
    / HERO_BAR_WIDTH, /
    */ HERO_BAR_HEIGHT)

    call BlzFrameSetTexture( /*
    / HeroManaBackground, /
    / "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", /
    / 0, /
    */ true)

    call BlzFrameSetVertexColor( /*
    / HeroManaBackground, /
    */ BlzConvertColor(255, 15, 15, 15))


    // =====================================================
    // MANA FILL
    // =====================================================

    set HeroManaFill = BlzCreateFrameByType( /*
    / "BACKDROP", /
    / "HeroManaFill", /
    / HeroManaBackground, /
    / "", /
    */ 0)

    call BlzFrameSetPoint( /*
    / HeroManaFill, /
    / FRAMEPOINT_LEFT, /
    / HeroManaBackground, /
    / FRAMEPOINT_LEFT, /
    / 0.00000, /
    */ 0.00000)

    call BlzFrameSetSize( /*
    / HeroManaFill, /
    / HERO_BAR_WIDTH, /
    */ HERO_BAR_HEIGHT)

    call BlzFrameSetTexture( /*
    / HeroManaFill, /
    / "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", /
    / 0, /
    */ true)

    call BlzFrameSetVertexColor( /*
    / HeroManaFill, /
    */ BlzConvertColor(255, 35, 90, 210))


    // =====================================================
    // MANA TEXT
    // =====================================================

    set HeroManaText = BlzCreateFrameByType( /*
    / "TEXT", /
    / "HeroManaText", /
    / HeroManaBackground, /
    / "", /
    */ 0)

    call BlzFrameSetAllPoints(HeroManaText, HeroManaBackground)

    call BlzFrameSetText(HeroManaText, "|cffffffff0 / 0|r")

    call BlzFrameSetTextAlignment( /*
    / HeroManaText, /
    / TEXT_JUSTIFY_MIDDLE, /
    */ TEXT_JUSTIFY_CENTER)

    call BlzFrameSetEnable(HeroManaText, false)

    // =====================================================
    // XP BAR
    // =====================================================

    set HeroXPBackground = BlzCreateFrameByType( /*
    / "BACKDROP", /
    / "HeroXPBackground", /
    / HeroResourcePanel, /
    / "", /
    */ 0)

    call BlzFrameSetAbsPoint( /*
    / HeroXPBackground, /
    / FRAMEPOINT_BOTTOMLEFT, /
    / HERO_XP_X, /
    */ HERO_XP_Y)

    call BlzFrameSetSize( /*
    / HeroXPBackground, /
    / HERO_XP_WIDTH, /
    */ HERO_XP_HEIGHT)

    call BlzFrameSetTexture( /*
    / HeroXPBackground, /
    / "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", /
    / 0, /
    */ true)

    call BlzFrameSetVertexColor( /*
    / HeroXPBackground, /
    */ BlzConvertColor(255,15,15,15))

    // =====================================================
    // XP FILL
    // =====================================================
    set HeroXPFill = BlzCreateFrameByType( /*
    / "BACKDROP", /
    / "HeroXPFill", /
    / HeroXPBackground, /
    / "", /
    */ 0)

    call BlzFrameSetPoint( /*
    / HeroXPFill, /
    / FRAMEPOINT_LEFT, /
    / HeroXPBackground, /
    / FRAMEPOINT_LEFT, /
    / 0.0, /
    */ 0.0)

    call BlzFrameSetSize( /*
    / HeroXPFill, /
    / HERO_XP_WIDTH, /
    */ HERO_XP_HEIGHT)

    call BlzFrameSetTexture( /*
    / HeroXPFill, /
    / "UI\\Widgets\\ToolTips\\Human\\human-tooltip-background.blp", /
    / 0, /
    */ true)

    call BlzFrameSetVertexColor( /*
    / HeroXPFill, /
    */ BlzConvertColor(255,210,180,35))

    // =====================================================
    // XP TEXT
    // =====================================================

    set HeroXPText = BlzCreateFrameByType( /*
    / "TEXT", /
    / "HeroXPText", /
    / HeroXPBackground, /
    / "", /
    */ 0)

    call BlzFrameSetAllPoints(HeroXPText, HeroXPBackground)

    call BlzFrameSetText(HeroXPText,"|cffffffff0 / 0|r")

    call BlzFrameSetTextAlignment( /*
    / HeroXPText, /
    / TEXT_JUSTIFY_MIDDLE, /
    */ TEXT_JUSTIFY_CENTER)

    call BlzFrameSetEnable(HeroXPText,false)

    // =====================================================
    // UPDATE TIMER
    // =====================================================

    set HeroResourceTimer = CreateTimer()

    call TimerStart( /*
    / HeroResourceTimer, /
    / 0.05, /
    / true, /
    */ function UpdateHeroResourceUI)


    set console = null
endfunction


endlibrary
 
Back
Top