aircraft_gui.c
changeset 168 79f9ed5b23e6
parent 164 0cbdf3c9bde1
child 174 bd79fb899824
--- a/aircraft_gui.c	Mon Sep 06 20:51:25 2004 +0000
+++ b/aircraft_gui.c	Mon Sep 06 21:20:01 2004 +0000
@@ -908,11 +908,9 @@
 		n =							_num_aircraft_sort[owner] - _num_aircraft_sort[owner-1];
 	}
 
-	_internal_sort_type				= _aircraft_sort_type[owner];
 	_internal_sort_order			= _aircraft_sort_order[owner];
 	_internal_name_sorter_id	= STR_SV_AIRCRAFT_NAME;
-	// only name sorting needs a different procedure, all others are handled by the general sorter
-	qsort(firstelement, n, sizeof(_aircraft_sort[0]), (_internal_sort_type == SORT_BY_NAME) ? VehicleNameSorter : GeneralVehicleSorter);
+	qsort(firstelement, n, sizeof(_aircraft_sort[0]), _vehicle_sorter[_aircraft_sort_type[owner]]);
 
 	DEBUG(misc, 1) ("Resorting Aircraft list player %d...", owner+1);
 }
@@ -925,7 +923,7 @@
 		const byte window_number = (byte)w->window_number;
 
 		if (_aircraft_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria
-			w->disabled_state |= (1 << 3);
+			w->disabled_state |= (1 << 2);
 
 		if (_aircraft_sort_dirty[window_number] || _vehicle_sort_dirty[VEHAIRCRAFT]) {
 			_aircraft_sort_dirty[window_number] = false;
@@ -947,11 +945,12 @@
 			SET_DPARAM16(0, p->name_1);
 			SET_DPARAM32(1, p->name_2);
 			SET_DPARAM16(2, w->vscroll.count);
-			SET_DPARAM16(3, _vehicle_sort_listing[_aircraft_sort_type[window_number]]);
 			DrawWindowWidgets(w);
 		}
+		/* draw sorting criteria string */
+		DrawString(85, 15, _vehicle_sort_listing[_aircraft_sort_type[window_number]], 0x10);
 		/* draw arrow pointing up/down for ascending/descending soring */
-		DoDrawString(_aircraft_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 85, 15, 0x10);
+		DoDrawString(_aircraft_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10);
 
 		/* draw the aircraft */
 		{
@@ -997,13 +996,13 @@
 
 	case WE_CLICK: {
 		switch(e->click.widget) {
-		case 3: /* Flip sorting method ascending/descending */
+		case 2: /* Flip sorting method ascending/descending */
 			_aircraft_sort_order[(byte)w->window_number] ^= 1;
 			_aircraft_sort_dirty[(byte)w->window_number] = true;
 			SetWindowDirty(w);
 			break;
-		case 4: case 5:/* Select sorting criteria dropdown menu */
-			ShowDropDownMenu(w, _vehicle_sort_listing, _aircraft_sort_type[(byte)w->window_number], 5, 0); // do it for widget 5
+		case 3: case 4:/* Select sorting criteria dropdown menu */
+			ShowDropDownMenu(w, _vehicle_sort_listing, _aircraft_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4
 			return;
 		case 6: { /* Matrix to show vehicles */
 			int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
@@ -1053,7 +1052,7 @@
 		_aircraft_sort_type[(byte)w->window_number] = e->dropdown.index;
 
 		if (_aircraft_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen
-			w->disabled_state &= ~(1 << 3);
+			w->disabled_state &= ~(1 << 2);
 
 		SetWindowDirty(w);
 		break;
@@ -1078,10 +1077,10 @@
 static const Widget _player_aircraft_widgets[] = {
 {   WWT_CLOSEBOX,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,    14,    11,   259,     0,    13, STR_A009_AIRCRAFT,			STR_018C_WINDOW_TITLE_DRAG_THIS},
-{      WWT_PANEL,    14,     0,    15,    14,    25, 0x0,										0},
-{ WWT_PUSHTXTBTN,    14,    16,    96,    14,    25, SRT_SORT_BY,						STR_SORT_TIP},
-{    WWT_TEXTBTN,    14,    97,   248,    14,    25, STR_02E7,							0},
-{   WWT_CLOSEBOX,    14,   249,   259,    14,    25, STR_0225,							STR_SORT_TIP},
+{ WWT_PUSHTXTBTN,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_TIP},
+{      WWT_PANEL,    14,    81,   237,    14,    25, 0x0,										STR_SORT_TIP},
+{   WWT_CLOSEBOX,    14,   238,   248,    14,    25, STR_0225,							STR_SORT_TIP},
+{      WWT_PANEL,    14,   249,   259,    14,    25, 0x0,										0},
 {     WWT_MATRIX,    14,     0,   248,    26,   169, 0x401,									STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT},
 {  WWT_SCROLLBAR,    14,   249,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
 { WWT_PUSHTXTBTN,    14,     0,   129,   170,   181, STR_A003_NEW_AIRCRAFT,	STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES},
@@ -1092,7 +1091,7 @@
 static const WindowDesc _player_aircraft_desc = {
 	-1, -1, 260, 182,
 	WC_AIRCRAFT_LIST,0,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
 	_player_aircraft_widgets,
 	PlayerAircraftWndProc
 };
@@ -1100,10 +1099,10 @@
 static const Widget _other_player_aircraft_widgets[] = {
 {   WWT_CLOSEBOX,    14,     0,    10,     0,    13, STR_00C5,							STR_018B_CLOSE_WINDOW},
 {    WWT_CAPTION,    14,    11,   259,     0,    13, STR_A009_AIRCRAFT,			STR_018C_WINDOW_TITLE_DRAG_THIS},
-{      WWT_PANEL,    14,     0,    15,    14,    25, 0x0,										0},
-{ WWT_PUSHTXTBTN,    14,    16,    96,    14,    25, SRT_SORT_BY,						STR_SORT_TIP},
-{    WWT_TEXTBTN,    14,    97,   248,    14,    25, STR_02E7,							0},
-{   WWT_CLOSEBOX,    14,   249,   259,    14,    25, STR_0225,							STR_SORT_TIP},
+{ WWT_PUSHTXTBTN,    14,     0,    80,    14,    25, SRT_SORT_BY,						STR_SORT_TIP},
+{      WWT_PANEL,    14,    81,   237,    14,    25, 0x0,										STR_SORT_TIP},
+{   WWT_CLOSEBOX,    14,   238,   248,    14,    25, STR_0225,							STR_SORT_TIP},
+{      WWT_PANEL,    14,   249,   259,    14,    25, 0x0,										0},
 {     WWT_MATRIX,    14,     0,   248,    26,   169, 0x401,									STR_A01F_AIRCRAFT_CLICK_ON_AIRCRAFT},
 {  WWT_SCROLLBAR,    14,   249,   259,    26,   169, 0x0,										STR_0190_SCROLL_BAR_SCROLLS_LIST},
 {      WWT_LAST},
@@ -1112,7 +1111,7 @@
 static const WindowDesc _other_player_aircraft_desc = {
 	-1, -1, 260, 170,
 	WC_AIRCRAFT_LIST,0,
-	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESTORE_DPARAM,
+	WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS,
 	_other_player_aircraft_widgets,
 	PlayerAircraftWndProc
 };