Index: src/player_gui.cpp =================================================================== --- src/player_gui.cpp (revision 9793) +++ src/player_gui.cpp (working copy) @@ -29,29 +29,61 @@ static void DrawPlayerEconomyStats(const Player *p, byte mode) { + /* Finance indexes + * Legend: + * Index: Name - Section + * 0: Construction - Others + * 1: New Vehicles - Others + * 2: Train Running Costs - Recurring expenses + * 3: Road Veh. Running Costs - Recurring expenses + * 4: Aircraft Running Costs - Recurring expenses + * 5: Ship Running Costs - Recurring expenses + * 6: Property Maintenance - Recurring expenses + * 7: Train Income - Recurring income + * 8: Road Vehicle Income - Recurring income + * 9: Aircraft Income - Recurring income + * 10: Ship Income - Recurring income + * 11: Loan Interest - Recurring expenses + * 12: Other - Others + */ + int x, y, i, j, year; const int64 (*tbl)[13]; - int64 sum, cost; + int64 sum, cost, tally; StringID str; if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status /* draw categories */ DrawStringCenterUnderline(61, 15, STR_700F_EXPENDITURE_INCOME, 0); - for (i = 0; i != 13; i++) - DrawString(2, 27 + i * 10, STR_7011_CONSTRUCTION + i, 0); - DrawStringRightAligned(111, 27 + 10 * 13 + 2, STR_7020_TOTAL, 0); - + for (i = 0; i != 2; i++) + DrawString(2, 27 + i*10 + 140, STR_7011_CONSTRUCTION + i, 0); + for (i = 2; i != 7; i++) + DrawString(2, 27 + i*10 + 40, STR_7011_CONSTRUCTION + i, 0); + for (i = 7; i != 11; i++) + DrawString(2, 27 + i*10 - 70, STR_7011_CONSTRUCTION + i, 0); + DrawString(2, 27 + 11*10, STR_7011_CONSTRUCTION + i, 0); + i++; + DrawString(2, 27 + 12*10 + 40, STR_7011_CONSTRUCTION + i, 0); + DrawStringRightAligned(111, 27 + 4*10 + 2, STR_7020_TOTAL, 0); + DrawStringRightAligned(111, 27 + 12*10 + 2, STR_7020_TOTAL, 0); + DrawStringRightAligned(111, 27 + 17*10 + 2, STR_7020_TOTAL, 0); + DrawStringRightAligned(111, 27 + 19*10 + 2, STR_7020_TOTAL, 0); + /* draw the price columns */ year = _cur_year - 2; j = 3; - x = 215; + x = 255; tbl = p->yearly_expenses + 2; do { if (year >= p->inaugurated_year) { SetDParam(0, year); DrawStringRightAlignedUnderline(x, 15, STR_7010, 0); + + tally = 0; + + /* recurring income: indexes 7, 8, 9, 10 */ sum = 0; - for (i = 0; i != 13; i++) { + for (i = 7; i != 11; i++) { /* draw one row in the price column */ cost = (*tbl)[i]; if (cost != 0) { @@ -60,23 +92,94 @@ str = STR_701E; if (cost < 0) { cost = -cost; str++; } SetDParam64(0, cost); - DrawStringRightAligned(x, 27 + i * 10, str, 0); + DrawStringRightAligned(x, 27 + i * 10 - 70, str, 0); } } + + str = STR_701E; + tally += sum; + if (sum < 0) { sum = -sum; str++; } + SetDParam64(0, sum); + DrawStringRightAligned(x, 27 + 4 * 10 + 2, str, 0); + + /* recurring expenses: indexes 2, 3, 4, 5, 6, 11 */ + sum = 0; + for (i = 2; i != 7; i++) { + cost = (*tbl)[i]; + if (cost != 0) { + sum += cost; + + str = STR_701E; + if (cost < 0) { cost = -cost; str++; } + SetDParam64(0, cost); + DrawStringRightAligned(x, 27 + i * 10 + 40, str, 0); + } + } + i = 11; + cost = (*tbl)[i]; + if (cost != 0) { + sum += cost; + + str = STR_701E; + if (cost < 0) { cost = -cost; str++; } + SetDParam64(0, cost); + DrawStringRightAligned(x, 27 + i * 10, str, 0); + } + str = STR_701E; + tally += sum; if (sum < 0) { sum = -sum; str++; } SetDParam64(0, sum); - DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, 0); + DrawStringRightAligned(x, 27 + 12 * 10 + 2, str, 0); - GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215); - x += 95; + /* others: indexes 0, 1, 12 */ + sum = 0; + for (i = 0; i != 2; i++) { + cost = (*tbl)[i]; + if (cost != 0) { + sum += cost; + + str = STR_701E; + if (cost < 0) { cost = -cost; str++; } + SetDParam64(0, cost); + DrawStringRightAligned(x, 27 + i * 10 + 140, str, 0); + } + } + + i = 12; + cost = (*tbl)[i]; + if (cost != 0) { + sum += cost; + + str = STR_701E; + if (cost < 0) { cost = -cost; str++; } + SetDParam64(0, cost); + DrawStringRightAligned(x, 27 + i * 10 + 40, str, 0); + } + + str = STR_701E; + tally += sum; + if (sum < 0) { sum = -sum; str++; } + SetDParam64(0, sum); + DrawStringRightAligned(x, 27 + 17 * 10 + 2, str, 0); + + str = STR_701E; + if (tally < 0) { tally = -tally; str++; } + SetDParam64(0, sum); + DrawStringRightAligned(x, 27 + 19 * 10 + 2, str, 0); + + GfxFillRect(x - 75, 27 + 10 * 4, x, 27 + 10 * 4, 215); + GfxFillRect(x - 75, 27 + 10 * 12, x, 27 + 10 * 12, 215); + GfxFillRect(x - 75, 27 + 10 * 17, x, 27 + 10 * 17, 215); + GfxFillRect(x - 75, 27 + 10 * 19, x, 27 + 10 * 19, 215); + x += 135; } year++; tbl--; } while (--j != 0); - y = 171; + y = 231; /* draw max loan aligned to loan below (y += 10) */ SetDParam64(0, (uint64)_economy.max_loan); @@ -105,23 +208,23 @@ static const Widget _player_finances_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, -{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, -{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, -{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL}, -{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 202, 204, 215, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, -{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 203, 406, 204, 215, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, +{ WWT_CAPTION, RESIZE_NONE, 14, 11, 499, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_IMGBTN, RESIZE_NONE, 14, 500, 514, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, +{ WWT_STICKYBOX, RESIZE_NONE, 14, 515, 526, 0, 13, 0x0, STR_STICKY_BUTTON}, +{ WWT_PANEL, RESIZE_NONE, 14, 0, 526, 14, 229, 0x0, STR_NULL}, +{ WWT_PANEL, RESIZE_NONE, 14, 0, 526, 230, 263, 0x0, STR_NULL}, +{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 0, 262, 264, 275, STR_7029_BORROW, STR_7035_INCREASE_SIZE_OF_LOAN}, +{ WWT_PUSHTXTBTN, RESIZE_NONE, 14, 263, 526, 264, 275, STR_702A_REPAY, STR_7036_REPAY_PART_OF_LOAN}, { WIDGETS_END}, }; static const Widget _other_player_finances_widgets[] = { { WWT_CLOSEBOX, RESIZE_NONE, 14, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW}, -{ WWT_CAPTION, RESIZE_NONE, 14, 11, 379, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, -{ WWT_IMGBTN, RESIZE_NONE, 14, 380, 394, 0, 13, SPR_LARGE_SMALL_WINDOW, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, -{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, -{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, -{ WWT_PANEL, RESIZE_NONE, 14, 0, 406, 170, 203, 0x0, STR_NULL}, +{ WWT_CAPTION, RESIZE_NONE, 14, 11, 499, 0, 13, STR_700E_FINANCES, STR_018C_WINDOW_TITLE_DRAG_THIS}, +{ WWT_IMGBTN, RESIZE_NONE, 14, 500, 514, 0, 13, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, +{ WWT_STICKYBOX, RESIZE_NONE, 14, 515, 526, 0, 13, 0x0, STR_STICKY_BUTTON}, +{ WWT_PANEL, RESIZE_NONE, 14, 0, 526, 14, 229, 0x0, STR_NULL}, +{ WWT_PANEL, RESIZE_NONE, 14, 0, 526, 230, 263, 0x0, STR_NULL}, { WIDGETS_END}, }; @@ -192,7 +295,7 @@ } static const WindowDesc _player_finances_desc = { - WDP_AUTO, WDP_AUTO, 407, 216, + WDP_AUTO, WDP_AUTO, 527, 276, WC_FINANCES, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _player_finances_widgets, @@ -208,7 +311,7 @@ }; static const WindowDesc _other_player_finances_desc = { - WDP_AUTO, WDP_AUTO, 407, 204, + WDP_AUTO, WDP_AUTO, 527, 264, WC_FINANCES, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _other_player_finances_widgets,