Fix left mouse button scroll in viewport map mode

pull/217/head
Jonathan G Rennison 3 years ago
parent b8c3bee8b0
commit e75e2b5bdc

@ -4215,15 +4215,15 @@ bool HandleViewportDoubleClicked(Window *w, int x, int y)
}
}
bool HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click)
HandleViewportClickedResult HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click)
{
/* No click in smallmap mode except for plan making. */
if (vp->zoom >= ZOOM_LVL_DRAW_MAP && !(_thd.place_mode & HT_MAP)) return true;
/* No click in smallmap mode except for plan making and left-button scrolling. */
if (vp->zoom >= ZOOM_LVL_DRAW_MAP && !(_thd.place_mode & HT_MAP)) return HVCR_SCROLL_ONLY;
const Vehicle *v = CheckClickOnVehicle(vp, x, y);
if (_thd.place_mode & HT_VEHICLE) {
if (v != nullptr && VehicleClicked(v)) return true;
if (v != nullptr && VehicleClicked(v)) return HVCR_DENY;
}
/* Vehicle placement mode already handled above. */
@ -4235,18 +4235,18 @@ bool HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click)
static bool stop_snap_on_double_click = false;
if (double_click && stop_snap_on_double_click) {
SetRailSnapMode(RSM_NO_SNAP);
return true;
return HVCR_DENY;
}
stop_snap_on_double_click = !(_thd.drawstyle & HT_LINE) || (_thd.dir2 == HT_DIR_END);
}
PlaceObject();
return true;
return HVCR_DENY;
}
if (vp->zoom >= ZOOM_LVL_DRAW_MAP) return true;
if (vp->zoom >= ZOOM_LVL_DRAW_MAP) return HVCR_SCROLL_ONLY;
if (CheckClickOnViewportSign(vp, x, y)) return true;
if (CheckClickOnViewportSign(vp, x, y)) return HVCR_DENY;
bool result = CheckClickOnLandscape(vp, x, y);
if (v != nullptr) {
@ -4260,9 +4260,9 @@ bool HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click)
ShowVehicleViewWindow(v);
}
}
return true;
return HVCR_DENY;
}
return result;
return result ? HVCR_DENY : HVCR_ALLOW;
}
void RebuildViewportOverlay(Window *w, bool incremental)

@ -75,8 +75,14 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie
void StartSpriteCombine();
void EndSpriteCombine();
enum HandleViewportClickedResult {
HVCR_DENY,
HVCR_SCROLL_ONLY,
HVCR_ALLOW,
};
bool HandleViewportDoubleClicked(Window *w, int x, int y);
bool HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click);
HandleViewportClickedResult HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click);
void SetRedErrorSquare(TileIndex tile);
void SetTileSelectSize(int w, int h);
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);

@ -2995,15 +2995,18 @@ static void MouseLoop(MouseClick click, int mousewheel)
case MC_DOUBLE_LEFT:
if (HandleViewportDoubleClicked(w, x, y)) break;
/* FALL THROUGH */
case MC_LEFT:
if (HandleViewportClicked(vp, x, y, click == MC_DOUBLE_LEFT)) return;
case MC_LEFT: {
HandleViewportClickedResult result = HandleViewportClicked(vp, x, y, click == MC_DOUBLE_LEFT);
if (result == HVCR_DENY) return;
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
_settings_client.gui.scroll_mode == VSM_MAP_LMB) {
_scrolling_viewport = w;
_cursor.fix_at = false;
return;
}
if (result != HVCR_ALLOW) return;
break;
}
case MC_RIGHT:
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&

Loading…
Cancel
Save