mirror of https://github.com/OpenTTD/OpenTTD
Add: Wallclock mode for company graph time axis
parent
fdead06e14
commit
4c331ed7a2
|
@ -172,6 +172,7 @@ protected:
|
|||
static const int GRAPH_NUM_MONTHS = 24; ///< Number of months displayed in the graph.
|
||||
static const int PAYMENT_GRAPH_X_STEP_DAYS = 20; ///< X-axis step label for cargo payment rates "Days in transit".
|
||||
static const int PAYMENT_GRAPH_X_STEP_SECONDS = 10; ///< X-axis step label for cargo payment rates "Seconds in transit".
|
||||
static const int ECONOMY_QUARTER_MINUTES = 3; ///< Minutes per economic quarter.
|
||||
|
||||
static const TextColour GRAPH_AXIS_LABEL_COLOUR = TC_BLACK; ///< colour of the graph axis label.
|
||||
|
||||
|
@ -338,8 +339,13 @@ protected:
|
|||
/* Don't draw the first line, as that's where the axis will be. */
|
||||
x = r.left + x_sep;
|
||||
|
||||
for (int i = 0; i < this->num_vert_lines; i++) {
|
||||
GfxFillRect(x, r.top, x, r.bottom, GRAPH_GRID_COLOUR);
|
||||
int grid_colour = GRAPH_GRID_COLOUR;
|
||||
for (int i = 1; i < this->num_vert_lines + 1; i++) {
|
||||
/* If using wallclock units, we separate periods with a lighter line. */
|
||||
if (TimerGameEconomy::UsingWallclockUnits()) {
|
||||
grid_colour = (i % 4 == 0) ? GRAPH_YEAR_LINE_COLOUR : GRAPH_GRID_COLOUR;
|
||||
}
|
||||
GfxFillRect(x, r.top, x, r.bottom, grid_colour);
|
||||
x += x_sep;
|
||||
}
|
||||
|
||||
|
@ -401,7 +407,7 @@ protected:
|
|||
x += x_sep;
|
||||
}
|
||||
} else {
|
||||
/* Draw x-axis labels for graphs not based on quarterly performance (cargo payment rates). */
|
||||
/* Draw x-axis labels for graphs not based on quarterly performance (cargo payment rates, and all graphs when using wallclock units). */
|
||||
x = r.left;
|
||||
y = r.bottom + ScaleGUITrad(2);
|
||||
uint16_t label = this->x_values_start;
|
||||
|
@ -624,6 +630,12 @@ struct OperatingProfitGraphWindow : BaseGraphWindow {
|
|||
OperatingProfitGraphWindow(WindowDesc *desc, WindowNumber window_number) :
|
||||
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
|
||||
{
|
||||
this->num_on_x_axis = GRAPH_NUM_MONTHS;
|
||||
this->num_vert_lines = GRAPH_NUM_MONTHS;
|
||||
this->x_values_start = ECONOMY_QUARTER_MINUTES;
|
||||
this->x_values_increment = ECONOMY_QUARTER_MINUTES;
|
||||
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
||||
|
||||
this->InitializeWindow(window_number);
|
||||
}
|
||||
|
||||
|
@ -643,10 +655,12 @@ static constexpr NWidgetPart _nested_operating_profit_widgets[] = {
|
|||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 160), SetFill(1, 1), SetResize(1, 1),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_BROWN, WID_CV_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_LAST_72_MINUTES_TIME_LABEL, STR_NULL),
|
||||
NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
@ -675,6 +689,12 @@ struct IncomeGraphWindow : BaseGraphWindow {
|
|||
IncomeGraphWindow(WindowDesc *desc, WindowNumber window_number) :
|
||||
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
|
||||
{
|
||||
this->num_on_x_axis = GRAPH_NUM_MONTHS;
|
||||
this->num_vert_lines = GRAPH_NUM_MONTHS;
|
||||
this->x_values_start = ECONOMY_QUARTER_MINUTES;
|
||||
this->x_values_increment = ECONOMY_QUARTER_MINUTES;
|
||||
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
||||
|
||||
this->InitializeWindow(window_number);
|
||||
}
|
||||
|
||||
|
@ -694,10 +714,12 @@ static constexpr NWidgetPart _nested_income_graph_widgets[] = {
|
|||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_BROWN, WID_CV_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_LAST_72_MINUTES_TIME_LABEL, STR_NULL),
|
||||
NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
@ -724,6 +746,12 @@ struct DeliveredCargoGraphWindow : BaseGraphWindow {
|
|||
DeliveredCargoGraphWindow(WindowDesc *desc, WindowNumber window_number) :
|
||||
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_COMMA)
|
||||
{
|
||||
this->num_on_x_axis = GRAPH_NUM_MONTHS;
|
||||
this->num_vert_lines = GRAPH_NUM_MONTHS;
|
||||
this->x_values_start = ECONOMY_QUARTER_MINUTES;
|
||||
this->x_values_increment = ECONOMY_QUARTER_MINUTES;
|
||||
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
||||
|
||||
this->InitializeWindow(window_number);
|
||||
}
|
||||
|
||||
|
@ -743,10 +771,12 @@ static constexpr NWidgetPart _nested_delivered_cargo_graph_widgets[] = {
|
|||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_BROWN, WID_CV_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_LAST_72_MINUTES_TIME_LABEL, STR_NULL),
|
||||
NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
@ -773,6 +803,12 @@ struct PerformanceHistoryGraphWindow : BaseGraphWindow {
|
|||
PerformanceHistoryGraphWindow(WindowDesc *desc, WindowNumber window_number) :
|
||||
BaseGraphWindow(desc, WID_PHG_GRAPH, STR_JUST_COMMA)
|
||||
{
|
||||
this->num_on_x_axis = GRAPH_NUM_MONTHS;
|
||||
this->num_vert_lines = GRAPH_NUM_MONTHS;
|
||||
this->x_values_start = ECONOMY_QUARTER_MINUTES;
|
||||
this->x_values_increment = ECONOMY_QUARTER_MINUTES;
|
||||
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
||||
|
||||
this->InitializeWindow(window_number);
|
||||
}
|
||||
|
||||
|
@ -799,10 +835,12 @@ static constexpr NWidgetPart _nested_performance_history_widgets[] = {
|
|||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_PHG_BACKGROUND),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_EMPTY, COLOUR_BROWN, WID_PHG_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_BROWN, WID_PHG_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_LAST_72_MINUTES_TIME_LABEL, STR_NULL),
|
||||
NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_PHG_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
@ -829,6 +867,12 @@ struct CompanyValueGraphWindow : BaseGraphWindow {
|
|||
CompanyValueGraphWindow(WindowDesc *desc, WindowNumber window_number) :
|
||||
BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
|
||||
{
|
||||
this->num_on_x_axis = GRAPH_NUM_MONTHS;
|
||||
this->num_vert_lines = GRAPH_NUM_MONTHS;
|
||||
this->x_values_start = ECONOMY_QUARTER_MINUTES;
|
||||
this->x_values_increment = ECONOMY_QUARTER_MINUTES;
|
||||
this->draw_dates = !TimerGameEconomy::UsingWallclockUnits();
|
||||
|
||||
this->InitializeWindow(window_number);
|
||||
}
|
||||
|
||||
|
@ -848,10 +892,12 @@ static constexpr NWidgetPart _nested_company_value_graph_widgets[] = {
|
|||
NWidget(WWT_STICKYBOX, COLOUR_BROWN),
|
||||
EndContainer(),
|
||||
NWidget(WWT_PANEL, COLOUR_BROWN, WID_CV_BACKGROUND),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(WWT_EMPTY, COLOUR_BROWN, WID_CV_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
|
||||
NWidget(NWID_VERTICAL),
|
||||
NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
|
||||
NWidget(NWID_HORIZONTAL),
|
||||
NWidget(NWID_SPACER), SetMinimalSize(12, 0), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_TEXT, COLOUR_BROWN, WID_CV_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_LAST_72_MINUTES_TIME_LABEL, STR_NULL),
|
||||
NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
|
||||
NWidget(WWT_RESIZEBOX, COLOUR_BROWN, WID_CV_RESIZE), SetDataTip(RWV_HIDE_BEVEL, STR_TOOLTIP_RESIZE),
|
||||
EndContainer(),
|
||||
EndContainer(),
|
||||
|
|
|
@ -622,6 +622,8 @@ STR_GRAPH_CARGO_DELIVERED_CAPTION :{WHITE}Units of
|
|||
STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION :{WHITE}Company performance ratings (maximum rating=1000)
|
||||
STR_GRAPH_COMPANY_VALUES_CAPTION :{WHITE}Company Value Graph
|
||||
|
||||
STR_GRAPH_LAST_72_MINUTES_TIME_LABEL :{TINY_FONT}{BLACK}{TKM "" "Last 72 minutes"}
|
||||
|
||||
STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION :{WHITE}Cargo Payment Rates
|
||||
STR_GRAPH_CARGO_PAYMENT_RATES_TIME_LABEL :{TINY_FONT}{BLACK}{TKM Days Seconds} in transit
|
||||
STR_GRAPH_CARGO_PAYMENT_RATES_TITLE :{TINY_FONT}{BLACK}Payment for delivering 10 units (or 10,000 litres) of cargo a distance of 20 squares
|
||||
|
|
|
@ -27,6 +27,7 @@ enum CompanyValueWidgets : WidgetID {
|
|||
WID_CV_BACKGROUND, ///< Background of the window.
|
||||
WID_CV_GRAPH, ///< Graph itself.
|
||||
WID_CV_RESIZE, ///< Resize button.
|
||||
WID_CV_FOOTER, ///< Footer.
|
||||
};
|
||||
|
||||
/** Widget of the #PerformanceHistoryGraphWindow class. */
|
||||
|
@ -36,6 +37,7 @@ enum PerformanceHistoryGraphWidgets : WidgetID {
|
|||
WID_PHG_BACKGROUND, ///< Background of the window.
|
||||
WID_PHG_GRAPH, ///< Graph itself.
|
||||
WID_PHG_RESIZE, ///< Resize button.
|
||||
WID_PHG_FOOTER, ///< Footer.
|
||||
};
|
||||
|
||||
/** Widget of the #PaymentRatesGraphWindow class. */
|
||||
|
|
Loading…
Reference in New Issue