diff --git a/src/config.h b/src/config.h index 3d05e9fe..e556b71f 100644 --- a/src/config.h +++ b/src/config.h @@ -18,6 +18,11 @@ typedef struct Config { extern Config tconfig; +/* + * IMPORTANT: When adding new controls, ALWAYS add them RIGHT AFTER the last KEY_* constant. + * Not doing so will likely break replays! And don't forget to update CONFIG_KEY_LAST below. + */ + enum { KEY_UP = 0, KEY_DOWN, @@ -29,6 +34,7 @@ enum { KEY_FULLSCREEN, KEY_SCREENSHOT, + KEY_SKIP, FULLSCREEN, @@ -50,7 +56,8 @@ void parse_config(char *filename); void config_preset(); #define CONFIG_KEY_FIRST KEY_UP -#define CONFIG_KEY_LAST KEY_SCREENSHOT +#define CONFIG_KEY_LAST KEY_SKIP + int config_sym2key(int sym); #endif diff --git a/src/config.l b/src/config.l index c574efb4..e2ed4c35 100644 --- a/src/config.l +++ b/src/config.l @@ -31,6 +31,7 @@ "key_fullscreen" { yylval = KEY_FULLSCREEN; return tKEY_FULLSCREEN; } "key_screenshot" { yylval = KEY_SCREENSHOT; return tKEY_SCREENSHOT; } +"key_skip" { yylval = KEY_SKIP; return tKEY_SKIP; } "fullscreen" { yylval = FULLSCREEN; return tFULLSCREEN; } diff --git a/src/config.y b/src/config.y index 6a2db380..711b79c4 100644 --- a/src/config.y +++ b/src/config.y @@ -43,6 +43,7 @@ %token tKEY_FULLSCREEN %token tKEY_SCREENSHOT +%token tKEY_SKIP %token tFULLSCREEN @@ -100,6 +101,7 @@ key_key : tKEY_UP | tKEY_BOMB | tKEY_FULLSCREEN | tKEY_SCREENSHOT + | tKEY_SKIP | tNO_SHADER | tNO_AUDIO | tFULLSCREEN @@ -155,6 +157,7 @@ void config_preset() { tconfig.intval[KEY_FULLSCREEN] = SDLK_F11; tconfig.intval[KEY_SCREENSHOT] = SDLK_p; + tconfig.intval[KEY_SKIP] = SDLK_LCTRL; tconfig.intval[FULLSCREEN] = 0; diff --git a/src/dialog.h b/src/dialog.h index 67d8963c..ec360085 100644 --- a/src/dialog.h +++ b/src/dialog.h @@ -33,6 +33,7 @@ typedef struct Dialog { int page_time; int birthtime; + int skip; } Dialog; Dialog *create_dialog(char *left, char *right); @@ -43,4 +44,4 @@ void delete_dialog(Dialog *d); void draw_dialog(Dialog *dialog); void page_dialog(Dialog **d); -#endif \ No newline at end of file +#endif diff --git a/src/menu/options.c b/src/menu/options.c index c7b696f8..2bb0e88b 100644 --- a/src/menu/options.c +++ b/src/menu/options.c @@ -492,7 +492,10 @@ void create_options_menu(MenuData *m) { add_menu_entry(m, "Take a screenshot", do_nothing, NULL); bind_keybinding(m, "key_screenshot", KEY_SCREENSHOT); - + + add_menu_entry(m, "Skip dialog", do_nothing, NULL); + bind_keybinding(m, "key_skip", KEY_SKIP); + add_menu_separator(m); allocate_binding(m); diff --git a/src/menu/replayview.c b/src/menu/replayview.c index a162ae8c..b526c0d9 100755 --- a/src/menu/replayview.c +++ b/src/menu/replayview.c @@ -77,11 +77,9 @@ static void replayview_drawitem(void *n, int item, int cnt) { switch(i) { case 0: a = AL_Left; - time_t t = rpy->seed; struct tm* timeinfo = localtime(&t); strftime(tmp, 128, "%Y-%m-%d %H:%M", timeinfo); - break; case 1: diff --git a/src/stage.c b/src/stage.c index 71bf5f27..958e0b35 100644 --- a/src/stage.c +++ b/src/stage.c @@ -96,6 +96,8 @@ void replay_input() { default: if(global.dialog && e->type == EV_PRESS && (e->key == KEY_SHOT || e->key == KEY_BOMB)) page_dialog(&global.dialog); + else if(global.dialog && e->key == KEY_SKIP) + global.dialog->skip = (e->type == EV_PRESS); else player_event(&global.plr, e->type, e->key); break; @@ -128,6 +130,9 @@ void stage_input() { } else { player_event(&global.plr, EV_PRESS, key); replay_event(&global.replay, EV_PRESS, key); + + if(key == KEY_SKIP && global.dialog) + global.dialog->skip = True; } break; @@ -135,6 +140,9 @@ void stage_input() { case SDL_KEYUP: player_event(&global.plr,EV_RELEASE, key); replay_event(&global.replay, EV_RELEASE, key); + + if(key == KEY_SKIP && global.dialog) + global.dialog->skip = False; break; case SDL_QUIT: @@ -143,6 +151,16 @@ void stage_input() { } } + // workaround + if(global.dialog && global.dialog->skip) { + Uint8 *keys = SDL_GetKeyState(NULL); + + if(!keys[tconfig.intval[KEY_SKIP]]) { + global.dialog->skip = False; + replay_event(&global.replay, EV_RELEASE, KEY_SKIP); + } + } + if(!global.menu) player_applymovement(&global.plr); } @@ -385,6 +403,9 @@ void stage_logic(int time) { boss_death(&global.boss); } + if(global.dialog && global.dialog->skip && global.frames - global.dialog->page_time > 3) + page_dialog(&global.dialog); + global.frames++; if(!global.dialog && !global.boss) @@ -392,7 +413,6 @@ void stage_logic(int time) { if(global.timer >= time) global.game_over = GAMEOVER_WIN; - } void stage_end() {