(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
authorrubidium
Sat, 17 May 2008 13:01:30 +0000
changeset 10596 0ee9eba64c9c
parent 10595 7957c71b0dfe
child 10597 d50861a6c96b
(svn r13140) -Codechange: move the gui-list-sorting out of window_gui.h so window_gui.h only needs to be included in *_gui.cpp.
projects/openttd_vs80.vcproj
projects/openttd_vs90.vcproj
source.list
src/aircraft_gui.cpp
src/autoreplace_gui.cpp
src/build_vehicle_gui.cpp
src/depot_gui.cpp
src/economy.cpp
src/network/network_gui.cpp
src/sortlist_type.h
src/train_cmd.cpp
src/vehicle.cpp
src/vehicle_gui.cpp
src/vehicle_gui.h
src/viewport.cpp
src/window_gui.h
--- a/projects/openttd_vs80.vcproj	Sat May 17 12:48:06 2008 +0000
+++ b/projects/openttd_vs80.vcproj	Sat May 17 13:01:30 2008 +0000
@@ -1408,6 +1408,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sortlist_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\sound_func.h"
 				>
 			</File>
--- a/projects/openttd_vs90.vcproj	Sat May 17 12:48:06 2008 +0000
+++ b/projects/openttd_vs90.vcproj	Sat May 17 13:01:30 2008 +0000
@@ -1405,6 +1405,10 @@
 				>
 			</File>
 			<File
+				RelativePath=".\..\src\sortlist_type.h"
+				>
+			</File>
+			<File
 				RelativePath=".\..\src\sound_func.h"
 				>
 			</File>
--- a/source.list	Sat May 17 12:48:06 2008 +0000
+++ b/source.list	Sat May 17 13:01:30 2008 +0000
@@ -277,6 +277,7 @@
 signs_type.h
 slope_func.h
 slope_type.h
+sortlist_type.h
 sound_func.h
 sound_type.h
 sprite.h
--- a/src/aircraft_gui.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/aircraft_gui.cpp	Sat May 17 13:01:30 2008 +0000
@@ -13,6 +13,7 @@
 #include "vehicle_func.h"
 #include "gfx_func.h"
 #include "order_func.h"
+#include "window_gui.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/autoreplace_gui.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/autoreplace_gui.cpp	Sat May 17 13:01:30 2008 +0000
@@ -21,6 +21,7 @@
 #include "widgets/dropdown_func.h"
 #include "engine_func.h"
 #include "engine_base.h"
+#include "window_gui.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/build_vehicle_gui.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/build_vehicle_gui.cpp	Sat May 17 13:01:30 2008 +0000
@@ -28,6 +28,7 @@
 #include "gfx_func.h"
 #include "widgets/dropdown_func.h"
 #include "string_func.h"
+#include "window_gui.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/depot_gui.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/depot_gui.cpp	Sat May 17 13:01:30 2008 +0000
@@ -25,6 +25,7 @@
 #include "order_func.h"
 #include "depot_base.h"
 #include "tilehighlight_func.h"
+#include "window_gui.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
--- a/src/economy.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/economy.cpp	Sat May 17 13:01:30 2008 +0000
@@ -46,6 +46,7 @@
 #include "gfx_func.h"
 #include "autoreplace_func.h"
 #include "player_gui.h"
+#include "window_gui.h"
 
 #include "table/strings.h"
 #include "table/sprites.h"
--- a/src/network/network_gui.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/network/network_gui.cpp	Sat May 17 13:01:30 2008 +0000
@@ -30,6 +30,7 @@
 #include "../settings_type.h"
 #include "../widgets/dropdown_func.h"
 #include "../querystring_gui.h"
+#include "../sortlist_type.h"
 
 #include "table/strings.h"
 #include "../table/sprites.h"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/sortlist_type.h	Sat May 17 13:01:30 2008 +0000
@@ -0,0 +1,31 @@
+/* $Id$ */
+
+/** @file sortlist_type.h Base types for having sorted lists in GUIs. */
+
+#ifndef SORTLIST_TYPE_H
+#define SORTLIST_TYPE_H
+
+enum SortListFlags {
+	VL_NONE    = 0,      ///< no sort
+	VL_DESC    = 1 << 0, ///< sort descending or ascending
+	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
+	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
+	VL_END     = 1 << 3,
+};
+DECLARE_ENUM_AS_BIT_SET(SortListFlags);
+
+struct Listing {
+	bool order;    ///< Ascending/descending
+	byte criteria; ///< Sorting criteria
+};
+
+template <typename T>
+struct GUIList {
+	T* sort_list;        ///< The items to sort.
+	SortListFlags flags; ///< used to control sorting/resorting/etc.
+	uint16 list_length;  ///< length of the list being sorted
+	uint16 resort_timer; ///< resort list after a given amount of ticks if set
+	byte sort_type;      ///< what criteria to sort on
+};
+
+#endif /* SORTLIST_TYPE_H */
--- a/src/train_cmd.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/train_cmd.cpp	Sat May 17 13:01:30 2008 +0000
@@ -1350,7 +1350,7 @@
 
 	if (flags & DC_EXEC) {
 		if (v == first && IsFrontEngine(first)) {
-			delete FindWindowById(WC_VEHICLE_VIEW, first->index);
+			DeleteWindowById(WC_VEHICLE_VIEW, first->index);
 		}
 		InvalidateWindow(WC_VEHICLE_DEPOT, first->tile);
 		RebuildVehicleLists();
--- a/src/vehicle.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/vehicle.cpp	Sat May 17 13:01:30 2008 +0000
@@ -590,11 +590,8 @@
 		delete this->Next();
 	}
 
-	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
-	if (w != NULL && w->viewport->follow_vehicle == this->index) {
-		ScrollMainWindowTo(this->x_pos, this->y_pos, true); // lock the main view on the vehicle's last position
-		w->viewport->follow_vehicle = INVALID_VEHICLE;
-	}
+	extern void StopGlobalFollowVehicle(const Vehicle *v);
+	StopGlobalFollowVehicle(this);
 }
 
 Vehicle::~Vehicle()
