@@ -15,24 +15,25 @@
#include "window_gui.h"
#include "company_base.h"
#include "company_gui.h"
#include "economy_func.h"
#include "cargotype.h"
#include "strings_func.h"
#include "window_func.h"
#include "date_func.h"
#include "gfx_func.h"
#include "sortlist_type.h"
#include "core/geometry_func.hpp"
#include "math.h"
#include "currency.h"
#include "table/strings.h"
#include "table/sprites.h"
/* Bitmasks of company and cargo indices that shouldn't be drawn. */
static uint _legend_excluded_companies;
static uint _legend_excluded_cargo;
/* Apparently these don't play well with enums. */
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.
@@ -1345,26 +1346,42 @@ struct PerformanceRatingDetailWindow : W
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);
score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WD_FRAMERECT_LEFT;
SetDParam(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. */
uint max = 999999999; // nine 9s
* 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);
uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width;
size->width = 7 + score_info_width + 5 + this->bar_width + 5 + score_detail_width + 7;
uint left = 7;
uint right = size->width - 7;
bool rtl = _dynlang.text_dir == TD_RTL;
this->score_info_left = rtl ? right - score_info_width : left;
this->score_info_right = rtl ? right : left + score_info_width;
@@ -374,25 +374,25 @@ struct GameOptionsWindow : Window {
T::SetSet(name);
this->reload = true;
this->InvalidateData();
virtual void OnDropdownSelect(int widget, int index)
{
switch (widget) {
case GOW_CURRENCY_DROPDOWN: // Currency
if (index == CUSTOM_CURRENCY_ID) ShowCustCurrency();
this->opt->locale.currency = index;
MarkWholeScreenDirty();
ReInitAllWindows();
break;
case GOW_DISTANCE_DROPDOWN: // Measuring units
this->opt->locale.units = index;
case GOW_ROADSIDE_DROPDOWN: // Road side
if (this->opt->vehicle.road_side != index) { // only change if setting changed
uint i;
if (GetSettingFromName("vehicle.road_side", &i) == NULL) NOT_REACHED();
SetSettingValue(i, index);
Status change: