X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=77eb4718d0c7f049a5be0ea1f372627820fc91d3;hb=dce27fe1c087a26e6dac4ef6367012c51810f327;hp=aeb5ec9cbeee81e88136c84a43d63fa0c2d338ac;hpb=49221e59bff18cdfbef8c877b588280266ae5037;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index aeb5ec9c..77eb4718 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1,25 +1,22 @@ /*********************************************************** -* Rocks'n'Diamonds -- McDuffin Strikes Back! * +* Artsoft Retro-Game Library * *----------------------------------------------------------* -* (c) 1995-98 Artsoft Entertainment * -* Holger Schemel * -* Oststrasse 11a * -* 33604 Bielefeld * -* phone: ++49 +521 290471 * -* email: aeglos@valinor.owl.de * +* (c) 1994-2002 Artsoft Entertainment * +* Holger Schemel * +* Detmolder Strasse 189 * +* 33604 Bielefeld * +* Germany * +* e-mail: info@artsoft.org * *----------------------------------------------------------* -* gadgets.c * +* gadgets.c * ***********************************************************/ #include - -#include "libgame.h" - -#if 0 -#include "main_TMP.h" -#endif +#include #include "gadgets.h" +#include "text.h" +#include "misc.h" /* values for DrawGadget() */ @@ -66,6 +63,21 @@ static int getNewGadgetID() return id; } +#if 0 +void DUMP_GADGET_MAP_STATE() +{ + struct GadgetInfo *gi = gadget_list_first_entry; + + while (gi) + { + printf("-XXX-1-> '%s': %s\n", + gi->info_text, (gi->mapped ? "mapped" : "not mapped")); + + gi = gi->next; + } +} +#endif + static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my) { struct GadgetInfo *gi = gadget_list_first_entry; @@ -85,11 +97,6 @@ static struct GadgetInfo *getGadgetInfoFromMousePosition(int mx, int my) static void default_callback_info(void *ptr) { -#if 0 - if (game_status == LEVELED) - HandleEditorGadgetInfoText(ptr); -#endif - return; } @@ -312,7 +319,9 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) break; case GDI_CHECKED: - gi->checked = va_arg(ap, boolean); + /* take care here: "boolean" is typedef'ed as "unsigned char", + which gets promoted to "int" */ + gi->checked = (boolean)va_arg(ap, int); break; case GDI_RADIO_NR: @@ -371,25 +380,25 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) break; case GDI_DESIGN_UNPRESSED: - gi->design[GD_BUTTON_UNPRESSED].bitmap = va_arg(ap, Bitmap); + gi->design[GD_BUTTON_UNPRESSED].bitmap = va_arg(ap, Bitmap *); gi->design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int); gi->design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int); break; case GDI_DESIGN_PRESSED: - gi->design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap); + gi->design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap *); gi->design[GD_BUTTON_PRESSED].x = va_arg(ap, int); gi->design[GD_BUTTON_PRESSED].y = va_arg(ap, int); break; case GDI_ALT_DESIGN_UNPRESSED: - gi->alt_design[GD_BUTTON_UNPRESSED].bitmap= va_arg(ap, Bitmap); + gi->alt_design[GD_BUTTON_UNPRESSED].bitmap= va_arg(ap, Bitmap *); gi->alt_design[GD_BUTTON_UNPRESSED].x = va_arg(ap, int); gi->alt_design[GD_BUTTON_UNPRESSED].y = va_arg(ap, int); break; case GDI_ALT_DESIGN_PRESSED: - gi->alt_design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap); + gi->alt_design[GD_BUTTON_PRESSED].bitmap = va_arg(ap, Bitmap *); gi->alt_design[GD_BUTTON_PRESSED].x = va_arg(ap, int); gi->alt_design[GD_BUTTON_PRESSED].y = va_arg(ap, int); break; @@ -403,7 +412,7 @@ static void HandleGadgetTags(struct GadgetInfo *gi, int first_tag, va_list ap) break; case GDI_DECORATION_DESIGN: - gi->deco.design.bitmap = va_arg(ap, Bitmap); + gi->deco.design.bitmap = va_arg(ap, Bitmap *); gi->deco.design.x = va_arg(ap, int); gi->deco.design.y = va_arg(ap, int); break; @@ -852,15 +861,27 @@ void HandleGadgets(int mx, int my, int button) if (last_info_gi != new_gi || (new_gi && new_gi->type == GD_TYPE_DRAWING_AREA && changed_position)) { - last_info_gi = new_gi; - if (new_gi != NULL && (button == 0 || new_gi == last_gi)) { - new_gi->event.type = 0; + new_gi->event.type = GD_EVENT_INFO_ENTERING; new_gi->callback_info(new_gi); } - else + else if (last_info_gi != NULL) + { + last_info_gi->event.type = GD_EVENT_INFO_LEAVING; + last_info_gi->callback_info(last_info_gi); + +#if 0 default_callback_info(NULL); + + printf("It seems that we are leaving gadget [%s]!\n", + (last_info_gi != NULL && + last_info_gi->info_text != NULL ? + last_info_gi->info_text : "")); +#endif + } + + last_info_gi = new_gi; } if (gadget_pressed)