--- a/src/vehicle_gui.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/vehicle_gui.cpp	Sat May 17 13:01:30 2008 +0000
@@ -2171,3 +2171,12 @@
 		default: NOT_REACHED();
 	}
 }
+
+void StopGlobalFollowVehicle(const Vehicle *v)
+{
+	Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
+	if (w != NULL && w->viewport->follow_vehicle == v->index) {
+		ScrollMainWindowTo(v->x_pos, v->y_pos, true); // lock the main view on the vehicle's last position
+		w->viewport->follow_vehicle = INVALID_VEHICLE;
+	}
+}
--- a/src/vehicle_gui.h	Sat May 17 12:48:06 2008 +0000
+++ b/src/vehicle_gui.h	Sat May 17 13:01:30 2008 +0000
@@ -5,7 +5,8 @@
 #ifndef VEHICLE_GUI_H
 #define VEHICLE_GUI_H
 
-#include "window_gui.h"
+#include "sortlist_type.h"
+#include "window_type.h"
 #include "vehicle_type.h"
 #include "order_type.h"
 #include "station_type.h"
--- a/src/viewport.cpp	Sat May 17 12:48:06 2008 +0000
+++ b/src/viewport.cpp	Sat May 17 13:01:30 2008 +0000
@@ -47,6 +47,7 @@
 #include "misc/smallvec.h"
 #include "window_func.h"
 #include "tilehighlight_func.h"
+#include "window_gui.h"
 
 #include "table/sprites.h"
 #include "table/strings.h"
--- a/src/window_gui.h	Sat May 17 12:48:06 2008 +0000
+++ b/src/window_gui.h	Sat May 17 13:01:30 2008 +0000
@@ -514,29 +514,6 @@
 	virtual ~PickerWindowBase();
 };
 
-enum SortListFlags {
-	VL_NONE    = 0,      ///< no sort
-	VL_DESC    = 1 << 0, ///< sort descending or ascending
-	VL_RESORT  = 1 << 1, ///< instruct the code to resort the list in the next loop
-	VL_REBUILD = 1 << 2, ///< create sort-listing to use for qsort and friends
-	VL_END     = 1 << 3,
-};
-DECLARE_ENUM_AS_BIT_SET(SortListFlags);
-
-struct Listing {
-	bool order;    ///< Ascending/descending
-	byte criteria; ///< Sorting criteria
-};
-
-template <typename T>
-struct GUIList {
-	T* sort_list;        ///< The items to sort.
-	SortListFlags flags; ///< used to control sorting/resorting/etc.
-	uint16 list_length;  ///< length of the list being sorted
-	uint16 resort_timer; ///< resort list after a given amount of ticks if set
-	byte sort_type;      ///< what criteria to sort on
-};
-
 /****************** THESE ARE NOT WIDGET TYPES!!!!! *******************/
 enum WindowWidgetBehaviours {
 	WWB_PUSHBUTTON  = 1 << 5,