mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-24 00:03:11 +01:00
Merge pull request #25157 from AaronVanGeffen/context-cleanup
Move types and constants out of Context.h
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
union SDL_Event;
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/Version.h>
|
||||
#include <openrct2/config/Config.h>
|
||||
#include <openrct2/core/UTF8.h>
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <cmath>
|
||||
#include <openrct2-ui/UiStringIds.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Diagnostic.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/Input.h>
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
#include <openrct2/interface/Window.h>
|
||||
#include <openrct2/interface/WindowBase.h>
|
||||
|
||||
struct TextInputSession;
|
||||
namespace OpenRCT2
|
||||
{
|
||||
struct TextInputSession;
|
||||
}
|
||||
|
||||
namespace OpenRCT2::Ui
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <openrct2/EditorObjectSelectionSession.h>
|
||||
#include <openrct2/Game.h>
|
||||
#include <openrct2/GameState.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/SpriteIds.h>
|
||||
#include <openrct2/actions/LoadOrQuitAction.h>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Diagnostic.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/OpenRCT2.h>
|
||||
#include <openrct2/audio/Audio.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <openrct2-ui/interface/Widget.h>
|
||||
#include <openrct2-ui/windows/Windows.h>
|
||||
#include <openrct2/Context.h>
|
||||
#include <openrct2/Input.h>
|
||||
#include <openrct2/core/String.hpp>
|
||||
#include <openrct2/core/UTF8.h>
|
||||
#include <openrct2/drawing/Drawing.h>
|
||||
|
||||
@@ -890,7 +890,7 @@ namespace OpenRCT2
|
||||
auto windowManager = _uiContext->GetWindowManager();
|
||||
auto ft = Formatter();
|
||||
ft.Add<uint32_t>(result.TargetVersion);
|
||||
ft.Add<uint32_t>(OpenRCT2::kParkFileCurrentVersion);
|
||||
ft.Add<uint32_t>(kParkFileCurrentVersion);
|
||||
windowManager->ShowError(STR_WARNING_PARK_VERSION_TITLE, STR_WARNING_PARK_VERSION_MESSAGE, ft);
|
||||
}
|
||||
else if (HasObjectsThatUseFallbackImages())
|
||||
@@ -954,14 +954,14 @@ namespace OpenRCT2
|
||||
if (e.MinVersion == e.TargetVersion)
|
||||
{
|
||||
ft.Add<uint32_t>(e.TargetVersion);
|
||||
ft.Add<uint32_t>(OpenRCT2::kParkFileCurrentVersion);
|
||||
ft.Add<uint32_t>(kParkFileCurrentVersion);
|
||||
windowManager->ShowError(STR_ERROR_PARK_VERSION_TITLE, STR_ERROR_PARK_VERSION_TOO_NEW_MESSAGE_2, ft);
|
||||
}
|
||||
else
|
||||
{
|
||||
ft.Add<uint32_t>(e.TargetVersion);
|
||||
ft.Add<uint32_t>(e.MinVersion);
|
||||
ft.Add<uint32_t>(OpenRCT2::kParkFileCurrentVersion);
|
||||
ft.Add<uint32_t>(kParkFileCurrentVersion);
|
||||
windowManager->ShowError(STR_ERROR_PARK_VERSION_TITLE, STR_ERROR_PARK_VERSION_TOO_NEW_MESSAGE, ft);
|
||||
}
|
||||
}
|
||||
@@ -1591,194 +1591,188 @@ namespace OpenRCT2
|
||||
return Context::Instance;
|
||||
}
|
||||
|
||||
void ContextInit()
|
||||
{
|
||||
GetWindowManager()->Init();
|
||||
}
|
||||
|
||||
bool ContextLoadParkFromStream(void* stream)
|
||||
{
|
||||
return GetContext()->LoadParkFromStream(static_cast<IStream*>(stream), "");
|
||||
}
|
||||
|
||||
void ContextSetCurrentCursor(CursorID cursor)
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursor(cursor);
|
||||
}
|
||||
|
||||
void ContextUpdateCursorScale()
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorScale(static_cast<uint8_t>(std::round(Config::Get().general.WindowScale)));
|
||||
}
|
||||
|
||||
void ContextHideCursor()
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorVisible(false);
|
||||
}
|
||||
|
||||
void ContextShowCursor()
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorVisible(true);
|
||||
}
|
||||
|
||||
ScreenCoordsXY ContextGetCursorPosition()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetCursorPosition();
|
||||
}
|
||||
|
||||
ScreenCoordsXY ContextGetCursorPositionScaled()
|
||||
{
|
||||
auto cursorCoords = ContextGetCursorPosition();
|
||||
// Compensate for window scaling.
|
||||
return { static_cast<int32_t>(std::ceil(cursorCoords.x / Config::Get().general.WindowScale)),
|
||||
static_cast<int32_t>(std::ceil(cursorCoords.y / Config::Get().general.WindowScale)) };
|
||||
}
|
||||
|
||||
void ContextSetCursorPosition(const ScreenCoordsXY& cursorPosition)
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorPosition(cursorPosition);
|
||||
}
|
||||
|
||||
const CursorState* ContextGetCursorState()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetCursorState();
|
||||
}
|
||||
|
||||
const uint8_t* ContextGetKeysState()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetKeysState();
|
||||
}
|
||||
|
||||
const uint8_t* ContextGetKeysPressed()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetKeysPressed();
|
||||
}
|
||||
|
||||
TextInputSession* ContextStartTextInput(u8string& buffer, size_t maxLength)
|
||||
{
|
||||
return GetContext()->GetUiContext().StartTextInput(buffer, maxLength);
|
||||
}
|
||||
|
||||
void ContextStopTextInput()
|
||||
{
|
||||
GetContext()->GetUiContext().StopTextInput();
|
||||
}
|
||||
|
||||
bool ContextIsInputActive()
|
||||
{
|
||||
return GetContext()->GetUiContext().IsTextInputActive();
|
||||
}
|
||||
|
||||
void ContextTriggerResize()
|
||||
{
|
||||
return GetContext()->GetUiContext().TriggerResize();
|
||||
}
|
||||
|
||||
void ContextSetFullscreenMode(int32_t mode)
|
||||
{
|
||||
return GetContext()->GetUiContext().SetFullscreenMode(static_cast<FullscreenMode>(mode));
|
||||
}
|
||||
|
||||
void ContextRecreateWindow()
|
||||
{
|
||||
GetContext()->GetUiContext().RecreateWindow();
|
||||
}
|
||||
|
||||
int32_t ContextGetWidth()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetWidth();
|
||||
}
|
||||
|
||||
int32_t ContextGetHeight()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetHeight();
|
||||
}
|
||||
|
||||
bool ContextHasFocus()
|
||||
{
|
||||
return GetContext()->GetUiContext().HasFocus();
|
||||
}
|
||||
|
||||
void ContextSetCursorTrap(bool value)
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorTrap(value);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenWindow(WindowClass wc)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenWindow(wc);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenWindowView(uint8_t wc)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenView(wc);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenDetails(type, id);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenIntent(Intent* intent)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenIntent(intent);
|
||||
}
|
||||
|
||||
void ContextBroadcastIntent(Intent* intent)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->BroadcastIntent(*intent);
|
||||
}
|
||||
|
||||
void ContextForceCloseWindowByClass(WindowClass windowClass)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->ForceClose(windowClass);
|
||||
}
|
||||
|
||||
WindowBase* ContextShowError(StringId title, StringId message, const Formatter& args, const bool autoClose /* = false */)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->ShowError(title, message, args, autoClose);
|
||||
}
|
||||
|
||||
void ContextHandleInput()
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->HandleInput();
|
||||
}
|
||||
|
||||
void ContextInputHandleKeyboard(bool isTitle)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->HandleKeyboard(isTitle);
|
||||
}
|
||||
|
||||
void ContextQuit()
|
||||
{
|
||||
GetContext()->Quit();
|
||||
}
|
||||
|
||||
u8string ContextOpenCommonFileDialog(Ui::FileDialogDesc& desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetContext()->GetUiContext().ShowFileDialog(desc);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
LOG_ERROR(ex.what());
|
||||
return u8string{};
|
||||
}
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
void ContextInit()
|
||||
{
|
||||
GetWindowManager()->Init();
|
||||
}
|
||||
|
||||
bool ContextLoadParkFromStream(void* stream)
|
||||
{
|
||||
return GetContext()->LoadParkFromStream(static_cast<IStream*>(stream), "");
|
||||
}
|
||||
|
||||
void OpenRCT2Finish()
|
||||
{
|
||||
GetContext()->Finish();
|
||||
}
|
||||
|
||||
void ContextSetCurrentCursor(CursorID cursor)
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursor(cursor);
|
||||
}
|
||||
|
||||
void ContextUpdateCursorScale()
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorScale(static_cast<uint8_t>(std::round(Config::Get().general.WindowScale)));
|
||||
}
|
||||
|
||||
void ContextHideCursor()
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorVisible(false);
|
||||
}
|
||||
|
||||
void ContextShowCursor()
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorVisible(true);
|
||||
}
|
||||
|
||||
ScreenCoordsXY ContextGetCursorPosition()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetCursorPosition();
|
||||
}
|
||||
|
||||
ScreenCoordsXY ContextGetCursorPositionScaled()
|
||||
{
|
||||
auto cursorCoords = ContextGetCursorPosition();
|
||||
// Compensate for window scaling.
|
||||
return { static_cast<int32_t>(std::ceil(cursorCoords.x / Config::Get().general.WindowScale)),
|
||||
static_cast<int32_t>(std::ceil(cursorCoords.y / Config::Get().general.WindowScale)) };
|
||||
}
|
||||
|
||||
void ContextSetCursorPosition(const ScreenCoordsXY& cursorPosition)
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorPosition(cursorPosition);
|
||||
}
|
||||
|
||||
const CursorState* ContextGetCursorState()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetCursorState();
|
||||
}
|
||||
|
||||
const uint8_t* ContextGetKeysState()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetKeysState();
|
||||
}
|
||||
|
||||
const uint8_t* ContextGetKeysPressed()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetKeysPressed();
|
||||
}
|
||||
|
||||
TextInputSession* ContextStartTextInput(u8string& buffer, size_t maxLength)
|
||||
{
|
||||
return GetContext()->GetUiContext().StartTextInput(buffer, maxLength);
|
||||
}
|
||||
|
||||
void ContextStopTextInput()
|
||||
{
|
||||
GetContext()->GetUiContext().StopTextInput();
|
||||
}
|
||||
|
||||
bool ContextIsInputActive()
|
||||
{
|
||||
return GetContext()->GetUiContext().IsTextInputActive();
|
||||
}
|
||||
|
||||
void ContextTriggerResize()
|
||||
{
|
||||
return GetContext()->GetUiContext().TriggerResize();
|
||||
}
|
||||
|
||||
void ContextSetFullscreenMode(int32_t mode)
|
||||
{
|
||||
return GetContext()->GetUiContext().SetFullscreenMode(static_cast<FullscreenMode>(mode));
|
||||
}
|
||||
|
||||
void ContextRecreateWindow()
|
||||
{
|
||||
GetContext()->GetUiContext().RecreateWindow();
|
||||
}
|
||||
|
||||
int32_t ContextGetWidth()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetWidth();
|
||||
}
|
||||
|
||||
int32_t ContextGetHeight()
|
||||
{
|
||||
return GetContext()->GetUiContext().GetHeight();
|
||||
}
|
||||
|
||||
bool ContextHasFocus()
|
||||
{
|
||||
return GetContext()->GetUiContext().HasFocus();
|
||||
}
|
||||
|
||||
void ContextSetCursorTrap(bool value)
|
||||
{
|
||||
GetContext()->GetUiContext().SetCursorTrap(value);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenWindow(WindowClass wc)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenWindow(wc);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenWindowView(uint8_t wc)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenView(wc);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenDetails(type, id);
|
||||
}
|
||||
|
||||
WindowBase* ContextOpenIntent(Intent* intent)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->OpenIntent(intent);
|
||||
}
|
||||
|
||||
void ContextBroadcastIntent(Intent* intent)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->BroadcastIntent(*intent);
|
||||
}
|
||||
|
||||
void ContextForceCloseWindowByClass(WindowClass windowClass)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->ForceClose(windowClass);
|
||||
}
|
||||
|
||||
WindowBase* ContextShowError(StringId title, StringId message, const Formatter& args, const bool autoClose /* = false */)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
return windowManager->ShowError(title, message, args, autoClose);
|
||||
}
|
||||
|
||||
void ContextHandleInput()
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->HandleInput();
|
||||
}
|
||||
|
||||
void ContextInputHandleKeyboard(bool isTitle)
|
||||
{
|
||||
auto windowManager = Ui::GetWindowManager();
|
||||
windowManager->HandleKeyboard(isTitle);
|
||||
}
|
||||
|
||||
void ContextQuit()
|
||||
{
|
||||
GetContext()->Quit();
|
||||
}
|
||||
|
||||
u8string ContextOpenCommonFileDialog(OpenRCT2::Ui::FileDialogDesc& desc)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetContext()->GetUiContext().ShowFileDialog(desc);
|
||||
}
|
||||
catch (const std::exception& ex)
|
||||
{
|
||||
LOG_ERROR(ex.what());
|
||||
return u8string{};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,74 +17,28 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
struct IScenarioRepository;
|
||||
enum class DrawingEngine : int32_t;
|
||||
enum class CursorID : uint8_t;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Formatter;
|
||||
class Intent;
|
||||
struct IObjectManager;
|
||||
struct IObjectRepository;
|
||||
struct IStream;
|
||||
struct WindowBase;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
struct ITrackDesignRepository;
|
||||
enum class DrawingEngine : int32_t;
|
||||
struct IGameStateSnapshots;
|
||||
|
||||
struct IScenarioRepository;
|
||||
struct ITrackDesignRepository;
|
||||
struct NewVersionInfo;
|
||||
|
||||
struct TTFFontDescriptor;
|
||||
namespace OpenRCT2::Ui
|
||||
{
|
||||
struct FileDialogDesc;
|
||||
}
|
||||
|
||||
struct CursorState
|
||||
{
|
||||
ScreenCoordsXY position;
|
||||
uint8_t left, middle, right, any;
|
||||
int32_t wheel;
|
||||
int32_t old;
|
||||
bool touch, touchIsDouble;
|
||||
uint32_t touchDownTimestamp;
|
||||
};
|
||||
|
||||
struct TextInputSession
|
||||
{
|
||||
u8string* Buffer; // UTF-8 string buffer, non-owning.
|
||||
size_t Length; // Number of codepoints
|
||||
size_t MaxLength; // Maximum length of text, Length can't be larger than this.
|
||||
size_t SelectionStart; // Selection start, in bytes
|
||||
size_t SelectionSize; // Selection length in bytes
|
||||
|
||||
const utf8* ImeBuffer; // IME UTF-8 stream
|
||||
};
|
||||
|
||||
struct Resolution
|
||||
{
|
||||
int32_t Width;
|
||||
int32_t Height;
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CURSOR_UP = 0,
|
||||
CURSOR_DOWN = 1,
|
||||
CURSOR_CHANGED = 2,
|
||||
CURSOR_RELEASED = CURSOR_UP | CURSOR_CHANGED,
|
||||
CURSOR_PRESSED = CURSOR_DOWN | CURSOR_CHANGED,
|
||||
};
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class AssetPackManager;
|
||||
|
||||
class Formatter;
|
||||
class Intent;
|
||||
struct CursorState;
|
||||
struct IObjectManager;
|
||||
struct IObjectRepository;
|
||||
struct IPlatformEnvironment;
|
||||
struct IReplayManager;
|
||||
struct IScene;
|
||||
struct IStream;
|
||||
struct TextInputSession;
|
||||
struct WindowBase;
|
||||
|
||||
namespace Audio
|
||||
{
|
||||
@@ -113,8 +67,9 @@ namespace OpenRCT2
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
struct FileDialogDesc;
|
||||
struct IUiContext;
|
||||
}
|
||||
} // namespace Ui
|
||||
|
||||
namespace Paint
|
||||
{
|
||||
@@ -191,54 +146,39 @@ namespace OpenRCT2
|
||||
std::unique_ptr<IPlatformEnvironment>&& env, std::unique_ptr<Audio::IAudioContext>&& audioContext,
|
||||
std::unique_ptr<Ui::IUiContext>&& uiContext);
|
||||
[[nodiscard]] IContext* GetContext();
|
||||
|
||||
void ContextInit();
|
||||
void ContextSetCurrentCursor(CursorID cursor);
|
||||
void ContextUpdateCursorScale();
|
||||
void ContextHideCursor();
|
||||
void ContextShowCursor();
|
||||
ScreenCoordsXY ContextGetCursorPosition();
|
||||
ScreenCoordsXY ContextGetCursorPositionScaled();
|
||||
void ContextSetCursorPosition(const ScreenCoordsXY& cursorPosition);
|
||||
const CursorState* ContextGetCursorState();
|
||||
const uint8_t* ContextGetKeysState();
|
||||
const uint8_t* ContextGetKeysPressed();
|
||||
TextInputSession* ContextStartTextInput(u8string& buffer, size_t maxLength);
|
||||
void ContextStopTextInput();
|
||||
bool ContextIsInputActive();
|
||||
void ContextTriggerResize();
|
||||
void ContextSetFullscreenMode(int32_t mode);
|
||||
void ContextRecreateWindow();
|
||||
int32_t ContextGetWidth();
|
||||
int32_t ContextGetHeight();
|
||||
bool ContextHasFocus();
|
||||
void ContextSetCursorTrap(bool value);
|
||||
OpenRCT2::WindowBase* ContextOpenWindow(WindowClass wc);
|
||||
OpenRCT2::WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id);
|
||||
OpenRCT2::WindowBase* ContextOpenWindowView(uint8_t view);
|
||||
OpenRCT2::WindowBase* ContextShowError(
|
||||
StringId title, StringId message, const class OpenRCT2::Formatter& args, bool autoClose = false);
|
||||
OpenRCT2::WindowBase* ContextOpenIntent(OpenRCT2::Intent* intent);
|
||||
void ContextBroadcastIntent(OpenRCT2::Intent* intent);
|
||||
void ContextForceCloseWindowByClass(WindowClass wc);
|
||||
void ContextHandleInput();
|
||||
void ContextInputHandleKeyboard(bool isTitle);
|
||||
void ContextQuit();
|
||||
bool ContextLoadParkFromStream(void* stream);
|
||||
u8string ContextOpenCommonFileDialog(OpenRCT2::Ui::FileDialogDesc& desc);
|
||||
} // namespace OpenRCT2
|
||||
|
||||
namespace
|
||||
{
|
||||
// The number of logical update / ticks per second.
|
||||
constexpr uint32_t kGameUpdateFPS = 40;
|
||||
// The maximum amount of updates in case rendering is slower
|
||||
constexpr uint32_t kGameMaxUpdates = 4;
|
||||
// The game update interval in milliseconds, (1000 / 40fps) = 25ms
|
||||
constexpr float kGameUpdateTimeMS = 1.0f / kGameUpdateFPS;
|
||||
// The maximum threshold to advance.
|
||||
constexpr float kGameUpdateMaxThreshold = kGameUpdateTimeMS * kGameMaxUpdates;
|
||||
}; // namespace
|
||||
|
||||
constexpr float kGameMinTimeScale = 0.1f;
|
||||
constexpr float kGameMaxTimeScale = 5.0f;
|
||||
|
||||
void ContextInit();
|
||||
void ContextSetCurrentCursor(CursorID cursor);
|
||||
void ContextUpdateCursorScale();
|
||||
void ContextHideCursor();
|
||||
void ContextShowCursor();
|
||||
ScreenCoordsXY ContextGetCursorPosition();
|
||||
ScreenCoordsXY ContextGetCursorPositionScaled();
|
||||
void ContextSetCursorPosition(const ScreenCoordsXY& cursorPosition);
|
||||
const CursorState* ContextGetCursorState();
|
||||
const uint8_t* ContextGetKeysState();
|
||||
const uint8_t* ContextGetKeysPressed();
|
||||
TextInputSession* ContextStartTextInput(u8string& buffer, size_t maxLength);
|
||||
void ContextStopTextInput();
|
||||
bool ContextIsInputActive();
|
||||
void ContextTriggerResize();
|
||||
void ContextSetFullscreenMode(int32_t mode);
|
||||
void ContextRecreateWindow();
|
||||
int32_t ContextGetWidth();
|
||||
int32_t ContextGetHeight();
|
||||
bool ContextHasFocus();
|
||||
void ContextSetCursorTrap(bool value);
|
||||
OpenRCT2::WindowBase* ContextOpenWindow(WindowClass wc);
|
||||
OpenRCT2::WindowBase* ContextOpenDetailWindow(uint8_t type, int32_t id);
|
||||
OpenRCT2::WindowBase* ContextOpenWindowView(uint8_t view);
|
||||
OpenRCT2::WindowBase* ContextShowError(
|
||||
StringId title, StringId message, const class OpenRCT2::Formatter& args, bool autoClose = false);
|
||||
OpenRCT2::WindowBase* ContextOpenIntent(OpenRCT2::Intent* intent);
|
||||
void ContextBroadcastIntent(OpenRCT2::Intent* intent);
|
||||
void ContextForceCloseWindowByClass(WindowClass wc);
|
||||
void ContextHandleInput();
|
||||
void ContextInputHandleKeyboard(bool isTitle);
|
||||
void ContextQuit();
|
||||
bool ContextLoadParkFromStream(void* stream);
|
||||
u8string ContextOpenCommonFileDialog(OpenRCT2::Ui::FileDialogDesc& desc);
|
||||
|
||||
@@ -736,7 +736,7 @@ void GameLoadOrQuitNoSavePrompt()
|
||||
default:
|
||||
GameUnloadScripts();
|
||||
getGameState().entities.ResetAllEntities();
|
||||
OpenRCT2Finish();
|
||||
GetContext()->Finish();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,19 @@
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class Intent;
|
||||
}
|
||||
|
||||
// The number of logical update / ticks per second.
|
||||
constexpr uint32_t kGameUpdateFPS = 40;
|
||||
// The maximum amount of updates in case rendering is slower
|
||||
constexpr uint32_t kGameMaxUpdates = 4;
|
||||
// The game update interval in milliseconds, (1000 / 40fps) = 25ms
|
||||
constexpr float kGameUpdateTimeMS = 1.0f / kGameUpdateFPS;
|
||||
// The maximum threshold to advance.
|
||||
constexpr float kGameUpdateMaxThreshold = kGameUpdateTimeMS * kGameMaxUpdates;
|
||||
|
||||
constexpr float kGameMinTimeScale = 0.1f;
|
||||
constexpr float kGameMaxTimeScale = 5.0f;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
struct ParkLoadResult;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/FlagHolder.hpp"
|
||||
#include "core/StringTypes.h"
|
||||
#include "interface/Window.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
@@ -54,6 +55,36 @@ namespace OpenRCT2
|
||||
ScrollRight
|
||||
};
|
||||
|
||||
struct CursorState
|
||||
{
|
||||
ScreenCoordsXY position;
|
||||
uint8_t left, middle, right, any;
|
||||
int32_t wheel;
|
||||
int32_t old;
|
||||
bool touch, touchIsDouble;
|
||||
uint32_t touchDownTimestamp;
|
||||
};
|
||||
|
||||
struct TextInputSession
|
||||
{
|
||||
u8string* Buffer; // UTF-8 string buffer, non-owning.
|
||||
size_t Length; // Number of codepoints
|
||||
size_t MaxLength; // Maximum length of text, Length can't be larger than this.
|
||||
size_t SelectionStart; // Selection start, in bytes
|
||||
size_t SelectionSize; // Selection length in bytes
|
||||
|
||||
const utf8* ImeBuffer; // IME UTF-8 stream
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
CURSOR_UP = 0,
|
||||
CURSOR_DOWN = 1,
|
||||
CURSOR_CHANGED = 2,
|
||||
CURSOR_RELEASED = CURSOR_UP | CURSOR_CHANGED,
|
||||
CURSOR_PRESSED = CURSOR_DOWN | CURSOR_CHANGED,
|
||||
};
|
||||
|
||||
extern WidgetRef gHoverWidget;
|
||||
extern WidgetRef gPressedWidget;
|
||||
|
||||
|
||||
@@ -67,6 +67,4 @@ extern LegacyScene gLegacyScene;
|
||||
extern uint32_t gScreenAge;
|
||||
extern PromptMode gSavePromptMode;
|
||||
|
||||
void OpenRCT2Finish();
|
||||
|
||||
int32_t CommandLineRun(const char** argv, int32_t argc);
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Chat.h"
|
||||
|
||||
#include "../Context.h"
|
||||
#include "../Input.h"
|
||||
#include "../audio/Audio.h"
|
||||
#include "../audio/AudioMixer.h"
|
||||
#include "../core/UTF8.h"
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
#include <string>
|
||||
|
||||
struct RenderTarget;
|
||||
struct TextInputSession;
|
||||
|
||||
enum class ConsoleInput : uint8_t
|
||||
{
|
||||
@@ -30,7 +29,8 @@ enum class ConsoleInput : uint8_t
|
||||
namespace OpenRCT2
|
||||
{
|
||||
enum class FormatToken : uint8_t;
|
||||
}
|
||||
struct TextInputSession;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
class InteractiveConsole
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ void StdInOutConsole::Start()
|
||||
{
|
||||
if (lastPromptQuit)
|
||||
{
|
||||
OpenRCT2Finish();
|
||||
GetContext()->Finish();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void StdInOutConsole::Clear()
|
||||
|
||||
void StdInOutConsole::Close()
|
||||
{
|
||||
OpenRCT2Finish();
|
||||
GetContext()->Finish();
|
||||
}
|
||||
|
||||
void StdInOutConsole::WriteLine(const std::string& s, FormatToken colourFormat)
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "IntroScene.h"
|
||||
|
||||
#include "../../Context.h"
|
||||
#include "../../Input.h"
|
||||
#include "../../SpriteIds.h"
|
||||
#include "../../audio/Audio.h"
|
||||
#include "../../audio/AudioChannel.h"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "Wait.h"
|
||||
|
||||
#include "../../../Context.h"
|
||||
#include "../../../Game.h"
|
||||
|
||||
namespace OpenRCT2::Title
|
||||
{
|
||||
|
||||
@@ -43,6 +43,12 @@ namespace OpenRCT2
|
||||
fullscreenDesktop,
|
||||
};
|
||||
|
||||
struct Resolution
|
||||
{
|
||||
int32_t Width;
|
||||
int32_t Height;
|
||||
};
|
||||
|
||||
inline bool operator<(const Resolution& lhs, const Resolution& rhs)
|
||||
{
|
||||
int32_t areaA = lhs.Width * lhs.Height;
|
||||
|
||||
@@ -35,9 +35,7 @@ namespace OpenRCT2::Ui
|
||||
virtual WindowBase* OpenDetails(uint8_t type, int32_t id) = 0;
|
||||
virtual WindowBase* OpenIntent(Intent* intent) = 0;
|
||||
virtual void BroadcastIntent(const Intent& intent) = 0;
|
||||
virtual WindowBase* ShowError(
|
||||
StringId title, StringId message, const OpenRCT2::Formatter& formatter, bool autoClose = false)
|
||||
= 0;
|
||||
virtual WindowBase* ShowError(StringId title, StringId message, const Formatter& formatter, bool autoClose = false) = 0;
|
||||
virtual WindowBase* ShowError(std::string_view title, std::string_view message, bool autoClose = false) = 0;
|
||||
virtual void ForceClose(WindowClass windowClass) = 0;
|
||||
virtual void UpdateMapTooltip() = 0;
|
||||
|
||||
Reference in New Issue
Block a user