45 |
45 |
46 InputStr: TChatLine; |
46 InputStr: TChatLine; |
47 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
47 InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char |
48 |
48 |
49 const colors: array[#1..#4] of Longword = ( |
49 const colors: array[#1..#4] of Longword = ( |
50 $FFFFFF, // chat message |
50 {$IFDEF ENDIAN_LITTLE} |
51 $FF00FF, // action message |
51 // ABGR |
52 $90FF90, // join/leave message |
52 $FFFFFFFF, // chat message [White] |
53 $A0FFFF // team message |
53 $FFFF00FF, // action message [Purple] |
|
54 $FF90FF90, // join/leave message [Lime] |
|
55 $FFA0FFFF // team message [Light Yellow] |
|
56 {$ELSE} |
|
57 // RGBA |
|
58 $FFFFFFFF, // chat message [White] |
|
59 $FF00FFFF, // action message [Purple] |
|
60 $90FF90FF, // join/leave message [Lime] |
|
61 $FFFFA0FF // team message [Light Yellow] |
|
62 {$ENDIF} |
54 ); |
63 ); |
55 |
64 |
56 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); |
65 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); |
57 var strSurface, resSurface: PSDL_Surface; |
66 var strSurface, resSurface: PSDL_Surface; |
58 w, h: LongInt; |
67 w, h: LongInt; |
64 |
73 |
65 cl.s:= str; |
74 cl.s:= str; |
66 |
75 |
67 if isInput then |
76 if isInput then |
68 begin |
77 begin |
69 color:= $FFFF00; |
78 color:= |
|
79 {$IFDEF ENDIAN_LITTLE} |
|
80 $FFFFFF00; // [Yellow abgr] |
|
81 {$ELSE} |
|
82 $00FFFFFF; // [Yellow rgba] |
|
83 {$ENDIF} |
70 str:= UserNick + '> ' + str + '_' |
84 str:= UserNick + '> ' + str + '_' |
71 end |
85 end |
72 else begin |
86 else begin |
73 color:= colors[str[1]]; |
87 color:= colors[str[1]]; |
74 delete(str, 1, 1) |
88 delete(str, 1, 1) |
75 end; |
89 end; |
76 |
90 |
77 |
91 |
78 TTF_SizeUTF8(Fontz[fnt16].Handle, Str2PChar(str), w, h); |
92 TTF_SizeUTF8(Fontz[fnt16].Handle, Str2PChar(str), w, h); |
79 |
93 |
80 resSurface:= SDL_CreateRGBSurface(0, |
94 resSurface:= SDL_CreateRGBSurface(0, toPowerOf2(w), toPowerOf2(h), 32, RMask, GMask, BMask, AMask); |
81 toPowerOf2(w), |
|
82 toPowerOf2(h), |
|
83 32, |
|
84 RMask, GMask, BMask, AMask); |
|
85 |
95 |
86 strSurface:= TTF_RenderUTF8_Solid(Fontz[fnt16].Handle, Str2PChar(str), color); |
96 strSurface:= TTF_RenderUTF8_Solid(Fontz[fnt16].Handle, Str2PChar(str), color); |
87 //strSurface:= doSurfaceConversion(strSurface); |
|
88 cl.Width:= w + 4; |
97 cl.Width:= w + 4; |
89 SDL_UpperBlit(strSurface, nil, resSurface, nil); |
98 SDL_UpperBlit(strSurface, nil, resSurface, nil); |
90 SDL_FreeSurface(strSurface); |
99 SDL_FreeSurface(strSurface); |
91 |
100 |
92 cl.Time:= RealTicks + 12500; |
101 cl.Time:= RealTicks + 12500; |