Implement customizable toggle windowed mode shortcut (#3462)

Implement customizable toggle windowed mode shortcut
This commit is contained in:
Patrick de Wit 2016-05-03 21:07:33 +02:00 committed by Ted John
parent 2aa73dcbe2
commit 13701660c9
8 changed files with 23 additions and 10 deletions

View File

@ -4111,7 +4111,7 @@ STR_5802 :{SMALLFONT}{BLACK}Stops guests from littering and vomiting
STR_5803 :{SMALLFONT}{BLACK}Rotate selected map element
STR_5804 :Mute sound
STR_5805 :{SMALLFONT}{BLACK}If checked, your server will be added to the{NEWLINE}public server list so everyone can find it
STR_5806 :Toggle windowed mode
STR_5807 :{WINDOW_COLOUR_2}Number of rides: {BLACK}{COMMA16}
STR_5808 :{WINDOW_COLOUR_2}Number of shops and stalls: {BLACK}{COMMA16}
STR_5809 :{WINDOW_COLOUR_2}Number of information kiosks and other facilities: {BLACK}{COMMA16}

View File

@ -1036,6 +1036,7 @@ static const uint16 _defaultShortcutKeys[SHORTCUT_COUNT] = {
SHORTCUT_UNDEFINED, // SHORTCUT_SHOW_OPTIONS
SHORTCUT_UNDEFINED, // SHORTCUT_MUTE_SOUND
ALT | SDL_SCANCODE_RETURN // SHORTCUT_WINDOWED_MODE_TOGGLE
};
#define SHORTCUT_FILE_VERSION 1

View File

@ -80,6 +80,7 @@ enum {
SHORTCUT_QUICK_SAVE_GAME,
SHORTCUT_SHOW_OPTIONS,
SHORTCUT_MUTE_SOUND,
SHORTCUT_WINDOWED_MODE_TOGGLE,
SHORTCUT_COUNT
};

View File

@ -30,6 +30,7 @@
#include "window.h"
#include "widget.h"
#include "../audio/audio.h"
#include "../platform/platform.h"
typedef void (*shortcut_action)();
@ -535,6 +536,11 @@ static void shortcut_mute_sound()
audio_toggle_all_sounds();
}
static void shortcut_windowed_mode_toggle()
{
platform_toggle_windowed_mode();
}
static const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
shortcut_close_top_most_window,
shortcut_close_all_floating_windows,
@ -582,7 +588,8 @@ static const shortcut_action shortcut_table[SHORTCUT_COUNT] = {
shortcut_open_chat_window,
shortcut_quick_save_game,
shortcut_show_options,
shortcut_mute_sound
shortcut_mute_sound,
shortcut_windowed_mode_toggle
};
#pragma endregion

View File

@ -2445,6 +2445,7 @@ enum {
STR_ADVERTISE_SERVER_TIP = 5805,
STR_SHORTCUT_WINDOWED_MODE_TOGGLE = 5806,
STR_NUMBER_RIDES = 5807,
STR_NUMBER_SHOPS_AND_STALLS = 5808,
STR_NUMBER_RESTROOMS_AND_INFORMATION_KIOSKS = 5809,

View File

@ -130,6 +130,7 @@ void platform_free();
void platform_trigger_resize();
void platform_update_palette(const uint8 *colours, int start_index, int num_colours);
void platform_set_fullscreen_mode(int mode);
void platform_toggle_windowed_mode();
void platform_set_cursor(uint8 cursor);
void platform_refresh_video();
void platform_process_messages();

View File

@ -583,13 +583,6 @@ void platform_process_messages()
gLastKeyPressed = e.key.keysym.sym;
gKeysPressed[e.key.keysym.scancode] = 1;
if (e.key.keysym.sym == SDLK_RETURN && e.key.keysym.mod & KMOD_ALT) {
int targetMode = gConfigGeneral.fullscreen_mode == 0 ? 2 : 0;
platform_set_fullscreen_mode(targetMode);
gConfigGeneral.fullscreen_mode = targetMode;
config_save_default();
break;
}
// Text input
if (gTextInput.buffer == NULL) break;
@ -865,6 +858,14 @@ void platform_set_fullscreen_mode(int mode)
}
}
void platform_toggle_windowed_mode()
{
int targetMode = gConfigGeneral.fullscreen_mode == 0 ? 2 : 0;
platform_set_fullscreen_mode(targetMode);
gConfigGeneral.fullscreen_mode = targetMode;
config_save_default();
}
/**
* This is not quite the same as the below function as we don't want to
* derfererence the cursor before the function.

View File

@ -133,7 +133,8 @@ const rct_string_id ShortcutStringIds[] = {
STR_SEND_MESSAGE,
STR_SHORTCUT_QUICK_SAVE_GAME,
STR_SHORTCUT_SHOW_OPTIONS,
STR_SHORTCUT_MUTE_SOUND
STR_SHORTCUT_MUTE_SOUND,
STR_SHORTCUT_WINDOWED_MODE_TOGGLE
};
/**