summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-05-17 13:01:30 +0000
committerrubidium <rubidium@openttd.org>2008-05-17 13:01:30 +0000
commit87015f5b6395f15a624f67e25dce10fe52a12c81 (patch)
tree46351975e7a6b7a08ca8eedc476a4109e9a1b776 /src
parent8b5421290027ab67cba25225111e3561ddd7af07 (diff)
downloadopenttd-87015f5b6395f15a624f67e25dce10fe52a12c81.tar.xz
(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.
Diffstat (limited to 'src')
-rw-r--r--src/aircraft_gui.cpp1
-rw-r--r--src/autoreplace_gui.cpp1
-rw-r--r--src/build_vehicle_gui.cpp1
-rw-r--r--src/depot_gui.cpp1
-rw-r--r--src/economy.cpp1
-rw-r--r--src/network/network_gui.cpp1
-rw-r--r--src/sortlist_type.h31
-rw-r--r--src/train_cmd.cpp2
-rw-r--r--src/vehicle.cpp7
-rw-r--r--src/vehicle_gui.cpp9
-rw-r--r--src/vehicle_gui.h3
-rw-r--r--src/viewport.cpp1
-rw-r--r--src/window_gui.h23
13 files changed, 52 insertions, 30 deletions
diff --git a/src/aircraft_gui.cpp b/src/aircraft_gui.cpp
index 2208d32ec..9787032fc 100644
--- a/src/aircraft_gui.cpp
+++ b/src/aircraft_gui.cpp
@@ -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"
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index e5a612201..87bdabdb2 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -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"
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index a5af78f6a..eb7333f55 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -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"
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index 842d18203..14d90acd6 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -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"
diff --git a/src/economy.cpp b/src/economy.cpp
index ab0695a00..f417ad9b1 100644
--- a/src/economy.cpp
+++ b/src/economy.cpp
@@ -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"
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index 61beab24a..f433eddbd 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -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"
diff --git a/src/sortlist_type.h b/src/sortlist_type.h
new file mode 100644
index 000000000..a3e428554
--- /dev/null
+++ b/src/sortlist_type.h
@@ -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 */
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index b377bfb5c..146c33bc1 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -1350,7 +1350,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
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();
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index b559a8fc7..53a38e239 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -590,11 +590,8 @@ void Vehicle::PreDestructor()
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()
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index 274c9e20f..7fcd64b5b 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -2171,3 +2171,12 @@ void DrawVehicleImage(const Vehicle *v, int x, int y, VehicleID selection, int c
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;
+ }
+}
diff --git a/src/vehicle_gui.h b/src/vehicle_gui.h
index 1079bd22e..e34282cc2 100644
--- a/src/vehicle_gui.h
+++ b/src/vehicle_gui.h
@@ -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"
diff --git a/src/viewport.cpp b/src/viewport.cpp
index 6cc15e30c..2a78983a9 100644
--- a/src/viewport.cpp
+++ b/src/viewport.cpp
@@ -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"
diff --git a/src/window_gui.h b/src/window_gui.h
index ab74b0c42..29fe579f6 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -514,29 +514,6 @@ public:
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,