Merge pull request #25719 from AaronVanGeffen/weather-cheats-dropdown
Add sprites to weather cheat dropdown
@@ -3846,4 +3846,8 @@ STR_7013 :Drag areas of path
|
||||
STR_7014 :I own the game on Steam, but I haven’t installed it yet.
|
||||
STR_7015 :Please close Steam if it’s running, then click ‘OK’.
|
||||
STR_7016 :OpenRCT2 has tried to trigger a download in Steam. Please open Steam and let it download the game. When Steam is finished, click ‘OK’.
|
||||
STR_7017 :Quit
|
||||
STR_7017 :Quit
|
||||
STR_7018 :{SPRITE}{MOVE_X}{17}{STRINGID}
|
||||
STR_7019 :{SPRITE}{MOVE_X}{27}{STRINGID}
|
||||
STR_7020 :{MOVE_X}{10}{SPRITE}{NEWLINE_SMALLER}{MOVE_X}{36}{STRINGID}
|
||||
STR_7021 :{MOVE_X}{10}{SPRITE}{NEWLINE_SMALLER}»{MOVE_X}{36}{STRINGID}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
0.4.31 (in development)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: [#25844] The sprite builder now also supports adding JSON-based palettes.
|
||||
- Improved: [#25719] The weather change dropdown now shows icons next to the weather types for easier selection.
|
||||
- Improved: [#25765] The ‘View options’ and ‘Special track elements’ dropdowns no longer need click-and-hold.
|
||||
- Improved: [#25858] macOS now supports the onboarding menu.
|
||||
- Change: [#25018] Add upkeep cost to booster pieces.
|
||||
|
||||
BIN
resources/g2/icons/weather_blizzard_small.png
Normal file
|
After Width: | Height: | Size: 4.4 KiB |
BIN
resources/g2/icons/weather_cloud_small.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resources/g2/icons/weather_heavy_rain_small.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resources/g2/icons/weather_heavy_snow_small.png
Normal file
|
After Width: | Height: | Size: 4.3 KiB |
BIN
resources/g2/icons/weather_light_rain_small.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resources/g2/icons/weather_snow_small.png
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
resources/g2/icons/weather_storm_small.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resources/g2/icons/weather_sun_cloud_small.png
Normal file
|
After Width: | Height: | Size: 3.8 KiB |
BIN
resources/g2/icons/weather_sun_small.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
@@ -363,18 +363,54 @@
|
||||
"x": 2,
|
||||
"y": 1
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_sun_small.png",
|
||||
"x": 3
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_sun_cloud_small.png",
|
||||
"x": 0
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_cloud_small.png",
|
||||
"x": 0
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_light_rain_small.png",
|
||||
"x": 3
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_heavy_rain_small.png",
|
||||
"x": 2
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_storm_small.png",
|
||||
"x": 3
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_snow.png",
|
||||
"x": 3
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_snow_small.png",
|
||||
"x": 3
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_heavy_snow.png",
|
||||
"x": 1
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_heavy_snow_small.png",
|
||||
"x": 3
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_blizzard.png",
|
||||
"x": 1
|
||||
},
|
||||
{
|
||||
"path": "icons/weather_blizzard_small.png",
|
||||
"x": 2
|
||||
},
|
||||
{
|
||||
"path": "icons/monitor_0.png",
|
||||
"x": 3,
|
||||
|
||||
@@ -433,6 +433,10 @@ namespace OpenRCT2
|
||||
STR_STAFF_CHEATS_TIP = 6669,
|
||||
STR_THIS_FEATURE_IS_CURRENTLY_UNSTABLE = 5563,
|
||||
STR_WARNING_IN_CAPS = 5562,
|
||||
STR_WEATHER_CAPTION = 7018,
|
||||
STR_WEATHER_DROPDOWN_ITEM = 7019,
|
||||
STR_WEATHER_DROPDOWN_ITEM_ENLARGED = 7020,
|
||||
STR_WEATHER_DROPDOWN_ITEM_ENLARGED_SELECTED = 7021,
|
||||
STR_WEATHER_NATURE_CHEATS_TIP = 6666,
|
||||
STR_YEAR = 6196,
|
||||
STR_CHEAT_IGNORE_PRICE_TIP = 6660,
|
||||
|
||||
@@ -178,6 +178,7 @@ namespace OpenRCT2::Dropdown
|
||||
Item PlainMenuLabel(StringId stringId);
|
||||
Item PlainMenuLabel(u8string string);
|
||||
Item PlainMenuLabel(const utf8* string);
|
||||
Item PlainMenuLabel(StringId format, const Formatter& ft);
|
||||
|
||||
/**
|
||||
* Like MenuLabel, but shows a tick when selected.
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/actions/CheatSetAction.h>
|
||||
#include <openrct2/actions/ParkSetDateAction.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/core/EnumUtils.hpp>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
#include <openrct2/localisation/Currency.h>
|
||||
@@ -56,19 +57,25 @@ static StringId _staffSpeedNames[] =
|
||||
STR_FAST,
|
||||
};
|
||||
|
||||
static constexpr StringId WeatherTypes[] =
|
||||
struct WeatherInfo
|
||||
{
|
||||
STR_SUNNY,
|
||||
STR_PARTIALLY_CLOUDY,
|
||||
STR_CLOUDY,
|
||||
STR_RAIN,
|
||||
STR_HEAVY_RAIN,
|
||||
STR_THUNDERSTORM,
|
||||
STR_SNOW,
|
||||
STR_HEAVY_SNOW,
|
||||
STR_BLIZZARD,
|
||||
ImageIndex smallIcon;
|
||||
ImageIndex largeIcon;
|
||||
StringId label;
|
||||
};
|
||||
|
||||
static constexpr auto kWeatherTypes = std::to_array<WeatherInfo>({
|
||||
{ SPR_G2_WEATHER_SUN_SMALL, SPR_WEATHER_SUN, STR_SUNNY },
|
||||
{ SPR_G2_WEATHER_SUN_CLOUD_SMALL, SPR_WEATHER_SUN_CLOUD, STR_PARTIALLY_CLOUDY },
|
||||
{ SPR_G2_WEATHER_CLOUD_SMALL, SPR_WEATHER_CLOUD, STR_CLOUDY },
|
||||
{ SPR_G2_WEATHER_LIGHT_RAIN_SMALL, SPR_WEATHER_LIGHT_RAIN, STR_RAIN },
|
||||
{ SPR_G2_WEATHER_HEAVY_RAIN_SMALL, SPR_WEATHER_HEAVY_RAIN, STR_HEAVY_RAIN },
|
||||
{ SPR_G2_WEATHER_STORM_SMALL, SPR_WEATHER_STORM, STR_THUNDERSTORM },
|
||||
{ SPR_G2_WEATHER_SNOW_SMALL, SPR_G2_WEATHER_SNOW, STR_SNOW },
|
||||
{ SPR_G2_WEATHER_HEAVY_SNOW_SMALL, SPR_G2_WEATHER_HEAVY_SNOW, STR_HEAVY_SNOW },
|
||||
{ SPR_G2_WEATHER_BLIZZARD_SMALL, SPR_G2_WEATHER_BLIZZARD, STR_BLIZZARD },
|
||||
});
|
||||
|
||||
enum WindowCheatsWidgetIdx
|
||||
{
|
||||
WIDX_BACKGROUND,
|
||||
@@ -342,7 +349,7 @@ static constexpr auto window_cheats_rides_widgets = makeWidgets(
|
||||
static constexpr auto window_cheats_weather_widgets = makeWidgets(
|
||||
kMainCheatWidgets,
|
||||
makeWidget ({ 5, 48}, {238, 50}, WidgetType::groupbox, WindowColour::secondary, STR_CHEAT_WEATHER_GROUP ), // Weather group
|
||||
makeWidget ({126, 62}, {111, 14}, WidgetType::dropdownMenu, WindowColour::secondary, kStringIdNone, STR_CHANGE_WEATHER_TOOLTIP ), // Force weather
|
||||
makeWidget ({126, 62}, {111, 14}, WidgetType::dropdownMenu, WindowColour::secondary, STR_WEATHER_CAPTION, STR_CHANGE_WEATHER_TOOLTIP ), // Force weather
|
||||
makeWidget ({225, 63}, { 11, 12}, WidgetType::button, WindowColour::secondary, STR_DROPDOWN_GLYPH, STR_CHANGE_WEATHER_TOOLTIP ), // Force weather
|
||||
makeWidget ({ 11, 80}, kCheatCheckSize, WidgetType::checkbox, WindowColour::secondary, STR_CHEAT_FREEZE_WEATHER, STR_CHEAT_FREEZE_WEATHER_TIP), // Freeze weather
|
||||
makeWidget ({ 5, 102}, {238, 37}, WidgetType::groupbox, WindowColour::secondary, STR_FAUNA ), // Fauna group
|
||||
@@ -577,7 +584,11 @@ static StringId window_cheats_page_titles[] = {
|
||||
// Current weather
|
||||
if (page == WINDOW_CHEATS_PAGE_WEATHER)
|
||||
{
|
||||
widgets[WIDX_WEATHER].text = WeatherTypes[EnumValue(gameState.weatherCurrent.weatherType)];
|
||||
auto& weatherType = kWeatherTypes[EnumValue(gameState.weatherCurrent.weatherType)];
|
||||
|
||||
auto ft = Formatter::Common();
|
||||
ft.Add<uint32_t>(weatherType.smallIcon);
|
||||
ft.Add<StringId>(weatherType.label);
|
||||
}
|
||||
|
||||
// Staff speed
|
||||
@@ -1000,26 +1011,41 @@ static StringId window_cheats_page_titles[] = {
|
||||
|
||||
void onMouseDownWeather(WidgetIndex widgetIndex)
|
||||
{
|
||||
auto* widget = &widgets[widgetIndex];
|
||||
auto& gameState = getGameState();
|
||||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_WEATHER_DROPDOWN_BUTTON:
|
||||
{
|
||||
Widget* dropdownWidget = widget - 1;
|
||||
const auto& dropdownWidget = widgets[widgetIndex - 1];
|
||||
const bool isEnlarged = Config::Get().interface.enlargedUi;
|
||||
const auto currentSelection = EnumValue(getGameState().weatherCurrent.weatherType);
|
||||
|
||||
for (size_t i = 0; i < std::size(WeatherTypes); i++)
|
||||
const auto itemWidth = dropdownWidget.width() + (isEnlarged ? 30 : 22) - 3;
|
||||
const auto itemHeight = isEnlarged ? 20 : 12; // !!! TTF?
|
||||
|
||||
const auto format = isEnlarged ? STR_WEATHER_DROPDOWN_ITEM_ENLARGED : STR_DROPDOWN_MENU_LABEL;
|
||||
const auto formatAlt = isEnlarged ? STR_WEATHER_DROPDOWN_ITEM_ENLARGED_SELECTED
|
||||
: STR_DROPDOWN_MENU_LABEL_SELECTED;
|
||||
|
||||
auto i = 0u;
|
||||
for (auto& weatherType : kWeatherTypes)
|
||||
{
|
||||
gDropdown.items[i] = Dropdown::MenuLabel(WeatherTypes[i]);
|
||||
Formatter ft;
|
||||
if (!isEnlarged)
|
||||
ft.Add<StringId>(STR_WEATHER_DROPDOWN_ITEM);
|
||||
|
||||
ft.Add<uint32_t>(isEnlarged ? weatherType.largeIcon : weatherType.smallIcon);
|
||||
ft.Add<StringId>(weatherType.label);
|
||||
|
||||
// Workaround: DIY to keep selection indicator aligned with label
|
||||
auto label = i == currentSelection ? formatAlt : format;
|
||||
gDropdown.items[i] = Dropdown::PlainMenuLabel(label, ft);
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
WindowDropdownShowTextCustomWidth(
|
||||
{ windowPos.x + dropdownWidget->left, windowPos.y + dropdownWidget->top }, dropdownWidget->height(),
|
||||
colours[1], 0, Dropdown::Flag::StayOpen, std::size(WeatherTypes), dropdownWidget->width() - 4);
|
||||
|
||||
auto currentWeather = gameState.weatherCurrent.weatherType;
|
||||
gDropdown.items[EnumValue(currentWeather)].setChecked(true);
|
||||
|
||||
break;
|
||||
{ windowPos.x + dropdownWidget.left, windowPos.y + dropdownWidget.bottom }, 0, colours[1], itemHeight,
|
||||
Dropdown::Flag::CustomHeight | Dropdown::Flag::StayOpen, std::size(kWeatherTypes), itemWidth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
int32_t NumRows;
|
||||
int32_t ItemWidth;
|
||||
int32_t ItemHeight;
|
||||
int32_t ItemPadding;
|
||||
bool ListVertically;
|
||||
|
||||
public:
|
||||
@@ -88,8 +89,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
return Config::Get().interface.enlargedUi ? 6 : 0;
|
||||
}
|
||||
|
||||
static void drawTextItem(
|
||||
RenderTarget& rt, ScreenCoordsXY screenCoords, int32_t width, const Dropdown::Item& item, bool highlighted,
|
||||
void drawTextItem(
|
||||
RenderTarget& rt, ScreenCoordsXY screenCoords, int32_t ddWidth, const Dropdown::Item& item, bool highlighted,
|
||||
StringId format, Colour background)
|
||||
{
|
||||
ColourWithFlags colour = { background };
|
||||
@@ -98,11 +99,11 @@ namespace OpenRCT2::Ui::Windows
|
||||
if (item.isDisabled())
|
||||
colour = { background, { ColourFlag::inset } };
|
||||
|
||||
auto yOffset = GetAdditionalRowPadding();
|
||||
auto yOffset = ItemPadding;
|
||||
Formatter ft;
|
||||
ft.Add<const utf8*>(item.text);
|
||||
|
||||
DrawTextEllipsised(rt, { screenCoords.x + 2, screenCoords.y + yOffset }, width - 7, format, ft, { colour });
|
||||
DrawTextEllipsised(rt, { screenCoords.x + 2, screenCoords.y + yOffset }, ddWidth - 7, format, ft, { colour });
|
||||
}
|
||||
|
||||
void onDraw(RenderTarget& rt) override
|
||||
@@ -212,6 +213,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
// Set and calculate num items, rows and columns
|
||||
ItemHeight = (txtFlags & Dropdown::Flag::CustomHeight) ? customItemHeight : GetDefaultRowHeight();
|
||||
ItemPadding = (txtFlags & Dropdown::Flag::CustomHeight) ? 0 : GetAdditionalRowPadding();
|
||||
|
||||
gDropdown.numItems = static_cast<int32_t>(numItems);
|
||||
if (gDropdown.numItems > 1)
|
||||
@@ -670,6 +672,12 @@ namespace OpenRCT2::Dropdown
|
||||
return StringItem(ItemType::plain, LanguageGetString(stringId));
|
||||
}
|
||||
|
||||
Item PlainMenuLabel(StringId format, const Formatter& ft)
|
||||
{
|
||||
auto string = FormatStringIDLegacy(format, ft.Data());
|
||||
return StringItem(ItemType::plain, string.c_str());
|
||||
}
|
||||
|
||||
Item ToggleOption(StringId stringId)
|
||||
{
|
||||
return StringItem(ItemType::toggle, LanguageGetString(stringId));
|
||||
|
||||
@@ -1155,9 +1155,18 @@ enum : ImageIndex
|
||||
SPR_G2_FOLDER_DEFAULT,
|
||||
SPR_G2_SYSTEM_BROWSER,
|
||||
SPR_G2_PEEP_ANIMATIONS,
|
||||
SPR_G2_WEATHER_SUN_SMALL,
|
||||
SPR_G2_WEATHER_SUN_CLOUD_SMALL,
|
||||
SPR_G2_WEATHER_CLOUD_SMALL,
|
||||
SPR_G2_WEATHER_LIGHT_RAIN_SMALL,
|
||||
SPR_G2_WEATHER_HEAVY_RAIN_SMALL,
|
||||
SPR_G2_WEATHER_STORM_SMALL,
|
||||
SPR_G2_WEATHER_SNOW,
|
||||
SPR_G2_WEATHER_SNOW_SMALL,
|
||||
SPR_G2_WEATHER_HEAVY_SNOW,
|
||||
SPR_G2_WEATHER_HEAVY_SNOW_SMALL,
|
||||
SPR_G2_WEATHER_BLIZZARD,
|
||||
SPR_G2_WEATHER_BLIZZARD_SMALL,
|
||||
SPR_G2_MONITOR_TAB_START,
|
||||
SPR_G2_MONITOR_TAB_END = SPR_G2_MONITOR_TAB_START + 15,
|
||||
SPR_G2_CONTROLS_TAB_START,
|
||||
|
||||