From: Holger Schemel Date: Thu, 17 Dec 1998 00:12:05 +0000 (+0100) Subject: rnd-19981217-2 X-Git-Tag: 1.3.0^2~54 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=65e73b3607d8d4aef09abaf1f44d090197953f21;p=rocksndiamonds.git rnd-19981217-2 --- diff --git a/src/buttons.c b/src/buttons.c index c9c13480..7ac61e36 100644 --- a/src/buttons.c +++ b/src/buttons.c @@ -1810,6 +1810,7 @@ void HandleGadgets(int mx, int my, int button) gi->state = GD_BUTTON_PRESSED; gi->event.type = GD_EVENT_PRESSED; gi->event.button = button; + gi->event.off_borders = FALSE; /* initialize delay counter */ pressed_delay = 0; @@ -1833,7 +1834,7 @@ void HandleGadgets(int mx, int my, int button) gi->state = GD_BUTTON_PRESSED; gi->event.type = GD_EVENT_MOVING; - + gi->event.off_borders = FALSE; if (gi->event_mask & GD_EVENT_MOVING) gi->callback(gi); } @@ -1845,6 +1846,7 @@ void HandleGadgets(int mx, int my, int button) gi->state = GD_BUTTON_UNPRESSED; gi->event.type = GD_EVENT_MOVING; + gi->event.off_borders = TRUE; if (gi->event_mask & GD_EVENT_MOVING) gi->callback(gi); diff --git a/src/buttons.h b/src/buttons.h index 34797401..255c8243 100644 --- a/src/buttons.h +++ b/src/buttons.h @@ -330,6 +330,7 @@ struct GadgetEvent unsigned long type; /* event type */ int button; /* button number for button events */ int x, y; /* gadget position at event time */ + boolean off_borders; /* mouse pointer outside gadget? */ }; struct GadgetDrawingArea diff --git a/src/editor.c b/src/editor.c index 36003a11..88b7d7dc 100644 --- a/src/editor.c +++ b/src/editor.c @@ -1973,16 +1973,12 @@ static void RandomPlacement(int button) static void HandleDrawingAreas(struct GadgetInfo *gi) { static boolean started_inside_drawing_area = FALSE; - boolean inside_drawing_area; + boolean inside_drawing_area = !gi->event.off_borders; boolean button_press_event; boolean button_release_event; int new_element; int button = gi->event.button; - int mx = SX + gi->event.x * MINI_TILEX; - int my = SX + gi->event.y * MINI_TILEY; - int min_mx = SX, max_mx = SX + SXSIZE -1; - int min_my = SY, max_my = SY + SYSIZE -1; - int sx, sy; + int sx = gi->event.x, sy = gi->event.y; int lx, ly; int x, y; @@ -1992,13 +1988,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) button_press_event = (gi->event.type == GD_EVENT_PRESSED); button_release_event = (gi->event.type == GD_EVENT_RELEASED); - inside_drawing_area = - (mx >= min_mx && mx <= max_mx && my >= min_my && my <= max_my); - - mx = (mx < min_mx ? min_mx : mx > max_mx ? max_mx : mx); - my = (my < min_my ? min_my : my > max_my ? max_my : my); - sx = (mx - SX) / MINI_TILEX; - sy = (my - SY) / MINI_TILEY; + sx = (sx < 0 ? 0 : sx > 2*SCR_FIELDX - 1 ? 2*SCR_FIELDX - 1 : sx); + sy = (sy < 0 ? 0 : sy > 2*SCR_FIELDY - 1 ? 2*SCR_FIELDY - 1 : sy); lx = sx + level_xpos; ly = sy + level_ypos; @@ -2008,8 +1999,8 @@ static void HandleDrawingAreas(struct GadgetInfo *gi) if (!started_inside_drawing_area) return; - printf("%d,%d, %d,%d, %d,%d, %d,%d.\n", - gi->event.x, gi->event.y, mx, my, sx, sy, lx, ly); + printf("%d,%d, %d,%d, %d,%d.\n", + gi->event.x, gi->event.y, sx, sy, lx, ly); if ((!button && !button_release_event) || sx > lev_fieldx || sy > lev_fieldy ||