From f9609535cba3b9b907f0e8dad31f7727aa380f71 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 26 Apr 2024 13:29:09 +0200 Subject: [PATCH] added new setup option type "yes/no/ask" --- src/libgame/setup.c | 6 +++++ src/libgame/setup.h | 54 +++++++++++++++++++++++---------------------- src/libgame/types.h | 5 +++++ src/screens.c | 14 ++++++++++++ 4 files changed, 53 insertions(+), 26 deletions(-) diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 06190e0b..42ae7bdc 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -4863,6 +4863,7 @@ char *getSetupValue(int type, void *value) case TYPE_SWITCH_3_STATES: strcpy(value_string, (*(int *)value == MODE_AUTO ? "auto" : + *(int *)value == MODE_ASK ? "ask" : *(int *)value == FALSE ? "off" : "on")); break; @@ -4875,6 +4876,11 @@ char *getSetupValue(int type, void *value) *(int *)value == FALSE ? "no" : "yes")); break; + case TYPE_YES_NO_ASK: + strcpy(value_string, (*(int *)value == MODE_ASK ? "ask" : + *(int *)value == FALSE ? "no" : "yes")); + break; + case TYPE_ECS_AGA: strcpy(value_string, (*(boolean *)value ? "AGA" : "ECS")); break; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index 92d20194..c7a53302 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -22,36 +22,37 @@ #define TYPE_SWITCH_3_STATES (1 << 2) #define TYPE_YES_NO (1 << 3) #define TYPE_YES_NO_AUTO (1 << 4) -#define TYPE_ECS_AGA (1 << 5) -#define TYPE_KEY (1 << 6) -#define TYPE_KEY_X11 (1 << 7) -#define TYPE_INTEGER (1 << 8) -#define TYPE_STRING (1 << 9) -#define TYPE_PLAYER (1 << 10) -#define TYPE_ELEMENT (1 << 11) -#define TYPE_GRAPHIC (1 << 12) +#define TYPE_YES_NO_ASK (1 << 5) +#define TYPE_ECS_AGA (1 << 6) +#define TYPE_KEY (1 << 7) +#define TYPE_KEY_X11 (1 << 8) +#define TYPE_INTEGER (1 << 9) +#define TYPE_STRING (1 << 10) +#define TYPE_PLAYER (1 << 11) +#define TYPE_ELEMENT (1 << 12) +#define TYPE_GRAPHIC (1 << 13) // additional values for setup screen -#define TYPE_ENTER_SCREEN (1 << 13) -#define TYPE_LEAVE_SCREEN (1 << 14) -#define TYPE_ENTER_MENU (1 << 15) -#define TYPE_LEAVE_MENU (1 << 16) -#define TYPE_ENTER_LIST (1 << 17) -#define TYPE_LEAVE_LIST (1 << 18) -#define TYPE_TEXT_INPUT (1 << 19) -#define TYPE_EMPTY (1 << 20) -#define TYPE_SKIPPABLE (1 << 21) -#define TYPE_KEYTEXT (1 << 22) -#define TYPE_HEADLINE (1 << 23) - -#define TYPE_GHOSTED (1 << 24) -#define TYPE_QUERY (1 << 25) +#define TYPE_ENTER_SCREEN (1 << 14) +#define TYPE_LEAVE_SCREEN (1 << 15) +#define TYPE_ENTER_MENU (1 << 16) +#define TYPE_LEAVE_MENU (1 << 17) +#define TYPE_ENTER_LIST (1 << 18) +#define TYPE_LEAVE_LIST (1 << 19) +#define TYPE_TEXT_INPUT (1 << 20) +#define TYPE_EMPTY (1 << 21) +#define TYPE_SKIPPABLE (1 << 22) +#define TYPE_KEYTEXT (1 << 23) +#define TYPE_HEADLINE (1 << 24) + +#define TYPE_GHOSTED (1 << 25) +#define TYPE_QUERY (1 << 26) // additional values for internal purposes -#define TYPE_BITFIELD (1 << 26) -#define TYPE_CONTENT (1 << 27) -#define TYPE_ELEMENT_LIST (1 << 28) -#define TYPE_CONTENT_LIST (1 << 29) +#define TYPE_BITFIELD (1 << 27) +#define TYPE_CONTENT (1 << 28) +#define TYPE_ELEMENT_LIST (1 << 29) +#define TYPE_CONTENT_LIST (1 << 30) // derived values for setup file handling #define TYPE_BOOLEAN_STYLE (TYPE_BOOLEAN | \ @@ -63,6 +64,7 @@ #define TYPE_VALUE (TYPE_BOOLEAN_STYLE | \ TYPE_SWITCH_3_STATES | \ TYPE_YES_NO_AUTO | \ + TYPE_YES_NO_ASK | \ TYPE_KEY | \ TYPE_KEY_X11 | \ TYPE_INTEGER | \ diff --git a/src/libgame/types.h b/src/libgame/types.h index bbe46f55..2c678f70 100644 --- a/src/libgame/types.h +++ b/src/libgame/types.h @@ -36,10 +36,15 @@ typedef unsigned char byte; #undef MODE_AUTO #endif +#ifdef MODE_ASK +#undef MODE_ASK +#endif + #define TRUE 1 #define FALSE 0 #define MODE_AUTO -1 +#define MODE_ASK -1 #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/src/screens.c b/src/screens.c index 1c4e14a1..85b91cde 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2633,6 +2633,7 @@ static int getMenuTextFont(int type) if (type & (TYPE_SWITCH | TYPE_YES_NO | TYPE_YES_NO_AUTO | + TYPE_YES_NO_ASK | TYPE_STRING | TYPE_PLAYER | TYPE_ECS_AGA | @@ -3079,6 +3080,7 @@ static void HandleMenuScreen(int mx, int my, int dx, int dy, int button, if (menu_info[choice].type & menu_navigation_type || menu_info[choice].type & TYPE_BOOLEAN_STYLE || menu_info[choice].type & TYPE_YES_NO_AUTO || + menu_info[choice].type & TYPE_YES_NO_ASK || menu_info[choice].type & TYPE_PLAYER) button = MB_MENU_CHOICE; } @@ -8381,6 +8383,9 @@ static int getSetupValueFont(int type, void *value) else if (type & TYPE_YES_NO_AUTO) return (*(int *)value == MODE_AUTO ? FONT_OPTION_ON : *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); + else if (type & TYPE_YES_NO_ASK) + return (*(int *)value == MODE_ASK ? FONT_OPTION_ON : + *(int *)value == FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); else if (type & TYPE_PLAYER) return FONT_VALUE_1; else @@ -8529,6 +8534,15 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) (*(int *)si->value == TRUE ? MODE_AUTO : *(int *)si->value == MODE_AUTO ? FALSE : TRUE)); } + else if (si->type & TYPE_YES_NO_ASK) + { + *(int *)si->value = + (dx == -1 ? + (*(int *)si->value == MODE_ASK ? TRUE : + *(int *)si->value == TRUE ? FALSE : MODE_ASK) : + (*(int *)si->value == TRUE ? MODE_ASK : + *(int *)si->value == MODE_ASK ? FALSE : TRUE)); + } else if (si->type & TYPE_KEY) { Key key; -- 2.34.1