summaryrefslogtreecommitdiff
path: root/src/company_gui.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-24 12:42:36 +0000
committerrubidium <rubidium@openttd.org>2009-11-24 12:42:36 +0000
commitb6b551533532d64f47e883d770b9633027ca7628 (patch)
tree44a5a51654f42c75a7a8dd1ab3e8e6245184843e /src/company_gui.cpp
parent584c75722e4515dc2970bb14d4d2e4fa3d0e4164 (diff)
downloadopenttd-b6b551533532d64f47e883d770b9633027ca7628.tar.xz
(svn r18265) -Codechange: make the finance overview window big font aware
Diffstat (limited to 'src/company_gui.cpp')
-rw-r--r--src/company_gui.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 40ea52e8c..ab0e53f00 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -287,13 +287,12 @@ static const NWidgetPart _nested_company_finances_widgets[] = {
* @todo #money_width should be calculated dynamically.
*/
struct CompanyFinancesWindow : Window {
- bool small; ///< Window is toggled to 'small'.
- uint money_width; ///< Width needed for displaying all amounts.
+ static Money max_money; ///< The maximum amount of money a company has had this 'run'
+ bool small; ///< Window is toggled to 'small'.
CompanyFinancesWindow(const WindowDesc *desc, CompanyID company) : Window()
{
this->small = false;
- this->money_width = 86;
this->CreateNestedTree(desc);
this->SetupWidgets();
this->FinishInitNested(desc, company);
@@ -332,14 +331,13 @@ struct CompanyFinancesWindow : Window {
case CFW_EXPS_PRICE1:
case CFW_EXPS_PRICE2:
case CFW_EXPS_PRICE3:
- size->width = this->money_width;
size->height = _expenses_list_types[type].GetHeight();
- break;
-
+ /* Fall through */
case CFW_BALANCE_VALUE:
case CFW_LOAN_VALUE:
case CFW_TOTAL_VALUE:
- size->width = this->money_width + padding.width;
+ SetDParam(0, CompanyFinancesWindow::max_money);
+ size->width = max(GetStringBoundingBox(STR_FINANCES_NEGATIVE_INCOME).width, GetStringBoundingBox(STR_FINANCES_POSITIVE_INCOME).width) + padding.width;
break;
case CFW_MAXLOAN_GAP:
@@ -454,8 +452,21 @@ struct CompanyFinancesWindow : Window {
break;
}
}
+
+ virtual void OnHundredthTick()
+ {
+ const Company *c = Company::Get((CompanyID)this->window_number);
+ if (c->money > CompanyFinancesWindow::max_money) {
+ CompanyFinancesWindow::max_money = max(c->money * 2, CompanyFinancesWindow::max_money * 4);
+ this->SetupWidgets();
+ this->ReInit();
+ }
+ }
};
+/** First conservative estimate of the maximum amount of money */
+Money CompanyFinancesWindow::max_money = INT32_MAX;
+
static const WindowDesc _company_finances_desc(
WDP_AUTO, WDP_AUTO, 0, 0,
WC_FINANCES, WC_NONE,