mirror of https://github.com/OpenRCT2/OpenRCT2.git
Load objects for title editor and scenario editor
This commit is contained in:
parent
f9d7ee93fc
commit
f5e77a9e15
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/FileClassifier.h>
|
||||
#include <openrct2/object/ObjectManager.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/ParkImporter.h>
|
||||
#include <openrct2/scenario/ScenarioSources.h>
|
||||
|
@ -374,10 +375,16 @@ static void window_title_editor_mouseup(rct_window * w, rct_widgetindex widgetIn
|
|||
case WIDX_TITLE_EDITOR_LOAD_SAVE:
|
||||
if (w->selected_list_item >= 0 && w->selected_list_item < (sint16)_editingTitleSequence->NumSaves)
|
||||
{
|
||||
TitleSequenceParkHandle * handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
|
||||
const utf8 * extension = path_get_extension(handle->HintPath);
|
||||
bool isScenario = park_importer_extension_is_scenario(extension);
|
||||
park_importer_load_from_stream(handle->Stream, handle->HintPath);
|
||||
auto handle = TitleSequenceGetParkHandle(_editingTitleSequence, w->selected_list_item);
|
||||
auto stream = (IStream *)handle->Stream;
|
||||
auto hintPath = String::ToStd(handle->HintPath);
|
||||
|
||||
bool isScenario = ParkImporter::ExtensionIsScenario(hintPath);
|
||||
auto objectMgr = OpenRCT2::GetContext()->GetObjectManager();
|
||||
auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
|
||||
auto result = parkImporter->LoadFromStream(stream, isScenario);
|
||||
objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
|
||||
parkImporter->Import();
|
||||
|
||||
if (isScenario)
|
||||
scenario_begin();
|
||||
|
|
|
@ -52,20 +52,3 @@ namespace ParkImporter
|
|||
String::Equals(extension, ".sc6", true);
|
||||
}
|
||||
}
|
||||
|
||||
void park_importer_load_from_stream(void * stream_c, const utf8 * hintPath_c)
|
||||
{
|
||||
IStream * stream = (IStream *)stream_c;
|
||||
std::string hintPath = String::ToStd(hintPath_c);
|
||||
|
||||
bool isScenario = ParkImporter::ExtensionIsScenario(hintPath);
|
||||
|
||||
auto parkImporter = std::unique_ptr<IParkImporter>(ParkImporter::Create(hintPath));
|
||||
parkImporter->LoadFromStream(stream, isScenario);
|
||||
parkImporter->Import();
|
||||
}
|
||||
|
||||
bool park_importer_extension_is_scenario(const utf8 * extension)
|
||||
{
|
||||
return ParkImporter::ExtensionIsScenario(String::ToStd(extension));
|
||||
}
|
||||
|
|
|
@ -101,13 +101,3 @@ public:
|
|||
{
|
||||
}
|
||||
};
|
||||
|
||||
void park_importer_load_from_stream(void * stream, const utf8 * hintPath);
|
||||
bool park_importer_extension_is_scenario(const utf8 * extension);
|
||||
|
||||
PARK_LOAD_ERROR ParkLoadResult_GetError(const ParkLoadResult * t);
|
||||
size_t ParkLoadResult_GetMissingObjectsCount(const ParkLoadResult * t);
|
||||
const rct_object_entry * ParkLoadResult_GetMissingObjects(const ParkLoadResult * t);
|
||||
uint8 ParkLoadResult_GetFlag(const ParkLoadResult * t);
|
||||
void ParkLoadResult_Delete(ParkLoadResult * t);
|
||||
ParkLoadResult * ParkLoadResult_CreateInvalidExtension();
|
||||
|
|
|
@ -2856,17 +2856,19 @@ std::unique_ptr<IParkImporter> ParkImporter::CreateS4()
|
|||
|
||||
void load_from_sv4(const utf8 * path)
|
||||
{
|
||||
auto objectMgr = GetContext()->GetObjectManager();
|
||||
auto s4Importer = std::make_unique<S4Importer>();
|
||||
auto result = s4Importer->LoadSavedGame(path);
|
||||
// TODO load objects
|
||||
objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
|
||||
s4Importer->Import();
|
||||
}
|
||||
|
||||
void load_from_sc4(const utf8 * path)
|
||||
{
|
||||
auto objectMgr = GetContext()->GetObjectManager();
|
||||
auto s4Importer = std::make_unique<S4Importer>();
|
||||
auto result = s4Importer->LoadScenario(path);
|
||||
// TODO load objects
|
||||
objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
|
||||
s4Importer->Import();
|
||||
}
|
||||
|
||||
|
|
|
@ -439,11 +439,6 @@ public:
|
|||
// pad_13CE778
|
||||
|
||||
// Fix and set dynamic variables
|
||||
// TODO objects should already be loaded
|
||||
// if (!_objectManager->LoadObjects(_s6.objects, OBJECT_ENTRY_COUNT))
|
||||
// {
|
||||
// throw ObjectLoadException();
|
||||
// }
|
||||
map_strip_ghost_flag_from_elements();
|
||||
map_update_tile_pointers();
|
||||
game_convert_strings_to_utf8();
|
||||
|
@ -851,8 +846,9 @@ void load_from_sv6(const char * path)
|
|||
auto s6Importer = std::make_unique<S6Importer>(context->GetObjectRepository(), context->GetObjectManager());
|
||||
try
|
||||
{
|
||||
auto objectMgr = context->GetObjectManager();
|
||||
auto result = s6Importer->LoadSavedGame(path);
|
||||
// TODO load objects
|
||||
objectMgr->LoadObjects(result.RequiredObjects.data(), result.RequiredObjects.size());
|
||||
s6Importer->Import();
|
||||
game_fix_save_vars();
|
||||
sprite_position_tween_reset();
|
||||
|
|
Loading…
Reference in New Issue