|
|
@ -40,11 +40,6 @@
|
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/sprites.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
#include "table/strings.h"
|
|
|
|
|
|
|
|
|
|
|
|
struct vehicledetails_d {
|
|
|
|
|
|
|
|
byte tab;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
assert_compile(WINDOW_CUSTOM_SIZE >= sizeof(vehicledetails_d));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct refit_d {
|
|
|
|
struct refit_d {
|
|
|
|
int sel;
|
|
|
|
int sel;
|
|
|
|
struct RefitOption *cargo;
|
|
|
|
struct RefitOption *cargo;
|
|
|
@ -1374,280 +1369,274 @@ static const StringID _vehicle_translation_table[][4] = {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Initialize a newly created vehicle details window */
|
|
|
|
|
|
|
|
void CreateVehicleDetailsWindow(Window *w)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
extern int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab);
|
|
|
|
case VEH_TRAIN:
|
|
|
|
extern void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab);
|
|
|
|
ResizeWindow(w, 0, 39);
|
|
|
|
extern void DrawRoadVehDetails(const Vehicle *v, int x, int y);
|
|
|
|
|
|
|
|
extern void DrawShipDetails(const Vehicle *v, int x, int y);
|
|
|
|
|
|
|
|
extern void DrawAircraftDetails(const Vehicle *v, int x, int y);
|
|
|
|
|
|
|
|
|
|
|
|
w->vscroll.cap = 6;
|
|
|
|
struct VehicleDetailsWindow : Window {
|
|
|
|
w->height += 12;
|
|
|
|
int tab;
|
|
|
|
w->resize.step_height = 14;
|
|
|
|
|
|
|
|
w->resize.height = w->height - 14 * 2; // Minimum of 4 wagons in the display
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_8867_NAME_TRAIN;
|
|
|
|
/** Initialize a newly created vehicle details window */
|
|
|
|
w->widget[VLD_WIDGET_CAPTION].data = STR_8802_DETAILS;
|
|
|
|
VehicleDetailsWindow(const WindowDesc *desc, WindowNumber window_number) : Window(desc, window_number)
|
|
|
|
break;
|
|
|
|
{
|
|
|
|
|
|
|
|
const Vehicle *v = GetVehicle(this->window_number);
|
|
|
|
|
|
|
|
|
|
|
|
case VEH_ROAD: {
|
|
|
|
switch (v->type) {
|
|
|
|
w->widget[VLD_WIDGET_CAPTION].data = STR_900C_DETAILS;
|
|
|
|
case VEH_TRAIN:
|
|
|
|
w->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_902E_NAME_ROAD_VEHICLE;
|
|
|
|
ResizeWindow(this, 0, 39);
|
|
|
|
|
|
|
|
|
|
|
|
if (!RoadVehHasArticPart(v)) break;
|
|
|
|
this->vscroll.cap = 6;
|
|
|
|
|
|
|
|
this->height += 12;
|
|
|
|
|
|
|
|
this->resize.step_height = 14;
|
|
|
|
|
|
|
|
this->resize.height = this->height - 14 * 2; // Minimum of 4 wagons in the display
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw the text under the vehicle instead of next to it, minus the
|
|
|
|
this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_8867_NAME_TRAIN;
|
|
|
|
* height already allocated for the cargo of the first vehicle. */
|
|
|
|
this->widget[VLD_WIDGET_CAPTION].data = STR_8802_DETAILS;
|
|
|
|
uint height_extension = 15 - 11;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
/* Add space for the cargo amount for each part. */
|
|
|
|
case VEH_ROAD: {
|
|
|
|
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
|
|
|
this->widget[VLD_WIDGET_CAPTION].data = STR_900C_DETAILS;
|
|
|
|
height_extension += 11;
|
|
|
|
this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_902E_NAME_ROAD_VEHICLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ResizeWindow(w, 0, height_extension);
|
|
|
|
if (!RoadVehHasArticPart(v)) break;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case VEH_SHIP:
|
|
|
|
/* Draw the text under the vehicle instead of next to it, minus the
|
|
|
|
w->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_982F_NAME_SHIP;
|
|
|
|
* height already allocated for the cargo of the first vehicle. */
|
|
|
|
w->widget[VLD_WIDGET_CAPTION].data = STR_9811_DETAILS;
|
|
|
|
uint height_extension = 15 - 11;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
/* Add space for the cargo amount for each part. */
|
|
|
|
ResizeWindow(w, 0, 11);
|
|
|
|
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
|
|
|
|
w->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_A032_NAME_AIRCRAFT;
|
|
|
|
height_extension += 11;
|
|
|
|
w->widget[VLD_WIDGET_CAPTION].data = STR_A00C_DETAILS;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (v->type != VEH_TRAIN) {
|
|
|
|
ResizeWindow(this, 0, height_extension);
|
|
|
|
w->vscroll.cap = 1;
|
|
|
|
} break;
|
|
|
|
w->widget[VLD_WIDGET_MIDDLE_DETAILS].right += 12;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
w->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (w->vscroll.cap << 8) + 1;
|
|
|
|
case VEH_SHIP:
|
|
|
|
w->caption_color = v->owner;
|
|
|
|
this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_982F_NAME_SHIP;
|
|
|
|
|
|
|
|
this->widget[VLD_WIDGET_CAPTION].data = STR_9811_DETAILS;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
WP(w, vehicledetails_d).tab = 0;
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
}
|
|
|
|
ResizeWindow(this, 0, 11);
|
|
|
|
|
|
|
|
this->widget[VLD_WIDGET_RENAME_VEHICLE].tooltips = STR_A032_NAME_AIRCRAFT;
|
|
|
|
|
|
|
|
this->widget[VLD_WIDGET_CAPTION].data = STR_A00C_DETAILS;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Checks whether service interval is enabled for the vehicle. */
|
|
|
|
if (v->type != VEH_TRAIN) {
|
|
|
|
static inline bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type)
|
|
|
|
this->vscroll.cap = 1;
|
|
|
|
{
|
|
|
|
this->widget[VLD_WIDGET_MIDDLE_DETAILS].right += 12;
|
|
|
|
switch (vehicle_type) {
|
|
|
|
}
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
|
|
|
case VEH_TRAIN: return _patches.servint_trains != 0; break;
|
|
|
|
|
|
|
|
case VEH_ROAD: return _patches.servint_roadveh != 0; break;
|
|
|
|
|
|
|
|
case VEH_SHIP: return _patches.servint_ships != 0; break;
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT: return _patches.servint_aircraft != 0; break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // kill a compiler warning
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern int GetTrainDetailsWndVScroll(VehicleID veh_id, byte det_tab);
|
|
|
|
this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << 8) + 1;
|
|
|
|
extern void DrawTrainDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint16 vscroll_cap, byte det_tab);
|
|
|
|
this->caption_color = v->owner;
|
|
|
|
extern void DrawRoadVehDetails(const Vehicle *v, int x, int y);
|
|
|
|
|
|
|
|
extern void DrawShipDetails(const Vehicle *v, int x, int y);
|
|
|
|
|
|
|
|
extern void DrawAircraftDetails(const Vehicle *v, int x, int y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
this->tab = 0;
|
|
|
|
* Draw the details for the given vehicle at the position (x, y) of the Details windows
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param v current vehicle
|
|
|
|
|
|
|
|
* @param x The x coordinate
|
|
|
|
|
|
|
|
* @param y The y coordinate
|
|
|
|
|
|
|
|
* @param vscroll_pos (train only)
|
|
|
|
|
|
|
|
* @param vscroll_cap (train only)
|
|
|
|
|
|
|
|
* @param det_tab (train only)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static inline void DrawVehicleDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint vscroll_cap, byte det_tab)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
|
|
|
|
case VEH_TRAIN: DrawTrainDetails(v, x, y, vscroll_pos, vscroll_cap, det_tab); break;
|
|
|
|
|
|
|
|
case VEH_ROAD: DrawRoadVehDetails(v, x, y); break;
|
|
|
|
|
|
|
|
case VEH_SHIP: DrawShipDetails(v, x, y); break;
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT: DrawAircraftDetails(v, x, y); break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Repaint vehicle details window. */
|
|
|
|
/** Checks whether service interval is enabled for the vehicle. */
|
|
|
|
static void DrawVehicleDetailsWindow(Window *w)
|
|
|
|
static bool IsVehicleServiceIntervalEnabled(const VehicleType vehicle_type)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
|
switch (vehicle_type) {
|
|
|
|
byte det_tab = WP(w, vehicledetails_d).tab;
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
|
|
|
case VEH_TRAIN: return _patches.servint_trains != 0; break;
|
|
|
|
w->SetWidgetDisabledState(VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_player);
|
|
|
|
case VEH_ROAD: return _patches.servint_roadveh != 0; break;
|
|
|
|
|
|
|
|
case VEH_SHIP: return _patches.servint_ships != 0; break;
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT: return _patches.servint_aircraft != 0; break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false; // kill a compiler warning
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (v->type == VEH_TRAIN) {
|
|
|
|
/**
|
|
|
|
w->DisableWidget(det_tab + VLD_WIDGET_DETAILS_CARGO_CARRIED);
|
|
|
|
* Draw the details for the given vehicle at the position (x, y) of the Details windows
|
|
|
|
SetVScrollCount(w, GetTrainDetailsWndVScroll(v->index, det_tab));
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param v current vehicle
|
|
|
|
|
|
|
|
* @param x The x coordinate
|
|
|
|
|
|
|
|
* @param y The y coordinate
|
|
|
|
|
|
|
|
* @param vscroll_pos (train only)
|
|
|
|
|
|
|
|
* @param vscroll_cap (train only)
|
|
|
|
|
|
|
|
* @param det_tab (train only)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void DrawVehicleDetails(const Vehicle *v, int x, int y, int vscroll_pos, uint vscroll_cap, byte det_tab)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
|
|
|
|
case VEH_TRAIN: DrawTrainDetails(v, x, y, vscroll_pos, vscroll_cap, det_tab); break;
|
|
|
|
|
|
|
|
case VEH_ROAD: DrawRoadVehDetails(v, x, y); break;
|
|
|
|
|
|
|
|
case VEH_SHIP: DrawShipDetails(v, x, y); break;
|
|
|
|
|
|
|
|
case VEH_AIRCRAFT: DrawAircraftDetails(v, x, y); break;
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
w->SetWidgetsHiddenState(v->type != VEH_TRAIN,
|
|
|
|
/** Repaint vehicle details window. */
|
|
|
|
VLD_WIDGET_SCROLLBAR,
|
|
|
|
virtual void OnPaint()
|
|
|
|
VLD_WIDGET_DETAILS_CARGO_CARRIED,
|
|
|
|
{
|
|
|
|
VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
|
|
|
|
const Vehicle *v = GetVehicle(this->window_number);
|
|
|
|
VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
|
|
|
|
byte det_tab = this->tab;
|
|
|
|
VLD_WIDGET_DETAILS_TOTAL_CARGO,
|
|
|
|
|
|
|
|
VLD_WIDGET_RESIZE,
|
|
|
|
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Disable service-scroller when interval is set to disabled */
|
|
|
|
this->SetWidgetDisabledState(VLD_WIDGET_RENAME_VEHICLE, v->owner != _local_player);
|
|
|
|
w->SetWidgetsDisabledState(!IsVehicleServiceIntervalEnabled(v->type),
|
|
|
|
|
|
|
|
VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
|
|
|
|
|
|
|
|
VLD_WIDGET_DECREASE_SERVICING_INTERVAL,
|
|
|
|
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (v->type == VEH_TRAIN) {
|
|
|
|
|
|
|
|
this->DisableWidget(det_tab + VLD_WIDGET_DETAILS_CARGO_CARRIED);
|
|
|
|
|
|
|
|
SetVScrollCount(this, GetTrainDetailsWndVScroll(v->index, det_tab));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SetDParam(0, v->index);
|
|
|
|
this->SetWidgetsHiddenState(v->type != VEH_TRAIN,
|
|
|
|
DrawWindowWidgets(w);
|
|
|
|
VLD_WIDGET_SCROLLBAR,
|
|
|
|
|
|
|
|
VLD_WIDGET_DETAILS_CARGO_CARRIED,
|
|
|
|
|
|
|
|
VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
|
|
|
|
|
|
|
|
VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
|
|
|
|
|
|
|
|
VLD_WIDGET_DETAILS_TOTAL_CARGO,
|
|
|
|
|
|
|
|
VLD_WIDGET_RESIZE,
|
|
|
|
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw running cost */
|
|
|
|
/* Disable service-scroller when interval is set to disabled */
|
|
|
|
SetDParam(1, v->age / 366);
|
|
|
|
this->SetWidgetsDisabledState(!IsVehicleServiceIntervalEnabled(v->type),
|
|
|
|
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
|
|
|
|
VLD_WIDGET_INCREASE_SERVICING_INTERVAL,
|
|
|
|
SetDParam(2, v->max_age / 366);
|
|
|
|
VLD_WIDGET_DECREASE_SERVICING_INTERVAL,
|
|
|
|
SetDParam(3, v->GetDisplayRunningCost());
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
DrawString(2, 15, _vehicle_translation_table[VST_VEHICLE_AGE_RUNNING_COST_YR][v->type], TC_FROMSTRING);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw max speed */
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
|
|
|
|
case VEH_TRAIN:
|
|
|
|
|
|
|
|
SetDParam(2, v->GetDisplayMaxSpeed());
|
|
|
|
|
|
|
|
SetDParam(1, v->u.rail.cached_power);
|
|
|
|
|
|
|
|
SetDParam(0, v->u.rail.cached_weight);
|
|
|
|
|
|
|
|
SetDParam(3, v->u.rail.cached_max_te / 1000);
|
|
|
|
|
|
|
|
DrawString(2, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
|
|
|
|
|
|
|
|
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
|
|
|
|
|
|
|
|
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, TC_FROMSTRING);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case VEH_ROAD:
|
|
|
|
SetDParam(0, v->index);
|
|
|
|
case VEH_SHIP:
|
|
|
|
DrawWindowWidgets(this);
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
|
|
|
|
SetDParam(0, v->GetDisplayMaxSpeed());
|
|
|
|
|
|
|
|
DrawString(2, 25, _vehicle_translation_table[VST_VEHICLE_MAX_SPEED][v->type], TC_FROMSTRING);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
/* Draw running cost */
|
|
|
|
}
|
|
|
|
SetDParam(1, v->age / 366);
|
|
|
|
|
|
|
|
SetDParam(0, (v->age + 365 < v->max_age) ? STR_AGE : STR_AGE_RED);
|
|
|
|
|
|
|
|
SetDParam(2, v->max_age / 366);
|
|
|
|
|
|
|
|
SetDParam(3, v->GetDisplayRunningCost());
|
|
|
|
|
|
|
|
DrawString(2, 15, _vehicle_translation_table[VST_VEHICLE_AGE_RUNNING_COST_YR][v->type], TC_FROMSTRING);
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw profit */
|
|
|
|
/* Draw max speed */
|
|
|
|
SetDParam(0, v->GetDisplayProfitThisYear());
|
|
|
|
switch (v->type) {
|
|
|
|
SetDParam(1, v->GetDisplayProfitLastYear());
|
|
|
|
case VEH_TRAIN:
|
|
|
|
DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
|
|
|
|
SetDParam(2, v->GetDisplayMaxSpeed());
|
|
|
|
|
|
|
|
SetDParam(1, v->u.rail.cached_power);
|
|
|
|
|
|
|
|
SetDParam(0, v->u.rail.cached_weight);
|
|
|
|
|
|
|
|
SetDParam(3, v->u.rail.cached_max_te / 1000);
|
|
|
|
|
|
|
|
DrawString(2, 25, (_patches.realistic_acceleration && v->u.rail.railtype != RAILTYPE_MAGLEV) ?
|
|
|
|
|
|
|
|
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :
|
|
|
|
|
|
|
|
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, TC_FROMSTRING);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw breakdown & reliability */
|
|
|
|
case VEH_ROAD:
|
|
|
|
SetDParam(0, v->reliability * 100 >> 16);
|
|
|
|
case VEH_SHIP:
|
|
|
|
SetDParam(1, v->breakdowns_since_last_service);
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
DrawString(2, 45, _vehicle_translation_table[VST_VEHICLE_RELIABILITY_BREAKDOWNS][v->type], TC_FROMSTRING);
|
|
|
|
SetDParam(0, v->GetDisplayMaxSpeed());
|
|
|
|
|
|
|
|
DrawString(2, 25, _vehicle_translation_table[VST_VEHICLE_MAX_SPEED][v->type], TC_FROMSTRING);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
/* Draw service interval text */
|
|
|
|
default: NOT_REACHED();
|
|
|
|
SetDParam(0, v->service_interval);
|
|
|
|
}
|
|
|
|
SetDParam(1, v->date_of_last_service);
|
|
|
|
|
|
|
|
DrawString(13, w->height - (v->type != VEH_TRAIN ? 11 : 23), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (v->type) {
|
|
|
|
/* Draw profit */
|
|
|
|
case VEH_TRAIN:
|
|
|
|
SetDParam(0, v->GetDisplayProfitThisYear());
|
|
|
|
DrawVehicleDetails(v, 2, 57, w->vscroll.pos, w->vscroll.cap, det_tab);
|
|
|
|
SetDParam(1, v->GetDisplayProfitLastYear());
|
|
|
|
break;
|
|
|
|
DrawString(2, 35, _vehicle_translation_table[VST_VEHICLE_PROFIT_THIS_YEAR_LAST_YEAR][v->type], TC_FROMSTRING);
|
|
|
|
|
|
|
|
|
|
|
|
case VEH_ROAD:
|
|
|
|
/* Draw breakdown & reliability */
|
|
|
|
case VEH_SHIP:
|
|
|
|
SetDParam(0, v->reliability * 100 >> 16);
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
SetDParam(1, v->breakdowns_since_last_service);
|
|
|
|
DrawVehicleImage(v, 3, 57, INVALID_VEHICLE, 0, 0);
|
|
|
|
DrawString(2, 45, _vehicle_translation_table[VST_VEHICLE_RELIABILITY_BREAKDOWNS][v->type], TC_FROMSTRING);
|
|
|
|
DrawVehicleDetails(v, 75, 57, w->vscroll.pos, w->vscroll.cap, det_tab);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
/* Draw service interval text */
|
|
|
|
}
|
|
|
|
SetDParam(0, v->service_interval);
|
|
|
|
}
|
|
|
|
SetDParam(1, v->date_of_last_service);
|
|
|
|
|
|
|
|
DrawString(13, this->height - (v->type != VEH_TRAIN ? 11 : 23), _patches.servint_ispercent ? STR_SERVICING_INTERVAL_PERCENT : STR_883C_SERVICING_INTERVAL_DAYS, TC_FROMSTRING);
|
|
|
|
|
|
|
|
|
|
|
|
/** Message strings for renaming vehicles indexed by vehicle type. */
|
|
|
|
switch (v->type) {
|
|
|
|
static const StringID _name_vehicle_title[] = {
|
|
|
|
case VEH_TRAIN:
|
|
|
|
STR_8865_NAME_TRAIN,
|
|
|
|
DrawVehicleDetails(v, 2, 57, this->vscroll.pos, this->vscroll.cap, det_tab);
|
|
|
|
STR_902C_NAME_ROAD_VEHICLE,
|
|
|
|
break;
|
|
|
|
STR_9831_NAME_SHIP,
|
|
|
|
|
|
|
|
STR_A030_NAME_AIRCRAFT
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Message strings for error while renaming indexed by vehicle type. */
|
|
|
|
case VEH_ROAD:
|
|
|
|
static const StringID _name_vehicle_error[] = {
|
|
|
|
case VEH_SHIP:
|
|
|
|
STR_8866_CAN_T_NAME_TRAIN,
|
|
|
|
case VEH_AIRCRAFT:
|
|
|
|
STR_902D_CAN_T_NAME_ROAD_VEHICLE,
|
|
|
|
DrawVehicleImage(v, 3, 57, INVALID_VEHICLE, 0, 0);
|
|
|
|
STR_9832_CAN_T_NAME_SHIP,
|
|
|
|
DrawVehicleDetails(v, 75, 57, this->vscroll.pos, this->vscroll.cap, det_tab);
|
|
|
|
STR_A031_CAN_T_NAME_AIRCRAFT
|
|
|
|
break;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Window event hook for vehicle details. */
|
|
|
|
default: NOT_REACHED();
|
|
|
|
static void VehicleDetailsWndProc(Window *w, WindowEvent *e)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
}
|
|
|
|
switch (e->event) {
|
|
|
|
|
|
|
|
case WE_CREATE:
|
|
|
|
|
|
|
|
CreateVehicleDetailsWindow(w);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case WE_PAINT:
|
|
|
|
virtual void OnClick(Point pt, int widget)
|
|
|
|
DrawVehicleDetailsWindow(w);
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
/** Message strings for renaming vehicles indexed by vehicle type. */
|
|
|
|
|
|
|
|
static const StringID _name_vehicle_title[] = {
|
|
|
|
|
|
|
|
STR_8865_NAME_TRAIN,
|
|
|
|
|
|
|
|
STR_902C_NAME_ROAD_VEHICLE,
|
|
|
|
|
|
|
|
STR_9831_NAME_SHIP,
|
|
|
|
|
|
|
|
STR_A030_NAME_AIRCRAFT
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
case WE_CLICK: {
|
|
|
|
switch (widget) {
|
|
|
|
switch (e->we.click.widget) {
|
|
|
|
case VLD_WIDGET_RENAME_VEHICLE: {// rename
|
|
|
|
case VLD_WIDGET_RENAME_VEHICLE: {// rename
|
|
|
|
const Vehicle *v = GetVehicle(this->window_number);
|
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
|
SetDParam(0, v->index);
|
|
|
|
SetDParam(0, v->index);
|
|
|
|
ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], 31, 150, this, CS_ALPHANUMERAL);
|
|
|
|
ShowQueryString(STR_VEHICLE_NAME, _name_vehicle_title[v->type], 31, 150, w, CS_ALPHANUMERAL);
|
|
|
|
} break;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
case VLD_WIDGET_INCREASE_SERVICING_INTERVAL: // increase int
|
|
|
|
case VLD_WIDGET_INCREASE_SERVICING_INTERVAL: // increase int
|
|
|
|
case VLD_WIDGET_DECREASE_SERVICING_INTERVAL: { // decrease int
|
|
|
|
case VLD_WIDGET_DECREASE_SERVICING_INTERVAL: { // decrease int
|
|
|
|
int mod = _ctrl_pressed ? 5 : 10;
|
|
|
|
int mod = _ctrl_pressed ? 5 : 10;
|
|
|
|
const Vehicle *v = GetVehicle(w->window_number);
|
|
|
|
const Vehicle *v = GetVehicle(this->window_number);
|
|
|
|
|
|
|
|
|
|
|
|
mod = (e->we.click.widget == VLD_WIDGET_DECREASE_SERVICING_INTERVAL) ? -mod : mod;
|
|
|
|
mod = (widget == VLD_WIDGET_DECREASE_SERVICING_INTERVAL) ? -mod : mod;
|
|
|
|
mod = GetServiceIntervalClamped(mod + v->service_interval);
|
|
|
|
mod = GetServiceIntervalClamped(mod + v->service_interval);
|
|
|
|
if (mod == v->service_interval) return;
|
|
|
|
if (mod == v->service_interval) return;
|
|
|
|
|
|
|
|
|
|
|
|
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
|
|
|
|
DoCommandP(v->tile, v->index, mod, NULL, CMD_CHANGE_SERVICE_INT | CMD_MSG(STR_018A_CAN_T_CHANGE_SERVICING));
|
|
|
|
} break;
|
|
|
|
} break;
|
|
|
|
|
|
|
|
|
|
|
|
case VLD_WIDGET_DETAILS_CARGO_CARRIED:
|
|
|
|
case VLD_WIDGET_DETAILS_CARGO_CARRIED:
|
|
|
|
case VLD_WIDGET_DETAILS_TRAIN_VEHICLES:
|
|
|
|
case VLD_WIDGET_DETAILS_TRAIN_VEHICLES:
|
|
|
|
case VLD_WIDGET_DETAILS_CAPACITY_OF_EACH:
|
|
|
|
case VLD_WIDGET_DETAILS_CAPACITY_OF_EACH:
|
|
|
|
case VLD_WIDGET_DETAILS_TOTAL_CARGO:
|
|
|
|
case VLD_WIDGET_DETAILS_TOTAL_CARGO:
|
|
|
|
w->SetWidgetsDisabledState(false,
|
|
|
|
this->SetWidgetsDisabledState(false,
|
|
|
|
VLD_WIDGET_DETAILS_CARGO_CARRIED,
|
|
|
|
VLD_WIDGET_DETAILS_CARGO_CARRIED,
|
|
|
|
VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
|
|
|
|
VLD_WIDGET_DETAILS_TRAIN_VEHICLES,
|
|
|
|
VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
|
|
|
|
VLD_WIDGET_DETAILS_CAPACITY_OF_EACH,
|
|
|
|
VLD_WIDGET_DETAILS_TOTAL_CARGO,
|
|
|
|
VLD_WIDGET_DETAILS_TOTAL_CARGO,
|
|
|
|
e->we.click.widget,
|
|
|
|
widget,
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
WIDGET_LIST_END);
|
|
|
|
|
|
|
|
|
|
|
|
WP(w, vehicledetails_d).tab = e->we.click.widget - VLD_WIDGET_DETAILS_CARGO_CARRIED;
|
|
|
|
this->tab = widget - VLD_WIDGET_DETAILS_CARGO_CARRIED;
|
|
|
|
w->SetDirty();
|
|
|
|
this->SetDirty();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} break;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_ON_EDIT_TEXT:
|
|
|
|
virtual void OnQueryTextFinished(char *str)
|
|
|
|
if (!StrEmpty(e->we.edittext.str)) {
|
|
|
|
{
|
|
|
|
_cmd_text = e->we.edittext.str;
|
|
|
|
/** Message strings for error while renaming indexed by vehicle type. */
|
|
|
|
DoCommandP(0, w->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(_name_vehicle_error[GetVehicle(w->window_number)->type]));
|
|
|
|
static const StringID _name_vehicle_error[] = {
|
|
|
|
}
|
|
|
|
STR_8866_CAN_T_NAME_TRAIN,
|
|
|
|
break;
|
|
|
|
STR_902D_CAN_T_NAME_ROAD_VEHICLE,
|
|
|
|
|
|
|
|
STR_9832_CAN_T_NAME_SHIP,
|
|
|
|
|
|
|
|
STR_A031_CAN_T_NAME_AIRCRAFT
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!StrEmpty(str)) {
|
|
|
|
|
|
|
|
_cmd_text = str;
|
|
|
|
|
|
|
|
DoCommandP(0, this->window_number, 0, NULL, CMD_NAME_VEHICLE | CMD_MSG(_name_vehicle_error[GetVehicle(this->window_number)->type]));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case WE_RESIZE:
|
|
|
|
virtual void OnResize(Point new_size, Point delta)
|
|
|
|
if (e->we.sizing.diff.x != 0) ResizeButtons(w, VLD_WIDGET_DETAILS_CARGO_CARRIED, VLD_WIDGET_DETAILS_TOTAL_CARGO);
|
|
|
|
{
|
|
|
|
if (e->we.sizing.diff.y == 0) break;
|
|
|
|
if (delta.x != 0) ResizeButtons(this, VLD_WIDGET_DETAILS_CARGO_CARRIED, VLD_WIDGET_DETAILS_TOTAL_CARGO);
|
|
|
|
|
|
|
|
if (delta.y == 0) return;
|
|
|
|
|
|
|
|
|
|
|
|
w->vscroll.cap += e->we.sizing.diff.y / 14;
|
|
|
|
this->vscroll.cap += delta.y / 14;
|
|
|
|
w->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (w->vscroll.cap << 8) + 1;
|
|
|
|
this->widget[VLD_WIDGET_MIDDLE_DETAILS].data = (this->vscroll.cap << 8) + 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Vehicle details window descriptor. */
|
|
|
|
/** Vehicle details window descriptor. */
|
|
|
|
static const WindowDesc _vehicle_details_desc = {
|
|
|
|
static const WindowDesc _vehicle_details_desc = {
|
|
|
@ -1655,7 +1644,7 @@ static const WindowDesc _vehicle_details_desc = {
|
|
|
|
WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW,
|
|
|
|
WC_VEHICLE_DETAILS, WC_VEHICLE_VIEW,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
|
|
|
WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_RESIZABLE,
|
|
|
|
_vehicle_details_widgets,
|
|
|
|
_vehicle_details_widgets,
|
|
|
|
VehicleDetailsWndProc
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/** Shows the vehicle details window of the given vehicle. */
|
|
|
|
/** Shows the vehicle details window of the given vehicle. */
|
|
|
@ -1663,7 +1652,7 @@ static void ShowVehicleDetailsWindow(const Vehicle *v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
|
|
|
|
DeleteWindowById(WC_VEHICLE_ORDERS, v->index);
|
|
|
|
DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
|
|
|
|
DeleteWindowById(WC_VEHICLE_DETAILS, v->index);
|
|
|
|
AllocateWindowDescFront<Window>(&_vehicle_details_desc, v->index);
|
|
|
|
AllocateWindowDescFront<VehicleDetailsWindow>(&_vehicle_details_desc, v->index);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|