X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=9dfea83896e25a33d61c3a90899d8e28e40a158d;hb=14089dac2cbe56e563863e1e5adb8847944fd262;hp=e34c245ba802847743eb2edaf6615625d045f059;hpb=4f99eecc06f270aa3c8f536c0b3813c743d19ef5;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index e34c245b..9dfea838 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -117,8 +117,9 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) case GD_TYPE_NORMAL_BUTTON: case GD_TYPE_CHECK_BUTTON: case GD_TYPE_RADIO_BUTTON: - BlitBitmap(gd->bitmap, drawto, - gd->x, gd->y, gi->width, gi->height, gi->x, gi->y); + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x, gd->y, gi->width, gi->height, + gi->x, gi->y); if (gi->deco.design.bitmap) BlitBitmap(gi->deco.design.bitmap, drawto, gi->deco.design.x, gi->deco.design.y, @@ -156,7 +157,9 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) border, gi->height, gi->x + gi->width - border, gi->y); /* gadget text value */ - DrawText(gi->x + border, gi->y + border, text, FS_SMALL, font_type); + DrawTextExt(drawto, + gi->x + border, gi->y + border, text, + FS_SMALL, font_type, FONT_OPAQUE); cursor_letter = gi->text.value[gi->text.cursor_position]; cursor_string[0] = '~'; @@ -165,8 +168,10 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) /* draw cursor, if active */ if (pressed) - DrawText(gi->x + border + gi->text.cursor_position * font_width, - gi->y + border, cursor_string, FS_SMALL, font_type); + DrawTextExt(drawto, + gi->x + border + gi->text.cursor_position * font_width, + gi->y + border, cursor_string, + FS_SMALL, font_type, FONT_OPAQUE); } break; @@ -183,33 +188,36 @@ static void DrawGadget(struct GadgetInfo *gi, boolean pressed, boolean direct) int step_size_remain = size_body - num_steps * design_body; /* clear scrollbar area */ - ClearRectangle(backbuffer, gi->x, gi->y, gi->width, gi->height); + ClearRectangleOnBackground(backbuffer, gi->x, gi->y, + gi->width, gi->height); /* upper part of gadget */ - BlitBitmap(gd->bitmap, drawto, - gd->x, gd->y, - gi->width, gi->border.size, - xpos, ypos); + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x, gd->y, + gi->width, gi->border.size, + xpos, ypos); /* middle part of gadget */ for (i=0; ibitmap, drawto, - gd->x, gd->y + gi->border.size, - gi->width, design_body, - xpos, ypos + gi->border.size + i * design_body); + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x, gd->y + gi->border.size, + gi->width, design_body, + xpos, ypos + gi->border.size + + i * design_body); /* remaining middle part of gadget */ if (step_size_remain > 0) - BlitBitmap(gd->bitmap, drawto, - gd->x, gd->y + gi->border.size, - gi->width, step_size_remain, - xpos, ypos + gi->border.size + num_steps * design_body); + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x, gd->y + gi->border.size, + gi->width, step_size_remain, + xpos, ypos + gi->border.size + + num_steps * design_body); /* lower part of gadget */ - BlitBitmap(gd->bitmap, drawto, - gd->x, gd->y + design_full - gi->border.size, - gi->width, gi->border.size, - xpos, ypos + size_full - gi->border.size); + BlitBitmapOnBackground(gd->bitmap, drawto, + gd->x, gd->y + design_full - gi->border.size, + gi->width, gi->border.size, + xpos, ypos + size_full - gi->border.size); } break; @@ -576,14 +584,14 @@ void RedrawGadget(struct GadgetInfo *gi) struct GadgetInfo *CreateGadget(int first_tag, ...) { - struct GadgetInfo *new_gadget = checked_malloc(sizeof(struct GadgetInfo)); + struct GadgetInfo *new_gadget = checked_calloc(sizeof(struct GadgetInfo)); va_list ap; /* always start with reliable default values */ - memset(new_gadget, 0, sizeof(struct GadgetInfo)); /* zero all fields */ new_gadget->id = getNewGadgetID(); new_gadget->callback_info = default_callback_info; new_gadget->callback_action = default_callback_action; + new_gadget->next = NULL; va_start(ap, first_tag); HandleGadgetTags(new_gadget, first_tag, ap); @@ -614,7 +622,9 @@ void FreeGadget(struct GadgetInfo *gi) if (gi == gadget_list_last_entry) gadget_list_last_entry = gi_previous; - gi_previous->next = gi->next; + if (gi_previous) + gi_previous->next = gi->next; + free(gi); }