From 6e781e8ea4fb92623b2ce61dd2caadf0d551c631 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 14 Dec 2022 11:54:37 +0100 Subject: [PATCH] added optional main menu button to directly show level set info This is a special button for the main menu that will only be displayed if files with level set information exist (like a "README" file in the current level set directory). The button will currently only be displayed if a valid screen position is defined for it in the currently active graphics configuration. --- src/conf_gfx.c | 8 ++++++++ src/main.h | 1 + src/screens.c | 52 ++++++++++++++++++++++++++++++++++---------------- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 829000da..b9cc9756 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6204,6 +6204,11 @@ struct ConfigInfo image_config[] = { "menu.button_play_solution", UNDEFINED_FILENAME }, { "menu.button_play_solution.active", UNDEFINED_FILENAME }, + { "menu.button_levelset_info", UNDEFINED_FILENAME }, + { "menu.button_levelset_info.clone_from", "envelope_1" }, + { "menu.button_levelset_info.active", UNDEFINED_FILENAME }, + { "menu.button_levelset_info.active.clone_from", "envelope_1.collecting" }, + { "menu.button_switch_ecs_aga", UNDEFINED_FILENAME }, { "menu.button_switch_ecs_aga.active", UNDEFINED_FILENAME }, @@ -8197,6 +8202,9 @@ struct ConfigInfo image_config[] = { "main.button.play_solution.x", "-1" }, { "main.button.play_solution.y", "-1" }, + { "main.button.levelset_info.x", "-1" }, + { "main.button.levelset_info.y", "-1" }, + { "main.button.switch_ecs_aga.x", "-1" }, { "main.button.switch_ecs_aga.y", "-1" }, diff --git a/src/main.h b/src/main.h index 0fc74cb2..7456a3d9 100644 --- a/src/main.h +++ b/src/main.h @@ -2750,6 +2750,7 @@ struct MenuMainButtonInfo struct MenuPosInfo insert_solution; struct MenuPosInfo play_solution; + struct MenuPosInfo levelset_info; struct MenuPosInfo switch_ecs_aga; }; diff --git a/src/screens.c b/src/screens.c index 021dfcdc..8a471ecb 100644 --- a/src/screens.c +++ b/src/screens.c @@ -203,20 +203,21 @@ #define SCREEN_CTRL_ID_NEXT_PLAYER 11 #define SCREEN_CTRL_ID_INSERT_SOLUTION 12 #define SCREEN_CTRL_ID_PLAY_SOLUTION 13 -#define SCREEN_CTRL_ID_SWITCH_ECS_AGA 14 -#define SCREEN_CTRL_ID_TOUCH_PREV_PAGE 15 -#define SCREEN_CTRL_ID_TOUCH_NEXT_PAGE 16 -#define SCREEN_CTRL_ID_TOUCH_PREV_PAGE2 17 -#define SCREEN_CTRL_ID_TOUCH_NEXT_PAGE2 18 +#define SCREEN_CTRL_ID_LEVELSET_INFO 14 +#define SCREEN_CTRL_ID_SWITCH_ECS_AGA 15 +#define SCREEN_CTRL_ID_TOUCH_PREV_PAGE 16 +#define SCREEN_CTRL_ID_TOUCH_NEXT_PAGE 17 +#define SCREEN_CTRL_ID_TOUCH_PREV_PAGE2 18 +#define SCREEN_CTRL_ID_TOUCH_NEXT_PAGE2 19 -#define NUM_SCREEN_MENUBUTTONS 19 +#define NUM_SCREEN_MENUBUTTONS 20 -#define SCREEN_CTRL_ID_SCROLL_UP 19 -#define SCREEN_CTRL_ID_SCROLL_DOWN 20 -#define SCREEN_CTRL_ID_SCROLL_VERTICAL 21 -#define SCREEN_CTRL_ID_NETWORK_SERVER 22 +#define SCREEN_CTRL_ID_SCROLL_UP 20 +#define SCREEN_CTRL_ID_SCROLL_DOWN 21 +#define SCREEN_CTRL_ID_SCROLL_VERTICAL 22 +#define SCREEN_CTRL_ID_NETWORK_SERVER 23 -#define NUM_SCREEN_GADGETS 23 +#define NUM_SCREEN_GADGETS 24 #define NUM_SCREEN_SCROLLBUTTONS 2 #define NUM_SCREEN_SCROLLBARS 1 @@ -224,11 +225,12 @@ #define SCREEN_MASK_MAIN (1 << 0) #define SCREEN_MASK_MAIN_HAS_SOLUTION (1 << 1) -#define SCREEN_MASK_INPUT (1 << 2) -#define SCREEN_MASK_TOUCH (1 << 3) -#define SCREEN_MASK_TOUCH2 (1 << 4) -#define SCREEN_MASK_SCORES (1 << 5) -#define SCREEN_MASK_SCORES_INFO (1 << 6) +#define SCREEN_MASK_MAIN_HAS_SET_INFO (1 << 2) +#define SCREEN_MASK_INPUT (1 << 3) +#define SCREEN_MASK_TOUCH (1 << 4) +#define SCREEN_MASK_TOUCH2 (1 << 5) +#define SCREEN_MASK_SCORES (1 << 6) +#define SCREEN_MASK_SCORES_INFO (1 << 7) // graphic position and size values for buttons and scrollbars #define SC_MENUBUTTON_XSIZE TILEX @@ -923,6 +925,11 @@ static struct MainControlInfo main_controls[] = }; +static boolean hasLevelSetInfo(void) +{ + return (getLevelSetInfoFilename(0) != NULL); +} + static int getTitleScreenGraphic(int nr, boolean initial) { return (initial ? IMG_TITLESCREEN_INITIAL_1 : IMG_TITLESCREEN_1) + nr; @@ -1809,6 +1816,7 @@ void DrawMainMenu(void) MapTapeButtons(); MapScreenMenuGadgets(SCREEN_MASK_MAIN); UpdateScreenMenuGadgets(SCREEN_MASK_MAIN_HAS_SOLUTION, hasSolutionTape()); + UpdateScreenMenuGadgets(SCREEN_MASK_MAIN_HAS_SET_INFO, hasLevelSetInfo()); // copy actual game door content to door double buffer for OpenDoor() BlitBitmap(drawto, bitmap_db_door_1, DX, DY, DXSIZE, DYSIZE, 0, 0); @@ -9562,6 +9570,14 @@ static struct GD_EVENT_RELEASED, FALSE, "play solution tape" }, + { + IMG_MENU_BUTTON_LEVELSET_INFO, IMG_MENU_BUTTON_LEVELSET_INFO_ACTIVE, + &menu.main.button.levelset_info, NULL, + SCREEN_CTRL_ID_LEVELSET_INFO, + SCREEN_MASK_MAIN_HAS_SET_INFO, + GD_EVENT_RELEASED, + FALSE, "show level set info" + }, { IMG_MENU_BUTTON_SWITCH_ECS_AGA, IMG_MENU_BUTTON_SWITCH_ECS_AGA_ACTIVE, &menu.main.button.switch_ecs_aga, &setup.prefer_aga_graphics, @@ -10170,6 +10186,10 @@ static void HandleScreenGadgets(struct GadgetInfo *gi) PlaySolutionTape(); break; + case SCREEN_CTRL_ID_LEVELSET_INFO: + DrawInfoScreen_FromMainMenu(INFO_MODE_LEVELSET); + break; + case SCREEN_CTRL_ID_SWITCH_ECS_AGA: setup.prefer_aga_graphics = !setup.prefer_aga_graphics; DrawMainMenu(); -- 2.34.1