Changeset - r5071:949c4f7f3fa6
[Not reviewed]
master
0 9 0
Darkvater - 18 years ago 2006-11-11 09:47:44
darkvater@openttd.org
(svn r7129) -Codechange: Get rid of a global variable that only sets a window's number.
9 files changed with 19 insertions and 31 deletions:
0 comments (0 inline, 0 general)
aircraft_gui.c
Show inline comments
 
@@ -180,15 +180,13 @@ static void ShowAircraftDetailsWindow(co
 
	Window *w;
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 

	
 
	_alloc_wnd_parent_num = veh;
 
	w = AllocateWindowDesc(&_aircraft_details_desc);
 
	w->window_number = veh;
 
	w = AllocateWindowDescFront(&_aircraft_details_desc, veh);
 
	w->caption_color = v->owner;
 
//	w->vscroll.cap = 6;
 
//	w->traindetails_d.tab = 0;
 
}
 

	
 

	
depot_gui.c
Show inline comments
 
@@ -218,16 +218,13 @@ static const WindowDesc _depot_sell_all_
 
	_depot_sell_all_widgets,
 
	DepotSellAllWndProc
 
};
 

	
 
static void ShowDepotSellAllWindow(TileIndex tile, byte type)
 
{
 
	Window *w;
 

	
 
	_alloc_wnd_parent_num = tile;
 
	w = AllocateWindowDescFront(&_depot_sell_all_desc, tile);
 
	Window *w = AllocateWindowDescFront(&_depot_sell_all_desc, tile);
 

	
 
	if (w != NULL) {
 
		w->caption_color = GetTileOwner(tile);
 
		WP(w, depot_d).type = type;
 
		switch (type) {
 
			case VEH_Train:
order_gui.c
Show inline comments
 
@@ -646,22 +646,19 @@ void ShowOrdersWindow(const Vehicle *v)
 
	Window *w;
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 

	
 
	_alloc_wnd_parent_num = veh;
 

	
 
	if (v->owner != _local_player) {
 
		w = AllocateWindowDesc(&_other_orders_desc);
 
		w = AllocateWindowDescFront(&_other_orders_desc, veh);
 
	} else {
 
		w = AllocateWindowDesc((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc);
 
		w = AllocateWindowDescFront((v->type == VEH_Train) ? &_orders_train_desc : &_orders_desc, veh);
 
	}
 

	
 
	if (w != NULL) {
 
		w->window_number = veh;
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 6;
 
		w->resize.step_height = 10;
 
		WP(w,order_d).sel = -1;
 
	}
 
}
roadveh_gui.c
Show inline comments
 
@@ -216,15 +216,14 @@ static void ShowRoadVehDetailsWindow(con
 
{
 
	Window *w;
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 
	_alloc_wnd_parent_num = veh;
 
	w = AllocateWindowDesc(&_roadveh_details_desc);
 
	w->window_number = veh;
 

	
 
	w = AllocateWindowDescFront(&_roadveh_details_desc, veh);
 
	w->caption_color = v->owner;
 
}
 

	
 
void CcCloneRoadVeh(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	if (success) ShowRoadVehViewWindow(GetVehicle(_new_vehicle_id));
ship_gui.c
Show inline comments
 
@@ -214,15 +214,13 @@ static void ShowShipDetailsWindow(const 
 
{
 
	Window *w;
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 
	_alloc_wnd_parent_num = veh;
 
	w = AllocateWindowDesc(&_ship_details_desc);
 
	w->window_number = veh;
 
	w = AllocateWindowDescFront(&_ship_details_desc, veh);
 
	w->caption_color = v->owner;
 
}
 

	
 
void CcBuildShip(bool success, TileIndex tile, uint32 p1, uint32 p2)
 
{
 
	const Vehicle *v;
train_gui.c
Show inline comments
 
@@ -1213,16 +1213,14 @@ static void ShowTrainDetailsWindow(const
 
	Window *w;
 
	VehicleID veh = v->index;
 

	
 
	DeleteWindowById(WC_VEHICLE_ORDERS, veh);
 
	DeleteWindowById(WC_VEHICLE_DETAILS, veh);
 

	
 
	_alloc_wnd_parent_num = veh;
 
	w = AllocateWindowDesc(&_train_details_desc);
 
	w = AllocateWindowDescFront(&_train_details_desc, veh);
 

	
 
	w->window_number = veh;
 
	w->caption_color = v->owner;
 
	w->vscroll.cap = 6;
 
	w->widget[4].data = (w->vscroll.cap << 8) + 1;
 

	
 
	w->resize.step_height = 14;
 
	w->resize.height = w->height - 14 * 2; /* Minimum of 4 wagons in the display */
vehicle_gui.c
Show inline comments
 
@@ -439,15 +439,13 @@ static const WindowDesc _vehicle_refit_d
 
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order)
 
{
 
	Window *w;
 

	
 
	DeleteWindowById(WC_VEHICLE_REFIT, v->index);
 

	
 
	_alloc_wnd_parent_num = v->index;
 

	
 
	w = AllocateWindowDesc(&_vehicle_refit_desc);
 
	w = AllocateWindowDescFront(&_vehicle_refit_desc, v->index);
 
	WP(w, refit_d).order = order;
 

	
 
	if (w != NULL) {
 
		w->window_number = v->index;
 
		w->caption_color = v->owner;
 
		w->vscroll.cap = 8;
window.c
Show inline comments
 
@@ -679,18 +679,23 @@ ok_pos:;
 

	
 
static Window *LocalAllocateWindowDesc(const WindowDesc *desc, int window_number)
 
{
 
	Point pt;
 
	Window *w;
 

	
 
	if (desc->parent_cls != WC_MAIN_WINDOW &&
 
			(w = FindWindowById(desc->parent_cls, _alloc_wnd_parent_num), _alloc_wnd_parent_num=0, w) != NULL &&
 
			w->left < _screen.width-20 && w->left > -60 && w->top < _screen.height-20) {
 
	/* By default position a child window at an offset of 10/10 of its parent.
 
	 * However if it falls too extremely outside window positions, reposition
 
	 * it to an automatic place */
 
	if (desc->parent_cls != 0 /* WC_MAIN_WINDOW */ &&
 
			(w = FindWindowById(desc->parent_cls, window_number)) != NULL &&
 
			w->left < _screen.width - 20 && w->left > -60 && w->top < _screen.height - 20) {
 

	
 
		pt.x = w->left + 10;
 
		if (pt.x > _screen.width + 10 - desc->width)
 
		if (pt.x > _screen.width + 10 - desc->width) {
 
			pt.x = (_screen.width + 10 - desc->width) - 20;
 
		}
 
		pt.y = w->top + 10;
 
	} else if (desc->cls == WC_BUILD_TOOLBAR) { // open Build Toolbars aligned
 
		/* Override the position if a toolbar is opened according to the place of the maintoolbar
 
		 * The main toolbar (WC_MAIN_TOOLBAR) is 640px in width */
 
		switch (_patches.toolbar_pos) {
 
			case 1:  pt.x = ((_screen.width + 640) >> 1) - desc->width; break;
 
@@ -1712,13 +1717,13 @@ int PositionMainToolbar(Window *w)
 

	
 
	if (w == NULL || w->window_class != WC_MAIN_TOOLBAR) {
 
		w = FindWindowById(WC_MAIN_TOOLBAR, 0);
 
	}
 

	
 
	switch (_patches.toolbar_pos) {
 
		case 1:  w->left = (_screen.width - w->width) >> 1; break;
 
		case 1:  w->left = (_screen.width - w->width) / 2; break;
 
		case 2:  w->left = _screen.width - w->width; break;
 
		default: w->left = 0;
 
	}
 
	SetDirtyBlocks(0, 0, _screen.width, w->height); // invalidate the whole top part
 
	return w->left;
 
}
window.h
Show inline comments
 
@@ -837,14 +837,12 @@ VARDEF Point _cursorpos_drag_start;
 
VARDEF bool _left_button_down;
 
VARDEF bool _left_button_clicked;
 

	
 
VARDEF bool _right_button_down;
 
VARDEF bool _right_button_clicked;
 

	
 
VARDEF int _alloc_wnd_parent_num;
 

	
 
VARDEF int _scrollbar_start_pos;
 
VARDEF int _scrollbar_size;
 
VARDEF byte _scroller_click_timeout;
 

	
 
VARDEF bool _scrolling_scrollbar;
 
VARDEF bool _scrolling_viewport;
0 comments (0 inline, 0 general)