hedgewars/uChat.pas
changeset 8152 5e329951afe5
parent 7722 1518827049ed
child 8330 aaefa587e277
child 8516 e422cbf9aa33
equal deleted inserted replaced
8150:6b30a4cd7c7c 8152:5e329951afe5
    39     Tex: PTexture;
    39     Tex: PTexture;
    40     Time: Longword;
    40     Time: Longword;
    41     Width: LongInt;
    41     Width: LongInt;
    42     s: shortstring;
    42     s: shortstring;
    43     end;
    43     end;
       
    44     TChatCmd = (quit, pause, finish, fullscreen);
    44 
    45 
    45 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    46 var Strs: array[0 .. MaxStrIndex] of TChatLine;
    46     MStrs: array[0 .. MaxStrIndex] of shortstring;
    47     MStrs: array[0 .. MaxStrIndex] of shortstring;
    47     missedCount: LongWord;
    48     missedCount: LongWord;
    48     lastStr: LongWord;
    49     lastStr: LongWord;
    50     InputStr: TChatLine;
    51     InputStr: TChatLine;
    51     InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char
    52     InputStrL: array[0..260] of char; // for full str + 4-byte utf-8 char
    52     ChatReady: boolean;
    53     ChatReady: boolean;
    53     showAll: boolean;
    54     showAll: boolean;
    54 
    55 
    55 const colors: array[#0..#6] of TSDL_Color = (
    56 const
    56     (r:$FF; g:$FF; b:$FF; unused:$FF), // unused, feel free to take it for anything
    57     colors: array[#0..#6] of TSDL_Color = (
    57     (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White]
    58             (r:$FF; g:$FF; b:$FF; unused:$FF), // unused, feel free to take it for anything
    58     (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple]
    59             (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White]
    59     (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime]
    60             (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple]
    60     (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow]
    61             (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime]
    61     (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red]
    62             (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow]
    62     (r:$00; g:$FF; b:$FF; unused:$FF)  // input line [Light Blue]
    63             (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red]
    63     );
    64             (r:$00; g:$FF; b:$FF; unused:$FF)  // input line [Light Blue]
       
    65             );
       
    66     ChatCommandz: array [TChatCmd] of record
       
    67             ChatCmd: string[31];
       
    68             ProcedureCallChatCmd: string[31];
       
    69             end = (
       
    70             (ChatCmd: '/quit'; ProcedureCallChatCmd: 'halt'),
       
    71             (ChatCmd: '/pause'; ProcedureCallChatCmd: 'pause'),
       
    72             (ChatCmd: '/finish'; ProcedureCallChatCmd: 'finish'),
       
    73             (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr')
       
    74             );
    64 
    75 
    65 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
    76 procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean);
    66 var strSurface, resSurface: PSDL_Surface;
    77 var strSurface, resSurface: PSDL_Surface;
    67     w, h: LongInt;
    78     w, h: LongInt;
    68     color: TSDL_Color;
    79     color: TSDL_Color;
   195 ParseCommand('/hogsay '+s, true)
   206 ParseCommand('/hogsay '+s, true)
   196 end;
   207 end;
   197 
   208 
   198 procedure AcceptChatString(s: shortstring);
   209 procedure AcceptChatString(s: shortstring);
   199 var i: TWave;
   210 var i: TWave;
       
   211     j: TChatCmd;
   200     c, t: LongInt;
   212     c, t: LongInt;
   201     x: byte;
   213     x: byte;
   202 begin
   214 begin
   203 t:= LocalTeam;
   215 t:= LocalTeam;
   204 x:= 0;
   216 x:= 0;
   263 
   275 
   264     for i:= Low(TWave) to High(TWave) do
   276     for i:= Low(TWave) to High(TWave) do
   265         if (s = Wavez[i].cmd) then
   277         if (s = Wavez[i].cmd) then
   266             begin
   278             begin
   267             ParseCommand('/taunt ' + char(i), true);
   279             ParseCommand('/taunt ' + char(i), true);
       
   280             exit
       
   281             end;
       
   282 
       
   283 	for j:= Low(TChatCmd) to High(TChatCmd) do
       
   284         if (s = ChatCommandz[j].ChatCmd) then
       
   285             begin
       
   286             ParseCommand(ChatCommandz[j].ProcedureCallChatCmd, true);
   268             exit
   287             exit
   269             end;
   288             end;
   270     end
   289     end
   271     else
   290     else
   272         ParseCommand('/say ' + s, true);
   291         ParseCommand('/say ' + s, true);