diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 57ba0ae..40c9789 100644 --- a/src/toolbar_gui.cpp +++ b/src/toolbar_gui.cpp @@ -238,16 +238,15 @@ public: * @ingroup gui_group */ enum BottomToolbarGuiWidgets { - BTB_STATUS, ///< Status panel containing cash and rating readout. + BTB_MONEY, ///< Status panel containing the amount of cash. BTB_WEATHER, ///< Weather sprite. - BTB_TEMPERATURE, ///< Temperature in the park. - BTB_SPACING, ///< Status panel containing nothing (yet). + BTB_NEWS, ///< Status panel containing nothing (yet). BTB_VIEW_DIRECTION, ///< Status panel containing viewing direction. BTB_DATE, ///< Status panel containing date. + BTB_TEMPERATURE, ///< Temperature in the park. }; -static const uint32 BOTTOM_BAR_HEIGHT = 35; ///< Minimum Y-coord size of the bottom toolbar (BTB) panel. -static const uint32 BOTTOM_BAR_POSITION_X = 75; ///< Separation of the toolbar from the edge of the window. +static const uint32 BOTTOM_BAR_HEIGHT = 50; ///< Minimum Y-coord size of the bottom toolbar (BTB) panel. /** * Widget parts of the bottom toolbar GUI. @@ -256,18 +255,23 @@ static const uint32 BOTTOM_BAR_POSITION_X = 75; ///< Separation of the toolbar f * @todo Implement non-minimal default window size to prevent the need to compute remaining space manually. */ static const WidgetPart _bottom_toolbar_widgets[] = { - Intermediate(0, 1), + Intermediate(1, 0), Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN), - Intermediate(1, 0), SetPadding(0, 3, 0, 3), - Widget(WT_LEFT_TEXT, BTB_STATUS, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 30, 0), SetData(STR_ARG1, STR_NULL), - SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value - Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1), + Intermediate(0, 1), // Money, guests, rating + Widget(WT_CENTERED_TEXT, BTB_MONEY, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 3, 0), SetData(STR_ARG1, STR_NULL), + EndContainer(), + Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN), + Intermediate(0, 1), // News + Widget(WT_EMPTY, BTB_NEWS, COL_RANGE_ORANGE_BROWN), + EndContainer(), + Widget(WT_PANEL, INVALID_WIDGET_INDEX, COL_RANGE_ORANGE_BROWN), + Intermediate(2, 1), // Weather, date, draw direction + Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 3, 0), SetData(STR_ARG1, STR_NULL), + Intermediate(1, 3), + Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN), Widget(WT_RIGHT_TEXT, BTB_TEMPERATURE, COL_RANGE_ORANGE_BROWN), SetFill(1, 0), SetData(STR_ARG1, STR_NULL), - Widget(WT_EMPTY, BTB_SPACING, COL_RANGE_ORANGE_BROWN), SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value - Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN), SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value - Widget(WT_RIGHT_TEXT, BTB_DATE, COL_RANGE_ORANGE_BROWN), SetPadding(3, 0, 30, 0), SetData(STR_ARG1, STR_NULL), - SetMinimalSize(1, BOTTOM_BAR_HEIGHT), // Temp X value - EndContainer(), + Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1), + EndContainer(), EndContainer(), }; @@ -279,7 +283,7 @@ BottomToolbarWindow::BottomToolbarWindow() : GuiWindow(WC_BOTTOM_TOOLBAR, ALL_WI Point32 BottomToolbarWindow::OnInitialPosition() { static Point32 pt; - pt.x = BOTTOM_BAR_POSITION_X; + pt.x = 0; pt.y = _video.GetYSize() - BOTTOM_BAR_HEIGHT; return pt; } @@ -287,7 +291,7 @@ Point32 BottomToolbarWindow::OnInitialPosition() void BottomToolbarWindow::SetWidgetStringParameters(WidgetNumber wid_num) const { switch (wid_num) { - case BTB_STATUS: + case BTB_MONEY: _finances_manager.CashToStrParams(); break; @@ -314,7 +318,7 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid Point32 p(0, 0); switch (wid_num) { - case BTB_STATUS: + case BTB_MONEY: p = GetMoneyStringSize(LARGE_MONEY_AMOUNT); break; @@ -335,17 +339,17 @@ void BottomToolbarWindow::UpdateWidgetSize(WidgetNumber wid_num, BaseWidget *wid GetTextSize(STR_ARG1, &p.x, &p.y); break; - case BTB_SPACING: { + case BTB_NEWS: { _str_params.SetNumber(1, LARGE_TEMPERATURE); Point32 temp_size; GetTextSize(STR_ARG1, &temp_size.x, &temp_size.y); - int32 remaining = _video.GetXSize() - (2 * BOTTOM_BAR_POSITION_X); - remaining -= temp_size.x; - remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width; + int32 remaining = _video.GetXSize(); remaining -= GetMoneyStringSize(LARGE_MONEY_AMOUNT).x; - remaining -= GetMaxDateSize().x; - remaining -= _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).base.x; // It's the same size for all compass sprites. + /* Temperature + weather sprite are below date */ + remaining -= std::max(temp_size.x + _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width + + _sprite_manager.GetTableSpriteSize(SPR_GUI_COMPASS_START).width, + GetMaxDateSize().x); p = {remaining, (int32)BOTTOM_BAR_HEIGHT}; break; } diff --git a/src/window.cpp b/src/window.cpp index 641e9a4..fbd8e30 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -664,6 +664,8 @@ void WindowManager::ResetAllWindows() for (Window *w = this->top; w != nullptr; w = w->lower) { w->ResetSize(); /// \todo This call should preserve the window size as much as possible. } + + this->RepositionAllWindows(); _video.MarkDisplayDirty(); } @@ -676,12 +678,24 @@ void WindowManager::RepositionAllWindows() Viewport *vp = GetViewport(); if (vp == nullptr) return; Rectangle32 vp_rect = vp->rect; + for (Window *w = this->top; w != nullptr; w = w->lower) { - if (w->wtype == WC_MAINDISPLAY) continue; - /* Add an arbitrary amount for closebox/titlebar, - * so the window is still actually accessible. */ - if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20)) || w->wtype == WC_BOTTOM_TOOLBAR) { - w->SetPosition(w->OnInitialPosition()); + switch(w->wtype) { + case WC_MAINDISPLAY: + break; + + case WC_TOOLBAR: + case WC_BOTTOM_TOOLBAR: + w->SetPosition(w->OnInitialPosition()); + break; + + default: + /* Add an arbitrary amount for closebox/titlebar, + * so the window is still actually accessible. */ + if (!vp_rect.IsPointInside(Point32(w->rect.base.x + 20, w->rect.base.y + 20))) { + w->SetPosition(w->OnInitialPosition()); + } + break; } } }