From: Holger Schemel Date: Tue, 7 Feb 2023 23:37:19 +0000 (+0100) Subject: added check button gadget that toggles only after releasing X-Git-Tag: 4.3.5.0~17 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=80f8fdb229218f835f2d5e9a05df6a5ed509b990;p=rocksndiamonds.git added check button gadget that toggles only after releasing --- diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 94fe7455..89eb0081 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -238,6 +238,7 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) { case GD_TYPE_NORMAL_BUTTON: case GD_TYPE_CHECK_BUTTON: + case GD_TYPE_CHECK_BUTTON_2: case GD_TYPE_RADIO_BUTTON: BlitBitmapOnBackground(gd->bitmap, drawto, @@ -828,6 +829,7 @@ static void DrawGadget_OverlayTouchButton(struct GadgetInfo *gi) { case GD_TYPE_NORMAL_BUTTON: case GD_TYPE_CHECK_BUTTON: + case GD_TYPE_CHECK_BUTTON_2: case GD_TYPE_RADIO_BUTTON: SDL_SetTextureAlphaMod(gd->bitmap->texture_masked, alpha); SDL_SetTextureBlendMode(gd->bitmap->texture_masked, SDL_BLENDMODE_BLEND); @@ -2158,7 +2160,11 @@ boolean HandleGadgets(int mx, int my, int button) boolean deactivate_gadget = TRUE; boolean gadget_changed = TRUE; - if (gi->type & GD_TYPE_SELECTBOX) + if (gi->type == GD_TYPE_CHECK_BUTTON_2) + { + gi->checked = !gi->checked; + } + else if (gi->type & GD_TYPE_SELECTBOX) { if (keep_selectbox_open || mouse_released_where_pressed || diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index aaf4de16..b2b43588 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -22,18 +22,20 @@ #define GD_TYPE_NORMAL_BUTTON (1 << 0) #define GD_TYPE_TEXT_BUTTON (1 << 1) #define GD_TYPE_CHECK_BUTTON (1 << 2) -#define GD_TYPE_RADIO_BUTTON (1 << 3) -#define GD_TYPE_DRAWING_AREA (1 << 4) -#define GD_TYPE_TEXT_INPUT_ALPHANUMERIC (1 << 5) -#define GD_TYPE_TEXT_INPUT_NUMERIC (1 << 6) -#define GD_TYPE_TEXT_AREA (1 << 7) -#define GD_TYPE_SELECTBOX (1 << 8) -#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 9) -#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 10) +#define GD_TYPE_CHECK_BUTTON_2 (1 << 3) +#define GD_TYPE_RADIO_BUTTON (1 << 4) +#define GD_TYPE_DRAWING_AREA (1 << 5) +#define GD_TYPE_TEXT_INPUT_ALPHANUMERIC (1 << 6) +#define GD_TYPE_TEXT_INPUT_NUMERIC (1 << 7) +#define GD_TYPE_TEXT_AREA (1 << 8) +#define GD_TYPE_SELECTBOX (1 << 9) +#define GD_TYPE_SCROLLBAR_VERTICAL (1 << 10) +#define GD_TYPE_SCROLLBAR_HORIZONTAL (1 << 11) #define GD_TYPE_BUTTON (GD_TYPE_NORMAL_BUTTON | \ GD_TYPE_TEXT_BUTTON | \ GD_TYPE_CHECK_BUTTON | \ + GD_TYPE_CHECK_BUTTON_2 | \ GD_TYPE_RADIO_BUTTON) #define GD_TYPE_SCROLLBAR (GD_TYPE_SCROLLBAR_VERTICAL | \ GD_TYPE_SCROLLBAR_HORIZONTAL)