• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

GetPlayerColorTexture

A small utility function to get the PlayerColor FilePath of a player, the function respects ally-enemy color mode and changed player colors. Might be of use in custom UI code. Has a Lua and jass version.
Was ported from the code section https://www.hiveworkshop.com/threads/getplayercolortexture.349480/
Lua:
--By Tasyen
---GetPlayerColorTexture
---@param player player
---@param enforcePlayerColor? boolean  (true) ignore enemy ally color mode
---@return string
function GetPlayerColorTexture(player, enforcePlayerColor)
    -- normal mode
    if GetAllyColorFilterState() == 0 or enforcePlayerColor then
        if GetHandleId(GetPlayerColor(player)) < 10 then
            return "ReplaceableTextures\\TeamColor\\TeamColor0"..GetHandleId(GetPlayerColor(player))
        else
            return "ReplaceableTextures\\TeamColor\\TeamColor"..GetHandleId(GetPlayerColor(player))
        end
    else
    -- enemy friend self mode
        if player == GetLocalPlayer() then
            return "ReplaceableTextures\\TeamColor\\TeamColor01"
        elseif player == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
            return "ReplaceableTextures\\TeamColor\\TeamColor24"
        elseif IsPlayerAlly(player, GetLocalPlayer()) then
            return "ReplaceableTextures\\TeamColor\\TeamColor02"
        elseif IsPlayerEnemy(player, GetLocalPlayer()) then
            return "ReplaceableTextures\\TeamColor\\TeamColor00"
        else
            return "ReplaceableTextures\\TeamColor\\TeamColor00"
        end
    end
end
JASS:
function GetPlayerColorTexture takes player p, boolean enforcePlayerColor returns string
    // normal mode
    if GetAllyColorFilterState() == 0 or enforcePlayerColor then
        if GetHandleId(GetPlayerColor(p)) < 10 then
            return "ReplaceableTextures\\TeamColor\\TeamColor0" + I2S(GetHandleId(GetPlayerColor(p)))
        else
            return "ReplaceableTextures\\TeamColor\\TeamColor" + I2S(GetHandleId(GetPlayerColor(p)))
        endif
    else
    // enemy friend self mode
        if p == GetLocalPlayer() then
            return "ReplaceableTextures\\TeamColor\\TeamColor01"
        elseif p == Player(PLAYER_NEUTRAL_AGGRESSIVE) then
            return "ReplaceableTextures\\TeamColor\\TeamColor24"
        elseif IsPlayerAlly(p, GetLocalPlayer()) then
            return "ReplaceableTextures\\TeamColor\\TeamColor02"
        elseif IsPlayerEnemy(p, GetLocalPlayer()) then
            return "ReplaceableTextures\\TeamColor\\TeamColor00"
        else
            return "ReplaceableTextures\\TeamColor\\TeamColor00"
        endif
    endif
endfunction
Tags: Player, Color, Custom UI
Contents

GetPlayerColorTexture jass (Binary)

GetPlayerColorTexture lua (Binary)

Reviews
Antares
Moved resource. Approved
Non-player slots 24,25,26,27 technically have an option to have custom colors and each have a separate texture file in the game files. Though they are all the same dark gray color.
Technically, this script only forgot to include other non-players besides "PLAYER_NEUTRAL_AGGRESSIVE" :peasant-thumbs-up:

PS: Someone might find this useful: "game always uses the 4th pixel from the top to determine color" https://www.hiveworkshop.com/threads/producer-update-24-team-colors.303529/post-3244061
 
Last edited:
Back
Top