2017-06-01 21:55:10 +02:00
|
|
|
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
|
2017-03-24 03:47:43 +01:00
|
|
|
/*****************************************************************************
|
|
|
|
* 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
|
|
|
|
|
2017-03-24 20:02:23 +01:00
|
|
|
#include "common.h"
|
2017-03-24 03:47:43 +01:00
|
|
|
|
2017-09-18 17:05:28 +02:00
|
|
|
#include "interface/window.h"
|
2017-06-11 16:16:47 +02:00
|
|
|
|
|
|
|
|
2017-03-25 18:42:14 +01:00
|
|
|
typedef struct CursorState
|
|
|
|
{
|
|
|
|
sint32 x, y;
|
|
|
|
uint8 left, middle, right, any;
|
|
|
|
sint32 wheel;
|
|
|
|
sint32 old;
|
|
|
|
bool touch, touchIsDouble;
|
|
|
|
uint32 touchDownTimestamp;
|
|
|
|
} CursorState;
|
|
|
|
|
2017-03-26 04:36:22 +02:00
|
|
|
typedef struct TextInputSession
|
|
|
|
{
|
|
|
|
utf8 * Buffer; // UTF-8 stream
|
|
|
|
size_t BufferSize; // Maximum number of bytes (excluding null terminator)
|
|
|
|
size_t Size; // Number of bytes (excluding null terminator)
|
|
|
|
size_t Length; // Number of codepoints
|
|
|
|
size_t SelectionStart; // Selection start, in bytes
|
|
|
|
size_t SelectionSize; // Selection length in bytes
|
2017-05-21 15:30:22 +02:00
|
|
|
|
|
|
|
const utf8 * ImeBuffer; // IME UTF-8 stream
|
2017-03-26 04:36:22 +02:00
|
|
|
} TextInputSession;
|
|
|
|
|
|
|
|
struct Resolution
|
|
|
|
{
|
|
|
|
sint32 Width;
|
|
|
|
sint32 Height;
|
|
|
|
};
|
|
|
|
|
2017-03-25 18:42:14 +01:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CURSOR_UP = 0,
|
|
|
|
CURSOR_DOWN = 1,
|
|
|
|
CURSOR_CHANGED = 2,
|
|
|
|
CURSOR_RELEASED = CURSOR_UP | CURSOR_CHANGED,
|
|
|
|
CURSOR_PRESSED = CURSOR_DOWN | CURSOR_CHANGED,
|
|
|
|
};
|
|
|
|
|
2017-03-25 15:57:02 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
|
2017-07-02 20:10:22 +02:00
|
|
|
#include <string>
|
|
|
|
|
2017-03-24 03:47:43 +01:00
|
|
|
namespace OpenRCT2
|
|
|
|
{
|
2017-06-11 13:53:37 +02:00
|
|
|
interface IPlatformEnvironment;
|
|
|
|
|
2017-03-28 20:58:15 +02:00
|
|
|
namespace Audio
|
|
|
|
{
|
|
|
|
interface IAudioContext;
|
|
|
|
}
|
|
|
|
|
2017-03-25 04:16:40 +01:00
|
|
|
namespace Ui
|
2017-03-24 17:26:43 +01:00
|
|
|
{
|
2017-03-25 04:16:40 +01:00
|
|
|
interface IUiContext;
|
2017-03-24 17:26:43 +01:00
|
|
|
}
|
|
|
|
|
2017-03-24 03:47:43 +01:00
|
|
|
/**
|
|
|
|
* Represents an instance of OpenRCT2 and can be used to get various services.
|
|
|
|
*/
|
|
|
|
interface IContext
|
|
|
|
{
|
2017-03-24 17:26:43 +01:00
|
|
|
virtual ~IContext() = default;
|
2017-03-25 04:16:40 +01:00
|
|
|
|
2017-03-28 20:58:15 +02:00
|
|
|
virtual Audio::IAudioContext * GetAudioContext() abstract;
|
|
|
|
virtual Ui::IUiContext * GetUiContext() abstract;
|
|
|
|
|
2017-03-24 03:47:43 +01:00
|
|
|
virtual sint32 RunOpenRCT2(int argc, char * * argv) abstract;
|
2017-06-04 00:10:20 +02:00
|
|
|
|
|
|
|
virtual bool Initialise() abstract;
|
2017-08-23 08:04:36 +02:00
|
|
|
virtual bool LoadParkFromFile(const std::string &path, bool loadTitleScreenOnFail = false) abstract;
|
2017-03-26 22:04:14 +02:00
|
|
|
virtual void Finish() abstract;
|
2017-07-28 19:43:48 +02:00
|
|
|
virtual void Quit() abstract;
|
2017-07-28 20:11:12 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* This is deprecated, use IPlatformEnvironment.
|
|
|
|
*/
|
|
|
|
virtual std::string GetPathLegacy(sint32 pathId) abstract;
|
2017-03-24 03:47:43 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
IContext * CreateContext();
|
2017-06-11 13:53:37 +02:00
|
|
|
IContext * CreateContext(IPlatformEnvironment * env, Audio::IAudioContext * audioContext, Ui::IUiContext * uiContext);
|
2017-03-25 04:16:40 +01:00
|
|
|
IContext * GetContext();
|
2017-07-16 09:54:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // __cplusplus
|
2017-07-02 01:04:32 +02:00
|
|
|
|
2017-07-16 09:54:34 +02:00
|
|
|
enum
|
|
|
|
{
|
2017-07-02 01:04:32 +02:00
|
|
|
// The game update inverval in milliseconds, (1000 / 40fps) = 25ms
|
2017-07-16 09:54:34 +02:00
|
|
|
GAME_UPDATE_TIME_MS = 25,
|
2017-07-02 01:04:32 +02:00
|
|
|
// The number of logical update / ticks per second.
|
2017-07-16 09:54:34 +02:00
|
|
|
GAME_UPDATE_FPS = 40,
|
|
|
|
// The maximum amount of updates in case rendering is slower
|
|
|
|
GAME_MAX_UPDATES = 4,
|
|
|
|
// The maximum threshold to advance.
|
|
|
|
GAME_UPDATE_MAX_THRESHOLD = GAME_UPDATE_TIME_MS * GAME_MAX_UPDATES,
|
|
|
|
};
|
2017-03-25 15:57:02 +01:00
|
|
|
|
2017-07-28 20:11:12 +02:00
|
|
|
/**
|
|
|
|
* Legacy get_file_path IDs.
|
|
|
|
* Remove when context_get_path_legacy is removed.
|
|
|
|
*/
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PATH_ID_G1,
|
|
|
|
PATH_ID_PLUGIN,
|
|
|
|
PATH_ID_CSS1,
|
|
|
|
PATH_ID_CSS2,
|
|
|
|
PATH_ID_CSS4,
|
|
|
|
PATH_ID_CSS5,
|
|
|
|
PATH_ID_CSS6,
|
|
|
|
PATH_ID_CSS7,
|
|
|
|
PATH_ID_CSS8,
|
|
|
|
PATH_ID_CSS9,
|
|
|
|
PATH_ID_CSS11,
|
|
|
|
PATH_ID_CSS12,
|
|
|
|
PATH_ID_CSS13,
|
|
|
|
PATH_ID_CSS14,
|
|
|
|
PATH_ID_CSS15,
|
|
|
|
PATH_ID_CSS3,
|
|
|
|
PATH_ID_CSS17,
|
|
|
|
PATH_ID_CSS18,
|
|
|
|
PATH_ID_CSS19,
|
|
|
|
PATH_ID_CSS20,
|
|
|
|
PATH_ID_CSS21,
|
|
|
|
PATH_ID_CSS22,
|
|
|
|
PATH_ID_SCORES,
|
|
|
|
PATH_ID_CSS23,
|
|
|
|
PATH_ID_CSS24,
|
|
|
|
PATH_ID_CSS25,
|
|
|
|
PATH_ID_CSS26,
|
|
|
|
PATH_ID_CSS27,
|
|
|
|
PATH_ID_CSS28,
|
|
|
|
PATH_ID_CSS29,
|
|
|
|
PATH_ID_CSS30,
|
|
|
|
PATH_ID_CSS31,
|
|
|
|
PATH_ID_CSS32,
|
|
|
|
PATH_ID_CSS33,
|
|
|
|
PATH_ID_CSS34,
|
|
|
|
PATH_ID_CSS35,
|
|
|
|
PATH_ID_CSS36,
|
|
|
|
PATH_ID_CSS37,
|
|
|
|
PATH_ID_CSS38,
|
|
|
|
PATH_ID_CUSTOM1,
|
|
|
|
PATH_ID_CUSTOM2,
|
|
|
|
PATH_ID_CSS39,
|
|
|
|
PATH_ID_CSS40,
|
|
|
|
PATH_ID_CSS41,
|
|
|
|
PATH_ID_SIXFLAGS_MAGICMOUNTAIN,
|
|
|
|
PATH_ID_CSS42,
|
|
|
|
PATH_ID_CSS43,
|
|
|
|
PATH_ID_CSS44,
|
|
|
|
PATH_ID_CSS45,
|
|
|
|
PATH_ID_CSS46,
|
|
|
|
PATH_ID_CSS50,
|
|
|
|
PATH_ID_END,
|
|
|
|
};
|
2017-03-25 15:57:02 +01:00
|
|
|
|
2017-03-25 18:42:14 +01:00
|
|
|
#ifdef __cplusplus
|
2017-03-25 15:57:02 +01:00
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
#endif
|
|
|
|
void context_setcurrentcursor(sint32 cursor);
|
2017-03-25 18:42:14 +01:00
|
|
|
void context_hide_cursor();
|
|
|
|
void context_show_cursor();
|
|
|
|
void context_get_cursor_position(sint32 * x, sint32 * y);
|
|
|
|
void context_get_cursor_position_scaled(sint32 * x, sint32 * y);
|
|
|
|
void context_set_cursor_position(sint32 x, sint32 y);
|
|
|
|
const CursorState * context_get_cursor_state();
|
|
|
|
const uint8 * context_get_keys_state();
|
|
|
|
const uint8 * context_get_keys_pressed();
|
2017-03-26 04:36:22 +02:00
|
|
|
TextInputSession * context_start_text_input(utf8 * buffer, size_t maxLength);
|
2017-03-25 18:42:14 +01:00
|
|
|
void context_stop_text_input();
|
|
|
|
bool context_is_input_active();
|
2017-03-26 04:36:22 +02:00
|
|
|
void context_trigger_resize();
|
|
|
|
void context_set_fullscreen_mode(sint32 mode);
|
2017-07-11 15:56:17 +02:00
|
|
|
void context_recreate_window();
|
2017-03-26 04:36:22 +02:00
|
|
|
sint32 context_get_resolutions(struct Resolution * * outResolutions);
|
2017-03-26 22:42:07 +02:00
|
|
|
sint32 context_get_width();
|
|
|
|
sint32 context_get_height();
|
2017-04-01 14:38:52 +02:00
|
|
|
bool context_has_focus();
|
|
|
|
void context_set_cursor_trap(bool value);
|
2017-06-11 16:16:47 +02:00
|
|
|
rct_window * context_open_window(rct_windowclass wc);
|
2017-09-05 20:55:18 +02:00
|
|
|
rct_window * context_open_window_view(uint8 view);
|
2017-06-11 20:04:50 +02:00
|
|
|
void context_input_handle_keyboard(bool isTitle);
|
2017-06-14 20:47:22 +02:00
|
|
|
bool context_read_bmp(void * * outPixels, uint32 * outWidth, uint32 * outHeight, const utf8 * path);
|
2017-07-28 19:43:48 +02:00
|
|
|
void context_quit();
|
2017-07-28 20:11:12 +02:00
|
|
|
const utf8 * context_get_path_legacy(sint32 pathId);
|
2017-08-23 08:04:36 +02:00
|
|
|
bool context_load_park_from_file(const utf8 * path);
|
2017-03-25 18:42:14 +01:00
|
|
|
#ifdef __cplusplus
|
2017-03-25 15:57:02 +01:00
|
|
|
}
|
|
|
|
#endif
|