1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Merge pull request #6432 from janisozaur/ui-cpp

openrct2-ui C++
This commit is contained in:
Michael Steenbeek
2017-10-11 11:31:02 +02:00
committed by GitHub
7 changed files with 281 additions and 188 deletions

View File

@@ -101,6 +101,8 @@
4C93F1A91F8B748900A9330D /* SplashBoats.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1A21F8B748900A9330D /* SplashBoats.cpp */; };
4C93F1AA1F8B748900A9330D /* SubmarineRide.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1A31F8B748900A9330D /* SubmarineRide.cpp */; };
4C93F1AB1F8B748900A9330D /* WaterCoaster.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1A41F8B748900A9330D /* WaterCoaster.cpp */; };
4C93F1AD1F8CD9F000A9330D /* Input.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1AC1F8CD9F000A9330D /* Input.cpp */; };
4C93F1AF1F8CD9F600A9330D /* KeyboardShortcut.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4C93F1AE1F8CD9F600A9330D /* KeyboardShortcut.cpp */; };
4CB832A71EFBDCCE00B88761 /* land_tool.c in Sources */ = {isa = PBXBuildFile; fileRef = 4CB832A51EFBDCCE00B88761 /* land_tool.c */; };
4CB832AB1EFFB8D100B88761 /* ttf_sdlport.c in Sources */ = {isa = PBXBuildFile; fileRef = 4CB832A81EFFB8D100B88761 /* ttf_sdlport.c */; };
4CB832AC1EFFB8D100B88761 /* ttf.c in Sources */ = {isa = PBXBuildFile; fileRef = 4CB832A91EFFB8D100B88761 /* ttf.c */; };
@@ -254,7 +256,6 @@
D4EC48E61C2637710024B507 /* g2.dat in Resources */ = {isa = PBXBuildFile; fileRef = D4EC48E31C2637710024B507 /* g2.dat */; };
D4EC48E71C2637710024B507 /* language in Resources */ = {isa = PBXBuildFile; fileRef = D4EC48E41C2637710024B507 /* language */; };
D4EC48E81C2637710024B507 /* title in Resources */ = {isa = PBXBuildFile; fileRef = D4EC48E51C2637710024B507 /* title */; };
F74789551EEDEA0D009E50E7 /* input.c in Sources */ = {isa = PBXBuildFile; fileRef = F74789531EEDEA0D009E50E7 /* input.c */; };
F76C85B01EC4E88300FA49E2 /* Audio.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C83571EC4E7CC00FA49E2 /* Audio.cpp */; };
F76C85B41EC4E88300FA49E2 /* AudioMixer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C835B1EC4E7CC00FA49E2 /* AudioMixer.cpp */; };
F76C85B71EC4E88300FA49E2 /* NullAudioSource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F76C835E1EC4E7CC00FA49E2 /* NullAudioSource.cpp */; };
@@ -489,7 +490,6 @@
F775F5381EE3725C001F00E7 /* DummyAudioContext.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F775F5361EE3724F001F00E7 /* DummyAudioContext.cpp */; };
F79F428F1F3260F1009E42F8 /* changelog.txt in Resources */ = {isa = PBXBuildFile; fileRef = F79F428E1F3260F1009E42F8 /* changelog.txt */; };
F7CB863F1EEDA0B50030C877 /* WindowManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB863D1EEDA0B50030C877 /* WindowManager.cpp */; };
F7CB86491EEDA1330030C877 /* keyboard_shortcut.c in Sources */ = {isa = PBXBuildFile; fileRef = F7CB86461EEDA1330030C877 /* keyboard_shortcut.c */; };
F7CB864A1EEDA1330030C877 /* KeyboardShortcuts.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB86471EEDA1330030C877 /* KeyboardShortcuts.cpp */; };
F7CB864D1EEDA1A80030C877 /* DummyWindowManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */; };
F7CB864E1EEDA2050030C877 /* DummyWindowManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */; };
@@ -697,6 +697,8 @@
4C93F1A21F8B748900A9330D /* SplashBoats.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SplashBoats.cpp; sourceTree = "<group>"; };
4C93F1A31F8B748900A9330D /* SubmarineRide.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SubmarineRide.cpp; sourceTree = "<group>"; };
4C93F1A41F8B748900A9330D /* WaterCoaster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WaterCoaster.cpp; sourceTree = "<group>"; };
4C93F1AC1F8CD9F000A9330D /* Input.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Input.cpp; sourceTree = "<group>"; };
4C93F1AE1F8CD9F600A9330D /* KeyboardShortcut.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardShortcut.cpp; sourceTree = "<group>"; };
4CB832A51EFBDCCE00B88761 /* land_tool.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = land_tool.c; sourceTree = "<group>"; };
4CB832A61EFBDCCE00B88761 /* land_tool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = land_tool.h; sourceTree = "<group>"; };
4CB832A81EFFB8D100B88761 /* ttf_sdlport.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ttf_sdlport.c; sourceTree = "<group>"; };
@@ -1013,8 +1015,7 @@
D4EC48E31C2637710024B507 /* g2.dat */ = {isa = PBXFileReference; lastKnownFileType = file; name = g2.dat; path = data/g2.dat; sourceTree = SOURCE_ROOT; };
D4EC48E41C2637710024B507 /* language */ = {isa = PBXFileReference; lastKnownFileType = folder; name = language; path = data/language; sourceTree = SOURCE_ROOT; };
D4EC48E51C2637710024B507 /* title */ = {isa = PBXFileReference; lastKnownFileType = folder; name = title; path = data/title; sourceTree = SOURCE_ROOT; };
F74789531EEDEA0D009E50E7 /* input.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = input.c; sourceTree = "<group>"; };
F74789541EEDEA0D009E50E7 /* input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = input.h; sourceTree = "<group>"; };
F74789541EEDEA0D009E50E7 /* Input.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Input.h; sourceTree = "<group>"; };
F76C809A1EC4D9FA00FA49E2 /* libopenrct2.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libopenrct2.a; sourceTree = BUILT_PRODUCTS_DIR; };
F76C83571EC4E7CC00FA49E2 /* Audio.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Audio.cpp; sourceTree = "<group>"; };
F76C83581EC4E7CC00FA49E2 /* audio.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = audio.h; sourceTree = "<group>"; };
@@ -1418,7 +1419,6 @@
F79F428E1F3260F1009E42F8 /* changelog.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = changelog.txt; path = distribution/changelog.txt; sourceTree = SOURCE_ROOT; };
F7CB863D1EEDA0B50030C877 /* WindowManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WindowManager.cpp; sourceTree = "<group>"; };
F7CB863E1EEDA0B50030C877 /* WindowManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WindowManager.h; sourceTree = "<group>"; };
F7CB86461EEDA1330030C877 /* keyboard_shortcut.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = keyboard_shortcut.c; sourceTree = "<group>"; };
F7CB86471EEDA1330030C877 /* KeyboardShortcuts.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyboardShortcuts.cpp; sourceTree = "<group>"; };
F7CB86481EEDA1330030C877 /* KeyboardShortcuts.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyboardShortcuts.h; sourceTree = "<group>"; };
F7CB864B1EEDA1A80030C877 /* DummyWindowManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DummyWindowManager.cpp; sourceTree = "<group>"; };
@@ -2749,9 +2749,9 @@
F7CB86451EEDA1200030C877 /* input */ = {
isa = PBXGroup;
children = (
F74789531EEDEA0D009E50E7 /* input.c */,
F74789541EEDEA0D009E50E7 /* input.h */,
F7CB86461EEDA1330030C877 /* keyboard_shortcut.c */,
4C93F1AC1F8CD9F000A9330D /* Input.cpp */,
F74789541EEDEA0D009E50E7 /* Input.h */,
4C93F1AE1F8CD9F600A9330D /* KeyboardShortcut.cpp */,
F7CB86471EEDA1330030C877 /* KeyboardShortcuts.cpp */,
F7CB86481EEDA1330030C877 /* KeyboardShortcuts.h */,
);
@@ -3122,7 +3122,6 @@
4C93F1931F8B747A00A9330D /* Twist.cpp in Sources */,
4C93F14A1F8B744400A9330D /* MineTrainCoaster.cpp in Sources */,
4C93F1531F8B744400A9330D /* SuspendedSwingingCoaster.cpp in Sources */,
F74789551EEDEA0D009E50E7 /* input.c in Sources */,
4C93F18B1F8B747A00A9330D /* GoKarts.cpp in Sources */,
C654DF2F1F69C0430040F43D /* Error.cpp in Sources */,
4C93F1791F8B745700A9330D /* SpiralSlide.cpp in Sources */,
@@ -3173,6 +3172,7 @@
C64644FC1F3FA4120026AC2D /* Footpath.cpp in Sources */,
F7CB864D1EEDA1A80030C877 /* DummyWindowManager.cpp in Sources */,
F76C887C1EC5324E00FA49E2 /* MemoryAudioSource.cpp in Sources */,
4C93F1AF1F8CD9F600A9330D /* KeyboardShortcut.cpp in Sources */,
4C93F14B1F8B744400A9330D /* MiniRollerCoaster.cpp in Sources */,
C654DF3D1F69C0430040F43D /* TrackDesignPlace.cpp in Sources */,
4C93F19C1F8B748200A9330D /* Monorail.cpp in Sources */,
@@ -3251,10 +3251,10 @@
4C93F14F1F8B744400A9330D /* ReverserRollerCoaster.cpp in Sources */,
4C8B42701EEB1ABD00F015CA /* X8DrawingEngine.cpp in Sources */,
C654DF301F69C0430040F43D /* Finances.cpp in Sources */,
F7CB86491EEDA1330030C877 /* keyboard_shortcut.c in Sources */,
4C93F19D1F8B748200A9330D /* SuspendedMonorail.cpp in Sources */,
C666EE751F37ACB10061AA04 /* NewsOptions.cpp in Sources */,
C654DF311F69C0430040F43D /* GuestList.cpp in Sources */,
4C93F1AD1F8CD9F000A9330D /* Input.cpp in Sources */,
C666EE761F37ACB10061AA04 /* Options.cpp in Sources */,
C666EE6E1F37ACB10061AA04 /* CustomCurrency.cpp in Sources */,
4C93F1711F8B745700A9330D /* HauntedHouse.cpp in Sources */,

View File

@@ -25,7 +25,6 @@ endif ()
# Sources
file(GLOB_RECURSE OPENRCT2_UI_SOURCES
"${CMAKE_CURRENT_LIST_DIR}/*.c"
"${CMAKE_CURRENT_LIST_DIR}/*.cpp"
"${CMAKE_CURRENT_LIST_DIR}/*.h"
"${CMAKE_CURRENT_LIST_DIR}/*.hpp")

View File

@@ -18,7 +18,7 @@
#include <openrct2-ui/windows/Window.h>
#include <openrct2/core/Console.hpp>
#include <openrct2/config/Config.h>
#include "input/input.h"
#include "input/Input.h"
#include "input/KeyboardShortcuts.h"
#include "WindowManager.h"

View File

@@ -14,23 +14,24 @@
*****************************************************************************/
#pragma endregion
#include <ctype.h>
#include <openrct2/common.h>
#include <SDL.h>
#include <openrct2/config/Config.h>
#include <ctype.h>
#include <openrct2/Context.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/common.h>
#include <openrct2/config/Config.h>
#include <openrct2/input.h>
#include <openrct2/interface/chat.h>
#include <openrct2/interface/console.h>
#include <openrct2/interface/window.h>
#include <openrct2/OpenRCT2.h>
#include "input.h"
#include "KeyboardShortcuts.h"
#include "Input.h"
static void input_handle_console(sint32 key)
{
CONSOLE_INPUT input = CONSOLE_INPUT_NONE;
switch (key) {
switch (key)
{
case SDL_SCANCODE_ESCAPE:
input = CONSOLE_INPUT_LINE_CLEAR;
break;
@@ -50,7 +51,8 @@ static void input_handle_console(sint32 key)
input = CONSOLE_INPUT_SCROLL_NEXT;
break;
}
if (input != CONSOLE_INPUT_NONE) {
if (input != CONSOLE_INPUT_NONE)
{
console_input(input);
}
}
@@ -58,7 +60,8 @@ static void input_handle_console(sint32 key)
static void input_handle_chat(sint32 key)
{
CHAT_INPUT input = CHAT_INPUT_NONE;
switch (key) {
switch (key)
{
case SDL_SCANCODE_ESCAPE:
input = CHAT_INPUT_CLOSE;
break;
@@ -66,15 +69,16 @@ static void input_handle_chat(sint32 key)
input = CHAT_INPUT_SEND;
break;
}
if (input != CHAT_INPUT_NONE) {
if (input != CHAT_INPUT_NONE)
{
chat_input(input);
}
}
static void game_handle_key_scroll()
{
rct_window *mainWindow;
sint32 scrollX, scrollY;
rct_window * mainWindow;
sint32 scrollX, scrollY;
mainWindow = window_get_main();
if (mainWindow == NULL)
@@ -84,23 +88,27 @@ static void game_handle_key_scroll()
if (mainWindow->viewport == NULL)
return;
rct_window *textWindow;
rct_window * textWindow;
textWindow = window_find_by_class(WC_TEXTINPUT);
if (textWindow || gUsingWidgetTextBox) return;
if (gChatOpen) return;
if (textWindow || gUsingWidgetTextBox)
return;
if (gChatOpen)
return;
scrollX = 0;
scrollY = 0;
scrollX = 0;
scrollY = 0;
const uint8 * keysState = context_get_keys_state();
get_keyboard_map_scroll(keysState, &scrollX, &scrollY);
// Scroll viewport
if (scrollX != 0) {
if (scrollX != 0)
{
mainWindow->saved_view_x += scrollX * (12 << mainWindow->viewport->zoom);
input_set_flag(INPUT_FLAG_VIEWPORT_SCROLLING, true);
}
if (scrollY != 0) {
if (scrollY != 0)
{
mainWindow->saved_view_y += scrollY * (12 << mainWindow->viewport->zoom);
input_set_flag(INPUT_FLAG_VIEWPORT_SCROLLING, true);
}
@@ -121,15 +129,20 @@ static sint32 input_scancode_to_rct_keycode(sint32 sdl_key)
void input_handle_keyboard(bool isTitle)
{
if (gOpenRCT2Headless) {
if (gOpenRCT2Headless)
{
return;
}
if (!gConsoleOpen) {
if (!isTitle) {
if (!gConsoleOpen)
{
if (!isTitle)
{
// Handle mouse scrolling
if (input_get_state() == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling) {
if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z))) {
if (input_get_state() == INPUT_STATE_NORMAL && gConfigGeneral.edge_scrolling)
{
if (!(gInputPlaceObjectModifier & (PLACE_OBJECT_MODIFIER_SHIFT_Z | PLACE_OBJECT_MODIFIER_COPY_Z)))
{
game_handle_edge_scroll();
}
}
@@ -137,43 +150,55 @@ void input_handle_keyboard(bool isTitle)
// Handle modifier keys and key scrolling
gInputPlaceObjectModifier = PLACE_OBJECT_MODIFIER_NONE;
const uint8 * keysState = context_get_keys_state();
if (keysState[SDL_SCANCODE_LSHIFT] || keysState[SDL_SCANCODE_RSHIFT]) {
const uint8 * keysState = context_get_keys_state();
if (keysState[SDL_SCANCODE_LSHIFT] || keysState[SDL_SCANCODE_RSHIFT])
{
gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_SHIFT_Z;
}
if (keysState[SDL_SCANCODE_LCTRL] || keysState[SDL_SCANCODE_RCTRL]) {
if (keysState[SDL_SCANCODE_LCTRL] || keysState[SDL_SCANCODE_RCTRL])
{
gInputPlaceObjectModifier |= PLACE_OBJECT_MODIFIER_COPY_Z;
}
if (keysState[SDL_SCANCODE_LALT] || keysState[SDL_SCANCODE_RALT]) {
if (keysState[SDL_SCANCODE_LALT] || keysState[SDL_SCANCODE_RALT])
{
gInputPlaceObjectModifier |= 4;
}
#ifdef __MACOSX__
if (keysState[SDL_SCANCODE_LGUI] || keysState[SDL_SCANCODE_RGUI]) {
if (keysState[SDL_SCANCODE_LGUI] || keysState[SDL_SCANCODE_RGUI])
{
gInputPlaceObjectModifier |= 8;
}
#endif
if (!isTitle) {
if (!isTitle)
{
game_handle_key_scroll();
}
}
// Handle key input
sint32 key;
while (!gOpenRCT2Headless && (key = get_next_key()) != 0) {
while (!gOpenRCT2Headless && (key = get_next_key()) != 0)
{
if (key == 255)
continue;
// Reserve backtick for console
if (key == SDL_SCANCODE_GRAVE) {
if ((gConfigGeneral.debugging_tools && !context_is_input_active()) || gConsoleOpen) {
if (key == SDL_SCANCODE_GRAVE)
{
if ((gConfigGeneral.debugging_tools && !context_is_input_active()) || gConsoleOpen)
{
window_cancel_textbox();
console_toggle();
}
continue;
} else if (gConsoleOpen) {
}
else if (gConsoleOpen)
{
input_handle_console(key);
continue;
} else if (!isTitle && gChatOpen) {
}
else if (!isTitle && gChatOpen)
{
input_handle_chat(key);
continue;
}
@@ -181,16 +206,22 @@ void input_handle_keyboard(bool isTitle)
key |= gInputPlaceObjectModifier << 8;
rct_window * w = window_find_by_class(WC_TEXTINPUT);
if (w != NULL) {
if (w != NULL)
{
char keychar = input_scancode_to_rct_keycode(key & 0xFF);
window_text_input_key(w, keychar);
} else if (!gUsingWidgetTextBox) {
}
else if (!gUsingWidgetTextBox)
{
w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
if (w != NULL) {
if (w != NULL)
{
keyboard_shortcuts_set(key);
window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST);
} else {
}
else
{
keyboard_shortcut_handle(key);
}
}

View File

@@ -14,32 +14,36 @@
*****************************************************************************/
#pragma endregion
#include <openrct2/Context.h>
#include <openrct2/Editor.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/audio/audio.h>
#include <openrct2/config/Config.h>
#include <openrct2/Editor.h>
#include <openrct2/core/Util.hpp>
#include <openrct2/game.h>
#include <openrct2/input.h>
#include <openrct2/interface/chat.h>
#include <openrct2/interface/Screenshot.h>
#include <openrct2/interface/chat.h>
#include <openrct2/interface/viewport.h>
#include <openrct2/interface/widget.h>
#include <openrct2/interface/window.h>
#include <openrct2/localisation/localisation.h>
#include <openrct2/network/network.h>
#include <openrct2/OpenRCT2.h>
#include <openrct2/platform/platform.h>
#include <openrct2/ride/track.h>
#include <openrct2/ride/track_paint.h>
#include <openrct2/title/TitleScreen.h>
#include <openrct2/util/util.h>
#include <openrct2/interface/viewport.h>
#include <openrct2/interface/widget.h>
#include <openrct2/interface/window.h>
#include <openrct2/Context.h>
#include "KeyboardShortcuts.h"
uint8 gKeyboardShortcutChangeId;
typedef void (*shortcut_action)();
static const shortcut_action shortcut_table[SHORTCUT_COUNT];
namespace
{
extern const shortcut_action shortcut_table[SHORTCUT_COUNT];
}
/**
*
@@ -48,16 +52,19 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT];
void keyboard_shortcut_handle(sint32 key)
{
sint32 shortcut = keyboard_shortcuts_get_from_key(key);
if (shortcut != -1) {
if (shortcut != -1)
{
keyboard_shortcut_handle_command(shortcut);
}
}
void keyboard_shortcut_handle_command(sint32 shortcutIndex)
{
if (shortcutIndex >= 0 && shortcutIndex < countof(shortcut_table)) {
if (shortcutIndex >= 0 && static_cast<uint32>(shortcutIndex) < Util::CountOf(shortcut_table))
{
shortcut_action action = shortcut_table[shortcutIndex];
if (action != NULL) {
if (action != NULL)
{
action();
}
}
@@ -67,10 +74,11 @@ void keyboard_shortcut_handle_command(sint32 shortcutIndex)
static void toggle_view_flag(sint32 viewportFlag)
{
rct_window *window;
rct_window * window;
window = window_get_main();
if (window != NULL) {
if (window != NULL)
{
window->viewport->flags ^= viewportFlag;
window_invalidate(window);
}
@@ -94,7 +102,7 @@ static void shortcut_cancel_construction_mode()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window *window = window_find_by_class(WC_ERROR);
rct_window * window = window_find_by_class(WC_ERROR);
if (window != NULL)
window_close(window);
else if (input_test_flag(INPUT_FLAG_TOOL_ACTIVE))
@@ -103,9 +111,11 @@ static void shortcut_cancel_construction_mode()
static void shortcut_pause_game()
{
if (!(gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER))) {
rct_window *window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
if (!(gScreenFlags & (SCREEN_FLAGS_TITLE_DEMO | SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window * window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL)
{
window_invalidate(window);
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_PAUSE);
}
@@ -127,7 +137,7 @@ static void shortcut_rotate_view_clockwise()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window* w = window_get_main();
rct_window * w = window_get_main();
window_rotate_camera(w, 1);
}
@@ -136,7 +146,7 @@ static void shortcut_rotate_view_anticlockwise()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
rct_window* w = window_get_main();
rct_window * w = window_get_main();
window_rotate_camera(w, -1);
}
@@ -146,17 +156,22 @@ static void shortcut_rotate_construction_object()
return;
// Rotate scenery
rct_window *w = window_find_by_class(WC_SCENERY);
if (w != NULL && !widget_is_disabled(w, WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON) && w->widgets[WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type != WWT_EMPTY) {
rct_window * w = window_find_by_class(WC_SCENERY);
if (w != NULL && !widget_is_disabled(w, WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON) &&
w->widgets[WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON].type != WWT_EMPTY)
{
window_event_mouse_up_call(w, WC_SCENERY__WIDX_SCENERY_ROTATE_OBJECTS_BUTTON);
return;
}
// Rotate construction track piece
w = window_find_by_class(WC_RIDE_CONSTRUCTION);
if (w != NULL && !widget_is_disabled(w, WC_RIDE_CONSTRUCTION__WIDX_ROTATE) && w->widgets[WC_RIDE_CONSTRUCTION__WIDX_ROTATE].type != WWT_EMPTY) {
if (w != NULL && !widget_is_disabled(w, WC_RIDE_CONSTRUCTION__WIDX_ROTATE) &&
w->widgets[WC_RIDE_CONSTRUCTION__WIDX_ROTATE].type != WWT_EMPTY)
{
// Check if building a maze...
if (w->widgets[WC_RIDE_CONSTRUCTION__WIDX_ROTATE].tooltip != STR_RIDE_CONSTRUCTION_BUILD_MAZE_IN_THIS_DIRECTION_TIP) {
if (w->widgets[WC_RIDE_CONSTRUCTION__WIDX_ROTATE].tooltip != STR_RIDE_CONSTRUCTION_BUILD_MAZE_IN_THIS_DIRECTION_TIP)
{
window_event_mouse_up_call(w, WC_RIDE_CONSTRUCTION__WIDX_ROTATE);
return;
}
@@ -164,21 +179,26 @@ static void shortcut_rotate_construction_object()
// Rotate track design preview
w = window_find_by_class(WC_TRACK_DESIGN_LIST);
if (w != NULL && !widget_is_disabled(w, WC_TRACK_DESIGN_LIST__WIDX_ROTATE) && w->widgets[WC_TRACK_DESIGN_LIST__WIDX_ROTATE].type != WWT_EMPTY) {
if (w != NULL && !widget_is_disabled(w, WC_TRACK_DESIGN_LIST__WIDX_ROTATE) &&
w->widgets[WC_TRACK_DESIGN_LIST__WIDX_ROTATE].type != WWT_EMPTY)
{
window_event_mouse_up_call(w, WC_TRACK_DESIGN_LIST__WIDX_ROTATE);
return;
}
// Rotate track design placement
w = window_find_by_class(WC_TRACK_DESIGN_PLACE);
if (w != NULL && !widget_is_disabled(w, WC_TRACK_DESIGN_PLACE__WIDX_ROTATE) && w->widgets[WC_TRACK_DESIGN_PLACE__WIDX_ROTATE].type != WWT_EMPTY) {
if (w != NULL && !widget_is_disabled(w, WC_TRACK_DESIGN_PLACE__WIDX_ROTATE) &&
w->widgets[WC_TRACK_DESIGN_PLACE__WIDX_ROTATE].type != WWT_EMPTY)
{
window_event_mouse_up_call(w, WC_TRACK_DESIGN_PLACE__WIDX_ROTATE);
return;
}
// Rotate park entrance
w = window_find_by_class(WC_MAP);
if (w != NULL && !widget_is_disabled(w, WC_MAP__WIDX_ROTATE_90) && w->widgets[WC_MAP__WIDX_ROTATE_90].type != WWT_EMPTY) {
if (w != NULL && !widget_is_disabled(w, WC_MAP__WIDX_ROTATE_90) && w->widgets[WC_MAP__WIDX_ROTATE_90].type != WWT_EMPTY)
{
window_event_mouse_up_call(w, WC_MAP__WIDX_ROTATE_90);
return;
}
@@ -210,26 +230,38 @@ static void shortcut_remove_vertical_land_toggle()
static void shortcut_remove_top_bottom_toolbar_toggle()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO) {
if (window_find_by_class(WC_TITLE_LOGO) != NULL) {
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
{
if (window_find_by_class(WC_TITLE_LOGO) != NULL)
{
window_close(window_find_by_class(WC_TITLE_LOGO));
window_close(window_find_by_class(WC_TITLE_OPTIONS));
window_close(window_find_by_class(WC_TITLE_MENU));
window_close(window_find_by_class(WC_TITLE_EXIT));
title_set_hide_version_info(true);
} else {
}
else
{
title_create_windows();
}
} else {
if (window_find_by_class(WC_TOP_TOOLBAR) != NULL) {
}
else
{
if (window_find_by_class(WC_TOP_TOOLBAR) != NULL)
{
window_close(window_find_by_class(WC_DROPDOWN));
window_close(window_find_by_class(WC_TOP_TOOLBAR));
window_close(window_find_by_class(WC_BOTTOM_TOOLBAR));
} else {
if (gScreenFlags == 0) {
}
else
{
if (gScreenFlags == 0)
{
window_top_toolbar_open();
window_game_bottom_toolbar_open();
} else {
}
else
{
window_top_toolbar_open();
window_editor_bottom_toolbar_open();
}
@@ -307,10 +339,13 @@ static void shortcut_adjust_land()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
rct_window *window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window * window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL)
{
window_invalidate(window);
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_LAND);
}
@@ -323,10 +358,13 @@ static void shortcut_adjust_water()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
rct_window *window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window * window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL)
{
window_invalidate(window);
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_WATER);
}
@@ -339,10 +377,13 @@ static void shortcut_build_scenery()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
rct_window *window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window * window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL)
{
window_invalidate(window);
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_SCENERY);
}
@@ -355,10 +396,13 @@ static void shortcut_build_paths()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
rct_window *window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window * window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL)
{
window_invalidate(window);
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_PATH);
}
@@ -371,8 +415,10 @@ static void shortcut_build_new_ride()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR))
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
context_open_window(WC_CONSTRUCT_RIDE);
}
}
@@ -393,7 +439,8 @@ static void shortcut_show_research_information()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
context_open_window_view(WV_RIDE_RESEARCH);
}
}
@@ -403,7 +450,8 @@ static void shortcut_show_rides_list()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
context_open_window(WC_RIDE_LIST);
}
}
@@ -413,7 +461,8 @@ static void shortcut_show_park_information()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
context_open_window(WC_PARK_INFORMATION);
}
}
@@ -423,7 +472,8 @@ static void shortcut_show_guest_list()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
context_open_window(WC_GUEST_LIST);
}
}
@@ -433,7 +483,8 @@ static void shortcut_show_staff_list()
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & (SCREEN_FLAGS_SCENARIO_EDITOR | SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
context_open_window(WC_STAFF_LIST);
}
}
@@ -486,8 +537,9 @@ static void shortcut_open_cheat_window()
return;
// Check if window is already open
rct_window *window = window_find_by_class(WC_CHEATS);
if (window != NULL) {
rct_window * window = window_find_by_class(WC_CHEATS);
if (window != NULL)
{
window_close(window);
return;
}
@@ -498,11 +550,14 @@ static void shortcut_clear_scenery()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
return;
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
rct_window *window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
if (!(gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) || gS6Info.editor_step == EDITOR_STEP_LANDSCAPE_EDITOR)
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
rct_window * window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL)
{
window_invalidate(window);
window_event_mouse_up_call(window, WC_TOP_TOOLBAR__WIDX_CLEAR_SCENERY);
}
@@ -510,7 +565,6 @@ static void shortcut_clear_scenery()
}
}
static void shortcut_open_chat_window()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
@@ -522,11 +576,13 @@ static void shortcut_open_chat_window()
static void shortcut_quick_save_game()
{
// Do a quick save in playing mode and a regular save in Scenario Editor mode. In other cases, don't do anything.
if (gScreenFlags == SCREEN_FLAGS_PLAYING) {
if (gScreenFlags == SCREEN_FLAGS_PLAYING)
{
tool_cancel();
save_game();
}
else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR) {
else if (gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR)
{
Intent * intent = intent_create(WC_LOADSAVE);
intent_set_uint(intent, INTENT_EXTRA_LOADSAVE_TYPE, LOADSAVETYPE_SAVE | LOADSAVETYPE_LANDSCAPE);
intent_set_string(intent, INTENT_EXTRA_PATH, gS6Info.name);
@@ -566,9 +622,12 @@ static void shortcut_orginal_painting_toggle()
static void shortcut_debug_paint_toggle()
{
rct_window * window = window_find_by_class(WC_DEBUG_PAINT);
if (window != NULL) {
if (window != NULL)
{
window_close(window);
} else {
}
else
{
context_open_window(WC_DEBUG_PAINT);
}
}
@@ -671,78 +730,83 @@ static void shortcut_ride_construction_demolish_current()
static void shortcut_load_game()
{
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER))) {
if (!(gScreenFlags & (SCREEN_FLAGS_TRACK_DESIGNER | SCREEN_FLAGS_TRACK_MANAGER)))
{
game_do_command(0, 1, 0, 0, GAME_COMMAND_LOAD_OR_QUIT, 0, 0);
}
}
static const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
shortcut_close_top_most_window,
shortcut_close_all_floating_windows,
shortcut_cancel_construction_mode,
shortcut_pause_game,
shortcut_zoom_view_out,
shortcut_zoom_view_in,
shortcut_rotate_view_clockwise,
shortcut_rotate_view_anticlockwise,
shortcut_rotate_construction_object,
shortcut_underground_view_toggle,
shortcut_remove_base_land_toggle,
shortcut_remove_vertical_land_toggle,
shortcut_see_through_rides_toggle,
shortcut_see_through_scenery_toggle,
shortcut_invisible_supports_toggle,
shortcut_invisible_people_toggle,
shortcut_height_marks_on_land_toggle,
shortcut_height_marks_on_ride_tracks_toggle,
shortcut_height_marks_on_paths_toggle,
shortcut_adjust_land,
shortcut_adjust_water,
shortcut_build_scenery,
shortcut_build_paths,
shortcut_build_new_ride,
shortcut_show_financial_information,
shortcut_show_research_information,
shortcut_show_rides_list,
shortcut_show_park_information,
shortcut_show_guest_list,
shortcut_show_staff_list,
shortcut_show_recent_messages,
shortcut_show_map,
shortcut_screenshot,
namespace
{
const shortcut_action shortcut_table[SHORTCUT_COUNT] =
{
shortcut_close_top_most_window,
shortcut_close_all_floating_windows,
shortcut_cancel_construction_mode,
shortcut_pause_game,
shortcut_zoom_view_out,
shortcut_zoom_view_in,
shortcut_rotate_view_clockwise,
shortcut_rotate_view_anticlockwise,
shortcut_rotate_construction_object,
shortcut_underground_view_toggle,
shortcut_remove_base_land_toggle,
shortcut_remove_vertical_land_toggle,
shortcut_see_through_rides_toggle,
shortcut_see_through_scenery_toggle,
shortcut_invisible_supports_toggle,
shortcut_invisible_people_toggle,
shortcut_height_marks_on_land_toggle,
shortcut_height_marks_on_ride_tracks_toggle,
shortcut_height_marks_on_paths_toggle,
shortcut_adjust_land,
shortcut_adjust_water,
shortcut_build_scenery,
shortcut_build_paths,
shortcut_build_new_ride,
shortcut_show_financial_information,
shortcut_show_research_information,
shortcut_show_rides_list,
shortcut_show_park_information,
shortcut_show_guest_list,
shortcut_show_staff_list,
shortcut_show_recent_messages,
shortcut_show_map,
shortcut_screenshot,
//new
shortcut_reduce_game_speed,
shortcut_increase_game_speed,
shortcut_open_cheat_window,
shortcut_remove_top_bottom_toolbar_toggle,
NULL,
NULL,
NULL,
NULL,
shortcut_open_chat_window,
shortcut_quick_save_game,
shortcut_show_options,
shortcut_mute_sound,
shortcut_windowed_mode_toggle,
shortcut_show_multiplayer,
shortcut_orginal_painting_toggle,
shortcut_debug_paint_toggle,
shortcut_see_through_paths_toggle,
shortcut_ride_construction_turn_left,
shortcut_ride_construction_turn_right,
shortcut_ride_construction_use_track_default,
shortcut_ride_construction_slope_down,
shortcut_ride_construction_slope_up,
shortcut_ride_construction_chain_lift_toggle,
shortcut_ride_construction_bank_left,
shortcut_ride_construction_bank_right,
shortcut_ride_construction_previous_track,
shortcut_ride_construction_next_track,
shortcut_ride_construction_build_current,
shortcut_ride_construction_demolish_current,
shortcut_load_game,
shortcut_clear_scenery,
};
// new
shortcut_reduce_game_speed,
shortcut_increase_game_speed,
shortcut_open_cheat_window,
shortcut_remove_top_bottom_toolbar_toggle,
NULL,
NULL,
NULL,
NULL,
shortcut_open_chat_window,
shortcut_quick_save_game,
shortcut_show_options,
shortcut_mute_sound,
shortcut_windowed_mode_toggle,
shortcut_show_multiplayer,
shortcut_orginal_painting_toggle,
shortcut_debug_paint_toggle,
shortcut_see_through_paths_toggle,
shortcut_ride_construction_turn_left,
shortcut_ride_construction_turn_right,
shortcut_ride_construction_use_track_default,
shortcut_ride_construction_slope_down,
shortcut_ride_construction_slope_up,
shortcut_ride_construction_chain_lift_toggle,
shortcut_ride_construction_bank_left,
shortcut_ride_construction_bank_right,
shortcut_ride_construction_previous_track,
shortcut_ride_construction_next_track,
shortcut_ride_construction_build_current,
shortcut_ride_construction_demolish_current,
shortcut_load_game,
shortcut_clear_scenery,
};
}
#pragma endregion

View File

@@ -22,7 +22,6 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="**\*.c" />
<ClCompile Include="**\*.cpp" />
</ItemGroup>
<ItemGroup>