mirror of https://github.com/OpenTTD/OpenTTD
(svn r6646) -Codechange: [vehicle list window] Cleaned up the drawing code
This moved a few of the strings and sprites a few pixels. Hopefully this will work out ok.release/0.5
parent
7606b2707d
commit
ff6f83b56c
|
@ -585,24 +585,3 @@ void ShowAircraftViewWindow(const Vehicle *v)
|
||||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y)
|
|
||||||
{
|
|
||||||
const Order *order;
|
|
||||||
int sel, i = 0;
|
|
||||||
|
|
||||||
sel = v->cur_order_index;
|
|
||||||
|
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
|
||||||
if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16);
|
|
||||||
sel--;
|
|
||||||
|
|
||||||
if (order->type == OT_GOTO_STATION) {
|
|
||||||
SetDParam(0, order->dest);
|
|
||||||
DrawString(x, y, STR_A036, 0);
|
|
||||||
|
|
||||||
y += 6;
|
|
||||||
if (++i == 4) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
23
ship_gui.c
23
ship_gui.c
|
@ -529,26 +529,3 @@ void ShowShipViewWindow(const Vehicle *v)
|
||||||
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
AssignWindowViewport(w, 3, 17, 0xE2, 0x54, w->window_number | (1 << 31), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawSmallOrderListShip(const Vehicle *v, int x, int y)
|
|
||||||
{
|
|
||||||
const Order *order;
|
|
||||||
int sel, i = 0;
|
|
||||||
|
|
||||||
sel = v->cur_order_index;
|
|
||||||
|
|
||||||
FOR_VEHICLE_ORDERS(v, order) {
|
|
||||||
if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16);
|
|
||||||
sel--;
|
|
||||||
|
|
||||||
if (order->type == OT_GOTO_STATION) {
|
|
||||||
if (!IsBuoy(GetStation(order->dest))) {
|
|
||||||
SetDParam(0, order->dest);
|
|
||||||
DrawString(x, y, STR_A036, 0);
|
|
||||||
|
|
||||||
y += 6;
|
|
||||||
if (++i == 4) break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
12
vehicle.c
12
vehicle.c
|
@ -2439,6 +2439,18 @@ int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID own
|
||||||
return (flags & DC_EXEC) ? 0 : CMD_ERROR;
|
return (flags & DC_EXEC) ? 0 : CMD_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsVehicleInDepot(const Vehicle *v)
|
||||||
|
{
|
||||||
|
switch (v->type) {
|
||||||
|
case VEH_Train: return CheckTrainInDepot(v, false) != -1;
|
||||||
|
case VEH_Road: return IsRoadVehInDepot(v);
|
||||||
|
case VEH_Ship: return IsShipInDepot(v);
|
||||||
|
case VEH_Aircraft: return IsAircraftInHangar(v);
|
||||||
|
default: NOT_REACHED();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void VehicleEnterDepot(Vehicle *v)
|
void VehicleEnterDepot(Vehicle *v)
|
||||||
{
|
{
|
||||||
switch (v->type) {
|
switch (v->type) {
|
||||||
|
|
|
@ -318,6 +318,7 @@ bool VehicleNeedsService(const Vehicle *v);
|
||||||
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, byte type, PlayerID owner, StationID station, OrderID order, uint16 depot_airport_index, uint16 window_type);
|
uint GenerateVehicleSortList(const Vehicle*** sort_list, uint16 *length_of_array, byte type, PlayerID owner, StationID station, OrderID order, uint16 depot_airport_index, uint16 window_type);
|
||||||
void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
|
void BuildDepotVehicleList(byte type, TileIndex tile, Vehicle ***engine_list, uint16 *engine_list_length, uint16 *engine_count, Vehicle ***wagon_list, uint16 *wagon_list_length, uint16 *wagon_count);
|
||||||
int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
|
int32 SendAllVehiclesToDepot(byte type, uint32 flags, bool service, PlayerID owner, uint16 vlw_flag, uint32 id);
|
||||||
|
bool IsVehicleInDepot(const Vehicle *v);
|
||||||
void VehicleEnterDepot(Vehicle *v);
|
void VehicleEnterDepot(Vehicle *v);
|
||||||
|
|
||||||
/* Flags to add to p2 for goto depot commands */
|
/* Flags to add to p2 for goto depot commands */
|
||||||
|
|
|
@ -1508,6 +1508,29 @@ static void CreateVehicleListWindow(Window *w)
|
||||||
ResizeVehicleListWidgets(w);
|
ResizeVehicleListWidgets(w);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void DrawSmallOrderList(const Vehicle *v, int x, int y)
|
||||||
|
{
|
||||||
|
const Order *order;
|
||||||
|
int sel, i = 0;
|
||||||
|
|
||||||
|
sel = v->cur_order_index;
|
||||||
|
|
||||||
|
FOR_VEHICLE_ORDERS(v, order) {
|
||||||
|
if (sel == 0) DrawString(x - 6, y, STR_SMALL_RIGHT_ARROW, 16);
|
||||||
|
sel--;
|
||||||
|
|
||||||
|
if (order->type == OT_GOTO_STATION) {
|
||||||
|
if (v->type == VEH_Ship && IsBuoy(GetStation(order->dest))) continue;
|
||||||
|
|
||||||
|
SetDParam(0, order->dest);
|
||||||
|
DrawString(x, y, STR_A036, 0);
|
||||||
|
|
||||||
|
y += 6;
|
||||||
|
if (++i == 4) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void DrawVehicleListWindow(Window *w)
|
static void DrawVehicleListWindow(Window *w)
|
||||||
{
|
{
|
||||||
vehiclelist_d *vl = &WP(w, vehiclelist_d);
|
vehiclelist_d *vl = &WP(w, vehiclelist_d);
|
||||||
|
@ -1594,58 +1617,32 @@ static void DrawVehicleListWindow(Window *w)
|
||||||
max = min(w->vscroll.pos + w->vscroll.cap, vl->l.list_length);
|
max = min(w->vscroll.pos + w->vscroll.cap, vl->l.list_length);
|
||||||
for (i = w->vscroll.pos; i < max; ++i) {
|
for (i = w->vscroll.pos; i < max; ++i) {
|
||||||
const Vehicle *v = vl->sort_list[i];
|
const Vehicle *v = vl->sort_list[i];
|
||||||
StringID str = (v->age > v->max_age - 366) ? STR_00E3 : STR_00E2;
|
StringID str;
|
||||||
|
|
||||||
SetDParam(0, v->profit_this_year);
|
SetDParam(0, v->profit_this_year);
|
||||||
SetDParam(1, v->profit_last_year);
|
SetDParam(1, v->profit_last_year);
|
||||||
|
|
||||||
switch (vl->vehicle_type) {
|
DrawVehicleImage(v, x + 19, y + 6, w->hscroll.cap + 2, 0, INVALID_VEHICLE);
|
||||||
case VEH_Train:
|
DrawString(x + 19, y + w->resize.step_height - 8, STR_0198_PROFIT_THIS_YEAR_LAST_YEAR, 0);
|
||||||
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) {
|
if ((v->type == VEH_Train && v->string_id != STR_SV_TRAIN_NAME) ||
|
||||||
SetDParam(0, v->string_id);
|
(v->type == VEH_Road && v->string_id != STR_SV_ROADVEH_NAME) ||
|
||||||
DrawString(x + 21, y, STR_01AB, 0);
|
(v->type == VEH_Ship && v->string_id != STR_SV_SHIP_NAME) ||
|
||||||
}
|
(v->type == VEH_Aircraft && v->string_id != STR_SV_AIRCRAFT_NAME)) {
|
||||||
break;
|
|
||||||
case VEH_Road:
|
|
||||||
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) {
|
/* The vehicle got a name so we will print it */
|
||||||
SetDParam(0, v->string_id);
|
SetDParam(0, v->string_id);
|
||||||
DrawString(x + 24, y, STR_01AB, 0);
|
DrawString(x + 19, y, STR_01AB, 0);
|
||||||
}
|
|
||||||
break;
|
|
||||||
case VEH_Ship:
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (w->resize.step_height == PLY_WND_PRC__SIZE_OF_ROW_BIG) DrawSmallOrderList(v, x + 138, y);
|
||||||
|
|
||||||
|
if (IsVehicleInDepot(v)) {
|
||||||
|
str = STR_021F;
|
||||||
|
} else {
|
||||||
|
str = (v->age > v->max_age - 366) ? STR_00E3 : STR_00E2;
|
||||||
|
}
|
||||||
|
|
||||||
SetDParam(0, v->unitnumber);
|
SetDParam(0, v->unitnumber);
|
||||||
DrawString(x, y + 2, str, 0);
|
DrawString(x, y + 2, str, 0);
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#define VEHICLE_GUI_H
|
#define VEHICLE_GUI_H
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
|
#include "vehicle.h"
|
||||||
|
|
||||||
void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
|
void DrawVehicleProfitButton(const Vehicle *v, int x, int y);
|
||||||
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order);
|
void ShowVehicleRefitWindow(const Vehicle *v, VehicleOrderID order);
|
||||||
|
@ -40,9 +41,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number);
|
||||||
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection);
|
void DrawTrainImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection);
|
||||||
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection);
|
void DrawRoadVehImage(const Vehicle *v, int x, int y, VehicleID selection);
|
||||||
void DrawShipImage(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 DrawAircraftImage(const Vehicle *v, int x, int y, VehicleID selection);
|
||||||
void DrawSmallOrderListAircraft(const Vehicle *v, int x, int y);
|
|
||||||
|
|
||||||
void ShowBuildTrainWindow(TileIndex tile);
|
void ShowBuildTrainWindow(TileIndex tile);
|
||||||
void ShowBuildRoadVehWindow(TileIndex tile);
|
void ShowBuildRoadVehWindow(TileIndex tile);
|
||||||
|
@ -57,4 +56,16 @@ void ShowVehicleListWindow(PlayerID player, StationID station, byte vehicle_type
|
||||||
void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type);
|
void ShowVehWithSharedOrders(Vehicle *v, byte vehicle_type);
|
||||||
void ShowVehDepotOrders(PlayerID player, byte vehicle_type, TileIndex depot_tile);
|
void ShowVehDepotOrders(PlayerID player, byte vehicle_type, TileIndex depot_tile);
|
||||||
|
|
||||||
|
|
||||||
|
static inline void DrawVehicleImage(const Vehicle *v, int x, int y, int count, int skip, VehicleID selection)
|
||||||
|
{
|
||||||
|
switch (v->type) {
|
||||||
|
case VEH_Train: DrawTrainImage(v, x, y, count, skip, selection); break;
|
||||||
|
case VEH_Road: DrawRoadVehImage(v, x, y, selection); break;
|
||||||
|
case VEH_Ship: DrawShipImage(v, x, y, selection); break;
|
||||||
|
case VEH_Aircraft: DrawAircraftImage(v, x, y, selection); break;
|
||||||
|
default: NOT_REACHED();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* VEHICLE_GUI_H */
|
#endif /* VEHICLE_GUI_H */
|
||||||
|
|
Loading…
Reference in New Issue