hedgewars/uChat.pas
changeset 947 4e0c3ad89483
parent 946 42c5cc87cbd1
child 948 5d49a92c240a
equal deleted inserted replaced
946:42c5cc87cbd1 947:4e0c3ad89483
    23 procedure AddChatString(s: shortstring);
    23 procedure AddChatString(s: shortstring);
    24 procedure DrawChat;
    24 procedure DrawChat;
    25 procedure KeyPressChat(Key: Longword);
    25 procedure KeyPressChat(Key: Longword);
    26 
    26 
    27 implementation
    27 implementation
    28 uses uMisc, uStore, uConsts, SDLh;
    28 uses uMisc, uStore, uConsts, SDLh, uConsole;
    29 
    29 
    30 const MaxStrIndex = 7;
    30 const MaxStrIndex = 7;
    31 
    31 
    32 type TChatLine = record
    32 type TChatLine = record
    33 		s: shortstring;
    33 		s: shortstring;
    67 strSurface:= TTF_RenderUTF8_Solid(Fontz[fnt16].Handle, Str2PChar(str), $FFFFFF);
    67 strSurface:= TTF_RenderUTF8_Solid(Fontz[fnt16].Handle, Str2PChar(str), $FFFFFF);
    68 SDL_UpperBlit(strSurface, nil, resSurface, nil);
    68 SDL_UpperBlit(strSurface, nil, resSurface, nil);
    69 
    69 
    70 SDL_FreeSurface(strSurface);
    70 SDL_FreeSurface(strSurface);
    71 
    71 
    72 
    72 cl.s:= str;
    73 cl.Time:= RealTicks + 7500;
    73 cl.Time:= RealTicks + 7500;
    74 cl.Tex:= Surface2Tex(resSurface);
    74 cl.Tex:= Surface2Tex(resSurface);
    75 SDL_FreeSurface(resSurface)
    75 SDL_FreeSurface(resSurface)
    76 end;
    76 end;
    77 
    77 
    98 	if i = 0 then i:= MaxStrIndex else dec(i);
    98 	if i = 0 then i:= MaxStrIndex else dec(i);
    99 	inc(cnt);
    99 	inc(cnt);
   100 	inc(t)
   100 	inc(t)
   101 	end;
   101 	end;
   102 
   102 
   103 visibleCount:= cnt
   103 visibleCount:= cnt;
       
   104 
       
   105 if (GameState = gsChat)
       
   106 	and (InputStr.Tex <> nil) then
       
   107 	DrawTexture(11, visibleCount * 16 + 10 + cConsoleYAdd, InputStr.Tex);
   104 end;
   108 end;
   105 
   109 
   106 procedure KeyPressChat(Key: Longword);
   110 procedure KeyPressChat(Key: Longword);
   107 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   111 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   108 var i, btw: integer;
   112 var i, btw: integer;
   114 				begin
   118 				begin
   115 				InputStr.s[0]:= InputStrL[byte(InputStr.s[0])];
   119 				InputStr.s[0]:= InputStrL[byte(InputStr.s[0])];
   116 				SetLine(InputStr, InputStr.s)
   120 				SetLine(InputStr, InputStr.s)
   117 				end;
   121 				end;
   118 		13,271: begin
   122 		13,271: begin
   119 			AddChatString(InputStr.s);
   123 			if Length(InputStr.s) > 0 then
   120 			SetLine(InputStr, '');
   124 				begin
       
   125 				AddChatString(InputStr.s);
       
   126 				ParseCommand('/say ' + InputStr.s, true);
       
   127 				SetLine(InputStr, '');
       
   128 				end;
   121 			GameState:= gsGame
   129 			GameState:= gsGame
   122 			end
   130 			end
   123 	else
   131 	else
   124 	if (Key < $80) then btw:= 1
   132 	if (Key < $80) then btw:= 1
   125 	else if (Key < $800) then btw:= 2
   133 	else if (Key < $800) then btw:= 2