From d442dd6ca65b694c37fbd3c93505644fe8478263 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 10 Mar 2010 22:27:23 +0100 Subject: [PATCH] rnd-20100310-1-src * added configurable key shortcuts for the tape recorder buttons --- ChangeLog | 3 ++ src/conf_gfx.c | 4 +++ src/conf_var.c | 16 +++++++++ src/conftime.h | 2 +- src/editor.c | 4 ++- src/events.c | 2 ++ src/files.c | 18 +++++++++- src/libgame/system.h | 11 ++++++ src/main.h | 14 ++++---- src/screens.c | 86 +++++++++++++++++++++++++++++++++++--------- src/tape.c | 25 +++++++++++-- src/tape.h | 2 ++ 12 files changed, 159 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index 96a007d5..60f21939 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2010-03-10 + * added configurable key shortcuts for the tape recorder buttons + 2010-03-09 * added (hidden) function to save native Supaplex levels with tape as native *.sp file containing level with demo (saved with a file name diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 28fbd129..fdb49e30 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5407,10 +5407,14 @@ struct ConfigInfo image_config[] = { "menu.draw_yoffset.SETUP[ARTWORK]", "0" }, { "menu.draw_xoffset.SETUP[INPUT]", "0" }, { "menu.draw_yoffset.SETUP[INPUT]", "0" }, + { "menu.draw_xoffset.SETUP[SHORTCUTS]", "0" }, + { "menu.draw_yoffset.SETUP[SHORTCUTS]", "0" }, { "menu.draw_xoffset.SETUP[SHORTCUTS_1]", "0" }, { "menu.draw_yoffset.SETUP[SHORTCUTS_1]", "0" }, { "menu.draw_xoffset.SETUP[SHORTCUTS_2]", "0" }, { "menu.draw_yoffset.SETUP[SHORTCUTS_2]", "0" }, + { "menu.draw_xoffset.SETUP[SHORTCUTS_3]", "0" }, + { "menu.draw_yoffset.SETUP[SHORTCUTS_3]", "0" }, { "menu.draw_xoffset.SETUP[CHOOSE_ARTWORK]", "0" }, { "menu.draw_yoffset.SETUP[CHOOSE_ARTWORK]", "0" }, { "menu.draw_xoffset.SETUP[CHOOSE_OTHER]", "0" }, diff --git a/src/conf_var.c b/src/conf_var.c index a965464d..90ed0b13 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -1288,6 +1288,14 @@ struct TokenIntPtrInfo image_config_vars[] = "menu.draw_yoffset.SETUP[INPUT]", &menu.draw_yoffset_setup[GFX_SPECIAL_ARG_SETUP_INPUT] }, + { + "menu.draw_xoffset.SETUP[SHORTCUTS]", + &menu.draw_xoffset_setup[GFX_SPECIAL_ARG_SETUP_SHORTCUTS] + }, + { + "menu.draw_yoffset.SETUP[SHORTCUTS]", + &menu.draw_yoffset_setup[GFX_SPECIAL_ARG_SETUP_SHORTCUTS] + }, { "menu.draw_xoffset.SETUP[SHORTCUTS_1]", &menu.draw_xoffset_setup[GFX_SPECIAL_ARG_SETUP_SHORTCUTS_1] @@ -1304,6 +1312,14 @@ struct TokenIntPtrInfo image_config_vars[] = "menu.draw_yoffset.SETUP[SHORTCUTS_2]", &menu.draw_yoffset_setup[GFX_SPECIAL_ARG_SETUP_SHORTCUTS_2] }, + { + "menu.draw_xoffset.SETUP[SHORTCUTS_3]", + &menu.draw_xoffset_setup[GFX_SPECIAL_ARG_SETUP_SHORTCUTS_3] + }, + { + "menu.draw_yoffset.SETUP[SHORTCUTS_3]", + &menu.draw_yoffset_setup[GFX_SPECIAL_ARG_SETUP_SHORTCUTS_3] + }, { "menu.draw_xoffset.SETUP[CHOOSE_ARTWORK]", &menu.draw_xoffset_setup[GFX_SPECIAL_ARG_SETUP_CHOOSE_ARTWORK] diff --git a/src/conftime.h b/src/conftime.h index 0a5f2859..6467aafc 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2010-03-09 23:35" +#define COMPILE_DATE_STRING "2010-03-10 14:11" diff --git a/src/editor.c b/src/editor.c index bbc863ca..9d5c42d2 100644 --- a/src/editor.c +++ b/src/editor.c @@ -11649,7 +11649,9 @@ void HandleLevelEditorKeyInput(Key key) ClickOnGadget(level_editor_gadget[id], button); else if (letter == '.') ClickOnGadget(level_editor_gadget[GADGET_ID_SINGLE_ITEMS], button); - else if (key == KSYM_Return || key == setup.shortcut.toggle_pause) + else if (key == KSYM_Return || + key == KSYM_space || + key == setup.shortcut.toggle_pause) ClickOnGadget(level_editor_gadget[GADGET_ID_TEST], button); else for (i = 0; i < ED_NUM_CTRL_BUTTONS; i++) diff --git a/src/events.c b/src/events.c index 2d9cbfcd..b9b5b862 100644 --- a/src/events.c +++ b/src/events.c @@ -762,6 +762,8 @@ void HandleKey(Key key, int key_status) TapeQuickLoad(); else if (key == setup.shortcut.toggle_pause) TapeTogglePause(TAPE_TOGGLE_MANUAL); + + HandleTapeButtonKeys(key); } if (game_status == GAME_MODE_PLAYING && !network_playing) diff --git a/src/files.c b/src/files.c index 124b1db0..205c371a 100644 --- a/src/files.c +++ b/src/files.c @@ -9003,8 +9003,13 @@ void SaveScore(int nr) #define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_3 5 #define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_4 6 #define SETUP_TOKEN_SHORTCUT_FOCUS_PLAYER_ALL 7 +#define SETUP_TOKEN_SHORTCUT_TAPE_EJECT 8 +#define SETUP_TOKEN_SHORTCUT_TAPE_STOP 9 +#define SETUP_TOKEN_SHORTCUT_TAPE_PAUSE 10 +#define SETUP_TOKEN_SHORTCUT_TAPE_RECORD 11 +#define SETUP_TOKEN_SHORTCUT_TAPE_PLAY 12 -#define NUM_SHORTCUT_SETUP_TOKENS 8 +#define NUM_SHORTCUT_SETUP_TOKENS 13 /* player setup */ #define SETUP_TOKEN_PLAYER_USE_JOYSTICK 0 @@ -9149,6 +9154,11 @@ static struct TokenInfo shortcut_setup_tokens[] = { TYPE_KEY_X11, &ssi.focus_player[2], "shortcut.focus_player_3" }, { TYPE_KEY_X11, &ssi.focus_player[3], "shortcut.focus_player_4" }, { TYPE_KEY_X11, &ssi.focus_player_all,"shortcut.focus_player_all" }, + { TYPE_KEY_X11, &ssi.tape_eject, "shortcut.tape_eject" }, + { TYPE_KEY_X11, &ssi.tape_stop, "shortcut.tape_stop" }, + { TYPE_KEY_X11, &ssi.tape_pause, "shortcut.tape_pause" }, + { TYPE_KEY_X11, &ssi.tape_record, "shortcut.tape_record" }, + { TYPE_KEY_X11, &ssi.tape_play, "shortcut.tape_play" }, }; static struct TokenInfo player_setup_tokens[] = @@ -9265,6 +9275,12 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->shortcut.focus_player[3] = DEFAULT_KEY_FOCUS_PLAYER_4; si->shortcut.focus_player_all = DEFAULT_KEY_FOCUS_PLAYER_ALL; + si->shortcut.tape_eject = DEFAULT_KEY_TAPE_EJECT; + si->shortcut.tape_stop = DEFAULT_KEY_TAPE_STOP; + si->shortcut.tape_pause = DEFAULT_KEY_TAPE_PAUSE; + si->shortcut.tape_record = DEFAULT_KEY_TAPE_RECORD; + si->shortcut.tape_play = DEFAULT_KEY_TAPE_PLAY; + for (i = 0; i < MAX_PLAYERS; i++) { si->input[i].use_joystick = FALSE; diff --git a/src/libgame/system.h b/src/libgame/system.h index 26d192e3..aeab9c23 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -72,6 +72,11 @@ #define DEFAULT_KEY_FOCUS_PLAYER_3 KSYM_F7 #define DEFAULT_KEY_FOCUS_PLAYER_4 KSYM_F8 #define DEFAULT_KEY_FOCUS_PLAYER_ALL KSYM_F9 +#define DEFAULT_KEY_TAPE_EJECT KSYM_UNDEFINED +#define DEFAULT_KEY_TAPE_STOP KSYM_UNDEFINED +#define DEFAULT_KEY_TAPE_PAUSE KSYM_UNDEFINED +#define DEFAULT_KEY_TAPE_RECORD KSYM_UNDEFINED +#define DEFAULT_KEY_TAPE_PLAY KSYM_UNDEFINED /* values for key_status */ #define KEY_NOT_PRESSED FALSE @@ -834,6 +839,12 @@ struct SetupShortcutInfo Key focus_player[MAX_PLAYERS]; Key focus_player_all; + + Key tape_eject; + Key tape_stop; + Key tape_pause; + Key tape_record; + Key tape_play; }; struct SetupSystemInfo diff --git a/src/main.h b/src/main.h index 9376b3ae..56ecbd16 100644 --- a/src/main.h +++ b/src/main.h @@ -1848,12 +1848,14 @@ #define GFX_SPECIAL_ARG_SETUP_SOUND 4 #define GFX_SPECIAL_ARG_SETUP_ARTWORK 5 #define GFX_SPECIAL_ARG_SETUP_INPUT 6 -#define GFX_SPECIAL_ARG_SETUP_SHORTCUTS_1 7 -#define GFX_SPECIAL_ARG_SETUP_SHORTCUTS_2 8 -#define GFX_SPECIAL_ARG_SETUP_CHOOSE_ARTWORK 9 -#define GFX_SPECIAL_ARG_SETUP_CHOOSE_OTHER 10 - -#define NUM_SPECIAL_GFX_SETUP_ARGS 11 +#define GFX_SPECIAL_ARG_SETUP_SHORTCUTS 7 +#define GFX_SPECIAL_ARG_SETUP_SHORTCUTS_1 8 +#define GFX_SPECIAL_ARG_SETUP_SHORTCUTS_2 9 +#define GFX_SPECIAL_ARG_SETUP_SHORTCUTS_3 10 +#define GFX_SPECIAL_ARG_SETUP_CHOOSE_ARTWORK 11 +#define GFX_SPECIAL_ARG_SETUP_CHOOSE_OTHER 12 + +#define NUM_SPECIAL_GFX_SETUP_ARGS 13 /* values for image configuration suffixes */ diff --git a/src/screens.c b/src/screens.c index 34eec746..74690d7f 100644 --- a/src/screens.c +++ b/src/screens.c @@ -45,22 +45,24 @@ #define SETUP_MODE_SOUND 4 #define SETUP_MODE_ARTWORK 5 #define SETUP_MODE_INPUT 6 -#define SETUP_MODE_SHORTCUTS_1 7 -#define SETUP_MODE_SHORTCUTS_2 8 +#define SETUP_MODE_SHORTCUTS 7 +#define SETUP_MODE_SHORTCUTS_1 8 +#define SETUP_MODE_SHORTCUTS_2 9 +#define SETUP_MODE_SHORTCUTS_3 10 /* sub-screens on the setup screen (generic) */ -#define SETUP_MODE_CHOOSE_ARTWORK 9 -#define SETUP_MODE_CHOOSE_OTHER 10 +#define SETUP_MODE_CHOOSE_ARTWORK 11 +#define SETUP_MODE_CHOOSE_OTHER 12 /* sub-screens on the setup screen (specific) */ -#define SETUP_MODE_CHOOSE_GAME_SPEED 11 -#define SETUP_MODE_CHOOSE_SCREEN_MODE 12 -#define SETUP_MODE_CHOOSE_SCROLL_DELAY 13 -#define SETUP_MODE_CHOOSE_GRAPHICS 14 -#define SETUP_MODE_CHOOSE_SOUNDS 15 -#define SETUP_MODE_CHOOSE_MUSIC 16 +#define SETUP_MODE_CHOOSE_GAME_SPEED 13 +#define SETUP_MODE_CHOOSE_SCREEN_MODE 14 +#define SETUP_MODE_CHOOSE_SCROLL_DELAY 15 +#define SETUP_MODE_CHOOSE_GRAPHICS 16 +#define SETUP_MODE_CHOOSE_SOUNDS 17 +#define SETUP_MODE_CHOOSE_MUSIC 18 -#define MAX_SETUP_MODES 17 +#define MAX_SETUP_MODES 19 /* for input setup functions */ #define SETUPINPUT_SCREEN_POS_START 0 @@ -232,7 +234,7 @@ static struct INFO_MODE_MAIN) #define DRAW_MODE_SETUP(i) ((i) >= SETUP_MODE_MAIN && \ - (i) <= SETUP_MODE_SHORTCUTS_2 ? (i) : \ + (i) <= SETUP_MODE_SHORTCUTS_3 ? (i) : \ (i) >= SETUP_MODE_CHOOSE_GRAPHICS && \ (i) <= SETUP_MODE_CHOOSE_MUSIC ? \ SETUP_MODE_CHOOSE_ARTWORK : \ @@ -4081,6 +4083,13 @@ static void execSetupInput() DrawSetupScreen(); } +static void execSetupShortcuts() +{ + setup_mode = SETUP_MODE_SHORTCUTS; + + DrawSetupScreen(); +} + static void execSetupShortcuts1() { setup_mode = SETUP_MODE_SHORTCUTS_1; @@ -4095,6 +4104,13 @@ static void execSetupShortcuts2() DrawSetupScreen(); } +static void execSetupShortcuts3() +{ + setup_mode = SETUP_MODE_SHORTCUTS_3; + + DrawSetupScreen(); +} + static void execExitSetup() { game_status = GAME_MODE_MAIN; @@ -4116,8 +4132,7 @@ static struct TokenInfo setup_info_main[] = { TYPE_ENTER_MENU, execSetupSound, "Sound & Music" }, { TYPE_ENTER_MENU, execSetupArtwork, "Custom Artwork" }, { TYPE_ENTER_MENU, execSetupInput, "Input Devices" }, - { TYPE_ENTER_MENU, execSetupShortcuts1, "Key Shortcuts 1" }, - { TYPE_ENTER_MENU, execSetupShortcuts2, "Key Shortcuts 2" }, + { TYPE_ENTER_MENU, execSetupShortcuts, "Key Shortcuts" }, { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execExitSetup, "Exit" }, { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and Exit" }, @@ -4263,6 +4278,17 @@ static struct TokenInfo setup_info_input[] = { 0, NULL, NULL } }; +static struct TokenInfo setup_info_shortcuts[] = +{ + { TYPE_ENTER_MENU, execSetupShortcuts1, "Various Keys" }, + { TYPE_ENTER_MENU, execSetupShortcuts2, "Player Focus" }, + { TYPE_ENTER_MENU, execSetupShortcuts3, "Tape Buttons" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + + { 0, NULL, NULL } +}; + static struct TokenInfo setup_info_shortcuts_1[] = { { TYPE_KEYTEXT, NULL, "Quick Save Game to Tape:", }, @@ -4275,7 +4301,7 @@ static struct TokenInfo setup_info_shortcuts_1[] = { TYPE_YES_NO, &setup.ask_on_escape, "Ask on 'Esc' Key:" }, { TYPE_YES_NO, &setup.ask_on_escape_editor, "Ask on 'Esc' Key (Editor):" }, { TYPE_EMPTY, NULL, "" }, - { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" }, { 0, NULL, NULL } }; @@ -4293,7 +4319,25 @@ static struct TokenInfo setup_info_shortcuts_2[] = { TYPE_KEYTEXT, NULL, "Set Focus to All Players:", }, { TYPE_KEY, &setup.shortcut.focus_player_all, "" }, { TYPE_EMPTY, NULL, "" }, - { TYPE_LEAVE_MENU, execSetupMain, "Back" }, + { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" }, + + { 0, NULL, NULL } +}; + +static struct TokenInfo setup_info_shortcuts_3[] = +{ + { TYPE_KEYTEXT, NULL, "Tape Eject:", }, + { TYPE_KEY, &setup.shortcut.tape_eject, "" }, + { TYPE_KEYTEXT, NULL, "Tape Stop:", }, + { TYPE_KEY, &setup.shortcut.tape_stop, "" }, + { TYPE_KEYTEXT, NULL, "Tape Pause:", }, + { TYPE_KEY, &setup.shortcut.tape_pause, "" }, + { TYPE_KEYTEXT, NULL, "Tape Record:", }, + { TYPE_KEY, &setup.shortcut.tape_record, "" }, + { TYPE_KEYTEXT, NULL, "Tape Play:", }, + { TYPE_KEY, &setup.shortcut.tape_play, "" }, + { TYPE_EMPTY, NULL, "" }, + { TYPE_LEAVE_MENU, execSetupShortcuts, "Back" }, { 0, NULL, NULL } }; @@ -4576,6 +4620,11 @@ static void DrawSetupScreen_Generic() setup_info = setup_info_artwork; title_string = "Custom Artwork"; } + else if (setup_mode == SETUP_MODE_SHORTCUTS) + { + setup_info = setup_info_shortcuts; + title_string = "Setup Shortcuts"; + } else if (setup_mode == SETUP_MODE_SHORTCUTS_1) { setup_info = setup_info_shortcuts_1; @@ -4586,6 +4635,11 @@ static void DrawSetupScreen_Generic() setup_info = setup_info_shortcuts_2; title_string = "Setup Shortcuts"; } + else if (setup_mode == SETUP_MODE_SHORTCUTS_3) + { + setup_info = setup_info_shortcuts_3; + title_string = "Setup Shortcuts"; + } DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, title_string); diff --git a/src/tape.c b/src/tape.c index 88f0f5a0..9f2a61f3 100644 --- a/src/tape.c +++ b/src/tape.c @@ -1299,10 +1299,8 @@ void UnmapTapeButtons() UnmapGadget(tape_gadget[i]); } -static void HandleTapeButtons(struct GadgetInfo *gi) +static void HandleTapeButtonsExt(int id) { - int id = gi->custom_id; - if (game_status != GAME_MODE_MAIN && game_status != GAME_MODE_PLAYING) return; @@ -1407,3 +1405,24 @@ static void HandleTapeButtons(struct GadgetInfo *gi) break; } } + +static void HandleTapeButtons(struct GadgetInfo *gi) +{ + HandleTapeButtonsExt(gi->custom_id); +} + +void HandleTapeButtonKeys(Key key) +{ + boolean use_extra = (tape.recording || tape.playing); + + if (key == setup.shortcut.tape_eject) + HandleTapeButtonsExt(use_extra ? TAPE_CTRL_ID_EXTRA : TAPE_CTRL_ID_EJECT); + else if (key == setup.shortcut.tape_stop) + HandleTapeButtonsExt(TAPE_CTRL_ID_STOP); + else if (key == setup.shortcut.tape_pause) + HandleTapeButtonsExt(TAPE_CTRL_ID_PAUSE); + else if (key == setup.shortcut.tape_record) + HandleTapeButtonsExt(TAPE_CTRL_ID_RECORD); + else if (key == setup.shortcut.tape_play) + HandleTapeButtonsExt(TAPE_CTRL_ID_PLAY); +} diff --git a/src/tape.h b/src/tape.h index 5243f268..cafa235d 100644 --- a/src/tape.h +++ b/src/tape.h @@ -165,4 +165,6 @@ void MapTapeWarpButton(); void MapTapeButtons(); void UnmapTapeButtons(); +void HandleTapeButtonKeys(Key); + #endif -- 2.34.1