Loading

Paste #pcpflxtiv

  1. diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
  2. index 57ba0ae..e661fdb 100644
  3. --- a/src/toolbar_gui.cpp
  4. +++ b/src/toolbar_gui.cpp
  5. @@ -227,6 +227,7 @@ public:
  6.     BottomToolbarWindow();
  7.  
  8.     Point32 OnInitialPosition() override;
  9. +   Point32 OnReposition() override;
  10.     void SetWidgetStringParameters(WidgetNumber wid_num) const override;
  11.     void OnChange(ChangeCode code, uint32 parameter) override;
  12.     void UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid) override;
  13. @@ -238,16 +239,15 @@ public:
  14.   * @ingroup gui_group
  15.   */
  16.  enum BottomToolbarGuiWidgets {
  17. -   BTB_STATUS,         ///< Status panel containing cash and rating readout.
  18. +   BTB_MONEY,          ///< Status panel containing the amount of cash.
  19.     BTB_WEATHER,        ///< Weather sprite.
  20. -   BTB_TEMPERATURE,    ///< Temperature in the park.
  21. -   BTB_SPACING,        ///< Status panel containing nothing (yet).
  22. +   BTB_NEWS,           ///< Status panel containing nothing (yet).
  23.     BTB_VIEW_DIRECTION, ///< Status panel containing viewing direction.
  24.     BTB_DATE,           ///< Status panel containing date.
  25. +   BTB_TEMPERATURE,    ///< Temperature in the park.
  26.  };
  27.  
  28. -static const uint32 BOTTOM_BAR_HEIGHT = 35;     ///< Minimum Y-coord size of the bottom toolbar (BTB) panel.
  29. -static const uint32 BOTTOM_BAR_POSITION_X = 75; ///< Separation of the toolbar from the edge of the window.
  30. +static const uint32 BOTTOM_BAR_HEIGHT = 50; ///< Minimum Y-coord size of the bottom toolbar (BTB) panel.
  31.  
  32.  /**
  33.   * Widget parts of the bottom toolbar GUI.
  34. @@ -256,17 +256,22 @@ static const uint32 BOTTOM_BAR_POSITION_X = 75; ///< Separation of the toolbar f
  35.   * @todo Implement non-minimal default window size to prevent the need to compute remaining space manually.
  36.   */
  37.  static const WidgetPart _bottom_toolbar_widgets[] = {
  38. -   Intermediate(0, 1),
  39. +   Intermediate(1, 0),
  40. +       Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  41. +           Intermediate(0, 1), // Money, guests, rating
  42. +               Widget(WT_CENTERED_TEXT, BTB_MONEY, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 3, 0), SetData(STR_ARG1, STR_NULL),
  43. +           EndContainer(),
  44.         Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  45. -           Intermediate(1, 0), SetPadding(0, 3, 0, 3),
  46. -               Widget(WT_LEFT_TEXT, BTB_STATUS, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 30, 0), SetData(STR_ARG1, STR_NULL),
  47. -                       SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value
  48. -               Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1),
  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. +           Intermediate(0, 1), // News
  55. +               Widget(WT_EMPTY, BTB_NEWS, COL_RANGE_ORANGE_BROWN), SetFill(1, 1), SetResize(1, 0),
  56. +           EndContainer(),
  57. +       Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN),
  58. +           Intermediate(2, 1), // Weather, date, draw direction
  59. +               Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 3, 0), SetData(STR_ARG1, STR_NULL),
  60. +               Intermediate(1, 3),
  61. +                   Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN),
  62. +                   Widget(WT_RIGHT_TEXT, BTB_TEMPERATURE, COL_RANGE_ORANGE_BROWN), SetFill(1, 0), SetData(STR_ARG1, STR_NULL),
  63. +                   Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1),
  64.             EndContainer(),
  65.     EndContainer(),
  66.  };
  67. @@ -278,16 +283,19 @@ BottomToolbarWindow::BottomToolbarWindow() : GuiWindow(WC_BOTTOM_TOOLBAR, ALL_WI
  68.  
  69.  Point32 BottomToolbarWindow::OnInitialPosition()
  70.  {
  71. -   static Point32 pt;
  72. -   pt.x = BOTTOM_BAR_POSITION_X;
  73. -   pt.y = _video.GetYSize() - BOTTOM_BAR_HEIGHT;
  74. -   return pt;
  75. +   return Point32(0, _video.GetYSize() - BOTTOM_BAR_HEIGHT);
  76. +}
  77. +
  78. +Point32 BottomToolbarWindow::OnReposition()
  79. +{
  80. +   this->ResetSize();
  81. +   return this->OnInitialPosition();
  82.  }
  83.  
  84.  void BottomToolbarWindow::SetWidgetStringParameters(WidgetNumber wid_num) const
  85.  {
  86.     switch (wid_num) {
  87. -       case BTB_STATUS:
  88. +       case BTB_MONEY:
  89.             _finances_manager.CashToStrParams();
  90.             break;
  91.  
  92. @@ -314,7 +322,7 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid
  93.     Point32 p(0, 0);
  94.  
  95.     switch (wid_num) {
  96. -       case BTB_STATUS:
  97. +       case BTB_MONEY:
  98.             p = GetMoneyStringSize(LARGE_MONEY_AMOUNT);
  99.             break;
  100.  
  101. @@ -335,17 +343,17 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid
  102.             GetTextSize(STR_ARG1, &p.x, &p.y);
  103.             break;
  104.  
  105. -       case BTB_SPACING: {
  106. +       case BTB_NEWS: {
  107.             _str_params.SetNumber(1, LARGE_TEMPERATURE);
  108.             Point32 temp_size;
  109.             GetTextSize(STR_ARG1, &temp_size.x, &temp_size.y);
  110.  
  111. -           int32 remaining = _video.GetXSize() - (2 * BOTTOM_BAR_POSITION_X);
  112. -           remaining -= temp_size.x;
  113. -           remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width;
  114. +           int32 remaining = _video.GetXSize();
  115.             remaining -= GetMoneyStringSize(LARGE_MONEY_AMOUNT).x;
  116. -           remaining -= GetMaxDateSize().x;
  117. -           remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).base.x; // It's the same size for all compass sprites.
  118. +           /* Temperature + weather sprite are below date */
  119. +           remaining -= std::max(temp_size.x + _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width
  120. +                                             + _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).width,
  121. +                                 GetMaxDateSize().x);
  122.             p = {remaining, (int32)BOTTOM_BAR_HEIGHT};
  123.             break;
  124.         }
  125. diff --git a/src/window.cpp b/src/window.cpp
  126. index ae89188..09bd396 100644
  127. --- a/src/window.cpp
  128. +++ b/src/window.cpp
  129. @@ -221,6 +221,11 @@ Point32 Window::OnInitialPosition()
  130.     return compute_pos.FindPosition(this);
  131.  }
  132.  
  133. +Point32 Window::OnReposition()
  134. +{
  135. +   return this->OnInitialPosition();
  136. +}
  137. +
  138.  /**
  139.   * Mark windows as being dirty (needing a repaint).
  140.   * @todo Marking the whole display as needing a repaint is too crude.
  141. @@ -678,6 +683,8 @@ void WindowManager::ResetAllWindows()
  142.         w->ResetSize();
  143.         w->SetSize(x_size, y_size);
  144.     }
  145. +
  146. +   this->RepositionAllWindows();
  147.     _video.MarkDisplayDirty();
  148.  }
  149.  
  150. @@ -690,12 +697,24 @@ void WindowManager::RepositionAllWindows()
  151.     Viewport *vp = GetViewport();
  152.     if (vp == nullptr) return;
  153.     Rectangle32 vp_rect = vp->rect;
  154. +
  155.     for (Window *w = this->top; w != nullptr; w = w->lower) {
  156. -       if (w->wtype == WC_MAINDISPLAY) continue;
  157. -       /* Add an arbitrary amount for closebox/titlebar,
  158. -        * so the window is still actually accessible. */
  159. -       if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20)) || w->wtype == WC_BOTTOM_TOOLBAR) {
  160. -           w->SetPosition(w->OnInitialPosition());
  161. +       switch(w->wtype) {
  162. +           case WC_MAINDISPLAY:
  163. +               break;
  164. +
  165. +           case WC_TOOLBAR:
  166. +           case WC_BOTTOM_TOOLBAR:
  167. +               w->SetPosition(w->OnReposition());
  168. +               break;
  169. +
  170. +           default:
  171. +               /* Add an arbitrary amount for closebox/titlebar,
  172. +                * so the window is still actually accessible. */
  173. +               if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20))) {
  174. +                   w->SetPosition(w->OnReposition());
  175. +               }
  176. +               break;
  177.         }
  178.     }
  179.  }
  180. diff --git a/src/window.h b/src/window.h
  181. index ee91933..3350bf0 100644
  182. --- a/src/window.h
  183. +++ b/src/window.h
  184. @@ -137,6 +137,7 @@ public:
  185.     void SetPosition(int x, int y);
  186.     void SetPosition(Point32 pos);
  187.     virtual Point32 OnInitialPosition();
  188. +   virtual Point32 OnReposition();
  189.  
  190.     void MarkDirty();
  191.  
  192.  

Comments