From: Holger Schemel Date: Fri, 4 Jan 2019 17:55:48 +0000 (+0100) Subject: added quickly toggling team mode by clicking on main menu "name/team" text X-Git-Tag: 4.1.2.0~65 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=b275388df382d188bdce63b9e68783cb7139fc11;p=rocksndiamonds.git added quickly toggling team mode by clicking on main menu "name/team" text --- diff --git a/src/screens.c b/src/screens.c index bf8ca0ef..2067ee28 100644 --- a/src/screens.c +++ b/src/screens.c @@ -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) { diff --git a/src/tools.c b/src/tools.c index 3f9fa56f..6763d611 100644 --- a/src/tools.c +++ b/src/tools.c @@ -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; diff --git a/src/tools.h b/src/tools.h index a6a224f0..9f144ca2 100644 --- a/src/tools.h +++ b/src/tools.h @@ -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);