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
|
|
|
* ---
|
2018-01-04 18:14:31 +01:00
|
|
|
* Copyright (c) 2011-2018, Lukas Weber <laochailan@web.de>.
|
|
|
|
* Copyright (c) 2012-2018, Andrei Alexeyev <akari@alienslab.net>.
|
2011-06-13 18:48:36 +02:00
|
|
|
*/
|
|
|
|
|
2017-11-25 20:45:11 +01:00
|
|
|
#include "taisei.h"
|
|
|
|
|
2011-06-13 18:48:36 +02:00
|
|
|
#include "mainmenu.h"
|
|
|
|
#include "menu.h"
|
2017-11-12 01:38:44 +01:00
|
|
|
#include "submenus.h"
|
2011-06-24 19:16:05 +02:00
|
|
|
|
2017-02-12 04:43:52 +01:00
|
|
|
#include "common.h"
|
2017-11-12 01:38:44 +01:00
|
|
|
|
2012-08-07 05:28:41 +02:00
|
|
|
#include "savereplay.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"
|
2017-10-08 13:30:51 +02:00
|
|
|
#include "plrmodes.h"
|
2011-06-13 18:48:36 +02: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;
|
|
|
|
}
|
|
|
|
|
2017-10-10 07:09:16 +02:00
|
|
|
global.diff = progress.game_settings.difficulty;
|
2017-09-11 21:09:30 +02:00
|
|
|
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-12-26 12:07:40 +01:00
|
|
|
static 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
|
|
|
}
|
|
|
|
|
2017-12-26 12:07:40 +01:00
|
|
|
static void update_main_menu(MenuData *menu);
|
|
|
|
|
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;
|
2017-12-26 12:07:40 +01:00
|
|
|
m->logic = update_main_menu;
|
2017-02-24 22:58:27 +01:00
|
|
|
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) {
|
2018-07-23 19:07:59 +02:00
|
|
|
r_color4(1, 1, 1, 1);
|
2018-02-06 07:19:25 +01:00
|
|
|
fill_screen("menu/mainmenubg");
|
2011-06-24 12:35:03 +02:00
|
|
|
}
|
|
|
|
|
2017-12-26 12:07:40 +01:00
|
|
|
static void update_main_menu(MenuData *menu) {
|
2018-06-29 23:36:51 +02:00
|
|
|
menu->drawdata[1] += (text_width(get_font("big"), menu->entries[menu->cursor].name, 0) - menu->drawdata[1])/10.0;
|
2017-12-26 12:07:40 +01:00
|
|
|
menu->drawdata[2] += (35*menu->cursor - menu->drawdata[2])/10.0;
|
|
|
|
|
|
|
|
for(int i = 0; i < menu->ecount; i++) {
|
|
|
|
menu->entries[i].drawdata += 0.2 * ((i == menu->cursor) - menu->entries[i].drawdata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-24 12:35:03 +02:00
|
|
|
void draw_main_menu(MenuData *menu) {
|
|
|
|
draw_main_menu_bg(menu);
|
2018-02-06 07:19:25 +01:00
|
|
|
draw_sprite(150.5, 100, "menu/logo");
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
r_mat_push();
|
|
|
|
r_mat_translate(0, SCREEN_H-270, 0);
|
2018-02-06 07:19:25 +01:00
|
|
|
draw_menu_selector(50 + menu->drawdata[1]/2, menu->drawdata[2], 1.5 * menu->drawdata[1], 64, menu->frames);
|
2018-06-29 23:36:51 +02:00
|
|
|
r_shader("text_default");
|
2018-07-23 19:07:59 +02:00
|
|
|
|
|
|
|
float o = 0.7;
|
|
|
|
|
2017-12-26 12:07:40 +01:00
|
|
|
for(int i = 0; i < menu->ecount; i++) {
|
2011-06-13 18:48:36 +02:00
|
|
|
float s = 5*sin(menu->frames/80.0 + 20*i);
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2012-08-06 07:54:22 +02:00
|
|
|
if(menu->entries[i].action == NULL) {
|
2018-07-23 19:07:59 +02:00
|
|
|
r_color4(0.2 * o, 0.3 * o, 0.5 * o, o);
|
2012-08-06 07:54:22 +02:00
|
|
|
} else {
|
|
|
|
float a = 1 - menu->entries[i].drawdata;
|
2018-07-23 19:07:59 +02:00
|
|
|
r_color4(o, min(1, 0.7 + a) * o, min(1, 0.4 + a) * o, o);
|
2012-04-05 14:24:55 +02:00
|
|
|
}
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2018-06-29 23:36:51 +02:00
|
|
|
text_draw(menu->entries[i].name, &(TextParams) {
|
|
|
|
.pos = { 50 + s, 35*i },
|
|
|
|
.font = "big",
|
|
|
|
// .shader = "text_example",
|
|
|
|
// .custom = time_get()
|
|
|
|
});
|
2011-06-13 18:48:36 +02:00
|
|
|
}
|
2017-02-11 04:52:08 +01:00
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
r_mat_pop();
|
|
|
|
|
|
|
|
bool cullcap_saved = r_capability_current(RCAP_CULL_FACE);
|
|
|
|
r_disable(RCAP_CULL_FACE);
|
2018-07-23 19:07:59 +02:00
|
|
|
r_color4(1, 1, 1, 0);
|
2018-04-12 16:08:48 +02:00
|
|
|
r_shader("sprite_default");
|
2017-03-04 22:51:23 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
r_mat_push();
|
|
|
|
r_mat_translate(posx,posy,0);
|
|
|
|
r_mat_scale(0.2,0.2,0.2);
|
|
|
|
r_mat_rotate_deg(2*(t%period),rx,ry,rz);
|
|
|
|
draw_sprite_batched(0,0,"part/petal");
|
|
|
|
r_mat_pop();
|
2017-03-04 22:51:23 +01:00
|
|
|
}
|
|
|
|
|
2018-06-29 23:36:51 +02:00
|
|
|
r_shader("text_default");
|
2018-04-12 16:08:48 +02:00
|
|
|
r_capability(RCAP_CULL_FACE, cullcap_saved);
|
|
|
|
|
2017-09-24 01:16:30 +02:00
|
|
|
char version[32];
|
|
|
|
snprintf(version, sizeof(version), "v%s", TAISEI_VERSION);
|
2018-06-29 23:36:51 +02:00
|
|
|
text_draw(TAISEI_VERSION, &(TextParams) {
|
|
|
|
.align = ALIGN_RIGHT,
|
|
|
|
.pos = { SCREEN_W-5, SCREEN_H-10 },
|
|
|
|
.font = "small",
|
|
|
|
});
|
2018-07-25 00:33:01 +02:00
|
|
|
|
2018-06-29 23:36:51 +02:00
|
|
|
r_shader_standard();
|
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);
|
2018-04-26 01:50:48 +02:00
|
|
|
set_ortho(SCREEN_W, SCREEN_H);
|
2018-02-06 07:19:25 +01:00
|
|
|
fill_screen("loading");
|
2018-06-29 23:36:51 +02:00
|
|
|
/*
|
|
|
|
text_draw(TAISEI_VERSION, &(TextParams) {
|
|
|
|
.align = ALIGN_RIGHT,
|
|
|
|
.pos = { SCREEN_W-5, SCREEN_H-10 },
|
|
|
|
.font = "small",
|
|
|
|
.shader = "text_default",
|
|
|
|
});
|
|
|
|
*/
|
2017-12-26 09:56:21 +01:00
|
|
|
video_swap_buffers();
|
2017-03-07 02:04:23 +01:00
|
|
|
}
|
2017-03-11 04:41:57 +01:00
|
|
|
|
|
|
|
void menu_preload(void) {
|
|
|
|
difficulty_preload();
|
|
|
|
|
2018-06-29 23:36:51 +02:00
|
|
|
preload_resources(RES_FONT, RESF_PERMANENT,
|
|
|
|
"big",
|
|
|
|
"small",
|
|
|
|
NULL);
|
|
|
|
|
2017-03-11 04:41:57 +01:00
|
|
|
preload_resources(RES_TEXTURE, RESF_PERMANENT,
|
2018-02-06 07:19:25 +01:00
|
|
|
"menu/mainmenubg",
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
preload_resources(RES_SPRITE, RESF_PERMANENT,
|
2017-03-11 04:41:57 +01:00
|
|
|
"part/smoke",
|
|
|
|
"part/petal",
|
2018-02-06 07:19:25 +01:00
|
|
|
"menu/logo",
|
|
|
|
"menu/arrow",
|
|
|
|
"star",
|
|
|
|
NULL);
|
|
|
|
|
2018-04-12 16:08:48 +02:00
|
|
|
preload_resources(RES_SHADER_PROGRAM, RESF_PERMANENT,
|
|
|
|
"sprite_circleclipped_indicator",
|
2017-03-11 04:41:57 +01:00
|
|
|
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);
|
2017-10-08 13:30:51 +02:00
|
|
|
|
|
|
|
for(int i = 0; i < NUM_CHARACTERS; ++i) {
|
2018-02-06 07:19:25 +01:00
|
|
|
preload_resource(RES_SPRITE, plrchar_get(i)->dialog_sprite_name, RESF_PERMANENT);
|
2017-10-08 13:30:51 +02:00
|
|
|
}
|
2017-03-11 04:41:57 +01:00
|
|
|
}
|