integrated transitions
This commit is contained in:
parent
1416a40451
commit
a7685eb6e1
14 changed files with 71 additions and 40 deletions
|
@ -213,8 +213,7 @@ void credits_draw(void) {
|
|||
credits_draw_entry(&(credits.entries[i]));
|
||||
glPopMatrix();
|
||||
|
||||
colorfill(1, 1, 1, 1 - (global.frames / 300.0));
|
||||
colorfill(1, 1, 1, credits.fadeout);
|
||||
draw_transition();
|
||||
}
|
||||
|
||||
void credits_process(void) {
|
||||
|
@ -232,8 +231,8 @@ void credits_process(void) {
|
|||
credits.panelalpha -= 1 / 120.0;
|
||||
}
|
||||
|
||||
if(global.frames >= credits.end) {
|
||||
credits.fadeout += 1 / 120.0;
|
||||
if(global.frames == credits.end) {
|
||||
set_transition(TransFadeWhite, CREDITS_FADEOUT, CREDITS_FADEOUT);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,7 +256,7 @@ void credits_free(void) {
|
|||
|
||||
void credits_loop(void) {
|
||||
credits_init();
|
||||
while(credits.fadeout <= 1) {
|
||||
while(global.frames <= credits.end + CREDITS_FADEOUT) {
|
||||
credits_input();
|
||||
credits_process();
|
||||
credits_draw();
|
||||
|
|
|
@ -17,4 +17,6 @@ void credits_add(char*, int);
|
|||
#define CREDITS_ENTRY_FADEOUT 100.0
|
||||
#define CREDITS_YUKKURI_SCALE 0.5
|
||||
|
||||
#define CREDITS_FADEOUT 120
|
||||
|
||||
#endif
|
||||
|
|
10
src/ending.c
10
src/ending.c
|
@ -117,10 +117,7 @@ void ending_draw(Ending *e) {
|
|||
draw_text(AL_Center, SCREEN_W/2, SCREEN_H/5*4, e->entries[e->pos].msg, _fonts.standard);
|
||||
glColor4f(1,1,1,1);
|
||||
|
||||
if(global.frames > - e->entries[e->count-1].time-ENDING_FADE_OUT)
|
||||
colorfill(1, 1, 1, (global.frames - e->entries[e->count-1].time + ENDING_FADE_OUT)/(float)ENDING_FADE_OUT);
|
||||
|
||||
// colorfill(1, 1, 1, 1);
|
||||
draw_transition();
|
||||
}
|
||||
|
||||
void ending_loop(void) {
|
||||
|
@ -129,7 +126,7 @@ void ending_loop(void) {
|
|||
|
||||
global.frames = 0;
|
||||
set_ortho();
|
||||
|
||||
|
||||
while(e.pos < e.count-1) {
|
||||
credits_input();
|
||||
|
||||
|
@ -140,5 +137,8 @@ void ending_loop(void) {
|
|||
|
||||
if(global.frames >= e.entries[e.pos+1].time)
|
||||
e.pos++;
|
||||
|
||||
if(global.frames == e.entries[e.count-1].time-ENDING_FADE_OUT)
|
||||
set_transition(TransFadeWhite, ENDING_FADE_OUT, ENDING_FADE_OUT);
|
||||
}
|
||||
}
|
|
@ -34,13 +34,14 @@ void create_gameover_menu(MenuData *m) {
|
|||
create_menu(m);
|
||||
|
||||
m->flags = MF_Transient;
|
||||
m->transition = NULL;
|
||||
m->context = "Game Over";
|
||||
|
||||
char s[64];
|
||||
int c = MAX_CONTINUES - global.plr.continues;
|
||||
snprintf(s, sizeof(s), "Continue (%i)", c);
|
||||
add_menu_entry(m, s, c? continue_game : NULL, NULL);
|
||||
add_menu_entry(m, c? "Give up" : "Return to Title", give_up, NULL);
|
||||
add_menu_entry(m, c? "Give up" : "Return to Title", give_up, NULL)->transition = TransFadeBlack;
|
||||
|
||||
if(!c)
|
||||
m->cursor = 1;
|
||||
|
|
|
@ -20,8 +20,9 @@ void return_to_title(void *arg) {
|
|||
void create_ingame_menu(MenuData *m) {
|
||||
create_menu(m);
|
||||
m->flags = MF_Abortable | MF_Transient;
|
||||
m->transition = NULL;
|
||||
add_menu_entry(m, "Return to Game", return_to_game, NULL);
|
||||
add_menu_entry(m, "Return to Title", return_to_title, NULL);
|
||||
add_menu_entry(m, "Return to Title", return_to_title, NULL)->transition = TransFadeBlack;
|
||||
}
|
||||
|
||||
void draw_ingame_menu_bg(float f) {
|
||||
|
|
|
@ -155,5 +155,6 @@ void draw_main_menu(MenuData *menu) {
|
|||
}
|
||||
|
||||
void main_menu_loop(MenuData *menu) {
|
||||
set_transition(TransFadeBlack, -1, FADE_TIME);
|
||||
menu_loop(menu, NULL, draw_main_menu, NULL);
|
||||
}
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
#include "menu.h"
|
||||
#include "global.h"
|
||||
|
||||
void add_menu_entry(MenuData *menu, char *name, MenuAction action, void *arg) {
|
||||
add_menu_entry_f(menu, name, action, arg, 0);
|
||||
MenuEntry *add_menu_entry(MenuData *menu, char *name, MenuAction action, void *arg) {
|
||||
return add_menu_entry_f(menu, name, action, arg, 0);
|
||||
}
|
||||
|
||||
void add_menu_entry_f(MenuData *menu, char *name, MenuAction action, void *arg, int flags) {
|
||||
MenuEntry *add_menu_entry_f(MenuData *menu, char *name, MenuAction action, void *arg, int flags) {
|
||||
menu->entries = realloc(menu->entries, (++menu->ecount)*sizeof(MenuEntry));
|
||||
MenuEntry *e = &(menu->entries[menu->ecount-1]);
|
||||
memset(e, 0, sizeof(MenuEntry));
|
||||
|
@ -22,6 +22,8 @@ void add_menu_entry_f(MenuData *menu, char *name, MenuAction action, void *arg,
|
|||
e->action = action;
|
||||
e->arg = arg;
|
||||
e->flags = flags;
|
||||
e->transition = menu->transition;
|
||||
return e;
|
||||
}
|
||||
|
||||
void add_menu_separator(MenuData *menu) {
|
||||
|
@ -46,13 +48,21 @@ void create_menu(MenuData *menu) {
|
|||
|
||||
menu->selected = -1;
|
||||
menu->quitdelay = FADE_TIME;
|
||||
menu->transition = TransFadeBlack;
|
||||
}
|
||||
|
||||
void close_menu(MenuData *menu) {
|
||||
TransitionRule trans = menu->transition;
|
||||
|
||||
if(menu->selected != -1)
|
||||
trans = menu->entries[menu->selected].transition;
|
||||
|
||||
set_transition(trans, menu->quitdelay, menu->quitdelay);
|
||||
|
||||
menu->quitframe = menu->frames;
|
||||
}
|
||||
|
||||
void close_menu(MenuData *menu) {
|
||||
menu->quitframe = menu->frames;
|
||||
}
|
||||
|
||||
void kill_menu(MenuData *menu) {
|
||||
void kill_menu(MenuData *menu) {
|
||||
menu->state = MS_Dead;
|
||||
}
|
||||
|
||||
|
@ -133,6 +143,9 @@ int menu_loop(MenuData *menu, void (*input)(MenuData*), void (*draw)(MenuData*),
|
|||
}
|
||||
|
||||
draw(menu);
|
||||
if(!(menu->flags & MF_ManualDrawTransition))
|
||||
draw_transition();
|
||||
|
||||
SDL_GL_SwapBuffers();
|
||||
frame_rate(&menu->lasttime);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#ifndef MENU_H
|
||||
#define MENU_H
|
||||
|
||||
#include "transition.h"
|
||||
|
||||
#define IMENU_BLUR 0.05
|
||||
#define TS_KR_DELAY SDL_DEFAULT_REPEAT_DELAY
|
||||
#define TS_KR_INTERVAL (SDL_DEFAULT_REPEAT_INTERVAL*2)
|
||||
|
@ -25,15 +27,21 @@ typedef struct {
|
|||
|
||||
int flags;
|
||||
|
||||
float drawdata;
|
||||
float drawdata;
|
||||
TransitionRule transition;
|
||||
} MenuEntry;
|
||||
|
||||
typedef enum MenuFlag {
|
||||
// enum EntryFlag {
|
||||
// MF_InstantSelect = 4
|
||||
// };
|
||||
|
||||
enum MenuFlag {
|
||||
MF_Transient = 1, // whether to close on selection or not.
|
||||
MF_Abortable = 2,
|
||||
|
||||
MF_InstantSelect = 4
|
||||
} MenuType;
|
||||
MF_InstantSelect = 4,
|
||||
MF_ManualDrawTransition = 8, // the menu will not call draw_transition() automatically
|
||||
};
|
||||
|
||||
enum MenuState{
|
||||
MS_Normal = 0,
|
||||
|
@ -57,13 +65,15 @@ typedef struct MenuData{
|
|||
int quitframe;
|
||||
int quitdelay;
|
||||
|
||||
TransitionRule transition;
|
||||
|
||||
float drawdata[4];
|
||||
|
||||
void *context;
|
||||
} MenuData;
|
||||
|
||||
void add_menu_entry(MenuData *menu, char *name, MenuAction action, void *arg);
|
||||
void add_menu_entry_f(MenuData *menu, char *name, MenuAction action, void *arg, int flags);
|
||||
MenuEntry *add_menu_entry(MenuData *menu, char *name, MenuAction action, void *arg);
|
||||
MenuEntry *add_menu_entry_f(MenuData *menu, char *name, MenuAction action, void *arg, int flags);
|
||||
|
||||
void add_menu_separator(MenuData *menu);
|
||||
void create_menu(MenuData *menu);
|
||||
|
|
|
@ -577,8 +577,7 @@ void draw_options_menu(MenuData *menu) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
|
|
@ -63,9 +63,10 @@ MenuData* replayview_stageselect(Replay *rpy) {
|
|||
create_menu(m);
|
||||
m->context = rpy;
|
||||
m->flags = MF_Transient | MF_Abortable;
|
||||
|
||||
m->transition = 0;
|
||||
|
||||
for(i = 0; i < rpy->stgcount; ++i) {
|
||||
add_menu_entry(m, stage_get(rpy->stages[i].stage)->title, start_replay, rpy);
|
||||
add_menu_entry(m, stage_get(rpy->stages[i].stage)->title, start_replay, rpy)->transition = TransFadeBlack;
|
||||
}
|
||||
|
||||
return m;
|
||||
|
@ -220,6 +221,7 @@ static void replayview_draw(MenuData *m) {
|
|||
replayview_draw_stagemenu(sm);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -250,7 +252,7 @@ int fill_replayview_menu(MenuData *m) {
|
|||
continue;
|
||||
}
|
||||
|
||||
add_menu_entry_f(m, " ", replayview_run, rpy, (rpy->stgcount > 1)*MF_InstantSelect);
|
||||
add_menu_entry_f(m, " ", replayview_run, rpy, (rpy->stgcount > 1)*MF_InstantSelect)->transition = rpy->stgcount < 1 ? TransFadeBlack : NULL;
|
||||
++rpys;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ void create_saverpy_menu(MenuData *m) {
|
|||
m->flags = MF_Transient;
|
||||
|
||||
add_menu_entry(m, "Yes", save_rpy, m);
|
||||
add_menu_entry(m, "No", (MenuAction) close_menu, m);
|
||||
add_menu_entry(m, "No", (MenuAction) kill_menu, m);
|
||||
}
|
||||
|
||||
void draw_saverpy_menu(MenuData *m) {
|
||||
|
|
|
@ -289,6 +289,7 @@ void stage_draw(StageInfo *info, StageRule bgdraw, ShaderRule *shaderrules, int
|
|||
glPopMatrix();
|
||||
|
||||
draw_hud();
|
||||
draw_transition();
|
||||
}
|
||||
|
||||
int apply_shaderrules(ShaderRule *shaderrules, int fbonum) {
|
||||
|
@ -399,6 +400,9 @@ void stage_logic(int time) {
|
|||
if(!global.dialog && !global.boss)
|
||||
global.timer++;
|
||||
|
||||
if(global.timer == time - FADE_TIME)
|
||||
set_transition(TransFadeBlack, FADE_TIME, FADE_TIME*2);
|
||||
|
||||
if(global.timer >= time)
|
||||
global.game_over = GAMEOVER_WIN;
|
||||
}
|
||||
|
|
|
@ -26,11 +26,10 @@ void TransFadeWhite(Transition *t) {
|
|||
colorfill(1,1,1,trans_fade(t));
|
||||
}
|
||||
|
||||
void TransIngame(Transition *t) {
|
||||
draw_ingame_menu_bg(trans_fade(t));
|
||||
}
|
||||
|
||||
void set_transition(TransitionRule rule, int dur1, int dur2) {
|
||||
if(!rule)
|
||||
return;
|
||||
|
||||
memset(&transition, 0, sizeof(Transition));
|
||||
transition.rule = rule;
|
||||
transition.dur1 = dur1;
|
||||
|
@ -38,8 +37,10 @@ void set_transition(TransitionRule rule, int dur1, int dur2) {
|
|||
}
|
||||
|
||||
void draw_transition(void) {
|
||||
if(transition.rule)
|
||||
transition.rule(&transition);
|
||||
if(!transition.rule)
|
||||
return;
|
||||
|
||||
transition.rule(&transition);
|
||||
|
||||
transition.frames++;
|
||||
|
||||
|
|
|
@ -22,8 +22,6 @@ struct Transition {
|
|||
void TransFadeBlack(Transition *t);
|
||||
void TransFadeWhite(Transition *t);
|
||||
|
||||
void TransIngame(Transition *t);
|
||||
|
||||
void set_transition(TransitionRule rule, int dur1, int dur2);
|
||||
void draw_transition(void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue