1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-31 10:45:16 +01:00

Load scenario previews using temp objects too

This commit is contained in:
Aaron van Geffen
2025-05-27 23:17:25 +02:00
parent d51a1754b4
commit 342f10a63c

View File

@@ -244,29 +244,17 @@ namespace OpenRCT2::Ui::Windows
auto& objManager = GetContext()->GetObjectManager();
// Unload current scenario meta object if it's not the one we need
auto* loadedObject = objManager.GetLoadedObject(ObjectType::scenarioMeta, 0);
if (loadedObject != nullptr && loadedObject->GetIdentifier() != source.textObjectId)
if (auto obj = objManager.LoadTempObject(source.textObjectId); obj != nullptr)
{
objManager.UnloadObjects({ loadedObject->GetDescriptor() });
loadedObject = nullptr;
auto& scenarioMetaObj = reinterpret_cast<ScenarioMetaObject&>(*obj);
ParkPreview preview{};
preview.images.push_back(scenarioMetaObj.GetMiniMapImage());
preview.images.push_back(scenarioMetaObj.GetPreviewImage());
_preview = preview;
scenarioMetaObj.Unload();
}
// Load the relevant scenario meta file if it hasn't been loaded yet
if (loadedObject == nullptr)
{
loadedObject = objManager.LoadObject(source.textObjectId);
if (loadedObject == nullptr)
return;
}
auto* scenarioMetaObj = reinterpret_cast<ScenarioMetaObject*>(loadedObject);
ParkPreview preview{};
preview.images.push_back(scenarioMetaObj->GetMiniMapImage());
preview.images.push_back(scenarioMetaObj->GetPreviewImage());
_preview = preview;
}
}