summaryrefslogtreecommitdiff
path: root/src/graph_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-10-22 16:33:07 +0000
committerrubidium <rubidium@openttd.org>2010-10-22 16:33:07 +0000
commitcab122efef1c0c9a13bbe978a49e3b98626498f0 (patch)
tree5d7bcd98f8910ac441a629fe6ddd0d95d6786b7d /src/graph_gui.cpp
parent9f256e8785066c14206b7a988803f929228a71ff (diff)
downloadopenttd-cab122efef1c0c9a13bbe978a49e3b98626498f0.tar.xz
(svn r21010) -Fix [FS#4102]: the detailed performance rating window would occasionally be too narrow. Based on a patch by Krille
Diffstat (limited to 'src/graph_gui.cpp')
-rw-r--r--src/graph_gui.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 52d8c2689..c40ca2ae1 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -24,6 +24,7 @@
#include "sortlist_type.h"
#include "core/geometry_func.hpp"
#include "math.h"
+#include "currency.h"
#include "table/strings.h"
#include "table/sprites.h"
@@ -1354,8 +1355,24 @@ struct PerformanceRatingDetailWindow : Window {
/* 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;