OpenRCT2/src/openrct2-ui/Ui.cpp

79 lines
2.2 KiB
C++
Raw Normal View History

/*****************************************************************************
2020-07-21 15:04:34 +02:00
* Copyright (c) 2014-2020 OpenRCT2 developers
*
* 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.
*****************************************************************************/
#include "Ui.h"
2018-06-22 23:22:29 +02:00
#include "UiContext.h"
2018-06-22 23:22:29 +02:00
#include "audio/AudioContext.h"
#include "drawing/BitmapReader.h"
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>
#include <openrct2/platform/platform.h>
2018-06-22 23:22:29 +02:00
#include <openrct2/ui/UiContext.h>
using namespace OpenRCT2;
2017-05-06 23:48:55 +02:00
using namespace OpenRCT2::Audio;
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)
{
return std::shared_ptr<T>(std::move(src));
}
/**
2017-10-03 00:00:32 +02:00
* Main entry point for non-Windows systems. Windows instead uses its own DLL proxy.
*/
#if defined(_MSC_VER) && !defined(__DISABLE_DLL_PROXY__)
2018-06-22 23:22:29 +02:00
int NormalisedMain(int argc, const char** argv)
#else
2018-06-22 23:22:29 +02:00
int main(int argc, const char** argv)
#endif
{
2019-10-05 18:57:07 +02:00
std::unique_ptr<IContext> context;
int32_t rc = EXIT_SUCCESS;
int runGame = cmdline_run(argv, argc);
core_init();
2018-05-09 00:39:03 +02:00
RegisterBitmapReader();
2020-01-19 22:48:50 +01:00
if (runGame == EXITCODE_CONTINUE)
{
if (gOpenRCT2Headless)
{
// Run OpenRCT2 with a plain context
2019-10-05 18:57:07 +02:00
context = CreateContext();
}
else
{
// Run OpenRCT2 with a UI context
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);
}
rc = context->RunOpenRCT2(argc, argv);
}
2020-01-19 22:48:50 +01:00
else if (runGame == EXITCODE_FAIL)
{
rc = EXIT_FAILURE;
}
return rc;
}
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