Merge branch 'vehicle_details_gui_additions' into jgrpp

Conflicts:
	src/table/settings.ini
pull/3/head
Jonathan G Rennison 9 years ago
commit 5d7ad2ba7b

@ -1293,6 +1293,10 @@ STR_CONFIG_SETTING_POPULATION_IN_LABEL :Show extra info
STR_CONFIG_SETTING_POPULATION_IN_LABEL_HELPTEXT :Display the population of towns in their label on the map 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 :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_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_VEHICLE_GROUP_IN_DETAILS :Show vehicle group in details: {STRING2}
STR_CONFIG_SETTING_SHOW_VEHICLE_GROUP_IN_DETAILS_HELPTEXT :Show vehicle group name in the vehicle details window
STR_CONFIG_SETTING_LANDSCAPE :Landscape: {STRING2} STR_CONFIG_SETTING_LANDSCAPE :Landscape: {STRING2}
STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Landscapes define basic gameplay scenarios with different cargos and town growth requirements. NewGRF and Game Scripts allow finer control though STR_CONFIG_SETTING_LANDSCAPE_HELPTEXT :Landscapes define basic gameplay scenarios with different cargos and town growth requirements. NewGRF and Game Scripts allow finer control though
@ -4086,9 +4090,13 @@ 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 :{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_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_TRAIN_LENGTH :{BLACK}Train length {LTBLUE}{DECIMAL} tile{P "" s} {STRING3}
STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR :{BLACK}Profit this year: {LTBLUE}{CURRENCY_LONG} (last year: {CURRENCY_LONG}) 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} STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS :{BLACK}Reliability: {LTBLUE}{COMMA}% {BLACK}Breakdowns since last service: {LTBLUE}{COMMA}
STR_VEHICLE_INFO_GROUP :{BLACK}Group: {LTBLUE}{GROUP}
STR_VEHICLE_INFO_BUILT_VALUE :{LTBLUE}{ENGINE} {BLACK}Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY_LONG} STR_VEHICLE_INFO_BUILT_VALUE :{LTBLUE}{ENGINE} {BLACK}Built: {LTBLUE}{NUM}{BLACK} Value: {LTBLUE}{CURRENCY_LONG}
STR_VEHICLE_INFO_NO_CAPACITY :{BLACK}Capacity: {LTBLUE}None{STRING} STR_VEHICLE_INFO_NO_CAPACITY :{BLACK}Capacity: {LTBLUE}None{STRING}
STR_VEHICLE_INFO_CAPACITY :{BLACK}Capacity: {LTBLUE}{CARGO_LONG}{3:STRING} STR_VEHICLE_INFO_CAPACITY :{BLACK}Capacity: {LTBLUE}{CARGO_LONG}{3:STRING}

@ -1588,6 +1588,8 @@ static SettingsContainer &GetSettingsTree()
interface->Add(new SettingEntry("gui.timetable_in_ticks")); interface->Add(new SettingEntry("gui.timetable_in_ticks"));
interface->Add(new SettingEntry("gui.timetable_arrival_departure")); interface->Add(new SettingEntry("gui.timetable_arrival_departure"));
interface->Add(new SettingEntry("gui.expenses_layout")); interface->Add(new SettingEntry("gui.expenses_layout"));
interface->Add(new SettingEntry("gui.show_train_length_in_details"));
interface->Add(new SettingEntry("gui.show_vehicle_group_in_details"));
} }
SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS)); SettingsPage *advisors = main->Add(new SettingsPage(STR_CONFIG_SETTING_ADVISORS));

