refactor and move keyboard shortcuts to a new source file

This commit is contained in:
IntelOrca 2014-11-05 18:50:51 +00:00
parent a773ada29e
commit ea6b0de6a6
9 changed files with 503 additions and 324 deletions

View File

@ -60,6 +60,7 @@
<ClCompile Include="..\src\hook.c" />
<ClCompile Include="..\src\input.c" />
<ClCompile Include="..\src\interface\graph.c" />
<ClCompile Include="..\src\interface\keyboard_shortcut.c" />
<ClCompile Include="..\src\interface\screenshot.c" />
<ClCompile Include="..\src\interface\viewport.c" />
<ClCompile Include="..\src\interface\widget.c" />
@ -166,6 +167,7 @@
<ClInclude Include="..\src\hook.h" />
<ClInclude Include="..\src\input.h" />
<ClInclude Include="..\src\interface\graph.h" />
<ClInclude Include="..\src\interface\keyboard_shortcut.h" />
<ClInclude Include="..\src\interface\screenshot.h" />
<ClInclude Include="..\src\interface\viewport.h" />
<ClInclude Include="..\src\interface\widget.h" />

View File

@ -379,7 +379,6 @@
</ClCompile>
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\drawing\rain.c">
<Filter>Source\Drawing</Filter>
</ClCompile>
@ -440,6 +439,10 @@
<ClCompile Include="..\src\windows\ride_construction.c">
<Filter>Source\Windows</Filter>
</ClCompile>
<ClCompile Include="..\lib\libspeex\resample.c;..\lib\lodepng\lodepng.c" />
<ClCompile Include="..\src\interface\keyboard_shortcut.c">
<Filter>Source\Interface</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\src\management\award.h">
@ -640,5 +643,8 @@
<ClInclude Include="..\src\ride\station.h">
<Filter>Source\Ride</Filter>
</ClInclude>
<ClInclude Include="..\src\interface\keyboard_shortcut.h">
<Filter>Source\Interface</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -50,6 +50,16 @@
int gGameSpeed = 1;
void game_increase_game_speed()
{
gGameSpeed = min(8, gGameSpeed + 1);
}
void game_reduce_game_speed()
{
gGameSpeed = max(1, gGameSpeed - 1);
}
/**
*
* rct2: 0x0066B5C0 (part of 0x0066B3E8)

View File

@ -86,6 +86,9 @@ typedef void (GAME_COMMAND_POINTER)(int* eax, int* ebx, int* ecx, int* edx, int*
extern int gGameSpeed;
void game_increase_game_speed();
void game_reduce_game_speed();
void game_create_windows();
void game_update();
void game_logic_update();

View File

@ -25,6 +25,7 @@
#include "config.h"
#include "game.h"
#include "input.h"
#include "interface/keyboard_shortcut.h"
#include "interface/viewport.h"
#include "interface/widget.h"
#include "interface/window.h"
@ -926,324 +927,6 @@ int get_next_key()
return 0;
}
void handle_shortcut_command(int shortcutIndex)
{
rct_window *window;
switch (shortcutIndex) {
case SHORTCUT_CLOSE_TOP_MOST_WINDOW:
window_close_top();
break;
case SHORTCUT_CLOSE_ALL_FLOATING_WINDOWS:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2))
window_close_all();
else if (RCT2_GLOBAL(0x0141F570, uint8) == 1)
window_close_top();
break;
case SHORTCUT_CANCEL_CONSTRUCTION_MODE:
window = window_find_by_class(WC_ERROR);
if (window != NULL)
window_close(window);
else if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE)
tool_cancel();
break;
case SHORTCUT_PAUSE_GAME:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 10)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 0, WE_MOUSE_UP);
}
}
break;
case SHORTCUT_ZOOM_VIEW_OUT:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 2, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_ZOOM_VIEW_IN:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 3, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_ROTATE_VIEW:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 4, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_ROTATE_CONSTRUCTION_OBJECT:
RCT2_CALLPROC_EBPSAFE(0x006E4182);
break;
case SHORTCUT_UNDERGROUND_VIEW_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_UNDERGROUND_INSIDE;
window_invalidate(window);
}
break;
case SHORTCUT_REMOVE_BASE_LAND_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_HIDE_BASE;
window_invalidate(window);
}
break;
case SHORTCUT_REMOVE_VERTICAL_LAND_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_HIDE_VERTICAL;
window_invalidate(window);
}
break;
case SHORTCUT_SEE_THROUGH_RIDES_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_RIDES;
window_invalidate(window);
}
break;
case SHORTCUT_SEE_THROUGH_SCENERY_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_SEETHROUGH_SCENERY;
window_invalidate(window);
}
break;
case SHORTCUT_INVISIBLE_SUPPORTS_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_INVISIBLE_SUPPORTS;
window_invalidate(window);
}
break;
case SHORTCUT_INVISIBLE_PEOPLE_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_INVISIBLE_PEEPS;
window_invalidate(window);
}
break;
case SHORTCUT_HEIGHT_MARKS_ON_LAND_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_LAND_HEIGHTS;
window_invalidate(window);
}
break;
case SHORTCUT_HEIGHT_MARKS_ON_RIDE_TRACKS_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_TRACK_HEIGHTS;
window_invalidate(window);
}
break;
case SHORTCUT_HEIGHT_MARKS_ON_PATHS_TOGGLE:
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= VIEWPORT_FLAG_PATH_HEIGHTS;
window_invalidate(window);
}
break;
case SHORTCUT_ADJUST_LAND:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 7, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_ADJUST_WATER:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 8, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_BUILD_SCENERY:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 9, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_BUILD_PATHS:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 10, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_BUILD_NEW_RIDE:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 11, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_SHOW_FINANCIAL_INFORMATION:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_finances_open();
break;
case SHORTCUT_SHOW_RESEARCH_INFORMATION:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
// Open new ride window
RCT2_CALLPROC_EBPSAFE(0x006B3CFF);
window = window_find_by_class(WC_CONSTRUCT_RIDE);
if (window != NULL)
RCT2_CALLPROC_WE_MOUSE_DOWN(window->event_handlers[WE_MOUSE_DOWN], 10, window, NULL);
}
break;
case SHORTCUT_SHOW_RIDES_LIST:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 12, WE_MOUSE_UP);
}
}
break;
case SHORTCUT_SHOW_PARK_INFORMATION:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 13, WE_MOUSE_UP);
}
}
break;
case SHORTCUT_SHOW_GUEST_LIST:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 15, WE_MOUSE_UP);
}
}
break;
case SHORTCUT_SHOW_STAFF_LIST:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 14, WE_MOUSE_UP);
}
}
break;
case SHORTCUT_SHOW_RECENT_MESSAGES:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E))
window_news_open();
break;
case SHORTCUT_SHOW_MAP:
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 6, WE_MOUSE_UP);
}
}
}
break;
case SHORTCUT_SCREENSHOT:
RCT2_CALLPROC_EBPSAFE(0x006E4034); // set screenshot countdown to 2
break;
// New
case SHORTCUT_REDUCE_GAME_SPEED:
game_reduce_game_speed();
break;
case SHORTCUT_INCREASE_GAME_SPEED:
game_increase_game_speed();
break;
}
}
void game_increase_game_speed()
{
gGameSpeed = min(8, gGameSpeed + 1);
}
void game_reduce_game_speed()
{
gGameSpeed = max(1, gGameSpeed - 1);
}
/**
*
* rct2: 0x006E3E68
*/
void handle_shortcut(int key)
{
int i;
for (i = 0; i < SHORTCUT_COUNT; i++) {
if (key == gShortcutKeys[i]) {
handle_shortcut_command(i);
break;
}
}
}
/**
*
* rct2: 0x006E3E91
*/
void set_shortcut(int key)
{
int i;
// Unmap shortcut that already uses this key
for (i = 0; i < 32; i++) {
if (key == gShortcutKeys[i]) {
gShortcutKeys[i] = 0xFFFF;
break;
}
}
// Map shortcut to this key
gShortcutKeys[RCT2_GLOBAL(0x009DE511, uint8)] = key;
window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST);
config_save();
}
/**
*
* rct2: 0x006E3B43
@ -1281,7 +964,7 @@ void game_handle_keyboard_input()
w = window_find_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
if (w != NULL)
set_shortcut(key);
keyboard_shortcut_set(key);
else if (RCT2_GLOBAL(RCT2_ADDRESS_ON_TUTORIAL, uint8) == 1)
tutorial_stop();
else{
@ -1290,7 +973,7 @@ void game_handle_keyboard_input()
((void(*)(int, rct_window*))w->event_handlers[WE_TEXT_INPUT])(key,w);
}
else{
handle_shortcut(key);
keyboard_shortcut_handle(key);
}
}

View File

@ -46,7 +46,6 @@ enum {
void game_handle_input();
void game_handle_keyboard_input();
void handle_shortcut_command(int shortcutIndex);
void store_mouse_input(int state);

View File

@ -0,0 +1,447 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#include "../addresses.h"
#include "../config.h"
#include "../game.h"
#include "../input.h"
#include "keyboard_shortcut.h"
#include "viewport.h"
#include "window.h"
typedef void (*shortcut_action)();
static const shortcut_action shortcut_table[SHORTCUT_COUNT];
/**
*
* rct2: 0x006E3E91
*/
void keyboard_shortcut_set(int key)
{
int i;
// Unmap shortcut that already uses this key
for (i = 0; i < 32; i++) {
if (key == gShortcutKeys[i]) {
gShortcutKeys[i] = 0xFFFF;
break;
}
}
// Map shortcut to this key
gShortcutKeys[RCT2_GLOBAL(0x009DE511, uint8)] = key;
window_close_by_class(WC_CHANGE_KEYBOARD_SHORTCUT);
window_invalidate_by_class(WC_KEYBOARD_SHORTCUT_LIST);
config_save();
}
/**
*
* rct2: 0x006E3E68
*/
void keyboard_shortcut_handle(int key)
{
int i;
for (i = 0; i < SHORTCUT_COUNT; i++) {
if (key == gShortcutKeys[i]) {
keyboard_shortcut_handle_command(i);
break;
}
}
}
void keyboard_shortcut_handle_command(int shortcutIndex)
{
if (shortcutIndex >= 0 && shortcutIndex < countof(shortcut_table))
shortcut_table[shortcutIndex]();
}
#pragma region Shortcut Commands
static void toggle_view_flag(int viewportFlag)
{
rct_window *window;
window = window_get_main();
if (window != NULL) {
window->viewport->flags ^= viewportFlag;
window_invalidate(window);
}
}
static void shortcut_close_top_most_window()
{
window_close_top();
}
static void shortcut_close_all_floating_windows()
{
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2))
window_close_all();
else if (RCT2_GLOBAL(0x0141F570, uint8) == 1)
window_close_top();
}
static void shortcut_cancel_construction_mode()
{
rct_window *window;
window = window_find_by_class(WC_ERROR);
if (window != NULL)
window_close(window);
else if (RCT2_GLOBAL(RCT2_ADDRESS_INPUT_FLAGS, uint32) & INPUT_FLAG_TOOL_ACTIVE)
tool_cancel();
}
static void shortcut_pause_game()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 10)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 0, WE_MOUSE_UP);
}
}
}
static void shortcut_zoom_view_out()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 2, WE_MOUSE_UP);
}
}
}
}
static void shortcut_zoom_view_in()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 3, WE_MOUSE_UP);
}
}
}
}
static void shortcut_rotate_view()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 8)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 4, WE_MOUSE_UP);
}
}
}
}
static void shortcut_rotate_construction_object()
{
RCT2_CALLPROC_EBPSAFE(0x006E4182);
}
static void shortcut_underground_view_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_UNDERGROUND_INSIDE);
}
static void shortcut_remove_base_land_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_HIDE_BASE);
}
static void shortcut_remove_vertical_land_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_HIDE_VERTICAL);
}
static void shortcut_see_through_rides_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_SEETHROUGH_RIDES);
}
static void shortcut_see_through_scenery_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_SEETHROUGH_SCENERY);
}
static void shortcut_invisible_supports_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_INVISIBLE_SUPPORTS);
}
static void shortcut_invisible_people_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_INVISIBLE_PEEPS);
}
static void shortcut_height_marks_on_land_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_LAND_HEIGHTS);
}
static void shortcut_height_marks_on_ride_tracks_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_TRACK_HEIGHTS);
}
static void shortcut_height_marks_on_paths_toggle()
{
toggle_view_flag(VIEWPORT_FLAG_PATH_HEIGHTS);
}
static void shortcut_adjust_land()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 7, WE_MOUSE_UP);
}
}
}
}
static void shortcut_adjust_water()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 8, WE_MOUSE_UP);
}
}
}
}
static void shortcut_build_scenery()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 9, WE_MOUSE_UP);
}
}
}
}
static void shortcut_build_paths()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 10, WE_MOUSE_UP);
}
}
}
}
static void shortcut_build_new_ride()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 11, WE_MOUSE_UP);
}
}
}
}
static void shortcut_show_financial_information()
{
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C))
if (!(RCT2_GLOBAL(RCT2_ADDRESS_PARK_FLAGS, uint32) & PARK_FLAGS_NO_MONEY))
window_finances_open();
}
static void shortcut_show_research_information()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
// Open new ride window
RCT2_CALLPROC_EBPSAFE(0x006B3CFF);
window = window_find_by_class(WC_CONSTRUCT_RIDE);
if (window != NULL)
RCT2_CALLPROC_WE_MOUSE_DOWN(window->event_handlers[WE_MOUSE_DOWN], 10, window, NULL);
}
}
static void shortcut_show_rides_list()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 12, WE_MOUSE_UP);
}
}
}
static void shortcut_show_park_information()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 13, WE_MOUSE_UP);
}
}
}
static void shortcut_show_guest_list()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 15, WE_MOUSE_UP);
}
}
}
static void shortcut_show_staff_list()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 14, WE_MOUSE_UP);
}
}
}
static void shortcut_show_recent_messages()
{
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0E))
window_news_open();
}
static void shortcut_show_map()
{
rct_window *window;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2) || RCT2_GLOBAL(0x0141F570, uint8) == 1) {
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 0x0C)) {
window = window_find_by_class(WC_TOP_TOOLBAR);
if (window != NULL) {
window_invalidate(window);
window_event_helper(window, 6, WE_MOUSE_UP);
}
}
}
}
static void shortcut_screenshot()
{
RCT2_CALLPROC_EBPSAFE(0x006E4034); // set screenshot countdown to 2
}
static void shortcut_reduce_game_speed()
{
game_reduce_game_speed();
}
static void shortcut_increase_game_speed()
{
game_increase_game_speed();
}
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,
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,
shortcut_reduce_game_speed,
shortcut_increase_game_speed
};
#pragma endregion

