mirror of https://github.com/OpenTTD/OpenTTD
(svn r1750) - Feature: [ 1093261 ] Saving vehicle sorting criteria for each vehicle type (bociusz)
parent
7bbcf5875c
commit
b64c375f2f
|
@ -1021,8 +1021,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
/* draw sorting criteria string */
|
/* draw sorting criteria string */
|
||||||
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||||
DoDrawString(
|
DoDrawString(vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
|
||||||
|
|
||||||
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
||||||
for (i = w->vscroll.pos; i < max; ++i) {
|
for (i = w->vscroll.pos; i < max; ++i) {
|
||||||
|
@ -1061,6 +1060,7 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 3: /* Flip sorting method ascending/descending */
|
||||||
vl->flags ^= VL_DESC;
|
vl->flags ^= VL_DESC;
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
|
_sorting.aircraft.order = !!(vl->flags & VL_DESC);
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1123,18 +1123,19 @@ static void PlayerAircraftWndProc(Window *w, WindowEvent *e)
|
||||||
// value has changed -> resort
|
// value has changed -> resort
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
vl->sort_type = e->dropdown.index;
|
vl->sort_type = e->dropdown.index;
|
||||||
|
_sorting.aircraft.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||||
w->disabled_state &= ~(1 << 3);
|
CLRBIT(w->disabled_state, 3);
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_CREATE: /* set up resort timer */
|
case WE_CREATE: /* set up resort timer */
|
||||||
vl->sort_list = NULL;
|
vl->sort_list = NULL;
|
||||||
vl->flags = VL_REBUILD;
|
vl->flags = VL_REBUILD | (_sorting.aircraft.order << (VL_DESC - 1));
|
||||||
vl->sort_type = SORT_BY_UNSORTED;
|
vl->sort_type = _sorting.aircraft.criteria;
|
||||||
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
3
gui.h
3
gui.h
|
@ -126,4 +126,7 @@ VARDEF byte _station_show_coverage;
|
||||||
VARDEF PlaceProc *_place_proc;
|
VARDEF PlaceProc *_place_proc;
|
||||||
VARDEF bool _no_button_sound;
|
VARDEF bool _no_button_sound;
|
||||||
|
|
||||||
|
/* vehicle_gui.c */
|
||||||
|
void InitializeGUI(void);
|
||||||
|
|
||||||
#endif /* GUI_H */
|
#endif /* GUI_H */
|
||||||
|
|
|
@ -808,8 +808,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
/* draw sorting criteria string */
|
/* draw sorting criteria string */
|
||||||
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||||
DoDrawString(
|
DoDrawString(vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
|
||||||
|
|
||||||
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
||||||
for (i = w->vscroll.pos; i < max; ++i) {
|
for (i = w->vscroll.pos; i < max; ++i) {
|
||||||
|
@ -846,6 +845,7 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 3: /* Flip sorting method ascending/descending */
|
||||||
vl->flags ^= VL_DESC;
|
vl->flags ^= VL_DESC;
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
|
_sorting.roadveh.order = !!(vl->flags & VL_DESC);
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -906,18 +906,19 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
// value has changed -> resort
|
// value has changed -> resort
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
vl->sort_type = e->dropdown.index;
|
vl->sort_type = e->dropdown.index;
|
||||||
|
_sorting.roadveh.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||||
w->disabled_state &= ~(1 << 3);
|
CLRBIT(w->disabled_state, 3);
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_CREATE: /* set up resort timer */
|
case WE_CREATE: /* set up resort timer */
|
||||||
vl->sort_list = NULL;
|
vl->sort_list = NULL;
|
||||||
vl->flags = VL_REBUILD;
|
vl->flags = VL_REBUILD | (_sorting.roadveh.order << (VL_DESC - 1));
|
||||||
vl->sort_type = SORT_BY_UNSORTED;
|
vl->sort_type = _sorting.roadveh.criteria;
|
||||||
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -935,7 +936,6 @@ static void PlayerRoadVehWndProc(Window *w, WindowEvent *e)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case WE_RESIZE:
|
case WE_RESIZE:
|
||||||
/* Update the scroll + matrix */
|
/* Update the scroll + matrix */
|
||||||
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
|
w->vscroll.cap += e->sizing.diff.y / PLY_WND_PRC__SIZE_OF_ROW_SMALL;
|
||||||
|
|
11
ship_gui.c
11
ship_gui.c
|
@ -965,8 +965,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
/* draw sorting criteria string */
|
/* draw sorting criteria string */
|
||||||
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||||
DoDrawString(
|
DoDrawString(vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
|
||||||
|
|
||||||
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
||||||
for (i = w->vscroll.pos; i < max; ++i) {
|
for (i = w->vscroll.pos; i < max; ++i) {
|
||||||
|
@ -1005,6 +1004,7 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 3: /* Flip sorting method ascending/descending */
|
||||||
vl->flags ^= VL_DESC;
|
vl->flags ^= VL_DESC;
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
|
_sorting.ship.order = !!(vl->flags & VL_DESC);
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
case 4: case 5:/* Select sorting criteria dropdown menu */
|
case 4: case 5:/* Select sorting criteria dropdown menu */
|
||||||
|
@ -1066,18 +1066,19 @@ static void PlayerShipsWndProc(Window *w, WindowEvent *e)
|
||||||
// value has changed -> resort
|
// value has changed -> resort
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
vl->sort_type = e->dropdown.index;
|
vl->sort_type = e->dropdown.index;
|
||||||
|
_sorting.ship.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||||
w->disabled_state &= ~(1 << 3);
|
CLRBIT(w->disabled_state, 3);
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_CREATE: /* set up resort timer */
|
case WE_CREATE: /* set up resort timer */
|
||||||
vl->sort_list = NULL;
|
vl->sort_list = NULL;
|
||||||
vl->flags = VL_REBUILD;
|
vl->flags = VL_REBUILD | (_sorting.ship.order << (VL_DESC - 1));
|
||||||
vl->sort_type = SORT_BY_UNSORTED;
|
vl->sort_type = _sorting.ship.criteria;
|
||||||
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
11
train_gui.c
11
train_gui.c
|
@ -1307,8 +1307,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
/* draw sorting criteria string */
|
/* draw sorting criteria string */
|
||||||
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
DrawString(85, 15, _vehicle_sort_listing[vl->sort_type], 0x10);
|
||||||
/* draw arrow pointing up/down for ascending/descending sorting */
|
/* draw arrow pointing up/down for ascending/descending sorting */
|
||||||
DoDrawString(
|
DoDrawString(vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
||||||
vl->flags & VL_DESC ? "\xAA" : "\xA0", 69, 15, 0x10);
|
|
||||||
|
|
||||||
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
||||||
for (i = w->vscroll.pos; i < max; ++i) {
|
for (i = w->vscroll.pos; i < max; ++i) {
|
||||||
|
@ -1347,6 +1346,7 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
case 3: /* Flip sorting method ascending/descending */
|
case 3: /* Flip sorting method ascending/descending */
|
||||||
vl->flags ^= VL_DESC;
|
vl->flags ^= VL_DESC;
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
|
_sorting.train.order = !!(vl->flags & VL_DESC);
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -1409,18 +1409,19 @@ static void PlayerTrainsWndProc(Window *w, WindowEvent *e)
|
||||||
// value has changed -> resort
|
// value has changed -> resort
|
||||||
vl->flags |= VL_RESORT;
|
vl->flags |= VL_RESORT;
|
||||||
vl->sort_type = e->dropdown.index;
|
vl->sort_type = e->dropdown.index;
|
||||||
|
_sorting.train.criteria = vl->sort_type;
|
||||||
|
|
||||||
// enable 'Sort By' if a sorter criteria is chosen
|
// enable 'Sort By' if a sorter criteria is chosen
|
||||||
if (vl->sort_type != SORT_BY_UNSORTED)
|
if (vl->sort_type != SORT_BY_UNSORTED)
|
||||||
w->disabled_state &= ~(1 << 3);
|
CLRBIT(w->disabled_state, 3);
|
||||||
}
|
}
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WE_CREATE: /* set up resort timer */
|
case WE_CREATE: /* set up resort timer */
|
||||||
vl->sort_list = NULL;
|
vl->sort_list = NULL;
|
||||||
vl->flags = VL_REBUILD;
|
vl->flags = VL_REBUILD | (_sorting.train.order << (VL_DESC - 1));
|
||||||
vl->sort_type = SORT_BY_UNSORTED;
|
vl->sort_type = _sorting.train.criteria;
|
||||||
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
vl->resort_timer = DAY_TICKS * PERIODIC_RESORT_DAYS;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
1
ttd.c
1
ttd.c
|
@ -721,6 +721,7 @@ int ttd_main(int argc, char* argv[])
|
||||||
|
|
||||||
// initialize the ingame console
|
// initialize the ingame console
|
||||||
IConsoleInit();
|
IConsoleInit();
|
||||||
|
InitializeGUI();
|
||||||
IConsoleCmdExec("exec scripts/autoexec.scr 0");
|
IConsoleCmdExec("exec scripts/autoexec.scr 0");
|
||||||
|
|
||||||
InitPlayerRandoms();
|
InitPlayerRandoms();
|
||||||
|
|
|
@ -1011,3 +1011,8 @@ void ShowReplaceVehicleWindow(byte vehicletype)
|
||||||
WP(w,replaceveh_d).vehicletype = vehicletype;
|
WP(w,replaceveh_d).vehicletype = vehicletype;
|
||||||
w->vscroll2.cap = w->vscroll.cap; // these two are always the same
|
w->vscroll2.cap = w->vscroll.cap; // these two are always the same
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InitializeGUI(void)
|
||||||
|
{
|
||||||
|
memset(&_sorting, 0, sizeof(_sorting));
|
||||||
|
}
|
||||||
|
|
|
@ -45,12 +45,26 @@ extern const StringID _vehicle_sort_listing[];
|
||||||
extern const StringID _rail_types_list[];
|
extern const StringID _rail_types_list[];
|
||||||
|
|
||||||
enum VehicleSortTypes {
|
enum VehicleSortTypes {
|
||||||
VEHTRAIN = 0,
|
VEHTRAIN = 0,
|
||||||
VEHROAD = 1,
|
VEHROAD = 1,
|
||||||
VEHSHIP = 2,
|
VEHSHIP = 2,
|
||||||
VEHAIRCRAFT = 3
|
VEHAIRCRAFT = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct Listing {
|
||||||
|
bool order; // Ascending/descending?
|
||||||
|
byte criteria; // Sorting criteria
|
||||||
|
} Listing;
|
||||||
|
|
||||||
|
typedef struct Sorting {
|
||||||
|
Listing aircraft;
|
||||||
|
Listing roadveh;
|
||||||
|
Listing ship;
|
||||||
|
Listing train;
|
||||||
|
} Sorting;
|
||||||
|
|
||||||
|
VARDEF Sorting _sorting;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
|
PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
|
||||||
PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
|
PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
|
||||||
|
|
Loading…
Reference in New Issue