mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-25 15:54:31 +01:00
Invert Context and UiContext dependencies
This commit is contained in:
@@ -22,8 +22,12 @@
|
||||
#include <shellapi.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
#include <openrct2-ui/UiContext.h>
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
#define DLLEXPORT extern "C" __declspec(dllexport)
|
||||
|
||||
static char * * GetCommandLineArgs(int argc, wchar_t * * argvW);
|
||||
@@ -39,13 +43,13 @@ DLLEXPORT int LaunchOpenRCT2(int argc, wchar_t * * argvW)
|
||||
return -1;
|
||||
}
|
||||
|
||||
OpenRCT2::IContext * context = OpenRCT2::CreateContext();
|
||||
OpenRCT2::Ui::IUiContext * uiContext = OpenRCT2::Ui::CreateContext(context);
|
||||
IUiContext * uiContext = OpenRCT2::Ui::CreateContext();
|
||||
IContext * context = OpenRCT2::CreateContext(uiContext);
|
||||
|
||||
int exitCode = context->RunOpenRCT2(argc, argv);
|
||||
|
||||
delete uiContext;
|
||||
delete context;
|
||||
delete uiContext;
|
||||
|
||||
FreeCommandLineArgs(argc, argv);
|
||||
return exitCode;
|
||||
|
||||
@@ -17,41 +17,56 @@
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/core/Registration.hpp>
|
||||
#include <openrct2/drawing/IDrawingEngine.h>
|
||||
#include <openrct2/ui/UiContext.h>
|
||||
#include "drawing/engines/DrawingEngines.h"
|
||||
#include "UiContext.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Drawing;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
class UiContext : public IUiContext
|
||||
{
|
||||
private:
|
||||
IContext * const _context;
|
||||
std::vector<std::unique_ptr<IRegistration>> _registrations;
|
||||
|
||||
// Drawing engines
|
||||
SoftwareDrawingEngineFactory _softwareDrawingFactory;
|
||||
HardwareDisplayDrawingEngineFactory _hardwareDrawingFactory;
|
||||
#ifndef DISABLE_OPENGL
|
||||
OpenGLDrawingEngineFactory _openglDrawingFactory;
|
||||
#endif
|
||||
|
||||
public:
|
||||
UiContext(IContext * context) :
|
||||
_context(context)
|
||||
UiContext()
|
||||
{
|
||||
_registrations.emplace_back(context->RegisterDrawingEngine(DRAWING_ENGINE_SOFTWARE, &_softwareDrawingFactory));
|
||||
_registrations.emplace_back(context->RegisterDrawingEngine(DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY, &_hardwareDrawingFactory));
|
||||
_registrations.emplace_back(context->RegisterDrawingEngine(DRAWING_ENGINE_OPENGL, &_openglDrawingFactory));
|
||||
}
|
||||
|
||||
~UiContext() override
|
||||
{
|
||||
}
|
||||
|
||||
// Window
|
||||
void * GetWindow() override { return nullptr; }
|
||||
sint32 GetWidth() override { return 0; }
|
||||
sint32 GetHeight() override { return 0; }
|
||||
void SetFullscreenMode(FULLSCREEN_MODE mode) override { }
|
||||
|
||||
// Drawing
|
||||
IDrawingEngine * CreateDrawingEngine(DRAWING_ENGINE_TYPE type) override
|
||||
{
|
||||
switch ((sint32)type) {
|
||||
case DRAWING_ENGINE_SOFTWARE:
|
||||
return CreateSoftwareDrawingEngine();
|
||||
case DRAWING_ENGINE_SOFTWARE_WITH_HARDWARE_DISPLAY:
|
||||
return CreateHardwareDisplayDrawingEngine();
|
||||
#ifndef DISABLE_OPENGL
|
||||
case DRAWING_ENGINE_OPENGL:
|
||||
return CreateOpenGLDrawingEngine();
|
||||
#endif
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
// Text input
|
||||
bool IsTextInputActive() override { return false; }
|
||||
const TextInputSession * StartTextInput(utf8 * buffer, sint32 bufferSize) override { return nullptr; }
|
||||
void StopTextInput() override { }
|
||||
};
|
||||
|
||||
IUiContext * OpenRCT2::Ui::CreateContext(IContext * context)
|
||||
IUiContext * OpenRCT2::Ui::CreateContext()
|
||||
{
|
||||
return new UiContext(context);
|
||||
return new UiContext();
|
||||
}
|
||||
|
||||
@@ -24,11 +24,8 @@ namespace OpenRCT2
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
interface IUiContext
|
||||
{
|
||||
virtual ~IUiContext() { }
|
||||
};
|
||||
interface IUiContext;
|
||||
|
||||
IUiContext * CreateContext(IContext * context);
|
||||
IUiContext * CreateContext();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,29 +17,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <openrct2/common.h>
|
||||
#include <openrct2/drawing/IDrawingEngine.h>
|
||||
|
||||
namespace OpenRCT2 { namespace Ui
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class SoftwareDrawingEngineFactory : public Drawing::IDrawingEngineFactory
|
||||
namespace Drawing
|
||||
{
|
||||
public:
|
||||
IDrawingEngine * Create() override;
|
||||
};
|
||||
interface IDrawingEngine;
|
||||
}
|
||||
|
||||
class HardwareDisplayDrawingEngineFactory : public Drawing::IDrawingEngineFactory
|
||||
namespace Ui
|
||||
{
|
||||
public:
|
||||
IDrawingEngine * Create() override;
|
||||
};
|
||||
|
||||
#ifndef DISABLE_OPENGL
|
||||
|
||||
class OpenGLDrawingEngineFactory : public Drawing::IDrawingEngineFactory
|
||||
{
|
||||
public:
|
||||
IDrawingEngine * Create() override;
|
||||
};
|
||||
|
||||
#endif // DISABLE_OPENGL
|
||||
} }
|
||||
Drawing::IDrawingEngine * CreateSoftwareDrawingEngine();
|
||||
Drawing::IDrawingEngine * CreateHardwareDisplayDrawingEngine();
|
||||
#ifndef DISABLE_OPENGL
|
||||
Drawing::IDrawingEngine * CreateOpenGLDrawingEngine();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ extern "C"
|
||||
#include <openrct2/drawing/lightfx.h>
|
||||
}
|
||||
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
class SoftwareDrawingEngine;
|
||||
|
||||
struct DirtyGrid
|
||||
@@ -828,12 +830,12 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
IDrawingEngine * OpenRCT2::Ui::SoftwareDrawingEngineFactory::Create()
|
||||
IDrawingEngine * OpenRCT2::Ui::CreateSoftwareDrawingEngine()
|
||||
{
|
||||
return new SoftwareDrawingEngine(false);
|
||||
}
|
||||
|
||||
IDrawingEngine * OpenRCT2::Ui::HardwareDisplayDrawingEngineFactory::Create()
|
||||
IDrawingEngine * OpenRCT2::Ui::CreateHardwareDisplayDrawingEngine()
|
||||
{
|
||||
return new SoftwareDrawingEngine(true);
|
||||
}
|
||||
|
||||
@@ -14,16 +14,7 @@
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifdef DISABLE_OPENGL
|
||||
|
||||
#include "../../IDrawingEngine.h"
|
||||
|
||||
IDrawingEngine * DrawingEngineFactory::CreateOpenGL()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
#else
|
||||
#ifndef DISABLE_OPENGL
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
@@ -59,6 +50,10 @@ extern "C"
|
||||
#include "TextureCache.h"
|
||||
#include "DrawCommands.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Drawing;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
struct OpenGLVersion
|
||||
{
|
||||
GLint Major;
|
||||
@@ -499,7 +494,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
IDrawingEngine * OpenRCT2::Ui::OpenGLDrawingEngineFactory::Create()
|
||||
IDrawingEngine * OpenRCT2::Ui::CreateOpenGLDrawingEngine()
|
||||
{
|
||||
return new OpenGLDrawingEngine();
|
||||
}
|
||||
|
||||
@@ -14,41 +14,69 @@
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "drawing/IDrawingEngine.h"
|
||||
#include <exception>
|
||||
#include "Context.h"
|
||||
#include "OpenRCT2.h"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
class Context : public IContext
|
||||
namespace OpenRCT2
|
||||
{
|
||||
public:
|
||||
Context()
|
||||
class Context : public IContext
|
||||
{
|
||||
}
|
||||
private:
|
||||
IUiContext * const _uiContext;
|
||||
|
||||
~Context() override
|
||||
{
|
||||
}
|
||||
public:
|
||||
// Singleton of Context.
|
||||
// Remove this when GetContext() is no longer called so that
|
||||
// multiple instances can be created in parallel
|
||||
static Context * Instance;
|
||||
|
||||
IRegistration * RegisterDrawingEngine(sint32 type, Drawing::IDrawingEngineFactory * factory) override
|
||||
{
|
||||
return Drawing::DrawingEngineFactory::Register((DRAWING_ENGINE)type, factory);
|
||||
}
|
||||
|
||||
sint32 RunOpenRCT2(int argc, char * * argv) override
|
||||
{
|
||||
core_init();
|
||||
int runGame = cmdline_run((const char * *)argv, argc);
|
||||
if (runGame == 1)
|
||||
public:
|
||||
Context(IUiContext * uiContext)
|
||||
: _uiContext(uiContext)
|
||||
{
|
||||
openrct2_launch();
|
||||
Instance = this;
|
||||
}
|
||||
return gExitCode;
|
||||
}
|
||||
};
|
||||
|
||||
IContext * OpenRCT2::CreateContext()
|
||||
{
|
||||
return new Context();
|
||||
~Context() override
|
||||
{
|
||||
Instance = nullptr;
|
||||
}
|
||||
|
||||
IUiContext * GetUiContext() override
|
||||
{
|
||||
return _uiContext;
|
||||
}
|
||||
|
||||
sint32 RunOpenRCT2(int argc, char * * argv) override
|
||||
{
|
||||
core_init();
|
||||
int runGame = cmdline_run((const char * *)argv, argc);
|
||||
if (runGame == 1)
|
||||
{
|
||||
openrct2_launch();
|
||||
}
|
||||
return gExitCode;
|
||||
}
|
||||
};
|
||||
|
||||
Context * Context::Instance = nullptr;
|
||||
|
||||
IContext * CreateContext()
|
||||
{
|
||||
return new Context(nullptr);
|
||||
}
|
||||
|
||||
IContext * CreateContext(IUiContext * uiContext)
|
||||
{
|
||||
return new Context(uiContext);
|
||||
}
|
||||
|
||||
IContext * GetContext()
|
||||
{
|
||||
return Context::Instance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,11 +20,9 @@
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
interface IRegistration;
|
||||
|
||||
namespace Drawing
|
||||
namespace Ui
|
||||
{
|
||||
interface IDrawingEngineFactory;
|
||||
interface IUiContext;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,9 +31,12 @@ namespace OpenRCT2
|
||||
interface IContext
|
||||
{
|
||||
virtual ~IContext() = default;
|
||||
virtual IRegistration * RegisterDrawingEngine(sint32 type, Drawing::IDrawingEngineFactory * factory) abstract;
|
||||
|
||||
virtual Ui::IUiContext * GetUiContext() abstract;
|
||||
virtual sint32 RunOpenRCT2(int argc, char * * argv) abstract;
|
||||
};
|
||||
|
||||
IContext * CreateContext();
|
||||
IContext * CreateContext(Ui::IUiContext * uiContext);
|
||||
IContext * GetContext();
|
||||
}
|
||||
|
||||
@@ -18,24 +18,28 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
extern "C" {
|
||||
extern "C"
|
||||
{
|
||||
#include "drawing.h"
|
||||
}
|
||||
|
||||
interface IDrawingEngine;
|
||||
|
||||
interface IDrawingContext
|
||||
namespace OpenRCT2 { namespace Drawing
|
||||
{
|
||||
virtual ~IDrawingContext() { }
|
||||
interface IDrawingEngine;
|
||||
|
||||
virtual IDrawingEngine * GetEngine() abstract;
|
||||
interface IDrawingContext
|
||||
{
|
||||
virtual ~IDrawingContext() { }
|
||||
|
||||
virtual void Clear(uint8 paletteIndex) abstract;
|
||||
virtual void FillRect(uint32 colour, sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
|
||||
virtual void FilterRect(FILTER_PALETTE_ID palette, sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
|
||||
virtual void DrawLine(uint32 colour, sint32 x1, sint32 y1, sint32 x2, sint32 y2) abstract;
|
||||
virtual void DrawSprite(uint32 image, sint32 x, sint32 y, uint32 tertiaryColour) abstract;
|
||||
virtual void DrawSpriteRawMasked(sint32 x, sint32 y, uint32 maskImage, uint32 colourImage) abstract;
|
||||
virtual void DrawSpriteSolid(uint32 image, sint32 x, sint32 y, uint8 colour) abstract;
|
||||
virtual void DrawGlyph(uint32 image, sint32 x, sint32 y, uint8 * palette) abstract;
|
||||
};
|
||||
virtual OpenRCT2::Drawing::IDrawingEngine * GetEngine() abstract;
|
||||
|
||||
virtual void Clear(uint8 paletteIndex) abstract;
|
||||
virtual void FillRect(uint32 colour, sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
|
||||
virtual void FilterRect(FILTER_PALETTE_ID palette, sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
|
||||
virtual void DrawLine(uint32 colour, sint32 x1, sint32 y1, sint32 x2, sint32 y2) abstract;
|
||||
virtual void DrawSprite(uint32 image, sint32 x, sint32 y, uint32 tertiaryColour) abstract;
|
||||
virtual void DrawSpriteRawMasked(sint32 x, sint32 y, uint32 maskImage, uint32 colourImage) abstract;
|
||||
virtual void DrawSpriteSolid(uint32 image, sint32 x, sint32 y, uint8 colour) abstract;
|
||||
virtual void DrawGlyph(uint32 image, sint32 x, sint32 y, uint8 * palette) abstract;
|
||||
};
|
||||
} }
|
||||
|
||||
@@ -42,59 +42,44 @@ enum DRAWING_ENGINE_FLAGS
|
||||
#ifdef __cplusplus
|
||||
|
||||
struct rct_drawpixelinfo;
|
||||
interface IDrawingContext;
|
||||
|
||||
interface IDrawingEngine
|
||||
namespace OpenRCT2 { namespace Drawing
|
||||
{
|
||||
virtual ~IDrawingEngine() { }
|
||||
interface IDrawingContext;
|
||||
|
||||
virtual void Initialise(SDL_Window * window) abstract;
|
||||
virtual void Resize(uint32 width, uint32 height) abstract;
|
||||
virtual void SetPalette(SDL_Color * colours) abstract;
|
||||
|
||||
virtual void SetUncappedFrameRate(bool uncapped) abstract;
|
||||
|
||||
virtual void Invalidate(sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
|
||||
virtual void Draw() abstract;
|
||||
virtual void CopyRect(sint32 x, sint32 y, sint32 width, sint32 height, sint32 dx, sint32 dy) abstract;
|
||||
virtual sint32 Screenshot() abstract;
|
||||
|
||||
virtual IDrawingContext * GetDrawingContext(rct_drawpixelinfo * dpi) abstract;
|
||||
virtual rct_drawpixelinfo * GetDrawingPixelInfo() abstract;
|
||||
|
||||
virtual DRAWING_ENGINE_FLAGS GetFlags() abstract;
|
||||
|
||||
virtual void InvalidateImage(uint32 image) abstract;
|
||||
};
|
||||
|
||||
interface IRainDrawer
|
||||
{
|
||||
virtual ~IRainDrawer() { }
|
||||
virtual void Draw(sint32 x,
|
||||
sint32 y,
|
||||
sint32 width,
|
||||
sint32 height,
|
||||
sint32 xStart,
|
||||
sint32 yStart) abstract;
|
||||
};
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
interface IRegistration;
|
||||
|
||||
namespace Drawing
|
||||
interface IDrawingEngine
|
||||
{
|
||||
interface IDrawingEngineFactory
|
||||
{
|
||||
virtual ~IDrawingEngineFactory() { }
|
||||
virtual IDrawingEngine * Create() abstract;
|
||||
};
|
||||
virtual ~IDrawingEngine() { }
|
||||
|
||||
namespace DrawingEngineFactory
|
||||
{
|
||||
IRegistration * Register(DRAWING_ENGINE type, IDrawingEngineFactory * factory);
|
||||
}
|
||||
}
|
||||
}
|
||||
virtual void Initialise(SDL_Window * window) abstract;
|
||||
virtual void Resize(uint32 width, uint32 height) abstract;
|
||||
virtual void SetPalette(SDL_Color * colours) abstract;
|
||||
|
||||
virtual void SetUncappedFrameRate(bool uncapped) abstract;
|
||||
|
||||
virtual void Invalidate(sint32 left, sint32 top, sint32 right, sint32 bottom) abstract;
|
||||
virtual void Draw() abstract;
|
||||
virtual void CopyRect(sint32 x, sint32 y, sint32 width, sint32 height, sint32 dx, sint32 dy) abstract;
|
||||
virtual sint32 Screenshot() abstract;
|
||||
|
||||
virtual IDrawingContext * GetDrawingContext(rct_drawpixelinfo * dpi) abstract;
|
||||
virtual rct_drawpixelinfo * GetDrawingPixelInfo() abstract;
|
||||
|
||||
virtual DRAWING_ENGINE_FLAGS GetFlags() abstract;
|
||||
|
||||
virtual void InvalidateImage(uint32 image) abstract;
|
||||
};
|
||||
|
||||
interface IRainDrawer
|
||||
{
|
||||
virtual ~IRainDrawer() { }
|
||||
virtual void Draw(sint32 x,
|
||||
sint32 y,
|
||||
sint32 width,
|
||||
sint32 height,
|
||||
sint32 xStart,
|
||||
sint32 yStart) abstract;
|
||||
};
|
||||
} }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#pragma endregion
|
||||
|
||||
#include <stdexcept>
|
||||
#include "../Context.h"
|
||||
#include "../ui/UiContext.h"
|
||||
#include "../core/Exception.hpp"
|
||||
#include "../core/Registration.hpp"
|
||||
#include "IDrawingContext.h"
|
||||
@@ -33,28 +35,10 @@ extern "C"
|
||||
|
||||
using namespace OpenRCT2;
|
||||
using namespace OpenRCT2::Drawing;
|
||||
using namespace OpenRCT2::Ui;
|
||||
|
||||
static sint32 _drawingEngineType = DRAWING_ENGINE_SOFTWARE;
|
||||
static IDrawingEngine * _drawingEngine = nullptr;
|
||||
static IDrawingEngineFactory * _drawingEngineFactories[DRAWING_ENGINE_COUNT] = { nullptr };
|
||||
|
||||
IRegistration * DrawingEngineFactory::Register(DRAWING_ENGINE type, IDrawingEngineFactory * factory)
|
||||
{
|
||||
if (_drawingEngineFactories[type] != nullptr)
|
||||
{
|
||||
throw std::invalid_argument("Engine already registered.");
|
||||
}
|
||||
_drawingEngineFactories[type] = factory;
|
||||
|
||||
return Registration::Create([type, factory]() -> void
|
||||
{
|
||||
if (_drawingEngineFactories[type] != factory)
|
||||
{
|
||||
throw std::invalid_argument("Engine not registered.");
|
||||
}
|
||||
_drawingEngineFactories[type] = nullptr;
|
||||
});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -94,14 +78,10 @@ extern "C"
|
||||
assert(_drawingEngine == nullptr);
|
||||
|
||||
_drawingEngineType = gConfigGeneral.drawing_engine;
|
||||
IDrawingEngineFactory * deFactory = _drawingEngineFactories[_drawingEngineType];
|
||||
if (deFactory == nullptr)
|
||||
{
|
||||
log_fatal("Drawing engine not registered.");
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
IDrawingEngine * drawingEngine = deFactory->Create();
|
||||
IContext * context = GetContext();
|
||||
IUiContext * uiContext = context->GetUiContext();
|
||||
IDrawingEngine * drawingEngine = uiContext->CreateDrawingEngine((DRAWING_ENGINE_TYPE)_drawingEngineType);
|
||||
if (drawingEngine == nullptr)
|
||||
{
|
||||
if (_drawingEngineType == DRAWING_ENGINE_SOFTWARE)
|
||||
|
||||
@@ -26,6 +26,8 @@ extern "C"
|
||||
#include "Rain.h"
|
||||
#include "../core/Math.hpp"
|
||||
|
||||
using namespace OpenRCT2::Drawing;
|
||||
|
||||
typedef void (* DrawRainFunc)(IRainDrawer * rainDrawer, sint32 left, sint32 top, sint32 width, sint32 height);
|
||||
|
||||
static void DrawLightRain(IRainDrawer * rainDrawer, sint32 left, sint32 top, sint32 width, sint32 height);
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
interface IRainDrawer;
|
||||
namespace OpenRCT2 { namespace Drawing
|
||||
{
|
||||
interface IRainDrawer;
|
||||
} }
|
||||
|
||||
void DrawRain(rct_drawpixelinfo * dpi, IRainDrawer * rainDrawer);
|
||||
void DrawRain(rct_drawpixelinfo * dpi, OpenRCT2::Drawing::IRainDrawer * rainDrawer);
|
||||
|
||||
70
src/openrct2/ui/UiContext.h
Normal file
70
src/openrct2/ui/UiContext.h
Normal file
@@ -0,0 +1,70 @@
|
||||
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
||||
/*****************************************************************************
|
||||
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
||||
*
|
||||
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
|
||||
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
|
||||
*
|
||||
* OpenRCT2 is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* A full copy of the GNU General Public License can be found in licence.txt
|
||||
*****************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../common.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
namespace Drawing
|
||||
{
|
||||
enum class DRAWING_ENGINE_TYPE;
|
||||
interface IDrawingEngine;
|
||||
}
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
enum class FULLSCREEN_MODE
|
||||
{
|
||||
WINDOWED,
|
||||
FULLSCREEN,
|
||||
FULLSCREEN_DESKTOP,
|
||||
};
|
||||
|
||||
struct TextInputSession
|
||||
{
|
||||
const utf8 * Buffer; // UTF-8 stream
|
||||
size_t BufferSize; // Maximum number of bytes (excluding null terminator)
|
||||
size_t Size; // Number of bytes (excluding null terminator)
|
||||
uint32 Length; // Number of codepoints
|
||||
size_t SelectionStart; // Selection start, in bytes
|
||||
size_t SelectionSize; // Selection length in bytes
|
||||
};
|
||||
|
||||
/**
|
||||
* Represents the window or screen that OpenRCT2 is presented on.
|
||||
*/
|
||||
interface IUiContext
|
||||
{
|
||||
virtual ~IUiContext() = default;
|
||||
|
||||
// Window
|
||||
virtual void * GetWindow() abstract;
|
||||
virtual sint32 GetWidth() abstract;
|
||||
virtual sint32 GetHeight() abstract;
|
||||
virtual void SetFullscreenMode(FULLSCREEN_MODE mode) abstract;
|
||||
|
||||
// Drawing
|
||||
virtual Drawing::IDrawingEngine * CreateDrawingEngine(Drawing::DRAWING_ENGINE_TYPE type) abstract;
|
||||
|
||||
// Text input
|
||||
virtual bool IsTextInputActive() abstract;
|
||||
virtual const TextInputSession * StartTextInput(utf8 * buffer, sint32 bufferSize) abstract;
|
||||
virtual void StopTextInput() abstract;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user