2017-01-31 19:37:55 +01:00
|
|
|
/*****************************************************************************
|
2018-06-15 14:07:34 +02:00
|
|
|
* Copyright (c) 2014-2018 OpenRCT2 developers
|
2017-01-31 19:37:55 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* For a complete list of all authors, please refer to contributors.md
|
|
|
|
* Interested in contributing? Visit https://github.com/OpenRCT2/OpenRCT2
|
2017-01-31 19:37:55 +01:00
|
|
|
*
|
2018-06-15 14:07:34 +02:00
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
2017-01-31 19:37:55 +01:00
|
|
|
*****************************************************************************/
|
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
#include "ParkImporter.h"
|
|
|
|
|
2018-04-10 14:19:23 +02:00
|
|
|
#include "Context.h"
|
2017-01-31 19:37:55 +01:00
|
|
|
#include "core/Path.hpp"
|
|
|
|
#include "core/String.hpp"
|
2017-06-22 19:57:25 +02:00
|
|
|
#include "object/ObjectManager.h"
|
|
|
|
#include "object/ObjectRepository.h"
|
2018-06-22 23:25:16 +02:00
|
|
|
|
|
|
|
#include <memory>
|
2017-01-31 19:37:55 +01:00
|
|
|
|
2017-01-31 20:15:48 +01:00
|
|
|
namespace ParkImporter
|
2017-01-31 19:37:55 +01:00
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
std::unique_ptr<IParkImporter> Create(const std::string& hintPath)
|
2017-01-31 19:37:55 +01:00
|
|
|
{
|
2018-04-20 23:16:37 +02:00
|
|
|
std::unique_ptr<IParkImporter> parkImporter;
|
2017-01-31 20:15:48 +01:00
|
|
|
std::string extension = Path::GetExtension(hintPath);
|
|
|
|
if (ExtensionIsRCT1(extension))
|
|
|
|
{
|
|
|
|
parkImporter = CreateS4();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-04-10 14:19:23 +02:00
|
|
|
auto context = OpenRCT2::GetContext();
|
2018-08-29 09:27:35 +02:00
|
|
|
parkImporter = CreateS6(context->GetObjectRepository());
|
2017-01-31 20:15:48 +01:00
|
|
|
}
|
|
|
|
return parkImporter;
|
2017-01-31 19:37:55 +01:00
|
|
|
}
|
2017-01-31 20:15:48 +01:00
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
bool ExtensionIsRCT1(const std::string& extension)
|
2017-01-31 20:15:48 +01:00
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
return String::Equals(extension, ".sc4", true) || String::Equals(extension, ".sv4", true);
|
2017-01-31 20:15:48 +01:00
|
|
|
}
|
|
|
|
|
2018-06-22 23:25:16 +02:00
|
|
|
bool ExtensionIsScenario(const std::string& extension)
|
2017-01-31 20:15:48 +01:00
|
|
|
{
|
2018-06-22 23:25:16 +02:00
|
|
|
return String::Equals(extension, ".sc4", true) || String::Equals(extension, ".sc6", true);
|
2017-01-31 20:15:48 +01:00
|
|
|
}
|
2018-06-22 23:25:16 +02:00
|
|
|
} // namespace ParkImporter
|