mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r6372) -Codechange: static, unneeded decleration in headers, superfluous header includes
-Codechange: Unify the Sorting struct both for vehicle-lists and network-lists.
This commit is contained in:
parent
e42d819b6a
commit
794cc6d55e
@ -47,13 +47,8 @@ typedef struct network_ql_d {
|
||||
} network_ql_d;
|
||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(network_ql_d));
|
||||
|
||||
typedef struct NetworkGameSorting {
|
||||
bool order; // Ascending / Descending
|
||||
byte criteria; // Sorted by name/clients/connectivity
|
||||
} NetworkGameSorting;
|
||||
|
||||
/* Global to remember sorting after window has been closed */
|
||||
static NetworkGameSorting _ng_sorting;
|
||||
static Listing _ng_sorting;
|
||||
|
||||
static char _edit_str_buf[64];
|
||||
static bool _chat_tab_completion_active;
|
||||
|
@ -28,7 +28,23 @@
|
||||
#include "roadveh.h"
|
||||
#include "depot.h"
|
||||
|
||||
Sorting _sorting;
|
||||
typedef struct Sorting {
|
||||
Listing aircraft;
|
||||
Listing roadveh;
|
||||
Listing ship;
|
||||
Listing train;
|
||||
} Sorting;
|
||||
|
||||
static Sorting _sorting;
|
||||
|
||||
typedef struct vehiclelist_d {
|
||||
const Vehicle** sort_list; // list of vehicles (sorted)
|
||||
uint16 list_length;
|
||||
byte sort_type;
|
||||
SortListFlags flags;
|
||||
uint16 resort_timer;
|
||||
} vehiclelist_d;
|
||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
|
||||
|
||||
static uint32 _internal_name_sorter_id; // internal StringID for default vehicle-names
|
||||
static const Vehicle* _last_vehicle; // cached vehicle to hopefully speed up name-sorting
|
||||
@ -1074,7 +1090,7 @@ static const WindowDesc _replace_ship_aircraft_vehicle_desc = {
|
||||
};
|
||||
|
||||
|
||||
void ShowReplaceVehicleWindow(byte vehicletype)
|
||||
static void ShowReplaceVehicleWindow(byte vehicletype)
|
||||
{
|
||||
Window *w;
|
||||
|
||||
@ -1100,8 +1116,9 @@ void ShowReplaceVehicleWindow(byte vehicletype)
|
||||
break;
|
||||
default: return;
|
||||
}
|
||||
|
||||
w->caption_color = _local_player;
|
||||
WP(w,replaceveh_d).vehicletype = vehicletype;
|
||||
WP(w, replaceveh_d).vehicletype = vehicletype;
|
||||
w->vscroll2.cap = w->vscroll.cap; // these two are always the same
|
||||
}
|
||||
|
||||
@ -1153,7 +1170,6 @@ void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v)
|
||||
* 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);
|
||||
@ -1237,10 +1253,9 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
||||
|
||||
max = min(w->vscroll.pos + w->vscroll.cap, vl->list_length);
|
||||
for (i = w->vscroll.pos; i < max; ++i) {
|
||||
const Vehicle* v = vl->sort_list[i];
|
||||
StringID str;
|
||||
const Vehicle *v = vl->sort_list[i];
|
||||
StringID str = (v->age > v->max_age - 366) ? STR_00E3 : STR_00E2;
|
||||
|
||||
str = v->age > v->max_age - 366 ? STR_00E3 : STR_00E2;
|
||||
SetDParam(0, v->profit_this_year);
|
||||
SetDParam(1, v->profit_last_year);
|
||||
switch (vehicle_type) {
|
||||
@ -1248,6 +1263,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
||||
DrawTrainImage(v, x + 21, y + 6, w->hscroll.cap, 0, INVALID_VEHICLE);
|
||||
DrawString(x + 21, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
||||
if (IsTileDepotType(v->tile, TRANSPORT_RAIL) && (v->vehstatus & VS_HIDDEN)) str = STR_021F;
|
||||
|
||||
if (v->string_id != STR_SV_TRAIN_NAME) {
|
||||
SetDParam(0, v->string_id);
|
||||
DrawString(x + 21, y, STR_01AB, 0);
|
||||
@ -1257,6 +1273,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
||||
DrawRoadVehImage(v, x + 22, y + 6, INVALID_VEHICLE);
|
||||
DrawString(x + 24, y + 18, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
||||
if (IsRoadVehInDepot(v)) str = STR_021F;
|
||||
|
||||
if (v->string_id != STR_SV_ROADVEH_NAME) {
|
||||
SetDParam(0, v->string_id);
|
||||
DrawString(x + 24, y, STR_01AB, 0);
|
||||
@ -1266,21 +1283,25 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
||||
DrawShipImage(v, x + 19, y + 6, INVALID_VEHICLE);
|
||||
DrawString(x + 12, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
||||
if (IsShipInDepot(v)) str = STR_021F;
|
||||
|
||||
if (v->string_id != STR_SV_SHIP_NAME) {
|
||||
SetDParam(0, v->string_id);
|
||||
DrawString(x + 12, y, STR_01AB, 0);
|
||||
}
|
||||
DrawSmallOrderListShip(v, x + 138, y);
|
||||
|
||||
break;
|
||||
case VEH_Aircraft:
|
||||
DrawAircraftImage(v, x + 19, y + 6, INVALID_VEHICLE);
|
||||
DrawString(x + 19, y + 28, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
||||
if (IsAircraftInHangar(v)) str = STR_021F;
|
||||
|
||||
if (v->string_id != STR_SV_AIRCRAFT_NAME) {
|
||||
SetDParam(0, v->string_id);
|
||||
DrawString(x + 19, y, STR_01AB, 0);
|
||||
}
|
||||
DrawSmallOrderListAircraft(v, x + 136, y);
|
||||
|
||||
break;
|
||||
default: NOT_REACHED(); break;
|
||||
}
|
||||
@ -1414,8 +1435,7 @@ void PlayerVehWndProc(Window *w, WindowEvent *e)
|
||||
}
|
||||
break;
|
||||
|
||||
case WE_RESIZE:
|
||||
/* Update the scroll + matrix */
|
||||
case WE_RESIZE: /* Update the scroll + matrix */
|
||||
if (vehicle_type == VEH_Train) w->hscroll.cap += e->sizing.diff.x;
|
||||
w->vscroll.cap += e->sizing.diff.y / (int)w->resize.step_height;
|
||||
w->widget[7].unkA = (w->vscroll.cap << 8) + 1;
|
||||
|
@ -3,12 +3,8 @@
|
||||
#ifndef VEHICLE_GUI_H
|
||||
#define VEHICLE_GUI_H
|
||||
|
||||
#include "station.h"
|
||||
#include "vehicle.h"
|
||||
#include "window.h"
|
||||
|
||||
struct vehiclelist_d;
|
||||
|
||||
void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
|
||||
CargoID DrawVehicleRefitWindow(const Vehicle *v, int sel);
|
||||
void InitializeVehiclesGuiList(void);
|
||||
@ -19,20 +15,6 @@ void ResortVehicleLists(void);
|
||||
|
||||
#define PERIODIC_RESORT_DAYS 10
|
||||
|
||||
typedef struct Listing {
|
||||
bool order; // Ascending/descending?
|
||||
byte criteria; // Sorting criteria
|
||||
} Listing;
|
||||
|
||||
typedef struct Sorting {
|
||||
Listing aircraft;
|
||||
Listing roadveh;
|
||||
Listing ship;
|
||||
Listing train;
|
||||
} Sorting;
|
||||
|
||||
extern Sorting _sorting;
|
||||
|
||||
enum {
|
||||
PLY_WND_PRC__OFFSET_TOP_WIDGET = 26,
|
||||
PLY_WND_PRC__SIZE_OF_ROW_SMALL = 26,
|
||||
@ -54,8 +36,6 @@ static inline bool ValidVLWFlags(uint16 flags)
|
||||
|
||||
void PlayerVehWndProc(Window *w, WindowEvent *e);
|
||||
|
||||
void ShowReplaceVehicleWindow(byte vehicletype);
|
||||
|
||||
void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawTrainWagonPurchaseInfo(int x, int y, EngineID engine_number);
|
||||
void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number);
|
||||
@ -66,17 +46,16 @@ void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, Vehicle
|
||||
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection);
|
||||
void DrawShipImage(const Vehicle *v, int x, int y, VehicleID selection);
|
||||
void DrawSmallOrderListShip(const Vehicle *v, int x, int y);
|
||||
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
|
||||
void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y);
|
||||
|
||||
void ShowBuildTrainWindow(TileIndex tile);
|
||||
void ShowBuildRoadVehWindow(TileIndex tile);
|
||||
void ShowBuildShipWindow(TileIndex tile);
|
||||
void ShowBuildAircraftWindow(TileIndex tile);
|
||||
|
||||
void DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
|
||||
void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y);
|
||||
|
||||
void ChangeVehicleViewWindow(const Vehicle *from_v, const Vehicle *to_v);
|
||||
|
||||
int ShowAdditionalText(int x, int y, int w, EngineID engine_number);
|
||||
int ShowAdditionalText(int x, int y, int w, EngineID engine);
|
||||
|
||||
#endif /* VEHICLE_GUI_H */
|
||||
|
24
window.h
24
window.h
@ -449,26 +449,22 @@ typedef struct {
|
||||
} scroller_d;
|
||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(scroller_d));
|
||||
|
||||
typedef enum VehicleListFlags {
|
||||
typedef enum SortListFlags {
|
||||
VL_DESC = 0x01, // sort descending or ascending
|
||||
VL_RESORT = 0x02, // instruct the code to resort the list in the next loop
|
||||
VL_REBUILD = 0x04 // create sort-listing to use for qsort and friends
|
||||
} VehicleListFlags;
|
||||
} SortListFlags;
|
||||
|
||||
typedef struct vehiclelist_d {
|
||||
const Vehicle** sort_list;
|
||||
uint16 list_length;
|
||||
byte sort_type;
|
||||
VehicleListFlags flags;
|
||||
uint16 resort_timer;
|
||||
} vehiclelist_d;
|
||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehiclelist_d));
|
||||
typedef struct Listing {
|
||||
bool order; // Ascending/descending
|
||||
byte criteria; // Sorting criteria
|
||||
} Listing;
|
||||
|
||||
typedef struct list_d {
|
||||
uint16 list_length; // length of the list being sorted
|
||||
byte sort_type; // what criteria to sort on
|
||||
VehicleListFlags flags;// used to control sorting/resorting/etc.
|
||||
uint16 resort_timer; // resort list after a given amount of ticks if set
|
||||
uint16 list_length; // length of the list being sorted
|
||||
byte sort_type; // what criteria to sort on
|
||||
SortListFlags flags; // used to control sorting/resorting/etc.
|
||||
uint16 resort_timer; // resort list after a given amount of ticks if set
|
||||
} list_d;
|
||||
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(list_d));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user