35
35
#define BUTTONSPACE 14
37
37
// @author hsiegeln
38
const char money_frame_t::cost_type[MAX_PLAYER_COST][64] =
38
const char *money_frame_t::cost_type_name[MAX_PLAYER_COST_BUTTON] =
40
"Construction_Btn", "Operation", "New Vehicles", "Revenue",
41
"Maintenance", "Assets", "Cash", "Net Wealth", "Gross Profit", "Ops Profit", "Margin (%)", "Transported", "Powerlines"
44
const int money_frame_t::cost_type_color[MAX_PLAYER_COST] =
57
const COLOR_VAL money_frame_t::cost_type_color[MAX_PLAYER_COST_BUTTON] =
51
70
COL_VEHICLE_ASSETS,
61
const uint8 button_order[MAX_PLAYER_COST] =
75
const uint8 money_frame_t::cost_type[MAX_PLAYER_COST_BUTTON] =
63
3, 1, 4, 9, 2, 0, 8, 12, 11,
77
COST_INCOME, // Income
78
COST_VEHICLE_RUN, // Vehicle running costs
79
COST_MAINTENANCE, // Upkeep
81
COST_POWERLINES, // revenue from the power grid
82
COST_OPERATING_PROFIT, // COST_POWERLINES+COST_INCOME-(COST_VEHICLE_RUN+COST_MAINTENANCE)
83
COST_NEW_VEHICLE, // New vehicles
84
COST_CONSTRUCTION, // Construction
85
COST_PROFIT, // COST_POWERLINES+COST_INCOME-(COST_CONSTRUCTION+COST_VEHICLE_RUN+COST_NEW_VEHICLE+COST_MAINTENANCE)
86
COST_ALL_TRANSPORTED, // all transported goods
88
COST_ASSETS, // value of all vehicles and buildings
89
COST_MARGIN, // COST_OPERATING_PROFIT/COST_INCOME
90
COST_NETWEALTH, // Total Cash + Assets
91
117
money_frame_t::money_frame_t(spieler_t *sp)
92
: gui_frame_t("Finanzen", sp),
118
: gui_frame_t( translator::translate("Finanzen"), sp),
93
119
tylabel("This Year", COL_WHITE, gui_label_t::right),
94
120
lylabel("Last Year", COL_WHITE, gui_label_t::right),
95
121
conmoney(NULL, COL_WHITE, gui_label_t::money),
113
139
margin(NULL, COL_WHITE, gui_label_t::money),
114
140
transport(NULL, COL_WHITE, gui_label_t::right),
115
141
old_transport(NULL, COL_WHITE, gui_label_t::right),
142
toll(NULL, COL_WHITE, gui_label_t::money),
143
old_toll(NULL, COL_WHITE, gui_label_t::money),
116
144
powerline(NULL, COL_WHITE, gui_label_t::money),
117
145
old_powerline(NULL, COL_WHITE, gui_label_t::money),
118
146
maintenance_label("This Month",COL_WHITE, gui_label_t::right),
137
165
chart.set_dimension(MAX_PLAYER_HISTORY_YEARS, 10000);
138
166
chart.set_seed(sp->get_welt()->get_last_year());
139
167
chart.set_background(MN_GREY1);
140
for (int i = 0; i<MAX_PLAYER_COST; i++) {
141
chart.add_curve(cost_type_color[i], sp->get_finance_history_year(), MAX_PLAYER_COST, i, 12, (i < COST_ALL_TRANSPORTED) || i==COST_POWERLINES ? MONEY: STANDARD, false, true, (i < COST_ALL_TRANSPORTED) || i==COST_POWERLINES ? 2 : 0 );
168
for (int i = 0; i<MAX_PLAYER_COST_BUTTON; i++) {
169
const int type = cost_type[i];
170
chart.add_curve( cost_type_color[i], sp->get_finance_history_year(), MAX_PLAYER_COST, type, 12, (type < COST_ALL_TRANSPORTED || type==COST_POWERLINES) || type==COST_WAY_TOLLS ? MONEY: STANDARD, false, true, (type < COST_ALL_TRANSPORTED) || type==COST_POWERLINES || type==COST_WAY_TOLLS ? 2 : 0 );
148
177
mchart.set_dimension(MAX_PLAYER_HISTORY_MONTHS, 10000);
149
178
mchart.set_seed(0);
150
179
mchart.set_background(MN_GREY1);
151
for (int i = 0; i<MAX_PLAYER_COST; i++) {
152
mchart.add_curve(cost_type_color[i], sp->get_finance_history_month(), MAX_PLAYER_COST, i, 12, (i < COST_ALL_TRANSPORTED) || i==COST_POWERLINES ? MONEY: STANDARD, false, true, (i < COST_ALL_TRANSPORTED) || i==COST_POWERLINES ? 2 : 0 );
180
for (int i = 0; i<MAX_PLAYER_COST_BUTTON; i++) {
181
const int type = cost_type[i];
182
mchart.add_curve( cost_type_color[i], sp->get_finance_history_month(), MAX_PLAYER_COST, type, 12, (type < COST_ALL_TRANSPORTED || type==COST_POWERLINES) || type==COST_WAY_TOLLS ? MONEY: STANDARD, false, true, (type < COST_ALL_TRANSPORTED) || type==COST_POWERLINES || type==COST_WAY_TOLLS ? 2 : 0 );
154
184
mchart.set_visible(false);
155
185
//CHART MONTH END
174
204
old_vrmoney.set_pos(koord(lyl_x,top+1*BUTTONSPACE));
175
205
mmoney.set_pos(koord(tyl_x,top+2*BUTTONSPACE));
176
206
old_mmoney.set_pos(koord(lyl_x,top+2*BUTTONSPACE));
177
omoney.set_pos(koord(tyl_x,top+3*BUTTONSPACE));
178
old_omoney.set_pos(koord(lyl_x,top+3*BUTTONSPACE));
179
nvmoney.set_pos(koord(tyl_x,top+4*BUTTONSPACE));
180
old_nvmoney.set_pos(koord(lyl_x,top+4*BUTTONSPACE));
181
conmoney.set_pos(koord(tyl_x,top+5*BUTTONSPACE));
182
old_conmoney.set_pos(koord(lyl_x,top+5*BUTTONSPACE));
183
tmoney.set_pos(koord(tyl_x,top+6*BUTTONSPACE));
184
old_tmoney.set_pos(koord(lyl_x,top+6*BUTTONSPACE));
185
powerline.set_pos(koord(tyl_x,top+7*BUTTONSPACE));
186
old_powerline.set_pos(koord(lyl_x,top+7*BUTTONSPACE));
187
transport.set_pos(koord(tyl_x+19, top+8*BUTTONSPACE));
188
old_transport.set_pos(koord(lyl_x+19, top+8*BUTTONSPACE));
207
toll.set_pos(koord(tyl_x,top+3*BUTTONSPACE));
208
old_toll.set_pos(koord(lyl_x,top+3*BUTTONSPACE));
209
powerline.set_pos(koord(tyl_x,top+4*BUTTONSPACE));
210
old_powerline.set_pos(koord(lyl_x,top+4*BUTTONSPACE));
211
omoney.set_pos(koord(tyl_x,top+5*BUTTONSPACE));
212
old_omoney.set_pos(koord(lyl_x,top+5*BUTTONSPACE));
213
nvmoney.set_pos(koord(tyl_x,top+6*BUTTONSPACE));
214
old_nvmoney.set_pos(koord(lyl_x,top+6*BUTTONSPACE));
215
conmoney.set_pos(koord(tyl_x,top+7*BUTTONSPACE));
216
old_conmoney.set_pos(koord(lyl_x,top+7*BUTTONSPACE));
217
tmoney.set_pos(koord(tyl_x,top+8*BUTTONSPACE));
218
old_tmoney.set_pos(koord(lyl_x,top+8*BUTTONSPACE));
219
transport.set_pos(koord(tyl_x+19, top+9*BUTTONSPACE));
220
old_transport.set_pos(koord(lyl_x+19, top+9*BUTTONSPACE));
191
223
maintenance_label.set_pos(koord(left+340+80, top+1*BUTTONSPACE-2));
222
255
add_komponente(&old_imoney);
223
256
add_komponente(&old_tmoney);
224
257
add_komponente(&old_omoney);
258
add_komponente(&old_toll);
225
259
add_komponente(&old_powerline);
226
260
add_komponente(&old_transport);
269
303
// add filter buttons
270
for(int i=0; i<9; i++) {
271
int ibutton=button_order[i];
272
filterButtons[ibutton].init(button_t::box, cost_type[ibutton], koord(left, top+i*BUTTONSPACE-2), koord(120, BUTTONSPACE));
304
for(int ibutton=0; ibutton<10; ibutton++) {
305
filterButtons[ibutton].init(button_t::box, cost_type_name[ibutton], koord(left, top+ibutton*BUTTONSPACE-2), koord(120, BUTTONSPACE));
273
306
filterButtons[ibutton].add_listener(this);
274
307
filterButtons[ibutton].background = cost_type_color[ibutton];
275
308
add_komponente(filterButtons + ibutton);
277
for(int i=9; i<13; i++) {
278
int ibutton=button_order[i];
279
filterButtons[ibutton].init(button_t::box, cost_type[ibutton], koord(left+335, top+(i-4)*BUTTONSPACE-2), koord(120, BUTTONSPACE));
310
for(int ibutton=10; ibutton<MAX_PLAYER_COST_BUTTON; ibutton++) {
311
filterButtons[ibutton].init(button_t::box, cost_type_name[ibutton], koord(left+335, top+(ibutton-5)*BUTTONSPACE-2), koord(120, BUTTONSPACE));
280
312
filterButtons[ibutton].add_listener(this);
281
313
filterButtons[ibutton].background = cost_type_color[ibutton];
282
314
add_komponente(filterButtons + ibutton);
286
for ( int i = 0; i<MAX_PLAYER_COST; i++) {
318
for ( int i = 0; i<MAX_PLAYER_COST_BUTTON; i++) {
287
319
if (bFilterStates[sp->get_player_nr()] & (1<<i)) {
288
320
chart.show_curve(i);
289
321
mchart.show_curve(i);
338
370
old_transport.set_text(str_buf[21]);
339
371
old_transport.set_color(get_money_colour(COST_ALL_TRANSPORTED, 0));
341
//money_to_string(str_buf[22], sp->get_finance_history_year(0, COST_POWERLINES) );
342
powerline.set_text(display_money(COST_POWERLINES, str_buf[22], 0)); //set_text(str_buf[22]);
373
toll.set_text(display_money(COST_WAY_TOLLS, str_buf[24], 0));
374
toll.set_color(get_money_colour(COST_WAY_TOLLS, 0));
375
old_toll.set_text(display_money(COST_WAY_TOLLS, str_buf[25], 1));
376
old_toll.set_color(get_money_colour(COST_WAY_TOLLS, 1));
378
powerline.set_text(display_money(COST_POWERLINES, str_buf[22], 0));
343
379
powerline.set_color(get_money_colour(COST_POWERLINES, 0));
345
//money_to_string(str_buf[23], sp->get_finance_history_year(1, COST_POWERLINES) );
346
380
old_powerline.set_text(display_money(COST_POWERLINES, str_buf[23], 1));
347
381
old_powerline.set_color(get_money_colour(COST_POWERLINES, 1));
440
474
maintenance_money.set_text(str_buf[16]);
441
475
maintenance_money.set_color(sp->get_maintenance()>=0?MONEY_PLUS:MONEY_MINUS);
443
for (int i = 0; i<MAX_PLAYER_COST; i++) {
477
for (int i = 0; i<MAX_PLAYER_COST_BUTTON; i++) {
444
478
filterButtons[i].pressed = ( (bFilterStates[sp->get_player_nr()]&(1<<i)) != 0 );
445
479
// year_month_toggle.pressed = mchart.is_visible();