1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-10 09:32:29 +01:00

Optionally allow scenario previews to use screenshots

This commit is contained in:
Aaron van Geffen
2025-05-21 18:07:19 +02:00
parent 8c8d3435f1
commit 0f59d6dd02
6 changed files with 96 additions and 29 deletions

View File

@@ -3822,3 +3822,7 @@ STR_6774 :Time since last inspection
STR_6775 :{COMMA16} minute
STR_6776 :{COMMA16} minutes
STR_6777 :more than 4 hours
STR_6778 :Preview scenarios using:
STR_6779 :Select the kind of preview image to use in the scenario selection screen.
STR_6780 :Mini maps
STR_6781 :Screenshots

View File

@@ -1234,6 +1234,10 @@ namespace OpenRCT2
STR_SAVE_PLUGIN_DATA_TIP = 3334,
STR_SCENARIO_GROUPING_TIP = 5842,
STR_SCENARIO_OPTIONS = 6228,
STR_SCENARIO_PREVIEWS_LABEL = 6778,
STR_SCENARIO_PREVIEWS_MINIMAPS = 6780,
STR_SCENARIO_PREVIEWS_SCREENSHOTS = 6781,
STR_SCENARIO_PREVIEWS_TIP = 6779,
STR_SCENARIO_UNLOCKING_TIP = 5843,
STR_SCREEN_EDGE_SCROLLING = 2797,
STR_SCREEN_EDGE_SCROLLING_TIP = 2798,

View File

