OpenTTD Source  1.11.0-beta1
graph_gui.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of OpenTTD.
3  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6  */
7 
10 #include "stdafx.h"
11 #include "graph_gui.h"
12 #include "window_gui.h"
13 #include "company_base.h"
14 #include "company_gui.h"
15 #include "economy_func.h"
16 #include "cargotype.h"
17 #include "strings_func.h"
18 #include "window_func.h"
19 #include "date_func.h"
20 #include "gfx_func.h"
21 #include "sortlist_type.h"
22 #include "core/geometry_func.hpp"
23 #include "currency.h"
24 
25 #include "widgets/graph_widget.h"
26 
27 #include "table/strings.h"
28 #include "table/sprites.h"
29 #include <math.h>
30 
31 #include "safeguards.h"
32 
33 /* Bitmasks of company and cargo indices that shouldn't be drawn. */
34 static CompanyMask _legend_excluded_companies;
35 static CargoTypes _legend_excluded_cargo;
36 
37 /* Apparently these don't play well with enums. */
38 static const OverflowSafeInt64 INVALID_DATAPOINT(INT64_MAX); // Value used for a datapoint that shouldn't be drawn.
39 static const uint INVALID_DATAPOINT_POS = UINT_MAX; // Used to determine if the previous point was drawn.
40 
41 /****************/
42 /* GRAPH LEGEND */
43 /****************/
44 
47  {
48  this->InitNested(window_number);
49 
50  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
51  if (!HasBit(_legend_excluded_companies, c)) this->LowerWidget(c + WID_GL_FIRST_COMPANY);
52 
53  this->OnInvalidateData(c);
54  }
55  }
56 
57  void DrawWidget(const Rect &r, int widget) const override
58  {
60 
61  CompanyID cid = (CompanyID)(widget - WID_GL_FIRST_COMPANY);
62 
63  if (!Company::IsValidID(cid)) return;
64 
65  bool rtl = _current_text_dir == TD_RTL;
66 
67  Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
68  DrawCompanyIcon(cid, rtl ? r.right - d.width - 2 : r.left + 2, r.top + (r.bottom - r.top - d.height) / 2);
69 
70  SetDParam(0, cid);
71  SetDParam(1, cid);
72  DrawString(r.left + (rtl ? (uint)WD_FRAMERECT_LEFT : (d.width + 4)), r.right - (rtl ? (d.width + 4) : (uint)WD_FRAMERECT_RIGHT), r.top + (r.bottom - r.top + 1 - FONT_HEIGHT_NORMAL) / 2, STR_COMPANY_NAME_COMPANY_NUM, HasBit(_legend_excluded_companies, cid) ? TC_BLACK : TC_WHITE);
73  }
74 
75  void OnClick(Point pt, int widget, int click_count) override
76  {
78 
79  ToggleBit(_legend_excluded_companies, widget - WID_GL_FIRST_COMPANY);
80  this->ToggleWidgetLoweredState(widget);
81  this->SetDirty();
87  }
88 
94  void OnInvalidateData(int data = 0, bool gui_scope = true) override
95  {
96  if (!gui_scope) return;
97  if (Company::IsValidID(data)) return;
98 
99  SetBit(_legend_excluded_companies, data);
100  this->RaiseWidget(data + WID_GL_FIRST_COMPANY);
101  }
102 };
103 
110 static NWidgetBase *MakeNWidgetCompanyLines(int *biggest_index)
111 {
112  NWidgetVertical *vert = new NWidgetVertical();
113  uint line_height = std::max<uint>(GetSpriteSize(SPR_COMPANY_ICON).height, FONT_HEIGHT_NORMAL) + WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM;
114 
115  for (int widnum = WID_GL_FIRST_COMPANY; widnum <= WID_GL_LAST_COMPANY; widnum++) {
116  NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
117  panel->SetMinimalSize(246, line_height);
118  panel->SetFill(1, 0);
119  panel->SetDataTip(0x0, STR_GRAPH_KEY_COMPANY_SELECTION_TOOLTIP);
120  vert->Add(panel);
121  }
122  *biggest_index = WID_GL_LAST_COMPANY;
123  return vert;
124 }
125 
126 static const NWidgetPart _nested_graph_legend_widgets[] = {
128  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
129  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_KEY_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
130  NWidget(WWT_SHADEBOX, COLOUR_GREY),
131  NWidget(WWT_STICKYBOX, COLOUR_GREY),
132  EndContainer(),
133  NWidget(WWT_PANEL, COLOUR_GREY, WID_GL_BACKGROUND),
139  EndContainer(),
140  EndContainer(),
141 };
142 
143 static WindowDesc _graph_legend_desc(
144  WDP_AUTO, "graph_legend", 0, 0,
146  0,
147  _nested_graph_legend_widgets, lengthof(_nested_graph_legend_widgets)
148 );
149 
150 static void ShowGraphLegend()
151 {
152  AllocateWindowDescFront<GraphLegendWindow>(&_graph_legend_desc, 0);
153 }
154 
159 };
160 
161 /******************/
162 /* BASE OF GRAPHS */
163 /*****************/
164 
166 protected:
167  static const int GRAPH_MAX_DATASETS = 64;
168  static const int GRAPH_AXIS_LINE_COLOUR = PC_BLACK;
169  static const int GRAPH_NUM_MONTHS = 24;
170 
171  static const int MIN_GRAPH_NUM_LINES_Y = 9;
172  static const int MIN_GRID_PIXEL_SIZE = 20;
173 
174  uint64 excluded_data;
175  byte num_dataset;
176  byte num_on_x_axis;
177  byte num_vert_lines;
178  static const TextColour graph_axis_label_colour = TC_BLACK;
179 
180  /* The starting month and year that values are plotted against. If month is
181  * 0xFF, use x_values_start and x_values_increment below instead. */
182  byte month;
183  Year year;
184 
185  /* These values are used if the graph is being plotted against values
186  * rather than the dates specified by month and year. */
187  uint16 x_values_start;
188  uint16 x_values_increment;
189 
190  int graph_widget;
191  StringID format_str_y_axis;
192  byte colours[GRAPH_MAX_DATASETS];
193  OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS];
194 
201  ValuesInterval GetValuesInterval(int num_hori_lines) const
202  {
203  assert(num_hori_lines > 0);
204 
205  ValuesInterval current_interval;
206  current_interval.highest = INT64_MIN;
207  current_interval.lowest = INT64_MAX;
208 
209  for (int i = 0; i < this->num_dataset; i++) {
210  if (HasBit(this->excluded_data, i)) continue;
211  for (int j = 0; j < this->num_on_x_axis; j++) {
212  OverflowSafeInt64 datapoint = this->cost[i][j];
213 
214  if (datapoint != INVALID_DATAPOINT) {
215  current_interval.highest = std::max(current_interval.highest, datapoint);
216  current_interval.lowest = std::min(current_interval.lowest, datapoint);
217  }
218  }
219  }
220 
221  /* Prevent showing values too close to the graph limits. */
222  current_interval.highest = (11 * current_interval.highest) / 10;
223  current_interval.lowest = (11 * current_interval.lowest) / 10;
224 
225  /* Always include zero in the shown range. */
226  double abs_lower = (current_interval.lowest > 0) ? 0 : (double)abs(current_interval.lowest);
227  double abs_higher = (current_interval.highest < 0) ? 0 : (double)current_interval.highest;
228 
229  int num_pos_grids;
230  int64 grid_size;
231 
232  if (abs_lower != 0 || abs_higher != 0) {
233  /* The number of grids to reserve for the positive part is: */
234  num_pos_grids = (int)floor(0.5 + num_hori_lines * abs_higher / (abs_higher + abs_lower));
235 
236  /* If there are any positive or negative values, force that they have at least one grid. */
237  if (num_pos_grids == 0 && abs_higher != 0) num_pos_grids++;
238  if (num_pos_grids == num_hori_lines && abs_lower != 0) num_pos_grids--;
239 
240  /* Get the required grid size for each side and use the maximum one. */
241  int64 grid_size_higher = (abs_higher > 0) ? ((int64)abs_higher + num_pos_grids - 1) / num_pos_grids : 0;
242  int64 grid_size_lower = (abs_lower > 0) ? ((int64)abs_lower + num_hori_lines - num_pos_grids - 1) / (num_hori_lines - num_pos_grids) : 0;
243  grid_size = std::max(grid_size_higher, grid_size_lower);
244  } else {
245  /* If both values are zero, show an empty graph. */
246  num_pos_grids = num_hori_lines / 2;
247  grid_size = 1;
248  }
249 
250  current_interval.highest = num_pos_grids * grid_size;
251  current_interval.lowest = -(num_hori_lines - num_pos_grids) * grid_size;
252  return current_interval;
253  }
254 
260  uint GetYLabelWidth(ValuesInterval current_interval, int num_hori_lines) const
261  {
262  /* draw text strings on the y axis */
263  int64 y_label = current_interval.highest;
264  int64 y_label_separation = (current_interval.highest - current_interval.lowest) / num_hori_lines;
265 
266  uint max_width = 0;
267 
268  for (int i = 0; i < (num_hori_lines + 1); i++) {
269  SetDParam(0, this->format_str_y_axis);
270  SetDParam(1, y_label);
271  Dimension d = GetStringBoundingBox(STR_GRAPH_Y_LABEL);
272  if (d.width > max_width) max_width = d.width;
273 
274  y_label -= y_label_separation;
275  }
276 
277  return max_width;
278  }
279 
284  void DrawGraph(Rect r) const
285  {
286  uint x, y;
287  ValuesInterval interval;
288  int x_axis_offset;
289 
290  /* the colours and cost array of GraphDrawer must accommodate
291  * both values for cargo and companies. So if any are higher, quit */
292  static_assert(GRAPH_MAX_DATASETS >= (int)NUM_CARGO && GRAPH_MAX_DATASETS >= (int)MAX_COMPANIES);
293  assert(this->num_vert_lines > 0);
294 
295  byte grid_colour = _colour_gradient[COLOUR_GREY][4];
296 
297  /* Rect r will be adjusted to contain just the graph, with labels being
298  * placed outside the area. */
299  r.top += 5 + GetCharacterHeight(FS_SMALL) / 2;
300  r.bottom -= (this->month == 0xFF ? 1 : 3) * GetCharacterHeight(FS_SMALL) + 4;
301  r.left += 9;
302  r.right -= 5;
303 
304  /* Initial number of horizontal lines. */
305  int num_hori_lines = 160 / MIN_GRID_PIXEL_SIZE;
306  /* For the rest of the height, the number of horizontal lines will increase more slowly. */
307  int resize = (r.bottom - r.top - 160) / (2 * MIN_GRID_PIXEL_SIZE);
308  if (resize > 0) num_hori_lines += resize;
309 
310  interval = GetValuesInterval(num_hori_lines);
311 
312  int label_width = GetYLabelWidth(interval, num_hori_lines);
313 
314  r.left += label_width;
315 
316  int x_sep = (r.right - r.left) / this->num_vert_lines;
317  int y_sep = (r.bottom - r.top) / num_hori_lines;
318 
319  /* Redetermine right and bottom edge of graph to fit with the integer
320  * separation values. */
321  r.right = r.left + x_sep * this->num_vert_lines;
322  r.bottom = r.top + y_sep * num_hori_lines;
323 
324  OverflowSafeInt64 interval_size = interval.highest + abs(interval.lowest);
325  /* Where to draw the X axis. Use floating point to avoid overflowing and results of zero. */
326  x_axis_offset = (int)((r.bottom - r.top) * (double)interval.highest / (double)interval_size);
327 
328  /* Draw the background of the graph itself. */
329  GfxFillRect(r.left, r.top, r.right, r.bottom, GREY_SCALE(2));
330 
331  /* Draw the vertical grid lines. */
332 
333  /* Don't draw the first line, as that's where the axis will be. */
334  x = r.left + x_sep;
335 
336  for (int i = 0; i < this->num_vert_lines; i++) {
337  GfxFillRect(x, r.top, x, r.bottom, grid_colour);
338  x += x_sep;
339  }
340 
341  /* Draw the horizontal grid lines. */
342  y = r.bottom;
343 
344  for (int i = 0; i < (num_hori_lines + 1); i++) {
345  GfxFillRect(r.left - 3, y, r.left - 1, y, GRAPH_AXIS_LINE_COLOUR);
346  GfxFillRect(r.left, y, r.right, y, grid_colour);
347  y -= y_sep;
348  }
349 
350  /* Draw the y axis. */
351  GfxFillRect(r.left, r.top, r.left, r.bottom, GRAPH_AXIS_LINE_COLOUR);
352 
353  /* Draw the x axis. */
354  y = x_axis_offset + r.top;
355  GfxFillRect(r.left, y, r.right, y, GRAPH_AXIS_LINE_COLOUR);
356 
357  /* Find the largest value that will be drawn. */
358  if (this->num_on_x_axis == 0) return;
359 
360  assert(this->num_on_x_axis > 0);
361  assert(this->num_dataset > 0);
362 
363  /* draw text strings on the y axis */
364  int64 y_label = interval.highest;
365  int64 y_label_separation = abs(interval.highest - interval.lowest) / num_hori_lines;
366 
367  y = r.top - GetCharacterHeight(FS_SMALL) / 2;
368 
369  for (int i = 0; i < (num_hori_lines + 1); i++) {
370  SetDParam(0, this->format_str_y_axis);
371  SetDParam(1, y_label);
372  DrawString(r.left - label_width - 4, r.left - 4, y, STR_GRAPH_Y_LABEL, graph_axis_label_colour, SA_RIGHT);
373 
374  y_label -= y_label_separation;
375  y += y_sep;
376  }
377 
378  /* draw strings on the x axis */
379  if (this->month != 0xFF) {
380  x = r.left;
381  y = r.bottom + 2;
382  byte month = this->month;
383  Year year = this->year;
384  for (int i = 0; i < this->num_on_x_axis; i++) {
385  SetDParam(0, month + STR_MONTH_ABBREV_JAN);
386  SetDParam(1, month + STR_MONTH_ABBREV_JAN + 2);
387  SetDParam(2, year);
388  DrawStringMultiLine(x, x + x_sep, y, this->height, month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH, graph_axis_label_colour);
389 
390  month += 3;
391  if (month >= 12) {
392  month = 0;
393  year++;
394  }
395  x += x_sep;
396  }
397  } else {
398  /* Draw the label under the data point rather than on the grid line. */
399  x = r.left;
400  y = r.bottom + 2;
401  uint16 label = this->x_values_start;
402 
403  for (int i = 0; i < this->num_on_x_axis; i++) {
404  SetDParam(0, label);
405  DrawString(x + 1, x + x_sep - 1, y, STR_GRAPH_Y_LABEL_NUMBER, graph_axis_label_colour, SA_HOR_CENTER);
406 
407  label += this->x_values_increment;
408  x += x_sep;
409  }
410  }
411 
412  /* draw lines and dots */
413  uint linewidth = _settings_client.gui.graph_line_thickness;
414  uint pointoffs1 = (linewidth + 1) / 2;
415  uint pointoffs2 = linewidth + 1 - pointoffs1;
416  for (int i = 0; i < this->num_dataset; i++) {
417  if (!HasBit(this->excluded_data, i)) {
418  /* Centre the dot between the grid lines. */
419  x = r.left + (x_sep / 2);
420 
421  byte colour = this->colours[i];
422  uint prev_x = INVALID_DATAPOINT_POS;
423  uint prev_y = INVALID_DATAPOINT_POS;
424 
425  for (int j = 0; j < this->num_on_x_axis; j++) {
426  OverflowSafeInt64 datapoint = this->cost[i][j];
427 
428  if (datapoint != INVALID_DATAPOINT) {
429  /*
430  * Check whether we need to reduce the 'accuracy' of the
431  * datapoint value and the highest value to split overflows.
432  * And when 'drawing' 'one million' or 'one million and one'
433  * there is no significant difference, so the least
434  * significant bits can just be removed.
435  *
436  * If there are more bits needed than would fit in a 32 bits
437  * integer, so at about 31 bits because of the sign bit, the
438  * least significant bits are removed.
439  */
440  int mult_range = FindLastBit(x_axis_offset) + FindLastBit(abs(datapoint));
441  int reduce_range = std::max(mult_range - 31, 0);
442 
443  /* Handle negative values differently (don't shift sign) */
444  if (datapoint < 0) {
445  datapoint = -(abs(datapoint) >> reduce_range);
446  } else {
447  datapoint >>= reduce_range;
448  }
449  y = r.top + x_axis_offset - ((r.bottom - r.top) * datapoint) / (interval_size >> reduce_range);
450 
451  /* Draw the point. */
452  GfxFillRect(x - pointoffs1, y - pointoffs1, x + pointoffs2, y + pointoffs2, colour);
453 
454  /* Draw the line connected to the previous point. */
455  if (prev_x != INVALID_DATAPOINT_POS) GfxDrawLine(prev_x, prev_y, x, y, colour, linewidth);
456 
457  prev_x = x;
458  prev_y = y;
459  } else {
460  prev_x = INVALID_DATAPOINT_POS;
461  prev_y = INVALID_DATAPOINT_POS;
462  }
463 
464  x += x_sep;
465  }
466  }
467  }
468  }
469 
470 
471  BaseGraphWindow(WindowDesc *desc, int widget, StringID format_str_y_axis) :
472  Window(desc),
473  format_str_y_axis(format_str_y_axis)
474  {
476  this->num_vert_lines = 24;
477  this->graph_widget = widget;
478  }
479 
480  void InitializeWindow(WindowNumber number)
481  {
482  /* Initialise the dataset */
483  this->UpdateStatistics(true);
484 
485  this->InitNested(number);
486  }
487 
488 public:
489  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
490  {
491  if (widget != this->graph_widget) return;
492 
493  uint x_label_width = 0;
494 
495  if (this->month != 0xFF) {
496  byte month = this->month;
497  Year year = this->year;
498  for (int i = 0; i < this->num_on_x_axis; i++) {
499  SetDParam(0, month + STR_MONTH_ABBREV_JAN);
500  SetDParam(1, month + STR_MONTH_ABBREV_JAN + 2);
501  SetDParam(2, year);
502  x_label_width = std::max(x_label_width, GetStringBoundingBox(month == 0 ? STR_GRAPH_X_LABEL_MONTH_YEAR : STR_GRAPH_X_LABEL_MONTH).width);
503 
504  month += 3;
505  if (month >= 12) {
506  month = 0;
507  year++;
508  }
509  }
510  } else {
511  /* Draw the label under the data point rather than on the grid line. */
512  SetDParamMaxValue(0, this->x_values_start + this->num_on_x_axis * this->x_values_increment, 0, FS_SMALL);
513  x_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL_NUMBER).width;
514  }
515 
516  SetDParam(0, this->format_str_y_axis);
517  SetDParam(1, INT64_MAX);
518  uint y_label_width = GetStringBoundingBox(STR_GRAPH_Y_LABEL).width;
519 
520  size->width = std::max<uint>(size->width, 5 + y_label_width + this->num_on_x_axis * (x_label_width + 5) + 9);
521  size->height = std::max<uint>(size->height, 5 + (1 + MIN_GRAPH_NUM_LINES_Y * 2 + (this->month != 0xFF ? 3 : 1)) * FONT_HEIGHT_SMALL + 4);
522  size->height = std::max<uint>(size->height, size->width / 3);
523  }
524 
525  void DrawWidget(const Rect &r, int widget) const override
526  {
527  if (widget != this->graph_widget) return;
528 
529  DrawGraph(r);
530  }
531 
532  virtual OverflowSafeInt64 GetGraphData(const Company *c, int j)
533  {
534  return INVALID_DATAPOINT;
535  }
536 
537  void OnClick(Point pt, int widget, int click_count) override
538  {
539  /* Clicked on legend? */
540  if (widget == WID_CV_KEY_BUTTON) ShowGraphLegend();
541  }
542 
543  void OnGameTick() override
544  {
545  this->UpdateStatistics(false);
546  }
547 
553  void OnInvalidateData(int data = 0, bool gui_scope = true) override
554  {
555  if (!gui_scope) return;
556  this->UpdateStatistics(true);
557  }
558 
563  void UpdateStatistics(bool initialize)
564  {
565  CompanyMask excluded_companies = _legend_excluded_companies;
566 
567  /* Exclude the companies which aren't valid */
568  for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
569  if (!Company::IsValidID(c)) SetBit(excluded_companies, c);
570  }
571 
572  byte nums = 0;
573  for (const Company *c : Company::Iterate()) {
574  nums = std::min(this->num_vert_lines, std::max(nums, c->num_valid_stat_ent));
575  }
576 
577  int mo = (_cur_month / 3 - nums) * 3;
578  int yr = _cur_year;
579  while (mo < 0) {
580  yr--;
581  mo += 12;
582  }
583 
584  if (!initialize && this->excluded_data == excluded_companies && this->num_on_x_axis == nums &&
585  this->year == yr && this->month == mo) {
586  /* There's no reason to get new stats */
587  return;
588  }
589 
590  this->excluded_data = excluded_companies;
591  this->num_on_x_axis = nums;
592  this->year = yr;
593  this->month = mo;
594 
595  int numd = 0;
596  for (CompanyID k = COMPANY_FIRST; k < MAX_COMPANIES; k++) {
597  const Company *c = Company::GetIfValid(k);
598  if (c != nullptr) {
599  this->colours[numd] = _colour_gradient[c->colour][6];
600  for (int j = this->num_on_x_axis, i = 0; --j >= 0;) {
601  this->cost[numd][i] = (j >= c->num_valid_stat_ent) ? INVALID_DATAPOINT : GetGraphData(c, j);
602  i++;
603  }
604  }
605  numd++;
606  }
607 
608  this->num_dataset = numd;
609  }
610 };
611 
612 
613 /********************/
614 /* OPERATING PROFIT */
615 /********************/
616 
619  BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
620  {
621  this->InitializeWindow(window_number);
622  }
623 
624  OverflowSafeInt64 GetGraphData(const Company *c, int j) override
625  {
626  return c->old_economy[j].income + c->old_economy[j].expenses;
627  }
628 };
629 
630 static const NWidgetPart _nested_operating_profit_widgets[] = {
632  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
633  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_OPERATING_PROFIT_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
634  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
635  NWidget(WWT_SHADEBOX, COLOUR_GREY),
636  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
637  NWidget(WWT_STICKYBOX, COLOUR_GREY),
638  EndContainer(),
639  NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
641  NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 160), SetFill(1, 1), SetResize(1, 1),
643  NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
644  NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
645  EndContainer(),
646  EndContainer(),
647  EndContainer(),
648 };
649 
650 static WindowDesc _operating_profit_desc(
651  WDP_AUTO, "graph_operating_profit", 0, 0,
653  0,
654  _nested_operating_profit_widgets, lengthof(_nested_operating_profit_widgets)
655 );
656 
657 
658 void ShowOperatingProfitGraph()
659 {
660  AllocateWindowDescFront<OperatingProfitGraphWindow>(&_operating_profit_desc, 0);
661 }
662 
663 
664 /****************/
665 /* INCOME GRAPH */
666 /****************/
667 
670  BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
671  {
672  this->InitializeWindow(window_number);
673  }
674 
675  OverflowSafeInt64 GetGraphData(const Company *c, int j) override
676  {
677  return c->old_economy[j].income;
678  }
679 };
680 
681 static const NWidgetPart _nested_income_graph_widgets[] = {
683  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
684  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_INCOME_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
685  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
686  NWidget(WWT_SHADEBOX, COLOUR_GREY),
687  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
688  NWidget(WWT_STICKYBOX, COLOUR_GREY),
689  EndContainer(),
690  NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
692  NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
694  NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
695  NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
696  EndContainer(),
697  EndContainer(),
698  EndContainer(),
699 };
700 
701 static WindowDesc _income_graph_desc(
702  WDP_AUTO, "graph_income", 0, 0,
704  0,
705  _nested_income_graph_widgets, lengthof(_nested_income_graph_widgets)
706 );
707 
708 void ShowIncomeGraph()
709 {
710  AllocateWindowDescFront<IncomeGraphWindow>(&_income_graph_desc, 0);
711 }
712 
713 /*******************/
714 /* DELIVERED CARGO */
715 /*******************/
716 
719  BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_COMMA)
720  {
721  this->InitializeWindow(window_number);
722  }
723 
724  OverflowSafeInt64 GetGraphData(const Company *c, int j) override
725  {
727  }
728 };
729 
730 static const NWidgetPart _nested_delivered_cargo_graph_widgets[] = {
732  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
733  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_CARGO_DELIVERED_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
734  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
735  NWidget(WWT_SHADEBOX, COLOUR_GREY),
736  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
737  NWidget(WWT_STICKYBOX, COLOUR_GREY),
738  EndContainer(),
739  NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
741  NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 128), SetFill(1, 1), SetResize(1, 1),
743  NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
744  NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
745  EndContainer(),
746  EndContainer(),
747  EndContainer(),
748 };
749 
750 static WindowDesc _delivered_cargo_graph_desc(
751  WDP_AUTO, "graph_delivered_cargo", 0, 0,
753  0,
754  _nested_delivered_cargo_graph_widgets, lengthof(_nested_delivered_cargo_graph_widgets)
755 );
756 
757 void ShowDeliveredCargoGraph()
758 {
759  AllocateWindowDescFront<DeliveredCargoGraphWindow>(&_delivered_cargo_graph_desc, 0);
760 }
761 
762 /***********************/
763 /* PERFORMANCE HISTORY */
764 /***********************/
765 
768  BaseGraphWindow(desc, WID_PHG_GRAPH, STR_JUST_COMMA)
769  {
770  this->InitializeWindow(window_number);
771  }
772 
773  OverflowSafeInt64 GetGraphData(const Company *c, int j) override
774  {
775  return c->old_economy[j].performance_history;
776  }
777 
778  void OnClick(Point pt, int widget, int click_count) override
779  {
780  if (widget == WID_PHG_DETAILED_PERFORMANCE) ShowPerformanceRatingDetail();
781  this->BaseGraphWindow::OnClick(pt, widget, click_count);
782  }
783 };
784 
785 static const NWidgetPart _nested_performance_history_widgets[] = {
787  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
788  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_COMPANY_PERFORMANCE_RATINGS_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
789  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PHG_DETAILED_PERFORMANCE), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_PERFORMANCE_DETAIL_KEY, STR_GRAPH_PERFORMANCE_DETAIL_TOOLTIP),
790  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_PHG_KEY), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
791  NWidget(WWT_SHADEBOX, COLOUR_GREY),
792  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
793  NWidget(WWT_STICKYBOX, COLOUR_GREY),
794  EndContainer(),
795  NWidget(WWT_PANEL, COLOUR_GREY, WID_PHG_BACKGROUND),
797  NWidget(WWT_EMPTY, COLOUR_GREY, WID_PHG_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
799  NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
800  NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_PHG_RESIZE),
801  EndContainer(),
802  EndContainer(),
803  EndContainer(),
804 };
805 
806 static WindowDesc _performance_history_desc(
807  WDP_AUTO, "graph_performance", 0, 0,
809  0,
810  _nested_performance_history_widgets, lengthof(_nested_performance_history_widgets)
811 );
812 
813 void ShowPerformanceHistoryGraph()
814 {
815  AllocateWindowDescFront<PerformanceHistoryGraphWindow>(&_performance_history_desc, 0);
816 }
817 
818 /*****************/
819 /* COMPANY VALUE */
820 /*****************/
821 
824  BaseGraphWindow(desc, WID_CV_GRAPH, STR_JUST_CURRENCY_SHORT)
825  {
826  this->InitializeWindow(window_number);
827  }
828 
829  OverflowSafeInt64 GetGraphData(const Company *c, int j) override
830  {
831  return c->old_economy[j].company_value;
832  }
833 };
834 
835 static const NWidgetPart _nested_company_value_graph_widgets[] = {
837  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
838  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_COMPANY_VALUES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
839  NWidget(WWT_PUSHTXTBTN, COLOUR_GREY, WID_CV_KEY_BUTTON), SetMinimalSize(50, 0), SetMinimalTextLines(1, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM + 2), SetDataTip(STR_GRAPH_KEY_BUTTON, STR_GRAPH_KEY_TOOLTIP),
840  NWidget(WWT_SHADEBOX, COLOUR_GREY),
841  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
842  NWidget(WWT_STICKYBOX, COLOUR_GREY),
843  EndContainer(),
844  NWidget(WWT_PANEL, COLOUR_GREY, WID_CV_BACKGROUND),
846  NWidget(WWT_EMPTY, COLOUR_GREY, WID_CV_GRAPH), SetMinimalSize(576, 224), SetFill(1, 1), SetResize(1, 1),
848  NWidget(NWID_SPACER), SetFill(0, 1), SetResize(0, 1),
849  NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CV_RESIZE),
850  EndContainer(),
851  EndContainer(),
852  EndContainer(),
853 };
854 
855 static WindowDesc _company_value_graph_desc(
856  WDP_AUTO, "graph_company_value", 0, 0,
858  0,
859  _nested_company_value_graph_widgets, lengthof(_nested_company_value_graph_widgets)
860 );
861 
862 void ShowCompanyValueGraph()
863 {
864  AllocateWindowDescFront<CompanyValueGraphWindow>(&_company_value_graph_desc, 0);
865 }
866 
867 /*****************/
868 /* PAYMENT RATES */
869 /*****************/
870 
872  uint line_height;
874 
876  BaseGraphWindow(desc, WID_CPR_GRAPH, STR_JUST_CURRENCY_SHORT)
877  {
878  this->num_on_x_axis = 20;
879  this->num_vert_lines = 20;
880  this->month = 0xFF;
881  this->x_values_start = 10;
882  this->x_values_increment = 10;
883 
884  this->CreateNestedTree();
885  this->vscroll = this->GetScrollbar(WID_CPR_MATRIX_SCROLLBAR);
887 
888  /* Initialise the dataset */
889  this->OnHundredthTick();
890 
891  this->FinishInitNested(window_number);
892  }
893 
894  void UpdateExcludedData()
895  {
896  this->excluded_data = 0;
897 
898  int i = 0;
899  const CargoSpec *cs;
901  if (HasBit(_legend_excluded_cargo, cs->Index())) SetBit(this->excluded_data, i);
902  i++;
903  }
904  }
905 
906  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
907  {
908  if (widget != WID_CPR_MATRIX) {
909  BaseGraphWindow::UpdateWidgetSize(widget, size, padding, fill, resize);
910  return;
911  }
912 
913  const CargoSpec *cs;
915  SetDParam(0, cs->name);
916  Dimension d = GetStringBoundingBox(STR_GRAPH_CARGO_PAYMENT_CARGO);
917  d.width += 14; // colour field
920  *size = maxdim(d, *size);
921  }
922 
923  this->line_height = size->height;
924  size->height = this->line_height * 11; /* Default number of cargo types in most climates. */
925  resize->width = 0;
926  resize->height = this->line_height;
927  }
928 
929  void DrawWidget(const Rect &r, int widget) const override
930  {
931  if (widget != WID_CPR_MATRIX) {
932  BaseGraphWindow::DrawWidget(r, widget);
933  return;
934  }
935 
936  bool rtl = _current_text_dir == TD_RTL;
937 
938  int x = r.left + WD_FRAMERECT_LEFT;
939  int y = r.top;
940 
941  int pos = this->vscroll->GetPosition();
942  int max = pos + this->vscroll->GetCapacity();
943 
944  const CargoSpec *cs;
946  if (pos-- > 0) continue;
947  if (--max < 0) break;
948 
949  bool lowered = !HasBit(_legend_excluded_cargo, cs->Index());
950 
951  /* Redraw box if lowered */
952  if (lowered) DrawFrameRect(r.left, y, r.right, y + this->line_height - 1, COLOUR_ORANGE, lowered ? FR_LOWERED : FR_NONE);
953 
954  byte clk_dif = lowered ? 1 : 0;
955  int rect_x = clk_dif + (rtl ? r.right - 12 : r.left + WD_FRAMERECT_LEFT);
956 
957  GfxFillRect(rect_x, y + clk_dif, rect_x + 8, y + 5 + clk_dif, PC_BLACK);
958  GfxFillRect(rect_x + 1, y + 1 + clk_dif, rect_x + 7, y + 4 + clk_dif, cs->legend_colour);
959  SetDParam(0, cs->name);
960  DrawString(rtl ? r.left : x + 14 + clk_dif, (rtl ? r.right - 14 + clk_dif : r.right), y + clk_dif, STR_GRAPH_CARGO_PAYMENT_CARGO);
961 
962  y += this->line_height;
963  }
964  }
965 
966  void OnClick(Point pt, int widget, int click_count) override
967  {
968  switch (widget) {
970  /* Remove all cargoes from the excluded lists. */
971  _legend_excluded_cargo = 0;
972  this->excluded_data = 0;
973  this->SetDirty();
974  break;
975 
977  /* Add all cargoes to the excluded lists. */
978  int i = 0;
979  const CargoSpec *cs;
981  SetBit(_legend_excluded_cargo, cs->Index());
982  SetBit(this->excluded_data, i);
983  i++;
984  }
985  this->SetDirty();
986  break;
987  }
988 
989  case WID_CPR_MATRIX: {
990  uint row = this->vscroll->GetScrolledRowFromWidget(pt.y, this, WID_CPR_MATRIX, 0, this->line_height);
991  if (row >= this->vscroll->GetCount()) return;
992 
993  const CargoSpec *cs;
995  if (row-- > 0) continue;
996 
997  ToggleBit(_legend_excluded_cargo, cs->Index());
998  this->UpdateExcludedData();
999  this->SetDirty();
1000  break;
1001  }
1002  break;
1003  }
1004  }
1005  }
1006 
1007  void OnResize() override
1008  {
1009  this->vscroll->SetCapacityFromWidget(this, WID_CPR_MATRIX);
1010  }
1011 
1012  void OnGameTick() override
1013  {
1014  /* Override default OnGameTick */
1015  }
1016 
1022  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1023  {
1024  if (!gui_scope) return;
1025  this->OnHundredthTick();
1026  }
1027 
1028  void OnHundredthTick() override
1029  {
1030  this->UpdateExcludedData();
1031 
1032  int i = 0;
1033  const CargoSpec *cs;
1035  this->colours[i] = cs->legend_colour;
1036  for (uint j = 0; j != 20; j++) {
1037  this->cost[i][j] = GetTransportedGoodsIncome(10, 20, j * 4 + 4, cs->Index());
1038  }
1039  i++;
1040  }
1041  this->num_dataset = i;
1042  }
1043 };
1044 
1045 static const NWidgetPart _nested_cargo_payment_rates_widgets[] = {
1047  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1048  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1049  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1050  NWidget(WWT_DEFSIZEBOX, COLOUR_GREY),
1051  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1052  EndContainer(),
1053  NWidget(WWT_PANEL, COLOUR_GREY, WID_CPR_BACKGROUND), SetMinimalSize(568, 128),
1055  NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
1056  NWidget(WWT_TEXT, COLOUR_GREY, WID_CPR_HEADER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_TITLE, STR_NULL),
1057  NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
1058  EndContainer(),
1060  NWidget(WWT_EMPTY, COLOUR_GREY, WID_CPR_GRAPH), SetMinimalSize(495, 0), SetFill(1, 1), SetResize(1, 1),
1062  NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
1063  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_ENABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_ENABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_ENABLE_ALL), SetFill(1, 0),
1064  NWidget(WWT_PUSHTXTBTN, COLOUR_ORANGE, WID_CPR_DISABLE_CARGOES), SetDataTip(STR_GRAPH_CARGO_DISABLE_ALL, STR_GRAPH_CARGO_TOOLTIP_DISABLE_ALL), SetFill(1, 0),
1067  NWidget(WWT_MATRIX, COLOUR_ORANGE, WID_CPR_MATRIX), SetResize(0, 2), SetMatrixDataTip(1, 0, STR_GRAPH_CARGO_PAYMENT_TOGGLE_CARGO), SetScrollbar(WID_CPR_MATRIX_SCROLLBAR),
1069  EndContainer(),
1070  NWidget(NWID_SPACER), SetMinimalSize(0, 24), SetFill(0, 1),
1071  EndContainer(),
1072  NWidget(NWID_SPACER), SetMinimalSize(5, 0), SetFill(0, 1), SetResize(0, 1),
1073  EndContainer(),
1076  NWidget(WWT_TEXT, COLOUR_GREY, WID_CPR_FOOTER), SetMinimalSize(0, 6), SetPadding(2, 0, 2, 0), SetDataTip(STR_GRAPH_CARGO_PAYMENT_RATES_X_LABEL, STR_NULL),
1077  NWidget(NWID_SPACER), SetFill(1, 0), SetResize(1, 0),
1078  NWidget(WWT_RESIZEBOX, COLOUR_GREY, WID_CPR_RESIZE),
1079  EndContainer(),
1080  EndContainer(),
1081 };
1082 
1083 static WindowDesc _cargo_payment_rates_desc(
1084  WDP_AUTO, "graph_cargo_payment_rates", 0, 0,
1086  0,
1087  _nested_cargo_payment_rates_widgets, lengthof(_nested_cargo_payment_rates_widgets)
1088 );
1089 
1090 
1091 void ShowCargoPaymentRates()
1092 {
1093  AllocateWindowDescFront<PaymentRatesGraphWindow>(&_cargo_payment_rates_desc, 0);
1094 }
1095 
1096 /************************/
1097 /* COMPANY LEAGUE TABLE */
1098 /************************/
1099 
1100 static const StringID _performance_titles[] = {
1101  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER,
1102  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ENGINEER,
1103  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRAFFIC_MANAGER,
1104  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRAFFIC_MANAGER,
1105  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRANSPORT_COORDINATOR,
1106  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TRANSPORT_COORDINATOR,
1107  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ROUTE_SUPERVISOR,
1108  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_ROUTE_SUPERVISOR,
1109  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_DIRECTOR,
1110  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_DIRECTOR,
1111  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHIEF_EXECUTIVE,
1112  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHIEF_EXECUTIVE,
1113  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHAIRMAN,
1114  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_CHAIRMAN,
1115  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_PRESIDENT,
1116  STR_COMPANY_LEAGUE_PERFORMANCE_TITLE_TYCOON,
1117 };
1118 
1119 static inline StringID GetPerformanceTitleFromValue(uint value)
1120 {
1121  return _performance_titles[std::min(value, 1000u) >> 6];
1122 }
1123 
1124 class CompanyLeagueWindow : public Window {
1125 private:
1126  GUIList<const Company*> companies;
1128  uint text_width;
1129  uint icon_width;
1131 
1136  {
1137  if (!this->companies.NeedRebuild()) return;
1138 
1139  this->companies.clear();
1140 
1141  for (const Company *c : Company::Iterate()) {
1142  this->companies.push_back(c);
1143  }
1144 
1145  this->companies.shrink_to_fit();
1146  this->companies.RebuildDone();
1147  }
1148 
1150  static bool PerformanceSorter(const Company * const &c1, const Company * const &c2)
1151  {
1153  }
1154 
1155 public:
1157  {
1158  this->InitNested(window_number);
1159  this->companies.ForceRebuild();
1160  this->companies.NeedResort();
1161  }
1162 
1163  void OnPaint() override
1164  {
1165  this->BuildCompanyList();
1166  this->companies.Sort(&PerformanceSorter);
1167 
1168  this->DrawWidgets();
1169  }
1170 
1171  void DrawWidget(const Rect &r, int widget) const override
1172  {
1173  if (widget != WID_CL_BACKGROUND) return;
1174 
1175  int icon_y_offset = 1 + (FONT_HEIGHT_NORMAL - this->line_height) / 2;
1176  uint y = r.top + WD_FRAMERECT_TOP - icon_y_offset;
1177 
1178  bool rtl = _current_text_dir == TD_RTL;
1179  uint ordinal_left = rtl ? r.right - WD_FRAMERECT_LEFT - this->ordinal_width : r.left + WD_FRAMERECT_LEFT;
1180  uint ordinal_right = rtl ? r.right - WD_FRAMERECT_LEFT : r.left + WD_FRAMERECT_LEFT + this->ordinal_width;
1181  uint icon_left = r.left + WD_FRAMERECT_LEFT + WD_FRAMERECT_RIGHT + (rtl ? this->text_width : this->ordinal_width);
1182  uint text_left = rtl ? r.left + WD_FRAMERECT_LEFT : r.right - WD_FRAMERECT_LEFT - this->text_width;
1183  uint text_right = rtl ? r.left + WD_FRAMERECT_LEFT + this->text_width : r.right - WD_FRAMERECT_LEFT;
1184 
1185  for (uint i = 0; i != this->companies.size(); i++) {
1186  const Company *c = this->companies[i];
1187  DrawString(ordinal_left, ordinal_right, y, i + STR_ORDINAL_NUMBER_1ST, i == 0 ? TC_WHITE : TC_YELLOW);
1188 
1189  DrawCompanyIcon(c->index, icon_left, y + icon_y_offset);
1190 
1191  SetDParam(0, c->index);
1192  SetDParam(1, c->index);
1193  SetDParam(2, GetPerformanceTitleFromValue(c->old_economy[0].performance_history));
1194  DrawString(text_left, text_right, y, STR_COMPANY_LEAGUE_COMPANY_NAME);
1195  y += this->line_height;
1196  }
1197  }
1198 
1199  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1200  {
1201  if (widget != WID_CL_BACKGROUND) return;
1202 
1203  this->ordinal_width = 0;
1204  for (uint i = 0; i < MAX_COMPANIES; i++) {
1205  this->ordinal_width = std::max(this->ordinal_width, GetStringBoundingBox(STR_ORDINAL_NUMBER_1ST + i).width);
1206  }
1207  this->ordinal_width += 5; // Keep some extra spacing
1208 
1209  uint widest_width = 0;
1210  uint widest_title = 0;
1211  for (uint i = 0; i < lengthof(_performance_titles); i++) {
1212  uint width = GetStringBoundingBox(_performance_titles[i]).width;
1213  if (width > widest_width) {
1214  widest_title = i;
1215  widest_width = width;
1216  }
1217  }
1218 
1219  Dimension d = GetSpriteSize(SPR_COMPANY_ICON);
1220  this->icon_width = d.width + 2;
1221  this->line_height = std::max<int>(d.height + 2, FONT_HEIGHT_NORMAL);
1222 
1223  for (const Company *c : Company::Iterate()) {
1224  SetDParam(0, c->index);
1225  SetDParam(1, c->index);
1226  SetDParam(2, _performance_titles[widest_title]);
1227  widest_width = std::max(widest_width, GetStringBoundingBox(STR_COMPANY_LEAGUE_COMPANY_NAME).width);
1228  }
1229 
1230  this->text_width = widest_width + 30; // Keep some extra spacing
1231 
1232  size->width = WD_FRAMERECT_LEFT + this->ordinal_width + WD_FRAMERECT_RIGHT + this->icon_width + WD_FRAMERECT_LEFT + this->text_width + WD_FRAMERECT_RIGHT;
1233  size->height = WD_FRAMERECT_TOP + this->line_height * MAX_COMPANIES + WD_FRAMERECT_BOTTOM;
1234  }
1235 
1236 
1237  void OnGameTick() override
1238  {
1239  if (this->companies.NeedResort()) {
1240  this->SetDirty();
1241  }
1242  }
1243 
1249  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1250  {
1251  if (data == 0) {
1252  /* This needs to be done in command-scope to enforce rebuilding before resorting invalid data */
1253  this->companies.ForceRebuild();
1254  } else {
1255  this->companies.ForceResort();
1256  }
1257  }
1258 };
1259 
1260 static const NWidgetPart _nested_company_league_widgets[] = {
1262  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1263  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_COMPANY_LEAGUE_TABLE_CAPTION, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1264  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1265  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1266  EndContainer(),
1268 };
1269 
1270 static WindowDesc _company_league_desc(
1271  WDP_AUTO, "league", 0, 0,
1273  0,
1274  _nested_company_league_widgets, lengthof(_nested_company_league_widgets)
1275 );
1276 
1277 void ShowCompanyLeagueTable()
1278 {
1279  AllocateWindowDescFront<CompanyLeagueWindow>(&_company_league_desc, 0);
1280 }
1281 
1282 /*****************************/
1283 /* PERFORMANCE RATING DETAIL */
1284 /*****************************/
1285 
1287  static CompanyID company;
1288  int timeout;
1289 
1291  {
1292  this->UpdateCompanyStats();
1293 
1294  this->InitNested(window_number);
1296  }
1297 
1298  void UpdateCompanyStats()
1299  {
1300  /* Update all company stats with the current data
1301  * (this is because _score_info is not saved to a savegame) */
1302  for (Company *c : Company::Iterate()) {
1303  UpdateCompanyRatingAndValue(c, false);
1304  }
1305 
1306  this->timeout = DAY_TICKS * 5;
1307  }
1308 
1309  uint score_info_left;
1310  uint score_info_right;
1311  uint bar_left;
1312  uint bar_right;
1313  uint bar_width;
1314  uint bar_height;
1315  uint score_detail_left;
1316  uint score_detail_right;
1317 
1318  void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
1319  {
1320  switch (widget) {
1321  case WID_PRD_SCORE_FIRST:
1322  this->bar_height = FONT_HEIGHT_NORMAL + 4;
1323  size->height = this->bar_height + 2 * WD_MATRIX_TOP;
1324 
1325  uint score_info_width = 0;
1326  for (uint i = SCORE_BEGIN; i < SCORE_END; i++) {
1327  score_info_width = std::max(score_info_width, GetStringBoundingBox(STR_PERFORMANCE_DETAIL_VEHICLES + i).width);
1328  }
1329  SetDParamMaxValue(0, 1000);
1330  score_info_width += GetStringBoundingBox(STR_BLACK_COMMA).width + WD_FRAMERECT_LEFT;
1331 
1332  SetDParamMaxValue(0, 100);
1333  this->bar_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_PERCENT).width + 20; // Wide bars!
1334 
1335  /* At this number we are roughly at the max; it can become wider,
1336  * but then you need at 1000 times more money. At that time you're
1337  * not that interested anymore in the last few digits anyway.
1338  * The 500 is because 999 999 500 to 999 999 999 are rounded to
1339  * 1 000 M, and not 999 999 k. Use negative numbers to account for
1340  * the negative income/amount of money etc. as well. */
1341  int max = -(999999999 - 500);
1342 
1343  /* Scale max for the display currency. Prior to rendering the value
1344  * is converted into the display currency, which may cause it to
1345  * raise significantly. We need to compensate for that since {{CURRCOMPACT}}
1346  * is used, which can produce quite short renderings of very large
1347  * values. Otherwise the calculated width could be too narrow.
1348  * Note that it doesn't work if there was a currency with an exchange
1349  * rate greater than max.
1350  * When the currency rate is more than 1000, the 999 999 k becomes at
1351  * least 999 999 M which roughly is equally long. Furthermore if the
1352  * exchange rate is that high, 999 999 k is usually not enough anymore
1353  * to show the different currency numbers. */
1354  if (_currency->rate < 1000) max /= _currency->rate;
1355  SetDParam(0, max);
1356  SetDParam(1, max);
1357  uint score_detail_width = GetStringBoundingBox(STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY).width;
1358 
1359  size->width = 7 + score_info_width + 5 + this->bar_width + 5 + score_detail_width + 7;
1360  uint left = 7;
1361  uint right = size->width - 7;
1362 
1363  bool rtl = _current_text_dir == TD_RTL;
1364  this->score_info_left = rtl ? right - score_info_width : left;
1365  this->score_info_right = rtl ? right : left + score_info_width;
1366 
1367  this->score_detail_left = rtl ? left : right - score_detail_width;
1368  this->score_detail_right = rtl ? left + score_detail_width : right;
1369 
1370  this->bar_left = left + (rtl ? score_detail_width : score_info_width) + 5;
1371  this->bar_right = this->bar_left + this->bar_width;
1372  break;
1373  }
1374  }
1375 
1376  void DrawWidget(const Rect &r, int widget) const override
1377  {
1378  /* No need to draw when there's nothing to draw */
1379  if (this->company == INVALID_COMPANY) return;
1380 
1382  if (this->IsWidgetDisabled(widget)) return;
1383  CompanyID cid = (CompanyID)(widget - WID_PRD_COMPANY_FIRST);
1384  int offset = (cid == this->company) ? 1 : 0;
1385  Dimension sprite_size = GetSpriteSize(SPR_COMPANY_ICON);
1386  DrawCompanyIcon(cid, (r.left + r.right - sprite_size.width) / 2 + offset, (r.top + r.bottom - sprite_size.height) / 2 + offset);
1387  return;
1388  }
1389 
1390  if (!IsInsideMM(widget, WID_PRD_SCORE_FIRST, WID_PRD_SCORE_LAST + 1)) return;
1391 
1392  ScoreID score_type = (ScoreID)(widget - WID_PRD_SCORE_FIRST);
1393 
1394  /* The colours used to show how the progress is going */
1395  int colour_done = _colour_gradient[COLOUR_GREEN][4];
1396  int colour_notdone = _colour_gradient[COLOUR_RED][4];
1397 
1398  /* Draw all the score parts */
1399  int64 val = _score_part[company][score_type];
1400  int64 needed = _score_info[score_type].needed;
1401  int score = _score_info[score_type].score;
1402 
1403  /* SCORE_TOTAL has his own rules ;) */
1404  if (score_type == SCORE_TOTAL) {
1405  for (ScoreID i = SCORE_BEGIN; i < SCORE_END; i++) score += _score_info[i].score;
1406  needed = SCORE_MAX;
1407  }
1408 
1409  uint bar_top = r.top + WD_MATRIX_TOP;
1410  uint text_top = bar_top + 2;
1411 
1412  DrawString(this->score_info_left, this->score_info_right, text_top, STR_PERFORMANCE_DETAIL_VEHICLES + score_type);
1413 
1414  /* Draw the score */
1415  SetDParam(0, score);
1416  DrawString(this->score_info_left, this->score_info_right, text_top, STR_BLACK_COMMA, TC_FROMSTRING, SA_RIGHT);
1417 
1418  /* Calculate the %-bar */
1419  uint x = Clamp<int64>(val, 0, needed) * this->bar_width / needed;
1420  bool rtl = _current_text_dir == TD_RTL;
1421  if (rtl) {
1422  x = this->bar_right - x;
1423  } else {
1424  x = this->bar_left + x;
1425  }
1426 
1427  /* Draw the bar */
1428  if (x != this->bar_left) GfxFillRect(this->bar_left, bar_top, x, bar_top + this->bar_height, rtl ? colour_notdone : colour_done);
1429  if (x != this->bar_right) GfxFillRect(x, bar_top, this->bar_right, bar_top + this->bar_height, rtl ? colour_done : colour_notdone);
1430 
1431  /* Draw it */
1432  SetDParam(0, Clamp<int64>(val, 0, needed) * 100 / needed);
1433  DrawString(this->bar_left, this->bar_right, text_top, STR_PERFORMANCE_DETAIL_PERCENT, TC_FROMSTRING, SA_HOR_CENTER);
1434 
1435  /* SCORE_LOAN is inversed */
1436  if (score_type == SCORE_LOAN) val = needed - val;
1437 
1438  /* Draw the amount we have against what is needed
1439  * For some of them it is in currency format */
1440  SetDParam(0, val);
1441  SetDParam(1, needed);
1442  switch (score_type) {
1443  case SCORE_MIN_PROFIT:
1444  case SCORE_MIN_INCOME:
1445  case SCORE_MAX_INCOME:
1446  case SCORE_MONEY:
1447  case SCORE_LOAN:
1448  DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_CURRENCY);
1449  break;
1450  default:
1451  DrawString(this->score_detail_left, this->score_detail_right, text_top, STR_PERFORMANCE_DETAIL_AMOUNT_INT);
1452  }
1453  }
1454 
1455  void OnClick(Point pt, int widget, int click_count) override
1456  {
1457  /* Check which button is clicked */
1459  /* Is it no on disable? */
1460  if (!this->IsWidgetDisabled(widget)) {
1461  this->RaiseWidget(this->company + WID_PRD_COMPANY_FIRST);
1462  this->company = (CompanyID)(widget - WID_PRD_COMPANY_FIRST);
1463  this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST);
1464  this->SetDirty();
1465  }
1466  }
1467  }
1468 
1469  void OnGameTick() override
1470  {
1471  /* Update the company score every 5 days */
1472  if (--this->timeout == 0) {
1473  this->UpdateCompanyStats();
1474  this->SetDirty();
1475  }
1476  }
1477 
1483  void OnInvalidateData(int data = 0, bool gui_scope = true) override
1484  {
1485  if (!gui_scope) return;
1486  /* Disable the companies who are not active */
1487  for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
1489  }
1490 
1491  /* Check if the currently selected company is still active. */
1492  if (this->company != INVALID_COMPANY && !Company::IsValidID(this->company)) {
1493  /* Raise the widget for the previous selection. */
1494  this->RaiseWidget(this->company + WID_PRD_COMPANY_FIRST);
1495  this->company = INVALID_COMPANY;
1496  }
1497 
1498  if (this->company == INVALID_COMPANY) {
1499  for (const Company *c : Company::Iterate()) {
1500  this->company = c->index;
1501  break;
1502  }
1503  }
1504 
1505  /* Make sure the widget is lowered */
1506  this->LowerWidget(this->company + WID_PRD_COMPANY_FIRST);
1507  }
1508 };
1509 
1510 CompanyID PerformanceRatingDetailWindow::company = INVALID_COMPANY;
1511 
1518 static NWidgetBase *MakePerformanceDetailPanels(int *biggest_index)
1519 {
1520  const StringID performance_tips[] = {
1521  STR_PERFORMANCE_DETAIL_VEHICLES_TOOLTIP,
1522  STR_PERFORMANCE_DETAIL_STATIONS_TOOLTIP,
1523  STR_PERFORMANCE_DETAIL_MIN_PROFIT_TOOLTIP,
1524  STR_PERFORMANCE_DETAIL_MIN_INCOME_TOOLTIP,
1525  STR_PERFORMANCE_DETAIL_MAX_INCOME_TOOLTIP,
1526  STR_PERFORMANCE_DETAIL_DELIVERED_TOOLTIP,
1527  STR_PERFORMANCE_DETAIL_CARGO_TOOLTIP,
1528  STR_PERFORMANCE_DETAIL_MONEY_TOOLTIP,
1529  STR_PERFORMANCE_DETAIL_LOAN_TOOLTIP,
1530  STR_PERFORMANCE_DETAIL_TOTAL_TOOLTIP,
1531  };
1532 
1533  static_assert(lengthof(performance_tips) == SCORE_END - SCORE_BEGIN);
1534 
1536  for (int widnum = WID_PRD_SCORE_FIRST; widnum <= WID_PRD_SCORE_LAST; widnum++) {
1537  NWidgetBackground *panel = new NWidgetBackground(WWT_PANEL, COLOUR_GREY, widnum);
1538  panel->SetFill(1, 1);
1539  panel->SetDataTip(0x0, performance_tips[widnum - WID_PRD_SCORE_FIRST]);
1540  vert->Add(panel);
1541  }
1542  *biggest_index = WID_PRD_SCORE_LAST;
1543  return vert;
1544 }
1545 
1548 {
1549  return MakeCompanyButtonRows(biggest_index, WID_PRD_COMPANY_FIRST, WID_PRD_COMPANY_LAST, 8, STR_PERFORMANCE_DETAIL_SELECT_COMPANY_TOOLTIP);
1550 }
1551 
1552 static const NWidgetPart _nested_performance_rating_detail_widgets[] = {
1554  NWidget(WWT_CLOSEBOX, COLOUR_GREY),
1555  NWidget(WWT_CAPTION, COLOUR_GREY), SetDataTip(STR_PERFORMANCE_DETAIL, STR_TOOLTIP_WINDOW_TITLE_DRAG_THIS),
1556  NWidget(WWT_SHADEBOX, COLOUR_GREY),
1557  NWidget(WWT_STICKYBOX, COLOUR_GREY),
1558  EndContainer(),
1559  NWidget(WWT_PANEL, COLOUR_GREY),
1561  EndContainer(),
1563 };
1564 
1565 static WindowDesc _performance_rating_detail_desc(
1566  WDP_AUTO, "league_details", 0, 0,
1568  0,
1569  _nested_performance_rating_detail_widgets, lengthof(_nested_performance_rating_detail_widgets)
1570 );
1571 
1572 void ShowPerformanceRatingDetail()
1573 {
1574  AllocateWindowDescFront<PerformanceRatingDetailWindow>(&_performance_rating_detail_desc, 0);
1575 }
1576 
1577 void InitializeGraphGui()
1578 {
1579  _legend_excluded_companies = 0;
1580  _legend_excluded_cargo = 0;
1581 }
WD_FRAMERECT_TOP
@ WD_FRAMERECT_TOP
Offset at top to draw the frame rectangular area.
Definition: window_gui.h:62
PaymentRatesGraphWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: graph_gui.cpp:906
CargoArray::GetSum
const T GetSum() const
Get the sum of all cargo amounts.
Definition: cargo_type.h:121
InvalidateWindowData
void InvalidateWindowData(WindowClass cls, WindowNumber number, int data, bool gui_scope)
Mark window data of the window of a given class and specific window number as invalid (in need of re-...
Definition: window.cpp:3319
PaymentRatesGraphWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: graph_gui.cpp:929
CompanyEconomyEntry::company_value
Money company_value
The value of the company.
Definition: company_base.h:27
FOR_ALL_SORTED_STANDARD_CARGOSPECS
#define FOR_ALL_SORTED_STANDARD_CARGOSPECS(var)
Loop header for iterating over 'real' cargoes, sorted by name.
Definition: cargotype.h:171
NWidgetFunction
static NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
Obtain a nested widget (sub)tree from an external source.
Definition: widget_type.h:1145
WID_PHG_KEY
@ WID_PHG_KEY
Key button.
Definition: graph_widget.h:34
CompanyLeagueWindow::line_height
int line_height
Height of the text lines.
Definition: graph_gui.cpp:1130
SetWindowDirty
void SetWindowDirty(WindowClass cls, WindowNumber number)
Mark window as dirty (in need of repainting)
Definition: window.cpp:3218
GraphLegendWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: graph_gui.cpp:57
SetScrollbar
static NWidgetPart SetScrollbar(int index)
Attach a scrollbar to a widget.
Definition: widget_type.h:1094
WID_CV_KEY_BUTTON
@ WID_CV_KEY_BUTTON
Key button.
Definition: graph_widget.h:26
WID_CPR_RESIZE
@ WID_CPR_RESIZE
Resize button.
Definition: graph_widget.h:46
Dimension
Dimensions (a width and height) of a rectangle in 2D.
Definition: geometry_type.hpp:27
Scrollbar::GetCapacity
uint16 GetCapacity() const
Gets the number of visible elements of the scrollbar.
Definition: widget_type.h:621
WWT_STICKYBOX
@ WWT_STICKYBOX
Sticky box (at top-right of a window, after WWT_DEFSIZEBOX)
Definition: widget_type.h:64
SetPadding
static NWidgetPart SetPadding(uint8 top, uint8 right, uint8 bottom, uint8 left)
Widget part function for setting additional space around a widget.
Definition: widget_type.h:1045
GUIList::Sort
bool Sort(Comp compare)
Sort the list.
Definition: sortlist_type.h:247
Pool::PoolItem<&_company_pool >::GetIfValid
static Titem * GetIfValid(size_t index)
Returns Titem with given index.
Definition: pool_type.hpp:340
Window::GetScrollbar
const Scrollbar * GetScrollbar(uint widnum) const
Return the Scrollbar to a widget index.
Definition: window.cpp:309
FindLastBit
uint8 FindLastBit(uint64 x)
Search the last set bit in a 64 bit variable.
Definition: bitmath_func.cpp:65
SCORE_TOTAL
@ SCORE_TOTAL
This must always be the last entry.
Definition: economy_type.h:56
company_base.h
_cur_year
Year _cur_year
Current year, starting at 0.
Definition: date.cpp:25
NWidgetContainer::Add
void Add(NWidgetBase *wid)
Append widget wid to container.
Definition: widget.cpp:951
WD_MATRIX_TOP
@ WD_MATRIX_TOP
Offset at top of a matrix cell.
Definition: window_gui.h:78
GUISettings::graph_line_thickness
uint8 graph_line_thickness
the thickness of the lines in the various graph guis
Definition: settings_type.h:145
WWT_CAPTION
@ WWT_CAPTION
Window caption (window title between closebox and stickybox)
Definition: widget_type.h:59
PerformanceRatingDetailWindow
Definition: graph_gui.cpp:1286
company_gui.h
currency.h
Scrollbar::GetScrolledRowFromWidget
int GetScrolledRowFromWidget(int clickpos, const Window *const w, int widget, int padding=0, int line_height=-1) const
Compute the row of a scrolled widget that a user clicked in.
Definition: widget.cpp:1966
SA_RIGHT
@ SA_RIGHT
Right align the text (must be a single bit).
Definition: gfx_func.h:96
GUIList< const Company * >
WWT_DEFSIZEBOX
@ WWT_DEFSIZEBOX
Default window size box (at top-right of a window, between WWT_SHADEBOX and WWT_STICKYBOX)
Definition: widget_type.h:63
Window::CreateNestedTree
void CreateNestedTree(bool fill_nested=true)
Perform the first part of the initialization of a nested widget tree.
Definition: window.cpp:1832
CompanyLeagueWindow
Definition: graph_gui.cpp:1124
Pool::PoolItem::index
Tindex index
Index of this pool item.
Definition: pool_type.hpp:227
NWID_HORIZONTAL
@ NWID_HORIZONTAL
Horizontal container.
Definition: widget_type.h:73
CompanyLeagueWindow::BuildCompanyList
void BuildCompanyList()
(Re)Build the company league list
Definition: graph_gui.cpp:1135
WID_GL_FIRST_COMPANY
@ WID_GL_FIRST_COMPANY
First company in the legend.
Definition: graph_widget.h:20
maxdim
Dimension maxdim(const Dimension &d1, const Dimension &d2)
Compute bounding box of both dimensions.
Definition: geometry_func.cpp:22
WWT_MATRIX
@ WWT_MATRIX
Grid of rows and columns.
Definition: widget_type.h:57
WC_PERFORMANCE_HISTORY
@ WC_PERFORMANCE_HISTORY
Performance history graph; Window numbers:
Definition: window_type.h:540
HasBit
static bool HasBit(const T x, const uint8 y)
Checks if a bit in a value is set.
Definition: bitmath_func.hpp:103
Scrollbar::SetCount
void SetCount(int num)
Sets the number of elements in the list.
Definition: widget_type.h:669
PerformanceHistoryGraphWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: graph_gui.cpp:778
WID_PHG_DETAILED_PERFORMANCE
@ WID_PHG_DETAILED_PERFORMANCE
Detailed performance.
Definition: graph_widget.h:35
Year
int32 Year
Type for the year, note: 0 based, i.e. starts at the year 0.
Definition: date_type.h:18
TextColour
TextColour
Colour of the strings, see _string_colourmap in table/string_colours.h or docs/ottd-colourtext-palett...
Definition: gfx_type.h:250
SetResize
static NWidgetPart SetResize(int16 dx, int16 dy)
Widget part function for setting the resize step.
Definition: widget_type.h:929
PerformanceRatingDetailWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: graph_gui.cpp:1376
BaseGraphWindow::graph_axis_label_colour
static const TextColour graph_axis_label_colour
colour of the graph axis label.
Definition: graph_gui.cpp:178
MakeCompanyButtonRowsGraphGUI
NWidgetBase * MakeCompanyButtonRowsGraphGUI(int *biggest_index)
Make a number of rows with buttons for each company for the performance rating detail window.
Definition: graph_gui.cpp:1547
_settings_client
ClientSettings _settings_client
The current settings for this game.
Definition: settings.cpp:79
DrawString
int DrawString(int left, int right, int top, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly truncated to make it fit in its allocated space.
Definition: gfx.cpp:636
CargoSpec
Specification of a cargo type.
Definition: cargotype.h:55
WWT_EMPTY
@ WWT_EMPTY
Empty widget, place holder to reserve space in widget array.
Definition: widget_type.h:46
WindowNumber
int32 WindowNumber
Number to differentiate different windows of the same class.
Definition: window_type.h:711
FR_LOWERED
@ FR_LOWERED
If set the frame is lowered and the background colour brighter (ie. buttons when pressed)
Definition: window_gui.h:29
economy_func.h
SA_HOR_CENTER
@ SA_HOR_CENTER
Horizontally center the text.
Definition: gfx_func.h:95
ValuesInterval::highest
OverflowSafeInt64 highest
Highest value of this interval. Must be zero or greater.
Definition: graph_gui.cpp:157
Owner
Owner
Enum for all companies/owners.
Definition: company_type.h:18
Scrollbar
Scrollbar data structure.
Definition: widget_type.h:588
WID_CV_BACKGROUND
@ WID_CV_BACKGROUND
Background of the window.
Definition: graph_widget.h:27
WC_COMPANY_LEAGUE
@ WC_COMPANY_LEAGUE
Company league window; Window numbers:
Definition: window_type.h:552
_colour_gradient
byte _colour_gradient[COLOUR_END][8]
All 16 colour gradients 8 colours per gradient from darkest (0) to lightest (7)
Definition: gfx.cpp:52
Window::Window
Window(WindowDesc *desc)
Empty constructor, initialization has been moved to InitNested() called from the constructor of the d...
Definition: window.cpp:1871
SetDParam
static void SetDParam(uint n, uint64 v)
Set a string parameter v at index n in the global string parameter array.
Definition: strings_func.h:199
NWidgetPart
Partial widget specification to allow NWidgets to be written nested.
Definition: widget_type.h:909
SetDataTip
static NWidgetPart SetDataTip(uint32 data, StringID tip)
Widget part function for setting the data and tooltip.
Definition: widget_type.h:1013
GetStringBoundingBox
Dimension GetStringBoundingBox(const char *str, FontSize start_fontsize)
Return the string dimension in pixels.
Definition: gfx.cpp:838
BaseGraphWindow
Definition: graph_gui.cpp:165
WID_PHG_RESIZE
@ WID_PHG_RESIZE
Resize button.
Definition: graph_widget.h:38
DrawStringMultiLine
int DrawStringMultiLine(int left, int right, int top, int bottom, const char *str, TextColour colour, StringAlignment align, bool underline, FontSize fontsize)
Draw string, possibly over multiple lines.
Definition: gfx.cpp:759
PaymentRatesGraphWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: graph_gui.cpp:966
IsInsideMM
static bool IsInsideMM(const T x, const size_t min, const size_t max)
Checks if a value is in an interval.
Definition: math_func.hpp:204
PaymentRatesGraphWindow
Definition: graph_gui.cpp:871
WC_DELIVERED_CARGO
@ WC_DELIVERED_CARGO
Delivered cargo graph; Window numbers:
Definition: window_type.h:534
WID_CV_RESIZE
@ WID_CV_RESIZE
Resize button.
Definition: graph_widget.h:29
gfx_func.h
ScoreInfo::score
int score
How much score it will give.
Definition: economy_type.h:67
WindowDesc
High level window description.
Definition: window_gui.h:166
COMPANY_FIRST
@ COMPANY_FIRST
First company, same as owner.
Definition: company_type.h:22
WC_GRAPH_LEGEND
@ WC_GRAPH_LEGEND
Legend for graphs; Window numbers:
Definition: window_type.h:510
window_gui.h
WID_PHG_GRAPH
@ WID_PHG_GRAPH
Graph itself.
Definition: graph_widget.h:37
height
int height
Height in pixels of our display surface.
Definition: win32_v.cpp:49
NC_EQUALSIZE
@ NC_EQUALSIZE
Value of the NCB_EQUALSIZE flag.
Definition: widget_type.h:428
CargoSpec::Index
CargoID Index() const
Determines index of this cargospec.
Definition: cargotype.h:88
MakePerformanceDetailPanels
static NWidgetBase * MakePerformanceDetailPanels(int *biggest_index)
Make a vertical list of panels for outputting score details.
Definition: graph_gui.cpp:1518
BaseGraphWindow::GetValuesInterval
ValuesInterval GetValuesInterval(int num_hori_lines) const
Get the interval that contains the graph's data.
Definition: graph_gui.cpp:201
WDP_AUTO
@ WDP_AUTO
Find a place automatically.
Definition: window_gui.h:154
WID_CPR_MATRIX_SCROLLBAR
@ WID_CPR_MATRIX_SCROLLBAR
Cargo list scrollbar.
Definition: graph_widget.h:51
CompanyProperties::colour
byte colour
Company colour.
Definition: company_base.h:70
Window::resize
ResizeInfo resize
Resize information.
Definition: window_gui.h:322
MakeCompanyButtonRows
NWidgetBase * MakeCompanyButtonRows(int *biggest_index, int widget_first, int widget_last, int max_length, StringID button_tooltip)
Make a number of rows with button-like graphics, for enabling/disabling each company.
Definition: widget.cpp:2871
CompanyEconomyEntry::performance_history
int32 performance_history
Company score (scale 0-1000)
Definition: company_base.h:26
Scrollbar::GetCount
uint16 GetCount() const
Gets the number of elements in the list.
Definition: widget_type.h:612
WID_PRD_COMPANY_LAST
@ WID_PRD_COMPANY_LAST
Last company.
Definition: graph_widget.h:65
CompanyProperties::num_valid_stat_ent
byte num_valid_stat_ent
Number of valid statistical entries in old_economy.
Definition: company_base.h:99
WID_GL_BACKGROUND
@ WID_GL_BACKGROUND
Background of the window.
Definition: graph_widget.h:18
Window::InitNested
void InitNested(WindowNumber number=0)
Perform complete initialization of the Window with nested widgets, to allow use.
Definition: window.cpp:1861
GraphLegendWindow
Definition: graph_gui.cpp:45
SCORE_END
@ SCORE_END
How many scores are there..
Definition: economy_type.h:57
Window::height
int height
Height of the window (number of pixels down in y direction)
Definition: window_gui.h:320
PaymentRatesGraphWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: graph_gui.cpp:1022
Window::SetDirty
void SetDirty() const
Mark entire window as dirty (in need of re-paint)
Definition: window.cpp:984
WD_FRAMERECT_LEFT
@ WD_FRAMERECT_LEFT
Offset at left to draw the frame rectangular area.
Definition: window_gui.h:60
FS_SMALL
@ FS_SMALL
Index of the small font in the font tables.
Definition: gfx_type.h:208
WD_FRAMERECT_RIGHT
@ WD_FRAMERECT_RIGHT
Offset at right to draw the frame rectangular area.
Definition: window_gui.h:61
BaseGraphWindow::UpdateStatistics
void UpdateStatistics(bool initialize)
Update the statistics.
Definition: graph_gui.cpp:563
WD_FRAMERECT_BOTTOM
@ WD_FRAMERECT_BOTTOM
Offset at bottom to draw the frame rectangular area.
Definition: window_gui.h:63
WWT_PUSHTXTBTN
@ WWT_PUSHTXTBTN
Normal push-button (no toggle button) with text caption.
Definition: widget_type.h:102
PaymentRatesGraphWindow::line_height
uint line_height
Pixel height of each cargo type row.
Definition: graph_gui.cpp:872
NWidgetBase
Baseclass for nested widgets.
Definition: widget_type.h:124
SetMatrixDataTip
static NWidgetPart SetMatrixDataTip(uint8 cols, uint8 rows, StringID tip)
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
Definition: widget_type.h:1031
WID_CPR_ENABLE_CARGOES
@ WID_CPR_ENABLE_CARGOES
Enable cargoes button.
Definition: graph_widget.h:48
BaseGraphWindow::excluded_data
uint64 excluded_data
bitmask of the datasets that shouldn't be displayed.
Definition: graph_gui.cpp:174
WID_CPR_GRAPH
@ WID_CPR_GRAPH
Graph itself.
Definition: graph_widget.h:45
Window::SetWidgetDisabledState
void SetWidgetDisabledState(byte widget_index, bool disab_stat)
Sets the enabled/disabled status of a widget.
Definition: window_gui.h:392
WID_PRD_COMPANY_FIRST
@ WID_PRD_COMPANY_FIRST
First company.
Definition: graph_widget.h:64
MAX_COMPANIES
@ MAX_COMPANIES
Maximum number of companies.
Definition: company_type.h:23
CompanyLeagueWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: graph_gui.cpp:1249
BaseGraphWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: graph_gui.cpp:537
CompanyLeagueWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: graph_gui.cpp:1199
safeguards.h
sortlist_type.h
WID_PRD_SCORE_LAST
@ WID_PRD_SCORE_LAST
Last entry in the score list.
Definition: graph_widget.h:62
Window::left
int left
x position of left edge of the window
Definition: window_gui.h:317
ValuesInterval::lowest
OverflowSafeInt64 lowest
Lowest value of this interval. Must be zero or less.
Definition: graph_gui.cpp:158
UpdateCompanyRatingAndValue
int UpdateCompanyRatingAndValue(Company *c, bool update)
if update is set to true, the economy is updated with this score (also the house is updated,...
Definition: economy.cpp:149
BaseGraphWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: graph_gui.cpp:553
CompanyLeagueWindow::PerformanceSorter
static bool PerformanceSorter(const Company *const &c1, const Company *const &c2)
Sort the company league by performance history.
Definition: graph_gui.cpp:1150
CompanyLeagueWindow::text_width
uint text_width
The width of the actual text.
Definition: graph_gui.cpp:1128
sprites.h
PaymentRatesGraphWindow::OnGameTick
void OnGameTick() override
Called once per (game) tick.
Definition: graph_gui.cpp:1012
Point
Coordinates of a point in 2D.
Definition: geometry_type.hpp:21
PerformanceHistoryGraphWindow
Definition: graph_gui.cpp:766
date_func.h
WC_INCOME_GRAPH
@ WC_INCOME_GRAPH
Income graph; Window numbers:
Definition: window_type.h:522
stdafx.h
PC_BLACK
static const uint8 PC_BLACK
Black palette colour.
Definition: gfx_func.h:204
Window::window_number
WindowNumber window_number
Window number within the window class.
Definition: window_gui.h:312
GfxFillRect
void GfxFillRect(int left, int top, int right, int bottom, int colour, FillRectMode mode)
Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen.
Definition: gfx.cpp:110
GUIList::NeedResort
bool NeedResort()
Check if a resort is needed next loop If used the resort timer will decrease every call till 0.
Definition: sortlist_type.h:199
SCORE_MAX
@ SCORE_MAX
The max score that can be in the performance history.
Definition: economy_type.h:59
WC_NONE
@ WC_NONE
No window, redirects to WC_MAIN_WINDOW.
Definition: window_type.h:38
_sorted_standard_cargo_specs_size
uint8 _sorted_standard_cargo_specs_size
Number of standard cargo specifications stored in the _sorted_cargo_specs array.
Definition: cargotype.cpp:133
NWID_VERTICAL
@ NWID_VERTICAL
Vertical container.
Definition: widget_type.h:75
NWidgetResizeBase::SetFill
void SetFill(uint fill_x, uint fill_y)
Set the filling of the widget from initial size.
Definition: widget.cpp:837
WID_CPR_FOOTER
@ WID_CPR_FOOTER
Footer.
Definition: graph_widget.h:47
FONT_HEIGHT_SMALL
#define FONT_HEIGHT_SMALL
Height of characters in the small (FS_SMALL) font.
Definition: gfx_func.h:174
CompanyEconomyEntry::delivered_cargo
CargoArray delivered_cargo
The amount of delivered cargo.
Definition: company_base.h:25
DrawCompanyIcon
void DrawCompanyIcon(CompanyID c, int x, int y)
Draw the icon of a company.
Definition: company_cmd.cpp:141
BaseGraphWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: graph_gui.cpp:489
BaseGraphWindow::DrawGraph
void DrawGraph(Rect r) const
Actually draw the graph.
Definition: graph_gui.cpp:284
PerformanceRatingDetailWindow::UpdateWidgetSize
void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) override
Update size and resize step of a widget in the window.
Definition: graph_gui.cpp:1318
WC_PAYMENT_RATES
@ WC_PAYMENT_RATES
Payment rates graph; Window numbers:
Definition: window_type.h:558
GetSpriteSize
Dimension GetSpriteSize(SpriteID sprid, Point *offset, ZoomLevel zoom)
Get the size of a sprite.
Definition: gfx.cpp:909
WWT_CLOSEBOX
@ WWT_CLOSEBOX
Close box (at top-left of a window)
Definition: widget_type.h:67
WWT_RESIZEBOX
@ WWT_RESIZEBOX
Resize box (normally at bottom-right of a window)
Definition: widget_type.h:66
ValuesInterval
Contains the interval of a graph's data.
Definition: graph_gui.cpp:156
GUIList::NeedRebuild
bool NeedRebuild() const
Check if a rebuild is needed.
Definition: sortlist_type.h:362
WC_COMPANY_VALUE
@ WC_COMPANY_VALUE
Company value graph; Window numbers:
Definition: window_type.h:546
CompanyEconomyEntry::expenses
Money expenses
The amount of expenses.
Definition: company_base.h:24
StringID
uint32 StringID
Numeric value that represents a string, independent of the selected language.
Definition: strings_type.h:16
EndContainer
static NWidgetPart EndContainer()
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME,...
Definition: widget_type.h:998
Pool::PoolItem<&_company_pool >::Iterate
static Pool::IterateWrapper< Titem > Iterate(size_t from=0)
Returns an iterable ensemble of all valid Titem.
Definition: pool_type.hpp:378
strings_func.h
NWID_VSCROLLBAR
@ NWID_VSCROLLBAR
Vertical scrollbar.
Definition: widget_type.h:82
graph_gui.h
NWidgetCore::SetDataTip
void SetDataTip(uint32 widget_data, StringID tool_tip)
Set data and tool tip of the nested widget.
Definition: widget.cpp:892
WC_PERFORMANCE_DETAIL
@ WC_PERFORMANCE_DETAIL
Performance detail window; Window numbers:
Definition: window_type.h:564
WID_CPR_MATRIX
@ WID_CPR_MATRIX
Cargo list.
Definition: graph_widget.h:50
IncomeGraphWindow
Definition: graph_gui.cpp:668
WWT_TEXT
@ WWT_TEXT
Pure simple text.
Definition: widget_type.h:56
FONT_HEIGHT_NORMAL
#define FONT_HEIGHT_NORMAL
Height of characters in the normal (FS_NORMAL) font.
Definition: gfx_func.h:177
NWidget
static NWidgetPart NWidget(WidgetType tp, Colours col, int16 idx=-1)
Widget part function for starting a new 'real' widget.
Definition: widget_type.h:1113
geometry_func.hpp
WID_PRD_SCORE_FIRST
@ WID_PRD_SCORE_FIRST
First entry in the score list.
Definition: graph_widget.h:61
SetDParamMaxValue
void SetDParamMaxValue(uint n, uint64 max_value, uint min_count, FontSize size)
Set DParam n to some number that is suitable for string size computations.
Definition: strings.cpp:104
SetMinimalSize
static NWidgetPart SetMinimalSize(int16 x, int16 y)
Widget part function for setting the minimal size.
Definition: widget_type.h:946
WWT_PANEL
@ WWT_PANEL
Simple depressed panel.
Definition: widget_type.h:48
BaseGraphWindow::MIN_GRID_PIXEL_SIZE
static const int MIN_GRID_PIXEL_SIZE
Minimum distance between graph lines.
Definition: graph_gui.cpp:172
WID_CPR_BACKGROUND
@ WID_CPR_BACKGROUND
Background of the window.
Definition: graph_widget.h:43
BaseGraphWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: graph_gui.cpp:525
NUM_CARGO
@ NUM_CARGO
Maximal number of cargo types in a game.
Definition: cargo_type.h:64
NWidgetVertical
Vertical container.
Definition: widget_type.h:476
Scrollbar::GetPosition
uint16 GetPosition() const
Gets the position of the first visible element in the list.
Definition: widget_type.h:630
cargotype.h
ScoreInfo::needed
int needed
How much you need to get the perfect score.
Definition: economy_type.h:66
GraphLegendWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: graph_gui.cpp:94
WD_RESIZEBOX_WIDTH
@ WD_RESIZEBOX_WIDTH
Width of a resize box widget.
Definition: window_gui.h:110
CargoSpec::name
StringID name
Name of this type of cargo.
Definition: cargotype.h:70
Window::FinishInitNested
void FinishInitNested(WindowNumber window_number=0)
Perform the second part of the initialization of a nested widget tree.
Definition: window.cpp:1848
BaseGraphWindow::GetYLabelWidth
uint GetYLabelWidth(ValuesInterval current_interval, int num_hori_lines) const
Get width for Y labels.
Definition: graph_gui.cpp:260
CompanyValueGraphWindow
Definition: graph_gui.cpp:822
NWID_SPACER
@ NWID_SPACER
Invisible widget that takes some space.
Definition: widget_type.h:77
PerformanceRatingDetailWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: graph_gui.cpp:1455
BaseGraphWindow::MIN_GRAPH_NUM_LINES_Y
static const int MIN_GRAPH_NUM_LINES_Y
Minimal number of horizontal lines to draw.
Definition: graph_gui.cpp:171
WID_CL_BACKGROUND
@ WID_CL_BACKGROUND
Background of the window.
Definition: graph_widget.h:56
WID_GL_LAST_COMPANY
@ WID_GL_LAST_COMPANY
Last company in the legend.
Definition: graph_widget.h:21
CompanyLeagueWindow::icon_width
uint icon_width
The width of the company icon.
Definition: graph_gui.cpp:1129
CompanyLeagueWindow::OnPaint
void OnPaint() override
The window must be repainted.
Definition: graph_gui.cpp:1163
GUIList::ForceResort
void ForceResort()
Force a resort next Sort call Reset the resort timer if used too.
Definition: sortlist_type.h:213
abs
static T abs(const T a)
Returns the absolute value of (scalar) variable.
Definition: math_func.hpp:21
CompanyLeagueWindow::OnGameTick
void OnGameTick() override
Called once per (game) tick.
Definition: graph_gui.cpp:1237
WID_CPR_HEADER
@ WID_CPR_HEADER
Header.
Definition: graph_widget.h:44
ScoreID
ScoreID
Score categories in the detailed performance rating.
Definition: economy_type.h:45
CompanyEconomyEntry::income
Money income
The amount of income.
Definition: company_base.h:23
BaseGraphWindow::cost
OverflowSafeInt64 cost[GRAPH_MAX_DATASETS][GRAPH_NUM_MONTHS]
Stored costs for the last GRAPH_NUM_MONTHS months.
Definition: graph_gui.cpp:193
DrawFrameRect
void DrawFrameRect(int left, int top, int right, int bottom, Colours colour, FrameFlags flags)
Draw frame rectangle.
Definition: widget.cpp:175
CompanyLeagueWindow::ordinal_width
uint ordinal_width
The width of the ordinal number.
Definition: graph_gui.cpp:1127
PaymentRatesGraphWindow::OnResize
void OnResize() override
Called after the window got resized.
Definition: graph_gui.cpp:1007
window_func.h
GUIList::ForceRebuild
void ForceRebuild()
Force that a rebuild is needed.
Definition: sortlist_type.h:370
ToggleBit
static T ToggleBit(T &x, const uint8 y)
Toggles a bit in a variable.
Definition: bitmath_func.hpp:181
Window::ToggleWidgetLoweredState
void ToggleWidgetLoweredState(byte widget_index)
Invert the lowered/raised status of a widget.
Definition: window_gui.h:463
GetCharacterHeight
int GetCharacterHeight(FontSize size)
Get height of a character for a given font size.
Definition: fontcache.cpp:61
SetBit
static T SetBit(T &x, const uint8 y)
Set a bit in a variable.
Definition: bitmath_func.hpp:121
graph_widget.h
lengthof
#define lengthof(x)
Return the length of an fixed size array.
Definition: stdafx.h:377
Window::width
int width
width of the window (number of pixels to the right in x direction)
Definition: window_gui.h:319
Scrollbar::SetCapacityFromWidget
void SetCapacityFromWidget(Window *w, int widget, int padding=0)
Set capacity of visible elements from the size and resize properties of a widget.
Definition: widget.cpp:1980
OverflowSafeInt< int64, INT64_MAX, INT64_MIN >
BaseGraphWindow::GRAPH_NUM_MONTHS
static const int GRAPH_NUM_MONTHS
Number of months displayed in the graph.
Definition: graph_gui.cpp:169
INVALID_COMPANY
@ INVALID_COMPANY
An invalid company.
Definition: company_type.h:30
SetFill
static NWidgetPart SetFill(uint fill_x, uint fill_y)
Widget part function for setting filling.
Definition: widget_type.h:982
PaymentRatesGraphWindow::OnHundredthTick
void OnHundredthTick() override
Called once every 100 (game) ticks, or once every 3s, whichever comes last.
Definition: graph_gui.cpp:1028
DeliveredCargoGraphWindow
Definition: graph_gui.cpp:717
GREY_SCALE
#define GREY_SCALE(level)
Return the colour for a particular greyscale level.
Definition: gfx_func.h:202
PaymentRatesGraphWindow::vscroll
Scrollbar * vscroll
Cargo list scrollbar.
Definition: graph_gui.cpp:873
Window
Data structure for an opened window.
Definition: window_gui.h:276
GUIList::RebuildDone
void RebuildDone()
Notify the sortlist that the rebuild is done.
Definition: sortlist_type.h:380
WID_CV_GRAPH
@ WID_CV_GRAPH
Graph itself.
Definition: graph_widget.h:28
Pool::PoolItem<&_company_pool >::IsValidID
static bool IsValidID(size_t index)
Tests whether given index can be used to get valid (non-nullptr) Titem.
Definition: pool_type.hpp:318
Window::RaiseWidget
void RaiseWidget(byte widget_index)
Marks a widget as raised.
Definition: window_gui.h:483
Window::DrawWidgets
void DrawWidgets() const
Paint all widgets of a window.
Definition: widget.cpp:602
NWidgetBackground
Nested widget with a child.
Definition: widget_type.h:544
BaseGraphWindow::OnGameTick
void OnGameTick() override
Called once per (game) tick.
Definition: graph_gui.cpp:543
PerformanceRatingDetailWindow::OnGameTick
void OnGameTick() override
Called once per (game) tick.
Definition: graph_gui.cpp:1469
MakeNWidgetCompanyLines
static NWidgetBase * MakeNWidgetCompanyLines(int *biggest_index)
Construct a vertical list of buttons, one for each company.
Definition: graph_gui.cpp:110
WID_CPR_DISABLE_CARGOES
@ WID_CPR_DISABLE_CARGOES
Disable cargoes button.
Definition: graph_widget.h:49
WC_OPERATING_PROFIT
@ WC_OPERATING_PROFIT
Operating profit graph; Window numbers:
Definition: window_type.h:528
Window::IsWidgetDisabled
bool IsWidgetDisabled(byte widget_index) const
Gets the enabled/disabled status of a widget.
Definition: window_gui.h:421
CompanyLeagueWindow::DrawWidget
void DrawWidget(const Rect &r, int widget) const override
Draw the contents of a nested widget.
Definition: graph_gui.cpp:1171
Rect
Specification of a rectangle with absolute coordinates of all edges.
Definition: geometry_type.hpp:47
Window::LowerWidget
void LowerWidget(byte widget_index)
Marks a widget as lowered.
Definition: window_gui.h:474
Company
Definition: company_base.h:110
_cur_month
Month _cur_month
Current month (0..11)
Definition: date.cpp:26
CompanyProperties::old_economy
CompanyEconomyEntry old_economy[MAX_HISTORY_QUARTERS]
Economic data of the company of the last MAX_HISTORY_QUARTERS quarters.
Definition: company_base.h:98
PerformanceRatingDetailWindow::OnInvalidateData
void OnInvalidateData(int data=0, bool gui_scope=true) override
Some data on this window has become invalid.
Definition: graph_gui.cpp:1483
NWidgetResizeBase::SetMinimalSize
void SetMinimalSize(uint min_x, uint min_y)
Set minimal size of the widget.
Definition: widget.cpp:815
TD_RTL
@ TD_RTL
Text is written right-to-left by default.
Definition: strings_type.h:24
DAY_TICKS
static const int DAY_TICKS
1 day is 74 ticks; _date_fract used to be uint16 and incremented by 885.
Definition: date_type.h:28
_current_text_dir
TextDirection _current_text_dir
Text direction of the currently selected language.
Definition: strings.cpp:48
OperatingProfitGraphWindow
Definition: graph_gui.cpp:617
ClientSettings::gui
GUISettings gui
settings related to the GUI
Definition: settings_type.h:565
WID_PHG_BACKGROUND
@ WID_PHG_BACKGROUND
Background of the window.
Definition: graph_widget.h:36
SetMinimalTextLines
static NWidgetPart SetMinimalTextLines(uint8 lines, uint8 spacing, FontSize size=FS_NORMAL)
Widget part function for setting the minimal text lines.
Definition: widget_type.h:964
_score_info
const ScoreInfo _score_info[]
Score info, values used for computing the detailed performance rating.
Definition: economy.cpp:83
GraphLegendWindow::OnClick
void OnClick(Point pt, int widget, int click_count) override
A click with the left mouse button has been made on the window.
Definition: graph_gui.cpp:75
WWT_SHADEBOX
@ WWT_SHADEBOX
Shade box (at top-right of a window, between WWT_DEBUGBOX and WWT_DEFSIZEBOX)
Definition: widget_type.h:62