diff -r d24257910f8d -r aaefa587e277 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Sun Dec 02 00:03:16 2012 +0100 +++ b/hedgewars/uChat.pas Tue Dec 25 04:45:22 2012 +0100 @@ -41,6 +41,7 @@ Width: LongInt; s: shortstring; end; + TChatCmd = (quit, pause, finish, fullscreen); var Strs: array[0 .. MaxStrIndex] of TChatLine; MStrs: array[0 .. MaxStrIndex] of shortstring; @@ -52,15 +53,25 @@ ChatReady: boolean; showAll: boolean; -const colors: array[#0..#6] of TSDL_Color = ( - (r:$FF; g:$FF; b:$FF; unused:$FF), // unused, feel free to take it for anything - (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White] - (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple] - (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime] - (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow] - (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red] - (r:$00; g:$FF; b:$FF; unused:$FF) // input line [Light Blue] - ); +const + colors: array[#0..#6] of TSDL_Color = ( + (r:$FF; g:$FF; b:$FF; unused:$FF), // unused, feel free to take it for anything + (r:$FF; g:$FF; b:$FF; unused:$FF), // chat message [White] + (r:$FF; g:$00; b:$FF; unused:$FF), // action message [Purple] + (r:$90; g:$FF; b:$90; unused:$FF), // join/leave message [Lime] + (r:$FF; g:$FF; b:$A0; unused:$FF), // team message [Light Yellow] + (r:$FF; g:$00; b:$00; unused:$FF), // error messages [Red] + (r:$00; g:$FF; b:$FF; unused:$FF) // input line [Light Blue] + ); + ChatCommandz: array [TChatCmd] of record + ChatCmd: string[31]; + ProcedureCallChatCmd: string[31]; + end = ( + (ChatCmd: '/quit'; ProcedureCallChatCmd: 'halt'), + (ChatCmd: '/pause'; ProcedureCallChatCmd: 'pause'), + (ChatCmd: '/finish'; ProcedureCallChatCmd: 'finish'), + (ChatCmd: '/fullscreen'; ProcedureCallChatCmd: 'fullscr') + ); procedure SetLine(var cl: TChatLine; str: shortstring; isInput: boolean); var strSurface, resSurface: PSDL_Surface; @@ -181,7 +192,7 @@ i:= MaxStrIndex else dec(i); - + inc(cnt); inc(t) end; @@ -197,6 +208,7 @@ procedure AcceptChatString(s: shortstring); var i: TWave; + j: TChatCmd; c, t: LongInt; x: byte; begin @@ -204,13 +216,13 @@ x:= 0; if (s[1] = '"') and (s[Length(s)] = '"') then x:= 1 - + else if (s[1] = '''') and (s[Length(s)] = '''') then x:= 2 - + else if (s[1] = '-') and (s[Length(s)] = '-') then x:= 3; - + if (not CurrentTeam^.ExtDriven) and (x <> 0) then for c:= 0 to Pred(TeamsCount) do if (TeamsArray[c] = CurrentTeam) then @@ -267,6 +279,13 @@ ParseCommand('/taunt ' + char(i), true); exit end; + + for j:= Low(TChatCmd) to High(TChatCmd) do + if (s = ChatCommandz[j].ChatCmd) then + begin + ParseCommand(ChatCommandz[j].ProcedureCallChatCmd, true); + exit + end; end else ParseCommand('/say ' + s, true);