Index: player_gui.cpp =================================================================== --- player_gui.cpp (revision 10704) +++ player_gui.cpp (working copy) @@ -31,54 +31,197 @@ 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 Money (*tbl)[13]; - Money sum, cost; + Money sum, cost, total; StringID str; if (!(mode & 1)) { // normal sized economics window (mode&1) is minimized status - /* draw categories */ + /* draw header */ 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); - /* draw the price columns */ + /* draw income column names: indexes 7, 8, 9, 10 */ + for (i = 7; i != 11; i++) + DrawString(2, i * 10 - 43, STR_7011_CONSTRUCTION + i, 0); + + /* draw subtotal column name */ + DrawStringRightAligned(111, 69, STR_7020_TOTAL, 0); + + /* draw expenses column names: indexes 2, 3, 4, 5, 6, 11 */ + for (i = 2; i != 7; i++) + DrawString(2, i * 10 + 67, STR_7011_CONSTRUCTION + i, 0); + DrawString(2, 137, STR_7011_CONSTRUCTION + 11, 0); + + /* draw subtotal column name */ + DrawStringRightAligned(111, 149, STR_7020_TOTAL, 0); + + /* draw other column names: indexes 0, 1, 12*/ + for (i = 0; i != 2; i++) + DrawString(2, i * 10 + 167, STR_7011_CONSTRUCTION + i, 0); + DrawString(2, 187, STR_7011_CONSTRUCTION + 12, 0); + + /* draw subtotal column name */ + DrawStringRightAligned(111, 199, STR_7020_TOTAL, 0); + + /* draw total column name */ + DrawStringRightAligned(111, 219, STR_7020_TOTAL, 0); + + /* draw the column values */ 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); + + total = 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) { sum += cost; str = STR_701E; - if (cost < 0) { cost = -cost; str++; } + if (cost < 0) { + cost = -cost; + str++; + } SetDParam(0, cost); - DrawStringRightAligned(x, 27 + i * 10, str, 0); + DrawStringRightAligned(x, i * 10 - 43, str, 0); } } str = STR_701E; - if (sum < 0) { sum = -sum; str++; } + total += sum; + if (sum < 0) { + sum = -sum; + str++; + } SetDParam(0, sum); - DrawStringRightAligned(x, 27 + 13 * 10 + 2, str, 0); + DrawStringRightAligned(x, 69, str, 0); - GfxFillRect(x - 75, 27 + 10 * 13, x, 27 + 10 * 13, 215); - x += 95; + /* 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++; + } + SetDParam(0, cost); + DrawStringRightAligned(x, i * 10 + 67, str, 0); + } + } + + i = 11; + cost = (*tbl)[i]; + if (cost != 0) { + sum += cost; + + str = STR_701E; + if (cost < 0) { + cost = -cost; + str++; + } + SetDParam(0, cost); + DrawStringRightAligned(x, i * 10 + 27, str, 0); + } + + str = STR_701E; + total += sum; + if (sum < 0) { + sum = -sum; + str++; + } + SetDParam(0, sum); + DrawStringRightAligned(x, 149, str, 0); + + /* 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++; + } + SetDParam(0, cost); + DrawStringRightAligned(x, i * 10 + 167, str, 0); + } + } + + i = 12; + cost = (*tbl)[i]; + if (cost != 0) { + sum += cost; + + str = STR_701E; + if (cost < 0) { + cost = -cost; + str++; + } + SetDParam(0, cost); + DrawStringRightAligned(x, i * 10 + 67, str, 0); + } + + str = STR_701E; + total += sum; + if (sum < 0) { + sum = -sum; + str++; + } + SetDParam(0, sum); + DrawStringRightAligned(x, 199, str, 0); + + str = STR_701E; + if (total < 0) { + total = -total; + str++; + } + SetDParam(0, total); + DrawStringRightAligned(x, 219, str, 0); + + GfxFillRect(x - 75, 67, x, 67, 215); + GfxFillRect(x - 75, 147, x, 147, 215); + GfxFillRect(x - 75, 197, x, 197, 215); + GfxFillRect(x - 75, 217, x, 217, 215); + x += 135; } year++; tbl--; } while (--j != 0); - y = 171; + y = 231; /* draw max loan aligned to loan below (y += 10) */ SetDParam(0, _economy.max_loan); @@ -99,7 +242,7 @@ y += 12; - GfxFillRect(182 - 75, y - 2, 182, y - 2, 215); + GfxFillRect(107, y - 2, 182, y - 2, 215); SetDParam(0, p->player_money - p->current_loan); DrawStringRightAligned(182, y, STR_7028, 0); @@ -107,23 +250,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}, -{ WIDGETS_END}, +{ 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, SPR_LARGE_SMALL_WINDOW, 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, SPR_LARGE_SMALL_WINDOW, 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}, }; @@ -197,7 +340,7 @@ } static const WindowDesc _player_finances_desc = { - WDP_AUTO, WDP_AUTO, 407, 216, 407, 216, + WDP_AUTO, WDP_AUTO, 527, 276, 527, 276, WC_FINANCES, WC_NONE, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _player_finances_widgets, @@ -213,7 +356,7 @@ }; static const WindowDesc _other_player_finances_desc = { - WDP_AUTO, WDP_AUTO, 407, 204, 407, 204, + WDP_AUTO, WDP_AUTO, 527, 264, 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,