44 visibleCount: Longword = 0; |
44 visibleCount: Longword = 0; |
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 = ( |
|
50 $FFFFFF, // chat message |
|
51 $FF00FF, // action message |
|
52 $00B000, // join/leave message |
|
53 $AFFFAF // team message |
|
54 ); |
|
55 |
49 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); |
56 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); |
50 var strSurface, resSurface: PSDL_Surface; |
57 var strSurface, resSurface: PSDL_Surface; |
51 w, h: LongInt; |
58 w, h: LongInt; |
|
59 color: Longword; |
52 begin |
60 begin |
53 if cl.Tex <> nil then |
61 if cl.Tex <> nil then |
54 FreeTexture(cl.Tex); |
62 FreeTexture(cl.Tex); |
55 |
63 |
|
64 |
56 cl.s:= str; |
65 cl.s:= str; |
57 |
66 |
58 if isInput then str:= UserNick + '> ' + str + '_'; |
67 if isInput then |
|
68 begin |
|
69 color:= $00FFFF; |
|
70 str:= UserNick + '> ' + str + '_' |
|
71 end |
|
72 else begin |
|
73 color:= colors[str[1]]; |
|
74 delete(str, 1, 1) |
|
75 end; |
|
76 |
59 |
77 |
60 TTF_SizeUTF8(Fontz[fnt16].Handle, Str2PChar(str), w, h); |
78 TTF_SizeUTF8(Fontz[fnt16].Handle, Str2PChar(str), w, h); |
61 |
79 |
62 resSurface:= SDL_CreateRGBSurface(0, |
80 resSurface:= SDL_CreateRGBSurface(0, |
63 toPowerOf2(w), |
81 toPowerOf2(w), |
64 toPowerOf2(h), |
82 toPowerOf2(h), |
65 32, |
83 32, |
66 RMask, GMask, BMask, AMask); |
84 RMask, GMask, BMask, AMask); |
67 |
85 |
68 strSurface:= TTF_RenderUTF8_Solid(Fontz[fnt16].Handle, Str2PChar(str), $FFFFFF); |
86 strSurface:= TTF_RenderUTF8_Solid(Fontz[fnt16].Handle, Str2PChar(str), color); |
69 cl.Width:= w + 4; |
87 cl.Width:= w + 4; |
70 SDL_UpperBlit(strSurface, nil, resSurface, nil); |
88 SDL_UpperBlit(strSurface, nil, resSurface, nil); |
71 SDL_FreeSurface(strSurface); |
89 SDL_FreeSurface(strSurface); |
72 |
90 |
73 cl.Time:= RealTicks + 12500; |
91 cl.Time:= RealTicks + 12500; |