@@ -204,6 +204,9 @@ namespace OpenRCT2::Ui::Windows
WIDX_TITLE_SEQUENCE,
WIDX_TITLE_SEQUENCE_DROPDOWN,
WIDX_SCENARIO_GROUP,
WIDX_SCENARIO_PREVIEWS_LABEL,
WIDX_SCENARIO_PREVIEWS,
WIDX_SCENARIO_PREVIEWS_DROPDOWN,
WIDX_SCENARIO_GROUPING_LABEL,
WIDX_SCENARIO_GROUPING,
WIDX_SCENARIO_GROUPING_DROPDOWN,
@@ -395,7 +398,7 @@ namespace OpenRCT2::Ui::Windows
constexpr int32_t kTitleSequenceStart = 53;
constexpr int32_t kScenarioGroupStart = kTitleSequenceStart + 35;
constexpr int32_t kScenarioOptionsGroupStart = kScenarioGroupStart + 55;
constexpr int32_t kScenarioOptionsGroupStart = kScenarioGroupStart + 70;
constexpr int32_t kTweaksStart = kScenarioOptionsGroupStart + 39;
static constexpr auto window_options_misc_widgets = makeWidgets(
@@ -403,11 +406,14 @@ namespace OpenRCT2::Ui::Windows
MakeWidget( { 5, kTitleSequenceStart + 0}, {300, 31}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_TITLE_SEQUENCE ),
MakeDropdownWidgets({ 10, kTitleSequenceStart + 15}, {290, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary, STR_STRINGID, STR_TITLE_SEQUENCE_TIP), // Title sequence dropdown
MakeWidget({ 5, kScenarioGroupStart + 0}, {300, 51}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_SCENARIO_SELECTION ),
MakeWidget({ 10, kScenarioGroupStart + 16}, {165, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_OPTIONS_SCENARIO_GROUPING, STR_SCENARIO_GROUPING_TIP ),
MakeWidget({175, kScenarioGroupStart + 15}, {125, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Scenario select mode
MakeWidget({288, kScenarioGroupStart + 16}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_SCENARIO_GROUPING_TIP ),
MakeWidget({ 25, kScenarioGroupStart + 30}, {275, 16}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_OPTIONS_SCENARIO_UNLOCKING, STR_SCENARIO_UNLOCKING_TIP), // Unlocking of scenarios
MakeWidget({ 5, kScenarioGroupStart + 0}, {300, 66}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_OPTIONS_SCENARIO_SELECTION ),
MakeWidget({ 10, kScenarioGroupStart + 16}, {165, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_SCENARIO_PREVIEWS_LABEL, STR_SCENARIO_PREVIEWS_TIP ),
MakeWidget({175, kScenarioGroupStart + 15}, {125, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Scenario previews
MakeWidget({288, kScenarioGroupStart + 16}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_SCENARIO_PREVIEWS_TIP ),
MakeWidget({ 10, kScenarioGroupStart + 31}, {165, 12}, WindowWidgetType::Label, WindowColour::Secondary, STR_OPTIONS_SCENARIO_GROUPING, STR_SCENARIO_GROUPING_TIP ),
MakeWidget({175, kScenarioGroupStart + 30}, {125, 12}, WindowWidgetType::DropdownMenu, WindowColour::Secondary ), // Scenario select mode
MakeWidget({288, kScenarioGroupStart + 31}, { 11, 10}, WindowWidgetType::Button, WindowColour::Secondary, STR_DROPDOWN_GLYPH, STR_SCENARIO_GROUPING_TIP ),
MakeWidget({ 25, kScenarioGroupStart + 45}, {275, 16}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_OPTIONS_SCENARIO_UNLOCKING, STR_SCENARIO_UNLOCKING_TIP), // Unlocking of scenarios
MakeWidget({ 5, kScenarioOptionsGroupStart + 0}, {300, 35}, WindowWidgetType::Groupbox, WindowColour::Secondary, STR_SCENARIO_OPTIONS ),
MakeWidget({10, kScenarioOptionsGroupStart + 15}, {290, 15}, WindowWidgetType::Checkbox, WindowColour::Tertiary , STR_ALLOW_EARLY_COMPLETION, STR_EARLY_COMPLETION_TIP), // Allow early scenario completion
@@ -1822,7 +1828,7 @@ namespace OpenRCT2::Ui::Windows
Config::Get().general.ScenarioUnlockingEnabled ^= 1;
Config::Save();
auto* windowMgr = Ui::GetWindowManager();
windowMgr->CloseByClass(WindowClass::ScenarioSelect);
windowMgr->InvalidateByClass(WindowClass::ScenarioSelect);
break;
}
case WIDX_AUTO_OPEN_SHOPS:
@@ -1877,6 +1883,22 @@ namespace OpenRCT2::Ui::Windows
Dropdown::SetChecked(selectedIndex, true);
break;
}
case WIDX_SCENARIO_PREVIEWS_DROPDOWN:
{
uint32_t numItems = 2;
gDropdownItems[0].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[0].Args = STR_SCENARIO_PREVIEWS_MINIMAPS;
gDropdownItems[1].Format = STR_DROPDOWN_MENU_LABEL;
gDropdownItems[1].Args = STR_SCENARIO_PREVIEWS_SCREENSHOTS;
WindowDropdownShowTextCustomWidth(
{ windowPos.x + widget->left, windowPos.y + widget->top }, widget->height() + 1, colours[1], 0,
Dropdown::Flag::StayOpen, numItems, widget->width() - 3);
Dropdown::SetChecked(Config::Get().interface.scenarioPreviewScreenshots, true);
break;
}
case WIDX_SCENARIO_GROUPING_DROPDOWN:
{
uint32_t numItems = 2;
@@ -1936,11 +1958,21 @@ namespace OpenRCT2::Ui::Windows
Invalidate();
}
break;
case WIDX_SCENARIO_PREVIEWS_DROPDOWN:
if (dropdownIndex != static_cast<int32_t>(Config::Get().interface.scenarioPreviewScreenshots))
{
Config::Get().interface.scenarioPreviewScreenshots = dropdownIndex;
Config::Save();
Invalidate();
auto* windowMgr = Ui::GetWindowManager();
windowMgr->InvalidateByClass(WindowClass::ScenarioSelect);
}
break;
case WIDX_SCENARIO_GROUPING_DROPDOWN:
if (dropdownIndex != EnumValue(Config::Get().general.scenarioSelectMode))
{
Config::Get().general.scenarioSelectMode = static_cast<ScenarioSelectMode>(dropdownIndex);
Config::Get().interface.ScenarioselectLastTab = 0;
Config::Get().interface.scenarioSelectLastTab = 0;
Config::Save();
Invalidate();
auto* windowMgr = Ui::GetWindowManager();
@@ -1988,6 +2020,11 @@ namespace OpenRCT2::Ui::Windows
SetCheckboxValue(WIDX_AUTO_OPEN_SHOPS, Config::Get().general.AutoOpenShops);
SetCheckboxValue(WIDX_ALLOW_EARLY_COMPLETION, Config::Get().general.AllowEarlyCompletion);
if (Config::Get().interface.scenarioPreviewScreenshots)
widgets[WIDX_SCENARIO_PREVIEWS].text = STR_SCENARIO_PREVIEWS_SCREENSHOTS;
else
widgets[WIDX_SCENARIO_PREVIEWS].text = STR_SCENARIO_PREVIEWS_MINIMAPS;
if (Config::Get().general.scenarioSelectMode == ScenarioSelectMode::difficulty)
widgets[WIDX_SCENARIO_GROUPING].text = STR_OPTIONS_SCENARIO_DIFFICULTY;
else
@@ -2049,7 +2086,7 @@ namespace OpenRCT2::Ui::Windows
if (CsgAtLocationIsUsable(rct1path))
{
Config::Get().general.RCT1Path = std::move(rct1path);
Config::Get().interface.ScenarioselectLastTab = 0;
Config::Get().interface.scenarioSelectLastTab = 0;
Config::Save();
ContextShowError(STR_RESTART_REQUIRED, kStringIdNone, {});
}

View File

@@ -41,8 +41,9 @@ namespace OpenRCT2::Ui::Windows
{
static constexpr int32_t kInitialNumUnlockedScenarios = 5;
static constexpr uint8_t kNumTabs = 10;
static constexpr int32_t kPreviewPaneWidth = 179;
static constexpr int32_t kSidebarWidth = 180;
static constexpr uint8_t kPadding = 5;
static constexpr int32_t kPreviewPaneWidthRegular = 180;
static constexpr int32_t kPreviewPaneWidthScreenshots = 254;
static constexpr int32_t kTabHeight = 34;
static constexpr int32_t kWidgetsStart = 17;
static constexpr int32_t kTabsStart = kWidgetsStart;
@@ -115,7 +116,7 @@ namespace OpenRCT2::Ui::Windows
MakeRemapWidget({ 3, kTabsStart + (kTabHeight * 7) }, { kTabWidth, kTabHeight}, WindowWidgetType::Tab, WindowColour::Secondary, SPR_G2_SIDEWAYS_TAB), // tab 08
MakeRemapWidget({ 3, kTabsStart + (kTabHeight * 8) }, { kTabWidth, kTabHeight}, WindowWidgetType::Tab, WindowColour::Secondary, SPR_G2_SIDEWAYS_TAB), // tab 09
MakeRemapWidget({ 3, kTabsStart + (kTabHeight * 8) }, { kTabWidth, kTabHeight}, WindowWidgetType::Tab, WindowColour::Secondary, SPR_G2_SIDEWAYS_TAB), // tab 10
MakeWidget({ kTabWidth + 3, kWidgetsStart + 1 }, { kWindowWidth - kSidebarWidth, 362 }, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL) // level list
MakeWidget({ kTabWidth + 3, kWidgetsStart + 1 }, { kWindowWidth - kPreviewPaneWidthRegular, 362 }, WindowWidgetType::Scroll, WindowColour::Secondary, SCROLL_VERTICAL) // level list
);
// clang-format on
@@ -166,7 +167,7 @@ namespace OpenRCT2::Ui::Windows
if (widgetIndex >= WIDX_TAB1 && widgetIndex <= WIDX_TAB10)
{
selected_tab = widgetIndex - 4;
Config::Get().interface.ScenarioselectLastTab = selected_tab;
Config::Get().interface.scenarioSelectLastTab = selected_tab;
Config::Save();
_highlightedScenario = nullptr;
@@ -181,6 +182,14 @@ namespace OpenRCT2::Ui::Windows
}
}
int32_t GetPreviewPaneWidth() const
{
if (Config::Get().interface.scenarioPreviewScreenshots)
return kPreviewPaneWidthScreenshots;
else
return kPreviewPaneWidthRegular;
}
void LoadPreview()
{
_preview = {};
@@ -274,11 +283,15 @@ namespace OpenRCT2::Ui::Windows
ScreenCoordsXY DrawPreview(RenderTarget& rt, ScreenCoordsXY screenPos)
{
auto targetImageType = PreviewImageType::miniMap;
if (Config::Get().interface.scenarioPreviewScreenshots)
targetImageType = PreviewImageType::screenshot;
// Find minimap image to draw, if available
PreviewImage* image = nullptr;
for (auto& candidate : _preview.images)
{
if (candidate.type == PreviewImageType::miniMap)
if (candidate.type == targetImageType)
{
image = &candidate;
break;
@@ -289,7 +302,7 @@ namespace OpenRCT2::Ui::Windows
return screenPos;
// Draw frame
auto startFrameX = width - (kPreviewPaneWidth / 2) - (image->width / 2);
auto startFrameX = width - (GetPreviewPaneWidth() / 2) - (image->width / 2) - kPadding;
auto frameStartPos = ScreenCoordsXY(windowPos.x + startFrameX, screenPos.y + 15);
auto frameEndPos = frameStartPos + ScreenCoordsXY(image->width + 1, image->height + 1);
GfxFillRectInset(rt, { frameStartPos, frameEndPos }, colours[1], INSET_RECT_F_60 | INSET_RECT_FLAG_FILL_MID_LIGHT);
@@ -335,6 +348,8 @@ namespace OpenRCT2::Ui::Windows
DrawTextWrapped(rt, stringCoords, 87, format, ft, { COLOUR_AQUAMARINE, fontStyle, TextAlignment::CENTRE });
}
auto previewPaneWidth = GetPreviewPaneWidth();
// Return if no scenario highlighted
auto* scenario = _highlightedScenario;
if (scenario == nullptr)
@@ -345,9 +360,10 @@ namespace OpenRCT2::Ui::Windows
auto screenPos = windowPos
+ ScreenCoordsXY{ widgets[WIDX_SCENARIOLIST].right + 4, widgets[WIDX_TABCONTENT].top + 5 };
DrawTextEllipsised(
rt, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_SCENARIO_LOCKED, {}, { TextAlignment::CENTRE });
rt, screenPos + ScreenCoordsXY{ previewPaneWidth / 2, 0 }, previewPaneWidth, STR_SCENARIO_LOCKED, {},
{ TextAlignment::CENTRE });
DrawTextWrapped(rt, screenPos + ScreenCoordsXY{ 0, 15 }, 170, STR_SCENARIO_LOCKED_DESC);
DrawTextWrapped(rt, screenPos + ScreenCoordsXY{ 0, 15 }, previewPaneWidth, STR_SCENARIO_LOCKED_DESC);
}
else
{
@@ -355,7 +371,7 @@ namespace OpenRCT2::Ui::Windows
auto screenPos = windowPos
+ ScreenCoordsXY{ widgets[WIDX_SCENARIOLIST].right + 4, widgets[WIDX_TABCONTENT].top + 5 };
DrawTextWrapped(rt, screenPos + ScreenCoordsXY{ 0, 15 }, 170, STR_SCENARIO_HOVER_HINT);
DrawTextWrapped(rt, screenPos + ScreenCoordsXY{ 0, 15 }, previewPaneWidth, STR_SCENARIO_HOVER_HINT);
}
return;
}
@@ -377,14 +393,17 @@ namespace OpenRCT2::Ui::Windows
ft.Add<StringId>(STR_STRING);
ft.Add<const char*>(scenario->Name.c_str());
DrawTextEllipsised(
rt, screenPos + ScreenCoordsXY{ 85, 0 }, 170, STR_WINDOW_COLOUR_2_STRINGID, ft, { TextAlignment::CENTRE });
rt, screenPos + ScreenCoordsXY{ previewPaneWidth / 2, 0 }, previewPaneWidth, STR_WINDOW_COLOUR_2_STRINGID, ft,
{ TextAlignment::CENTRE });
// Still loading the preview?
if (_previewLoadJob.isValid())
{
ft = Formatter();
ft.Add<StringId>(STR_LOADING_GENERIC);
DrawTextBasic(rt, screenPos + ScreenCoordsXY{ 85, 15 }, STR_BLACK_STRING, ft, { TextAlignment::CENTRE });
DrawTextBasic(
rt, screenPos + ScreenCoordsXY{ previewPaneWidth / 2, 15 }, STR_BLACK_STRING, ft,
{ TextAlignment::CENTRE });
return;
}
@@ -396,7 +415,7 @@ namespace OpenRCT2::Ui::Windows
ft = Formatter();
ft.Add<StringId>(STR_STRING);
ft.Add<const char*>(scenario->Details.c_str());
screenPos.y += DrawTextWrapped(rt, screenPos, 170, STR_BLACK_STRING, ft) + 5;
screenPos.y += DrawTextWrapped(rt, screenPos, previewPaneWidth, STR_BLACK_STRING, ft) + 5;
// Scenario objective
Objective objective = { .Type = scenario->ObjectiveType,
@@ -407,7 +426,7 @@ namespace OpenRCT2::Ui::Windows
ft = Formatter();
ft.Add<StringId>(kObjectiveNames[scenario->ObjectiveType]);
formatObjective(ft, objective);
screenPos.y += DrawTextWrapped(rt, screenPos, 170, STR_OBJECTIVE, ft) + 5;
screenPos.y += DrawTextWrapped(rt, screenPos, previewPaneWidth, STR_OBJECTIVE, ft) + 5;
// Scenario score
if (scenario->Highscore != nullptr)
@@ -422,7 +441,7 @@ namespace OpenRCT2::Ui::Windows
ft.Add<StringId>(STR_STRING);
ft.Add<const char*>(completedByName.c_str());
ft.Add<money64>(scenario->Highscore->company_value);
screenPos.y += DrawTextWrapped(rt, screenPos, 170, STR_COMPLETED_BY_WITH_COMPANY_VALUE, ft);
screenPos.y += DrawTextWrapped(rt, screenPos, previewPaneWidth, STR_COMPLETED_BY_WITH_COMPANY_VALUE, ft);
}
}
@@ -436,7 +455,7 @@ namespace OpenRCT2::Ui::Windows
pressed_widgets |= 1LL << (selected_tab + WIDX_TAB1);
const int32_t bottomMargin = Config::Get().general.DebuggingTools ? 17 : 5;
widgets[WIDX_SCENARIOLIST].right = width - kPreviewPaneWidth;
widgets[WIDX_SCENARIOLIST].right = width - GetPreviewPaneWidth() - 2 * kPadding;
widgets[WIDX_SCENARIOLIST].bottom = height - bottomMargin;
}
@@ -863,9 +882,9 @@ namespace OpenRCT2::Ui::Windows
}
}
if (showPages & (1 << Config::Get().interface.ScenarioselectLastTab))
if (showPages & (1 << Config::Get().interface.scenarioSelectLastTab))
{
selected_tab = Config::Get().interface.ScenarioselectLastTab;
selected_tab = Config::Get().interface.scenarioSelectLastTab;
}
else
{

View File

@@ -376,7 +376,8 @@ namespace OpenRCT2::Config
model->CurrentTitleSequencePreset = reader->GetString("current_title_sequence", "*OPENRCT2");
model->RandomTitleSequence = reader->GetBoolean("random_title_sequence", false);
model->ObjectSelectionFilterFlags = reader->GetInt32("object_selection_filter_flags", 0x3FFF);
model->ScenarioselectLastTab = reader->GetInt32("scenarioselect_last_tab", 0);
model->scenarioSelectLastTab = reader->GetInt32("scenarioselect_last_tab", 0);
model->scenarioPreviewScreenshots = reader->GetBoolean("scenario_preview_screenshots", false);
model->ListRideVehiclesSeparately = reader->GetBoolean("list_ride_vehicles_separately", false);
model->WindowButtonsOnTheLeft = reader->GetBoolean("window_buttons_on_the_left", kWindowButtonsOnTheLeftDefault);
model->EnlargedUi = reader->GetBoolean("enlarged_ui", kEnlargedUiDefault);
@@ -402,7 +403,8 @@ namespace OpenRCT2::Config
writer->WriteString("current_title_sequence", model->CurrentTitleSequencePreset);
writer->WriteBoolean("random_title_sequence", model->RandomTitleSequence);
writer->WriteInt32("object_selection_filter_flags", model->ObjectSelectionFilterFlags);
writer->WriteInt32("scenarioselect_last_tab", model->ScenarioselectLastTab);
writer->WriteInt32("scenarioselect_last_tab", model->scenarioSelectLastTab);
writer->WriteBoolean("scenario_preview_screenshots", model->scenarioPreviewScreenshots);
writer->WriteBoolean("list_ride_vehicles_separately", model->ListRideVehiclesSeparately);
writer->WriteBoolean("window_buttons_on_the_left", model->WindowButtonsOnTheLeft);
writer->WriteBoolean("enlarged_ui", model->EnlargedUi);

View File

@@ -142,7 +142,8 @@ namespace OpenRCT2::Config
u8string CurrentThemePreset;
u8string CurrentTitleSequencePreset;
int32_t ObjectSelectionFilterFlags;
int32_t ScenarioselectLastTab;
int32_t scenarioSelectLastTab;
bool scenarioPreviewScreenshots;
bool ListRideVehiclesSeparately;
bool WindowButtonsOnTheLeft;
bool EnlargedUi;