@ -166,6 +166,8 @@ struct GUISettings {
uint32 last_newgrf_count; ///< the numbers of NewGRFs we found during the last scan 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 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 uint8 graph_line_thickness; ///< the thickness of the lines in the various graph guis
bool show_train_length_in_details; ///< show train length in vehicle details window top widget
bool show_vehicle_group_in_details; ///< show vehicle group in vehicle details window top widget
uint8 osk_activation; ///< Mouse gesture to trigger the OSK. uint8 osk_activation; ///< Mouse gesture to trigger the OSK.
bool show_vehicle_route_steps; ///< when a window related to a specific vehicle is focused, show route steps bool show_vehicle_route_steps; ///< when a window related to a specific vehicle is focused, show route steps

@ -3686,6 +3686,24 @@ def = true
str = STR_CONFIG_SETTING_SHOW_VEHICLE_ROUTE_STEPS str = STR_CONFIG_SETTING_SHOW_VEHICLE_ROUTE_STEPS
proc = RedrawScreen proc = RedrawScreen
[SDTC_BOOL]
var = gui.show_train_length_in_details
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = true
str = STR_CONFIG_SETTING_SHOW_TRAIN_LENGTH_IN_DETAILS
strhelp = STR_CONFIG_SETTING_SHOW_TRAIN_LENGTH_IN_DETAILS_HELPTEXT
proc = RedrawScreen
cat = SC_BASIC
[SDTC_BOOL]
var = gui.show_vehicle_group_in_details
flags = SLF_NOT_IN_SAVE | SLF_NO_NETWORK_SYNC
def = true
str = STR_CONFIG_SETTING_SHOW_VEHICLE_GROUP_IN_DETAILS
strhelp = STR_CONFIG_SETTING_SHOW_VEHICLE_GROUP_IN_DETAILS_HELPTEXT
proc = RedrawScreen
cat = SC_BASIC
; For the dedicated build we'll enable dates in logs by default. ; For the dedicated build we'll enable dates in logs by default.
[SDTC_BOOL] [SDTC_BOOL]
ifdef = DEDICATED ifdef = DEDICATED

@ -1912,6 +1912,7 @@ static StringID _service_interval_dropdown[] = {
struct VehicleDetailsWindow : Window { struct VehicleDetailsWindow : Window {
TrainDetailsWindowTabs tab; ///< For train vehicles: which tab is displayed. TrainDetailsWindowTabs tab; ///< For train vehicles: which tab is displayed.
Scrollbar *vscroll; Scrollbar *vscroll;
bool vehicle_group_line_shown;
/** Initialize a newly created vehicle details window */ /** Initialize a newly created vehicle details window */
VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc) VehicleDetailsWindow(WindowDesc *desc, WindowNumber window_number) : Window(desc)
@ -1960,6 +1961,11 @@ struct VehicleDetailsWindow : Window {
this->ReInit(); this->ReInit();
} }
} }
/* If the presence of the group line changes, the size of the top details widget must change */
if (this->vehicle_group_line_shown != this->ShouldShowGroupLine(v)) {
this->ReInit();
}
} }
/** /**
@ -1983,24 +1989,42 @@ struct VehicleDetailsWindow : Window {
return desired_height; return desired_height;
} }
bool ShouldShowGroupLine(const Vehicle *v) const
{
return (_settings_client.gui.show_vehicle_group_in_details && v->group_id != INVALID_GROUP && v->group_id != DEFAULT_GROUP);
}
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
{ {
switch (widget) { switch (widget) {
case WID_VD_TOP_DETAILS: { case WID_VD_TOP_DETAILS: {
const Vehicle *v = Vehicle::Get(this->window_number);
Dimension dim = { 0, 0 }; Dimension dim = { 0, 0 };
size->height = WD_FRAMERECT_TOP + 4 * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM; this->vehicle_group_line_shown = ShouldShowGroupLine(v);
size->height = WD_FRAMERECT_TOP + (this->vehicle_group_line_shown ? 5 : 4) * FONT_HEIGHT_NORMAL + WD_FRAMERECT_BOTTOM;
for (uint i = 0; i < 4; i++) SetDParamMaxValue(i, INT16_MAX); for (uint i = 0; i < 5; i++) SetDParamMaxValue(i, INT16_MAX);
static const StringID info_strings[] = { static const StringID info_strings[] = {
STR_VEHICLE_INFO_MAX_SPEED, STR_VEHICLE_INFO_MAX_SPEED,
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED,
STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE, STR_VEHICLE_INFO_WEIGHT_POWER_MAX_SPEED_MAX_TE,
STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR,
STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS
}; };
for (uint i = 0; i < lengthof(info_strings); i++) { for (uint i = 0; i < lengthof(info_strings); i++) {
dim = maxdim(dim, GetStringBoundingBox(info_strings[i])); dim = maxdim(dim, GetStringBoundingBox(info_strings[i]));
} }
if (v->type == VEH_TRAIN && _settings_client.gui.show_train_length_in_details) {
SetDParamMaxValue(0, _settings_game.vehicle.max_train_length * 10);
SetDParam(1, 1);
SetDParam(2, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR);
dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_TRAIN_LENGTH));
} else {
dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR));
}
if (this->vehicle_group_line_shown) {
SetDParam(0, v->group_id);
dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_GROUP));
}
SetDParam(0, STR_VEHICLE_INFO_AGE); SetDParam(0, STR_VEHICLE_INFO_AGE);
dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_AGE_RUNNING_COST_YR)); dim = maxdim(dim, GetStringBoundingBox(STR_VEHICLE_INFO_AGE_RUNNING_COST_YR));
size->width = dim.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT; size->width = dim.width + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT;
@ -2136,9 +2160,19 @@ struct VehicleDetailsWindow : Window {
y += FONT_HEIGHT_NORMAL; y += FONT_HEIGHT_NORMAL;
/* Draw profit */ /* Draw profit */
if (v->type == VEH_TRAIN && _settings_client.gui.show_train_length_in_details) {
const GroundVehicleCache *gcache = v->GetGroundVehicleCache();
SetDParam(0, CeilDiv(gcache->cached_total_length * 10, TILE_SIZE));
SetDParam(1, 1);
SetDParam(2, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR);
SetDParam(3, v->GetDisplayProfitThisYear());
SetDParam(4, v->GetDisplayProfitLastYear());
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_TRAIN_LENGTH);
} else {
SetDParam(0, v->GetDisplayProfitThisYear()); SetDParam(0, v->GetDisplayProfitThisYear());
SetDParam(1, v->GetDisplayProfitLastYear()); SetDParam(1, v->GetDisplayProfitLastYear());
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR); DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_PROFIT_THIS_YEAR_LAST_YEAR);
}
y += FONT_HEIGHT_NORMAL; y += FONT_HEIGHT_NORMAL;
/* Draw breakdown & reliability */ /* Draw breakdown & reliability */
@ -2162,6 +2196,16 @@ struct VehicleDetailsWindow : Window {
SetDParam(1, v->breakdowns_since_last_service); SetDParam(1, v->breakdowns_since_last_service);
} }
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS); DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_RELIABILITY_BREAKDOWNS);
y += FONT_HEIGHT_NORMAL;
bool should_show_group = this->ShouldShowGroupLine(v);
if (should_show_group) {
SetDParam(0, v->group_id);
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, y, STR_VEHICLE_INFO_GROUP);
}
if (this->vehicle_group_line_shown != should_show_group) {
const_cast<VehicleDetailsWindow *>(this)->ReInit();
}
break; break;
} }

Loading…
Cancel
Save