diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp index 45d47a7f72..0abc45ab04 100644 --- a/src/graph_gui.cpp +++ b/src/graph_gui.cpp @@ -40,6 +40,8 @@ static CargoTypes _legend_excluded_cargo; static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn. static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. +uint8 _cargo_payment_x_mode; + /****************/ /* GRAPH LEGEND */ /****************/ @@ -894,6 +896,9 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { this->vscroll = this->GetScrollbar(WID_CPR_MATRIX_SCROLLBAR); this->vscroll->SetCount(_sorted_standard_cargo_specs_size); + this->SetWidgetLoweredState(WID_CPR_DAYS, _cargo_payment_x_mode == 0); + this->SetWidgetLoweredState(WID_CPR_SPEED, _cargo_payment_x_mode == 1); + /* Initialise the dataset */ this->OnHundredthTick(); @@ -902,16 +907,18 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { void SetXAxis() { - uint16 x_scale; - switch (_settings_game.locale.units_velocity) { - case 2: - x_scale = 5; - break; - case 3: - x_scale = 1; - break; - default: - x_scale = 10; + uint16 x_scale = 10; + if (_cargo_payment_x_mode) { + switch (_settings_game.locale.units_velocity) { + case 2: + x_scale = 5; + break; + case 3: + x_scale = 1; + break; + default: + x_scale = 10; + } } this->x_values_start = x_scale; this->x_values_increment = x_scale; @@ -1035,6 +1042,16 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { } break; } + + case WID_CPR_DAYS: + case WID_CPR_SPEED: + _cargo_payment_x_mode = widget - WID_CPR_DAYS; + this->SetWidgetLoweredState(WID_CPR_DAYS, _cargo_payment_x_mode == 0); + this->SetWidgetLoweredState(WID_CPR_SPEED, _cargo_payment_x_mode == 1); + this->SetXAxis(); + this->OnHundredthTick(); + this->SetDirty(); + break; } } @@ -1071,7 +1088,7 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { FOR_ALL_SORTED_STANDARD_CARGOSPECS(cs) { this->colours[i] = cs->legend_colour; for (int j = 0; j != 20; j++) { - const byte ctt = static_cast(factor / static_cast((j + 1) * this->x_values_increment)); + const byte ctt = _cargo_payment_x_mode ? static_cast(factor / static_cast((j + 1) * this->x_values_increment)) : (j + 1) * 4; this->cost[i][j] = GetTransportedGoodsIncome(10, 20, ctt, cs->Index()); } i++; @@ -1083,7 +1100,12 @@ struct PaymentRatesGraphWindow : BaseGraphWindow { { switch (widget) { case WID_CPR_FOOTER: - SetDParam(0, STR_UNIT_NAME_VELOCITY_IMPERIAL + _settings_game.locale.units_velocity); + if (_cargo_payment_x_mode) { + SetDParam(0, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL_SPEED); + SetDParam(1, STR_UNIT_NAME_VELOCITY_IMPERIAL + _settings_game.locale.units_velocity); + } else { + SetDParam(0, STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL); + } break; } } @@ -1106,6 +1128,8 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { NWidget(NWID_HORIZONTAL), NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CPR_GRAPH), SetMinimalSize(495, 0), SetFill(1, 1), SetResize(1, 1), NWidget(NWID_VERTICAL), + NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_CPR_DAYS), SetDataTip(STR_GRAPH_CARGO_DAYS_MODE, STR_GRAPH_CARGO_TOOLTIP_DAYS_MODE), SetFill(1, 0), + NWidget(WWT_TEXTBTN, COLOUR_BROWN, WID_CPR_SPEED), SetDataTip(STR_GRAPH_CARGO_SPEED_MODE, STR_GRAPH_CARGO_TOOLTIP_SPEED_MODE), SetFill(1, 0), NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1), NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_ENABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0), NWidget(WWT_PUSHTXTBTN, COLOUR_BROWN, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0), @@ -1119,9 +1143,8 @@ static const NWidgetPart _nested_cargo_payment_rates_widgets[] = { NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1), EndContainer(), NWidget(NWID_HORIZONTAL), - NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(1, 0), SetResize(1, 0), - NWidget(WWT_TEXT, COLOUR_BROWN, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL_SPEED, STR_NULL), - NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0), + NWidget(NWID_SPACER), SetMinimalSize(WD_RESIZEBOX_WIDTH, 0), SetFill(0, 0), SetResize(0, 0), + NWidget(WWT_TEXT, COLOUR_BROWN, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetAlignment(SA_CENTER), SetPadding(2, 0, 2, 0), SetDataTip(STR_JUST_STRING1, STR_NULL), SetFill(1, 0), SetResize(1, 0), NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CPR_RESIZE), EndContainer(), EndContainer(), diff --git a/src/graph_gui.h b/src/graph_gui.h index 8338878c01..07a0c2f66a 100644 --- a/src/graph_gui.h +++ b/src/graph_gui.h @@ -10,6 +10,8 @@ #ifndef GRAPH_GUI_H #define GRAPH_GUI_H +extern uint8 _cargo_payment_x_mode; + void ShowOperatingProfitGraph(); void ShowIncomeGraph(); void ShowDeliveredCargoGraph(); diff --git a/src/lang/english.txt b/src/lang/english.txt index d02489a3b5..bb0082862e 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -613,6 +613,11 @@ STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL :{BLACK}Display STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO :{BLACK}Toggle graph for cargo type on/off STR_GRAPH_CARGO_PAYMENT_CARGO :{TINY_FONT}{BLACK}{STRING} +STR_GRAPH_CARGO_DAYS_MODE :{TINY_FONT}{BLACK}Days in transit +STR_GRAPH_CARGO_SPEED_MODE :{TINY_FONT}{BLACK}Average speed +STR_GRAPH_CARGO_TOOLTIP_DAYS_MODE :{BLACK}Display days in transit on the x-axis of the graph +STR_GRAPH_CARGO_TOOLTIP_SPEED_MODE :{BLACK}Display average transit speed on the x-axis of the graph + STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP :{BLACK}Show detailed performance ratings # Graph key window diff --git a/src/settings.cpp b/src/settings.cpp index e9c9bae17e..9a1cb30775 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -72,6 +72,7 @@ #include "scope_info.h" #include "viewport_func.h" #include "gui.h" +#include "graph_gui.h" #include "void_map.h" #include "station_base.h" diff --git a/src/table/misc_settings.ini b/src/table/misc_settings.ini index 1d3f94fc22..eab963d0ee 100644 --- a/src/table/misc_settings.ini +++ b/src/table/misc_settings.ini @@ -381,5 +381,13 @@ min = 0 max = ZEM_END - 1 cat = SC_BASIC +[SDTG_VAR] +name = ""cargo_payment_x_mode"" +type = SLE_UINT8 +var = _cargo_payment_x_mode +def = 0 +min = 0 +max = 1 + [SDTG_END] diff --git a/src/widgets/graph_widget.h b/src/widgets/graph_widget.h index 7c6478f640..14205b47b7 100644 --- a/src/widgets/graph_widget.h +++ b/src/widgets/graph_widget.h @@ -49,6 +49,8 @@ enum CargoPaymentRatesWidgets { WID_CPR_DISABLE_CARGOES, ///< Disable cargoes button. WID_CPR_MATRIX, ///< Cargo list. WID_CPR_MATRIX_SCROLLBAR,///< Cargo list scrollbar. + WID_CPR_DAYS, ///< Days in transit mode. + WID_CPR_SPEED, ///< Speed mode. }; /** Widget of the #CompanyLeagueWindow class. */