Changeset - r9203:1587086284e7
[Not reviewed]
master
0 15 0
rubidium - 16 years ago 2008-05-13 14:43:33
rubidium@openttd.org
(svn r13069) -Codechange: it is no longer needed to pass a void *data pointer with the WE_CREATE message because nothing uses it anymore.
15 files changed with 32 insertions and 38 deletions:
0 comments (0 inline, 0 general)
src/autoreplace_gui.cpp
Show inline comments
 
@@ -246,13 +246,13 @@ class ReplaceVehicleWindow : public Wind
 
		this->update_left  = false;
 
		this->update_right = false;
 
		this->init_lists   = false;
 
	}
 

	
 
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();
 
		new (&this->list[1]) EngineList();
 
		this->update_left   = true;
 
		this->update_right  = true;
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -804,13 +804,13 @@ struct BuildVehicleWindow : Window {
 
	byte sort_criteria;
 
	bool regenerate_list;
 
	EngineID sel_engine;
 
	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);
 

	
 
		ResizeWindow(this, 0, vlh - 14);
 
		this->resize.step_height = vlh;
src/depot_gui.cpp
Show inline comments
 
@@ -249,13 +249,13 @@ struct DepotWindow : Window {
 
	uint16 wagon_list_length;
 
	uint16 engine_count;
 
	uint16 wagon_count;
 
	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;
 
		this->wagon_list    = NULL;
 
		this->engine_count  = 0;
 
		this->wagon_count   = 0;
src/genworld_gui.cpp
Show inline comments
 
@@ -250,13 +250,13 @@ struct GenerateLandscapeWindow : public 
 
	uint widget_id;
 
	uint x;
 
	uint y;
 
	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);
 

	
 
		snprintf(this->edit_str_buf, sizeof(this->edit_str_buf), "%u", _patches_newgame.generation_seed);
 
		InitializeTextBuffer(&this->text, this->edit_str_buf, lengthof(this->edit_str_buf), 120);
 
		this->caption = STR_NULL;
 
@@ -641,13 +641,13 @@ enum CreateScenarioWindowWidgets {
 

	
 

	
 
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);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
src/group_gui.cpp
Show inline comments
 
@@ -184,13 +184,13 @@ static const Widget _group_widgets[] = {
 

	
 
struct VehicleGroupWindow : public Window, public VehicleListBase {
 
	GroupID group_sel;
 
	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);
 

	
 
		this->caption_color = owner;
 
		this->hscroll.cap = 224;
 
		this->resize.step_width = 1;
src/industry_gui.cpp
Show inline comments
 
@@ -459,13 +459,13 @@ class IndustryViewWindow : public Window
 
	byte editbox_line;        ///< The line clicked to open the edit box
 
	byte clicked_line;        ///< The line of the button that has been clicked
 
	byte clicked_button;      ///< The button that has been clicked (to raise)
 
	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;
 
		this->clicked_line = 0;
 
		this->clicked_button = 0;
 
		InitializeWindowViewport(this, 3, 17, 254, 86, GetIndustry(window_number)->xy + TileDiffXY(1, 1), ZOOM_LVL_INDUSTRY);
src/player_gui.cpp
Show inline comments
 
@@ -766,18 +766,18 @@ class SelectPlayerFaceWindow : public Wi
 
		this->ge = (GenderEthnicity)GB(this->face, _pf_info[PFV_GEN_ETHN].offset, _pf_info[PFV_GEN_ETHN].length); // get the gender and ethnicity
 
		this->is_female = HasBit(this->ge, GENDER_FEMALE); // get the gender: 0 == male and 1 == female
 
		this->is_moust_male = !is_female && GetPlayerFaceBits(this->face, PFV_HAS_MOUSTACHE, this->ge) != 0; // is a male face with moustache
 
	}
 

	
 
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();
 

	
 
		/* Check if repositioning from default is required */
 
		if (top != FIRST_GUI_CALL && left != FIRST_GUI_CALL) {
 
			this->top = top;
 
@@ -1042,13 +1042,14 @@ static const WindowDesc _select_player_f
 
 * @pre is player a valid player
 
 */
 
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
 
}
 

	
 

	
 
/* Names of the widgets. Keep them in the same order as in the widget array */
 
enum PlayerCompanyWindowWidgets {
 
	PCW_WIDGET_CLOSEBOX = 0,
src/querystring_gui.h
Show inline comments
 
@@ -21,13 +21,13 @@ struct QueryString {
 
};
 

	
 
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)
 
	{
 
	}
 

	
 
	void DrawEditBox(int wid);
 
	void HandleEditBox(int wid);
 
	int HandleEditBoxKey(int wid, uint16 key, uint16 keycode, bool &cont);
src/smallmap_gui.cpp
Show inline comments
 
@@ -797,13 +797,13 @@ public:
 
		y  = ((vp->virtual_height - (this->widget[SM_WIDGET_MAP].bottom - this->widget[SM_WIDGET_MAP].top ) * TILE_SIZE) / 2 + vp->virtual_top ) / 2 - TILE_SIZE * 2;
 
		this->scroll_x = (y - x) & ~0xF;
 
		this->scroll_y = (x + y) & ~0xF;
 
		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) {
 
			uint diff = ((_industries_per_column - BASE_NB_PER_COLUMN) * BASE_NB_PER_COLUMN) + 1;
 

	
 
			this->height = this->height + diff;
 
@@ -1118,22 +1118,21 @@ class ExtraViewportWindow : public Windo
 
		EVW_SPACER1,
 
		EVW_SPACER2,
 
		EVW_RESIZE,
 
	};
 

	
 
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);
 

	
 
		this->DisableWidget(EVW_ZOOMIN);
 
		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);
 

	
 
			/* center on same place as main window (zoom is maximum, no adjustment needed) */
 
			pt.x = w->viewport->scrollpos_x + w->viewport->virtual_height / 2;
 
