2011-06-13 18:48:36 +02:00
|
|
|
/*
|
|
|
|
* This software is licensed under the terms of the MIT-License
|
2017-02-11 04:52:08 +01:00
|
|
|
* See COPYING for further information.
|
2011-06-13 18:48:36 +02:00
|
|
|
* ---
|
2017-09-12 03:28:15 +02:00
|
|
|
* Copyright (c) 2011-2017, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2017, Andrei Alexeyev <akari@alienslab.net>.
|
2011-06-13 18:48:36 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "mainmenu.h"
|
|
|
|
#include "menu.h"
|
2011-06-24 19:16:05 +02:00
|
|
|
|
2017-02-12 04:43:52 +01:00
|
|
|
#include "common.h"
|
2011-07-04 13:27:35 +02:00
|
|
|
#include "options.h"
|
2012-07-14 10:40:21 +02:00
|
|
|
#include "stageselect.h"
|
2012-07-16 19:26:41 +02:00
|
|
|
#include "replayview.h"
|
2012-08-07 05:28:41 +02:00
|
|
|
#include "savereplay.h"
|
2017-02-12 05:30:25 +01:00
|
|
|
#include "spellpractice.h"
|
2017-09-11 21:09:30 +02:00
|
|
|
#include "stagepractice.h"
|
|
|
|
#include "difficultyselect.h"
|
2011-06-24 19:16:05 +02:00
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
#include "global.h"
|
2017-03-07 02:04:23 +01:00
|
|
|
#include "video.h"
|
2012-07-14 10:40:21 +02:00
|
|
|
#include "stage.h"
|
2017-09-18 10:49:06 +02:00
|
|
|
#include "version.h"
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2017-02-16 17:55:46 +01:00
|
|
|
void enter_options(MenuData *menu, void *arg) {
|
2011-07-03 15:11:18 +02:00
|
|
|
MenuData m;
|
|
|
|
create_options_menu(&m);
|
2017-02-24 22:58:27 +01:00
|
|
|
menu_loop(&m);
|
2011-07-03 15:11:18 +02:00
|
|
|
}
|
|
|
|
|
2017-02-16 17:55:46 +01:00
|
|
|
void enter_stagemenu(MenuData *menu, void *arg) {
|
2012-07-14 10:40:21 +02:00
|
|
|
MenuData m;
|
|
|
|
create_stage_menu(&m);
|
2017-02-24 22:58:27 +01:00
|
|
|
menu_loop(&m);
|
2012-07-14 10:40:21 +02:00
|
|
|
}
|
|
|
|
|
2017-02-16 17:55:46 +01:00
|
|
|
void enter_replayview(MenuData *menu, void *arg) {
|
2012-07-16 19:26:41 +02:00
|
|
|
MenuData m;
|
|
|
|
create_replayview_menu(&m);
|
2017-02-24 22:58:27 +01:00
|
|
|
menu_loop(&m);
|
2012-07-16 19:26:41 +02:00
|
|
|
}
|
|
|
|
|
2017-02-12 05:30:25 +01:00
|
|
|
void enter_spellpractice(MenuData *menu, void *arg) {
|
|
|
|
MenuData m;
|
|
|
|
create_spell_menu(&m);
|
2017-02-24 22:58:27 +01:00
|
|
|
menu_loop(&m);
|
2017-02-12 05:30:25 +01:00
|
|
|
}
|
|
|
|
|
2017-09-11 21:09:30 +02:00
|
|
|
void enter_stagepractice(MenuData *menu, void *arg) {
|
|
|
|
MenuData m;
|
|
|
|
|
|
|
|
do {
|
|
|
|
create_difficulty_menu(&m);
|
|
|
|
|
|
|
|
if(menu_loop(&m) < 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
create_stgpract_menu(&m, global.diff);
|
|
|
|
menu_loop(&m);
|
|
|
|
} while(m.selected < 0 || m.selected == m.ecount - 1);
|
|
|
|
}
|
|
|
|
|
2017-02-12 05:30:25 +01:00
|
|
|
static MenuEntry *spell_practice_entry;
|
2017-09-11 21:09:30 +02:00
|
|
|
static MenuEntry *stage_practice_entry;
|
2017-02-12 05:30:25 +01:00
|
|
|
|
2017-09-11 21:09:30 +02:00
|
|
|
void main_menu_update_practice_menus(void) {
|
|
|
|
spell_practice_entry->action = NULL;
|
|
|
|
stage_practice_entry->action = NULL;
|
2017-02-12 05:30:25 +01:00
|
|
|
|
2017-09-11 21:09:30 +02:00
|
|
|
for(StageInfo *stg = stages; stg->procs && (!spell_practice_entry->action || !stage_practice_entry->action); ++stg) {
|
2017-02-12 05:30:25 +01:00
|
|
|
if(stg->type == STAGE_SPELL) {
|
|
|
|
StageProgress *p = stage_get_progress_from_info(stg, D_Any, false);
|
2017-09-11 21:09:30 +02:00
|
|
|
|
2017-02-12 05:30:25 +01:00
|
|
|
if(p && p->unlocked) {
|
2017-09-11 21:09:30 +02:00
|
|
|
spell_practice_entry->action = enter_spellpractice;
|
|
|
|
}
|
|
|
|
} else if(stg->type == STAGE_STORY) {
|
|
|
|
for(Difficulty d = D_Easy; d <= D_Lunatic; ++d) {
|
|
|
|
StageProgress *p = stage_get_progress_from_info(stg, d, false);
|
|
|
|
|
|
|
|
if(p && p->unlocked) {
|
|
|
|
stage_practice_entry->action = enter_stagepractice;
|
|
|
|
}
|
2017-02-12 05:30:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-24 22:58:27 +01:00
|
|
|
void begin_main_menu(MenuData *m) {
|
2017-10-02 04:34:51 +02:00
|
|
|
start_bgm("menu");
|
2017-02-24 22:58:27 +01:00
|
|
|
}
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
void create_main_menu(MenuData *m) {
|
|
|
|
create_menu(m);
|
2017-02-24 22:58:27 +01:00
|
|
|
m->draw = draw_main_menu;
|
|
|
|
m->begin = begin_main_menu;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2017-02-12 04:43:52 +01:00
|
|
|
add_menu_entry(m, "Start Story", start_game, NULL);
|
2011-06-24 12:35:03 +02:00
|
|
|
add_menu_entry(m, "Start Extra", NULL, NULL);
|
2017-09-11 21:09:30 +02:00
|
|
|
add_menu_entry(m, "Stage Practice", enter_stagepractice, NULL);
|
2017-02-12 05:30:25 +01:00
|
|
|
add_menu_entry(m, "Spell Practice", enter_spellpractice, NULL);
|
2012-07-14 10:40:21 +02:00
|
|
|
#ifdef DEBUG
|
2012-07-14 10:49:58 +02:00
|
|
|
add_menu_entry(m, "Select Stage", enter_stagemenu, NULL);
|
2012-07-14 10:40:21 +02:00
|
|
|
#endif
|
2012-07-16 19:26:41 +02:00
|
|
|
add_menu_entry(m, "Replays", enter_replayview, NULL);
|
2011-07-03 15:11:18 +02:00
|
|
|
add_menu_entry(m, "Options", enter_options, NULL);
|
2017-02-24 22:58:27 +01:00
|
|
|
add_menu_entry(m, "Quit", menu_commonaction_close, NULL)->transition = TransFadeBlack;;
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2017-09-11 21:09:30 +02:00
|
|
|
stage_practice_entry = m->entries + 2;
|
|
|
|
spell_practice_entry = m->entries + 3;
|
|
|
|
main_menu_update_practice_menus();
|
2017-02-12 05:30:25 +01:00
|
|
|
}
|
2011-06-13 18:48:36 +02:00
|
|
|
|
2011-06-24 12:35:03 +02:00
|
|
|
void draw_main_menu_bg(MenuData* menu) {
|
2012-08-06 07:54:22 +02:00
|
|
|
glColor4f(1,1,1,1);
|
2017-03-04 22:51:23 +01:00
|
|
|
//draw_texture(SCREEN_W/2, SCREEN_H/2, "mainmenu/mainmenubgbg");
|
|
|
|
//glColor4f(1,1,1,0.95 + 0.05*sin(menu->frames/100.0));
|
2017-02-11 04:52:08 +01:00
|
|
|
|
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);
|
2012-08-03 19:58:21 +02:00
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
2011-06-24 12:35:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void draw_main_menu(MenuData *menu) {
|
|
|
|
draw_main_menu_bg(menu);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2017-03-04 11:32:59 +01:00
|
|
|
draw_texture(150.5, 100, "mainmenu/logo");
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
glPushMatrix();
|
2017-09-11 21:09:30 +02:00
|
|
|
glTranslatef(0, SCREEN_H-270, 0);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-06 07:54:22 +02:00
|
|
|
Texture *bg = get_tex("part/smoke");
|
2011-06-13 18:48:36 +02:00
|
|
|
glPushMatrix();
|
2012-08-06 07:54:22 +02:00
|
|
|
glTranslatef(50 + menu->drawdata[1]/2, menu->drawdata[2], 0); // 135
|
|
|
|
glScalef(menu->drawdata[1]/100.0, 0.5, 1);
|
|
|
|
glRotatef(menu->frames*2,0,0,1);
|
|
|
|
glColor4f(0,0,0,0.5);
|
|
|
|
draw_texture_p(0,0,bg);
|
2011-06-13 18:48:36 +02:00
|
|
|
glPopMatrix();
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
int i;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-06 07:54:22 +02:00
|
|
|
menu->drawdata[1] += (stringwidth(menu->entries[menu->cursor].name, _fonts.mainmenu) - menu->drawdata[1])/10.0;
|
|
|
|
menu->drawdata[2] += (35*menu->cursor - menu->drawdata[2])/10.0;
|
2017-02-11 04:52:08 +01:00
|
|
|
|
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-08-06 07:54:22 +02:00
|
|
|
menu->entries[i].drawdata += 0.2 * ((i == menu->cursor) - menu->entries[i].drawdata);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-06 07:54:22 +02:00
|
|
|
if(menu->entries[i].action == NULL) {
|
2017-03-04 22:51:23 +01:00
|
|
|
glColor4f(0.2,0.3,0.5,0.7);
|
2012-08-06 07:54:22 +02:00
|
|
|
} else {
|
|
|
|
//glColor4f(1,1,1,0.7);
|
|
|
|
float a = 1 - menu->entries[i].drawdata;
|
|
|
|
glColor4f(1, 0.7 + a, 0.4 + a, 0.7);
|
2012-04-05 14:24:55 +02:00
|
|
|
}
|
2017-02-11 04:52:08 +01:00
|
|
|
|
|
|
|
draw_text(AL_Left, 50 + s, 35*i, menu->entries[i].name, _fonts.mainmenu);
|
2011-06-13 18:48:36 +02:00
|
|
|
}
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
glPopMatrix();
|
2017-03-04 22:51:23 +01:00
|
|
|
|
|
|
|
glColor4f(1,1,1,1);
|
|
|
|
for(int i = 0; i < 50; i++) { // who needs persistent state for a particle system?
|
|
|
|
int period = 900;
|
|
|
|
int t = menu->frames+100*i + 30*sin(35*i);
|
|
|
|
int cycle = t/period;
|
|
|
|
float posx = SCREEN_W+300+100*sin(100345*i)+200*sin(1003*i+13537*cycle)-(0.6+0.01*sin(35*i))*(t%period);
|
|
|
|
float posy = 50+ 50*sin(503*i+14677*cycle)+0.8*(t%period);
|
|
|
|
float rx = sin(56*i+2147*cycle);
|
|
|
|
float ry = sin(913*i+137*cycle);
|
|
|
|
float rz = sin(1303*i+89631*cycle);
|
|
|
|
float r = sqrt(rx*rx+ry*ry+rz*rz);
|
2017-09-26 02:38:34 +02:00
|
|
|
|
|
|
|
if(!r) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-03-04 22:51:23 +01:00
|
|
|
rx /= r;
|
|
|
|
ry /= r;
|
|
|
|
rz /= r;
|
2017-09-26 02:38:34 +02:00
|
|
|
|
2017-03-04 22:51:23 +01:00
|
|
|
if(posx > SCREEN_W+20 || posy < -20 || posy > SCREEN_H+20)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
glDisable(GL_CULL_FACE);
|
|
|
|
glPushMatrix();
|
|
|
|
glTranslatef(posx,posy,0);
|
|
|
|
glScalef(0.2,0.2,0.2);
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
|
|
glRotatef(2*(t%period),rx,ry,rz);
|
|
|
|
draw_texture(0,0,"part/petal");
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
|
2017-09-24 01:16:30 +02:00
|
|
|
char version[32];
|
|
|
|
snprintf(version, sizeof(version), "v%s", TAISEI_VERSION);
|
|
|
|
draw_text(AL_Right,SCREEN_W-5,SCREEN_H-10,version,_fonts.small);
|
2011-06-13 18:48:36 +02:00
|
|
|
}
|
2017-03-07 02:04:23 +01:00
|
|
|
|
|
|
|
void draw_loading_screen(void) {
|
2017-03-11 04:41:57 +01:00
|
|
|
preload_resource(RES_TEXTURE, "loading", RESF_PERMANENT);
|
2017-03-07 02:04:23 +01:00
|
|
|
set_ortho();
|
|
|
|
draw_texture(SCREEN_W/2, SCREEN_H/2, "loading");
|
2017-09-18 10:49:06 +02:00
|
|
|
draw_text(AL_Right,SCREEN_W-5,SCREEN_H-10,TAISEI_VERSION,_fonts.small);
|
2017-03-07 02:04:23 +01:00
|
|
|
SDL_GL_SwapWindow(video.window);
|
|
|
|
}
|
2017-03-11 04:41:57 +01:00
|
|
|
|
|
|
|
void menu_preload(void) {
|
|
|
|
difficulty_preload();
|
|
|
|
|
|
|
|
preload_resources(RES_TEXTURE, RESF_PERMANENT,
|
|
|
|
"mainmenu/mainmenubg",
|
|
|
|
"mainmenu/logo",
|
|
|
|
"part/smoke",
|
|
|
|
"part/petal",
|
|
|
|
"dialog/marisa",
|
|
|
|
"dialog/youmu",
|
|
|
|
"charselect_arrow",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
preload_resources(RES_SFX, RESF_PERMANENT | RESF_OPTIONAL,
|
|
|
|
"generic_shot",
|
|
|
|
"shot_special1",
|
|
|
|
"hit",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
preload_resources(RES_BGM, RESF_PERMANENT | RESF_OPTIONAL,
|
2017-10-02 04:34:51 +02:00
|
|
|
"menu",
|
2017-03-11 04:41:57 +01:00
|
|
|
NULL);
|
|
|
|
}
|