mirror of https://github.com/OpenTTD/OpenTTD
(svn r169) -Fix: move around sort-widgets a bit so it looks more natural
-Fix: savegames are sorted with newest date first by default -Codechange: refine sorter functions -Fix: fixed linux warnings (tokai)release/0.4.5
parent
b7774b2ed3
commit
78b64ed192
|
@ -908,11 +908,9 @@ static void MakeSortedAircraftList(byte owner)
|
||||||
n = _num_aircraft_sort[owner] - _num_aircraft_sort[owner-1];
|
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_sort_order = _aircraft_sort_order[owner];
|
||||||
_internal_name_sorter_id = STR_SV_AIRCRAFT_NAME;
|
_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]), _vehicle_sorter[_aircraft_sort_type[owner]]);
|
||||||
qsort(firstelement, n, sizeof(_aircraft_sort[0]), (_internal_sort_type == SORT_BY_NAME) ? VehicleNameSorter : GeneralVehicleSorter);
|
|
||||||
|
|
||||||
DEBUG(misc, 1) ("Resorting Aircraft list player %d...", owner+1);
|
DEBUG(misc, 1) ("Resorting Aircraft list player %d...", owner+1);
|
||||||
}
|
}
|
||||||
|
@ -925,7 +923,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
const byte window_number = (byte)w->window_number;
|
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
|
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]) {
|
if (_aircraft_sort_dirty[window_number] || _vehicle_sort_dirty[VEHAIRCRAFT]) {
|
||||||
_aircraft_sort_dirty[window_number] = false;
|
_aircraft_sort_dirty[window_number] = false;
|
||||||
|
@ -947,11 +945,12 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
SET_DPARAM16(0, p->name_1);
|
SET_DPARAM16(0, p->name_1);
|
||||||
SET_DPARAM32(1, p->name_2);
|
SET_DPARAM32(1, p->name_2);
|
||||||
SET_DPARAM16(2, w->vscroll.count);
|
SET_DPARAM16(2, w->vscroll.count);
|
||||||
SET_DPARAM16(3, _vehicle_sort_listing[_aircraft_sort_type[window_number]]);
|
|
||||||
DrawWindowWidgets(w);
|
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 */
|
/* 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 */
|
/* draw the aircraft */
|
||||||
{
|
{
|
||||||
|
@ -997,13 +996,13 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_CLICK: {
|
case WE_CLICK: {
|
||||||
switch(e->click.widget) {
|
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_order[(byte)w->window_number] ^= 1;
|
||||||
_aircraft_sort_dirty[(byte)w->window_number] = true;
|
_aircraft_sort_dirty[(byte)w->window_number] = true;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 4: case 5:/* Select sorting criteria dropdown menu */
|
case 3: case 4:/* Select sorting criteria dropdown menu */
|
||||||
ShowDropDownMenu(w, _vehicle_sort_listing, _aircraft_sort_type[(byte)w->window_number], 5, 0); // do it for widget 5
|
ShowDropDownMenu(w, _vehicle_sort_listing, _aircraft_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4
|
||||||
return;
|
return;
|
||||||
case 6: { /* Matrix to show vehicles */
|
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;
|
int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
|
||||||
|
@ -1053,7 +1052,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
_aircraft_sort_type[(byte)w->window_number] = e->dropdown.index;
|
_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
|
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);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
@ -1078,10 +1077,10 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
static const Widget _player_aircraft_widgets[] = {
|
static const Widget _player_aircraft_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ 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_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, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, STR_SORT_TIP},
|
||||||
{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 249, 259, 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_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_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},
|
{ WWT_PUSHTXTBTN, 14, 0, 129, 170, 181, STR_A003_NEW_AIRCRAFT, STR_A020_BUILD_NEW_AIRCRAFT_REQUIRES},
|
||||||
|
@ -1092,7 +1091,7 @@ static const Widget _player_aircraft_widgets[] = {
|
||||||
static const WindowDesc _player_aircraft_desc = {
|
static const WindowDesc _player_aircraft_desc = {
|
||||||
-1, -1, 260, 182,
|
-1, -1, 260, 182,
|
||||||
WC_AIRCRAFT_LIST,0,
|
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,
|
_player_aircraft_widgets,
|
||||||
PlayerAircraftWndProc
|
PlayerAircraftWndProc
|
||||||
};
|
};
|
||||||
|
@ -1100,10 +1099,10 @@ static const WindowDesc _player_aircraft_desc = {
|
||||||
static const Widget _other_player_aircraft_widgets[] = {
|
static const Widget _other_player_aircraft_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ 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_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, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, STR_SORT_TIP},
|
||||||
{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 249, 259, 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_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_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_LAST},
|
{ WWT_LAST},
|
||||||
|
@ -1112,7 +1111,7 @@ static const Widget _other_player_aircraft_widgets[] = {
|
||||||
static const WindowDesc _other_player_aircraft_desc = {
|
static const WindowDesc _other_player_aircraft_desc = {
|
||||||
-1, -1, 260, 170,
|
-1, -1, 260, 170,
|
||||||
WC_AIRCRAFT_LIST,0,
|
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,
|
_other_player_aircraft_widgets,
|
||||||
PlayerAircraftWndProc
|
PlayerAircraftWndProc
|
||||||
};
|
};
|
||||||
|
|
|
@ -738,7 +738,7 @@ bool DoZoomInOutWindow(int how, Window *w)
|
||||||
|
|
||||||
// routine to disable/enable the zoom buttons. Didn't know where to place these otherwise
|
// routine to disable/enable the zoom buttons. Didn't know where to place these otherwise
|
||||||
{
|
{
|
||||||
Window * wt;
|
Window *wt = NULL;
|
||||||
switch (w->window_class) {
|
switch (w->window_class) {
|
||||||
case WC_MAIN_WINDOW:
|
case WC_MAIN_WINDOW:
|
||||||
wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
wt = FindWindowById(WC_MAIN_TOOLBAR, 0);
|
||||||
|
|
|
@ -747,11 +747,9 @@ static void MakeSortedRoadList(byte owner)
|
||||||
n = _num_road_sort[owner] - _num_road_sort[owner-1];
|
n = _num_road_sort[owner] - _num_road_sort[owner-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
_internal_sort_type = _road_sort_type[owner];
|
|
||||||
_internal_sort_order = _road_sort_order[owner];
|
_internal_sort_order = _road_sort_order[owner];
|
||||||
_internal_name_sorter_id = STR_SV_ROADVEH_NAME;
|
_internal_name_sorter_id = STR_SV_ROADVEH_NAME;
|
||||||
// only name sorting needs a different procedure, all others are handled by the general sorter
|
qsort(firstelement, n, sizeof(_road_sort[0]), _vehicle_sorter[_road_sort_type[owner]]);
|
||||||
qsort(firstelement, n, sizeof(_road_sort[0]), (_internal_sort_type == SORT_BY_NAME) ? VehicleNameSorter : GeneralVehicleSorter);
|
|
||||||
|
|
||||||
DEBUG(misc, 1) ("Resorting Roadvehicles list player %d...", owner+1);
|
DEBUG(misc, 1) ("Resorting Roadvehicles list player %d...", owner+1);
|
||||||
}
|
}
|
||||||
|
@ -764,7 +762,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
const byte window_number = (byte)w->window_number;
|
const byte window_number = (byte)w->window_number;
|
||||||
|
|
||||||
if (_road_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria
|
if (_road_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 (_road_sort_dirty[window_number] || _vehicle_sort_dirty[VEHROAD]) {
|
if (_road_sort_dirty[window_number] || _vehicle_sort_dirty[VEHROAD]) {
|
||||||
_road_sort_dirty[window_number] = false;
|
_road_sort_dirty[window_number] = false;
|
||||||
|
@ -786,11 +784,12 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
SET_DPARAM16(0, p->name_1);
|
SET_DPARAM16(0, p->name_1);
|
||||||
SET_DPARAM32(1, p->name_2);
|
SET_DPARAM32(1, p->name_2);
|
||||||
SET_DPARAM16(2, w->vscroll.count);
|
SET_DPARAM16(2, w->vscroll.count);
|
||||||
SET_DPARAM16(3, _vehicle_sort_listing[_road_sort_type[window_number]]);
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
}
|
}
|
||||||
|
/* draw sorting criteria string */
|
||||||
|
DrawString(85, 15, _vehicle_sort_listing[_road_sort_type[window_number]], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending soring */
|
/* draw arrow pointing up/down for ascending/descending soring */
|
||||||
DoDrawString(_road_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 85, 15, 0x10);
|
DoDrawString(_road_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
|
|
||||||
/* draw the roadvehicles */
|
/* draw the roadvehicles */
|
||||||
{
|
{
|
||||||
|
@ -833,13 +832,13 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_CLICK: {
|
case WE_CLICK: {
|
||||||
switch(e->click.widget) {
|
switch(e->click.widget) {
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 2: /* Flip sorting method ascending/descending */
|
||||||
_road_sort_order[(byte)w->window_number] ^= 1;
|
_road_sort_order[(byte)w->window_number] ^= 1;
|
||||||
_road_sort_dirty[(byte)w->window_number] = true;
|
_road_sort_dirty[(byte)w->window_number] = true;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 4: case 5:/* Select sorting criteria dropdown menu */
|
case 3: case 4:/* Select sorting criteria dropdown menu */
|
||||||
ShowDropDownMenu(w, _vehicle_sort_listing, _road_sort_type[(byte)w->window_number], 5, 0); // do it for widget 5
|
ShowDropDownMenu(w, _vehicle_sort_listing, _road_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4
|
||||||
return;
|
return;
|
||||||
case 6: { /* Matrix to show vehicles */
|
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_SMALL;
|
int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
|
||||||
|
@ -889,7 +888,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
_road_sort_type[(byte)w->window_number] = e->dropdown.index;
|
_road_sort_type[(byte)w->window_number] = e->dropdown.index;
|
||||||
|
|
||||||
if (_road_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen
|
if (_road_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);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
@ -914,21 +913,21 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
static const Widget _player_roadveh_widgets[] = {
|
static const Widget _player_roadveh_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
{ WWT_PANEL, 14, 0, 15, 14, 25, 0x0, 0},
|
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, STR_SORT_TIP},
|
||||||
{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 249, 259, 14, 25, STR_0225, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, 0},
|
||||||
{ WWT_MATRIX, 14, 0, 248, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON},
|
{ WWT_MATRIX, 14, 0, 248, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
|
||||||
{ WWT_SCROLLBAR, 14, 249, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
{ WWT_SCROLLBAR, 14, 249, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_PUSHTXTBTN, 14, 0, 129, 208, 219, STR_9004_NEW_VEHICLES, STR_901B_BUILD_NEW_ROAD_VEHICLES},
|
{ WWT_PUSHTXTBTN, 14, 0, 129, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES},
|
||||||
{ WWT_IMGBTN, 14, 130, 259, 208, 219, 0x0, 0},
|
{ WWT_PANEL, 14, 130, 259, 208, 219, 0x0, 0},
|
||||||
{ WWT_LAST},
|
{ WWT_LAST},
|
||||||
};
|
};
|
||||||
|
|
||||||
static const WindowDesc _player_roadveh_desc = {
|
static const WindowDesc _player_roadveh_desc = {
|
||||||
-1, -1, 260, 220,
|
-1, -1, 260, 220,
|
||||||
WC_ROADVEH_LIST,0,
|
WC_ROADVEH_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_roadveh_widgets,
|
_player_roadveh_widgets,
|
||||||
PlayerRoadVehWndProc
|
PlayerRoadVehWndProc
|
||||||
};
|
};
|
||||||
|
@ -936,11 +935,11 @@ static const WindowDesc _player_roadveh_desc = {
|
||||||
static const Widget _other_player_roadveh_widgets[] = {
|
static const Widget _other_player_roadveh_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9001_ROAD_VEHICLES, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
{ WWT_PANEL, 14, 0, 15, 14, 25, 0x0, 0},
|
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, STR_SORT_TIP},
|
||||||
{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 249, 259, 14, 25, STR_0225, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 249, 259, 14, 25, 0x0, 0},
|
||||||
{ WWT_MATRIX, 14, 0, 248, 26, 207, 0x701, STR_901A_ROAD_VEHICLES_CLICK_ON},
|
{ WWT_MATRIX, 14, 0, 248, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
|
||||||
{ WWT_SCROLLBAR, 14, 249, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
{ WWT_SCROLLBAR, 14, 249, 259, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_LAST},
|
{ WWT_LAST},
|
||||||
};
|
};
|
||||||
|
@ -948,7 +947,7 @@ static const Widget _other_player_roadveh_widgets[] = {
|
||||||
static const WindowDesc _other_player_roadveh_desc = {
|
static const WindowDesc _other_player_roadveh_desc = {
|
||||||
-1, -1, 260, 208,
|
-1, -1, 260, 208,
|
||||||
WC_ROADVEH_LIST,0,
|
WC_ROADVEH_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_roadveh_widgets,
|
_other_player_roadveh_widgets,
|
||||||
PlayerRoadVehWndProc
|
PlayerRoadVehWndProc
|
||||||
};
|
};
|
||||||
|
|
40
ship_gui.c
40
ship_gui.c
|
@ -911,11 +911,9 @@ static void MakeSortedShiptList(byte owner)
|
||||||
n = _num_ship_sort[owner] - _num_ship_sort[owner-1];
|
n = _num_ship_sort[owner] - _num_ship_sort[owner-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
_internal_sort_type = _ship_sort_type[owner];
|
|
||||||
_internal_sort_order = _ship_sort_order[owner];
|
_internal_sort_order = _ship_sort_order[owner];
|
||||||
_internal_name_sorter_id = STR_SV_SHIP_NAME;
|
_internal_name_sorter_id = STR_SV_SHIP_NAME;
|
||||||
// only name sorting needs a different procedure, all others are handled by the general sorter
|
qsort(firstelement, n, sizeof(_ship_sort[0]), _vehicle_sorter[_ship_sort_type[owner]]);
|
||||||
qsort(firstelement, n, sizeof(_ship_sort[0]), (_internal_sort_type == SORT_BY_NAME) ? VehicleNameSorter : GeneralVehicleSorter);
|
|
||||||
|
|
||||||
DEBUG(misc, 1) ("Resorting Ships list player %d...", owner+1);
|
DEBUG(misc, 1) ("Resorting Ships list player %d...", owner+1);
|
||||||
}
|
}
|
||||||
|
@ -928,7 +926,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
const byte window_number = (byte)w->window_number;
|
const byte window_number = (byte)w->window_number;
|
||||||
|
|
||||||
if (_ship_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria
|
if (_ship_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 (_ship_sort_dirty[window_number] || _vehicle_sort_dirty[VEHSHIP]) {
|
if (_ship_sort_dirty[window_number] || _vehicle_sort_dirty[VEHSHIP]) {
|
||||||
_ship_sort_dirty[window_number] = false;
|
_ship_sort_dirty[window_number] = false;
|
||||||
|
@ -950,11 +948,12 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
SET_DPARAM16(0, p->name_1);
|
SET_DPARAM16(0, p->name_1);
|
||||||
SET_DPARAM32(1, p->name_2);
|
SET_DPARAM32(1, p->name_2);
|
||||||
SET_DPARAM16(2, w->vscroll.count);
|
SET_DPARAM16(2, w->vscroll.count);
|
||||||
SET_DPARAM16(3, _vehicle_sort_listing[_ship_sort_type[window_number]]);
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
}
|
}
|
||||||
|
/* draw sorting criteria string */
|
||||||
|
DrawString(85, 15, _vehicle_sort_listing[_ship_sort_type[window_number]], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending soring */
|
/* draw arrow pointing up/down for ascending/descending soring */
|
||||||
DoDrawString(_ship_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 85, 15, 0x10);
|
DoDrawString(_ship_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
|
|
||||||
/* draw the ship vehicles */
|
/* draw the ship vehicles */
|
||||||
{
|
{
|
||||||
|
@ -1000,13 +999,13 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_CLICK: {
|
case WE_CLICK: {
|
||||||
switch(e->click.widget) {
|
switch(e->click.widget) {
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 2: /* Flip sorting method ascending/descending */
|
||||||
_ship_sort_order[(byte)w->window_number] ^= 1;
|
_ship_sort_order[(byte)w->window_number] ^= 1;
|
||||||
_ship_sort_dirty[(byte)w->window_number] = true;
|
_ship_sort_dirty[(byte)w->window_number] = true;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 4: case 5:/* Select sorting criteria dropdown menu */
|
case 3: case 4:/* Select sorting criteria dropdown menu */
|
||||||
ShowDropDownMenu(w, _vehicle_sort_listing, _ship_sort_type[(byte)w->window_number], 5, 0); // do it for widget 5
|
ShowDropDownMenu(w, _vehicle_sort_listing, _ship_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4
|
||||||
return;
|
return;
|
||||||
case 6: { /* Matrix to show vehicles */
|
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;
|
int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_BIG;
|
||||||
|
@ -1056,7 +1055,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
_ship_sort_type[(byte)w->window_number] = e->dropdown.index;
|
_ship_sort_type[(byte)w->window_number] = e->dropdown.index;
|
||||||
|
|
||||||
if (_ship_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen
|
if (_ship_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);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
@ -1077,13 +1076,14 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static const Widget _player_ships_widgets[] = {
|
static const Widget _player_ships_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
{ WWT_PANEL, 14, 0, 15, 14, 25, 0x0, 0},
|
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, 0},
|
||||||
{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 249, 259, 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_9823_SHIPS_CLICK_ON_SHIP_FOR},
|
{ WWT_MATRIX, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
|
||||||
{ WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
{ WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_PUSHTXTBTN, 14, 0, 129, 170, 181, STR_9804_NEW_SHIPS, STR_9824_BUILD_NEW_SHIPS_REQUIRES},
|
{ WWT_PUSHTXTBTN, 14, 0, 129, 170, 181, STR_9804_NEW_SHIPS, STR_9824_BUILD_NEW_SHIPS_REQUIRES},
|
||||||
|
@ -1094,7 +1094,7 @@ static const Widget _player_ships_widgets[] = {
|
||||||
static const WindowDesc _player_ships_desc = {
|
static const WindowDesc _player_ships_desc = {
|
||||||
-1, -1, 260, 182,
|
-1, -1, 260, 182,
|
||||||
WC_SHIPS_LIST,0,
|
WC_SHIPS_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_ships_widgets,
|
_player_ships_widgets,
|
||||||
PlayerShipsWndProc
|
PlayerShipsWndProc
|
||||||
};
|
};
|
||||||
|
@ -1102,10 +1102,10 @@ static const WindowDesc _player_ships_desc = {
|
||||||
static const Widget _other_player_ships_widgets[] = {
|
static const Widget _other_player_ships_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, 14, 11, 259, 0, 13, STR_9805_SHIPS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
{ WWT_PANEL, 14, 0, 15, 14, 25, 0x0, 0},
|
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 16, 96, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 237, 14, 25, 0x0, 0},
|
||||||
{ WWT_TEXTBTN, 14, 97, 248, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 238, 248, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 249, 259, 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_9823_SHIPS_CLICK_ON_SHIP_FOR},
|
{ WWT_MATRIX, 14, 0, 248, 26, 169, 0x401, STR_9823_SHIPS_CLICK_ON_SHIP_FOR},
|
||||||
{ WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
{ WWT_SCROLLBAR, 14, 249, 259, 26, 169, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_LAST},
|
{ WWT_LAST},
|
||||||
|
@ -1114,7 +1114,7 @@ static const Widget _other_player_ships_widgets[] = {
|
||||||
static const WindowDesc _other_player_ships_desc = {
|
static const WindowDesc _other_player_ships_desc = {
|
||||||
-1, -1, 260, 170,
|
-1, -1, 260, 170,
|
||||||
WC_SHIPS_LIST,0,
|
WC_SHIPS_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_ships_widgets,
|
_other_player_ships_widgets,
|
||||||
PlayerShipsWndProc
|
PlayerShipsWndProc
|
||||||
};
|
};
|
||||||
|
|
39
train_gui.c
39
train_gui.c
|
@ -1180,11 +1180,9 @@ static void MakeSortedTrainList(byte owner)
|
||||||
n = _num_train_sort[owner] - _num_train_sort[owner-1];
|
n = _num_train_sort[owner] - _num_train_sort[owner-1];
|
||||||
}
|
}
|
||||||
|
|
||||||
_internal_sort_type = _train_sort_type[owner];
|
|
||||||
_internal_sort_order = _train_sort_order[owner];
|
_internal_sort_order = _train_sort_order[owner];
|
||||||
_internal_name_sorter_id = STR_SV_TRAIN_NAME;
|
_internal_name_sorter_id = STR_SV_TRAIN_NAME;
|
||||||
// only name sorting needs a different procedure, all others are handled by the general sorter
|
qsort(firstelement, n, sizeof(_train_sort[0]), _vehicle_sorter[_train_sort_type[owner]]);
|
||||||
qsort(firstelement, n, sizeof(_train_sort[0]), (_internal_sort_type == SORT_BY_NAME) ? VehicleNameSorter : GeneralVehicleSorter);
|
|
||||||
|
|
||||||
DEBUG(misc, 1) ("Resorting Trains list player %d...", owner+1);
|
DEBUG(misc, 1) ("Resorting Trains list player %d...", owner+1);
|
||||||
}
|
}
|
||||||
|
@ -1197,7 +1195,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
const byte window_number = (byte)w->window_number;
|
const byte window_number = (byte)w->window_number;
|
||||||
|
|
||||||
if (_train_sort_type[window_number] == SORT_BY_UNSORTED) // disable 'Sort By' tooltip on Unsorted sorting criteria
|
if (_train_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 (_train_sort_dirty[window_number] || _vehicle_sort_dirty[VEHTRAIN]) {
|
if (_train_sort_dirty[window_number] || _vehicle_sort_dirty[VEHTRAIN]) {
|
||||||
_train_sort_dirty[window_number] = false;
|
_train_sort_dirty[window_number] = false;
|
||||||
|
@ -1219,11 +1217,12 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
SET_DPARAM16(0, p->name_1);
|
SET_DPARAM16(0, p->name_1);
|
||||||
SET_DPARAM32(1, p->name_2);
|
SET_DPARAM32(1, p->name_2);
|
||||||
SET_DPARAM16(2, w->vscroll.count);
|
SET_DPARAM16(2, w->vscroll.count);
|
||||||
SET_DPARAM16(3, _vehicle_sort_listing[_train_sort_type[window_number]]);
|
|
||||||
DrawWindowWidgets(w);
|
DrawWindowWidgets(w);
|
||||||
}
|
}
|
||||||
|
/* draw sorting criteria string */
|
||||||
|
DrawString(85, 15, _vehicle_sort_listing[_train_sort_type[window_number]], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending soring */
|
/* draw arrow pointing up/down for ascending/descending soring */
|
||||||
DoDrawString(_train_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 150, 15, 0x10);
|
DoDrawString(_train_sort_order[window_number] & 1 ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
|
|
||||||
/* draw the trains */
|
/* draw the trains */
|
||||||
{
|
{
|
||||||
|
@ -1266,13 +1265,13 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
|
|
||||||
case WE_CLICK: {
|
case WE_CLICK: {
|
||||||
switch(e->click.widget) {
|
switch(e->click.widget) {
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 2: /* Flip sorting method ascending/descending */
|
||||||
_train_sort_order[(byte)w->window_number] ^= 1;
|
_train_sort_order[(byte)w->window_number] ^= 1;
|
||||||
_train_sort_dirty[(byte)w->window_number] = true;
|
_train_sort_dirty[(byte)w->window_number] = true;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 4: case 5:/* Select sorting criteria dropdown menu */
|
case 3: case 4:/* Select sorting criteria dropdown menu */
|
||||||
ShowDropDownMenu(w, _vehicle_sort_listing, _train_sort_type[(byte)w->window_number], 5, 0); // do it for widget 5
|
ShowDropDownMenu(w, _vehicle_sort_listing, _train_sort_type[(byte)w->window_number], 4, 0); // do it for widget 4
|
||||||
return;
|
return;
|
||||||
case 6: { /* Matrix to show vehicles */
|
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_SMALL;
|
int id_v = (e->click.pt.y - PLY_WND_PRC__OFFSET_TOP_WIDGET) / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
|
||||||
|
@ -1322,7 +1321,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
_train_sort_type[(byte)w->window_number] = e->dropdown.index;
|
_train_sort_type[(byte)w->window_number] = e->dropdown.index;
|
||||||
|
|
||||||
if (_train_sort_type[(byte)w->window_number] != SORT_BY_UNSORTED) // enable 'Sort By' if a sorter criteria is chosen
|
if (_train_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);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
@ -1347,10 +1346,10 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
static const Widget _player_trains_widgets[] = {
|
static const Widget _player_trains_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
{ WWT_PANEL, 14, 0, 80, 14, 25, 0x0, 0},
|
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 81, 161, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP},
|
||||||
{ WWT_TEXTBTN, 14, 162, 313, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 314, 324, 14, 25, STR_0225, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 244, 324, 14, 25, 0x0, 0},
|
||||||
{ WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
|
{ WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
|
||||||
{ WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
{ WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_PUSHTXTBTN, 14, 0, 161, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES},
|
{ WWT_PUSHTXTBTN, 14, 0, 161, 208, 219, STR_8815_NEW_VEHICLES, STR_883E_BUILD_NEW_TRAINS_REQUIRES},
|
||||||
|
@ -1361,7 +1360,7 @@ static const Widget _player_trains_widgets[] = {
|
||||||
static const WindowDesc _player_trains_desc = {
|
static const WindowDesc _player_trains_desc = {
|
||||||
-1, -1, 325, 220,
|
-1, -1, 325, 220,
|
||||||
WC_TRAINS_LIST,0,
|
WC_TRAINS_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_trains_widgets,
|
_player_trains_widgets,
|
||||||
PlayerTrainsWndProc
|
PlayerTrainsWndProc
|
||||||
};
|
};
|
||||||
|
@ -1369,10 +1368,10 @@ static const WindowDesc _player_trains_desc = {
|
||||||
static const Widget _other_player_trains_widgets[] = {
|
static const Widget _other_player_trains_widgets[] = {
|
||||||
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
{ WWT_CLOSEBOX, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
|
||||||
{ WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
{ WWT_CAPTION, 14, 11, 324, 0, 13, STR_881B_TRAINS, STR_018C_WINDOW_TITLE_DRAG_THIS},
|
||||||
{ WWT_PANEL, 14, 0, 80, 14, 25, 0x0, 0},
|
{ WWT_PUSHTXTBTN, 14, 0, 80, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
||||||
{ WWT_PUSHTXTBTN, 14, 81, 161, 14, 25, SRT_SORT_BY, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 81, 232, 14, 25, 0x0, STR_SORT_TIP},
|
||||||
{ WWT_TEXTBTN, 14, 162, 313, 14, 25, STR_02E7, 0},
|
{ WWT_CLOSEBOX, 14, 233, 243, 14, 25, STR_0225, STR_SORT_TIP},
|
||||||
{ WWT_CLOSEBOX, 14, 314, 324, 14, 25, STR_0225, STR_SORT_TIP},
|
{ WWT_PANEL, 14, 244, 324, 14, 25, 0x0, 0},
|
||||||
{ WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
|
{ WWT_MATRIX, 14, 0, 313, 26, 207, 0x701, STR_883D_TRAINS_CLICK_ON_TRAIN_FOR},
|
||||||
{ WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
{ WWT_SCROLLBAR, 14, 314, 324, 26, 207, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
|
||||||
{ WWT_LAST},
|
{ WWT_LAST},
|
||||||
|
@ -1381,7 +1380,7 @@ static const Widget _other_player_trains_widgets[] = {
|
||||||
static const WindowDesc _other_player_trains_desc = {
|
static const WindowDesc _other_player_trains_desc = {
|
||||||
-1, -1, 325, 208,
|
-1, -1, 325, 208,
|
||||||
WC_TRAINS_LIST,0,
|
WC_TRAINS_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_trains_widgets,
|
_other_player_trains_widgets,
|
||||||
PlayerTrainsWndProc
|
PlayerTrainsWndProc
|
||||||
};
|
};
|
||||||
|
|
1
ttd.c
1
ttd.c
|
@ -581,6 +581,7 @@ int ttd_main(int argc, char* argv[])
|
||||||
LoadDriver(MUSIC_DRIVER, _ini_musicdriver);
|
LoadDriver(MUSIC_DRIVER, _ini_musicdriver);
|
||||||
LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads
|
LoadDriver(VIDEO_DRIVER, _ini_videodriver); // load video last, to prevent an empty window while sound and music loads
|
||||||
MusicLoop();
|
MusicLoop();
|
||||||
|
_savegame_sort_order = 1; // default sorting of savegames is by date, newest first
|
||||||
|
|
||||||
// Default difficulty level
|
// Default difficulty level
|
||||||
_opt_mod_ptr = &_new_opt;
|
_opt_mod_ptr = &_new_opt;
|
||||||
|
|
8
ttd.h
8
ttd.h
|
@ -524,10 +524,10 @@ enum Sprites {
|
||||||
};
|
};
|
||||||
|
|
||||||
enum MAP_OWNERS {
|
enum MAP_OWNERS {
|
||||||
OWNER_TOWN = 0xf, // a town owns the tile
|
OWNER_TOWN = 0xf, // a town owns the tile
|
||||||
OWNER_NONE = 0x10,// nobody owns the tile
|
OWNER_NONE = 0x10, // nobody owns the tile
|
||||||
OWNER_WATER = 0x11,// "water" owns the tile
|
OWNER_WATER = 0x11, // "water" owns the tile
|
||||||
OWNER_SPECTATOR = 0xff, // spectator in MP or in scenario editor
|
OWNER_SPECTATOR = 0xff, // spectator in MP or in scenario editor
|
||||||
};
|
};
|
||||||
|
|
||||||
VARDEF bool _savegame_sort_dirty;
|
VARDEF bool _savegame_sort_dirty;
|
||||||
|
|
205
vehicle_gui.c
205
vehicle_gui.c
|
@ -45,103 +45,150 @@ void DrawVehicleProfitButton(Vehicle *v, int x, int y)
|
||||||
/************ Sorter functions *****************/
|
/************ Sorter functions *****************/
|
||||||
int CDECL GeneralOwnerSorter(const void *a, const void *b)
|
int CDECL GeneralOwnerSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
return (*(SortStruct*)a).owner - (*(SortStruct*)b).owner;
|
return (*(const SortStruct*)a).owner - (*(const SortStruct*)b).owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Variables you need to set before calling this function!
|
||||||
|
* 1. (byte)_internal_sort_type: sorting criteria to sort on
|
||||||
|
* 2. (bool)_internal_sort_order: sorting order, descending/ascending
|
||||||
|
* 3. (uint32)_internal_name_sorter_id: default StringID of the vehicle when no name is set. eg
|
||||||
|
* STR_SV_TRAIN_NAME for trains or STR_SV_AIRCRAFT_NAME for aircraft
|
||||||
|
*/
|
||||||
|
int CDECL VehicleUnsortedSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
return DEREF_VEHICLE((*(const SortStruct*)a).index)->index - DEREF_VEHICLE((*(const SortStruct*)b).index)->index;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleNumberSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char _bufcache[64]; // used together with _last_vehicle_idx to hopefully speed up stringsorting
|
static char _bufcache[64]; // used together with _last_vehicle_idx to hopefully speed up stringsorting
|
||||||
|
|
||||||
/* Variables you need to set before calling this function!
|
|
||||||
* 1. (uint32)_internal_name_sorter_id: default StringID of the vehicle when no name is set. eg
|
|
||||||
* STR_SV_TRAIN_NAME for trains or STR_SV_AIRCRAFT_NAME for aircraft
|
|
||||||
* 2. (bool)_internal_sort_order: sorting order, descending/ascending
|
|
||||||
*/
|
|
||||||
int CDECL VehicleNameSorter(const void *a, const void *b)
|
int CDECL VehicleNameSorter(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
SortStruct *cmp1 = (SortStruct*)a;
|
const SortStruct *cmp1 = (SortStruct*)a;
|
||||||
SortStruct *cmp2 = (SortStruct*)b;
|
const SortStruct *cmp2 = (SortStruct*)b;
|
||||||
Vehicle *v;
|
const Vehicle *va = DEREF_VEHICLE(cmp1->index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE(cmp2->index);
|
||||||
char buf1[64] = "\0";
|
char buf1[64] = "\0";
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
v = DEREF_VEHICLE(cmp1->index);
|
if (va->string_id != _internal_name_sorter_id) {
|
||||||
if (v->string_id != _internal_name_sorter_id) {
|
SET_DPARAM16(0, va->string_id);
|
||||||
SET_DPARAM16(0, v->string_id);
|
|
||||||
GetString(buf1, STR_0315);
|
GetString(buf1, STR_0315);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( cmp2->index != _last_vehicle_idx) {
|
if ( cmp2->index != _last_vehicle_idx) {
|
||||||
_last_vehicle_idx = cmp2->index;
|
_last_vehicle_idx = cmp2->index;
|
||||||
v = DEREF_VEHICLE(cmp2->index);
|
|
||||||
_bufcache[0] = '\0';
|
_bufcache[0] = '\0';
|
||||||
if (v->string_id != _internal_name_sorter_id) {
|
if (vb->string_id != _internal_name_sorter_id) {
|
||||||
SET_DPARAM16(0, v->string_id);
|
SET_DPARAM16(0, vb->string_id);
|
||||||
GetString(_bufcache, STR_0315);
|
GetString(_bufcache, STR_0315);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
r = strcmp(buf1, _bufcache); // sort by name
|
r = strcmp(buf1, _bufcache); // sort by name
|
||||||
if (_internal_sort_order & 1) r = -r;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Variables you need to set before calling this function!
|
|
||||||
* 1. (byte)_internal_sort_type: the criteria by which to sort these vehicles (number, age, etc)
|
|
||||||
* 2. (bool)_internal_sort_order: sorting order, descending/ascending
|
|
||||||
*/
|
|
||||||
int CDECL GeneralVehicleSorter(const void *a, const void *b)
|
|
||||||
{
|
|
||||||
SortStruct *cmp1 = (SortStruct*)a;
|
|
||||||
SortStruct *cmp2 = (SortStruct*)b;
|
|
||||||
Vehicle *va = DEREF_VEHICLE(cmp1->index);
|
|
||||||
Vehicle *vb = DEREF_VEHICLE(cmp2->index);
|
|
||||||
int r;
|
|
||||||
|
|
||||||
switch (_internal_sort_type) {
|
|
||||||
case SORT_BY_UNSORTED: /* Sort unsorted */
|
|
||||||
return va->index - vb->index;
|
|
||||||
case SORT_BY_NUMBER: /* Sort by Number */
|
|
||||||
r = va->unitnumber - vb->unitnumber;
|
|
||||||
break;
|
|
||||||
/* case SORT_BY_NAME: Sort by Name (VehicleNameSorter)*/
|
|
||||||
case SORT_BY_AGE: /* Sort by Age */
|
|
||||||
r = va->age - vb->age;
|
|
||||||
break;
|
|
||||||
case SORT_BY_PROFIT_THIS_YEAR: /* Sort by Profit this year */
|
|
||||||
r = va->profit_this_year - vb->profit_this_year;
|
|
||||||
break;
|
|
||||||
case SORT_BY_PROFIT_LAST_YEAR: /* Sort by Profit last year */
|
|
||||||
r = va->profit_last_year - vb->profit_last_year;
|
|
||||||
break;
|
|
||||||
case SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE: { /* Sort by Total capacity per cargotype */
|
|
||||||
// FIXME - someone write a normal cargo sorter that also works by cargo_cap,
|
|
||||||
// FIXME - since I seem to be unable to do so :S
|
|
||||||
Vehicle *ua = va;
|
|
||||||
Vehicle *ub = vb;
|
|
||||||
int i;
|
|
||||||
byte _cargo_counta[NUM_CARGO];
|
|
||||||
byte _cargo_countb[NUM_CARGO];
|
|
||||||
do {
|
|
||||||
_cargo_counta[ua->cargo_type]++;
|
|
||||||
} while ( (ua = ua->next) != NULL);
|
|
||||||
do {
|
|
||||||
_cargo_countb[ub->cargo_type]++;
|
|
||||||
} while ( (ub = ub->next) != NULL);
|
|
||||||
|
|
||||||
for (i = 0; i < NUM_CARGO; i++) {
|
|
||||||
r = _cargo_counta[i] - _cargo_countb[i];
|
|
||||||
if (r != 0)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
case SORT_BY_RELIABILITY: /* Sort by Reliability */
|
|
||||||
r = va->reliability - vb->reliability;
|
|
||||||
break;
|
|
||||||
case SORT_BY_MAX_SPEED: /* Sort by Max speed */
|
|
||||||
r = va->max_speed - vb->max_speed;
|
|
||||||
break;
|
|
||||||
default: NOT_REACHED();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_internal_sort_order & 1) r = -r;
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
return r;
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleAgeSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = va->age - vb->age;
|
||||||
|
|
||||||
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleProfitThisYearSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = va->profit_this_year - vb->profit_this_year;
|
||||||
|
|
||||||
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleProfitLastYearSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = va->profit_last_year - vb->profit_last_year;
|
||||||
|
|
||||||
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleCargoSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
// FIXME - someone write a normal cargo sorter that also works by cargo_cap,
|
||||||
|
// FIXME - since I seem to be unable to do so :S
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = 0;
|
||||||
|
int i;
|
||||||
|
byte _cargo_counta[NUM_CARGO];
|
||||||
|
byte _cargo_countb[NUM_CARGO];
|
||||||
|
memset(_cargo_counta, 0, sizeof(_cargo_counta));
|
||||||
|
memset(_cargo_countb, 0, sizeof(_cargo_countb));
|
||||||
|
|
||||||
|
do {
|
||||||
|
_cargo_counta[va->cargo_type]++;
|
||||||
|
} while ( (va = va->next) != NULL);
|
||||||
|
|
||||||
|
do {
|
||||||
|
_cargo_countb[vb->cargo_type]++;
|
||||||
|
} while ( (vb = vb->next) != NULL);
|
||||||
|
|
||||||
|
for (i = 0; i < NUM_CARGO; i++) {
|
||||||
|
r = _cargo_counta[i] - _cargo_countb[i];
|
||||||
|
if (r != 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleReliabilitySorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = va->reliability - vb->reliability;
|
||||||
|
|
||||||
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int CDECL VehicleMaxSpeedSorter(const void *a, const void *b)
|
||||||
|
{
|
||||||
|
const Vehicle *va = DEREF_VEHICLE((*(const SortStruct*)a).index);
|
||||||
|
const Vehicle *vb = DEREF_VEHICLE((*(const SortStruct*)b).index);
|
||||||
|
int r = va->max_speed - vb->max_speed;
|
||||||
|
|
||||||
|
if (r == 0) // if the sorting criteria had the same value, sort by unitnumber
|
||||||
|
r = va->unitnumber - vb->unitnumber;
|
||||||
|
|
||||||
|
return (_internal_sort_order & 1) ? -r : r;
|
||||||
|
}
|
|
@ -5,33 +5,46 @@ void DrawVehicleProfitButton(Vehicle *v, int x, int y);
|
||||||
void InitializeVehiclesGuiList();
|
void InitializeVehiclesGuiList();
|
||||||
|
|
||||||
/* sorter stuff */
|
/* sorter stuff */
|
||||||
int CDECL GeneralOwnerSorter (const void *a, const void *b);
|
|
||||||
int CDECL VehicleNameSorter (const void *a, const void *b);
|
|
||||||
int CDECL GeneralVehicleSorter(const void *a, const void *b);
|
|
||||||
VARDEF uint32 _internal_name_sorter_id; // internal StringID for default vehicle-names
|
|
||||||
VARDEF uint32 _last_vehicle_idx; // cached index to hopefully speed up name-sorting
|
|
||||||
VARDEF bool _internal_sort_order; // descending/ascending
|
|
||||||
VARDEF byte _internal_sort_type; // Miscalleneous sorting criteria
|
|
||||||
|
|
||||||
typedef struct SortStruct { // store owner through sorting process
|
typedef struct SortStruct { // store owner through sorting process
|
||||||
uint32 index;
|
uint32 index;
|
||||||
byte owner;
|
byte owner;
|
||||||
} SortStruct;
|
} SortStruct;
|
||||||
|
|
||||||
#define PERIODIC_RESORT_DAYS 10
|
int CDECL GeneralOwnerSorter(const void *a, const void *b);
|
||||||
|
void VehicleSorter(SortStruct *firstelement, uint32 n, uint16 size);
|
||||||
|
VARDEF uint32 _internal_name_sorter_id; // internal StringID for default vehicle-names
|
||||||
|
VARDEF uint32 _last_vehicle_idx; // cached index to hopefully speed up name-sorting
|
||||||
|
VARDEF bool _internal_sort_order; // descending/ascending
|
||||||
|
|
||||||
enum VehicleSortListingTypes {
|
#define PERIODIC_RESORT_DAYS 10
|
||||||
SORT_BY_UNSORTED = 0,
|
#define DEF_SORTER(yyyy) int CDECL yyyy(const void *a, const void *b)
|
||||||
SORT_BY_NUMBER = 1,
|
|
||||||
SORT_BY_NAME = 2,
|
DEF_SORTER(VehicleUnsortedSorter);
|
||||||
SORT_BY_AGE = 3,
|
DEF_SORTER(VehicleNumberSorter);
|
||||||
SORT_BY_PROFIT_THIS_YEAR = 4,
|
DEF_SORTER(VehicleNameSorter);
|
||||||
SORT_BY_PROFIT_LAST_YEAR = 5,
|
DEF_SORTER(VehicleAgeSorter);
|
||||||
SORT_BY_TOTAL_CAPACITY_PER_CARGOTYPE = 6,
|
DEF_SORTER(VehicleProfitThisYearSorter);
|
||||||
SORT_BY_RELIABILITY = 7,
|
DEF_SORTER(VehicleProfitLastYearSorter);
|
||||||
SORT_BY_MAX_SPEED = 8
|
DEF_SORTER(VehicleCargoSorter);
|
||||||
|
DEF_SORTER(VehicleReliabilitySorter);
|
||||||
|
DEF_SORTER(VehicleMaxSpeedSorter);
|
||||||
|
|
||||||
|
typedef DEF_SORTER(VehicleSortListingTypeFunctions);
|
||||||
|
|
||||||
|
static VehicleSortListingTypeFunctions * const _vehicle_sorter[] = {
|
||||||
|
&VehicleUnsortedSorter,
|
||||||
|
&VehicleNumberSorter,
|
||||||
|
&VehicleNameSorter,
|
||||||
|
&VehicleAgeSorter,
|
||||||
|
&VehicleProfitThisYearSorter,
|
||||||
|
&VehicleProfitLastYearSorter,
|
||||||
|
&VehicleCargoSorter,
|
||||||
|
&VehicleReliabilitySorter,
|
||||||
|
&VehicleMaxSpeedSorter
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define SORT_BY_UNSORTED 0
|
||||||
|
|
||||||
static const uint16 _vehicle_sort_listing[] = {
|
static const uint16 _vehicle_sort_listing[] = {
|
||||||
STR_SORT_BY_UNSORTED,
|
STR_SORT_BY_UNSORTED,
|
||||||
STR_SORT_BY_NUMBER,
|
STR_SORT_BY_NUMBER,
|
||||||
|
|
|
@ -521,8 +521,8 @@ static void TileLoopWaterHelper(uint tile, const int16 *offs)
|
||||||
static void FloodVehicle(Vehicle *v)
|
static void FloodVehicle(Vehicle *v)
|
||||||
{
|
{
|
||||||
Vehicle *u;
|
Vehicle *u;
|
||||||
uint16 pass;
|
|
||||||
if (!(v->vehstatus & VS_CRASHED)) {
|
if (!(v->vehstatus & VS_CRASHED)) {
|
||||||
|
uint16 pass = 0;
|
||||||
|
|
||||||
if (v->type == VEH_Road) { // flood bus/truck
|
if (v->type == VEH_Road) { // flood bus/truck
|
||||||
pass = 1; // driver
|
pass = 1; // driver
|
||||||
|
@ -550,7 +550,8 @@ static void FloodVehicle(Vehicle *v)
|
||||||
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
|
v->u.rail.crash_anim_pos = 4000; // max 4440, disappear pretty fast
|
||||||
_vehicle_sort_dirty[VEHTRAIN] = true;
|
_vehicle_sort_dirty[VEHTRAIN] = true;
|
||||||
InvalidateWindow(WC_TRAINS_LIST, v->owner);
|
InvalidateWindow(WC_TRAINS_LIST, v->owner);
|
||||||
}
|
} else
|
||||||
|
return;
|
||||||
|
|
||||||
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
|
InvalidateWindowWidget(WC_VEHICLE_VIEW, v->index, 4);
|
||||||
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
||||||
|
|
Loading…
Reference in New Issue