added quickly toggling team mode by clicking on main menu "name/team" text
authorHolger Schemel <info@artsoft.org>
Fri, 4 Jan 2019 17:55:48 +0000 (18:55 +0100)
committerHolger Schemel <info@artsoft.org>
Fri, 4 Jan 2019 17:55:48 +0000 (18:55 +0100)
src/screens.c
src/tools.c
src/tools.h

index bf8ca0e..2067ee2 100644 (file)
@@ -2035,9 +2035,23 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
 
       if (pos == MAIN_CONTROL_NAME)
       {
-       SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
+       if ((mx || my) &&
+           insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY))
+       {
+         // special case: menu text "name/team" clicked -- toggle team mode
+         setup.team_mode = !setup.team_mode;
+
+         InitializeMainControls();
+         DrawCursorAndText_Main(choice, TRUE, FALSE);
 
-       HandleTypeName(strlen(setup.player_name), 0);
+         DrawPreviewPlayers();
+       }
+       else
+       {
+         SetGameStatus(GAME_MODE_PSEUDO_TYPENAME);
+
+         HandleTypeName(strlen(setup.player_name), 0);
+       }
       }
       else if (pos == MAIN_CONTROL_LEVELS)
       {
index 3f9fa56..6763d61 100644 (file)
@@ -3516,14 +3516,11 @@ static void DrawPreviewLevelExt(boolean restart)
   }
 }
 
-static void DrawPreviewPlayers(void)
+void DrawPreviewPlayers(void)
 {
   if (game_status != GAME_MODE_MAIN)
     return;
 
-  if (!network.enabled && !setup.team_mode)
-    return;
-
   boolean player_found[MAX_PLAYERS];
   int num_players = 0;
   int i, x, y;
@@ -3572,6 +3569,9 @@ static void DrawPreviewPlayers(void)
   ClearRectangleOnBackground(drawto, max_xpos, max_ypos,
                             max_players_width, max_players_height);
 
+  if (!network.enabled && !setup.team_mode)
+    return;
+
   // only draw players if level is suited for team mode
   if (num_players < 2)
     return;
index a6a224f..9f144ca 100644 (file)
@@ -194,6 +194,7 @@ void ShowEnvelopeDoor(char *text, int);
 void DrawLevel(int);
 void DrawSizedLevel(int, int, int, int, int);
 void DrawMiniLevel(int, int, int, int);
+void DrawPreviewPlayers(void);
 void DrawPreviewLevelInitial(void);
 void DrawPreviewLevelAnimation(void);