• 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!

[JASS] Dialog colors?

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
I've been having some difficulty with my dialog color(s) via GUI. I've decided to go about it a different way. I have this code:
Code:
function SetPlayerPrefix takes unit hero returns nothing
    local string txt
    local player player_owner = GetOwningPlayer(hero)
    local integer player_owner_id = GetPlayerId(player_owner)
    set txt = udg_PlayerName[player_owner_id] + " (" + GetUnitName(hero) + ")"
    call SetPlayerName(player_owner, txt)
    set txt = null
    set player_owner = null
endfunction

function StorePlayerNames takes nothing returns nothing
    local integer index = 0
    local player player_check
    loop
        exitwhen (index > 11)
        set player_check = Player(index)
        set udg_PlayerName[index] = GetPlayerName(player_check)
        set player_check = null
        set index = index + 1
    endloop
endfunction

Now what i was wondering is, is it possible to get dialog colors incorporated with this code? And if so , could you tell me how to call the function via
  • call custom script: ???
If not. Could anyone tell me how to set this in JASS, And then call forth the function in gui in times of need?
EDIT : This code is for setting hero pretext for selected player hero's.
 
Yes. Player colors. For instance:
Code:
function Trig_Forbidden_Zone_Actions takes nothing returns nothing
    call DisplayTextToForce( GetPlayersAll(), ( GetPlayerName(GetTriggerPlayer()) + " has entered the forbidden!" ) )
endfunction


function InitTrig_Forbidden_Zone takes nothing returns nothing
    set gg_trg_Forbidden_Zone = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Forbidden_Zone, null )
    call TriggerAddAction( gg_trg_Forbidden_Zone, function Trig_Forbidden_Zone_Actions )
endfunction

But instead of display to all players, i want the name of the player, as well as his.her corresponding player color displyed as well. Since i already have the custom Jass Script from the pretext. I was wondering if there is anyway to incorporate diaglogue colors.
 
|cffRRGGBB text |r is the format for colors in wc3.
Each of the capitalized letters is an hexadecimel value which means that it ranges between 0 and F (0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F).
RR is red, GG is green, and BB is blue.

If for example you want a white "Hello" message, you'll set a string/whatever to "|cffffffffHello|r".
 
Yes I'm aware of that. But for these you have to set player colors as a variable. I already have the players stored through JASS (refer to top). I was wondering if there is a way to incorporate those JASS triggers so that i could also include preset player colors. Its hard to input a color if every player is able to enter a certain area. I need their respective colors displayed when they trigger this event.
 
Yes, something like that. But remember arrays start from 0, so if you want to be really efficient, do player number - 1. :P
 
How would i call forth the trigger array?
  • Player - player number of (triggering player)
Something like that?

Declare a string array called, let's say, player_colors.

Then set each index to the corresponding color, for example

JASS:
player_colors[0] = "|cffff0000" // red player
player_colors[1] = "|cff0000ff" // blue player
// etc

And then just use the slot you want, for example
  • someTextFunction: player_colors[number of (Triggering Player)] + "Hello|r"
And I recon that if your whole text should be colored you don't even need to end the color with |r.
 
JASS:
function PlayerColouredText takes player p, string txt returns string
    local playercolor pc = GetPlayerColor(p)
    if pc == PLAYER_COLOR_RED then
        set txt = "|cffFF0202"+txt+"|r"
    elseif pc == PLAYER_COLOR_BLUE then
        set txt = "|cff0041FF"+txt+"|r"
    elseif pc == PLAYER_COLOR_CYAN then
        set txt = "|Cff1BE5B8"+txt+"|r"
    elseif pc == PLAYER_COLOR_PURPLE then
        set txt = "|CFF530080"+txt+"|r"
    elseif pc == PLAYER_COLOR_YELLOW then
        set txt = "|CFFFFFC00"+txt+"|r"
    elseif pc == PLAYER_COLOR_ORANGE then
        set txt = "|CFFFE890D"+txt+"|r"
    elseif pc == PLAYER_COLOR_GREEN then
        set txt = "|CFF1FBF00"+txt+"|r"
    elseif pc == PLAYER_COLOR_PINK then
        set txt = "|CFFE45AAF"+txt+"|r"
    elseif pc == PLAYER_COLOR_LIGHT_GRAY then
        set txt = "|CFF949596"+txt+"|r"
    elseif pc == PLAYER_COLOR_LIGHT_BLUE then
        set txt = "|CFF7DBEF1"+txt+"|r"
    elseif pc == PLAYER_COLOR_AQUA then
        set txt = "|CFF0F6145"+txt+"|r"
    elseif pc == PLAYER_COLOR_BROWN then
        set txt = "|CFF4D2903"+txt+"|r"
    else  // A safty function
        set txt = "|CFFFFFFFF"+txt+"|r"
    endif
    set pc = null
    return txt
endfunction
Got it from here, and altered it a little... Credits to PurgeAndFire.

Add that code above the other two functions.
Then change this function:
JASS:
function SetPlayerPrefix takes unit hero returns nothing
    local string txt
    local player player_owner = GetOwningPlayer(hero)
    local integer player_owner_id = GetPlayerId(player_owner)
    set txt = udg_PlayerName[player_owner_id] + " (" + GetUnitName(hero) + ")"
    set txt = PlayerColouredText(player_owner, txt)
    call SetPlayerName(player_owner, txt)
    set txt = null
    set player_owner = null
endfunction

Just a side note.... Please use <JASS> tags instead of <CODE> tags when posting, it's far easier to read. :thumbs_up:
 
Status
Not open for further replies.
Back
Top