From: Holger Schemel Date: Wed, 6 Nov 2024 19:16:04 +0000 (+0100) Subject: added new setup option type yes/no/once X-Git-Tag: 4.4.0.0-test-4~81 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=f09072e8a04a60b46dd85c94dd5f487a7f7b0893;p=rocksndiamonds.git added new setup option type yes/no/once --- diff --git a/src/libgame/setup.c b/src/libgame/setup.c index 07e0969e..94701acb 100644 --- a/src/libgame/setup.c +++ b/src/libgame/setup.c @@ -4923,6 +4923,11 @@ char *getSetupValue(int type, void *value) *(int *)value == STATE_FALSE ? "no" : "yes")); break; + case TYPE_YES_NO_ONCE: + strcpy(value_string, (*(int *)value == STATE_ONCE ? "once" : + *(int *)value == STATE_FALSE ? "no" : "yes")); + break; + case TYPE_ECS_AGA: strcpy(value_string, (*(boolean *)value ? "new" : "old")); break; diff --git a/src/libgame/setup.h b/src/libgame/setup.h index c540b801..396eff31 100644 --- a/src/libgame/setup.h +++ b/src/libgame/setup.h @@ -23,36 +23,37 @@ #define TYPE_YES_NO (1 << 3) #define TYPE_YES_NO_AUTO (1 << 4) #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) +#define TYPE_YES_NO_ONCE (1 << 6) +#define TYPE_ECS_AGA (1 << 7) +#define TYPE_KEY (1 << 8) +#define TYPE_KEY_X11 (1 << 9) +#define TYPE_INTEGER (1 << 10) +#define TYPE_STRING (1 << 11) +#define TYPE_PLAYER (1 << 12) +#define TYPE_ELEMENT (1 << 13) +#define TYPE_GRAPHIC (1 << 14) // additional values for setup screen -#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) +#define TYPE_ENTER_SCREEN (1 << 15) +#define TYPE_LEAVE_SCREEN (1 << 16) +#define TYPE_ENTER_MENU (1 << 17) +#define TYPE_LEAVE_MENU (1 << 18) +#define TYPE_ENTER_LIST (1 << 19) +#define TYPE_LEAVE_LIST (1 << 20) +#define TYPE_TEXT_INPUT (1 << 21) +#define TYPE_EMPTY (1 << 22) +#define TYPE_SKIPPABLE (1 << 23) +#define TYPE_KEYTEXT (1 << 24) +#define TYPE_HEADLINE (1 << 25) + +#define TYPE_GHOSTED (1 << 26) +#define TYPE_QUERY (1 << 27) // additional values for internal purposes -#define TYPE_BITFIELD (1 << 27) -#define TYPE_CONTENT (1 << 28) -#define TYPE_ELEMENT_LIST (1 << 29) -#define TYPE_CONTENT_LIST (1 << 30) +#define TYPE_BITFIELD (1 << 28) +#define TYPE_CONTENT (1 << 29) +#define TYPE_ELEMENT_LIST (1 << 30) +#define TYPE_CONTENT_LIST (1 << 31) // derived values for setup file handling #define TYPE_BOOLEAN_STYLE (TYPE_BOOLEAN | \ @@ -65,6 +66,7 @@ TYPE_SWITCH_3_STATES | \ TYPE_YES_NO_AUTO | \ TYPE_YES_NO_ASK | \ + TYPE_YES_NO_ONCE | \ TYPE_KEY | \ TYPE_KEY_X11 | \ TYPE_INTEGER | \ diff --git a/src/libgame/types.h b/src/libgame/types.h index 7dc2a7d4..23d0072a 100644 --- a/src/libgame/types.h +++ b/src/libgame/types.h @@ -40,6 +40,10 @@ typedef unsigned char byte; #undef STATE_ASK #endif +#ifdef STATE_ONCE +#undef STATE_ONCE +#endif + // values for boolean data type #define TRUE 1 #define FALSE 0 @@ -49,6 +53,7 @@ typedef unsigned char byte; #define STATE_FALSE 0 #define STATE_AUTO -1 #define STATE_ASK -1 +#define STATE_ONCE -1 #ifndef MIN #define MIN(a, b) ((a) < (b) ? (a) : (b)) diff --git a/src/screens.c b/src/screens.c index 1a6ae83a..6fb73d90 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2693,6 +2693,7 @@ static int getMenuTextFont(int type) TYPE_YES_NO | TYPE_YES_NO_AUTO | TYPE_YES_NO_ASK | + TYPE_YES_NO_ONCE | TYPE_STRING | TYPE_PLAYER | TYPE_ECS_AGA | @@ -3150,6 +3151,7 @@ static void HandleMenuScreen(int mx, int my, int dx, int dy, int button, 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_YES_NO_ONCE || menu_info[choice].type & TYPE_PLAYER) button = MB_MENU_CHOICE; } @@ -8621,6 +8623,9 @@ static int getSetupValueFont(int type, void *value) else if (type & TYPE_YES_NO_ASK) return (*(int *)value == STATE_ASK ? FONT_OPTION_ON : *(int *)value == STATE_FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); + else if (type & TYPE_YES_NO_ONCE) + return (*(int *)value == STATE_ONCE ? FONT_OPTION_ON : + *(int *)value == STATE_FALSE ? FONT_OPTION_OFF : FONT_OPTION_ON); else if (type & TYPE_PLAYER) return FONT_VALUE_1; else @@ -8778,6 +8783,15 @@ static void changeSetupValue(int screen_pos, int setup_info_pos_raw, int dx) (*(int *)si->value == STATE_TRUE ? STATE_ASK : *(int *)si->value == STATE_ASK ? STATE_FALSE : STATE_TRUE)); } + else if (si->type & TYPE_YES_NO_ONCE) + { + *(int *)si->value = + (dx == -1 ? + (*(int *)si->value == STATE_ONCE ? STATE_TRUE : + *(int *)si->value == STATE_TRUE ? STATE_FALSE : STATE_ONCE) : + (*(int *)si->value == STATE_TRUE ? STATE_ONCE : + *(int *)si->value == STATE_ONCE ? STATE_FALSE : STATE_TRUE)); + } else if (si->type & TYPE_KEY) { Key key;