1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 07:14:31 +01:00

Apply C++ formatting

This commit is contained in:
Michał Janiszewski
2017-10-10 10:52:48 +02:00
committed by Michael Steenbeek
parent b55f966a87
commit 83bb8721f8

View File

@@ -14,33 +14,34 @@
*****************************************************************************/
#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/core/Util.hpp>
#include <openrct2/Editor.h>
#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)();
namespace {
namespace
{
extern const shortcut_action shortcut_table[SHORTCUT_COUNT];
}
@@ -51,16 +52,19 @@ extern 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 && static_cast<uint32>(shortcutIndex) < Util::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();
}
}
@@ -70,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);
}
@@ -97,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))
@@ -106,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);
}
@@ -130,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);
}
@@ -139,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);
}
@@ -149,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;
}
@@ -167,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;
}
@@ -213,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();
}
@@ -310,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);
}
@@ -326,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);
}
@@ -342,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);
}
@@ -358,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);
}
@@ -374,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);
}
}
@@ -396,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);
}
}
@@ -406,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);
}
}
@@ -416,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);
}
}
@@ -426,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);
}
}
@@ -436,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);
}
}
@@ -489,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;
}
@@ -501,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);
}
@@ -513,7 +565,6 @@ static void shortcut_clear_scenery()
}
}
static void shortcut_open_chat_window()
{
if (gScreenFlags & SCREEN_FLAGS_TITLE_DEMO)
@@ -525,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);
@@ -569,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);
}
}
@@ -674,12 +730,14 @@ 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);
}
}
namespace {
namespace
{
const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
shortcut_close_top_most_window,
shortcut_close_all_floating_windows,
@@ -715,7 +773,7 @@ const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
shortcut_show_map,
shortcut_screenshot,
//new
// new
shortcut_reduce_game_speed,
shortcut_increase_game_speed,
shortcut_open_cheat_window,