mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
Add client setting to show train weight ratios in details header.
Off by default.
This commit is contained in:
parent
8ec1b2200e
commit
0ab2abbc23
@ -1287,6 +1287,10 @@ STR_CONFIG_SETTING_POPULATION_IN_LABEL :Show town popul
|
||||
STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT :Display the population of towns in their label on the map
|
||||
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS :Thickness of lines in graphs: {STRING2}
|
||||
STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT :Width of the line in the graphs. A thin line is more precisely readable, a thicker line is easier to see and colours are easier to distinguish
|
||||
STR_CONFIG_SETTING_SHOW_TRAIN_LENGTH_IN_DETAILS :Show train length in details: {STRING2}
|
||||
STR_CONFIG_SETTING_SHOW_TRAIN_LENGTH_IN_DETAILS_HELPTEXT :Show train length in the vehicle details window
|
||||
STR_CONFIG_SETTING_SHOW_TRAIN_WEIGHT_RATIOS_IN_DETAILS :Show train weight ratios in details: {STRING2}
|
||||
STR_CONFIG_SETTING_SHOW_TRAIN_WEIGHT_RATIOS_IN_DETAILS_HELPTEXT :Show train weight ratios in the vehicle details window
|
||||
STR_CONFIG_SETTING_SHOW_RESTRICTED_SIG_DEF :Show restricted electric signals using default graphics: {STRING2}
|
||||
STR_CONFIG_SETTING_SHOW_RESTRICTED_SIG_DEF_HELPTEXT :Show electric signals with routing restriction programs using the default signal graphics with a blue signal post, instead of using any NewGRF signal graphics. This is to make it easier to visually distinguish restricted signals.
|
||||
|
||||
@ -3776,6 +3780,8 @@ STR_VEHICLE_INFO_MAX_SPEED_RANGE :{BLACK}Max. spe
|
||||
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED :{BLACK}Weight: {LTBLUE}{WEIGHT_SHORT} {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY}
|
||||
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE :{BLACK}Weight: {LTBLUE}{WEIGHT_SHORT} {BLACK}Power: {LTBLUE}{POWER}{BLACK} Max. speed: {LTBLUE}{VELOCITY} {BLACK}Max. T.E.: {LTBLUE}{FORCE}
|
||||
|
||||
STR_VEHICLE_INFO_WEIGHT_RATIOS :{BLACK}Power / weight: {LTBLUE}{POWER_WEIGHT_RATIO} {BLACK} Max. T.E / weight: {LTBLUE}{FORCE_WEIGHT_RATIO}
|
||||
|
||||
STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR :{BLACK}Profit this year: {LTBLUE}{CURRENCY_LONG} (last year: {CURRENCY_LONG})
|
||||
STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS :{BLACK}Reliability: {LTBLUE}{COMMA}% {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
|
||||
|
||||
|
@ -1545,6 +1545,7 @@ static SettingsContainer &GetSettingsTree()
|
||||
interface->Add(new SettingEntry("gui.timetable_in_ticks"));
|
||||
interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
|
||||
interface->Add(new SettingEntry("gui.expenses_layout"));
|
||||
interface->Add(new SettingEntry("gui.show_train_weight_ratios_in_details"));
|
||||
}
|
||||
|
||||
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));
|
||||
|
@ -135,6 +135,7 @@ struct GUISettings {
|
||||
uint32 last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan
|
||||
byte missing_strings_threshold; ///< the number of missing strings before showing the warning
|
||||
uint8 graph_line_thickness; ///< the thickness of the lines in the various graph guis
|
||||
bool show_train_weight_ratios_in_details; ///< show train weight ratios in vehicle details window top widget
|
||||
bool show_restricted_signal_default; ///< Show restricted electric signals using the default sprite
|
||||
uint8 osk_activation; ///< Mouse gesture to trigger the OSK.
|
||||
|
||||
|
@ -3133,6 +3133,15 @@ strhelp = STR_CONFIG_SETTING_GRAPH_LINE_THICKNESS_HELPTEXT
|
||||
strval = STR_JUST_COMMA
|
||||
proc = RedrawScreen
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.show_train_weight_ratios_in_details
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
def = false
|
||||
str = STR_CONFIG_SETTING_SHOW_TRAIN_WEIGHT_RATIOS_IN_DETAILS
|
||||
strhelp = STR_CONFIG_SETTING_SHOW_TRAIN_WEIGHT_RATIOS_IN_DETAILS_HELPTEXT
|
||||
proc = RedrawScreen
|
||||
cat = SC_EXPERT
|
||||
|
||||
[SDTC_BOOL]
|
||||
var = gui.show_restricted_signal_default
|
||||
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
|
||||
|
@ -1859,6 +1859,7 @@ static StringID _service_interval_dropdown[] = {
|
||||
struct VehicleDetailsWindow : Window {
|
||||
TrainDetailsWindowTabs tab; ///< For train vehicles: which tab is displayed.
|
||||
Scrollbar *vscroll;
|
||||
bool vehicle_weight_ratio_line_shown;
|
||||
|
||||
/** Initialize a newly created vehicle details window */
|
||||
VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
|
||||
@ -1920,12 +1921,21 @@ struct VehicleDetailsWindow : Window {
|
||||
return desired_height;
|
||||
}
|
||||
|
||||
bool ShouldShowWeightRatioLine(const Vehicle *v) const
|
||||
{
|
||||
return (v->type == VEH_TRAIN && _settings_client.gui.show_train_weight_ratios_in_details);
|
||||
}
|
||||
|
||||
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
||||
{
|
||||
switch (widget) {
|
||||
case WID_VD_TOP_DETAILS: {
|
||||
const Vehicle *v = Vehicle::Get(this->window_number);
|
||||
Dimension dim = { 0, 0 };
|
||||
size->height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
||||
this->vehicle_weight_ratio_line_shown = ShouldShowWeightRatioLine(v);
|
||||
int lines = 4;
|
||||
if (this->vehicle_weight_ratio_line_shown) lines++;
|
||||
size->height = WD_FRAMERECT_TOP + lines * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
|
||||
|
||||
for (uint i = 0; i < 4; i++) SetDParamMaxValue(i, INT16_MAX);
|
||||
static const StringID info_strings[] = {
|
||||
@ -1938,6 +1948,11 @@ struct VehicleDetailsWindow : Window {
|
||||
for (uint i = 0; i < lengthof(info_strings); i++) {
|
||||
dim = maxdim(dim, GetStringBoundingBox(info_strings[i]));
|
||||
}
|
||||
if (this->vehicle_weight_ratio_line_shown) {
|
||||
SetDParamMaxValue(0, 1 << 16);
|
||||
SetDParamMaxValue(1, 1 << 16);
|
||||
dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_WEIGHT_RATIOS));
|
||||
}
|
||||
SetDParam(0, STR_VEHICLE_INFO_AGE);
|
||||
dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_AGE_RUNNING_COST_YR));
|
||||
size->width = dim.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
|
||||
@ -2072,6 +2087,14 @@ struct VehicleDetailsWindow : Window {
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, string);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
|
||||
bool should_show_weight_ratio = this->ShouldShowWeightRatioLine(v);
|
||||
if (should_show_weight_ratio) {
|
||||
SetDParam(0, (100 * Train::From(v)->gcache.cached_power) / max<uint>(1, Train::From(v)->gcache.cached_weight));
|
||||
SetDParam(1, (Train::From(v)->gcache.cached_max_te / 10) / max<uint>(1, Train::From(v)->gcache.cached_weight));
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_WEIGHT_RATIOS);
|
||||
y += FONT_HEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
/* Draw profit */
|
||||
SetDParam(0, v->GetDisplayProfitThisYear());
|
||||
SetDParam(1, v->GetDisplayProfitLastYear());
|
||||
@ -2082,6 +2105,10 @@ struct VehicleDetailsWindow : Window {
|
||||
SetDParam(0, ToPercent16(v->reliability));
|
||||
SetDParam(1, v->breakdowns_since_last_service);
|
||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS);
|
||||
|
||||
if (this->vehicle_weight_ratio_line_shown != should_show_weight_ratio) {
|
||||
const_cast<VehicleDetailsWindow *>(this)->ReInit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user