|
@@ -483,49 +483,49 @@ protected:
|
|
|
public:
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
{
|
|
|
if (widget != this->graph_widget) return;
|
|
|
|
|
|
uint x_label_width = 0;
|
|
|
|
|
|
if (this->month != 0xFF) {
|
|
|
byte month = this->month;
|
|
|
Year year = this->year;
|
|
|
for (int i = 0; i < this->num_on_x_axis; i++) {
|
|
|
SetDParam(0, month + STR_MONTH_ABBREV_JAN);
|
|
|
SetDParam(1, month + STR_MONTH_ABBREV_JAN + 2);
|
|
|
SetDParam(2, year);
|
|
|
x_label_width = max(x_label_width, GetStringBoundingBox(month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH).width);
|
|
|
|
|
|
month += 3;
|
|
|
if (month >= 12) {
|
|
|
month = 0;
|
|
|
year++;
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
/* Draw the label under the data point rather than on the grid line. */
|
|
|
SetDParam(0, this->x_values_start + this->num_on_x_axis * this->x_values_increment);
|
|
|
SetDParamMaxValue(0, this->x_values_start + this->num_on_x_axis * this->x_values_increment);
|
|
|
x_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL_NUMBER).width;
|
|
|
}
|
|
|
|
|
|
SetDParam(0, this->format_str_y_axis);
|
|
|
SetDParam(1, INT64_MAX);
|
|
|
uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width;
|
|
|
|
|
|
size->width = max<uint>(size->width, 5 + y_label_width + this->num_on_x_axis * (x_label_width + 5) + 9);
|
|
|
size->height = max<uint>(size->height, 5 + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + 4);
|
|
|
size->height = max<uint>(size->height, size->width / 3);
|
|
|
}
|
|
|
|
|
|
virtual void DrawWidget(const Rect &r, int widget) const
|
|
|
{
|
|
|
if (widget != this->graph_widget) return;
|
|
|
|
|
|
DrawGraph(r);
|
|
|
}
|
|
|
|
|
|
virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
|
|
|
{
|
|
|
return INVALID_DATAPOINT;
|
|
|
}
|
|
|
|
|
@@ -1301,52 +1301,52 @@ struct PerformanceRatingDetailWindow : W
|
|
|
|
|
|
this->timeout = DAY_TICKS * 5;
|
|
|
}
|
|
|
|
|
|
uint score_info_left;
|
|
|
uint score_info_right;
|
|
|
uint bar_left;
|
|
|
uint bar_right;
|
|
|
uint bar_width;
|
|
|
uint bar_height;
|
|
|
uint score_detail_left;
|
|
|
uint score_detail_right;
|
|
|
|
|
|
virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize)
|
|
|
{
|
|
|
switch (widget) {
|
|
|
case WID_PRD_SCORE_FIRST:
|
|
|
this->bar_height = FONT_HEIGHT_NORMAL + 4;
|
|
|
size->height = this->bar_height + 2 * WD_MATRIX_TOP;
|
|
|
|
|
|
uint score_info_width = 0;
|
|
|
for (uint i = SCORE_BEGIN; i < SCORE_END; i++) {
|
|
|
score_info_width = max(score_info_width, GetStringBoundingBox(STR_PERFORMANCE_DETAIL_VEHICLES + i).width);
|
|
|
}
|
|
|
SetDParam(0, 1000);
|
|
|
SetDParamMaxValue(0, 1000);
|
|
|
score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WD_FRAMERECT_LEFT;
|
|
|
|
|
|
SetDParam(0, 100);
|
|
|
SetDParamMaxValue(0, 100);
|
|
|
this->bar_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_PERCENT).width + 20; // Wide bars!
|
|
|
|
|
|
/* At this number we are roughly at the max; it can become wider,
|
|
|
* but then you need at 1000 times more money. At that time you're
|
|
|
* not that interested anymore in the last few digits anyway.
|
|
|
* The 500 is because 999 999 500 to 999 999 999 are rounded to
|
|
|
* 1 000 M, and not 999 999 k. Use negative numbers to account for
|
|
|
* the negative income/amount of money etc. as well. */
|
|
|
int max = -(999999999 - 500);
|
|
|
|
|
|
/* Scale max for the display currency. Prior to rendering the value
|
|
|
* is converted into the display currency, which may cause it to
|
|
|
* raise significantly. We need to compensate for that since {{CURRCOMPACT}}
|
|
|
* is used, which can produce quite short renderings of very large
|
|
|
* values. Otherwise the calculated width could be too narrow.
|
|
|
* Note that it doesn't work if there was a currency with an exchange
|
|
|
* rate greater than max.
|
|
|
* When the currency rate is more than 1000, the 999 999 k becomes at
|
|
|
* least 999 999 M which roughly is equally long. Furthermore if the
|
|
|
* exchange rate is that high, 999 999 k is usually not enough anymore
|
|
|
* to show the different currency numbers. */
|
|
|
if (_currency->rate < 1000) max /= _currency->rate;
|
|
|
SetDParam(0, max);
|
|
|
SetDParam(1, max);
|