Changeset - r4524:151b2dc80029
[Not reviewed]
master
0 5 0
bjarni - 18 years ago 2006-09-02 21:16:46
bjarni@openttd.org
(svn r6350) -Codechange: moved some setup stuff into WE_CREATE in PlayerVehWndProc()
This is possible now that the window number is known when running WE_CREATE and it's a nicer solution
5 files changed with 20 insertions and 22 deletions:
0 comments (0 inline, 0 general)
aircraft_gui.c
Show inline comments
 
@@ -1036,17 +1036,12 @@ void ShowPlayerAircraftLocal(PlayerID pl
 
		} else  {
 
			w = AllocateWindowDescFront(&_other_player_aircraft_desc, (station << 16) | (VEH_Aircraft << 11) | VLW_flag | player);
 
		}
 
	}
 

	
 
	if (w != NULL) {
 
		vehiclelist_d *vl = &WP(w, vehiclelist_d);
 
		vl->flags = VL_REBUILD | (_sorting.aircraft.order << (VL_DESC - 1));
 
		vl->sort_type = _sorting.aircraft.criteria;
 

	
 
		w->caption_color = player;
 
		w->vscroll.cap = 4;
 
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
 
		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
 
	}
 
}
 

	
roadveh_gui.c
Show inline comments
 
@@ -965,17 +965,12 @@ static void ShowPlayerRoadVehiclesLocal(
 
		} else  {
 
			w = AllocateWindowDescFront(&_other_player_roadveh_desc, (station << 16) | (VEH_Road << 11) | VLW_flag | player);
 
		}
 
	}
 

	
 
	if (w != NULL) {
 
		vehiclelist_d *vl = &WP(w, vehiclelist_d);
 
		vl->flags = VL_REBUILD | (_sorting.roadveh.order << (VL_DESC - 1));
 
		vl->sort_type = _sorting.roadveh.criteria;
 

	
 
		w->caption_color = player;
 
		w->vscroll.cap = 7; // maximum number of vehicles shown
 
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
 
		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL;
 
		w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */
 
	}
 
}
ship_gui.c
Show inline comments
 
@@ -978,17 +978,12 @@ static void ShowPlayerShipsLocal(PlayerI
 
		} else  {
 
			w = AllocateWindowDescFront(&_other_player_ships_desc, (station << 16) | (VEH_Ship << 11) | VLW_flag | player);
 
		}
 
	}
 

	
 
	if (w != NULL) {
 
		vehiclelist_d *vl = &WP(w, vehiclelist_d);
 
		vl->flags = VL_REBUILD | (_sorting.ship.order << (VL_DESC - 1));
 
		vl->sort_type = _sorting.ship.criteria;
 

	
 
		w->caption_color = player;
 
		w->vscroll.cap = 4;
 
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
 
		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_BIG;
 
	}
 
}
 

	
train_gui.c
Show inline comments
 
@@ -1434,17 +1434,12 @@ static void ShowPlayerTrainsLocal(Player
 
		} else  {
 
			w = AllocateWindowDescFront(&_other_player_trains_desc, (station << 16) | (VEH_Train << 11) | VLW_flag | player);
 
		}
 
	}
 

	
 
	if (w != NULL) {
 
		vehiclelist_d *vl = &WP(w, vehiclelist_d);
 
		vl->flags = VL_REBUILD | (_sorting.train.order << (VL_DESC - 1));
 
		vl->sort_type = _sorting.train.criteria;
 

	
 
		w->caption_color = player;
 
		w->hscroll.cap = 10 * 29;
 
		w->vscroll.cap = 7; // maximum number of vehicles shown
 
		w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
 
		w->resize.step_height = PLY_WND_PRC__SIZE_OF_ROW_SMALL;
 
		w->resize.step_width = 1;
 
		w->resize.height = 220 - (PLY_WND_PRC__SIZE_OF_ROW_SMALL * 3); /* Minimum of 4 vehicles */
vehicle_gui.c
Show inline comments
 
@@ -1359,14 +1359,32 @@ void PlayerVehWndProc(Window *w, WindowE
 
				}
 
			}
 
			SetWindowDirty(w);
 
			break;
 

	
 
		case WE_CREATE:
 
			/* IMPORTANT: order and criteria needs to be set after the window is created, but before it's used */
 
			/* w->window_number is not yet set at this point, so we lack info on what kind of vehicle we are dealing with */
 
			w->caption_color = GB(w->window_number, 0, 8); // OwnerID is stored in the last 8 bits of the window number
 
			switch (vehicle_type) {
 
				case VEH_Train:
 
					vl->flags = VL_REBUILD | (_sorting.train.order << (VL_DESC - 1));
 
					vl->sort_type = _sorting.train.criteria;
 
					break;
 
				case VEH_Road:
 
					vl->flags = VL_REBUILD | (_sorting.roadveh.order << (VL_DESC - 1));
 
					vl->sort_type = _sorting.roadveh.criteria;
 
					break;
 
				case VEH_Ship:
 
					vl->flags = VL_REBUILD | (_sorting.ship.order << (VL_DESC - 1));
 
					vl->sort_type = _sorting.ship.criteria;
 
					break;
 
				case VEH_Aircraft:
 
					vl->flags = VL_REBUILD | (_sorting.aircraft.order << (VL_DESC - 1));
 
					vl->sort_type = _sorting.aircraft.criteria;
 
					break;
 
				default: NOT_REACHED(); break;
 
			}
 
			vl->sort_list = NULL;
 
			vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;	// Set up resort timer
 
			break;
 

	
 
		case WE_DESTROY:
 
			free((void*)vl->sort_list);
0 comments (0 inline, 0 general)