@@ -1232,13 +1231,13 @@ void ShowExtraViewPortWindow(TileIndex t
 
{
 
	int i = 0;
 

	
 
	/* 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)
 
{
 
	bool res = ScrollWindowTo(x, y, FindWindowById(WC_MAIN_WINDOW, 0), instant);
 

	
src/station_gui.cpp
Show inline comments
 
@@ -284,13 +284,13 @@ static void SortStationsList(GUIStationL
 
struct PlayerStationsWindow : public Window, public GUIStationList
 
{
 
	static Listing station_sort;
 
	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;
 
		this->resize.step_height = 10;
 
		this->resize.height = this->height - 10 * 7; // minimum if 5 in the list
 

	
 
@@ -734,13 +734,13 @@ typedef std::list<CargoData> CargoDataLi
 
 * The StationView window
 
 */
 
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;
 
		this->vscroll.cap = 5;
 
		this->resize.step_height = 10;
 

	
src/transparency_gui.cpp
Show inline comments
 
@@ -33,13 +33,13 @@ class TransparenciesWindow : public Wind
 

	
 
		/* Panel with buttons for invisibility */
 
		TTW_BUTTONS = 12,        ///< Panel with 'invisibility' buttons
 
	};
 

	
 
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);
 
	}
 

	
 
	virtual void OnPaint()
 
	{
src/tree_gui.cpp
Show inline comments
 
@@ -42,13 +42,13 @@ class BuildTreesWindow : public Window
 
		BTW_TYPE_34,
 
		BTW_TYPE_RANDOM,
 
		BTW_MANY_RANDOM,
 
	};
 

	
 
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);
 
			int offset = this->widget[BTW_MANY_RANDOM].bottom - this->widget[BTW_MANY_RANDOM].top;
 
			this->height -= offset;
 
			this->widget[BTW_BACKGROUND].bottom -= offset;
src/vehicle_gui.cpp
Show inline comments
 
@@ -838,13 +838,13 @@ void DrawSmallOrderList(const Vehicle *v
 
 * 8-10 window type (use flags in vehicle_gui.h)
 
 * 11-15 vehicle type (using VEH_, but can be compressed to fewer bytes if needed)
 
 * 16-31 StationID or OrderID depending on window type (bit 8-10)
 
 */
 
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);
 

	
 
		this->vehicle_type = (VehicleType)GB(this->window_number, 11, 5);
 
		this->vehicles.list_length = 0;
src/window.cpp
Show inline comments
 
@@ -888,16 +888,16 @@ static void AssignWidgetToWindow(Window 
 
 * @param min_width minimum width in pixels of the window
 
 * @param min_height minimum height in pixels of the window
 
 * @param *proc see WindowProc function to call when any messages/updates happen to the window
 
 * @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)) {
 
		Window *w = FindDeletableWindow();
 
		if (w == NULL) w = ForceFindDeletableWindow();
 
		delete w;
 
@@ -940,13 +940,12 @@ void Window::Initialize(int x, int y, in
 

	
 
	*wz = this;
 
	_last_z_window++;
 

	
 
	WindowEvent e;
 
	e.event = WE_CREATE;
 
	e.we.create.data = data;
 
	this->HandleWindowEvent(&e);
 
}
 

	
 
/**
 
 * Find a nice spot for this window and resize it towards the default size.
 
 * @param def_width default width in pixels of the window
 
@@ -1022,15 +1021,15 @@ void Window::FindWindowPlacementAndResiz
 
 * @param height height in pixels of the window
 
 * @param *proc see WindowProc function to call when any messages/updates happen to the window
 
 * @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
 
 * @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);
 
}
 

	
 

	
 
static bool IsGoodAutoPlace1(int left, int top, int width, int height, Point &pos)
 
@@ -1212,20 +1211,19 @@ static Point LocalGetWindowPlacement(con
 

	
 
/**
 
 * Set the positions of a new window from a WindowDesc and open it.
 
 *
 
 * @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);
 
}
 

	
 
/** Do a search for a window at specific coordinates. For this we start
src/window_gui.h
Show inline comments
 
@@ -141,16 +141,12 @@ enum WindowEventCodes {
 
 * @see WindowEventCodes
 
 */
 
struct WindowEvent {
 
	byte event;
 
	union {
 
		struct {
 
			void *data;
 
		} create;
 

	
 
		struct {
 
			Point pt;
 
			int widget;
 
		} click;
 

	
 
		struct {
 
			Point pt;
 
@@ -288,19 +284,19 @@ struct Window : ZeroedMemoryAllocator {
 
private:
 
	WindowProc *wndproc;   ///< Event handler function for the window. Do not use directly, call HandleWindowEvent() instead.
 
	void HandleWindowEvent(WindowEvent *e);
 

	
 
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();
 

	
 
	uint16 flags4;              ///< Window flags, @see WindowFlags
 
	WindowClass window_class;   ///< Window class
 
	WindowNumber window_number; ///< Window number within the window class
 
@@ -639,16 +635,16 @@ bool IsWindowOfPrototype(const Window *w
 
 * @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 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);
 

	
 
void RelocateAllWindows(int neww, int newh);
 

	
0 comments (0 inline, 0 general)