hedgewars/uChat.pas
changeset 949 866729775535
parent 948 5d49a92c240a
child 950 feb18ec0c5c2
equal deleted inserted replaced
948:5d49a92c240a 949:866729775535
    22 
    22 
    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 var UserNick: shortstring = '';
       
    28 
    27 implementation
    29 implementation
    28 uses uMisc, uStore, uConsts, SDLh, uConsole, uKeys;
    30 uses uMisc, uStore, uConsts, SDLh, uConsole, uKeys;
    29 
    31 
    30 const MaxStrIndex = 7;
    32 const MaxStrIndex = 7;
    31 
    33 
    32 type TChatLine = record
    34 type TChatLine = record
    33 		s: shortstring;
    35 		s: shortstring;
    34 		Time: Longword;
    36 		Time: Longword;
    35 		Tex: PTexture;
    37 		Tex: PTexture;
    36 		end;
    38 		end;
    37 
       
    38 
    39 
    39 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    40 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    40 	lastStr: Longword = 0;
    41 	lastStr: Longword = 0;
    41 	visibleCount: Longword = 0;
    42 	visibleCount: Longword = 0;
    42 	
    43 	
   108 end;
   109 end;
   109 
   110 
   110 procedure KeyPressChat(Key: Longword);
   111 procedure KeyPressChat(Key: Longword);
   111 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   112 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   112 var i, btw: integer;
   113 var i, btw: integer;
   113     utf8: shortstring;
   114     utf8, s: shortstring;
   114 begin
   115 begin
   115 if Key <> 0 then
   116 if Key <> 0 then
   116 	case Key of
   117 	case Key of
   117 		8: if Length(InputStr.s) > 0 then
   118 		8: if Length(InputStr.s) > 0 then
   118 				begin
   119 				begin
   120 				SetLine(InputStr, InputStr.s)
   121 				SetLine(InputStr, InputStr.s)
   121 				end;
   122 				end;
   122 		13, 271: begin
   123 		13, 271: begin
   123 			if Length(InputStr.s) > 0 then
   124 			if Length(InputStr.s) > 0 then
   124 				begin
   125 				begin
   125 				AddChatString(InputStr.s);
   126 				s:= UserNick + ': ' + InputStr.s;
   126 				ParseCommand('/say ' + InputStr.s, true);
   127 				AddChatString(s);
       
   128 				ParseCommand('/say ' + s, true);
   127 				SetLine(InputStr, '')
   129 				SetLine(InputStr, '')
   128 				end;
   130 				end;
   129 			FreezeEnterKey;
   131 			FreezeEnterKey;
   130 			GameState:= gsGame
   132 			GameState:= gsGame
   131 			end
   133 			end