forked from rosebudai/OpenRCT2-Web
Split off ParkInfoPanel and DateInfoPanel from GameBottomToolbar (#26919)
* Split off DateInfoPanel and ParkInfoPanel from GameBottomToolbar
* Replace gToolbarDirtyFlags (BottomToolbarDirtyFlag) with window invalidation
* Rename kGuestCountFormats{,Singular}
* Resize new panels along GUI
* Rename functions to match code style
* Remove some now-unnecessary widget resizing
* Rename panel widget indices to remove position
This commit is contained in:
1 parent
8ebe3965a2
commit
8dab2cce07
16 files changed
+624
-454
No files matched your search
@@ -3837,3 +3837,5 @@ STR_7037 :Operating mode
|
||||
STR_7038 :Wait and load
|
||||
STR_7039 :Ride type
|
||||
STR_7040 :Footpath additions
|
||||
STR_7041 :Park info panel
|
||||
STR_7042 :Date info panel
|
||||
@@ -1980,6 +1980,7 @@ namespace OpenRCT2
|
||||
STR_THEMES_WINDOW_CHANGE_KEYBOARD_SHORTCUT = 5221,
|
||||
STR_THEMES_WINDOW_CLEAR_SCENERY = 5195,
|
||||
STR_THEMES_WINDOW_CONSTRUCT_RIDE = 5201,
|
||||
STR_THEMES_WINDOW_DATE_INFO_PANEL = 7042,
|
||||
STR_THEMES_WINDOW_DEMOLISH_RIDE_PROMPT = 5224,
|
||||
STR_THEMES_WINDOW_EDITOR_INVENTION_LIST = 5211,
|
||||
STR_THEMES_WINDOW_EDITOR_OBJECT_SELECTION = 5210,
|
||||
@@ -2003,6 +2004,7 @@ namespace OpenRCT2
|
||||
STR_THEMES_WINDOW_NEW_CAMPAIGN = 5188,
|
||||
STR_THEMES_WINDOW_OPTIONS = 5219,
|
||||
STR_THEMES_WINDOW_PARK_INFORMATION = 5253,
|
||||
STR_THEMES_WINDOW_PARK_INFO_PANEL = 7041,
|
||||
STR_THEMES_WINDOW_PEEP = 5205,
|
||||
STR_THEMES_WINDOW_PLAYER = 5736,
|
||||
STR_THEMES_WINDOW_RECENT_NEWS = 5192,
|
||||
|
||||
@@ -74,6 +74,8 @@ public:
|
||||
return ClearSceneryOpen();
|
||||
case WindowClass::customCurrencyConfig:
|
||||
return CustomCurrencyOpen();
|
||||
case WindowClass::dateInfoPanel:
|
||||
return dateInfoPanelOpen();
|
||||
case WindowClass::debugPaint:
|
||||
return DebugPaintOpen();
|
||||
case WindowClass::editorInventionList:
|
||||
@@ -104,6 +106,8 @@ public:
|
||||
return NewRideOpen();
|
||||
case WindowClass::parkInformation:
|
||||
return ParkEntranceOpen();
|
||||
case WindowClass::parkInfoPanel:
|
||||
return parkInfoPanelOpen();
|
||||
case WindowClass::recentNews:
|
||||
return NewsOpen();
|
||||
case WindowClass::rideConstruction:
|
||||
@@ -500,29 +504,29 @@ public:
|
||||
}
|
||||
|
||||
case INTENT_ACTION_UPDATE_CLIMATE:
|
||||
gToolbarDirtyFlags.set(BottomToolbarDirtyFlag::weather);
|
||||
InvalidateByClass(WindowClass::dateInfoPanel);
|
||||
InvalidateByClass(WindowClass::guestList);
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_UPDATE_GUEST_COUNT:
|
||||
gToolbarDirtyFlags.set(BottomToolbarDirtyFlag::guestCount);
|
||||
InvalidateByClass(WindowClass::guestList);
|
||||
InvalidateByClass(WindowClass::parkInformation);
|
||||
InvalidateByClass(WindowClass::parkInfoPanel);
|
||||
WindowGuestListRefreshList();
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_UPDATE_PARK_RATING:
|
||||
gToolbarDirtyFlags.set(BottomToolbarDirtyFlag::parkRating);
|
||||
InvalidateByClass(WindowClass::parkInformation);
|
||||
InvalidateByClass(WindowClass::parkInfoPanel);
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_UPDATE_DATE:
|
||||
gToolbarDirtyFlags.set(BottomToolbarDirtyFlag::date);
|
||||
InvalidateByClass(WindowClass::dateInfoPanel);
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_UPDATE_CASH:
|
||||
InvalidateByClass(WindowClass::finances);
|
||||
gToolbarDirtyFlags.set(BottomToolbarDirtyFlag::money);
|
||||
InvalidateByClass(WindowClass::parkInfoPanel);
|
||||
break;
|
||||
|
||||
case INTENT_ACTION_UPDATE_BANNER:
|
||||
|
||||
@@ -171,19 +171,20 @@ static void ShortcutRemoveTopBottomToolbarToggle()
|
||||
windowMgr->CloseByClass(WindowClass::dropdown);
|
||||
windowMgr->CloseByClass(WindowClass::topToolbar);
|
||||
windowMgr->CloseByClass(WindowClass::bottomToolbar);
|
||||
windowMgr->CloseByClass(WindowClass::parkInfoPanel);
|
||||
windowMgr->CloseByClass(WindowClass::dateInfoPanel);
|
||||
}
|
||||
else if (gLegacyScene == LegacyScene::playing)
|
||||
{
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindow(WindowClass::bottomToolbar);
|
||||
ContextOpenWindow(WindowClass::parkInfoPanel);
|
||||
ContextOpenWindow(WindowClass::dateInfoPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gLegacyScene == LegacyScene::playing)
|
||||
{
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindow(WindowClass::bottomToolbar);
|
||||
}
|
||||
else
|
||||
{
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindowView(WindowView::editorBottomToolbar);
|
||||
}
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindowView(WindowView::editorBottomToolbar);
|
||||
}
|
||||
}
|
||||
GfxInvalidateScreen();
|
||||
|
||||
@@ -158,7 +158,9 @@ namespace OpenRCT2::Ui
|
||||
{
|
||||
// WindowClass WindowClassSZ WindowName windowColours
|
||||
{ WindowClass::topToolbar, "WC_TOP_TOOLBAR", STR_THEMES_WINDOW_TOP_TOOLBAR, { opaque(Drawing::Colour::lightBlue), opaque(Drawing::Colour::darkGreen), opaque(Drawing::Colour::darkBrown), opaque(Drawing::Colour::grey) } },
|
||||
{ WindowClass::bottomToolbar, "WC_BOTTOM_TOOLBAR", STR_THEMES_WINDOW_BOTTOM_TOOLBAR, { translucent(Drawing::Colour::darkGreen), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black), opaque(Drawing::Colour::brightGreen) } },
|
||||
{ WindowClass::bottomToolbar, "WC_BOTTOM_TOOLBAR", STR_THEMES_WINDOW_BOTTOM_TOOLBAR, { translucent(Drawing::Colour::darkGreen), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black) } },
|
||||
{ WindowClass::parkInfoPanel, "WC_PARK_INFO_PANEL", STR_THEMES_WINDOW_PARK_INFO_PANEL, { translucent(Drawing::Colour::darkGreen), opaque(Drawing::Colour::brightGreen) } },
|
||||
{ WindowClass::dateInfoPanel, "WC_DATE_INFO_PANEL", STR_THEMES_WINDOW_DATE_INFO_PANEL, { translucent(Drawing::Colour::darkGreen) } },
|
||||
{ WindowClass::ride, "WC_RIDE", STR_THEMES_WINDOW_RIDE, { opaque(Drawing::Colour::grey), opaque(Drawing::Colour::bordeauxRed), opaque(Drawing::Colour::saturatedGreen) } },
|
||||
{ WindowClass::rideConstruction, "WC_RIDE_CONSTRUCTION", STR_THEMES_WINDOW_RIDE_CONSTRUCTION, { opaque(Drawing::Colour::darkBrown), opaque(Drawing::Colour::darkBrown), opaque(Drawing::Colour::darkBrown) } },
|
||||
{ WindowClass::rideList, "WC_RIDE_LIST", STR_THEMES_WINDOW_RIDE_LIST, { opaque(Drawing::Colour::grey), opaque(Drawing::Colour::bordeauxRed), opaque(Drawing::Colour::bordeauxRed) } },
|
||||
@@ -232,7 +234,9 @@ namespace OpenRCT2::Ui
|
||||
|
||||
static constexpr std::array kPredefinedThemeRCT1Entries = std::to_array<UIThemeWindowEntry>({
|
||||
{ WindowClass::topToolbar, { opaque(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black) } },
|
||||
{ WindowClass::bottomToolbar, { translucent(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::voidBackground), opaque(Drawing::Colour::yellow), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black) } },
|
||||
{ WindowClass::bottomToolbar, { translucent(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::voidBackground) } },
|
||||
{ WindowClass::parkInfoPanel, { translucent(Drawing::Colour::grey), opaque(Drawing::Colour::yellow) } },
|
||||
{ WindowClass::dateInfoPanel, { translucent(Drawing::Colour::grey) } },
|
||||
{ WindowClass::ride, { opaque(Drawing::Colour::bordeauxRed), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::saturatedGreen), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black) } },
|
||||
{ WindowClass::rideList, { opaque(Drawing::Colour::bordeauxRed), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black) } },
|
||||
{ WindowClass::constructRide, { opaque(Drawing::Colour::bordeauxRed), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::grey), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black), opaque(Drawing::Colour::black) } },
|
||||
|
||||
@@ -174,6 +174,7 @@
|
||||
<ClCompile Include="windows\Cheats.cpp" />
|
||||
<ClCompile Include="windows\ClearScenery.cpp" />
|
||||
<ClCompile Include="windows\CustomCurrency.cpp" />
|
||||
<ClCompile Include="windows\DateInfoPanel.cpp" />
|
||||
<ClCompile Include="windows\DebugPaint.cpp" />
|
||||
<ClCompile Include="windows\DemolishRidePrompt.cpp" />
|
||||
<ClCompile Include="windows\Dropdown.cpp" />
|
||||
@@ -206,6 +207,7 @@
|
||||
<ClCompile Include="windows\Options.cpp" />
|
||||
<ClCompile Include="windows\OverwritePrompt.cpp" />
|
||||
<ClCompile Include="windows\Park.cpp" />
|
||||
<ClCompile Include="windows\ParkInfoPanel.cpp" />
|
||||
<ClCompile Include="windows\PatrolArea.cpp" />
|
||||
<ClCompile Include="windows\Player.cpp" />
|
||||
<ClCompile Include="windows\ProgressWindow.cpp" />
|
||||
|
||||
@@ -0,0 +1,192 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/interface/Window.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Rectangle.h>
|
||||
#include <openrct2/drawing/Text.h>
|
||||
#include <openrct2/localisation/Localisation.Date.h>
|
||||
#include <openrct2/ui/WindowManager.h>
|
||||
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
constexpr auto kPanelWidth = 142;
|
||||
|
||||
enum DateInfoPanelWidgetIdx : WidgetIndex
|
||||
{
|
||||
WIDX_PANEL_OUTSET,
|
||||
WIDX_PANEL_INSET,
|
||||
WIDX_DATE
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
static constexpr Widget kDateInfoPanelWidgets[] =
|
||||
{
|
||||
makeWidget({0, 0}, {kPanelWidth - 0, 34}, WidgetType::imgBtn, WindowColour::primary), // Right outset panel
|
||||
makeWidget({2, 2}, {kPanelWidth - 4, 30}, WidgetType::empty, WindowColour::primary), // Right inset panel
|
||||
makeWidget({2, 2}, {kPanelWidth - 4, 12}, WidgetType::hiddenButton, WindowColour::primary) // Date
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
class DateInfoPanel final : public Window
|
||||
{
|
||||
private:
|
||||
Drawing::Colour getHoverWidgetColour(WidgetIndex index)
|
||||
{
|
||||
return (
|
||||
gHoverWidget.windowClassification == WindowClass::dateInfoPanel && gHoverWidget.widgetIndex == index
|
||||
? static_cast<Drawing::Colour>(Drawing::Colour::white)
|
||||
: colours[0].colour);
|
||||
}
|
||||
|
||||
void drawPanel(RenderTarget& rt)
|
||||
{
|
||||
const auto& panelWidget = widgets[WIDX_PANEL_OUTSET];
|
||||
const auto topLeft = windowPos + ScreenCoordsXY{ panelWidget.left + 1, panelWidget.top + 1 };
|
||||
const auto bottomRight = windowPos + ScreenCoordsXY{ panelWidget.right - 1, panelWidget.bottom - 1 };
|
||||
|
||||
// Draw green inset rectangle on panel
|
||||
Rectangle::fillInset(
|
||||
rt, { topLeft, bottomRight }, colours[0], Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light,
|
||||
Rectangle::FillMode::none);
|
||||
|
||||
auto screenCoords = ScreenCoordsXY{ (panelWidget.left + panelWidget.right) / 2 + windowPos.x,
|
||||
panelWidget.top + windowPos.y + 2 };
|
||||
|
||||
// Date
|
||||
auto& date = GetDate();
|
||||
int32_t year = date.GetYear() + 1;
|
||||
int32_t month = date.GetMonth();
|
||||
int32_t day = date.GetDay();
|
||||
|
||||
auto colour = getHoverWidgetColour(WIDX_DATE);
|
||||
StringId stringId = DateFormatStringFormatIds[Config::Get().general.dateFormat];
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(DateDayNames[day]);
|
||||
ft.Add<int16_t>(month);
|
||||
ft.Add<int16_t>(year);
|
||||
drawText(rt, screenCoords, stringId, ft, { colour, TextAlignment::centre });
|
||||
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t line_height = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
// Temperature
|
||||
screenCoords = { windowPos.x + panelWidget.left + 15, static_cast<int32_t>(screenCoords.y + line_height + 1) };
|
||||
|
||||
int32_t temperature = getGameState().weatherCurrent.temperature;
|
||||
StringId format = STR_CELSIUS_VALUE;
|
||||
if (Config::Get().general.temperatureFormat == TemperatureUnit::fahrenheit)
|
||||
{
|
||||
temperature = Weather::celsiusToFahrenheit(temperature);
|
||||
format = STR_FAHRENHEIT_VALUE;
|
||||
}
|
||||
ft = Formatter();
|
||||
ft.Add<int16_t>(temperature);
|
||||
drawText(rt, screenCoords + ScreenCoordsXY{ 0, 6 }, format, ft);
|
||||
screenCoords.x += 30;
|
||||
|
||||
// Current weather
|
||||
auto currentWeatherSpriteId = Weather::getWeatherSpriteId(getGameState().weatherCurrent.weatherType);
|
||||
GfxDrawSprite(rt, ImageId(currentWeatherSpriteId), screenCoords);
|
||||
|
||||
// Next weather
|
||||
auto nextWeatherSpriteId = Weather::getWeatherSpriteId(getGameState().weatherNext.weatherType);
|
||||
if (currentWeatherSpriteId != nextWeatherSpriteId)
|
||||
{
|
||||
if (getGameState().weatherUpdateTimer < 960)
|
||||
{
|
||||
GfxDrawSprite(rt, ImageId(SPR_NEXT_WEATHER), screenCoords + ScreenCoordsXY{ 27, 5 });
|
||||
GfxDrawSprite(rt, ImageId(nextWeatherSpriteId), screenCoords + ScreenCoordsXY{ 40, 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
DateInfoPanel()
|
||||
{
|
||||
setWidgets(kDateInfoPanelWidgets);
|
||||
}
|
||||
|
||||
void onMouseUp(WidgetIndex widgetIndex) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_PANEL_OUTSET:
|
||||
case WIDX_DATE:
|
||||
ContextOpenWindow(WindowClass::recentNews);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void onPrepareDraw() override
|
||||
{
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t line_height = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
// Reset dimensions as appropriate -- in case we're switching languages.
|
||||
height = line_height * 2 + 12;
|
||||
windowPos.y = ContextGetHeight() - height;
|
||||
|
||||
// Change height of widgets in accordance with line height.
|
||||
widgets[WIDX_PANEL_OUTSET].bottom = line_height * 3 + 3;
|
||||
widgets[WIDX_PANEL_INSET].bottom = line_height * 3 + 1;
|
||||
widgets[WIDX_DATE].bottom = line_height + 1;
|
||||
}
|
||||
|
||||
void onDraw(RenderTarget& rt) override
|
||||
{
|
||||
const auto& rightWidget = widgets[WIDX_PANEL_OUTSET];
|
||||
|
||||
// Draw panel grey backgrounds
|
||||
auto leftTop = windowPos + ScreenCoordsXY{ rightWidget.left, rightWidget.top };
|
||||
auto rightBottom = windowPos + ScreenCoordsXY{ rightWidget.right, rightWidget.bottom };
|
||||
Rectangle::filter(rt, { leftTop, rightBottom }, FilterPaletteID::palette51);
|
||||
|
||||
drawWidgets(rt);
|
||||
|
||||
drawPanel(rt);
|
||||
}
|
||||
|
||||
CursorID onCursor(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID cursorId) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_DATE:
|
||||
gTooltipCloseTimeout = gCurrentRealTimeTicks + 2000;
|
||||
break;
|
||||
}
|
||||
return cursorId;
|
||||
}
|
||||
};
|
||||
|
||||
WindowBase* dateInfoPanelOpen()
|
||||
{
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t lineHeight = FontGetLineHeight(FontStyle::medium);
|
||||
int32_t panelHeight = lineHeight * 2 + 12;
|
||||
|
||||
auto* windowMgr = GetWindowManager();
|
||||
auto* window = windowMgr->Create<DateInfoPanel>(
|
||||
WindowClass::dateInfoPanel, ScreenCoordsXY(ContextGetWidth() - kPanelWidth - 1, ContextGetHeight() - panelHeight),
|
||||
{ kPanelWidth, panelHeight },
|
||||
{ WindowFlag::stickToFront, WindowFlag::transparent, WindowFlag::noBackground, WindowFlag::noTitleBar });
|
||||
|
||||
return window;
|
||||
}
|
||||
} // namespace OpenRCT2::Ui::Windows
|
||||
@@ -7,29 +7,21 @@
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../interface/Theme.h"
|
||||
|
||||
#include <openrct2-ui/interface/Theme.h>
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/interface/Window.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/drawing/Drawing.String.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Rectangle.h>
|
||||
#include <openrct2/drawing/RenderTarget.h>
|
||||
#include <openrct2/drawing/Text.h>
|
||||
#include <openrct2/entity/EntityRegistry.h>
|
||||
#include <openrct2/entity/Guest.h>
|
||||
#include <openrct2/entity/Staff.h>
|
||||
#include <openrct2/interface/ColourWithFlags.h>
|
||||
#include <openrct2/localisation/Formatter.h>
|
||||
#include <openrct2/localisation/Localisation.Date.h>
|
||||
#include <openrct2/localisation/StringIds.h>
|
||||
#include <openrct2/management/NewsItem.h>
|
||||
#include <openrct2/object/ObjectManager.h>
|
||||
@@ -43,207 +35,28 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
enum WindowGameBottomToolbarWidgetIdx : WidgetIndex
|
||||
{
|
||||
WIDX_LEFT_OUTSET,
|
||||
WIDX_LEFT_INSET,
|
||||
WIDX_MONEY,
|
||||
WIDX_GUESTS,
|
||||
WIDX_PARK_RATING,
|
||||
|
||||
WIDX_MIDDLE_OUTSET,
|
||||
WIDX_MIDDLE_INSET,
|
||||
WIDX_PANEL_OUTSET,
|
||||
WIDX_PANEL_INSET,
|
||||
WIDX_NEWS_SUBJECT,
|
||||
WIDX_NEWS_LOCATE,
|
||||
|
||||
WIDX_RIGHT_OUTSET,
|
||||
WIDX_RIGHT_INSET,
|
||||
WIDX_DATE
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
static constexpr Widget window_game_bottom_toolbar_widgets[] =
|
||||
static constexpr Widget kGameBottomToolbarWidgets[] =
|
||||
{
|
||||
makeWidget({ 0, 0}, {142, 34}, WidgetType::imgBtn, WindowColour::primary ), // Left outset panel
|
||||
makeWidget({ 2, 2}, {138, 30}, WidgetType::empty, WindowColour::primary ), // Left inset panel
|
||||
makeWidget({ 2, 1}, {138, 12}, WidgetType::hiddenButton,WindowColour::primary , 0xFFFFFFFF, STR_PROFIT_PER_WEEK_AND_PARK_VALUE_TIP), // Money window
|
||||
makeWidget({ 2, 11}, {138, 12}, WidgetType::hiddenButton,WindowColour::primary ), // Guests window
|
||||
makeWidget({ 2, 21}, {138, 11}, WidgetType::hiddenButton,WindowColour::primary , 0xFFFFFFFF, STR_PARK_RATING_TIP ), // Park rating window
|
||||
|
||||
makeWidget({142, 0}, {356, 34}, WidgetType::imgBtn, WindowColour::tertiary ), // Middle outset panel
|
||||
makeWidget({144, 2}, {352, 30}, WidgetType::hiddenButton,WindowColour::tertiary ), // Middle inset panel
|
||||
makeWidget({147, 5}, { 24, 24}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SHOW_SUBJECT_TIP ), // Associated news item window
|
||||
makeWidget({469, 5}, { 24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_LOCATE), STR_LOCATE_SUBJECT_TIP ), // Scroll to news item target
|
||||
|
||||
makeWidget({498, 0}, {142, 34}, WidgetType::imgBtn, WindowColour::primary ), // Right outset panel
|
||||
makeWidget({500, 2}, {138, 30}, WidgetType::empty, WindowColour::primary ), // Right inset panel
|
||||
makeWidget({500, 2}, {138, 12}, WidgetType::hiddenButton,WindowColour::primary ), // Date
|
||||
makeWidget({ 0, 0}, {356, 34}, WidgetType::imgBtn, WindowColour::tertiary ), // Middle outset panel
|
||||
makeWidget({ 2, 2}, {352, 30}, WidgetType::hiddenButton, WindowColour::tertiary ), // Middle inset panel
|
||||
makeWidget({ 5, 5}, { 24, 24}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SHOW_SUBJECT_TIP ), // Associated news item window
|
||||
makeWidget({327, 5}, { 24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_LOCATE), STR_LOCATE_SUBJECT_TIP) // Scroll to news item target
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
BottomToolbarDirtyFlags gToolbarDirtyFlags;
|
||||
|
||||
class GameBottomToolbar final : public Window
|
||||
{
|
||||
private:
|
||||
Drawing::Colour GetHoverWidgetColour(WidgetIndex index)
|
||||
{
|
||||
return (
|
||||
gHoverWidget.windowClassification == WindowClass::bottomToolbar && gHoverWidget.widgetIndex == index
|
||||
? static_cast<Drawing::Colour>(Drawing::Colour::white)
|
||||
: colours[0].colour);
|
||||
}
|
||||
|
||||
void DrawLeftPanel(RenderTarget& rt)
|
||||
{
|
||||
const auto& leftPanelWidget = widgets[WIDX_LEFT_OUTSET];
|
||||
|
||||
const auto topLeft = windowPos + ScreenCoordsXY{ leftPanelWidget.left + 1, leftPanelWidget.top + 1 };
|
||||
const auto bottomRight = windowPos + ScreenCoordsXY{ leftPanelWidget.right - 1, leftPanelWidget.bottom - 1 };
|
||||
// Draw green inset rectangle on panel
|
||||
Rectangle::fillInset(
|
||||
rt, { topLeft, bottomRight }, colours[0], Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light,
|
||||
Rectangle::FillMode::none);
|
||||
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t line_height = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
auto& gameState = getGameState();
|
||||
|
||||
// Draw money
|
||||
if (!gameState.park.flags.has(ParkFlag::noMoney))
|
||||
{
|
||||
const auto& widget = widgets[WIDX_MONEY];
|
||||
auto screenCoords = ScreenCoordsXY{ windowPos.x + widget.midX(),
|
||||
windowPos.y + widget.midY() - (line_height == 10 ? 5 : 6) };
|
||||
|
||||
auto colour = GetHoverWidgetColour(WIDX_MONEY);
|
||||
StringId stringId = gameState.park.cash < 0 ? STR_BOTTOM_TOOLBAR_CASH_NEGATIVE : STR_BOTTOM_TOOLBAR_CASH;
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(gameState.park.cash);
|
||||
drawText(rt, screenCoords, stringId, ft, { colour, TextAlignment::centre });
|
||||
}
|
||||
|
||||
static constexpr StringId _guestCountFormats[] = {
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_STABLE,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_DECREASE,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_INCREASE,
|
||||
};
|
||||
|
||||
static constexpr StringId _guestCountFormatsSingular[] = {
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_STABLE_SINGULAR,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_DECREASE_SINGULAR,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_INCREASE_SINGULAR,
|
||||
};
|
||||
|
||||
// Draw guests
|
||||
{
|
||||
const auto& widget = widgets[WIDX_GUESTS];
|
||||
auto screenCoords = ScreenCoordsXY{ windowPos.x + widget.midX(), windowPos.y + widget.midY() - 6 };
|
||||
|
||||
StringId stringId = gameState.park.numGuestsInPark == 1
|
||||
? _guestCountFormatsSingular[gameState.park.guestChangeModifier]
|
||||
: _guestCountFormats[gameState.park.guestChangeModifier];
|
||||
auto colour = GetHoverWidgetColour(WIDX_GUESTS);
|
||||
auto ft = Formatter();
|
||||
ft.Add<uint32_t>(gameState.park.numGuestsInPark);
|
||||
drawText(rt, screenCoords, stringId, ft, { colour, TextAlignment::centre });
|
||||
}
|
||||
|
||||
// Draw park rating
|
||||
{
|
||||
const auto& widget = widgets[WIDX_PARK_RATING];
|
||||
auto screenCoords = windowPos + ScreenCoordsXY{ widget.left + 11, widget.midY() - 5 };
|
||||
|
||||
DrawParkRating(
|
||||
rt, colours[3].colour, false, screenCoords, std::max(10, ((gameState.park.rating / 4) * 263) / 256));
|
||||
}
|
||||
}
|
||||
|
||||
void DrawParkRating(RenderTarget& rt, Colour colour, bool blink, const ScreenCoordsXY& coords, uint8_t factor)
|
||||
{
|
||||
int16_t bar_width = (factor * 114) / 255;
|
||||
Rectangle::fillInset(
|
||||
rt, { coords + ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 114, 9 } }, colours[0],
|
||||
Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light, Rectangle::FillMode::none);
|
||||
if (!blink || GameIsPaused() || (gCurrentRealTimeTicks & 8))
|
||||
{
|
||||
if (bar_width > 2)
|
||||
{
|
||||
Rectangle::fillInset(
|
||||
rt, { coords + ScreenCoordsXY{ 2, 2 }, coords + ScreenCoordsXY{ bar_width - 1, 8 } },
|
||||
ColourWithFlags{ colour });
|
||||
}
|
||||
}
|
||||
|
||||
// Draw thumbs on the sides
|
||||
GfxDrawSprite(rt, ImageId(SPR_RATING_LOW), coords - ScreenCoordsXY{ 14, 0 });
|
||||
GfxDrawSprite(rt, ImageId(SPR_RATING_HIGH), coords + ScreenCoordsXY{ 114, 0 });
|
||||
}
|
||||
|
||||
void DrawRightPanel(RenderTarget& rt)
|
||||
{
|
||||
const auto& rightPanelWidget = widgets[WIDX_RIGHT_OUTSET];
|
||||
|
||||
const auto topLeft = windowPos + ScreenCoordsXY{ rightPanelWidget.left + 1, rightPanelWidget.top + 1 };
|
||||
const auto bottomRight = windowPos + ScreenCoordsXY{ rightPanelWidget.right - 1, rightPanelWidget.bottom - 1 };
|
||||
// Draw green inset rectangle on panel
|
||||
Rectangle::fillInset(
|
||||
rt, { topLeft, bottomRight }, colours[0], Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light,
|
||||
Rectangle::FillMode::none);
|
||||
|
||||
auto screenCoords = ScreenCoordsXY{ (rightPanelWidget.left + rightPanelWidget.right) / 2 + windowPos.x,
|
||||
rightPanelWidget.top + windowPos.y + 2 };
|
||||
|
||||
// Date
|
||||
auto& date = GetDate();
|
||||
int32_t year = date.GetYear() + 1;
|
||||
int32_t month = date.GetMonth();
|
||||
int32_t day = date.GetDay();
|
||||
|
||||
auto colour = GetHoverWidgetColour(WIDX_DATE);
|
||||
StringId stringId = DateFormatStringFormatIds[Config::Get().general.dateFormat];
|
||||
auto ft = Formatter();
|
||||
ft.Add<StringId>(DateDayNames[day]);
|
||||
ft.Add<int16_t>(month);
|
||||
ft.Add<int16_t>(year);
|
||||
drawText(rt, screenCoords, stringId, ft, { colour, TextAlignment::centre });
|
||||
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t line_height = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
// Temperature
|
||||
screenCoords = { windowPos.x + rightPanelWidget.left + 15, static_cast<int32_t>(screenCoords.y + line_height + 1) };
|
||||
|
||||
int32_t temperature = getGameState().weatherCurrent.temperature;
|
||||
StringId format = STR_CELSIUS_VALUE;
|
||||
if (Config::Get().general.temperatureFormat == TemperatureUnit::fahrenheit)
|
||||
{
|
||||
temperature = Weather::celsiusToFahrenheit(temperature);
|
||||
format = STR_FAHRENHEIT_VALUE;
|
||||
}
|
||||
ft = Formatter();
|
||||
ft.Add<int16_t>(temperature);
|
||||
drawText(rt, screenCoords + ScreenCoordsXY{ 0, 6 }, format, ft);
|
||||
screenCoords.x += 30;
|
||||
|
||||
// Current weather
|
||||
auto currentWeatherSpriteId = Weather::getWeatherSpriteId(getGameState().weatherCurrent.weatherType);
|
||||
GfxDrawSprite(rt, ImageId(currentWeatherSpriteId), screenCoords);
|
||||
|
||||
// Next weather
|
||||
auto nextWeatherSpriteId = Weather::getWeatherSpriteId(getGameState().weatherNext.weatherType);
|
||||
if (currentWeatherSpriteId != nextWeatherSpriteId)
|
||||
{
|
||||
if (getGameState().weatherUpdateTimer < 960)
|
||||
{
|
||||
GfxDrawSprite(rt, ImageId(SPR_NEXT_WEATHER), screenCoords + ScreenCoordsXY{ 27, 5 });
|
||||
GfxDrawSprite(rt, ImageId(nextWeatherSpriteId), screenCoords + ScreenCoordsXY{ 40, 0 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawNewsItem(RenderTarget& rt)
|
||||
{
|
||||
const auto& middleOutsetWidget = widgets[WIDX_MIDDLE_OUTSET];
|
||||
const auto& middleOutsetWidget = widgets[WIDX_PANEL_OUTSET];
|
||||
auto* newsItem = News::GetItem(0);
|
||||
|
||||
// Current news item
|
||||
@@ -359,7 +172,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void DrawMiddlePanel(RenderTarget& rt)
|
||||
{
|
||||
Widget* middleOutsetWidget = &widgets[WIDX_MIDDLE_OUTSET];
|
||||
Widget* middleOutsetWidget = &widgets[WIDX_PANEL_OUTSET];
|
||||
|
||||
Rectangle::fillInset(
|
||||
rt,
|
||||
@@ -391,50 +204,17 @@ namespace OpenRCT2::Ui::Windows
|
||||
}
|
||||
}
|
||||
|
||||
void InvalidateDirtyWidgets()
|
||||
{
|
||||
if (gToolbarDirtyFlags.has(BottomToolbarDirtyFlag::money))
|
||||
{
|
||||
gToolbarDirtyFlags.unset(BottomToolbarDirtyFlag::money);
|
||||
invalidateWidget(WIDX_LEFT_INSET);
|
||||
}
|
||||
|
||||
if (gToolbarDirtyFlags.has(BottomToolbarDirtyFlag::date))
|
||||
{
|
||||
gToolbarDirtyFlags.unset(BottomToolbarDirtyFlag::date);
|
||||
invalidateWidget(WIDX_RIGHT_INSET);
|
||||
}
|
||||
|
||||
if (gToolbarDirtyFlags.has(BottomToolbarDirtyFlag::guestCount))
|
||||
{
|
||||
gToolbarDirtyFlags.unset(BottomToolbarDirtyFlag::guestCount);
|
||||
invalidateWidget(WIDX_LEFT_INSET);
|
||||
}
|
||||
|
||||
if (gToolbarDirtyFlags.has(BottomToolbarDirtyFlag::weather))
|
||||
{
|
||||
gToolbarDirtyFlags.unset(BottomToolbarDirtyFlag::weather);
|
||||
invalidateWidget(WIDX_RIGHT_INSET);
|
||||
}
|
||||
|
||||
if (gToolbarDirtyFlags.has(BottomToolbarDirtyFlag::parkRating))
|
||||
{
|
||||
gToolbarDirtyFlags.unset(BottomToolbarDirtyFlag::parkRating);
|
||||
invalidateWidget(WIDX_LEFT_INSET);
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
GameBottomToolbar()
|
||||
{
|
||||
setWidgets(window_game_bottom_toolbar_widgets);
|
||||
setWidgets(kGameBottomToolbarWidgets);
|
||||
|
||||
currentFrame = 0;
|
||||
initScrollWidgets();
|
||||
|
||||
// Reset the middle widget to not show by default.
|
||||
// If it is required to be shown news_update will reshow it.
|
||||
widgets[WIDX_MIDDLE_OUTSET].setHidden();
|
||||
widgets[WIDX_PANEL_OUTSET].setHidden();
|
||||
}
|
||||
|
||||
void onMouseUp(WidgetIndex widgetIndex) override
|
||||
@@ -443,18 +223,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_LEFT_OUTSET:
|
||||
case WIDX_MONEY:
|
||||
if (!getGameState().park.flags.has(ParkFlag::noMoney))
|
||||
ContextOpenWindow(WindowClass::finances);
|
||||
break;
|
||||
case WIDX_GUESTS:
|
||||
ContextOpenWindowView(WindowView::parkGuests);
|
||||
break;
|
||||
case WIDX_PARK_RATING:
|
||||
ContextOpenWindowView(WindowView::parkRating);
|
||||
break;
|
||||
case WIDX_MIDDLE_INSET:
|
||||
case WIDX_PANEL_INSET:
|
||||
if (News::IsQueueEmpty())
|
||||
{
|
||||
ContextOpenWindow(WindowClass::recentNews);
|
||||
@@ -485,31 +254,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
WindowScrollToLocation(*mainWindow, subjectLoc.value());
|
||||
}
|
||||
break;
|
||||
case WIDX_RIGHT_OUTSET:
|
||||
case WIDX_DATE:
|
||||
ContextOpenWindow(WindowClass::recentNews);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StringWithArgs onTooltip(WidgetIndex widgetIndex, StringId fallback) override
|
||||
{
|
||||
const auto& gameState = getGameState();
|
||||
auto ft = Formatter();
|
||||
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_MONEY:
|
||||
ft.Add<money64>(gameState.park.currentProfit);
|
||||
ft.Add<money64>(gameState.park.value);
|
||||
break;
|
||||
case WIDX_PARK_RATING:
|
||||
ft.Add<int16_t>(gameState.park.rating);
|
||||
break;
|
||||
}
|
||||
return { fallback, ft };
|
||||
}
|
||||
|
||||
void onPrepareDraw() override
|
||||
{
|
||||
// Figure out how much line height we have to work with.
|
||||
@@ -520,79 +267,38 @@ namespace OpenRCT2::Ui::Windows
|
||||
windowPos.y = ContextGetHeight() - height;
|
||||
|
||||
// Change height of widgets in accordance with line height.
|
||||
widgets[WIDX_LEFT_OUTSET].bottom = widgets[WIDX_MIDDLE_OUTSET].bottom = widgets[WIDX_RIGHT_OUTSET].bottom
|
||||
= line_height * 3 + 3;
|
||||
widgets[WIDX_LEFT_INSET].bottom = widgets[WIDX_MIDDLE_INSET].bottom = widgets[WIDX_RIGHT_INSET].bottom = line_height
|
||||
* 3
|
||||
+ 1;
|
||||
|
||||
// Reposition left widgets in accordance with line height... depending on whether there is money in play.
|
||||
if (getGameState().park.flags.has(ParkFlag::noMoney))
|
||||
{
|
||||
widgets[WIDX_MONEY].setHidden();
|
||||
widgets[WIDX_GUESTS].top = 1;
|
||||
widgets[WIDX_GUESTS].bottom = line_height + 7;
|
||||
widgets[WIDX_PARK_RATING].top = line_height + 8;
|
||||
widgets[WIDX_PARK_RATING].bottom = height - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
widgets[WIDX_MONEY].setVisible();
|
||||
widgets[WIDX_MONEY].bottom = widgets[WIDX_MONEY].top + line_height;
|
||||
widgets[WIDX_GUESTS].top = widgets[WIDX_MONEY].bottom + 1;
|
||||
widgets[WIDX_GUESTS].bottom = widgets[WIDX_GUESTS].top + line_height;
|
||||
widgets[WIDX_PARK_RATING].top = widgets[WIDX_GUESTS].bottom - 1;
|
||||
widgets[WIDX_PARK_RATING].bottom = height - 1;
|
||||
}
|
||||
|
||||
// Reposition right widgets in accordance with line height, too.
|
||||
widgets[WIDX_DATE].bottom = line_height + 1;
|
||||
widgets[WIDX_PANEL_OUTSET].bottom = line_height * 3 + 3;
|
||||
widgets[WIDX_PANEL_INSET].bottom = line_height * 3 + 1;
|
||||
|
||||
// Anchor the middle and right panel to the right
|
||||
int32_t x = ContextGetWidth();
|
||||
width = x;
|
||||
x--;
|
||||
widgets[WIDX_RIGHT_OUTSET].right = x;
|
||||
x -= 2;
|
||||
widgets[WIDX_RIGHT_INSET].right = x;
|
||||
x -= 137;
|
||||
widgets[WIDX_RIGHT_INSET].left = x;
|
||||
x -= 2;
|
||||
widgets[WIDX_RIGHT_OUTSET].left = x;
|
||||
x--;
|
||||
widgets[WIDX_MIDDLE_OUTSET].right = x;
|
||||
x -= 2;
|
||||
widgets[WIDX_MIDDLE_INSET].right = x;
|
||||
x -= 3;
|
||||
widgets[WIDX_NEWS_LOCATE].right = x;
|
||||
x -= 23;
|
||||
widgets[WIDX_NEWS_LOCATE].left = x;
|
||||
widgets[WIDX_DATE].left = widgets[WIDX_RIGHT_OUTSET].left + 2;
|
||||
widgets[WIDX_DATE].right = widgets[WIDX_RIGHT_OUTSET].right - 2;
|
||||
widgets[WIDX_PANEL_OUTSET].right = width - 1;
|
||||
widgets[WIDX_PANEL_INSET].right = width - 3;
|
||||
widgets[WIDX_NEWS_LOCATE].right = width - 6;
|
||||
widgets[WIDX_NEWS_LOCATE].left = widgets[WIDX_NEWS_LOCATE].right - 24;
|
||||
|
||||
if (News::IsQueueEmpty())
|
||||
{
|
||||
bool useFullToolbar = ThemeGetFlags() & UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR;
|
||||
widgets[WIDX_MIDDLE_OUTSET].setVisible(useFullToolbar);
|
||||
widgets[WIDX_MIDDLE_INSET].setVisible(useFullToolbar);
|
||||
widgets[WIDX_PANEL_OUTSET].setVisible(useFullToolbar);
|
||||
widgets[WIDX_PANEL_INSET].setVisible(useFullToolbar);
|
||||
widgets[WIDX_NEWS_SUBJECT].setHidden();
|
||||
widgets[WIDX_NEWS_LOCATE].setHidden();
|
||||
|
||||
if (useFullToolbar)
|
||||
{
|
||||
widgets[WIDX_MIDDLE_OUTSET].colour = 0;
|
||||
widgets[WIDX_MIDDLE_INSET].colour = 0;
|
||||
widgets[WIDX_PANEL_OUTSET].colour = 0;
|
||||
widgets[WIDX_PANEL_INSET].colour = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
News::Item* newsItem = News::GetItem(0);
|
||||
widgets[WIDX_MIDDLE_OUTSET].setVisible();
|
||||
widgets[WIDX_MIDDLE_INSET].setVisible();
|
||||
widgets[WIDX_PANEL_OUTSET].setVisible();
|
||||
widgets[WIDX_PANEL_INSET].setVisible();
|
||||
widgets[WIDX_NEWS_SUBJECT].setVisible();
|
||||
widgets[WIDX_NEWS_LOCATE].setVisible();
|
||||
widgets[WIDX_MIDDLE_OUTSET].colour = 2;
|
||||
widgets[WIDX_MIDDLE_INSET].colour = 2;
|
||||
widgets[WIDX_PANEL_OUTSET].colour = 2;
|
||||
widgets[WIDX_PANEL_INSET].colour = 2;
|
||||
setWidgetDisabled(WIDX_NEWS_SUBJECT, false);
|
||||
setWidgetDisabled(WIDX_NEWS_LOCATE, false);
|
||||
|
||||
@@ -618,32 +324,18 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void onDraw(RenderTarget& rt) override
|
||||
{
|
||||
const auto& leftWidget = widgets[WIDX_LEFT_OUTSET];
|
||||
const auto& rightWidget = widgets[WIDX_RIGHT_OUTSET];
|
||||
const auto& middleWidget = widgets[WIDX_MIDDLE_OUTSET];
|
||||
|
||||
// Draw panel grey backgrounds
|
||||
auto leftTop = windowPos + ScreenCoordsXY{ leftWidget.left, leftWidget.top };
|
||||
auto rightBottom = windowPos + ScreenCoordsXY{ leftWidget.right, leftWidget.bottom };
|
||||
Rectangle::filter(rt, { leftTop, rightBottom }, FilterPaletteID::palette51);
|
||||
|
||||
leftTop = windowPos + ScreenCoordsXY{ rightWidget.left, rightWidget.top };
|
||||
rightBottom = windowPos + ScreenCoordsXY{ rightWidget.right, rightWidget.bottom };
|
||||
Rectangle::filter(rt, { leftTop, rightBottom }, FilterPaletteID::palette51);
|
||||
const auto& middleWidget = widgets[WIDX_PANEL_OUTSET];
|
||||
|
||||
if (ThemeGetFlags() & UITHEME_FLAG_USE_FULL_BOTTOM_TOOLBAR)
|
||||
{
|
||||
// Draw grey background
|
||||
leftTop = windowPos + ScreenCoordsXY{ middleWidget.left, middleWidget.top };
|
||||
rightBottom = windowPos + ScreenCoordsXY{ middleWidget.right, middleWidget.bottom };
|
||||
auto leftTop = windowPos + ScreenCoordsXY{ middleWidget.left, middleWidget.top };
|
||||
auto rightBottom = windowPos + ScreenCoordsXY{ middleWidget.right, middleWidget.bottom };
|
||||
Rectangle::filter(rt, { leftTop, rightBottom }, FilterPaletteID::palette51);
|
||||
}
|
||||
|
||||
drawWidgets(rt);
|
||||
|
||||
DrawLeftPanel(rt);
|
||||
DrawRightPanel(rt);
|
||||
|
||||
if (!News::IsQueueEmpty())
|
||||
{
|
||||
DrawNewsItem(rt);
|
||||
@@ -659,27 +351,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
currentFrame++;
|
||||
if (currentFrame >= 24)
|
||||
currentFrame = 0;
|
||||
|
||||
InvalidateDirtyWidgets();
|
||||
}
|
||||
|
||||
CursorID onCursor(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID cursorId) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_MONEY:
|
||||
case WIDX_GUESTS:
|
||||
case WIDX_PARK_RATING:
|
||||
case WIDX_DATE:
|
||||
gTooltipCloseTimeout = gCurrentRealTimeTicks + 2000;
|
||||
break;
|
||||
}
|
||||
return cursorId;
|
||||
}
|
||||
|
||||
void onPeriodicUpdate() override
|
||||
{
|
||||
InvalidateDirtyWidgets();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -688,8 +359,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
*/
|
||||
WindowBase* GameBottomToolbarOpen()
|
||||
{
|
||||
int32_t screenWidth = ContextGetWidth();
|
||||
int32_t screenHeight = ContextGetHeight();
|
||||
// TODO: query ParkInfoPanel, DateInfoPanel
|
||||
constexpr auto kPanelWidth = 142;
|
||||
|
||||
// Toolbar width depends on whether we're showing panels besides
|
||||
// TODO: read config when applicable
|
||||
auto toolbarWidth = ContextGetWidth() - kPanelWidth * 2;
|
||||
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t lineHeight = FontGetLineHeight(FontStyle::medium);
|
||||
@@ -697,7 +372,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
auto* windowMgr = GetWindowManager();
|
||||
auto* window = windowMgr->Create<GameBottomToolbar>(
|
||||
WindowClass::bottomToolbar, ScreenCoordsXY(0, screenHeight - toolbarHeight), { screenWidth, toolbarHeight },
|
||||
WindowClass::bottomToolbar, ScreenCoordsXY(kPanelWidth, ContextGetHeight() - toolbarHeight),
|
||||
{ toolbarWidth, toolbarHeight },
|
||||
{ WindowFlag::stickToFront, WindowFlag::transparent, WindowFlag::noBackground, WindowFlag::noTitleBar });
|
||||
|
||||
return window;
|
||||
@@ -708,7 +384,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (gLegacyScene == LegacyScene::playing)
|
||||
{
|
||||
auto* windowMgr = GetWindowManager();
|
||||
windowMgr->InvalidateWidgetByClass(WindowClass::bottomToolbar, WIDX_MIDDLE_OUTSET);
|
||||
windowMgr->InvalidateWidgetByClass(WindowClass::bottomToolbar, WIDX_PANEL_OUTSET);
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2::Ui::Windows
|
||||
@@ -0,0 +1,264 @@
|
||||
/*****************************************************************************
|
||||
* Copyright (c) 2014-2026 OpenRCT2 developers
|
||||
*
|
||||
* For a complete list of all authors, please refer to contributors.md
|
||||
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
||||
*****************************************************************************/
|
||||
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/interface/Window.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/drawing/Rectangle.h>
|
||||
#include <openrct2/drawing/Text.h>
|
||||
#include <openrct2/ui/WindowManager.h>
|
||||
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
constexpr auto kPanelWidth = 142;
|
||||
|
||||
enum ParkInfoPanelWidgetIdx : WidgetIndex
|
||||
{
|
||||
WIDX_PANEL_OUTSET,
|
||||
WIDX_PANEL_INSET,
|
||||
WIDX_MONEY,
|
||||
WIDX_GUESTS,
|
||||
WIDX_PARK_RATING,
|
||||
};
|
||||
|
||||
// clang-format off
|
||||
static constexpr Widget kParkInfoPanelWidgets[] =
|
||||
{
|
||||
makeWidget({0, 0}, {kPanelWidth - 0, 34}, WidgetType::imgBtn, WindowColour::primary ), // Left outset panel
|
||||
makeWidget({2, 2}, {kPanelWidth - 4, 30}, WidgetType::empty, WindowColour::primary ), // Left inset panel
|
||||
makeWidget({2, 1}, {kPanelWidth - 4, 12}, WidgetType::hiddenButton, WindowColour::primary, 0xFFFFFFFF, STR_PROFIT_PER_WEEK_AND_PARK_VALUE_TIP), // Money
|
||||
makeWidget({2, 11}, {kPanelWidth - 4, 12}, WidgetType::hiddenButton, WindowColour::primary ), // Guests
|
||||
makeWidget({2, 21}, {kPanelWidth - 4, 11}, WidgetType::hiddenButton, WindowColour::primary, 0xFFFFFFFF, STR_PARK_RATING_TIP ) // Park rating
|
||||
};
|
||||
// clang-format on
|
||||
|
||||
class ParkInfoPanel final : public Window
|
||||
{
|
||||
private:
|
||||
Drawing::Colour getHoverWidgetColour(WidgetIndex index)
|
||||
{
|
||||
return (
|
||||
gHoverWidget.windowClassification == WindowClass::parkInfoPanel && gHoverWidget.widgetIndex == index
|
||||
? static_cast<Drawing::Colour>(Drawing::Colour::white)
|
||||
: colours[0].colour);
|
||||
}
|
||||
|
||||
void drawPanel(RenderTarget& rt)
|
||||
{
|
||||
const auto& panelWidget = widgets[WIDX_PANEL_OUTSET];
|
||||
const auto topLeft = windowPos + ScreenCoordsXY{ panelWidget.left + 1, panelWidget.top + 1 };
|
||||
const auto bottomRight = windowPos + ScreenCoordsXY{ panelWidget.right - 1, panelWidget.bottom - 1 };
|
||||
|
||||
// Draw green inset rectangle on panel
|
||||
Rectangle::fillInset(
|
||||
rt, { topLeft, bottomRight }, colours[0], Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light,
|
||||
Rectangle::FillMode::none);
|
||||
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t line_height = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
auto& gameState = getGameState();
|
||||
|
||||
// Draw money
|
||||
if (!gameState.park.flags.has(ParkFlag::noMoney))
|
||||
{
|
||||
const auto& widget = widgets[WIDX_MONEY];
|
||||
auto screenCoords = ScreenCoordsXY{ windowPos.x + widget.midX(),
|
||||
windowPos.y + widget.midY() - (line_height == 10 ? 5 : 6) };
|
||||
|
||||
auto colour = getHoverWidgetColour(WIDX_MONEY);
|
||||
StringId stringId = gameState.park.cash < 0 ? STR_BOTTOM_TOOLBAR_CASH_NEGATIVE : STR_BOTTOM_TOOLBAR_CASH;
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(gameState.park.cash);
|
||||
drawText(rt, screenCoords, stringId, ft, { colour, TextAlignment::centre });
|
||||
}
|
||||
|
||||
static constexpr StringId kGuestCountFormats[] = {
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_STABLE,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_DECREASE,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_INCREASE,
|
||||
};
|
||||
|
||||
static constexpr StringId kGuestCountFormatsSingular[] = {
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_STABLE_SINGULAR,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_DECREASE_SINGULAR,
|
||||
STR_BOTTOM_TOOLBAR_NUM_GUESTS_INCREASE_SINGULAR,
|
||||
};
|
||||
|
||||
// Draw guests
|
||||
{
|
||||
const auto& widget = widgets[WIDX_GUESTS];
|
||||
auto screenCoords = ScreenCoordsXY{ windowPos.x + widget.midX(), windowPos.y + widget.midY() - 6 };
|
||||
|
||||
StringId stringId = gameState.park.numGuestsInPark == 1
|
||||
? kGuestCountFormatsSingular[gameState.park.guestChangeModifier]
|
||||
: kGuestCountFormats[gameState.park.guestChangeModifier];
|
||||
auto colour = getHoverWidgetColour(WIDX_GUESTS);
|
||||
auto ft = Formatter();
|
||||
ft.Add<uint32_t>(gameState.park.numGuestsInPark);
|
||||
drawText(rt, screenCoords, stringId, ft, { colour, TextAlignment::centre });
|
||||
}
|
||||
|
||||
// Draw park rating
|
||||
{
|
||||
const auto& widget = widgets[WIDX_PARK_RATING];
|
||||
auto screenCoords = windowPos + ScreenCoordsXY{ widget.left + 11, widget.midY() - 5 };
|
||||
|
||||
drawParkRating(
|
||||
rt, colours[1].colour, false, screenCoords, std::max(10, ((gameState.park.rating / 4) * 263) / 256));
|
||||
}
|
||||
}
|
||||
|
||||
void drawParkRating(RenderTarget& rt, Colour colour, bool blink, const ScreenCoordsXY& coords, uint8_t factor)
|
||||
{
|
||||
int16_t bar_width = (factor * 114) / 255;
|
||||
Rectangle::fillInset(
|
||||
rt, { coords + ScreenCoordsXY{ 1, 1 }, coords + ScreenCoordsXY{ 114, 9 } }, colours[0],
|
||||
Rectangle::BorderStyle::inset, Rectangle::FillBrightness::light, Rectangle::FillMode::none);
|
||||
if (!blink || GameIsPaused() || (gCurrentRealTimeTicks & 8))
|
||||
{
|
||||
if (bar_width > 2)
|
||||
{
|
||||
Rectangle::fillInset(
|
||||
rt, { coords + ScreenCoordsXY{ 2, 2 }, coords + ScreenCoordsXY{ bar_width - 1, 8 } },
|
||||
ColourWithFlags{ colour });
|
||||
}
|
||||
}
|
||||
|
||||
// Draw thumbs on the sides
|
||||
GfxDrawSprite(rt, ImageId(SPR_RATING_LOW), coords - ScreenCoordsXY{ 14, 0 });
|
||||
GfxDrawSprite(rt, ImageId(SPR_RATING_HIGH), coords + ScreenCoordsXY{ 114, 0 });
|
||||
}
|
||||
|
||||
public:
|
||||
ParkInfoPanel()
|
||||
{
|
||||
setWidgets(kParkInfoPanelWidgets);
|
||||
}
|
||||
|
||||
void onMouseUp(WidgetIndex widgetIndex) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_PANEL_OUTSET:
|
||||
case WIDX_MONEY:
|
||||
if (!getGameState().park.flags.has(ParkFlag::noMoney))
|
||||
ContextOpenWindow(WindowClass::finances);
|
||||
break;
|
||||
case WIDX_GUESTS:
|
||||
ContextOpenWindowView(WindowView::parkGuests);
|
||||
break;
|
||||
case WIDX_PARK_RATING:
|
||||
ContextOpenWindowView(WindowView::parkRating);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StringWithArgs onTooltip(WidgetIndex widgetIndex, StringId fallback) override
|
||||
{
|
||||
const auto& gameState = getGameState();
|
||||
auto ft = Formatter();
|
||||
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_MONEY:
|
||||
ft.Add<money64>(gameState.park.currentProfit);
|
||||
ft.Add<money64>(gameState.park.value);
|
||||
break;
|
||||
case WIDX_PARK_RATING:
|
||||
ft.Add<int16_t>(gameState.park.rating);
|
||||
break;
|
||||
}
|
||||
return { fallback, ft };
|
||||
}
|
||||
|
||||
void onPrepareDraw() override
|
||||
{
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t line_height = FontGetLineHeight(FontStyle::medium);
|
||||
|
||||
// Reset dimensions as appropriate -- in case we're switching languages.
|
||||
height = line_height * 2 + 12;
|
||||
windowPos.y = ContextGetHeight() - height;
|
||||
|
||||
// Change height of widgets in accordance with line height.
|
||||
// TODO: replace offset to full width with window size/position
|
||||
widgets[WIDX_PANEL_OUTSET].bottom = line_height * 3 + 3;
|
||||
widgets[WIDX_PANEL_INSET].bottom = line_height * 3 + 1;
|
||||
|
||||
// Reposition left widgets in accordance with line height... depending on whether there is money in play.
|
||||
if (getGameState().park.flags.has(ParkFlag::noMoney))
|
||||
{
|
||||
widgets[WIDX_MONEY].setHidden();
|
||||
widgets[WIDX_GUESTS].top = 1;
|
||||
widgets[WIDX_GUESTS].bottom = line_height + 7;
|
||||
widgets[WIDX_PARK_RATING].top = line_height + 8;
|
||||
widgets[WIDX_PARK_RATING].bottom = height - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
widgets[WIDX_MONEY].setVisible();
|
||||
widgets[WIDX_MONEY].bottom = widgets[WIDX_MONEY].top + line_height;
|
||||
widgets[WIDX_GUESTS].top = widgets[WIDX_MONEY].bottom + 1;
|
||||
widgets[WIDX_GUESTS].bottom = widgets[WIDX_GUESTS].top + line_height;
|
||||
widgets[WIDX_PARK_RATING].top = widgets[WIDX_GUESTS].bottom - 1;
|
||||
widgets[WIDX_PARK_RATING].bottom = height - 1;
|
||||
}
|
||||
}
|
||||
|
||||
void onDraw(RenderTarget& rt) override
|
||||
{
|
||||
const auto& leftWidget = widgets[WIDX_PANEL_OUTSET];
|
||||
|
||||
// Draw panel grey backgrounds
|
||||
auto leftTop = windowPos + ScreenCoordsXY{ leftWidget.left, leftWidget.top };
|
||||
auto rightBottom = windowPos + ScreenCoordsXY{ leftWidget.right, leftWidget.bottom };
|
||||
Rectangle::filter(rt, { leftTop, rightBottom }, FilterPaletteID::palette51);
|
||||
|
||||
drawWidgets(rt);
|
||||
|
||||
drawPanel(rt);
|
||||
}
|
||||
|
||||
CursorID onCursor(WidgetIndex widgetIndex, const ScreenCoordsXY& screenCoords, CursorID cursorId) override
|
||||
{
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_MONEY:
|
||||
case WIDX_GUESTS:
|
||||
case WIDX_PARK_RATING:
|
||||
gTooltipCloseTimeout = gCurrentRealTimeTicks + 2000;
|
||||
break;
|
||||
}
|
||||
return cursorId;
|
||||
}
|
||||
};
|
||||
|
||||
WindowBase* parkInfoPanelOpen()
|
||||
{
|
||||
// Figure out how much line height we have to work with.
|
||||
uint32_t lineHeight = FontGetLineHeight(FontStyle::medium);
|
||||
int32_t panelHeight = lineHeight * 2 + 12;
|
||||
|
||||
auto* windowMgr = GetWindowManager();
|
||||
auto* window = windowMgr->Create<ParkInfoPanel>(
|
||||
WindowClass::parkInfoPanel, ScreenCoordsXY(0, ContextGetHeight() - panelHeight), { kPanelWidth, panelHeight },
|
||||
{ WindowFlag::stickToFront, WindowFlag::transparent, WindowFlag::noBackground, WindowFlag::noTitleBar });
|
||||
|
||||
return window;
|
||||
}
|
||||
} // namespace OpenRCT2::Ui::Windows
|
||||
@@ -154,6 +154,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
static WindowClass window_themes_tab_1_classes[] = {
|
||||
WindowClass::topToolbar,
|
||||
WindowClass::bottomToolbar,
|
||||
WindowClass::parkInfoPanel,
|
||||
WindowClass::dateInfoPanel,
|
||||
WindowClass::editorScenarioBottomToolbar,
|
||||
WindowClass::editorTrackBottomToolbar,
|
||||
WindowClass::titleMenu,
|
||||
|
||||
@@ -81,6 +81,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
// CustomCurrency
|
||||
WindowBase* CustomCurrencyOpen();
|
||||
|
||||
// DateInfoPanel
|
||||
WindowBase* dateInfoPanelOpen();
|
||||
|
||||
// DebugPaint
|
||||
WindowBase* DebugPaintOpen();
|
||||
|
||||
@@ -126,7 +129,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
bool WindowFootpathSelectDefault();
|
||||
|
||||
// GameBottomToolbar
|
||||
extern BottomToolbarDirtyFlags gToolbarDirtyFlags;
|
||||
WindowBase* GameBottomToolbarOpen();
|
||||
void WindowGameBottomToolbarInvalidateNewsItem();
|
||||
|
||||
@@ -213,6 +215,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
WindowBase* ParkObjectiveOpen();
|
||||
WindowBase* ParkRatingOpen();
|
||||
|
||||
// ParkInfoPanel
|
||||
WindowBase* parkInfoPanelOpen();
|
||||
|
||||
// Player
|
||||
WindowBase* PlayerOpen(uint8_t id);
|
||||
|
||||
|
||||
@@ -120,6 +120,8 @@ void GameCreateWindows()
|
||||
ContextOpenWindow(WindowClass::mainWindow);
|
||||
ContextOpenWindow(WindowClass::topToolbar);
|
||||
ContextOpenWindow(WindowClass::bottomToolbar);
|
||||
ContextOpenWindow(WindowClass::parkInfoPanel);
|
||||
ContextOpenWindow(WindowClass::dateInfoPanel);
|
||||
WindowResizeGui(ContextGetWidth(), ContextGetHeight());
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
#include "../Context.h"
|
||||
#include "../Game.h"
|
||||
#include "../Input.h"
|
||||
#include "../OpenRCT2.h"
|
||||
#include "../audio/Audio.h"
|
||||
#include "../config/Config.h"
|
||||
#include "../drawing/Drawing.String.h"
|
||||
@@ -20,6 +19,7 @@
|
||||
#include "../drawing/RenderTarget.h"
|
||||
#include "../entity/EntityRegistry.h"
|
||||
#include "../ride/RideAudio.h"
|
||||
#include "../scenes/SceneManager.h"
|
||||
#include "../ui/UiContext.h"
|
||||
#include "../ui/WindowManager.h"
|
||||
#include "../world/Map.h"
|
||||
@@ -363,7 +363,8 @@ static constexpr float kWindowScrollLocations[][2] = {
|
||||
auto screenCoords = Translate3DTo2DWithZ(w.viewport->rotation, coords);
|
||||
|
||||
int32_t i = 0;
|
||||
if (gLegacyScene != LegacyScene::titleSequence)
|
||||
auto sceneManager = GetContext()->GetSceneManager();
|
||||
if (sceneManager->getActiveScene() != sceneManager->getTitleScene())
|
||||
{
|
||||
bool found = false;
|
||||
while (!found)
|
||||
@@ -720,63 +721,10 @@ static constexpr float kWindowScrollLocations[][2] = {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x0066B905
|
||||
*/
|
||||
void WindowResizeGui(int32_t width, int32_t height)
|
||||
{
|
||||
WindowResizeGuiScenarioEditor(width, height);
|
||||
if (isInEditorMode())
|
||||
return;
|
||||
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
WindowBase* titleWind = windowMgr->FindByClass(WindowClass::titleMenu);
|
||||
if (titleWind != nullptr)
|
||||
{
|
||||
titleWind->windowPos.x = (width - titleWind->width) / 2;
|
||||
titleWind->windowPos.y = height - 182;
|
||||
}
|
||||
|
||||
WindowBase* versionWind = windowMgr->FindByClass(WindowClass::titleVersion);
|
||||
if (versionWind != nullptr)
|
||||
versionWind->windowPos.y = height - 30;
|
||||
|
||||
WindowBase* exitWind = windowMgr->FindByClass(WindowClass::titleExit);
|
||||
if (exitWind != nullptr)
|
||||
{
|
||||
exitWind->windowPos.x = width - 40;
|
||||
exitWind->windowPos.y = height - 64;
|
||||
}
|
||||
|
||||
WindowBase* optionsWind = windowMgr->FindByClass(WindowClass::titleOptions);
|
||||
if (optionsWind != nullptr)
|
||||
{
|
||||
optionsWind->windowPos.x = width - 80;
|
||||
}
|
||||
|
||||
// Keep options window centred after a resize
|
||||
WindowBase* optionsWindow = windowMgr->FindByClass(WindowClass::options);
|
||||
if (optionsWindow != nullptr)
|
||||
{
|
||||
optionsWindow->windowPos.x = (ContextGetWidth() - optionsWindow->width) / 2;
|
||||
optionsWindow->windowPos.y = (ContextGetHeight() - optionsWindow->height) / 2;
|
||||
}
|
||||
|
||||
// Keep progress bar window centred after a resize
|
||||
WindowBase* ProgressWindow = windowMgr->FindByClass(WindowClass::progressWindow);
|
||||
if (ProgressWindow != nullptr)
|
||||
{
|
||||
ProgressWindow->windowPos.x = (ContextGetWidth() - ProgressWindow->width) / 2;
|
||||
ProgressWindow->windowPos.y = (ContextGetHeight() - ProgressWindow->height) / 2;
|
||||
}
|
||||
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* rct2: 0x0066F0DD
|
||||
*/
|
||||
void WindowResizeGuiScenarioEditor(int32_t width, int32_t height)
|
||||
static void WindowResizeGuiMainToolbars(const int32_t width, const int32_t height)
|
||||
{
|
||||
auto* mainWind = WindowGetMain();
|
||||
if (mainWind != nullptr)
|
||||
@@ -801,14 +749,92 @@ static constexpr float kWindowScrollLocations[][2] = {
|
||||
topWind->width = std::max(640, width);
|
||||
}
|
||||
|
||||
WindowBase* parkInfoPanel = windowMgr->FindByClass(WindowClass::parkInfoPanel);
|
||||
if (parkInfoPanel != nullptr)
|
||||
{
|
||||
parkInfoPanel->windowPos.y = height - 32;
|
||||
}
|
||||
|
||||
WindowBase* dateInfoPanel = windowMgr->FindByClass(WindowClass::dateInfoPanel);
|
||||
if (dateInfoPanel != nullptr)
|
||||
{
|
||||
dateInfoPanel->windowPos.x = width - dateInfoPanel->width;
|
||||
dateInfoPanel->windowPos.y = height - 32;
|
||||
}
|
||||
|
||||
WindowBase* bottomWind = windowMgr->FindByClass(WindowClass::bottomToolbar);
|
||||
if (bottomWind != nullptr)
|
||||
{
|
||||
bottomWind->width = std::max(640, width) - parkInfoPanel->width - dateInfoPanel->width;
|
||||
bottomWind->windowPos.x = parkInfoPanel->width;
|
||||
bottomWind->windowPos.y = height - 32;
|
||||
bottomWind->width = std::max(640, width);
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowResizeGuiTitleScreen(const int32_t width, const int32_t height)
|
||||
{
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
WindowBase* titleWind = windowMgr->FindByClass(WindowClass::titleMenu);
|
||||
if (titleWind != nullptr)
|
||||
{
|
||||
titleWind->windowPos.x = (width - titleWind->width) / 2;
|
||||
titleWind->windowPos.y = height - 182;
|
||||
}
|
||||
|
||||
WindowBase* versionWind = windowMgr->FindByClass(WindowClass::titleVersion);
|
||||
if (versionWind != nullptr)
|
||||
versionWind->windowPos.y = height - 30;
|
||||
|
||||
WindowBase* exitWind = windowMgr->FindByClass(WindowClass::titleExit);
|
||||
if (exitWind != nullptr)
|
||||
{
|
||||
exitWind->windowPos.x = width - 40;
|
||||
exitWind->windowPos.y = height - 64;
|
||||
}
|
||||
|
||||
WindowBase* optionsWind = windowMgr->FindByClass(WindowClass::titleOptions);
|
||||
if (optionsWind != nullptr)
|
||||
{
|
||||
optionsWind->windowPos.x = width - 80;
|
||||
}
|
||||
}
|
||||
|
||||
static void WindowResizeGuiCentredWindows(const int32_t width, const int32_t height)
|
||||
{
|
||||
auto* windowMgr = Ui::GetWindowManager();
|
||||
|
||||
// Keep options window centred after a resize
|
||||
WindowBase* optionsWindow = windowMgr->FindByClass(WindowClass::options);
|
||||
if (optionsWindow != nullptr)
|
||||
{
|
||||
optionsWindow->windowPos.x = (width - optionsWindow->width) / 2;
|
||||
optionsWindow->windowPos.y = (height - optionsWindow->height) / 2;
|
||||
}
|
||||
|
||||
// Keep progress bar window centred after a resize
|
||||
WindowBase* ProgressWindow = windowMgr->FindByClass(WindowClass::progressWindow);
|
||||
if (ProgressWindow != nullptr)
|
||||
{
|
||||
ProgressWindow->windowPos.x = (width - ProgressWindow->width) / 2;
|
||||
ProgressWindow->windowPos.y = (height - ProgressWindow->height) / 2;
|
||||
}
|
||||
}
|
||||
|
||||
void WindowResizeGui(const int32_t width, const int32_t height)
|
||||
{
|
||||
WindowResizeGuiMainToolbars(width, height);
|
||||
|
||||
auto sceneManager = GetContext()->GetSceneManager();
|
||||
if (sceneManager->getActiveScene() == sceneManager->getTitleScene())
|
||||
{
|
||||
return WindowResizeGuiTitleScreen(width, height);
|
||||
}
|
||||
|
||||
WindowResizeGuiCentredWindows(width, height);
|
||||
|
||||
GfxInvalidateScreen();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update zoom based volume attenuation for ride music and clear music list.
|
||||
* rct2: 0x006BC348
|
||||
|
||||
@@ -86,9 +86,7 @@ namespace OpenRCT2
|
||||
|
||||
Viewport* WindowGetViewport(WindowBase* window);
|
||||
|
||||
// Open window functions
|
||||
void WindowResizeGui(int32_t width, int32_t height);
|
||||
void WindowResizeGuiScenarioEditor(int32_t width, int32_t height);
|
||||
|
||||
void TextinputCancel();
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@ namespace OpenRCT2
|
||||
mainWindow = 0,
|
||||
topToolbar = 1,
|
||||
bottomToolbar = 2,
|
||||
parkInfoPanel = 3,
|
||||
dateInfoPanel = 4,
|
||||
tooltip = 5,
|
||||
dropdown = 6,
|
||||
about = 8,
|
||||
// WC_PUBLISHER_CREDITS = 9,
|
||||
// WC_MUSIC_CREDITS = 10,
|
||||
// publisherCredits = 9,
|
||||
// musicCredits = 10,
|
||||
error = 11,
|
||||
ride = 12,
|
||||
rideConstruction = 13,
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../core/FlagHolder.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
struct ZoomLevel;
|
||||
@@ -102,16 +100,6 @@ namespace OpenRCT2
|
||||
quit
|
||||
};
|
||||
|
||||
enum class BottomToolbarDirtyFlag : uint8_t
|
||||
{
|
||||
money,
|
||||
date,
|
||||
guestCount,
|
||||
weather,
|
||||
parkRating,
|
||||
};
|
||||
using BottomToolbarDirtyFlags = FlagHolder<uint8_t, BottomToolbarDirtyFlag>;
|
||||
|
||||
enum class LoadSaveAction : uint8_t
|
||||
{
|
||||
load,
|
||||
|
||||
Reference in new issue
Block a user