From cf1e926e371f91628a6048adc0d62f129a0d84ab Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 7 Jan 2009 17:40:17 +0000 Subject: [PATCH] (svn r14902) -Feature: Advanced setting to keep various building tools active, which are usually closed after placing an object. (planetmaker) --- src/airport_gui.cpp | 2 +- src/dock_gui.cpp | 4 ++-- src/industry_gui.cpp | 2 +- src/lang/english.txt | 1 + src/rail_gui.cpp | 10 +++++----- src/road_gui.cpp | 6 +++--- src/settings.cpp | 1 + src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/town_gui.cpp | 2 +- 10 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 4e6b7bce48..945d196d68 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -34,7 +34,7 @@ void CcBuildAirport(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index 1de5899b06..6c588bebe1 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -35,7 +35,7 @@ void CcBuildDocks(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_02_SPLAT, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } } @@ -215,7 +215,7 @@ struct BuildDocksToolbarWindow : Window { if (pt.x != -1) { switch (select_proc) { case DDSP_BUILD_BRIDGE: - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); extern void CcBuildBridge(bool success, TileIndex tile, uint32 p1, uint32 p2); DoCommandP(end_tile, start_tile, TRANSPORT_WATER << 15, CMD_BUILD_BRIDGE | CMD_MSG(STR_CAN_T_BUILD_AQUEDUCT_HERE), CcBuildBridge); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 06a12febc1..93a1121e1a 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -375,7 +375,7 @@ public: } /* If an industry has been built, just reset the cursor and the system */ - if (success) ResetObjectToPlace(); + if (success && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } virtual void OnTick() diff --git a/src/lang/english.txt b/src/lang/english.txt index 77b1c24938..9c61c1f5e4 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1139,6 +1139,7 @@ STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_FIRST :First available STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_LAST :Last available STR_CONFIG_PATCHES_DEFAULT_RAIL_TYPE_MOST_USED :Most used STR_CONFIG_PATCHES_SHOW_TRACK_RESERVATION :{LTBLUE}Show reserved tracks: {ORANGE}{STRING1} +STR_CONFIG_PATCHES_PERSISTENT_BUILDINGTOOLS :{LTBLUE}Keep building tools active after usage: {ORANGE}{STRING1} STR_CONFIG_PATCHES_ALWAYS_BUILD_INFRASTRUCTURE :{LTBLUE}Show building tools when no suitable vehicles are available: {ORANGE}{STRING1} STR_CONFIG_PATCHES_MAX_TRAINS :{LTBLUE}Max trains per player: {ORANGE}{STRING1} diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 9161bf5f2c..862707b1a9 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -142,7 +142,7 @@ void CcRailDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) DiagDirection dir = (DiagDirection)p2; SndPlayTileFx(SND_20_SPLAT_2, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); tile += TileOffsByDiagDir(dir); @@ -174,8 +174,8 @@ void CcStation(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_20_SPLAT_2, tile); - /* Only close the station builder window if the default station is chosen. */ - if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0) ResetObjectToPlace(); + /* Only close the station builder window if the default station and non persistent building is chosen. */ + if (_railstation.station_class == STAT_CLASS_DFLT && _railstation.station_type == 0 && !_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } } @@ -256,7 +256,7 @@ void CcBuildRailTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_20_SPLAT_2, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } else { SetRedErrorSquare(_build_tunnel_endtile); } @@ -707,7 +707,7 @@ struct BuildRailToolbarWindow : Window { switch (select_proc) { default: NOT_REACHED(); case DDSP_BUILD_BRIDGE: - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_RAIL, _cur_railtype); break; diff --git a/src/road_gui.cpp b/src/road_gui.cpp index 79a37d7236..902649df75 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -118,7 +118,7 @@ void CcBuildRoadTunnel(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_20_SPLAT_2, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } else { SetRedErrorSquare(_build_tunnel_endtile); } @@ -191,7 +191,7 @@ void CcRoadDepot(bool success, TileIndex tile, uint32 p1, uint32 p2) if (success) { DiagDirection dir = (DiagDirection)GB(p1, 0, 2); SndPlayTileFx(SND_1F_SPLAT, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); BuildRoadOutsideStation(tile, dir); /* For a drive-through road stop build connecting road for other entrance */ if (HasBit(p2, 1)) BuildRoadOutsideStation(tile, ReverseDiagDir(dir)); @@ -579,7 +579,7 @@ struct BuildRoadToolbarWindow : Window { switch (select_proc) { default: NOT_REACHED(); case DDSP_BUILD_BRIDGE: - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); ShowBuildBridgeWindow(start_tile, end_tile, TRANSPORT_ROAD, RoadTypeToRoadTypes(_cur_roadtype)); break; diff --git a/src/settings.cpp b/src/settings.cpp index 846e3312a9..731efa51c1 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1466,6 +1466,7 @@ const SettingDesc _patch_settings[] = { SDTC_VAR(gui.station_platlength, SLE_UINT8, S, 0, 5, 1, 7, 0, STR_NULL, NULL), SDTC_BOOL(gui.station_dragdrop, S, 0, true, STR_NULL, NULL), SDTC_BOOL(gui.station_show_coverage, S, 0, false, STR_NULL, NULL), + SDTC_BOOL(gui.persistent_buildingtools, S, 0, false, STR_CONFIG_PATCHES_PERSISTENT_BUILDINGTOOLS, NULL), SDTC_VAR(gui.console_backlog_timeout, SLE_UINT16, S, 0, 100, 10, 65500, 0, STR_NULL, NULL), SDTC_VAR(gui.console_backlog_length, SLE_UINT16, S, 0, 100, 10, 65500, 0, STR_NULL, NULL), diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 9e3a3f3913..94a9891f38 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -639,6 +639,7 @@ static const char *_patches_ui[] = { "gui.quick_goto", "gui.default_rail_type", "gui.always_build_infrastructure", + "gui.persistent_buildingtools", "gui.show_track_reservation", "gui.left_mouse_btn_scrolling", }; diff --git a/src/settings_type.h b/src/settings_type.h index 1adf9c504c..c51a5130b1 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -89,6 +89,7 @@ struct GUISettings { byte station_platlength; ///< the platform length, in tiles, for rail stations bool station_dragdrop; ///< whether drag and drop is enabled for stations bool station_show_coverage; ///< whether to highlight coverage area + bool persistent_buildingtools; ///< keep the building tools active after usage uint16 console_backlog_timeout; ///< the minimum amount of time items should be in the console backlog before they will be removed in ~3 seconds granularity. uint16 console_backlog_length; ///< the minimum amount of items in the console backlog before items will be removed. diff --git a/src/town_gui.cpp b/src/town_gui.cpp index c76556170e..cc6a617247 100644 --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -658,7 +658,7 @@ void CcBuildTown(bool success, TileIndex tile, uint32 p1, uint32 p2) { if (success) { SndPlayTileFx(SND_1F_SPLAT, tile); - ResetObjectToPlace(); + if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace(); } }