summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/clear_cmd.cpp3
-rw-r--r--src/dummy_land.cpp3
-rw-r--r--src/industry_cmd.cpp3
-rw-r--r--src/landscape.cpp4
-rw-r--r--src/lang/english.txt2
-rw-r--r--src/rail_cmd.cpp8
-rw-r--r--src/road_cmd.cpp7
-rw-r--r--src/settings.cpp1
-rw-r--r--src/settings_gui.cpp1
-rw-r--r--src/settings_type.h1
-rw-r--r--src/station_cmd.cpp3
-rw-r--r--src/tile_cmd.h4
-rw-r--r--src/town_cmd.cpp3
-rw-r--r--src/tree_cmd.cpp3
-rw-r--r--src/tunnelbridge_cmd.cpp3
-rw-r--r--src/unmovable_cmd.cpp7
-rw-r--r--src/viewport.cpp17
-rw-r--r--src/viewport_func.h2
-rw-r--r--src/water_cmd.cpp4
-rw-r--r--src/window.cpp11
20 files changed, 59 insertions, 31 deletions
diff --git a/src/clear_cmd.cpp b/src/clear_cmd.cpp
index 74687f5f0..8b9a6edef 100644
--- a/src/clear_cmd.cpp
+++ b/src/clear_cmd.cpp
@@ -310,9 +310,10 @@ get_out:;
} while (--i);
}
-static void ClickTile_Clear(TileIndex tile)
+static bool ClickTile_Clear(TileIndex tile)
{
/* not used */
+ return false;
}
static TrackStatus GetTileTrackStatus_Clear(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
diff --git a/src/dummy_land.cpp b/src/dummy_land.cpp
index 67eac6214..de244f99b 100644
--- a/src/dummy_land.cpp
+++ b/src/dummy_land.cpp
@@ -54,9 +54,10 @@ static void TileLoop_Dummy(TileIndex tile)
/* not used */
}
-static void ClickTile_Dummy(TileIndex tile)
+static bool ClickTile_Dummy(TileIndex tile)
{
/* not used */
+ return false;
}
static void ChangeTileOwner_Dummy(TileIndex tile, Owner old_owner, Owner new_owner)
diff --git a/src/industry_cmd.cpp b/src/industry_cmd.cpp
index e930dde3f..413a3aa81 100644
--- a/src/industry_cmd.cpp
+++ b/src/industry_cmd.cpp
@@ -837,9 +837,10 @@ static void TileLoop_Industry(TileIndex tile)
}
}
-static void ClickTile_Industry(TileIndex tile)
+static bool ClickTile_Industry(TileIndex tile)
{
ShowIndustryViewWindow(GetIndustryIndex(tile));
+ return true;
}
static TrackStatus GetTileTrackStatus_Industry(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
diff --git a/src/landscape.cpp b/src/landscape.cpp
index 95e602651..9bcedcdc1 100644
--- a/src/landscape.cpp
+++ b/src/landscape.cpp
@@ -519,9 +519,9 @@ void AnimateTile(TileIndex tile)
_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile);
}
-void ClickTile(TileIndex tile)
+bool ClickTile(TileIndex tile)
{
- _tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
+ return _tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
}
void GetTileDesc(TileIndex tile, TileDesc *td)
diff --git a/src/lang/english.txt b/src/lang/english.txt
index d8634e326..68afbcf1d 100644
--- a/src/lang/english.txt
+++ b/src/lang/english.txt
@@ -1126,6 +1126,8 @@ STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_COMMAND :Command-click
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_CONTROL :Control-click
STR_CONFIG_PATCHES_RIGHT_MOUSE_BTN_EMU_OFF :Off
+STR_CONFIG_PATCHES_LEFT_MOUSE_BTN_SCROLLING :{LTBLUE}Left-click scrolling: {ORANGE}{STRING1}
+
STR_CONFIG_PATCHES_PAUSE_ON_NEW_GAME :{LTBLUE}Automatically pause when starting a new game: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS :{LTBLUE}Use the advanced vehicle list: {ORANGE}{STRING1}
STR_CONFIG_PATCHES_ADVANCED_VEHICLE_LISTS_OFF :Off
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index eb2d4dc70..72383777d 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -2332,12 +2332,12 @@ static TrackStatus GetTileTrackStatus_Track(TileIndex tile, TransportType mode,
return CombineTrackStatus(TrackBitsToTrackdirBits(trackbits), red_signals);
}
-static void ClickTile_Track(TileIndex tile)
+static bool ClickTile_Track(TileIndex tile)
{
switch (GetRailTileType(tile)) {
- case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); break;
- case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); break;
- default: break;
+ case RAIL_TILE_DEPOT: ShowDepotWindow(tile, VEH_TRAIN); return true;
+ case RAIL_TILE_WAYPOINT: ShowWaypointWindow(GetWaypointByTile(tile)); return true;
+ default: return false;
}
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index aae3f934f..cb4595bd6 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1430,9 +1430,12 @@ static void TileLoop_Road(TileIndex tile)
}
}
-static void ClickTile_Road(TileIndex tile)
+static bool ClickTile_Road(TileIndex tile)
{
- if (IsRoadDepot(tile)) ShowDepotWindow(tile, VEH_ROAD);
+ if (!IsRoadDepot(tile)) return false;
+
+ ShowDepotWindow(tile, VEH_ROAD);
+ return true;
}
/* Converts RoadBits to TrackBits */
diff --git a/src/settings.cpp b/src/settings.cpp
index 19d3aa7f6..bba8587a0 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -1424,6 +1424,7 @@ const SettingDesc _patch_settings[] = {
SDTC_BOOL(gui.autoscroll, S, 0, false, STR_CONFIG_PATCHES_AUTOSCROLL, NULL),
SDTC_BOOL(gui.reverse_scroll, S, 0, false, STR_CONFIG_PATCHES_REVERSE_SCROLLING, NULL),
SDTC_BOOL(gui.smooth_scroll, S, 0, false, STR_CONFIG_PATCHES_SMOOTH_SCROLLING, NULL),
+ SDTC_BOOL(gui.left_mouse_btn_scrolling, S, 0, false, STR_CONFIG_PATCHES_LEFT_MOUSE_BTN_SCROLLING, NULL),
SDTC_BOOL(gui.measure_tooltip, S, 0, false, STR_CONFIG_PATCHES_MEASURE_TOOLTIP, NULL),
SDTC_VAR(gui.errmsg_duration, SLE_UINT8, S, 0, 5, 0, 20, 0, STR_CONFIG_PATCHES_ERRMSG_DURATION, NULL),
SDTC_VAR(gui.toolbar_pos, SLE_UINT8, S, MS, 0, 0, 2, 0, STR_CONFIG_PATCHES_TOOLBAR_POS, v_PositionMainToolbar),
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 08fe287ca..c939d5f64 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -614,6 +614,7 @@ static const char *_patches_ui[] = {
"gui.default_rail_type",
"gui.always_build_infrastructure",
"gui.show_track_reservation",
+ "gui.left_mouse_btn_scrolling",
};
static const char *_patches_construction[] = {
diff --git a/src/settings_type.h b/src/settings_type.h
index 0c9d366b3..1414f5537 100644
--- a/src/settings_type.h
+++ b/src/settings_type.h
@@ -66,6 +66,7 @@ struct GUISettings {
uint8 right_mouse_btn_emulation; ///< should we emulate right mouse clicking?
uint8 scrollwheel_scrolling; ///< scrolling using the scroll wheel?
uint8 scrollwheel_multiplier; ///< how much 'wheel' per incoming event from the OS?
+ bool left_mouse_btn_scrolling; ///< left mouse button scroll
bool pause_on_newgame; ///< whether to start new games paused or not
bool enable_signal_gui; ///< show the signal GUI when the signal button is pressed
Year colored_news_year; ///< when does newspaper become colored?
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 0026b0a11..1923ebd61 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2569,13 +2569,14 @@ static void AnimateTile_Station(TileIndex tile)
}
-static void ClickTile_Station(TileIndex tile)
+static bool ClickTile_Station(TileIndex tile)
{
if (IsHangar(tile)) {
ShowDepotWindow(tile, VEH_AIRCRAFT);
} else {
ShowStationViewWindow(GetStationIndex(tile));
}
+ return true;
}
static VehicleEnterTileStatus VehicleEnter_Station(Vehicle *v, TileIndex tile, int x, int y)
diff --git a/src/tile_cmd.h b/src/tile_cmd.h
index 5baa3fa25..c7a09eb79 100644
--- a/src/tile_cmd.h
+++ b/src/tile_cmd.h
@@ -103,7 +103,7 @@ typedef TrackStatus GetTileTrackStatusProc(TileIndex tile, TransportType mode, u
* @param b Destination array of produced cargo
*/
typedef void GetProducedCargoProc(TileIndex tile, CargoID *b);
-typedef void ClickTileProc(TileIndex tile);
+typedef bool ClickTileProc(TileIndex tile);
typedef void AnimateTileProc(TileIndex tile);
typedef void TileLoopProc(TileIndex tile);
typedef void ChangeTileOwnerProc(TileIndex tile, Owner old_owner, Owner new_owner);
@@ -156,7 +156,7 @@ VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y
void GetAcceptedCargo(TileIndex tile, AcceptedCargo ac);
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
void AnimateTile(TileIndex tile);
-void ClickTile(TileIndex tile);
+bool ClickTile(TileIndex tile);
void GetTileDesc(TileIndex tile, TileDesc *td);
#endif /* TILE_CMD_H */
diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp
index d91b941d0..e37e331c1 100644
--- a/src/town_cmd.cpp
+++ b/src/town_cmd.cpp
@@ -522,9 +522,10 @@ static void TileLoop_Town(TileIndex tile)
* Dummy tile callback function for handling tile clicks in towns
* @param tile unused
*/
-static void ClickTile_Town(TileIndex tile)
+static bool ClickTile_Town(TileIndex tile)
{
/* not used */
+ return false;
}
static CommandCost ClearTile_Town(TileIndex tile, byte flags)
diff --git a/src/tree_cmd.cpp b/src/tree_cmd.cpp
index 733b05923..9526a4dff 100644
--- a/src/tree_cmd.cpp
+++ b/src/tree_cmd.cpp
@@ -744,9 +744,10 @@ void OnTick_Trees()
}
}
-static void ClickTile_Trees(TileIndex tile)
+static bool ClickTile_Trees(TileIndex tile)
{
/* not used */
+ return false;
}
static TrackStatus GetTileTrackStatus_Trees(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side)
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp
index baf8700d3..4af0315be 100644
--- a/src/tunnelbridge_cmd.cpp
+++ b/src/tunnelbridge_cmd.cpp
@@ -1282,9 +1282,10 @@ static void TileLoop_TunnelBridge(TileIndex tile)
}
}
-static void ClickTile_TunnelBridge(TileIndex tile)
+static bool ClickTile_TunnelBridge(TileIndex tile)
{
/* not used */
+ return false;
}
diff --git a/src/unmovable_cmd.cpp b/src/unmovable_cmd.cpp
index 063df456a..e2efec469 100644
--- a/src/unmovable_cmd.cpp
+++ b/src/unmovable_cmd.cpp
@@ -355,9 +355,12 @@ static TrackStatus GetTileTrackStatus_Unmovable(TileIndex tile, TransportType mo
return 0;
}
-static void ClickTile_Unmovable(TileIndex tile)
+static bool ClickTile_Unmovable(TileIndex tile)
{
- if (IsCompanyHQ(tile)) ShowCompany(GetTileOwner(tile));
+ if (!IsCompanyHQ(tile)) return false;
+
+ ShowCompany(GetTileOwner(tile));
+ return true;
}
diff --git a/src/viewport.cpp b/src/viewport.cpp
index a35c00fe4..a6cacd24b 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -1986,11 +1986,12 @@ static bool CheckClickOnWaypoint(const ViewPort *vp, int x, int y)
}
-static void CheckClickOnLandscape(const ViewPort *vp, int x, int y)
+static bool CheckClickOnLandscape(const ViewPort *vp, int x, int y)
{
Point pt = TranslateXYToTileCoord(vp, x, y);
- if (pt.x != -1) ClickTile(TileVirtXY(pt.x, pt.y));
+ if (pt.x != -1) return ClickTile(TileVirtXY(pt.x, pt.y));
+ return true;
}
@@ -2018,21 +2019,23 @@ static OnVehicleClickProc* const _on_vehicle_click_proc[] = {
Nop // Disaster vehicles
};
-void HandleViewportClicked(const ViewPort *vp, int x, int y)
+bool HandleViewportClicked(const ViewPort *vp, int x, int y)
{
const Vehicle *v;
- if (CheckClickOnTown(vp, x, y)) return;
- if (CheckClickOnStation(vp, x, y)) return;
- if (CheckClickOnSign(vp, x, y)) return;
- if (CheckClickOnWaypoint(vp, x, y)) return;
+ if (CheckClickOnTown(vp, x, y)) return true;
+ if (CheckClickOnStation(vp, x, y)) return true;
+ if (CheckClickOnSign(vp, x, y)) return true;
+ if (CheckClickOnWaypoint(vp, x, y)) return true;
CheckClickOnLandscape(vp, x, y);
v = CheckClickOnVehicle(vp, x, y);
if (v != NULL) {
DEBUG(misc, 2, "Vehicle %d (index %d) at %p", v->unitnumber, v->index, v);
_on_vehicle_click_proc[v->type](v);
+ return true;
}
+ return CheckClickOnLandscape(vp, x, y);
}
Vehicle *CheckMouseOverVehicle()
diff --git a/src/viewport_func.h b/src/viewport_func.h
index f5a87d06f..9523c895f 100644
--- a/src/viewport_func.h
+++ b/src/viewport_func.h
@@ -43,7 +43,7 @@ void AddChildSpriteScreen(SpriteID image, SpriteID pal, int x, int y, bool trans
void StartSpriteCombine();
void EndSpriteCombine();
-void HandleViewportClicked(const ViewPort *vp, int x, int y);
+bool HandleViewportClicked(const ViewPort *vp, int x, int y);
void PlaceObject();
void SetRedErrorSquare(TileIndex tile);
void SetTileSelectSize(int w, int h);
diff --git a/src/water_cmd.cpp b/src/water_cmd.cpp
index cd4125c95..0c7907f20 100644
--- a/src/water_cmd.cpp
+++ b/src/water_cmd.cpp
@@ -1204,13 +1204,15 @@ static TrackStatus GetTileTrackStatus_Water(TileIndex tile, TransportType mode,
return CombineTrackStatus(TrackBitsToTrackdirBits(ts), TRACKDIR_BIT_NONE);
}
-static void ClickTile_Water(TileIndex tile)
+static bool ClickTile_Water(TileIndex tile)
{
if (GetWaterTileType(tile) == WATER_TILE_DEPOT) {
TileIndex tile2 = GetOtherShipDepotTile(tile);
ShowDepotWindow(tile < tile2 ? tile : tile2, VEH_SHIP);
+ return true;
}
+ return false;
}
static void ChangeTileOwner_Water(TileIndex tile, Owner old_owner, Owner new_owner)
diff --git a/src/window.cpp b/src/window.cpp
index 8b4d92ba2..c0911561c 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1581,7 +1581,7 @@ static bool HandleViewportScroll()
Window *w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y);
- if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) {
+ if (!(_right_button_down || scrollwheel_scrolling || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down)) || w == NULL) {
_cursor.fix_at = false;
_scrolling_viewport = false;
return true;
@@ -1595,7 +1595,7 @@ static bool HandleViewportScroll()
}
Point delta;
- if (_settings_client.gui.reverse_scroll) {
+ if (_settings_client.gui.reverse_scroll || (_settings_client.gui.left_mouse_btn_scrolling && _left_button_down)) {
delta.x = -_cursor.delta.x;
delta.y = -_cursor.delta.y;
} else {
@@ -1915,7 +1915,12 @@ void MouseLoop(MouseClick click, int mousewheel)
}
if (_thd.place_mode == VHM_NONE) {
- HandleViewportClicked(vp, x, y);
+ if (!HandleViewportClicked(vp, x, y) &&
+ !(w->flags4 & WF_DISABLE_VP_SCROLL) &&
+ _settings_client.gui.left_mouse_btn_scrolling) {
+ _scrolling_viewport = true;
+ _cursor.fix_at = false;
+ }
} else {
PlaceObject();
}