Added stageselect menu for the debug mode

This commit is contained in:
Andrew "Akari" Alexeyew 2012-07-14 11:40:21 +03:00
parent f5e18a3030
commit db8dfd3580
9 changed files with 122 additions and 5 deletions

View file

@ -36,6 +36,7 @@ set(SRCs
menu/menu.c
menu/mainmenu.c
menu/options.c
menu/stageselect.c
menu/ingamemenu.c
menu/gameovermenu.c
menu/difficulty.c

View file

@ -11,10 +11,10 @@
#include "difficulty.h"
#include "charselect.h"
#include "options.h"
#include "stageselect.h"
#include "global.h"
#include "stages/stage0.h"
#include "stages/stage1.h"
#include "stage.h"
void quit_menu(void *arg) {
MenuData *m = arg;
@ -35,8 +35,13 @@ troll:
if(char_menu_loop(&m) == -1)
goto troll;
stage0_loop();
stage1_loop();
if(arg)
((StageInfo*)arg)->loop();
else {
int i;
for(i = 0; stages[i].loop; ++i)
stages[i].loop();
}
global.game_over = 0;
}
@ -47,6 +52,12 @@ void enter_options(void *arg) {
options_menu_loop(&m);
}
void enter_stagemenu(void *arg) {
MenuData m;
create_stage_menu(&m);
stage_menu_loop(&m);
}
void create_main_menu(MenuData *m) {
create_menu(m);
@ -54,6 +65,9 @@ void create_main_menu(MenuData *m) {
add_menu_entry(m, "Start Story", start_story, NULL);
add_menu_entry(m, "Start Extra", NULL, NULL);
#ifdef DEBUG
add_menu_entry(m, "Select stage", enter_stagemenu, NULL);
#endif
add_menu_entry(m, "Options", enter_options, NULL);
add_menu_entry(m, "Quit", quit_menu, m);
}

View file

@ -17,4 +17,6 @@ void draw_main_menu_bg(MenuData *m);
void draw_main_menu(MenuData *m);
void main_menu_loop(MenuData *m);
void start_story(void*);
#endif

View file

@ -17,6 +17,11 @@ void add_menu_entry(MenuData *menu, char *name, void (*action)(void *), void *ar
menu->entries[menu->ecount-1].drawdata = 0;
}
void add_menu_separator(MenuData *menu) {
menu->entries = realloc(menu->entries, (++menu->ecount)*sizeof(MenuEntry));
memset(&(menu->entries[menu->ecount-1]), 0, sizeof(MenuEntry));
}
void destroy_menu(MenuData *menu) {
int i;

View file

@ -49,6 +49,7 @@ typedef struct MenuData{
} MenuData;
void add_menu_entry(MenuData *menu, char *name, void (*action)(void *), void *arg);
void add_menu_separator();
void create_menu(MenuData *menu);
void destroy_menu(MenuData *menu);

View file

@ -405,7 +405,7 @@ void create_options_menu(MenuData *m) {
// --- Drawing the menu --- //
void draw_options_menu_bg(MenuData* menu) {
glColor4f(0.3, 0.3, 0.3, 1);
glColor4f(0.3, 0.3, 0.3,1);
draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenu/mainmenubgbg");
glColor4f(1,0.6,0.5,0.6 + 0.1*sin(menu->frames/100.0));
draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenu/mainmenubg");

74
src/menu/stageselect.c Executable file
View file

@ -0,0 +1,74 @@
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
* Copyright (C) 2011, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
*/
#include "global.h"
#include "menu.h"
#include "options.h"
#include "stage.h"
#include "stageselect.h"
#include "mainmenu.h"
void backtomain(void*);
void create_stage_menu(MenuData *m) {
char title[STGMENU_MAX_TITLE_LENGTH];
int i;
create_menu(m);
m->type = MT_Persistent;
for(i = 0; stages[i].loop; ++i) {
snprintf(title, STGMENU_MAX_TITLE_LENGTH, "%d. %s", i + 1, stages[i].title);
add_menu_entry(m, title, start_story, &(stages[i]));
}
add_menu_separator(m);
add_menu_entry(m, "Back", backtomain, m);
}
void draw_stage_menu(MenuData *m) {
draw_options_menu_bg(m);
draw_text(AL_Right, 220*(1-m->fade), 30, "Stage Select", _fonts.mainmenu);
glPushMatrix();
glTranslatef(100, 100, 0);
glPushMatrix();
glTranslatef(SCREEN_W/2 - 100, m->drawdata[2], 0);
glScalef(SCREEN_W - 200, 20, 1);
glColor4f(0,0,0,0.5);
draw_quad();
glPopMatrix();
int i;
for(i = 0; i < m->ecount; i++) {
MenuEntry *e = &(m->entries[i]);
e->drawdata += 0.2 * (10*(i == m->cursor) - e->drawdata);
if(e->action == NULL)
glColor4f(0.5, 0.5, 0.5, 0.7);
else if(i == m->cursor)
glColor4f(1,1,0,0.7);
else
glColor4f(1, 1, 1, 0.7);
if(e->name)
draw_text(AL_Left, 20 - e->drawdata, 20*i, e->name, _fonts.standard);
}
glPopMatrix();
m->drawdata[2] += (20*m->cursor - m->drawdata[2])/10.0;
fade_out(m->fade);
}
int stage_menu_loop(MenuData *m) {
return menu_loop(m, NULL, draw_stage_menu);
}

18
src/menu/stageselect.h Executable file
View file

@ -0,0 +1,18 @@
/*
* This software is licensed under the terms of the MIT-License
* See COPYING for further information.
* ---
* Copyright (C) 2011, Lukas Weber <laochailan@web.de>
* Copyright (C) 2011, Alexeyew Andrew <http://akari.thebadasschoobs.org/>
*/
#ifndef STGMENU_H
#define STGMENU_H
#define STGMENU_MAX_TITLE_LENGTH 128
void create_stage_menu(MenuData *m);
void draw_stage_menu(MenuData *m);
int stage_menu_loop(MenuData *m);
#endif

View file

@ -38,7 +38,9 @@ typedef struct StageInfo {
char *subtitle;
} StageInfo;
extern StageInfo stages[];
StageInfo* stage_get(int);
void stage_loop(StageRule start, StageRule end, StageRule draw, StageRule event, ShaderRule *shaderrules, int endtime);
void apply_bg_shaders(ShaderRule *shaderrules);