--- .svn/text-base/player_gui.c.svn-base 2006-04-05 23:43:12.265625000 +0200 +++ player_gui.c 2006-04-07 18:04:07.314551000 +0200 @@ -1,4 +1,4 @@ -/* $Id$ */ +/* $Id: player_gui.c 4092 2006-03-24 18:16:39Z belugas $ */ #include "stdafx.h" #include "openttd.h" @@ -29,27 +29,41 @@ { 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 + 1920); DrawStringCenterUnderline(x-17, 15, STR_7010, 0); sum = 0; - for (i = 0; i != 13; i++) { + tally = 0; + + /* recurring income */ + sum = 0; + for (i = 7; i != 11; i++) { /* draw one row in the price column */ cost = (*tbl)[i]; if (cost != 0) { @@ -58,23 +72,93 @@ 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 */ + 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 */ + 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, tally); + 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); @@ -103,23 +187,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, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, -{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, -{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, -{ WWT_IMGBTN, 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_IMGBTN, RESIZE_NONE, 14, 0, 526, 14, 229, 0x0, STR_NULL}, +{ WWT_IMGBTN, 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, 0x2AA, STR_7075_TOGGLE_LARGE_SMALL_WINDOW}, -{ WWT_STICKYBOX, RESIZE_NONE, 14, 395, 406, 0, 13, 0x0, STR_STICKY_BUTTON}, -{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 406, 14, 169, 0x0, STR_NULL}, -{ WWT_IMGBTN, 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_IMGBTN, RESIZE_NONE, 14, 0, 526, 14, 229, 0x0, STR_NULL}, +{ WWT_IMGBTN, RESIZE_NONE, 14, 0, 526, 230, 263, 0x0, STR_NULL}, { WIDGETS_END}, }; @@ -187,7 +271,7 @@ } static const WindowDesc _player_finances_desc = { - -1,-1, 407, 216, + -1,-1, 527, 276, WC_FINANCES,0, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _player_finances_widgets, @@ -203,7 +287,7 @@ }; static const WindowDesc _other_player_finances_desc = { - -1,-1, 407, 204, + -1,-1, 527, 264, WC_FINANCES,0, WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS | WDF_STICKY_BUTTON, _other_player_finances_widgets,