changeset 11072:19fd43d5975d draft

(svn r15413) -Fix [FS#2529/2533]: inconsistencies between station and bridge building w.r.t. tile selection and when the window should be closed.
author rubidium <rubidium@openttd.org>
date Sun, 08 Feb 2009 15:45:34 +0000
parents bb1fbf9e52ab
children 9f899b8c0460
files src/bridge_gui.cpp src/dock_gui.cpp src/rail_gui.cpp src/road_gui.cpp src/station_gui.cpp src/tilehighlight_type.h src/viewport.cpp
diffstat 7 files changed, 10 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/bridge_gui.cpp
+++ b/src/bridge_gui.cpp
@@ -124,6 +124,7 @@
 		type(br_type),
 		bridges(bl)
 	{
+		this->parent = FindWindowById(WC_BUILD_TOOLBAR, GB(this->type, 15, 2));
 		this->bridges->SetListing(this->last_sorting);
 		this->bridges->SetSortFuncs(this->sorter_funcs);
 		this->bridges->NeedResort();
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -244,6 +244,7 @@
 		delete FindWindowById(WC_BUILD_STATION, 0);
 		delete FindWindowById(WC_BUILD_DEPOT, 0);
 		delete FindWindowById(WC_SELECT_STATION, 0);
+		delete FindWindowById(WC_BUILD_BRIDGE, 0);
 	}
 
 	virtual void OnPlacePresize(Point pt, TileIndex tile_from)
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -746,6 +746,7 @@
 		delete FindWindowById(WC_BUILD_STATION, 0);
 		delete FindWindowById(WC_BUILD_DEPOT, 0);
 		delete FindWindowById(WC_SELECT_STATION, 0);
+		delete FindWindowById(WC_BUILD_BRIDGE, 0);
 	}
 
 	virtual void OnPlacePresize(Point pt, TileIndex tile)
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -530,6 +530,7 @@
 		delete FindWindowById(WC_TRUCK_STATION, 0);
 		delete FindWindowById(WC_BUILD_DEPOT, 0);
 		delete FindWindowById(WC_SELECT_STATION, 0);
+		delete FindWindowById(WC_BUILD_BRIDGE, 0);
 	}
 
 	virtual void OnPlaceDrag(ViewportPlaceMethod select_method, ViewportDragDropSelectionProcess select_proc, Point pt)
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -1129,20 +1129,12 @@
 	{
 		this->vscroll.cap = 6;
 		this->resize.step_height = 10;
-		_thd.lock_pos = true;
-		_thd.lock_size = true;
 
 		FindStationsNearby(this->tile, this->size_x, this->size_y, true);
 
 		this->FindWindowPlacementAndResize(desc);
 	}
 
-	~SelectStationWindow()
-	{
-		_thd.lock_pos = false;
-		_thd.lock_size = false;
-	}
-
 	virtual void OnPaint()
 	{
 		SetVScrollCount(this, _stations_nearby_list.Length() + 1);
@@ -1260,6 +1252,7 @@
 void ShowSelectStationIfNeeded(CommandContainer cmd, int w, int h)
 {
 	if (StationJoinerNeeded(cmd, w, h)) {
+		if (!_settings_client.gui.persistent_buildingtools) ResetObjectToPlace();
 		if (BringWindowToFrontById(WC_SELECT_STATION, 0)) return;
 		new SelectStationWindow(&_select_station_desc, cmd, w, h);
 	} else {
--- a/src/tilehighlight_type.h
+++ b/src/tilehighlight_type.h
@@ -71,9 +71,6 @@
 	ViewportPlaceMethod select_method;
 	ViewportDragDropSelectionProcess select_proc;
 
-	bool lock_pos;  //< If position changes are taken, or not
-	bool lock_size; //< If size changes are taken, or not
-
 	TileIndex redsq;
 };
 
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -2190,17 +2190,11 @@
 		/* clear the old selection? */
 		if (_thd.drawstyle) SetSelectionTilesDirty();
 
-		if (!_thd.lock_pos) {
-			_thd.pos = _thd.new_pos;
-			_thd.drawstyle = _thd.new_drawstyle;
-		}
-
-		if (!_thd.lock_size) {
-			_thd.size = _thd.new_size;
-			_thd.dirty = 0xff;
-		}
-
+		_thd.drawstyle = _thd.new_drawstyle;
+		_thd.pos = _thd.new_pos;
+		_thd.size = _thd.new_size;
 		_thd.outersize = _thd.new_outersize;
+		_thd.dirty = 0xff;
 
 		/* draw the new selection? */
 		if (_thd.new_drawstyle) SetSelectionTilesDirty();
@@ -2640,7 +2634,7 @@
 			y = sy + Clamp(y - sy, -limit, limit);
 			} /* Fallthrough */
 		case VPM_X_AND_Y: { /* drag an X by Y area */
-			if (_settings_client.gui.measure_tooltip && !_thd.lock_size) {
+			if (_settings_client.gui.measure_tooltip) {
 				static const StringID measure_strings_area[] = {
 					STR_NULL, STR_NULL, STR_MEASURE_AREA, STR_MEASURE_AREA_HEIGHTDIFF
 				};
@@ -2734,10 +2728,6 @@
 
 void SetObjectToPlace(CursorID icon, SpriteID pal, ViewportHighlightMode mode, WindowClass window_class, WindowNumber window_num)
 {
-	/* unlock position and size */
-	_thd.lock_pos = false;
-	_thd.lock_size = false;
-
 	/* undo clicking on button and drag & drop */
 	if (_thd.place_mode != VHM_NONE || _special_mouse_mode == WSM_DRAGDROP) {
 		Window *w = FindWindowById(_thd.window_class, _thd.window_number);