Having chat mode as game state was a mistake
authorunc0rr
Sun, 04 Mar 2018 00:13:38 +0100
changeset 13082 c213645ff848
parent 13081 65a3b4bea459
child 13083 dd904dd9c587
Having chat mode as game state was a mistake
hedgewars/hwengine.pas
hedgewars/uChat.pas
hedgewars/uCommandHandlers.pas
hedgewars/uGearsHandlersRope.pas
hedgewars/uTypes.pas
hedgewars/uVariables.pas
--- a/hedgewars/hwengine.pas	Fri Mar 02 19:44:09 2018 +0100
+++ b/hedgewars/hwengine.pas	Sun Mar 04 00:13:38 2018 +0100
@@ -105,7 +105,7 @@
             RecountAllTeamsHealth;
             GameState:= gsGame;
             end;
-        gsConfirm, gsGame, gsChat:
+        gsConfirm, gsGame:
             begin
             // disable screenshot flash effect when about to make another screenshot
             if flagMakeCapture and (ScreenFade = sfFromWhite) then
@@ -180,7 +180,7 @@
         begin
             case event.type_ of
                 SDL_KEYDOWN:
-                    if GameState = gsChat then
+                    if isInChatMode then
                         begin
                     // sdl on iphone supports only ashii keyboards and the unicode field is deprecated in sdl 1.3
                         KeyPressChat(event.key.keysym);
@@ -188,10 +188,10 @@
                     else
                         if GameState >= gsGame then ProcessKey(event.key);
                 SDL_KEYUP:
-                    if (GameState <> gsChat) and (GameState >= gsGame) then
+                    if (not isInChatMode) and (GameState >= gsGame) then
                         ProcessKey(event.key);
 
-                SDL_TEXTINPUT: if GameState = gsChat then uChat.TextInput(event.text);
+                SDL_TEXTINPUT: if isInChatMode then uChat.TextInput(event.text);
 
                 SDL_WINDOWEVENT:
                     begin
--- a/hedgewars/uChat.pas	Fri Mar 02 19:44:09 2018 +0100
+++ b/hedgewars/uChat.pas	Sun Mar 04 00:13:38 2018 +0100
@@ -303,7 +303,7 @@
 top := 10 + visibleCount * ClHeight; // we start with input line (if any)
 
 // draw chat input line first and under all other lines
-if (GameState = gsChat) and (InputStr.Tex <> nil) then
+if isInChatMode and (InputStr.Tex <> nil) then
     begin
 
     if InputLinePrefix.Tex = nil then
@@ -575,7 +575,7 @@
     history:= 0;
     SDL_StopTextInput();
     //SDL_EnableKeyRepeat(0,0);
-    GameState:= gsGame;
+    isInChatMode:= false;
     ResetKbd;
 end;
 
@@ -1101,7 +1101,7 @@
 var i: Integer;
 begin
     s:= s; // avoid compiler hint
-    GameState:= gsChat;
+    isInChatMode:= true;
     SDL_StopTextInput();
     SDL_StartTextInput();
     //Make REALLY sure unexpected events are flushed (1 time is insufficient as of SDL 2.0.7)
--- a/hedgewars/uCommandHandlers.pas	Fri Mar 02 19:44:09 2018 +0100
+++ b/hedgewars/uCommandHandlers.pas	Sun Mar 04 00:13:38 2018 +0100
@@ -49,14 +49,15 @@
 procedure chQuit(var s: shortstring);
 begin
     s:= s; // avoid compiler hint
-    if (GameState = gsGame) or (GameState = gsChat) then
-        begin
-        prevGState:= GameState;
+    if (GameState = gsGame) then
+    begin
+        isInChatMode:= false;
         GameState:= gsConfirm;
-        end
-    else
+    end
+    else begin
         if GameState = gsConfirm then
-            GameState:= prevGState;
+            GameState:= gsGame;
+    end;
 
     updateCursorVisibility;
 end;
--- a/hedgewars/uGearsHandlersRope.pas	Fri Mar 02 19:44:09 2018 +0100
+++ b/hedgewars/uGearsHandlersRope.pas	Sun Mar 04 00:13:38 2018 +0100
@@ -26,7 +26,7 @@
 
 implementation
 uses uConsts, uFloat, uCollisions, uVariables, uGearsList, uSound, uGearsUtils,
-    uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender, uGearsHandlersMess;
+    uAmmos, uDebug, uUtils, uGearsHedgehog, uGearsRender;
 
 const
     IsNilHHFatal = false;
--- a/hedgewars/uTypes.pas	Fri Mar 02 19:44:09 2018 +0100
+++ b/hedgewars/uTypes.pas	Sun Mar 04 00:13:38 2018 +0100
@@ -36,7 +36,7 @@
         end;
 
     // Possible states of the game
-    TGameState = (gsLandGen, gsStart, gsGame, gsChat, gsConfirm, gsExit, gsSuspend);
+    TGameState = (gsLandGen, gsStart, gsGame, gsConfirm, gsExit, gsSuspend);
 
     // Game types that help determining what the engine is actually supposed to do
     TGameType = (gmtLocal, gmtDemo, gmtNet, gmtSave, gmtLandPreview, gmtSyntax, gmtRecord);
--- a/hedgewars/uVariables.pas	Fri Mar 02 19:44:09 2018 +0100
+++ b/hedgewars/uVariables.pas	Sun Mar 04 00:13:38 2018 +0100
@@ -51,6 +51,7 @@
     cFlattenClouds     : boolean;
     cIce               : boolean;
     cSnow              : boolean;
+    isInChatMode       : boolean;
 
     cAltDamage         : boolean;
     cReducedQuality    : LongWord;
@@ -2662,6 +2663,7 @@
     lastVisualGearByUID := nil;
     lastGearByUID       := nil;
     cReadyDelay         := 5000;
+    isInChatMode        := false;
 
         {*  REFERENCE
       4096 -> $FFFFF000