HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Centering Text Function

08-17-2004, 12:58 AM#1
Dragunov
Hey guys,

I was wondering if anybody here knew what the funcion in JASS was that centers text? I'm not talking about spacebar, spacebar, spacebar... I'm talking about an actual centering function that will center at all resolutions.

Anybody know the function? Thanks for the help,

-Drag
08-17-2004, 03:10 AM#2
BDSM
I can't say I know of one, but the best thing would probably be to figure out how many characters can fit per line on the screen - if, depending on resolution, this varies it may prove more difficult. You might call this function CenterText, and it would add the proper number of spaces to the front and end of the text you want to show to make it centered.
08-17-2004, 02:13 PM#3
Dragunov
Actually, I've just realized that different resolutions only change the amount of detail on your screen. The camera itself does not move out like it does in Diablo II. Soooo, writing a function that measures how many characters are in the screen and compensates accordingly is possible. I'll get my team to work on it, I'll post it here when we've got it.

-Drag
08-19-2004, 01:17 PM#4
Cacodemon
Oh, just use function:

Code:
function Text takes player PlayerID, string Text, real Time, real HValue, real VValue returns nothing
 if ((PlayerID == GetLocalPlayer()) or (PlayerID == null)) then
  call DisplayTimedTextToPlayer(GetLocalPlayer(), HValue, VValue, Time, Text)
 endif
endfunction

HValue and VValue are reals from 0.0 to 1.0 - they define part of screen where your message will be displayed. 0.5 / 0.5 means center of the screen.

If you want to display text to all players, just use null instead of player handle.

example:

Code:
call Text(null, "Hello, World!", 5, 0.5, 0.5) // This will display centered text "Hello, World!" for all players, after 5 seconds message disappears.
call Text(Player(0), "Hello, World!", 5, 0.5, 0.5) // This will display centered text "Hello, World!" for Red Player, after 5 seconds message disappears.
08-19-2004, 01:20 PM#5
Vexorian
Quote:
Originally Posted by Cacodemon
Oh, just use function:

Code:
function Text takes player PlayerID, string Text, real Time, real HValue, real VValue returns nothing
 if ((PlayerID == GetLocalPlayer()) or (PlayerID == null)) then
  call DisplayTimedTextToPlayer(GetLocalPlayer(), HValue, VValue, Time, Text)
 endif
endfunction

HValue and VValue are reals from 0.0 to 1.0 - they define part of screen where your message will be displayed. 0.5 / 0.5 means center of the screen.

If you want to display text to all players, just use null instead of player handle.

example:

Code:
call Text(null, "Hello, World!", 5, 0.5, 0.5) // This will display centered text "Hello, World!" for all players, after 5 seconds message disappears.
call Text(Player(0), "Hello, World!", 5, 0.5, 0.5) // This will display centered text "Hello, World!" for Red Player, after 5 seconds message disappears.
was the new function really needed?
08-22-2004, 09:49 AM#6
jmoritz
Nope, and it's bugged too :P