hedgewars/uChat.pas
changeset 2664 949c189ba568
parent 2630 079ef82eac75
child 2677 83ad68ceef72
equal deleted inserted replaced
2663:d53918cd22bb 2664:949c189ba568
    46 	visibleCount: Longword = 0;
    46 	visibleCount: Longword = 0;
    47 
    47 
    48 	InputStr: TChatLine;
    48 	InputStr: TChatLine;
    49 	InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char
    49 	InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char
    50 
    50 
    51 const colors: array[#1..#4] of Longword = (
    51 const colors: array[#1..#4] of TSDL_Color = (
    52 {$IFDEF ENDIAN_LITTLE}
    52 	(r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White]
    53 // ABGR
    53 	(r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple]
    54 	$FFFFFFFF, // chat message [White]
    54 	(r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime]
    55 	$FFFF00FF, // action message [Purple]
    55 	(r:$FF; g:$FF; b:$A0; unused:$FF)  // team message [Light Yellow]
    56 	$FF90FF90, // join/leave message [Lime]
       
    57 	$FFA0FFFF  // team message [Light Yellow]
       
    58 {$ELSE}
       
    59 // RGBA
       
    60 	$FFFFFFFF, // chat message [White]
       
    61 	$FF00FFFF, // action message [Purple]
       
    62 	$90FF90FF, // join/leave message [Lime]
       
    63 	$FFFFA0FF  // team message [Light Yellow]
       
    64 {$ENDIF}
       
    65 	);
    56 	);
    66 
    57 
    67 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
    58 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
    68 var strSurface, resSurface: PSDL_Surface;
    59 var strSurface, resSurface: PSDL_Surface;
    69 	w, h: LongInt;
    60 	w, h: LongInt;
    70 	color: Longword;
    61 	color: TSDL_Color;
    71 begin
    62 begin
    72 if cl.Tex <> nil then
    63 if cl.Tex <> nil then
    73 	FreeTexture(cl.Tex);
    64 	FreeTexture(cl.Tex);
    74 
    65 
    75 
    66 
    76 cl.s:= str;
    67 cl.s:= str;
    77 
    68 
    78 if isInput then
    69 if isInput then
    79 	begin
    70 begin
    80 	color:=
    71 	// [Light Blue]
    81 {$IFDEF ENDIAN_LITTLE}	
    72 	color.r:= $00;
    82 	$FFFFFF00; // [Yellow abgr]
    73 	color.g:= $FF;
    83 {$ELSE}
    74 	color.b:= $FF;
    84 	$00FFFFFF; // [Yellow rgba]
    75 	color.unused:= $FF;
    85 {$ENDIF}	
       
    86 	str:= UserNick + '> ' + str + '_'
    76 	str:= UserNick + '> ' + str + '_'
    87 	end
    77 end
    88 	else begin
    78 else
       
    79 begin
    89 	color:= colors[str[1]];
    80 	color:= colors[str[1]];
    90 	delete(str, 1, 1)
    81 	delete(str, 1, 1)
    91 	end;
    82 end;
    92 
    83 
    93 
    84 
    94 TTF_SizeUTF8(Fontz[fnt16].Handle, Str2PChar(str), w, h);
    85 TTF_SizeUTF8(Fontz[fnt16].Handle, Str2PChar(str), w, h);
    95 
    86 
    96 resSurface:= SDL_CreateRGBSurface(0, toPowerOf2(w), toPowerOf2(h), 32, RMask, GMask, BMask, AMask);
    87 resSurface:= SDL_CreateRGBSurface(0, toPowerOf2(w), toPowerOf2(h), 32, RMask, GMask, BMask, AMask);