|
@@ -138,13 +138,14 @@ enum CompanyFinancesWindowWidgets {
|
|
|
CFW_MAXLOAN_VALUE, ///< Max loan widget
|
|
|
CFW_SEL_BUTTONS, ///< Selection of buttons
|
|
|
CFW_INCREASE_LOAN, ///< Increase loan
|
|
|
CFW_REPAY_LOAN, ///< Decrease loan
|
|
|
};
|
|
|
|
|
|
/** Draw the expenses categories.
|
|
|
/**
|
|
|
* Draw the expenses categories.
|
|
|
* @param r Available space for drawing.
|
|
|
* @note The environment must provide padding at the left and right of \a r.
|
|
|
*/
|
|
|
static void DrawCategories(const Rect &r)
|
|
|
{
|
|
|
int y = r.top;
|
|
@@ -165,13 +166,14 @@ static void DrawCategories(const Rect &r
|
|
|
}
|
|
|
}
|
|
|
|
|
|
DrawString(r.left, r.right, y + EXP_LINESPACE, STR_FINANCES_TOTAL_CAPTION, TC_FROMSTRING, SA_RIGHT);
|
|
|
}
|
|
|
|
|
|
/** Draw an amount of money.
|
|
|
/**
|
|
|
* Draw an amount of money.
|
|
|
* @param amount Amount of money to draw,
|
|
|
* @param left Left coordinate of the space to draw in.
|
|
|
* @param right Right coordinate of the space to draw in.
|
|
|
* @param top Top coordinate of the space to draw in.
|
|
|
*/
|
|
|
static void DrawPrice(Money amount, int left, int right, int top)
|
|
@@ -182,13 +184,14 @@ static void DrawPrice(Money amount, int
|
|
|
str++;
|
|
|
}
|
|
|
SetDParam(0, amount);
|
|
|
DrawString(left, right, top, str, TC_FROMSTRING, SA_RIGHT);
|
|
|
}
|
|
|
|
|
|
/** Draw a column with prices.
|
|
|
/**
|
|
|
* Draw a column with prices.
|
|
|
* @param r Available space for drawing.
|
|
|
* @param year Year being drawn.
|
|
|
* @param tbl Pointer to table of amounts for \a year.
|
|
|
* @note The environment must provide padding at the left and right of \a r.
|
|
|
*/
|
|
|
static void DrawYearColumn(const Rect &r, int year, const Money (*tbl)[EXPENSES_END])
|
|
@@ -275,13 +278,14 @@ static const NWidgetPart _nested_company
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CFW_INCREASE_LOAN), SetFill(1, 0), SetDataTip(STR_FINANCES_BORROW_BUTTON, STR_FINANCES_BORROW_TOOLTIP),
|
|
|
NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, CFW_REPAY_LOAN), SetFill(1, 0), SetDataTip(STR_FINANCES_REPAY_BUTTON, STR_FINANCES_REPAY_TOOLTIP),
|
|
|
EndContainer(),
|
|
|
EndContainer(),
|
|
|
};
|
|
|
|
|
|
/** Window class displaying the company finances.
|
|
|
/**
|
|
|
* Window class displaying the company finances.
|
|
|
* @todo #money_width should be calculated dynamically.
|
|
|
*/
|
|
|
struct CompanyFinancesWindow : Window {
|
|
|
static Money max_money; ///< The maximum amount of money a company has had this 'run'
|
|
|
bool small; ///< Window is toggled to 'small'.
|
|
|
|
|
@@ -384,13 +388,14 @@ struct CompanyFinancesWindow : Window {
|
|
|
case CFW_LOAN_LINE:
|
|
|
GfxFillRect(r.left, r.top, r.right, r.top, 215);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/** Setup the widgets in the nested tree, such that the finances window is displayed properly.
|
|
|
/**
|
|
|
* Setup the widgets in the nested tree, such that the finances window is displayed properly.
|
|
|
* @note After setup, the window must be (re-)initialized.
|
|
|
*/
|
|
|
void SetupWidgets()
|
|
|
{
|
|
|
int plane = this->small ? SZSP_NONE : 0;
|
|
|
this->GetWidget<NWidgetStacked>(CFW_SEL_PANEL)->SetDisplayedPlane(plane);
|
|
@@ -474,13 +479,14 @@ static const WindowDesc _company_finance
|
|
|
WDP_AUTO, 0, 0,
|
|
|
WC_FINANCES, WC_NONE,
|
|
|
WDF_UNCLICK_BUTTONS,
|
|
|
_nested_company_finances_widgets, lengthof(_nested_company_finances_widgets)
|
|
|
);
|
|
|
|
|
|
/** Open the finances window of a company.
|
|
|
/**
|
|
|
* Open the finances window of a company.
|
|
|
* @param company Company to show finances of.
|
|
|
* @pre is company a valid company.
|
|
|
*/
|
|
|
void ShowCompanyFinances(CompanyID company)
|
|
|
{
|
|
|
if (!Company::IsValidID(company)) return;
|
|
@@ -1142,13 +1148,14 @@ public:
|
|
|
this->owner = (Owner)this->window_number;
|
|
|
this->face = Company::Get((CompanyID)this->window_number)->face;
|
|
|
|
|
|
this->UpdateData();
|
|
|
}
|
|
|
|
|
|
/** Select planes to display to the user with the #NWID_SELECTION widgets #SCMFW_WIDGET_SEL_LOADSAVE, #SCMFW_WIDGET_SEL_MALEFEMALE, and #SCMFW_WIDGET_SEL_PARTS.
|
|
|
/**
|
|
|
* Select planes to display to the user with the #NWID_SELECTION widgets #SCMFW_WIDGET_SEL_LOADSAVE, #SCMFW_WIDGET_SEL_MALEFEMALE, and #SCMFW_WIDGET_SEL_PARTS.
|
|
|
* @param advanced Display advanced face management window.
|
|
|
*/
|
|
|
void SelectDisplayPlanes(bool advanced)
|
|
|
{
|
|
|
this->GetWidget<NWidgetStacked>(SCMFW_WIDGET_SEL_LOADSAVE)->SetDisplayedPlane(advanced ? 0 : SZSP_NONE);
|
|
|
this->GetWidget<NWidgetStacked>(SCMFW_WIDGET_SEL_PARTS)->SetDisplayedPlane(advanced ? 0 : SZSP_NONE);
|