View File

@ -0,0 +1,28 @@
/*****************************************************************************
* Copyright (c) 2014 Ted John
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* This file is part of 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.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*****************************************************************************/
#ifndef _INTERFACE_KEYBOARD_SHORTCUT_H_
#define _INTERFACE_KEYBOARD_SHORTCUT_H_
void keyboard_shortcut_set(int key);
void keyboard_shortcut_handle(int key);
void keyboard_shortcut_handle_command(int shortcutIndex);
#endif

View File

@ -30,6 +30,7 @@
#include "../cursors.h"
#include "../drawing/drawing.h"
#include "../input.h"
#include "../interface/keyboard_shortcut.h"
#include "../interface/screenshot.h"
#include "../interface/window.h"
#include "osinterface.h"
@ -467,10 +468,10 @@ void osinterface_process_messages()
int gesturePixels = (int)(_gestureRadius * RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_WIDTH, sint16));
if (gesturePixels > tolerance) {
_gestureRadius = 0;
handle_shortcut_command(SHORTCUT_ZOOM_VIEW_IN);
keyboard_shortcut_handle_command(SHORTCUT_ZOOM_VIEW_IN);
} else if (gesturePixels < -tolerance) {
_gestureRadius = 0;
handle_shortcut_command(SHORTCUT_ZOOM_VIEW_OUT);
keyboard_shortcut_handle_command(SHORTCUT_ZOOM_VIEW_OUT);
}
}
break;