added support for toggling team mode in main menu using cursor keys
authorHolger Schemel <info@artsoft.org>
Sun, 13 Jun 2021 10:14:28 +0000 (12:14 +0200)
committerHolger Schemel <info@artsoft.org>
Sun, 13 Jun 2021 10:14:28 +0000 (12:14 +0200)
src/screens.c

index 83b91dc477a2e142239b70aae7a7e4ccbf8b5422..a63aa3339f8d3ec1d70c7d3cd2cab0b0f5432d9d 100644 (file)
@@ -1957,6 +1957,16 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
   }
 }
 
+static void HandleMainMenu_ToggleTeamMode(void)
+{
+  setup.team_mode = !setup.team_mode;
+
+  InitializeMainControls();
+  DrawCursorAndText_Main(MAIN_CONTROL_NAME, TRUE, FALSE);
+
+  DrawPreviewPlayers();
+}
+
 static void HandleMainMenu_SelectLevel(int step, int direction,
                                       int selected_level_nr)
 {
@@ -2106,9 +2116,16 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
       else if (dx != 0)
       {
-       if (choice != MAIN_CONTROL_INFO &&
-           choice != MAIN_CONTROL_SETUP)
+       if (choice == MAIN_CONTROL_NAME)
+       {
+         // special case: cursor left or right pressed -- toggle team mode
+         HandleMainMenu_ToggleTeamMode();
+       }
+       else if (choice != MAIN_CONTROL_INFO &&
+                choice != MAIN_CONTROL_SETUP)
+       {
          HandleMainMenu_SelectLevel(1, dx, NO_DIRECT_LEVEL_SELECT);
+       }
       }
     }
     else
@@ -2121,12 +2138,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
            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);
-
-         DrawPreviewPlayers();
+         HandleMainMenu_ToggleTeamMode();
        }
        else
        {