From 969b64ecce695a468b80108184194be0a2c1ae6d Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Fri, 17 Feb 2023 20:02:53 +0100 Subject: [PATCH] added functions for setting and getting screen borders for gadgets --- src/editor.c | 2 ++ src/libgame/gadgets.c | 28 +++++++++++++++++++++++++++- src/libgame/gadgets.h | 1 + 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/src/editor.c b/src/editor.c index ab9b1c00..b202aaf8 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7315,6 +7315,8 @@ void CreateLevelEditorGadgets(void) use_permanent_palette = !editor.palette.show_as_separate_screen; + InitGadgetScreenBorders(-1, INFOTEXT_YPOS); + ReinitializeElementList(); CreateControlButtons(); diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index 89eb0081..0f221a73 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -38,6 +38,8 @@ static struct GadgetInfo *gadget_list_last_entry = NULL; static struct GadgetInfo *last_info_gi = NULL; static int next_free_gadget_id = 1; static boolean gadget_id_wrapped = FALSE; +static int gadget_screen_border_right = -1; +static int gadget_screen_border_bottom = -1; static void (*PlayGadgetSoundActivating)(void) = NULL; static void (*PlayGadgetSoundSelecting)(void) = NULL; @@ -50,6 +52,30 @@ void InitGadgetsSoundCallback(void (*activating_function)(void), PlayGadgetSoundSelecting = selecting_function; } +void InitGadgetScreenBorders(int border_right, int border_bottom) +{ + gadget_screen_border_right = border_right; + gadget_screen_border_bottom = border_bottom; +} + +static int getGadgetScreenBorderRight(void) +{ + if (gadget_screen_border_right < gfx.sx || + gadget_screen_border_right > gfx.sx + gfx.sxsize) + return gfx.sx + gfx.sxsize; + + return gadget_screen_border_right; +} + +static int getGadgetScreenBorderBottom(void) +{ + if (gadget_screen_border_bottom < gfx.sy || + gadget_screen_border_bottom > gfx.sy + gfx.sysize) + return gfx.sy + gfx.sysize; + + return gadget_screen_border_bottom; +} + static struct GadgetInfo *getGadgetInfoFromGadgetID(int id) { struct GadgetInfo *gi = gadget_list_first_entry; @@ -1262,7 +1288,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) int border_xsize = gi->border.xsize; int border_ysize = gi->border.ysize; int button_size = gi->border.xsize_selectbutton; - int bottom_screen_border = gfx.sy + gfx.sysize - font_height; + int bottom_screen_border = getGadgetScreenBorderBottom(); Bitmap *src_bitmap; int src_x, src_y; diff --git a/src/libgame/gadgets.h b/src/libgame/gadgets.h index b2b43588..ad9e939c 100644 --- a/src/libgame/gadgets.h +++ b/src/libgame/gadgets.h @@ -276,6 +276,7 @@ struct GadgetInfo void InitGadgetsSoundCallback(void (*activating_function)(void), void (*selecting_function)(void)); +void InitGadgetScreenBorders(int, int); struct GadgetInfo *CreateGadget(int, ...); void FreeGadget(struct GadgetInfo *); -- 2.34.1