2017-03-24 18:29:45 +01:00
|
|
|
/*****************************************************************************
|
2020-07-21 15:04:34 +02:00
|
|
|
* Copyright (c) 2014-2020 OpenRCT2 developers
|
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
|
|
|
|
*
|
|
|
|
* OpenRCT2 is licensed under the GNU General Public License version 3.
|
|
|
|
*****************************************************************************/
|
2017-03-24 18:29:45 +01:00
|
|
|
|
2017-06-02 20:08:03 +02:00
|
|
|
#include "Ui.h"
|
2018-06-22 23:22:29 +02:00
|
|
|
|
2017-03-24 18:29:45 +01:00
|
|
|
#include "UiContext.h"
|
2018-06-22 23:22:29 +02:00
|
|
|
#include "audio/AudioContext.h"
|
|
|
|
#include "drawing/BitmapReader.h"
|
2017-03-24 18:29:45 +01:00
|
|
|
|
2018-06-22 23:22:29 +02:00
|
|
|
#include <openrct2/Context.h>
|
|
|
|
#include <openrct2/OpenRCT2.h>
|
|
|
|
#include <openrct2/PlatformEnvironment.h>
|
|
|
|
#include <openrct2/audio/AudioContext.h>
|
2020-01-19 22:48:50 +01:00
|
|
|
#include <openrct2/cmdline/CommandLine.hpp>
|
2017-09-18 17:05:28 +02:00
|
|
|
#include <openrct2/platform/platform.h>
|
2018-06-22 23:22:29 +02:00
|
|
|
#include <openrct2/ui/UiContext.h>
|
2017-06-25 19:49:04 +02:00
|
|
|
|
2017-03-24 18:29:45 +01:00
|
|
|
using namespace OpenRCT2;
|
2017-05-06 23:48:55 +02:00
|
|
|
using namespace OpenRCT2::Audio;
|
2017-03-24 18:29:45 +01:00
|
|
|
using namespace OpenRCT2::Ui;
|
|
|
|
|
2018-06-22 23:22:29 +02:00
|
|
|
template<typename T> static std::shared_ptr<T> to_shared(std::unique_ptr<T>&& src)
|
2018-04-20 20:58:59 +02:00
|
|
|
{
|
|
|
|
return std::shared_ptr<T>(std::move(src));
|
|
|
|
}
|
|
|
|
|
2017-03-24 18:29:45 +01:00
|
|
|
/**
|
2017-10-03 00:00:32 +02:00
|
|
|
* Main entry point for non-Windows systems. Windows instead uses its own DLL proxy.
|
2017-03-24 18:29:45 +01:00
|
|
|
*/
|
2018-04-13 00:07:18 +02:00
|
|
|
#if defined(_MSC_VER) && !defined(__DISABLE_DLL_PROXY__)
|
2018-06-22 23:22:29 +02:00
|
|
|
int NormalisedMain(int argc, const char** argv)
|
2017-06-02 20:08:03 +02:00
|
|
|
#else
|
2018-06-22 23:22:29 +02:00
|
|
|
int main(int argc, const char** argv)
|
2017-06-02 20:08:03 +02:00
|
|
|
#endif
|
2017-03-24 18:29:45 +01:00
|
|
|
{
|
2019-10-05 18:57:07 +02:00
|
|
|
std::unique_ptr<IContext> context;
|
2019-10-05 21:26:55 +02:00
|
|
|
int32_t rc = EXIT_SUCCESS;
|
2018-01-01 23:51:43 +01:00
|
|
|
int runGame = cmdline_run(argv, argc);
|
2017-05-08 22:36:35 +02:00
|
|
|
core_init();
|
2018-05-09 00:39:03 +02:00
|
|
|
RegisterBitmapReader();
|
2020-01-19 22:48:50 +01:00
|
|
|
if (runGame == EXITCODE_CONTINUE)
|
2017-05-08 22:36:35 +02:00
|
|
|
{
|
2017-06-04 00:10:20 +02:00
|
|
|
if (gOpenRCT2Headless)
|
|
|
|
{
|
|
|
|
// Run OpenRCT2 with a plain context
|
2019-10-05 18:57:07 +02:00
|
|
|
context = CreateContext();
|
2017-06-04 00:10:20 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Run OpenRCT2 with a UI context
|
2018-04-20 20:58:59 +02:00
|
|
|
auto env = to_shared(CreatePlatformEnvironment());
|
|
|
|
auto audioContext = to_shared(CreateAudioContext());
|
|
|
|
auto uiContext = to_shared(CreateUiContext(env));
|
2019-10-05 18:57:07 +02:00
|
|
|
context = CreateContext(env, audioContext, uiContext);
|
|
|
|
}
|
2019-10-05 21:26:55 +02:00
|
|
|
rc = context->RunOpenRCT2(argc, argv);
|
|
|
|
}
|
2020-01-19 22:48:50 +01:00
|
|
|
else if (runGame == EXITCODE_FAIL)
|
2019-10-05 21:26:55 +02:00
|
|
|
{
|
|
|
|
rc = EXIT_FAILURE;
|
2017-05-08 22:36:35 +02:00
|
|
|
}
|
2019-10-05 21:26:55 +02:00
|
|
|
return rc;
|
2017-03-24 18:29:45 +01:00
|
|
|
}
|
2017-06-15 14:22:15 +02:00
|
|
|
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
extern "C" {
|
2018-06-22 23:22:29 +02:00
|
|
|
int SDL_main(int argc, const char* argv[])
|
2017-06-15 14:22:15 +02:00
|
|
|
{
|
|
|
|
return main(argc, argv);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|