diff options
-rw-r--r-- | src/autoreplace_gui.cpp | 2 | ||||
-rw-r--r-- | src/build_vehicle_gui.cpp | 2 | ||||
-rw-r--r-- | src/depot_gui.cpp | 2 | ||||
-rw-r--r-- | src/genworld_gui.cpp | 4 | ||||
-rw-r--r-- | src/group_gui.cpp | 2 | ||||
-rw-r--r-- | src/industry_gui.cpp | 2 | ||||
-rw-r--r-- | src/player_gui.cpp | 7 | ||||
-rw-r--r-- | src/querystring_gui.h | 2 | ||||
-rw-r--r-- | src/smallmap_gui.cpp | 7 | ||||
-rw-r--r-- | src/station_gui.cpp | 4 | ||||
-rw-r--r-- | src/transparency_gui.cpp | 2 | ||||
-rw-r--r-- | src/tree_gui.cpp | 2 | ||||
-rw-r--r-- | src/vehicle_gui.cpp | 2 | ||||
-rw-r--r-- | src/window.cpp | 16 | ||||
-rw-r--r-- | src/window_gui.h | 14 |
15 files changed, 32 insertions, 38 deletions
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp index af5d3d4a6..2d1365b26 100644 --- a/src/autoreplace_gui.cpp +++ b/src/autoreplace_gui.cpp @@ -249,7 +249,7 @@ class ReplaceVehicleWindow : public Window { } public: - ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, NULL, window_number) + ReplaceVehicleWindow(const WindowDesc *desc, VehicleType vehicletype, GroupID id_g) : Window(desc, window_number) { this->wagon_btnstate = true; // start with locomotives (all other vehicles will not read this bool) new (&this->list[0]) EngineList(); diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 33211e611..df75315a4 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -807,7 +807,7 @@ struct BuildVehicleWindow : Window { EngineID rename_engine; EngineList eng_list; - BuildVehicleWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, NULL, tile == 0 ? (int)type : tile) + BuildVehicleWindow(const WindowDesc *desc, TileIndex tile, VehicleType type) : Window(desc, tile == 0 ? (int)type : tile) { this->vehicle_type = type; int vlh = GetVehicleListHeight(this->vehicle_type); diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 1c8cf299b..f490e58de 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -252,7 +252,7 @@ struct DepotWindow : Window { Vehicle **vehicle_list; Vehicle **wagon_list; - DepotWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + DepotWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->sel = INVALID_VEHICLE; this->vehicle_list = NULL; diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp index 3c24f9491..867244f5b 100644 --- a/src/genworld_gui.cpp +++ b/src/genworld_gui.cpp @@ -253,7 +253,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow { char name[64]; glwp_modes mode; - GenerateLandscapeWindow(const WindowDesc *desc, void *data = NULL, WindowNumber number = 0) : QueryStringBaseWindow(desc, NULL, number) + GenerateLandscapeWindow(const WindowDesc *desc, WindowNumber number = 0) : QueryStringBaseWindow(desc, number) { this->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE); @@ -644,7 +644,7 @@ struct CreateScenarioWindow : public Window { uint widget_id; - CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, NULL, window_number) + CreateScenarioWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE); } diff --git a/src/group_gui.cpp b/src/group_gui.cpp index 25760924e..8ead8cb54 100644 --- a/src/group_gui.cpp +++ b/src/group_gui.cpp @@ -187,7 +187,7 @@ struct VehicleGroupWindow : public Window, public VehicleListBase { VehicleID vehicle_sel; GUIGroupList groups; - VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, NULL, window_number) + VehicleGroupWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8); diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp index 23ec1ceac..2fb18da3e 100644 --- a/src/industry_gui.cpp +++ b/src/industry_gui.cpp @@ -462,7 +462,7 @@ class IndustryViewWindow : public Window byte production_offset_y; ///< The offset of the production texts/buttons public: - IndustryViewWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + IndustryViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->flags4 |= WF_DISABLE_VP_SCROLL; this->editbox_line = 0; diff --git a/src/player_gui.cpp b/src/player_gui.cpp index 36613a553..0879a0c60 100644 --- a/src/player_gui.cpp +++ b/src/player_gui.cpp @@ -769,12 +769,12 @@ class SelectPlayerFaceWindow : public Window } public: - SelectPlayerFaceWindow(const WindowDesc *desc, void *data, WindowNumber number) : Window(desc, data, number) + SelectPlayerFaceWindow(const WindowDesc *desc, bool advanced) : Window(desc, 0) { this->FindWindowPlacementAndResize(desc); this->caption_color = this->window_number; this->face = GetPlayer((PlayerID)this->window_number)->face; - this->advanced = *(bool*)data; + this->advanced = advanced; this->UpdateData(); @@ -1045,7 +1045,8 @@ static void DoSelectPlayerFace(PlayerID player, bool adv, int top, int left) { if (!IsValidPlayer(player)) return; - AllocateWindowDescFront<SelectPlayerFaceWindow>(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player, &adv); // simple or advanced window + if (BringWindowToFrontById(WC_PLAYER_FACE, 0)) return; + return SelectPlayerFaceWindow(adv ? &_select_player_face_adv_desc : &_select_player_face_desc, player, adv); // simple or advanced window } diff --git a/src/querystring_gui.h b/src/querystring_gui.h index 7b001dadd..8df54d1b2 100644 --- a/src/querystring_gui.h +++ b/src/querystring_gui.h @@ -24,7 +24,7 @@ struct QueryStringBaseWindow : public Window, public QueryString { char edit_str_buf[64]; char orig_str_buf[64]; - QueryStringBaseWindow(const WindowDesc *desc, void *data = NULL, WindowNumber window_number = 0) : Window(desc, data, window_number) + QueryStringBaseWindow(const WindowDesc *desc, WindowNumber window_number = 0) : Window(desc, window_number) { } diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp index d940e4b57..b2e4be10d 100644 --- a/src/smallmap_gui.cpp +++ b/src/smallmap_gui.cpp @@ -800,7 +800,7 @@ public: this->SetDirty(); } - SmallMapWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) + SmallMapWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number) { /* Resize the window to fit industries list */ if (_industries_per_column > BASE_NB_PER_COLUMN) { @@ -1121,7 +1121,7 @@ class ExtraViewportWindow : public Window }; public: - ExtraViewportWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) + ExtraViewportWindow(const WindowDesc *desc, int window_number, TileIndex tile) : Window(desc, window_number) { /* New viewport start at (zero,zero) */ InitializeWindowViewport(this, 3, 17, this->widget[EVW_VIEWPORT].right - this->widget[EVW_VIEWPORT].left - 1, this->widget[EVW_VIEWPORT].bottom - this->widget[EVW_VIEWPORT].top - 1, 0, ZOOM_LVL_VIEWPORT); @@ -1130,7 +1130,6 @@ public: this->FindWindowPlacementAndResize(desc); Point pt; - TileIndex tile = *(TileIndex*)data; if (tile == INVALID_TILE) { /* the main window with the main view */ const Window *w = FindWindowById(WC_MAIN_WINDOW, 0); @@ -1235,7 +1234,7 @@ void ShowExtraViewPortWindow(TileIndex tile) /* find next free window number for extra viewport */ while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++; - AllocateWindowDescFront<ExtraViewportWindow>(&_extra_view_port_desc, i, &tile); + new ExtraViewportWindow(&_extra_view_port_desc, i, tile); } bool ScrollMainWindowTo(int x, int y, bool instant) diff --git a/src/station_gui.cpp b/src/station_gui.cpp index 51f4d3d3f..e14fbbe8f 100644 --- a/src/station_gui.cpp +++ b/src/station_gui.cpp @@ -287,7 +287,7 @@ struct PlayerStationsWindow : public Window, public GUIStationList static byte facilities; static bool include_empty; - PlayerStationsWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + PlayerStationsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { this->caption_color = (byte)this->window_number; this->vscroll.cap = 12; @@ -737,7 +737,7 @@ struct StationViewWindow : public Window { uint32 cargo; ///< Bitmask of cargo types to expand uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type - StationViewWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + StationViewWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { PlayerID owner = GetStation(window_number)->owner; if (owner != OWNER_NONE) this->caption_color = owner; diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp index e650fc6b3..f1e0d52fa 100644 --- a/src/transparency_gui.cpp +++ b/src/transparency_gui.cpp @@ -36,7 +36,7 @@ class TransparenciesWindow : public Window }; public: - TransparenciesWindow(const WindowDesc *desc, void *data, int window_number) : Window(desc, data, window_number) + TransparenciesWindow(const WindowDesc *desc, int window_number) : Window(desc, window_number) { this->FindWindowPlacementAndResize(desc); } diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp index 8f01d50d2..866ac91f1 100644 --- a/src/tree_gui.cpp +++ b/src/tree_gui.cpp @@ -45,7 +45,7 @@ class BuildTreesWindow : public Window }; public: - BuildTreesWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + BuildTreesWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { if (_game_mode != GM_EDITOR) { this->HideWidget(BTW_MANY_RANDOM); diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp index 4c6c3f84e..7b702f45e 100644 --- a/src/vehicle_gui.cpp +++ b/src/vehicle_gui.cpp @@ -841,7 +841,7 @@ void DrawSmallOrderList(const Vehicle *v, int x, int y) */ struct VehicleListWindow : public Window, public VehicleListBase { - VehicleListWindow(const WindowDesc *desc, void *data, WindowNumber window_number) : Window(desc, data, window_number) + VehicleListWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number) { uint16 window_type = this->window_number & VLW_MASK; PlayerID player = (PlayerID)GB(this->window_number, 0, 8); diff --git a/src/window.cpp b/src/window.cpp index 4c7f89454..09320a003 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -891,10 +891,10 @@ static void AssignWidgetToWindow(Window *w, const Widget *widget) * @param cls see WindowClass class of the window, used for identification and grouping * @param *widget see Widget pointer to the window layout and various elements * @param window_number number being assigned to the new window - * @param data the data to be given during the WE_CREATE message - * @return Window pointer of the newly created window */ + * @return Window pointer of the newly created window + */ void Window::Initialize(int x, int y, int min_width, int min_height, - WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data) + WindowProc *proc, WindowClass cls, const Widget *widget, int window_number) { /* We have run out of windows, close one and use that as the place for our new one */ if (_last_z_window == endof(_z_windows)) { @@ -943,7 +943,6 @@ void Window::Initialize(int x, int y, int min_width, int min_height, WindowEvent e; e.event = WE_CREATE; - e.we.create.data = data; this->HandleWindowEvent(&e); } @@ -1025,9 +1024,9 @@ void Window::FindWindowPlacementAndResize(const WindowDesc *desc) * @param *widget see Widget pointer to the window layout and various elements * @return Window pointer of the newly created window */ -Window::Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data) +Window::Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget) { - this->Initialize(x, y, width, height, proc, cls, widget, 0, data); + this->Initialize(x, y, width, height, proc, cls, widget, 0); if (proc != NULL) this->FindWindowPlacementAndResize(width, height); } @@ -1215,14 +1214,13 @@ static Point LocalGetWindowPlacement(const WindowDesc *desc, int window_number) * * @param *desc The pointer to the WindowDesc to be created * @param window_number the window number of the new window - * @param data arbitrary data that is send with the WE_CREATE message * * @return Window pointer of the newly created window */ -Window::Window(const WindowDesc *desc, void *data, WindowNumber window_number) +Window::Window(const WindowDesc *desc, WindowNumber window_number) { Point pt = LocalGetWindowPlacement(desc, window_number); - this->Initialize(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->proc, desc->cls, desc->widgets, window_number, data); + this->Initialize(pt.x, pt.y, desc->minimum_width, desc->minimum_height, desc->proc, desc->cls, desc->widgets, window_number); this->desc_flags = desc->flags; if (desc->proc != NULL) this->FindWindowPlacementAndResize(desc->default_width, desc->default_height); diff --git a/src/window_gui.h b/src/window_gui.h index 2edef2343..8102340ae 100644 --- a/src/window_gui.h +++ b/src/window_gui.h @@ -144,10 +144,6 @@ struct WindowEvent { byte event; union { struct { - void *data; - } create; - - struct { Point pt; int widget; } click; @@ -291,13 +287,13 @@ private: protected: void Initialize(int x, int y, int min_width, int min_height, - WindowProc *proc, WindowClass cls, const Widget *widget, int window_number, void *data); + WindowProc *proc, WindowClass cls, const Widget *widget, int window_number); void FindWindowPlacementAndResize(int def_width, int def_height); void FindWindowPlacementAndResize(const WindowDesc *desc); public: - Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data = NULL); - Window(const WindowDesc *desc, void *data = NULL, WindowNumber number = 0); + Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget); + Window(const WindowDesc *desc, WindowNumber number = 0); virtual ~Window(); @@ -642,10 +638,10 @@ bool IsWindowOfPrototype(const Window *w, const Widget *widget); * @return see Window pointer of the newly created window */ template <typename Wcls> -Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number, void *data = NULL) +Wcls *AllocateWindowDescFront(const WindowDesc *desc, int window_number) { if (BringWindowToFrontById(desc->cls, window_number)) return NULL; - return new Wcls(desc, data, window_number); + return new Wcls(desc, window_number); } void DrawWindowViewport(const Window *w); |