mirror of https://github.com/OpenRCT2/OpenRCT2.git
Leverage more historical data in Finances window.
This adds a horizontal scrollbar to the summary page.
This commit is contained in:
parent
6cdcda2c65
commit
df6a86d9bf
|
@ -1,5 +1,6 @@
|
|||
0.1.3 (in development)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: [#7267] Leverage more historical data in Finances window.
|
||||
|
||||
0.1.2 (2018-03-18)
|
||||
------------------------------------------------------------------------
|
||||
|
|
|
@ -51,7 +51,8 @@ enum
|
|||
WIDX_TAB_5,
|
||||
WIDX_TAB_6,
|
||||
|
||||
WIDX_LOAN = 10,
|
||||
WIDX_SUMMARY_SCROLL = 10,
|
||||
WIDX_LOAN,
|
||||
WIDX_LOAN_INCREASE,
|
||||
WIDX_LOAN_DECREASE,
|
||||
|
||||
|
@ -87,14 +88,15 @@ enum
|
|||
|
||||
static rct_widget _windowFinancesSummaryWidgets[] =
|
||||
{
|
||||
{ WWT_FRAME, 0, 0, 529, 0, 288, 0xFFFFFFFF, STR_NONE }, \
|
||||
{ WWT_FRAME, 0, 0, 529, 0, 309, 0xFFFFFFFF, STR_NONE }, \
|
||||
{ WWT_CAPTION, 0, 1, 528, 1, 14, STR_FINANCIAL_SUMMARY, STR_WINDOW_TITLE_TIP }, \
|
||||
{ WWT_CLOSEBOX, 0, 517, 527, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP }, \
|
||||
{ WWT_RESIZE, 1, 0, 529, 43, 288, 0xFFFFFFFF, STR_NONE }, \
|
||||
{ WWT_RESIZE, 1, 0, 529, 43, 309, 0xFFFFFFFF, STR_NONE }, \
|
||||
TAB_WIDGETS,
|
||||
{ WWT_SPINNER, 1, 64, 153, 259, 270, STR_FINANCES_SUMMARY_LOAN_VALUE, STR_NONE },
|
||||
{ WWT_BUTTON, 1, 142, 152, 260, 264, STR_NUMERIC_UP, STR_NONE },
|
||||
{ WWT_BUTTON, 1, 142, 152, 265, 269, STR_NUMERIC_DOWN, STR_NONE },
|
||||
{ WWT_SCROLL, 1, 130, 520, 50, 260, SCROLL_HORIZONTAL, STR_NONE },
|
||||
{ WWT_SPINNER, 1, 64, 153, 279, 290, STR_FINANCES_SUMMARY_LOAN_VALUE, STR_NONE },
|
||||
{ WWT_BUTTON, 1, 142, 152, 280, 284, STR_NUMERIC_UP, STR_NONE },
|
||||
{ WWT_BUTTON, 1, 142, 152, 285, 289, STR_NUMERIC_DOWN, STR_NONE },
|
||||
{ WIDGETS_END },
|
||||
};
|
||||
|
||||
|
@ -183,9 +185,12 @@ static rct_widget *_windowFinancesPageWidgets[] =
|
|||
|
||||
static void window_finances_summary_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
||||
static void window_finances_summary_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
|
||||
static void window_finances_summary_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height);
|
||||
static void window_finances_summary_invertscroll(rct_window *w);
|
||||
static void window_finances_summary_update(rct_window *w);
|
||||
static void window_finances_summary_invalidate(rct_window *w);
|
||||
static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi);
|
||||
static void window_finances_summary_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex);
|
||||
|
||||
static void window_finances_financial_graph_mouseup(rct_window *w, rct_widgetindex widgetIndex);
|
||||
static void window_finances_financial_graph_update(rct_window *w);
|
||||
|
@ -232,7 +237,7 @@ static rct_window_event_list _windowFinancesSummaryEvents =
|
|||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
window_finances_summary_scrollgetsize,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
|
@ -244,7 +249,7 @@ static rct_window_event_list _windowFinancesSummaryEvents =
|
|||
nullptr,
|
||||
window_finances_summary_invalidate,
|
||||
window_finances_summary_paint,
|
||||
nullptr
|
||||
window_finances_summary_scrollpaint
|
||||
};
|
||||
|
||||
// 0x00988F28
|
||||
|
@ -438,6 +443,7 @@ static rct_window_event_list *const _windowFinancesPageEvents[] =
|
|||
static constexpr const uint32 WindowFinancesPageEnabledWidgets[] =
|
||||
{
|
||||
ALWAYS_ENABLED_WIDGETS |
|
||||
(1ULL << WIDX_SUMMARY_SCROLL) |
|
||||
(1ULL << WIDX_LOAN_INCREASE) |
|
||||
(1ULL << WIDX_LOAN_DECREASE),
|
||||
|
||||
|
@ -486,6 +492,8 @@ static constexpr const sint32 WindowFinancesTabAnimationLoops[] =
|
|||
16, 32, 32, 32, 38, 16
|
||||
};
|
||||
|
||||
static constexpr const sint32 EXPENDITURE_COLUMN_WIDTH = 80;
|
||||
|
||||
static constexpr const rct_string_id window_finances_summary_row_labels[RCT_EXPENDITURE_TYPE_COUNT] = {
|
||||
STR_FINANCES_SUMMARY_RIDE_CONSTRUCTION,
|
||||
STR_FINANCES_SUMMARY_RIDE_RUNNING_COSTS,
|
||||
|
@ -517,7 +525,7 @@ rct_window * window_finances_open()
|
|||
|
||||
w = window_bring_to_front_by_class(WC_FINANCES);
|
||||
if (w == nullptr) {
|
||||
w = window_create_auto_pos(530, 290, _windowFinancesPageEvents[0], WC_FINANCES, WF_10);
|
||||
w = window_create_auto_pos(530, 310, _windowFinancesPageEvents[0], WC_FINANCES, WF_10);
|
||||
w->number = 0;
|
||||
w->frame_no = 0;
|
||||
|
||||
|
@ -527,7 +535,7 @@ rct_window * window_finances_open()
|
|||
w->page = WINDOW_FINANCES_PAGE_SUMMARY;
|
||||
window_invalidate(w);
|
||||
w->width = 530;
|
||||
w->height = 290;
|
||||
w->height = 310;
|
||||
window_invalidate(w);
|
||||
|
||||
w->widgets = _windowFinancesPageWidgets[WINDOW_FINANCES_PAGE_SUMMARY];
|
||||
|
@ -536,8 +544,12 @@ rct_window * window_finances_open()
|
|||
w->event_handlers = _windowFinancesPageEvents[WINDOW_FINANCES_PAGE_SUMMARY];
|
||||
w->pressed_widgets = 0;
|
||||
w->disabled_widgets = 0;
|
||||
|
||||
window_init_scroll_widgets(w);
|
||||
|
||||
// Scroll summary all the way to the right, initially.
|
||||
window_finances_summary_invertscroll(w);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
|
@ -595,6 +607,23 @@ static void window_finances_summary_mousedown(rct_window *w, rct_widgetindex wid
|
|||
}
|
||||
}
|
||||
|
||||
static uint16 summary_num_months_available()
|
||||
{
|
||||
return std::min<uint16>(gDateMonthsElapsed, EXPENDITURE_TABLE_MONTH_COUNT);
|
||||
}
|
||||
|
||||
static void window_finances_summary_scrollgetsize(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height)
|
||||
{
|
||||
*width = EXPENDITURE_COLUMN_WIDTH * (summary_num_months_available() + 1);
|
||||
}
|
||||
|
||||
static void window_finances_summary_invertscroll(rct_window *w)
|
||||
{
|
||||
rct_widget summary = w->widgets[WIDX_SUMMARY_SCROLL];
|
||||
w->scrolls[0].h_left = std::max(0, w->scrolls[0].h_right - ((summary.right - summary.left) - 2));
|
||||
widget_scroll_update_thumbs(w, WIDX_SUMMARY_SCROLL);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x0069CBA6
|
||||
|
@ -628,33 +657,74 @@ static void window_finances_summary_invalidate(rct_window *w)
|
|||
*/
|
||||
static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
||||
{
|
||||
sint32 i, j, x, y;
|
||||
|
||||
window_draw_widgets(w, dpi);
|
||||
window_finances_draw_tab_images(dpi, w);
|
||||
|
||||
x = w->x + 8;
|
||||
y = w->y + 51;
|
||||
sint32 x = w->x + 8;
|
||||
sint32 y = w->y + 51;
|
||||
|
||||
// Expenditure / Income heading
|
||||
draw_string_left_underline(dpi, STR_FINANCES_SUMMARY_EXPENDITURE_INCOME, nullptr, COLOUR_BLACK, x, y);
|
||||
y += 14;
|
||||
|
||||
// Expenditure / Income row labels
|
||||
for (i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++) {
|
||||
for (sint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++)
|
||||
{
|
||||
// Darken every even row
|
||||
if (i % 2 == 0)
|
||||
gfx_fill_rect(dpi, x, y - 1, x + 513 - 2, y + (TABLE_CELL_HEIGHT - 2), ColourMapA[w->colours[1]].lighter | 0x1000000);
|
||||
gfx_fill_rect(dpi, x, y - 1, x + 121, y + (TABLE_CELL_HEIGHT - 2), ColourMapA[w->colours[1]].lighter | 0x1000000);
|
||||
|
||||
gfx_draw_string_left(dpi, window_finances_summary_row_labels[i], nullptr, COLOUR_BLACK, x, y - 1);
|
||||
y += TABLE_CELL_HEIGHT;
|
||||
}
|
||||
|
||||
// Horizontal rule below expenditure / income table
|
||||
gfx_fill_rect_inset(dpi, w->x + 8, w->y + 272, w->x + 8 + 513, w->y + 272 + 1, w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
|
||||
|
||||
// Loan and interest rate
|
||||
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_LOAN, nullptr, COLOUR_BLACK, w->x + 8, w->y + 279);
|
||||
set_format_arg(0, uint16, gBankLoanInterestRate);
|
||||
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_AT_X_PER_YEAR, gCommonFormatArgs, COLOUR_BLACK, w->x + 160, w->y + 279);
|
||||
|
||||
// Current cash
|
||||
rct_string_id stringId = gCash >= 0 ? STR_CASH_LABEL : STR_CASH_NEGATIVE_LABEL;
|
||||
gfx_draw_string_left(dpi, stringId, &gCash, COLOUR_BLACK, w->x + 8, w->y + 294);
|
||||
|
||||
// Objective related financial information
|
||||
if (gScenarioObjectiveType == OBJECTIVE_MONTHLY_FOOD_INCOME) {
|
||||
money32 lastMonthProfit = finance_get_last_month_shop_profit();
|
||||
set_format_arg(0, money32, lastMonthProfit);
|
||||
gfx_draw_string_left(dpi, STR_LAST_MONTH_PROFIT_FROM_FOOD_DRINK_MERCHANDISE_SALES_LABEL, gCommonFormatArgs, COLOUR_BLACK, w->x + 280, w->y + 279);
|
||||
} else {
|
||||
// Park value and company value
|
||||
gfx_draw_string_left(dpi, STR_PARK_VALUE_LABEL, &gParkValue, COLOUR_BLACK, w->x + 280, w->y + 279);
|
||||
gfx_draw_string_left(dpi, STR_COMPANY_VALUE_LABEL, &gCompanyValue, COLOUR_BLACK, w->x + 280, w->y + 294);
|
||||
}
|
||||
}
|
||||
|
||||
static void window_finances_summary_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, sint32 scrollIndex)
|
||||
{
|
||||
sint32 x = 0;
|
||||
sint32 y = TABLE_CELL_HEIGHT + 2;
|
||||
|
||||
rct_widget self = w->widgets[WIDX_SUMMARY_SCROLL];
|
||||
sint32 row_width = std::max<uint16>(w->scrolls[0].h_right, self.right - self.left);
|
||||
|
||||
// Expenditure / Income row labels
|
||||
for (sint32 i = 0; i < RCT_EXPENDITURE_TYPE_COUNT; i++)
|
||||
{
|
||||
// Darken every even row
|
||||
if (i % 2 == 0)
|
||||
gfx_fill_rect(dpi, x, y - 1, x + row_width, y + (TABLE_CELL_HEIGHT - 2), ColourMapA[w->colours[1]].lighter | 0x1000000);
|
||||
|
||||
y += TABLE_CELL_HEIGHT;
|
||||
}
|
||||
|
||||
// Expenditure / Income values for each month
|
||||
x = w->x + 118;
|
||||
sint16 currentMonthYear = gDateMonthsElapsed;
|
||||
for (i = 4; i >= 0; i--) {
|
||||
y = w->y + 51;
|
||||
for (sint32 i = summary_num_months_available(); i >= 0; i--)
|
||||
{
|
||||
y = 0;
|
||||
|
||||
sint16 monthyear = currentMonthYear - i;
|
||||
if (monthyear < 0)
|
||||
|
@ -668,14 +738,14 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
monthyear == currentMonthYear ? STR_WINDOW_COLOUR_2_STRINGID : STR_BLACK_STRING,
|
||||
gCommonFormatArgs,
|
||||
COLOUR_BLACK,
|
||||
x + 80,
|
||||
x + EXPENDITURE_COLUMN_WIDTH,
|
||||
y
|
||||
);
|
||||
y += 14;
|
||||
|
||||
// Month expenditures
|
||||
money32 profit = 0;
|
||||
for (j = 0; j < RCT_EXPENDITURE_TYPE_COUNT; j++)
|
||||
for (sint32 j = 0; j < RCT_EXPENDITURE_TYPE_COUNT; j++)
|
||||
{
|
||||
money32 expenditure = gExpenditureTable[i][j];
|
||||
if (expenditure != 0)
|
||||
|
@ -686,7 +756,7 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
expenditure >= 0 ? STR_FINANCES_SUMMARY_INCOME_VALUE : STR_FINANCES_SUMMARY_EXPENDITURE_VALUE,
|
||||
&expenditure,
|
||||
COLOUR_BLACK,
|
||||
x + 80,
|
||||
x + EXPENDITURE_COLUMN_WIDTH,
|
||||
y
|
||||
);
|
||||
}
|
||||
|
@ -700,35 +770,12 @@ static void window_finances_summary_paint(rct_window *w, rct_drawpixelinfo *dpi)
|
|||
profit >= 0 ? STR_FINANCES_SUMMARY_INCOME_VALUE : STR_FINANCES_SUMMARY_LOSS_VALUE,
|
||||
&profit,
|
||||
COLOUR_BLACK,
|
||||
x + 80,
|
||||
x + EXPENDITURE_COLUMN_WIDTH,
|
||||
y
|
||||
);
|
||||
gfx_fill_rect(dpi, x + 10, y - 2, x + 10 + 70, y - 2, PALETTE_INDEX_10);
|
||||
gfx_fill_rect(dpi, x + 10, y - 2, x + EXPENDITURE_COLUMN_WIDTH, y - 2, PALETTE_INDEX_10);
|
||||
|
||||
x += 80;
|
||||
}
|
||||
|
||||
// Horizontal rule below expenditure / income table
|
||||
gfx_fill_rect_inset(dpi, w->x + 8, w->y + 252, w->x + 8 + 513, w->y + 252 + 1, w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
|
||||
|
||||
// Loan and interest rate
|
||||
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_LOAN, nullptr, COLOUR_BLACK, w->x + 8, w->y + 259);
|
||||
set_format_arg(0, uint16, gBankLoanInterestRate);
|
||||
gfx_draw_string_left(dpi, STR_FINANCES_SUMMARY_AT_X_PER_YEAR, gCommonFormatArgs, COLOUR_BLACK, w->x + 160, w->y + 259);
|
||||
|
||||
// Current cash
|
||||
rct_string_id stringId = gCash >= 0 ? STR_CASH_LABEL : STR_CASH_NEGATIVE_LABEL;
|
||||
gfx_draw_string_left(dpi, stringId, &gCash, COLOUR_BLACK, w->x + 8, w->y + 274);
|
||||
|
||||
// Objective related financial information
|
||||
if (gScenarioObjectiveType == OBJECTIVE_MONTHLY_FOOD_INCOME) {
|
||||
money32 lastMonthProfit = finance_get_last_month_shop_profit();
|
||||
set_format_arg(0, money32, lastMonthProfit);
|
||||
gfx_draw_string_left(dpi, STR_LAST_MONTH_PROFIT_FROM_FOOD_DRINK_MERCHANDISE_SALES_LABEL, gCommonFormatArgs, COLOUR_BLACK, w->x + 280, w->y + 259);
|
||||
} else {
|
||||
// Park value and company value
|
||||
gfx_draw_string_left(dpi, STR_PARK_VALUE_LABEL, &gParkValue, COLOUR_BLACK, w->x + 280, w->y + 259);
|
||||
gfx_draw_string_left(dpi, STR_COMPANY_VALUE_LABEL, &gCompanyValue, COLOUR_BLACK, w->x + 280, w->y + 274);
|
||||
x += EXPENDITURE_COLUMN_WIDTH;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1375,7 +1422,7 @@ static void window_finances_set_page(rct_window *w, sint32 page)
|
|||
w->height = 207;
|
||||
} else if (w->page == WINDOW_FINANCES_PAGE_SUMMARY) {
|
||||
w->width = 530;
|
||||
w->height = 290;
|
||||
w->height = 310;
|
||||
} else {
|
||||
w->width = 530;
|
||||
w->height = 257;
|
||||
|
@ -1385,6 +1432,10 @@ static void window_finances_set_page(rct_window *w, sint32 page)
|
|||
|
||||
window_init_scroll_widgets(w);
|
||||
window_invalidate(w);
|
||||
|
||||
// Scroll summary all the way to the right, initially.
|
||||
if (w->page == WINDOW_FINANCES_PAGE_SUMMARY)
|
||||
window_finances_summary_invertscroll(w);
|
||||
}
|
||||
|
||||
static void window_finances_set_pressed_tab(rct_window *w)
|
||||
|
|
Loading…
Reference in New Issue