~ubuntu-branches/ubuntu/raring/simutrans/raring-proposed

« back to all changes in this revision

Viewing changes to gui/money_frame.cc

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2011-11-03 19:59:02 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20111103195902-uopgwf488mfctb75
Tags: 111.0-1
* New upstream release.
* debian/rules: Update get-orig-source target for new upstream release.
* Use xz compression for source and binary packages.
* Use override_* targets to simplify debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
#define BUTTONSPACE 14
36
36
 
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] =
39
39
{
40
 
  "Construction_Btn", "Operation", "New Vehicles", "Revenue",
41
 
  "Maintenance", "Assets", "Cash", "Net Wealth", "Gross Profit", "Ops Profit", "Margin (%)", "Transported", "Powerlines"
 
40
        "Revenue",
 
41
        "Operation",
 
42
        "Maintenance",
 
43
        "Road toll",
 
44
        "Powerlines",
 
45
        "Ops Profit",
 
46
        "New Vehicles",
 
47
        "Construction_Btn",
 
48
        "Gross Profit",
 
49
        "Transported",
 
50
        "Cash",
 
51
        "Assets",
 
52
        "Margin (%)",
 
53
        "Net Wealth"
42
54
};
43
55
 
44
 
const int money_frame_t::cost_type_color[MAX_PLAYER_COST] =
 
56
 
 
57
const COLOR_VAL money_frame_t::cost_type_color[MAX_PLAYER_COST_BUTTON] =
45
58
{
46
 
        COL_CONSTRUCTION,
 
59
        COL_REVENUE,
47
60
        COL_OPERATION,
 
61
        COL_MAINTENANCE,
 
62
        COL_TOLL,
 
63
        COL_POWERLINES,
 
64
        COL_OPS_PROFIT,
48
65
        COL_NEW_VEHICLES,
49
 
        COL_REVENUE,
50
 
        COL_MAINTENANCE,
 
66
        COL_CONSTRUCTION,
 
67
        COL_PROFIT,
 
68
        COL_TRANSPORTED,
 
69
        COL_CASH,
51
70
        COL_VEHICLE_ASSETS,
52
 
        COL_CASH,
53
 
        COL_WEALTH,
54
 
        COL_PROFIT,
55
 
        COL_OPS_PROFIT,
56
71
        COL_MARGIN,
57
 
        COL_TRANSPORTED,
58
 
        COL_POWERLINES
 
72
        COL_WEALTH
59
73
};
60
74
 
61
 
const uint8 button_order[MAX_PLAYER_COST] =
 
75
const uint8 money_frame_t::cost_type[MAX_PLAYER_COST_BUTTON] =
62
76
{
63
 
        3, 1, 4, 9, 2, 0, 8, 12, 11,
64
 
        6, 5, 10, 7
 
77
        COST_INCOME,        // Income
 
78
        COST_VEHICLE_RUN,   // Vehicle running costs
 
79
        COST_MAINTENANCE,   // Upkeep
 
80
        COST_WAY_TOLLS,
 
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
 
87
        COST_CASH,          // Cash
 
88
        COST_ASSETS,        // value of all vehicles and buildings
 
89
        COST_MARGIN,        // COST_OPERATING_PROFIT/COST_INCOME
 
90
        COST_NETWEALTH,     // Total Cash + Assets
65
91
};
66
92
 
67
93
 
89
115
 
90
116
 
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 );
142
171
        }
143
172
        //CHART YEAR END
144
173
 
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 );
153
183
        }
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));
189
221
 
190
222
        // right column
191
223
        maintenance_label.set_pos(koord(left+340+80, top+1*BUTTONSPACE-2));
212
244
        add_komponente(&imoney);
213
245
        add_komponente(&tmoney);
214
246
        add_komponente(&omoney);
 
247
        add_komponente(&toll);
215
248
        add_komponente(&powerline);
216
249
        add_komponente(&transport);
217
250
 
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);
227
261
 
267
301
        }
268
302
 
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);
276
309
        }
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);
283
315
        }
284
316
 
285
317
        // states ...
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);
307
339
void money_frame_t::zeichnen(koord pos, koord gr)
308
340
{
309
341
        // Hajo: each label needs its own buffer
310
 
        static char str_buf[24][256];
 
342
        static char str_buf[26][64];
311
343
 
312
344
        sp->calc_finance_history();
313
345
 
338
370
        old_transport.set_text(str_buf[21]);
339
371
        old_transport.set_color(get_money_colour(COST_ALL_TRANSPORTED, 0));
340
372
 
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));
 
377
 
 
378
        powerline.set_text(display_money(COST_POWERLINES, str_buf[22], 0));
343
379
        powerline.set_color(get_money_colour(COST_POWERLINES, 0));
344
 
 
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));
348
382
 
440
474
        maintenance_money.set_text(str_buf[16]);
441
475
        maintenance_money.set_color(sp->get_maintenance()>=0?MONEY_PLUS:MONEY_MINUS);
442
476
 
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();
446
480
        }
460
494
                return true;
461
495
        }
462
496
 
463
 
        for ( int i = 0; i<MAX_PLAYER_COST; i++) {
 
497
        for ( int i = 0; i<MAX_PLAYER_COST_BUTTON; i++) {
464
498
                if (komp == &filterButtons[i]) {
465
499
                        bFilterStates[sp->get_player_nr()] ^= (1<<i);
466
500
                        if (bFilterStates[sp->get_player_nr()] & (1<<i)) {
495
529
 
496
530
        if(  file->is_loading()  ) {
497
531
                // states ...
498
 
                for( uint32 i = 0; i<MAX_PLAYER_COST; i++) {
 
532
                for( uint32 i = 0; i<MAX_PLAYER_COST_BUTTON; i++) {
499
533
                        if (bFilterStates[sp->get_player_nr()] & (1<<i)) {
500
534
                                chart.show_curve(i);
501
535
                                mchart.show_curve(i);