Changeset - r4665:e4b54323d415
[Not reviewed]
master
0 1 0
bjarni - 18 years ago 2006-09-28 18:13:31
bjarni@openttd.org
(svn r6559) -Codechange: [vehicle list windows] moved creation and drawing code into two new functions to make it easier to see what goes on where
1 file changed with 31 insertions and 14 deletions:
0 comments (0 inline, 0 general)
vehicle_gui.c
Show inline comments
 
@@ -1200,25 +1200,19 @@ void ChangeVehicleViewWindow(const Vehic
 
	}
 
}
 

	
 
/*
 
 * Start of functions regarding vehicle list windows
 
 */
 

	
 
enum {
 
	PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
 
	PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
 
	PLY_WND_PRC__SIZE_OF_ROW_BIG   = 36,
 
};
 

	
 
/*
 
 * bitmask for w->window_number
 
 * 0-7 PlayerID (owner)
 
 * 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)
 
 **/
 
void PlayerVehWndProc(Window *w, WindowEvent *e)
 
static void CreateVehicleListWindow(Window *w)
 
{
 
	vehiclelist_d *vl = &WP(w, vehiclelist_d);
 

	
 
	switch (e->event) {
 
		case WE_CREATE: {
 
			uint16 window_type = w->window_number & VLW_MASK;
 
			vl->vehicle_type = GB(w->window_number, 11, 5);
 
			w->caption_color = GB(w->window_number, 0, 8); // PlayerID
 
@@ -1277,9 +1271,12 @@ void PlayerVehWndProc(Window *w, WindowE
 
			vl->l.sort_type = vl->_sorting->criteria;
 
			vl->sort_list = NULL;
 
			vl->l.resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;	// Set up resort timer
 
		} break;
 

	
 
}
 

	
 
		case WE_PAINT: {
 
static void DrawVehicleListWindow(Window *w)
 
{
 
	vehiclelist_d *vl = &WP(w, vehiclelist_d);
 
			int x = 2;
 
			int y = PLY_WND_PRC__OFFSET_TOP_WIDGET;
 
			int max;
 
@@ -1390,7 +1387,27 @@ void PlayerVehWndProc(Window *w, WindowE
 

	
 
				y += w->resize.step_height;
 
			}
 
		}	break;
 
}
 

	
 
/*
 
 * bitmask for w->window_number
 
 * 0-7 PlayerID (owner)
 
 * 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)
 
 **/
 
void PlayerVehWndProc(Window *w, WindowEvent *e)
 
{
 
	vehiclelist_d *vl = &WP(w, vehiclelist_d);
 

	
 
	switch (e->event) {
 
		case WE_CREATE:
 
			CreateVehicleListWindow(w);
 
			break;
 

	
 
		case WE_PAINT:
 
			DrawVehicleListWindow(w);
 
			break;
 

	
 
		case WE_CLICK: {
 
			switch (e->we.click.widget) {
0 comments (0 inline, 0 general)