X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fgadgets.c;h=aaf01eb7e99d70c806f148697b08a82444d27b96;hb=6890bb7cb72e140f4b82f35217655ae6c5213fec;hp=a134b04921c77e6367249607564f5e6d071e9918;hpb=e2b2b44c56f55520c8cc43cf361c83a12e60f7b0;p=rocksndiamonds.git diff --git a/src/libgame/gadgets.c b/src/libgame/gadgets.c index a134b049..aaf01eb7 100644 --- a/src/libgame/gadgets.c +++ b/src/libgame/gadgets.c @@ -1717,7 +1717,7 @@ boolean HandleGadgets(int mx, int my, int button) if (gs->item_position < 0) gs->item_position = 0; - if (gs->item_position > gs->items_max - gs->items_visible) + else if (gs->item_position > gs->items_max - gs->items_visible) gs->item_position = gs->items_max - gs->items_visible; if (old_item_position != gs->item_position) @@ -1799,13 +1799,22 @@ boolean HandleGadgets(int mx, int my, int button) gs->position = scrollbar_mouse_pos - gs->drag_position; - if (gs->position < 0) + /* make sure to always precisely reach end positions when dragging */ + if (gs->position <= 0) + { gs->position = 0; - if (gs->position > gs->position_max) + gs->item_position = 0; + } + else if (gs->position >= gs->position_max) + { gs->position = gs->position_max; - - gs->item_position = - gs->items_max * (gs->position + gs->correction) / gs->size_max_cmp; + gs->item_position = gs->items_max - gs->items_visible; + } + else + { + gs->item_position = + gs->items_max * (gs->position + gs->correction) / gs->size_max_cmp; + } if (gs->item_position < 0) gs->item_position = 0;