equal
deleted
inserted
replaced
41 |
41 |
42 /* Apparently these don't play well with enums. */ |
42 /* Apparently these don't play well with enums. */ |
43 static const int64 INVALID_DATAPOINT = INT64_MAX; // Value used for a datapoint that shouldn't be drawn. |
43 static const int64 INVALID_DATAPOINT = INT64_MAX; // Value used for a datapoint that shouldn't be drawn. |
44 static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. |
44 static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn. |
45 |
45 |
46 typedef struct GraphDrawer { |
46 struct GraphDrawer { |
47 uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. |
47 uint excluded_data; ///< bitmask of the datasets that shouldn't be displayed. |
48 byte num_dataset; |
48 byte num_dataset; |
49 byte num_on_x_axis; |
49 byte num_on_x_axis; |
50 bool has_negative_values; |
50 bool has_negative_values; |
51 byte num_vert_lines; |
51 byte num_vert_lines; |
63 int left, top; ///< Where to start drawing the graph, in pixels. |
63 int left, top; ///< Where to start drawing the graph, in pixels. |
64 uint height; ///< The height of the graph in pixels. |
64 uint height; ///< The height of the graph in pixels. |
65 StringID format_str_y_axis; |
65 StringID format_str_y_axis; |
66 byte colors[GRAPH_MAX_DATASETS]; |
66 byte colors[GRAPH_MAX_DATASETS]; |
67 int64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years |
67 int64 cost[GRAPH_MAX_DATASETS][24]; ///< last 2 years |
68 } GraphDrawer; |
68 }; |
69 |
69 |
70 static void DrawGraph(const GraphDrawer *gw) |
70 static void DrawGraph(const GraphDrawer *gw) |
71 { |
71 { |
72 uint x, y; ///< Reused whenever x and y coordinates are needed. |
72 uint x, y; ///< Reused whenever x and y coordinates are needed. |
73 int64 highest_value; ///< Highest value to be drawn. |
73 int64 highest_value; ///< Highest value to be drawn. |
314 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
314 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
315 _graph_legend_widgets, |
315 _graph_legend_widgets, |
316 GraphLegendWndProc |
316 GraphLegendWndProc |
317 }; |
317 }; |
318 |
318 |
319 static void ShowGraphLegend(void) |
319 static void ShowGraphLegend() |
320 { |
320 { |
321 AllocateWindowDescFront(&_graph_legend_desc, 0); |
321 AllocateWindowDescFront(&_graph_legend_desc, 0); |
322 } |
322 } |
323 |
323 |
324 /********************/ |
324 /********************/ |
413 _operating_profit_widgets, |
413 _operating_profit_widgets, |
414 OperatingProfitWndProc |
414 OperatingProfitWndProc |
415 }; |
415 }; |
416 |
416 |
417 |
417 |
418 void ShowOperatingProfitGraph(void) |
418 void ShowOperatingProfitGraph() |
419 { |
419 { |
420 if (AllocateWindowDescFront(&_operating_profit_desc, 0)) { |
420 if (AllocateWindowDescFront(&_operating_profit_desc, 0)) { |
421 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
421 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
422 } |
422 } |
423 } |
423 } |
481 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
481 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
482 _income_graph_widgets, |
482 _income_graph_widgets, |
483 IncomeGraphWndProc |
483 IncomeGraphWndProc |
484 }; |
484 }; |
485 |
485 |
486 void ShowIncomeGraph(void) |
486 void ShowIncomeGraph() |
487 { |
487 { |
488 if (AllocateWindowDescFront(&_income_graph_desc, 0)) { |
488 if (AllocateWindowDescFront(&_income_graph_desc, 0)) { |
489 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
489 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
490 } |
490 } |
491 } |
491 } |
548 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
548 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
549 _delivered_cargo_graph_widgets, |
549 _delivered_cargo_graph_widgets, |
550 DeliveredCargoGraphWndProc |
550 DeliveredCargoGraphWndProc |
551 }; |
551 }; |
552 |
552 |
553 void ShowDeliveredCargoGraph(void) |
553 void ShowDeliveredCargoGraph() |
554 { |
554 { |
555 if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) { |
555 if (AllocateWindowDescFront(&_delivered_cargo_graph_desc, 0)) { |
556 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
556 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
557 } |
557 } |
558 } |
558 } |
617 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
617 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
618 _performance_history_widgets, |
618 _performance_history_widgets, |
619 PerformanceHistoryWndProc |
619 PerformanceHistoryWndProc |
620 }; |
620 }; |
621 |
621 |
622 void ShowPerformanceHistoryGraph(void) |
622 void ShowPerformanceHistoryGraph() |
623 { |
623 { |
624 if (AllocateWindowDescFront(&_performance_history_desc, 0)) { |
624 if (AllocateWindowDescFront(&_performance_history_desc, 0)) { |
625 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
625 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
626 } |
626 } |
627 } |
627 } |
684 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
684 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_UNCLICK_BUTTONS, |
685 _company_value_graph_widgets, |
685 _company_value_graph_widgets, |
686 CompanyValueGraphWndProc |
686 CompanyValueGraphWndProc |
687 }; |
687 }; |
688 |
688 |
689 void ShowCompanyValueGraph(void) |
689 void ShowCompanyValueGraph() |
690 { |
690 { |
691 if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) { |
691 if (AllocateWindowDescFront(&_company_value_graph_desc, 0)) { |
692 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
692 InvalidateWindow(WC_GRAPH_LEGEND, 0); |
693 } |
693 } |
694 } |
694 } |
782 _cargo_payment_rates_widgets, |
782 _cargo_payment_rates_widgets, |
783 CargoPaymentRatesWndProc |
783 CargoPaymentRatesWndProc |
784 }; |
784 }; |
785 |
785 |
786 |
786 |
787 void ShowCargoPaymentRates(void) |
787 void ShowCargoPaymentRates() |
788 { |
788 { |
789 Window *w = AllocateWindowDescFront(&_cargo_payment_rates_desc, 0); |
789 Window *w = AllocateWindowDescFront(&_cargo_payment_rates_desc, 0); |
790 if (w == NULL) return; |
790 if (w == NULL) return; |
791 |
791 |
792 /* Count the number of active cargo types */ |
792 /* Count the number of active cargo types */ |
797 |
797 |
798 /* Resize the window to fit the cargo types */ |
798 /* Resize the window to fit the cargo types */ |
799 ResizeWindow(w, 0, num_active * 8); |
799 ResizeWindow(w, 0, num_active * 8); |
800 |
800 |
801 /* Add widgets for each cargo type */ |
801 /* Add widgets for each cargo type */ |
802 w->widget_count = 3 + num_active; |
802 w->widget_count += num_active; |
803 w->widget = ReallocT(w->widget, w->widget_count); |
803 w->widget = ReallocT(w->widget, w->widget_count + 1); |
|
804 w->widget[w->widget_count].type = WWT_LAST; |
804 |
805 |
805 /* Set the properties of each widget */ |
806 /* Set the properties of each widget */ |
806 for (uint i = 0; i != num_active; i++) { |
807 for (uint i = 0; i != num_active; i++) { |
807 Widget *wi = &w->widget[3 + i]; |
808 Widget *wi = &w->widget[3 + i]; |
808 wi->type = WWT_PANEL; |
809 wi->type = WWT_PANEL; |
903 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
904 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET | WDF_STICKY_BUTTON, |
904 _company_league_widgets, |
905 _company_league_widgets, |
905 CompanyLeagueWndProc |
906 CompanyLeagueWndProc |
906 }; |
907 }; |
907 |
908 |
908 void ShowCompanyLeagueTable(void) |
909 void ShowCompanyLeagueTable() |
909 { |
910 { |
910 AllocateWindowDescFront(&_company_league_desc,0); |
911 AllocateWindowDescFront(&_company_league_desc,0); |
911 } |
912 } |
912 |
913 |
913 /*****************************/ |
914 /*****************************/ |
1142 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1143 WDF_STD_TOOLTIPS | WDF_STD_BTN | WDF_DEF_WIDGET, |
1143 _performance_rating_detail_widgets, |
1144 _performance_rating_detail_widgets, |
1144 PerformanceRatingDetailWndProc |
1145 PerformanceRatingDetailWndProc |
1145 }; |
1146 }; |
1146 |
1147 |
1147 void ShowPerformanceRatingDetail(void) |
1148 void ShowPerformanceRatingDetail() |
1148 { |
1149 { |
1149 AllocateWindowDescFront(&_performance_rating_detail_desc, 0); |
1150 AllocateWindowDescFront(&_performance_rating_detail_desc, 0); |
1150 } |
1151 } |