Added a skip-dialog key, like in Touhou (default: left ctrl)
This commit is contained in:
parent
a67f526c7c
commit
c5487c3187
7 changed files with 39 additions and 6 deletions
|
@ -18,6 +18,11 @@ typedef struct Config {
|
|||
|
||||
extern Config tconfig;
|
||||
|
||||
/*
|
||||
* <Akari> 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
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
#endif
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
22
src/stage.c
22
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() {
|
||||
|
|
Loading…
Reference in a new issue