2016-05-04 19:24:41 +02:00
|
|
|
#pragma region Copyright (c) 2014-2016 OpenRCT2 Developers
|
2014-10-06 18:36:58 +02:00
|
|
|
/*****************************************************************************
|
|
|
|
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
|
2015-08-04 01:08:42 +02:00
|
|
|
*
|
2016-05-04 19:24:41 +02:00
|
|
|
* 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
|
2015-08-04 01:08:42 +02:00
|
|
|
*
|
2014-10-06 18:36:58 +02:00
|
|
|
* 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.
|
2016-05-04 19:24:41 +02:00
|
|
|
*
|
|
|
|
* A full copy of the GNU General Public License can be found in licence.txt
|
2014-10-06 18:36:58 +02:00
|
|
|
*****************************************************************************/
|
2016-05-04 19:24:41 +02:00
|
|
|
#pragma endregion
|
2015-08-04 01:08:42 +02:00
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
#ifndef _PLATFORM_H_
|
|
|
|
#define _PLATFORM_H_
|
|
|
|
|
2016-01-13 23:37:13 +01:00
|
|
|
#include "../common.h"
|
|
|
|
|
|
|
|
#ifdef __WINDOWS__
|
2016-05-28 13:24:52 +02:00
|
|
|
#ifndef HAVE_MATH_H
|
|
|
|
#define HAVE_MATH_H
|
|
|
|
#endif
|
2016-01-13 23:37:13 +01:00
|
|
|
#endif // __WINDOWS__
|
2015-08-04 00:16:30 +02:00
|
|
|
|
2015-01-23 21:47:33 +01:00
|
|
|
#include <SDL.h>
|
|
|
|
|
2016-03-10 00:07:55 +01:00
|
|
|
#include "../core/textinputbuffer.h"
|
2015-12-22 18:56:47 +01:00
|
|
|
#include "../drawing/font.h"
|
2014-12-07 22:45:42 +01:00
|
|
|
|
2014-10-09 15:03:54 +02:00
|
|
|
#ifndef MAX_PATH
|
|
|
|
#define MAX_PATH 260
|
2015-12-15 08:32:48 +01:00
|
|
|
#endif
|
|
|
|
|
2016-01-13 23:37:13 +01:00
|
|
|
#ifdef __MACOSX__
|
2015-12-15 08:32:48 +01:00
|
|
|
#define KEYBOARD_PRIMARY_MODIFIER KMOD_GUI
|
|
|
|
#else
|
|
|
|
#define KEYBOARD_PRIMARY_MODIFIER KMOD_CTRL
|
2014-10-09 15:03:54 +02:00
|
|
|
#endif
|
2014-10-06 18:36:58 +02:00
|
|
|
|
2014-12-07 22:45:42 +01:00
|
|
|
#define INVALID_HANDLE -1
|
|
|
|
|
2015-12-20 09:33:12 +01:00
|
|
|
#define TOUCH_DOUBLE_TIMEOUT 300
|
|
|
|
|
2016-09-19 18:59:06 +02:00
|
|
|
#ifdef __WINDOWS__
|
|
|
|
#define PATH_SEPARATOR "\\"
|
2016-09-26 04:24:29 +02:00
|
|
|
#define PLATFORM_NEWLINE "\r\n"
|
2016-09-19 18:59:06 +02:00
|
|
|
#else
|
|
|
|
#define PATH_SEPARATOR "/"
|
2016-09-26 04:24:29 +02:00
|
|
|
#define PLATFORM_NEWLINE "\n"
|
2016-09-19 18:59:06 +02:00
|
|
|
#endif
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct resolution {
|
2015-01-23 21:47:33 +01:00
|
|
|
int width, height;
|
|
|
|
} resolution;
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct file_info {
|
2014-12-07 22:45:42 +01:00
|
|
|
const char *path;
|
|
|
|
uint64 size;
|
|
|
|
uint64 last_modified;
|
|
|
|
} file_info;
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct rct2_date {
|
2015-09-29 23:35:15 +02:00
|
|
|
sint16 day;
|
|
|
|
sint16 month;
|
|
|
|
sint16 year;
|
|
|
|
sint16 day_of_week;
|
|
|
|
} rct2_date;
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct rct2_time {
|
2015-09-29 23:35:15 +02:00
|
|
|
sint16 hour;
|
|
|
|
sint16 minute;
|
|
|
|
sint16 second;
|
|
|
|
} rct2_time;
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct openrct2_cursor {
|
2015-02-12 21:51:40 +01:00
|
|
|
int x, y;
|
|
|
|
unsigned char left, middle, right, any;
|
|
|
|
int wheel;
|
|
|
|
int old;
|
2015-12-20 09:33:12 +01:00
|
|
|
bool touch, touchIsDouble;
|
|
|
|
unsigned int touchDownTimestamp;
|
2015-02-12 21:51:40 +01:00
|
|
|
} openrct2_cursor;
|
|
|
|
|
|
|
|
enum {
|
|
|
|
CURSOR_UP = 0,
|
|
|
|
CURSOR_DOWN = 1,
|
|
|
|
CURSOR_CHANGED = 2,
|
|
|
|
CURSOR_RELEASED = CURSOR_UP | CURSOR_CHANGED,
|
|
|
|
CURSOR_PRESSED = CURSOR_DOWN | CURSOR_CHANGED,
|
|
|
|
};
|
|
|
|
|
2016-01-29 18:40:42 +01:00
|
|
|
typedef enum {FD_OPEN, FD_SAVE} filedialog_type;
|
|
|
|
|
2016-05-12 23:57:40 +02:00
|
|
|
typedef struct file_dialog_desc {
|
2016-02-26 00:47:27 +01:00
|
|
|
uint8 type;
|
|
|
|
const utf8 *title;
|
|
|
|
const utf8 *initial_directory;
|
|
|
|
const utf8 *default_filename;
|
|
|
|
struct {
|
|
|
|
const utf8 *name; // E.g. "Image Files"
|
|
|
|
const utf8 *pattern; // E.g. "*.png;*.jpg;*.gif"
|
|
|
|
} filters[8];
|
|
|
|
} file_dialog_desc;
|
2016-01-29 18:40:42 +01:00
|
|
|
|
2015-02-12 21:51:40 +01:00
|
|
|
extern openrct2_cursor gCursorState;
|
|
|
|
extern const unsigned char *gKeysState;
|
|
|
|
extern unsigned char *gKeysPressed;
|
|
|
|
extern unsigned int gLastKeyPressed;
|
|
|
|
|
2016-03-10 00:07:55 +01:00
|
|
|
extern textinputbuffer gTextInput;
|
2015-07-29 01:15:15 +02:00
|
|
|
extern bool gTextInputCompositionActive;
|
|
|
|
extern utf8 gTextInputComposition[32];
|
|
|
|
extern int gTextInputCompositionStart;
|
|
|
|
extern int gTextInputCompositionLength;
|
|
|
|
|
2015-01-23 21:47:33 +01:00
|
|
|
extern int gResolutionsAllowAnyAspectRatio;
|
|
|
|
extern int gNumResolutions;
|
|
|
|
extern resolution *gResolutions;
|
|
|
|
extern SDL_Window *gWindow;
|
|
|
|
|
2016-02-15 03:23:47 +01:00
|
|
|
extern SDL_Color gPalette[256];
|
|
|
|
|
2015-10-04 22:31:28 +02:00
|
|
|
extern bool gSteamOverlayActive;
|
|
|
|
|
2015-01-23 21:47:33 +01:00
|
|
|
// Platform shared definitions
|
|
|
|
void platform_update_fullscreen_resolutions();
|
2015-01-24 14:16:35 +01:00
|
|
|
void platform_get_closest_resolution(int inWidth, int inHeight, int *outWidth, int *outHeight);
|
2015-02-12 21:51:40 +01:00
|
|
|
void platform_init();
|
|
|
|
void platform_draw();
|
2016-05-31 23:49:58 +02:00
|
|
|
void platform_draw_require_end();
|
2015-02-12 21:51:40 +01:00
|
|
|
void platform_free();
|
2015-11-12 00:42:42 +01:00
|
|
|
void platform_trigger_resize();
|
2015-10-19 20:27:27 +02:00
|
|
|
void platform_update_palette(const uint8 *colours, int start_index, int num_colours);
|
2015-02-12 21:51:40 +01:00
|
|
|
void platform_set_fullscreen_mode(int mode);
|
2016-05-03 21:07:33 +02:00
|
|
|
void platform_toggle_windowed_mode();
|
2016-02-26 12:54:00 +01:00
|
|
|
void platform_set_cursor(uint8 cursor);
|
2015-05-22 04:17:46 +02:00
|
|
|
void platform_refresh_video();
|
2015-02-12 21:51:40 +01:00
|
|
|
void platform_process_messages();
|
|
|
|
int platform_scancode_to_rct_keycode(int sdl_key);
|
2015-08-04 22:41:45 +02:00
|
|
|
void platform_start_text_input(utf8 *buffer, int max_length);
|
2015-02-12 21:51:40 +01:00
|
|
|
void platform_stop_text_input();
|
2016-10-12 22:52:33 +02:00
|
|
|
bool platform_is_input_active();
|
2016-07-23 23:25:13 +02:00
|
|
|
void platform_get_date_utc(rct2_date *out_date);
|
|
|
|
void platform_get_time_utc(rct2_time *out_time);
|
|
|
|
void platform_get_date_local(rct2_date *out_date);
|
|
|
|
void platform_get_time_local(rct2_time *out_time);
|
2015-01-23 21:47:33 +01:00
|
|
|
|
2014-10-06 18:36:58 +02:00
|
|
|
// Platform specific definitions
|
2016-09-26 04:24:29 +02:00
|
|
|
void platform_get_exe_path(utf8 *outPath, size_t outSize);
|
2015-08-04 22:41:45 +02:00
|
|
|
bool platform_file_exists(const utf8 *path);
|
|
|
|
bool platform_directory_exists(const utf8 *path);
|
|
|
|
bool platform_original_game_data_exists(const utf8 *path);
|
|
|
|
time_t platform_file_get_modified_time(const utf8* path);
|
|
|
|
bool platform_ensure_directory_exists(const utf8 *path);
|
|
|
|
bool platform_directory_delete(const utf8 *path);
|
|
|
|
bool platform_lock_single_instance();
|
|
|
|
int platform_enumerate_files_begin(const utf8 *pattern);
|
|
|
|
bool platform_enumerate_files_next(int handle, file_info *outFileInfo);
|
2014-10-17 04:22:45 +02:00
|
|
|
void platform_enumerate_files_end(int handle);
|
2015-08-04 22:41:45 +02:00
|
|
|
int platform_enumerate_directories_begin(const utf8 *directory);
|
|
|
|
bool platform_enumerate_directories_next(int handle, utf8 *path);
|
2015-02-15 18:31:16 +01:00
|
|
|
void platform_enumerate_directories_end(int handle);
|
2016-04-21 20:17:26 +02:00
|
|
|
void platform_init_window_icon();
|
2015-06-22 15:55:57 +02:00
|
|
|
|
|
|
|
// Returns the bitmask of the GetLogicalDrives function for windows, 0 for other systems
|
|
|
|
int platform_get_drives();
|
|
|
|
|
2015-08-04 22:41:45 +02:00
|
|
|
bool platform_file_copy(const utf8 *srcPath, const utf8 *dstPath, bool overwrite);
|
|
|
|
bool platform_file_move(const utf8 *srcPath, const utf8 *dstPath);
|
|
|
|
bool platform_file_delete(const utf8 *path);
|
2014-11-10 23:37:55 +01:00
|
|
|
void platform_hide_cursor();
|
|
|
|
void platform_show_cursor();
|
|
|
|
void platform_get_cursor_position(int *x, int *y);
|
2016-07-30 21:42:21 +02:00
|
|
|
void platform_get_cursor_position_scaled(int *x, int *y);
|
2014-11-10 23:37:55 +01:00
|
|
|
void platform_set_cursor_position(int x, int y);
|
2014-11-30 21:26:53 +01:00
|
|
|
unsigned int platform_get_ticks();
|
2015-11-03 23:20:35 +01:00
|
|
|
void platform_resolve_user_data_path();
|
2015-12-17 22:49:39 +01:00
|
|
|
void platform_resolve_openrct_data_path();
|
2016-09-26 04:24:29 +02:00
|
|
|
void platform_get_openrct_data_path(utf8 *outPath, size_t outSize);
|
|
|
|
void platform_get_user_directory(utf8 *outPath, const utf8 *subDirectory, size_t outSize);
|
2016-02-10 21:49:10 +01:00
|
|
|
utf8* platform_get_username();
|
2015-08-04 22:41:45 +02:00
|
|
|
void platform_show_messagebox(utf8 *message);
|
2016-09-26 04:24:29 +02:00
|
|
|
bool platform_open_common_file_dialog(utf8 *outFilename, file_dialog_desc *desc, size_t outSize);
|
2015-08-01 17:40:15 +02:00
|
|
|
utf8 *platform_open_directory_browser(utf8 *title);
|
2015-02-19 20:40:14 +01:00
|
|
|
uint8 platform_get_locale_currency();
|
2016-01-12 15:40:12 +01:00
|
|
|
uint8 platform_get_currency_value(const char *currencyCode);
|
2015-02-19 20:40:14 +01:00
|
|
|
uint16 platform_get_locale_language();
|
|
|
|
uint8 platform_get_locale_measurement_format();
|
|
|
|
uint8 platform_get_locale_temperature_format();
|
2016-09-26 04:24:29 +02:00
|
|
|
bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size);
|
2014-10-06 18:36:58 +02:00
|
|
|
|
2015-10-04 22:31:28 +02:00
|
|
|
bool platform_check_steam_overlay_attached();
|
2015-10-03 20:46:34 +02:00
|
|
|
|
2016-01-03 02:48:52 +01:00
|
|
|
datetime64 platform_get_datetime_now_utc();
|
|
|
|
|
2015-02-12 21:51:40 +01:00
|
|
|
// Windows specific definitions
|
2016-01-13 23:37:13 +01:00
|
|
|
#ifdef __WINDOWS__
|
2015-08-29 03:04:54 +02:00
|
|
|
#ifndef WIN32_LEAN_AND_MEAN
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#endif
|
2015-02-12 21:51:40 +01:00
|
|
|
#include <windows.h>
|
2016-09-08 22:37:12 +02:00
|
|
|
#undef GetMessage
|
2015-02-12 21:51:40 +01:00
|
|
|
|
2016-10-23 17:16:20 +02:00
|
|
|
void platform_windows_open_console();
|
2016-10-24 00:10:24 +02:00
|
|
|
void platform_windows_close_console();
|
2015-02-11 23:17:49 +01:00
|
|
|
int windows_get_registry_install_info(rct2_install_info *installInfo, char *source, char *font, uint8 charset);
|
2015-02-12 21:51:40 +01:00
|
|
|
HWND windows_get_window_handle();
|
2016-04-21 22:41:53 +02:00
|
|
|
void platform_setup_file_associations();
|
|
|
|
void platform_remove_file_associations();
|
2016-07-13 20:34:53 +02:00
|
|
|
// This function cannot be marked as 'static', even though it may seem to be,
|
|
|
|
// as it requires external linkage, which 'static' prevents
|
|
|
|
__declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow);
|
2016-10-29 00:33:52 +02:00
|
|
|
|
|
|
|
void wrl_initialise();
|
|
|
|
void wrl_dispose();
|
|
|
|
bool wrl_is_gamebar_visible();
|
|
|
|
|
2016-01-13 23:37:13 +01:00
|
|
|
#endif // __WINDOWS__
|
2015-08-04 01:08:42 +02:00
|
|
|
|
2016-07-13 00:46:51 +02:00
|
|
|
#if defined(__LINUX__) || defined(__MACOSX__)
|
2016-09-26 04:24:29 +02:00
|
|
|
void platform_posix_sub_user_data_path(char *buffer, size_t size, const char *homedir);
|
|
|
|
void platform_posix_sub_resolve_openrct_data_path(utf8 *out, size_t size);
|
2016-07-13 00:46:51 +02:00
|
|
|
#endif
|
|
|
|
|
2015-08-04 01:08:42 +02:00
|
|
|
#endif
|