diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp index 57ba0ae..6410641 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 = 70; ///< Minimum Y-coord size of the bottom toolbar (BTB) panel. /** * Widget parts of the bottom toolbar GUI. @@ -259,14 +258,15 @@ static const WidgetPart _bottom_toolbar_widgets[] = { Intermediate(0, 1), 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), - 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 + Widget(WT_CENTERED_TEXT, BTB_MONEY, COL_RANGE_ORANGE_BROWN), SetPadding(3, 5, 30, 0), SetData(STR_ARG1, STR_NULL), + Widget(WT_EMPTY, BTB_NEWS, COL_RANGE_ORANGE_BROWN), + Widget(WT_EMPTY, BTB_VIEW_DIRECTION, COL_RANGE_ORANGE_BROWN), + Intermediate(2, 1), + 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 + Intermediate(1, 2), + Widget(WT_RIGHT_TEXT, BTB_TEMPERATURE, COL_RANGE_ORANGE_BROWN), SetFill(1, 0), SetData(STR_ARG1, STR_NULL), + Widget(WT_EMPTY, BTB_WEATHER, COL_RANGE_ORANGE_BROWN), SetPadding(3, 3, 3, 3), SetFill(0, 1), EndContainer(), EndContainer(), }; @@ -279,7 +279,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 +287,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 +314,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,16 +335,15 @@ 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(); + /* Temperature + weather sprite are below date */ + remaining -= std::max(temp_size.x + _sprite_manager.GetTableSpriteSize(SPR_GUI_WEATHER_START).width, GetMaxDateSize().x); 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. p = {remaining, (int32)BOTTOM_BAR_HEIGHT}; break; diff --git a/src/widget.cpp b/src/widget.cpp index 376677e..e662619 100644 --- a/src/widget.cpp +++ b/src/widget.cpp @@ -282,6 +282,10 @@ void LeafWidget::Draw(const GuiWindow *w) int right = w->GetWidgetScreenX(this) + this->pos.width - 1 - this->paddings[PAD_RIGHT]; int bottom = w->GetWidgetScreenY(this) + this->pos.height - 1 - this->paddings[PAD_BOTTOM]; + if (left < 0 || top < 0 || right > _video.GetXSize() || bottom > _video.GetYSize()) { + printf("Drawing widget outside window: l:%i, t:%i, r:%i, b:%i\n", left, top, right, bottom); + } + static Recolouring rc; rc.Set(0, RecolourEntry(COL_RANGE_BROWN, this->colour)); @@ -468,6 +472,10 @@ void DataWidget::Draw(const GuiWindow *w) int top = w->GetWidgetScreenY(this) + this->paddings[PAD_TOP]; int right = w->GetWidgetScreenX(this) + this->pos.width - 1 - this->paddings[PAD_RIGHT]; int bottom = w->GetWidgetScreenY(this) + this->pos.height - 1 - this->paddings[PAD_BOTTOM]; + if (left < 0 || top < 0 || right > _video.GetXSize() || bottom > _video.GetYSize()) { + printf("Drawing widget outside window: l:%i, t:%i, r:%i, b:%i\n", left, top, right, bottom); + } + Rectangle32 border_rect; if (bsd != nullptr) { left += bsd->border_left; @@ -956,6 +964,10 @@ void BackgroundWidget::Draw(const GuiWindow *w) assert(right - left + 1 >= 0); assert(bottom - top + 1 >= 0); + if (left < 0 || top < 0 || right > _video.GetXSize() || bottom > _video.GetYSize()) { + printf("Drawing widget outside window: l:%i, t:%i, r:%i, b:%i\n", left, top, right, bottom); + } + Rectangle32 rect(left, top, right - left + 1, bottom - top + 1); const BorderSpriteData &bsd = (this->wtype == WT_PANEL) ? _gui_sprites.panel : _gui_sprites.tabbar_panel; DrawBorderSprites(bsd, false, rect, this->colour);