hedgewars/uChat.pas
changeset 8152 5e329951afe5
parent 7722 1518827049ed
child 8330 aaefa587e277
child 8516 e422cbf9aa33
--- a/hedgewars/uChat.pas	Fri Nov 30 10:51:29 2012 +0100
+++ b/hedgewars/uChat.pas	Fri Nov 30 15:00:47 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;
@@ -197,6 +208,7 @@
 
 procedure AcceptChatString(s: shortstring);
 var i: TWave;
+    j: TChatCmd;
     c, t: LongInt;
     x: byte;
 begin
@@ -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);