hedgewars/uChat.pas
changeset 988 cdff3f6f9b38
parent 984 dd5f16f69926
child 990 dfa6a6fe1542
equal deleted inserted replaced
987:0fcd3fadda41 988:cdff3f6f9b38
    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 = '';
    27 var UserNick: shortstring = '';
       
    28 	ChatVisibleCount: Longword = 7;
    28 
    29 
    29 implementation
    30 implementation
    30 uses uMisc, uStore, uConsts, SDLh, uConsole, uKeys;
    31 uses uMisc, uStore, uConsts, SDLh, uConsole, uKeys;
    31 
    32 
    32 const MaxStrIndex = 7;
    33 const MaxStrIndex = 30;
    33 
    34 
    34 type TChatLine = record
    35 type TChatLine = record
    35 		s: shortstring;
    36 		s: shortstring;
    36 		Time: Longword;
    37 		Time: Longword;
    37 		Tex: PTexture;
    38 		Tex: PTexture;
    89 var i, t, cnt: Longword;
    90 var i, t, cnt: Longword;
    90 begin
    91 begin
    91 cnt:= 0;
    92 cnt:= 0;
    92 t:= 0;
    93 t:= 0;
    93 i:= lastStr;
    94 i:= lastStr;
    94 while (t <= MaxStrIndex)
    95 while (t < ChatVisibleCount)
    95 	and (Strs[i].Tex <> nil)
    96 	and (Strs[i].Tex <> nil)
    96 	and (Strs[i].Time > RealTicks) do
    97 	and (Strs[i].Time > RealTicks) do
    97 	begin
    98 	begin
    98 	DrawTexture(8, (visibleCount - t) * 16 - 6 + cConsoleYAdd, Strs[i].Tex);
    99 	DrawTexture(8, (visibleCount - t) * 16 - 6, Strs[i].Tex);
    99 	if i = 0 then i:= MaxStrIndex else dec(i);
   100 	if i = 0 then i:= MaxStrIndex else dec(i);
   100 	inc(cnt);
   101 	inc(cnt);
   101 	inc(t)
   102 	inc(t)
   102 	end;
   103 	end;
   103 
   104 
   104 visibleCount:= cnt;
   105 visibleCount:= cnt;
   105 
   106 
   106 if (GameState = gsChat)
   107 if (GameState = gsChat)
   107 	and (InputStr.Tex <> nil) then
   108 	and (InputStr.Tex <> nil) then
   108 	DrawTexture(11, visibleCount * 16 + 10 + cConsoleYAdd, InputStr.Tex);
   109 	DrawTexture(11, visibleCount * 16 + 10, InputStr.Tex);
   109 end;
   110 end;
   110 
   111 
   111 procedure KeyPressChat(Key: Longword);
   112 procedure KeyPressChat(Key: Longword);
   112 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   113 const firstByteMark: array[1..4] of byte = (0, $C0, $E0, $F0);
   113 var i, btw: integer;
   114 var i, btw: integer;