mirror of https://github.com/OpenTTD/OpenTTD
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
parent
db69f81fe7
commit
dddfaaac7d
|
@ -249,7 +249,7 @@ class ReplaceVehicleWindow : public Window {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
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)
|
this->wagon_btnstate = true; // start with locomotives (all other vehicles will not read this bool)
|
||||||
new (&this->list[0]) EngineList();
|
new (&this->list[0]) EngineList();
|
||||||
|
|
|
@ -807,7 +807,7 @@ struct BuildVehicleWindow : Window {
|
||||||
EngineID rename_engine;
|
EngineID rename_engine;
|
||||||
EngineList eng_list;
|
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;
|
this->vehicle_type = type;
|
||||||
int vlh = GetVehicleListHeight(this->vehicle_type);
|
int vlh = GetVehicleListHeight(this->vehicle_type);
|
||||||
|
|
|
@ -252,7 +252,7 @@ struct DepotWindow : Window {
|
||||||
Vehicle **vehicle_list;
|
Vehicle **vehicle_list;
|
||||||
Vehicle **wagon_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->sel = INVALID_VEHICLE;
|
||||||
this->vehicle_list = NULL;
|
this->vehicle_list = NULL;
|
||||||
|
|
|
@ -253,7 +253,7 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
|
||||||
char name[64];
|
char name[64];
|
||||||
glwp_modes mode;
|
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);
|
this->LowerWidget(_opt_newgame.landscape + GLAND_TEMPERATE);
|
||||||
|
|
||||||
|
@ -644,7 +644,7 @@ struct CreateScenarioWindow : public Window
|
||||||
{
|
{
|
||||||
uint widget_id;
|
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);
|
this->LowerWidget(_opt_newgame.landscape + CSCEN_TEMPERATE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ struct VehicleGroupWindow : public Window, public VehicleListBase {
|
||||||
VehicleID vehicle_sel;
|
VehicleID vehicle_sel;
|
||||||
GUIGroupList groups;
|
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);
|
const PlayerID owner = (PlayerID)GB(this->window_number, 0, 8);
|
||||||
|
|
||||||
|
|
|
@ -462,7 +462,7 @@ class IndustryViewWindow : public Window
|
||||||
byte production_offset_y; ///< The offset of the production texts/buttons
|
byte production_offset_y; ///< The offset of the production texts/buttons
|
||||||
|
|
||||||
public:
|
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->flags4 |= WF_DISABLE_VP_SCROLL;
|
||||||
this->editbox_line = 0;
|
this->editbox_line = 0;
|
||||||
|
|
|
@ -769,12 +769,12 @@ class SelectPlayerFaceWindow : public Window
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
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->FindWindowPlacementAndResize(desc);
|
||||||
this->caption_color = this->window_number;
|
this->caption_color = this->window_number;
|
||||||
this->face = GetPlayer((PlayerID)this->window_number)->face;
|
this->face = GetPlayer((PlayerID)this->window_number)->face;
|
||||||
this->advanced = *(bool*)data;
|
this->advanced = advanced;
|
||||||
|
|
||||||
this->UpdateData();
|
this->UpdateData();
|
||||||
|
|
||||||
|
@ -1045,7 +1045,8 @@ static void DoSelectPlayerFace(PlayerID player, bool adv, int top, int left)
|
||||||
{
|
{
|
||||||
if (!IsValidPlayer(player)) return;
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ struct QueryStringBaseWindow : public Window, public QueryString {
|
||||||
char edit_str_buf[64];
|
char edit_str_buf[64];
|
||||||
char orig_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)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -800,7 +800,7 @@ public:
|
||||||
this->SetDirty();
|
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 */
|
/* Resize the window to fit industries list */
|
||||||
if (_industries_per_column > BASE_NB_PER_COLUMN) {
|
if (_industries_per_column > BASE_NB_PER_COLUMN) {
|
||||||
|
@ -1121,7 +1121,7 @@ class ExtraViewportWindow : public Window
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
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) */
|
/* 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);
|
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);
|
this->FindWindowPlacementAndResize(desc);
|
||||||
|
|
||||||
Point pt;
|
Point pt;
|
||||||
TileIndex tile = *(TileIndex*)data;
|
|
||||||
if (tile == INVALID_TILE) {
|
if (tile == INVALID_TILE) {
|
||||||
/* the main window with the main view */
|
/* the main window with the main view */
|
||||||
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
const Window *w = FindWindowById(WC_MAIN_WINDOW, 0);
|
||||||
|
@ -1235,7 +1234,7 @@ void ShowExtraViewPortWindow(TileIndex tile)
|
||||||
/* find next free window number for extra viewport */
|
/* find next free window number for extra viewport */
|
||||||
while (FindWindowById(WC_EXTRA_VIEW_PORT, i) != NULL) i++;
|
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)
|
bool ScrollMainWindowTo(int x, int y, bool instant)
|
||||||
|
|
|
@ -287,7 +287,7 @@ struct PlayerStationsWindow : public Window, public GUIStationList
|
||||||
static byte facilities;
|
static byte facilities;
|
||||||
static bool include_empty;
|
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->caption_color = (byte)this->window_number;
|
||||||
this->vscroll.cap = 12;
|
this->vscroll.cap = 12;
|
||||||
|
@ -737,7 +737,7 @@ struct StationViewWindow : public Window {
|
||||||
uint32 cargo; ///< Bitmask of cargo types to expand
|
uint32 cargo; ///< Bitmask of cargo types to expand
|
||||||
uint16 cargo_rows[NUM_CARGO]; ///< Header row for each cargo type
|
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;
|
PlayerID owner = GetStation(window_number)->owner;
|
||||||
if (owner != OWNER_NONE) this->caption_color = owner;
|
if (owner != OWNER_NONE) this->caption_color = owner;
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TransparenciesWindow : public Window
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
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);
|
this->FindWindowPlacementAndResize(desc);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ class BuildTreesWindow : public Window
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
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) {
|
if (_game_mode != GM_EDITOR) {
|
||||||
this->HideWidget(BTW_MANY_RANDOM);
|
this->HideWidget(BTW_MANY_RANDOM);
|
||||||
|
|
|
@ -841,7 +841,7 @@ void DrawSmallOrderList(const Vehicle *v, int x, int y)
|
||||||
*/
|
*/
|
||||||
struct VehicleListWindow : public Window, public VehicleListBase {
|
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;
|
uint16 window_type = this->window_number & VLW_MASK;
|
||||||
PlayerID player = (PlayerID)GB(this->window_number, 0, 8);
|
PlayerID player = (PlayerID)GB(this->window_number, 0, 8);
|
||||||
|
|
|
@ -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 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 *widget see Widget pointer to the window layout and various elements
|
||||||
* @param window_number number being assigned to the new window
|
* @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,
|
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 */
|
/* 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)) {
|
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;
|
WindowEvent e;
|
||||||
e.event = WE_CREATE;
|
e.event = WE_CREATE;
|
||||||
e.we.create.data = data;
|
|
||||||
this->HandleWindowEvent(&e);
|
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
|
* @param *widget see Widget pointer to the window layout and various elements
|
||||||
* @return Window pointer of the newly created window
|
* @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);
|
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 *desc The pointer to the WindowDesc to be created
|
||||||
* @param window_number the window number of the new window
|
* @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
|
* @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);
|
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;
|
this->desc_flags = desc->flags;
|
||||||
|
|
||||||
if (desc->proc != NULL) this->FindWindowPlacementAndResize(desc->default_width, desc->default_height);
|
if (desc->proc != NULL) this->FindWindowPlacementAndResize(desc->default_width, desc->default_height);
|
||||||
|
|
|
@ -143,10 +143,6 @@ enum WindowEventCodes {
|
||||||
struct WindowEvent {
|
struct WindowEvent {
|
||||||
byte event;
|
byte event;
|
||||||
union {
|
union {
|
||||||
struct {
|
|
||||||
void *data;
|
|
||||||
} create;
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
Point pt;
|
Point pt;
|
||||||
int widget;
|
int widget;
|
||||||
|
@ -291,13 +287,13 @@ private:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void Initialize(int x, int y, int min_width, int min_height,
|
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(int def_width, int def_height);
|
||||||
void FindWindowPlacementAndResize(const WindowDesc *desc);
|
void FindWindowPlacementAndResize(const WindowDesc *desc);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget, void *data = NULL);
|
Window(int x, int y, int width, int height, WindowProc *proc, WindowClass cls, const Widget *widget);
|
||||||
Window(const WindowDesc *desc, void *data = NULL, WindowNumber number = 0);
|
Window(const WindowDesc *desc, WindowNumber number = 0);
|
||||||
|
|
||||||
virtual ~Window();
|
virtual ~Window();
|
||||||
|
|
||||||
|
@ -642,10 +638,10 @@ bool IsWindowOfPrototype(const Window *w, const Widget *widget);
|
||||||
* @return see Window pointer of the newly created window
|
* @return see Window pointer of the newly created window
|
||||||
*/
|
*/
|
||||||
template <typename Wcls>
|
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;
|
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);
|
void DrawWindowViewport(const Window *w);
|
||||||
|
|
Loading…
Reference in New Issue