Fix left mouse button scroll in viewport map mode
This commit is contained in:
@@ -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. */
|
/* 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 true;
|
if (vp->zoom >= ZOOM_LVL_DRAW_MAP && !(_thd.place_mode & HT_MAP)) return HVCR_SCROLL_ONLY;
|
||||||
|
|
||||||
const Vehicle *v = CheckClickOnVehicle(vp, x, y);
|
const Vehicle *v = CheckClickOnVehicle(vp, x, y);
|
||||||
|
|
||||||
if (_thd.place_mode & HT_VEHICLE) {
|
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. */
|
/* 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;
|
static bool stop_snap_on_double_click = false;
|
||||||
if (double_click && stop_snap_on_double_click) {
|
if (double_click && stop_snap_on_double_click) {
|
||||||
SetRailSnapMode(RSM_NO_SNAP);
|
SetRailSnapMode(RSM_NO_SNAP);
|
||||||
return true;
|
return HVCR_DENY;
|
||||||
}
|
}
|
||||||
stop_snap_on_double_click = !(_thd.drawstyle & HT_LINE) || (_thd.dir2 == HT_DIR_END);
|
stop_snap_on_double_click = !(_thd.drawstyle & HT_LINE) || (_thd.dir2 == HT_DIR_END);
|
||||||
}
|
}
|
||||||
|
|
||||||
PlaceObject();
|
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);
|
bool result = CheckClickOnLandscape(vp, x, y);
|
||||||
|
|
||||||
if (v != nullptr) {
|
if (v != nullptr) {
|
||||||
@@ -4260,9 +4260,9 @@ bool HandleViewportClicked(const Viewport *vp, int x, int y, bool double_click)
|
|||||||
ShowVehicleViewWindow(v);
|
ShowVehicleViewWindow(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return HVCR_DENY;
|
||||||
}
|
}
|
||||||
return result;
|
return result ? HVCR_DENY : HVCR_ALLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RebuildViewportOverlay(Window *w, bool incremental)
|
void RebuildViewportOverlay(Window *w, bool incremental)
|
||||||
|
@@ -75,8 +75,14 @@ void ViewportAddString(const DrawPixelInfo *dpi, ZoomLevel small_from, const Vie
|
|||||||
void StartSpriteCombine();
|
void StartSpriteCombine();
|
||||||
void EndSpriteCombine();
|
void EndSpriteCombine();
|
||||||
|
|
||||||
|
enum HandleViewportClickedResult {
|
||||||
|
HVCR_DENY,
|
||||||
|
HVCR_SCROLL_ONLY,
|
||||||
|
HVCR_ALLOW,
|
||||||
|
};
|
||||||
|
|
||||||
bool HandleViewportDoubleClicked(Window *w, int x, int y);
|
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 SetRedErrorSquare(TileIndex tile);
|
||||||
void SetTileSelectSize(int w, int h);
|
void SetTileSelectSize(int w, int h);
|
||||||
void SetTileSelectBigSize(int ox, int oy, int sx, int sy);
|
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:
|
case MC_DOUBLE_LEFT:
|
||||||
if (HandleViewportDoubleClicked(w, x, y)) break;
|
if (HandleViewportDoubleClicked(w, x, y)) break;
|
||||||
/* FALL THROUGH */
|
/* FALL THROUGH */
|
||||||
case MC_LEFT:
|
case MC_LEFT: {
|
||||||
if (HandleViewportClicked(vp, x, y, click == MC_DOUBLE_LEFT)) return;
|
HandleViewportClickedResult result = HandleViewportClicked(vp, x, y, click == MC_DOUBLE_LEFT);
|
||||||
|
if (result == HVCR_DENY) return;
|
||||||
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
|
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
|
||||||
_settings_client.gui.scroll_mode == VSM_MAP_LMB) {
|
_settings_client.gui.scroll_mode == VSM_MAP_LMB) {
|
||||||
_scrolling_viewport = w;
|
_scrolling_viewport = w;
|
||||||
_cursor.fix_at = false;
|
_cursor.fix_at = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (result != HVCR_ALLOW) return;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MC_RIGHT:
|
case MC_RIGHT:
|
||||||
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
|
if (!(w->flags & WF_DISABLE_VP_SCROLL) &&
|
||||||
|
Reference in New Issue
Block a user