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 bf8ca0ef9d3dc6e6ef228183bfcaf5e32e74ac7b..2067ee28f8592e08bfe4136b27de1bdeba03f7c9 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 3f9fa56f8ef683be363200ec522c5cfec6439ba2..6763d611a6d9ac384dc0228337f934afe45fcc39 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 a6a224f09cb3a1aca99a8df77ebb10d6c74597c1..9f144ca297b9867c4e542ae24e9960ebfaeae414 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);