Loading

Paste #pn4xnvlte

  1. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
  2. index 57ba0ae..6410641 100644
  3. --- a/src/toolbar_gui.cpp
  4. +++ b/src/toolbar_gui.cpp
  5. @@ -238,16 +238,15 @@ public:
  6.   * @ingroup gui_group
  7.   */
  8.  enum BottomToolbarGuiWidgets {
  9. -   BTB_STATUS,         ///< Status panel containing cash and rating readout.
  10. +   BTB_MONEY,          ///< Status panel containing the amount of cash.
  11.     BTB_WEATHER,        ///< Weather sprite.
  12. -   BTB_TEMPERATURE,    ///< Temperature in the park.
  13. -   BTB_SPACING,        ///< Status panel containing nothing (yet).
  14. +   BTB_NEWS,           ///< Status panel containing nothing (yet).
  15.     BTB_VIEW_DIRECTION, ///< Status panel containing viewing direction.
  16.     BTB_DATE,           ///< Status panel containing date.
  17. +   BTB_TEMPERATURE,    ///< Temperature in the park.
  18.  };
  19.  
  20. -static const uint32 BOTTOM_BAR_HEIGHT = 35;     ///< Minimum Y-coord size of the bottom toolbar (BTB) panel.
  21. -static const uint32 BOTTOM_BAR_POSITION_X = 75; ///< Separation of the toolbar from the edge of the window.
  22. +static const uint32 BOTTOM_BAR_HEIGHT = 70;     ///< Minimum Y-coord size of the bottom toolbar (BTB) panel.
  23.  
  24.  /**
  25.   * Widget parts of the bottom toolbar GUI.
  26. @@ -259,14 +258,15 @@ static const WidgetPart _bottom_toolbar_widgets[] = {
  27.     Intermediate(0, 1),
  28.         Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  29.             Intermediate(1, 0), SetPadding(0, 3, 0, 3),
  30. -               Widget(WT_LEFT_TEXT, BTB_STATUS, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 30, 0), SetData(STR_ARG1, STR_NULL),
  31. -                       SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  32. -               Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1),
  33. -               Widget(WT_RIGHT_TEXT, BTB_TEMPERATURE, COL_RANGE_ORANGE_BROWN), SetFill(1, 0), SetData(STR_ARG1, STR_NULL),
  34. -               Widget(WT_EMPTY, BTB_SPACING, COL_RANGE_ORANGE_BROWN), SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  35. -               Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN), SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  36. -               Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 30, 0), SetData(STR_ARG1, STR_NULL),
  37. -                       SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  38. +               Widget(WT_CENTERED_TEXT, BTB_MONEY, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 30, 0), SetData(STR_ARG1, STR_NULL),
  39. +               Widget(WT_EMPTY, BTB_NEWS, COL_RANGE_ORANGE_BROWN),
  40. +               Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN),
  41. +               Intermediate(2, 1),
  42. +                   Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 30, 0), SetData(STR_ARG1, STR_NULL),
  43. +                           SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  44. +                   Intermediate(1, 2),
  45. +                       Widget(WT_RIGHT_TEXT, BTB_TEMPERATURE, COL_RANGE_ORANGE_BROWN), SetFill(1, 0), SetData(STR_ARG1, STR_NULL),
  46. +                       Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1),
  47.             EndContainer(),
  48.     EndContainer(),
  49.  };
  50. @@ -279,7 +279,7 @@ BottomToolbarWindow::BottomToolbarWindow() : GuiWindow(WC_BOTTOM_TOOLBAR, ALL_WI
  51.  Point32 BottomToolbarWindow::OnInitialPosition()
  52.  {
  53.     static Point32 pt;
  54. -   pt.x = BOTTOM_BAR_POSITION_X;
  55. +   pt.x = 0;
  56.     pt.y = _video.GetYSize() - BOTTOM_BAR_HEIGHT;
  57.     return pt;
  58.  }
  59. @@ -287,7 +287,7 @@ Point32 BottomToolbarWindow::OnInitialPosition()
  60.  void BottomToolbarWindow::SetWidgetStringParameters(WidgetNumber wid_num) const
  61.  {
  62.     switch (wid_num) {
  63. -       case BTB_STATUS:
  64. +       case BTB_MONEY:
  65.             _finances_manager.CashToStrParams();
  66.             break;
  67.  
  68. @@ -314,7 +314,7 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid
  69.     Point32 p(0, 0);
  70.  
  71.     switch (wid_num) {
  72. -       case BTB_STATUS:
  73. +       case BTB_MONEY:
  74.             p = GetMoneyStringSize(LARGE_MONEY_AMOUNT);
  75.             break;
  76.  
  77. @@ -335,16 +335,15 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid
  78.             GetTextSize(STR_ARG1, &p.x, &p.y);
  79.             break;
  80.  
  81. -       case BTB_SPACING: {
  82. +       case BTB_NEWS: {
  83.             _str_params.SetNumber(1, LARGE_TEMPERATURE);
  84.             Point32 temp_size;
  85.             GetTextSize(STR_ARG1, &temp_size.x, &temp_size.y);
  86.  
  87. -           int32 remaining = _video.GetXSize() - (2 * BOTTOM_BAR_POSITION_X);
  88. -           remaining -= temp_size.x;
  89. -           remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width;
  90. +           int32 remaining = _video.GetXSize();
  91. +           /* Temperature + weather sprite are below date */
  92. +           remaining -= std::max(temp_size.x + _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width, GetMaxDateSize().x);
  93.             remaining -= GetMoneyStringSize(LARGE_MONEY_AMOUNT).x;
  94. -           remaining -= GetMaxDateSize().x;
  95.             remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).base.x; // It's the same size for all compass sprites.
  96.             p = {remaining, (int32)BOTTOM_BAR_HEIGHT};
  97.             break;
  98. diff --git a/src/widget.cpp b/src/widget.cpp
  99. index 376677e..e662619 100644
  100. --- a/src/widget.cpp
  101. +++ b/src/widget.cpp
  102. @@ -282,6 +282,10 @@ void LeafWidget::Draw(const GuiWindow *w)
  103.     int right  = w->GetWidgetScreenX(this) + this->pos.width - 1 - this->paddings[PAD_RIGHT];
  104.     int bottom = w->GetWidgetScreenY(this) + this->pos.height - 1 - this->paddings[PAD_BOTTOM];
  105.  
  106. +   if (left < 0 || top < 0 || right > _video.GetXSize() || bottom > _video.GetYSize()) {
  107. +       printf("Drawing widget outside window: l:%i, t:%i, r:%i, b:%i\n", left, top, right, bottom);
  108. +   }
  109. +
  110.     static Recolouring rc;
  111.     rc.Set(0, RecolourEntry(COL_RANGE_BROWN, this->colour));
  112.  
  113. @@ -468,6 +472,10 @@ void DataWidget::Draw(const GuiWindow *w)
  114.     int top    = w->GetWidgetScreenY(this) + this->paddings[PAD_TOP];
  115.     int right  = w->GetWidgetScreenX(this) + this->pos.width  - 1 - this->paddings[PAD_RIGHT];
  116.     int bottom = w->GetWidgetScreenY(this) + this->pos.height - 1 - this->paddings[PAD_BOTTOM];
  117. +   if (left < 0 || top < 0 || right > _video.GetXSize() || bottom > _video.GetYSize()) {
  118. +       printf("Drawing widget outside window: l:%i, t:%i, r:%i, b:%i\n", left, top, right, bottom);
  119. +   }
  120. +
  121.     Rectangle32 border_rect;
  122.     if (bsd != nullptr) {
  123.         left += bsd->border_left;
  124. @@ -956,6 +964,10 @@ void BackgroundWidget::Draw(const GuiWindow *w)
  125.     assert(right - left + 1 >= 0);
  126.     assert(bottom - top + 1 >= 0);
  127.  
  128. +   if (left < 0 || top < 0 || right > _video.GetXSize() || bottom > _video.GetYSize()) {
  129. +       printf("Drawing widget outside window: l:%i, t:%i, r:%i, b:%i\n", left, top, right, bottom);
  130. +   }
  131. +
  132.     Rectangle32 rect(left, top, right - left + 1, bottom - top + 1);
  133.     const BorderSpriteData &bsd = (this->wtype == WT_PANEL) ? _gui_sprites.panel : _gui_sprites.tabbar_panel;
  134.     DrawBorderSprites(bsd, false, rect, this->colour);
  135.  

Comments