finally, a spell practice menu

This commit is contained in:
Andrei "Akari" Alexeyev 2017-02-12 06:30:25 +02:00 committed by Martin Herkt
parent 02c0b50bdb
commit de52c87af7
7 changed files with 108 additions and 3 deletions

View file

@ -44,6 +44,7 @@ set(SRCs
menu/savereplay.c
menu/difficulty.c
menu/charselect.c
menu/spellpractice.c
menu/common.c
stages/stage1.c
stages/stage2.c

View file

@ -12,6 +12,7 @@
#include "charselect.h"
#include "ending.h"
#include "credits.h"
#include "mainmenu.h"
void start_game(MenuData *menu, void *arg) {
MenuData m;
@ -96,6 +97,7 @@ troll2:
start_bgm("bgm_menu");
replay_destroy(&global.replay);
main_menu_update_spellpractice();
global.game_over = 0;
}

View file

@ -13,6 +13,7 @@
#include "stageselect.h"
#include "replayview.h"
#include "savereplay.h"
#include "spellpractice.h"
#include "global.h"
#include "stage.h"
@ -36,19 +37,45 @@ void enter_replayview(MenuData *menu, void *arg) {
replayview_menu_loop(&m);
}
void enter_spellpractice(MenuData *menu, void *arg) {
MenuData m;
create_spell_menu(&m);
spell_menu_loop(&m);
}
static MenuEntry *spell_practice_entry;
void main_menu_update_spellpractice(void) {
MenuEntry *e = spell_practice_entry;
e->action = NULL;
for(StageInfo *stg = stages; stg->loop; ++stg) {
if(stg->type == STAGE_SPELL) {
StageProgress *p = stage_get_progress_from_info(stg, D_Any, false);
if(p && p->unlocked) {
e->action = enter_spellpractice;
return;
}
}
}
}
void create_main_menu(MenuData *m) {
create_menu(m);
add_menu_entry(m, "Start Story", start_game, NULL);
add_menu_entry(m, "Start Extra", NULL, NULL);
add_menu_entry(m, "Spell Practice", enter_spellpractice, NULL);
#ifdef DEBUG
add_menu_entry(m, "Select Stage", enter_stagemenu, NULL);
#endif
add_menu_entry(m, "Replays", enter_replayview, NULL);
add_menu_entry(m, "Options", enter_options, NULL);
add_menu_entry(m, "Quit", (MenuAction)kill_menu, m);
}
spell_practice_entry = m->entries + 2;
main_menu_update_spellpractice();
}
void draw_main_menu_bg(MenuData* menu) {
glColor4f(1,1,1,1);
@ -66,7 +93,7 @@ void draw_main_menu(MenuData *menu) {
draw_texture(150, 100, "mainmenu/logo");
glPushMatrix();
glTranslatef(0, SCREEN_H-200, 0);
glTranslatef(0, SCREEN_H-235, 0);
Texture *bg = get_tex("part/smoke");
glPushMatrix();

View file

@ -14,5 +14,6 @@ void create_main_menu(MenuData *m);
void draw_main_menu_bg(MenuData *m);
void draw_main_menu(MenuData *m);
void main_menu_loop(MenuData *m);
void main_menu_update_spellpractice(void);
#endif

58
src/menu/spellpractice.c Normal file
View file

@ -0,0 +1,58 @@
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
*/
#include "spellpractice.h"
#include "common.h"
#include "options.h"
#include "global.h"
void create_spell_menu(MenuData *m) {
char title[128];
Difficulty lastdiff = D_Any;
create_menu(m);
m->flags = MF_Abortable;
for(StageInfo *stg = stages; stg->loop; ++stg) {
if(stg->type != STAGE_SPELL) {
continue;
}
if(stg->difficulty < lastdiff) {
add_menu_separator(m);
}
StageProgress *p = stage_get_progress_from_info(stg, D_Any, false);
if(p && p->unlocked) {
snprintf(title, sizeof(title), "%s: %s", stg->title, stg->subtitle);
add_menu_entry(m, title, start_game, stg);
} else {
snprintf(title, sizeof(title), "%s: ???????", stg->title);
add_menu_entry(m, title, NULL, NULL);
}
lastdiff = stg->difficulty;
}
add_menu_separator(m);
add_menu_entry(m, "Back", menu_commonaction_close, NULL);
while(!m->entries[m->cursor].action) {
++m->cursor;
}
}
void draw_spell_menu(MenuData *m) {
draw_options_menu_bg(m);
draw_menu_title(m, "Spell Practice");
animate_menu_list(m);
draw_menu_list(m, 100, 100, NULL);
}
int spell_menu_loop(MenuData *m) {
return menu_loop(m, NULL, draw_spell_menu, NULL);
}

16
src/menu/spellpractice.h Normal file
View file

@ -0,0 +1,16 @@
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
*/
#ifndef SPELLMENU_H
#define SPELLMENU_H
#include "menu.h"
void create_spell_menu(MenuData *m);
int spell_menu_loop(MenuData *m);
#endif

View file

@ -760,7 +760,7 @@ void stage_loop(StageRule start, StageRule end, StageRule draw, StageRule event,
printf("Random seed: %u\n", seed);
if(info->type == STAGE_SPELL) {
global.plr.lifes = 1;
global.plr.lifes = 0;
global.plr.bombs = 0;
}
} else {