Loading

Paste #plvceywyl

  1. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
  2. index 57ba0ae..40c9789 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 = 50; ///< Minimum Y-coord size of the bottom toolbar (BTB) panel.
  23.  
  24.  /**
  25.   * Widget parts of the bottom toolbar GUI.
  26. @@ -256,18 +255,23 @@ static const uint32 BOTTOM_BAR_POSITION_X = 75; ///< Separation of the toolbar f
  27.   * @todo Implement non-minimal default window size to prevent the need to compute remaining space manually.
  28.   */
  29.  static const WidgetPart _bottom_toolbar_widgets[] = {
  30. -   Intermediate(0, 1),
  31. +   Intermediate(1, 0),
  32.         Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  33. -           Intermediate(1, 0), SetPadding(0, 3, 0, 3),
  34. -               Widget(WT_LEFT_TEXT, BTB_STATUS, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 30, 0), SetData(STR_ARG1, STR_NULL),
  35. -                       SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  36. -               Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1),
  37. +       Intermediate(0, 1), // Money, guests, rating
  38. +           Widget(WT_CENTERED_TEXT, BTB_MONEY, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 3, 0), SetData(STR_ARG1, STR_NULL),
  39. +       EndContainer(),
  40. +       Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  41. +       Intermediate(0, 1), // News
  42. +           Widget(WT_EMPTY, BTB_NEWS, COL_RANGE_ORANGE_BROWN),
  43. +       EndContainer(),
  44. +       Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  45. +       Intermediate(2, 1), // Weather, date, draw direction
  46. +           Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 3, 0), SetData(STR_ARG1, STR_NULL),
  47. +           Intermediate(1, 3),
  48. +               Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN),
  49.                 Widget(WT_RIGHT_TEXT, BTB_TEMPERATURE, COL_RANGE_ORANGE_BROWN), SetFill(1, 0), SetData(STR_ARG1, STR_NULL),
  50. -               Widget(WT_EMPTY, BTB_SPACING, COL_RANGE_ORANGE_BROWN), SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  51. -               Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN), SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  52. -               Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 30, 0), SetData(STR_ARG1, STR_NULL),
  53. -                       SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  54. -           EndContainer(),
  55. +               Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1),
  56. +       EndContainer(),
  57.     EndContainer(),
  58.  };
  59.  
  60. @@ -279,7 +283,7 @@ BottomToolbarWindow::BottomToolbarWindow() : GuiWindow(WC_BOTTOM_TOOLBAR, ALL_WI
  61.  Point32 BottomToolbarWindow::OnInitialPosition()
  62.  {
  63.     static Point32 pt;
  64. -   pt.x = BOTTOM_BAR_POSITION_X;
  65. +   pt.x = 0;
  66.     pt.y = _video.GetYSize() - BOTTOM_BAR_HEIGHT;
  67.     return pt;
  68.  }
  69. @@ -287,7 +291,7 @@ Point32 BottomToolbarWindow::OnInitialPosition()
  70.  void BottomToolbarWindow::SetWidgetStringParameters(WidgetNumber wid_num) const
  71.  {
  72.     switch (wid_num) {
  73. -       case BTB_STATUS:
  74. +       case BTB_MONEY:
  75.             _finances_manager.CashToStrParams();
  76.             break;
  77.  
  78. @@ -314,7 +318,7 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid
  79.     Point32 p(0, 0);
  80.  
  81.     switch (wid_num) {
  82. -       case BTB_STATUS:
  83. +       case BTB_MONEY:
  84.             p = GetMoneyStringSize(LARGE_MONEY_AMOUNT);
  85.             break;
  86.  
  87. @@ -335,17 +339,17 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid
  88.             GetTextSize(STR_ARG1, &p.x, &p.y);
  89.             break;
  90.  
  91. -       case BTB_SPACING: {
  92. +       case BTB_NEWS: {
  93.             _str_params.SetNumber(1, LARGE_TEMPERATURE);
  94.             Point32 temp_size;
  95.             GetTextSize(STR_ARG1, &temp_size.x, &temp_size.y);
  96.  
  97. -           int32 remaining = _video.GetXSize() - (2 * BOTTOM_BAR_POSITION_X);
  98. -           remaining -= temp_size.x;
  99. -           remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width;
  100. +           int32 remaining = _video.GetXSize();
  101.             remaining -= GetMoneyStringSize(LARGE_MONEY_AMOUNT).x;
  102. -           remaining -= GetMaxDateSize().x;
  103. -           remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).base.x; // It's the same size for all compass sprites.
  104. +           /* Temperature + weather sprite are below date */
  105. +           remaining -= std::max(temp_size.x + _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width
  106. +                                             + _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).width,
  107. +                                 GetMaxDateSize().x);
  108.             p = {remaining, (int32)BOTTOM_BAR_HEIGHT};
  109.             break;
  110.         }
  111. diff --git a/src/window.cpp b/src/window.cpp
  112. index 641e9a4..fbd8e30 100644
  113. --- a/src/window.cpp
  114. +++ b/src/window.cpp
  115. @@ -664,6 +664,8 @@ void WindowManager::ResetAllWindows()
  116.     for (Window *w = this->top; w != nullptr; w = w->lower) {
  117.         w->ResetSize(); /// \todo This call should preserve the window size as much as possible.
  118.     }
  119. +
  120. +   this->RepositionAllWindows();
  121.     _video.MarkDisplayDirty();
  122.  }
  123.  
  124. @@ -676,12 +678,24 @@ void WindowManager::RepositionAllWindows()
  125.     Viewport *vp = GetViewport();
  126.     if (vp == nullptr) return;
  127.     Rectangle32 vp_rect = vp->rect;
  128. +
  129.     for (Window *w = this->top; w != nullptr; w = w->lower) {
  130. -       if (w->wtype == WC_MAINDISPLAY) continue;
  131. -       /* Add an arbitrary amount for closebox/titlebar,
  132. -        * so the window is still actually accessible. */
  133. -       if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20)) || w->wtype == WC_BOTTOM_TOOLBAR) {
  134. -           w->SetPosition(w->OnInitialPosition());
  135. +       switch(w->wtype) {
  136. +           case WC_MAINDISPLAY:
  137. +               break;
  138. +
  139. +           case WC_TOOLBAR:
  140. +           case WC_BOTTOM_TOOLBAR:
  141. +               w->SetPosition(w->OnInitialPosition());
  142. +               break;
  143. +
  144. +           default:
  145. +               /* Add an arbitrary amount for closebox/titlebar,
  146. +                * so the window is still actually accessible. */
  147. +               if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20))) {
  148. +                   w->SetPosition(w->OnInitialPosition());
  149. +               }
  150. +               break;
  151.         }
  152.     }
  153.  }
  154.  

Comments