2011-06-13 18:48:36 +02:00
|
|
|
/*
|
|
|
|
* 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 "mainmenu.h"
|
|
|
|
#include "menu.h"
|
2011-06-24 19:16:05 +02:00
|
|
|
|
|
|
|
#include "difficulty.h"
|
|
|
|
#include "charselect.h"
|
2011-07-04 13:27:35 +02:00
|
|
|
#include "options.h"
|
2012-07-14 10:40:21 +02:00
|
|
|
#include "stageselect.h"
|
2011-06-24 19:16:05 +02:00
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
#include "global.h"
|
2012-07-14 10:40:21 +02:00
|
|
|
#include "stage.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
|
|
|
|
void quit_menu(void *arg) {
|
|
|
|
MenuData *m = arg;
|
|
|
|
m->quit = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
void start_story(void *arg) {
|
2011-06-24 12:35:03 +02:00
|
|
|
MenuData m;
|
2011-06-24 19:16:05 +02:00
|
|
|
|
2011-07-04 09:14:08 +02:00
|
|
|
init_player(&global.plr);
|
|
|
|
|
2011-06-24 19:16:05 +02:00
|
|
|
troll:
|
2011-06-24 12:35:03 +02:00
|
|
|
create_difficulty_menu(&m);
|
2011-06-24 19:16:05 +02:00
|
|
|
if(difficulty_menu_loop(&m) == -1)
|
|
|
|
return;
|
|
|
|
|
|
|
|
create_char_menu(&m);
|
|
|
|
if(char_menu_loop(&m) == -1)
|
|
|
|
goto troll;
|
|
|
|
|
2012-07-14 10:40:21 +02:00
|
|
|
if(arg)
|
|
|
|
((StageInfo*)arg)->loop();
|
|
|
|
else {
|
|
|
|
int i;
|
|
|
|
for(i = 0; stages[i].loop; ++i)
|
|
|
|
stages[i].loop();
|
|
|
|
}
|
2012-01-06 21:52:55 +01:00
|
|
|
|
|
|
|
global.game_over = 0;
|
2011-06-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
2012-01-06 21:52:55 +01:00
|
|
|
void enter_options(void *arg) {
|
2011-07-03 15:11:18 +02:00
|
|
|
MenuData m;
|
|
|
|
create_options_menu(&m);
|
2011-07-04 12:30:14 +02:00
|
|
|
options_menu_loop(&m);
|
2011-07-03 15:11:18 +02:00
|
|
|
}
|
|
|
|
|
2012-07-14 10:40:21 +02:00
|
|
|
void enter_stagemenu(void *arg) {
|
|
|
|
MenuData m;
|
|
|
|
create_stage_menu(&m);
|
|
|
|
stage_menu_loop(&m);
|
|
|
|
}
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
void create_main_menu(MenuData *m) {
|
|
|
|
create_menu(m);
|
|
|
|
|
|
|
|
m->type = MT_Persistent;
|
|
|
|
|
|
|
|
add_menu_entry(m, "Start Story", start_story, NULL);
|
2011-06-24 12:35:03 +02:00
|
|
|
add_menu_entry(m, "Start Extra", NULL, NULL);
|
2012-07-14 10:40:21 +02:00
|
|
|
#ifdef DEBUG
|
|
|
|
add_menu_entry(m, "Select stage", enter_stagemenu, NULL);
|
|
|
|
#endif
|
2011-07-03 15:11:18 +02:00
|
|
|
add_menu_entry(m, "Options", enter_options, NULL);
|
2011-06-13 18:48:36 +02:00
|
|
|
add_menu_entry(m, "Quit", quit_menu, m);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-24 12:35:03 +02:00
|
|
|
void draw_main_menu_bg(MenuData* menu) {
|
2011-06-26 13:45:27 +02:00
|
|
|
draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenu/mainmenubgbg");
|
2012-04-04 22:36:51 +02:00
|
|
|
glColor4f(1,1,1,0.7 + 0.1*sin(menu->frames/100.0));
|
2011-06-26 13:45:27 +02:00
|
|
|
draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenu/mainmenubg");
|
2011-06-24 12:35:03 +02:00
|
|
|
glColor4f(1,1,1,1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void draw_main_menu(MenuData *menu) {
|
|
|
|
draw_main_menu_bg(menu);
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2012-04-04 22:36:51 +02:00
|
|
|
draw_texture(SCREEN_W-200, SCREEN_H/2+100, "dialog/marisa");
|
|
|
|
|
|
|
|
draw_texture(150, 100, "mainmenu/logo");
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(0, SCREEN_H-200, 0);
|
|
|
|
|
|
|
|
glPushMatrix();
|
2012-04-05 14:24:55 +02:00
|
|
|
glTranslatef(135, menu->drawdata[2], 0);
|
|
|
|
glScalef(270, 34, 1);
|
|
|
|
|
|
|
|
glColor4f(0,0,0,0.7);
|
|
|
|
|
|
|
|
draw_quad();
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
int i;
|
|
|
|
|
2012-04-05 14:24:55 +02:00
|
|
|
int grey = 2;
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
for(i = 0; i < menu->ecount; i++) {
|
|
|
|
float s = 5*sin(menu->frames/80.0 + 20*i);
|
2012-04-05 14:24:55 +02:00
|
|
|
|
|
|
|
if(menu->entries[i].action == NULL && grey != 1) {
|
|
|
|
glColor4f(0.5,0.5,0.5,0.7);
|
|
|
|
grey = 1;
|
|
|
|
} else if(grey != 0) {
|
|
|
|
glColor4f(1,1,1,0.7);
|
|
|
|
grey = 0;
|
|
|
|
}
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2012-04-05 14:24:55 +02:00
|
|
|
draw_text(AL_Left, 50 + s, 35*i, menu->entries[i].name, _fonts.mainmenu);
|
2011-06-13 18:48:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
glPopMatrix();
|
|
|
|
|
|
|
|
menu->drawdata[2] += (35*menu->cursor - menu->drawdata[2])/10.0;
|
|
|
|
|
|
|
|
fade_out(menu->fade);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main_menu_loop(MenuData *menu) {
|
2011-06-25 12:41:40 +02:00
|
|
|
menu_loop(menu, NULL, draw_main_menu);
|
2011-07-03 15:11:18 +02:00
|
|
|
}
|