taisei/src/menu/gameovermenu.c
Andrei Alexeyev 173c8c3cc6
replay: general refactor
* Split replay.c into multiple files under replay/; improve logical
  separation of replay-related code.
* Separate replay playback state from data.
* Get rid of global static replay struct and avoid unnecessary replay
  copying.
* Replay playback and recording are now independent and may occur
  simultaneously, although this functionality is not yet exposed. This
  enables replay "re-recording" while synthesizing new desync check
  events, possibly at a different rate from the original replay.
* Rate of recorded desync check events can now be controlled with the
  TAISEI_REPLAY_DESYNC_CHECK_FREQUENCY environment variable. The default
  value is 300 as before.
* Probably other stuff I forgot about.
2021-06-16 01:43:10 +03:00

55 lines
1.6 KiB
C

/*
* This software is licensed under the terms of the MIT License.
* See COPYING for further information.
* ---
* Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
* Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
*/
#include "taisei.h"
#include "menu.h"
#include "gameovermenu.h"
#include "ingamemenu.h"
#include "stats.h"
#include "global.h"
static void continue_game(MenuData *m, void *arg) {
log_info("The game is being continued...");
player_event(&global.plr, &global.replay.input, &global.replay.output, EV_CONTINUE, 0);
}
static void give_up(MenuData *m, void *arg) {
global.gameover = (MAX_CONTINUES - global.plr.stats.total.continues_used) ? GAMEOVER_ABORT : GAMEOVER_DEFEAT;
}
MenuData* create_gameover_menu(void) {
MenuData *m = alloc_menu();
m->draw = draw_ingame_menu;
m->logic = update_ingame_menu;
m->flags = MF_Transient | MF_AlwaysProcessInput;
m->transition = TransEmpty;
if(global.stage->type == STAGE_SPELL) {
m->context = "Spell Failed";
add_menu_entry(m, "Retry", restart_game, NULL)->transition = TransFadeBlack;
add_menu_entry(m, "Give up", give_up, NULL)->transition = TransFadeBlack;
} else {
m->context = "Game Over";
char s[64];
int c = MAX_CONTINUES - global.plr.stats.total.continues_used;
snprintf(s, sizeof(s), "Continue (%i)", c);
add_menu_entry(m, s, c ? continue_game : NULL, NULL);
add_menu_entry(m, "Restart the Game", restart_game, NULL)->transition = TransFadeBlack;
add_menu_entry(m, c? "Give up" : "Return to Title", give_up, NULL)->transition = TransFadeBlack;
if(!c)
m->cursor = 1;
}
set_transition(TransEmpty, 0, m->transition_out_time);
return m;
}