1 /*
2 * This software is licensed under the terms of the MIT License.
3 * See COPYING for further information.
4 * ---
5 * Copyright (c) 2011-2019, Lukas Weber <laochailan@web.de>.
6 * Copyright (c) 2012-2019, Andrei Alexeyev <akari@taisei-project.org>.
7 */
8
9 #include "taisei.h"
10
11 #include "global.h"
12 #include "menu.h"
13 #include "options.h"
14 #include "stage.h"
15 #include "stageselect.h"
16 #include "common.h"
17 #include "video.h"
18
draw_stage_menu(MenuData * m)19 static void draw_stage_menu(MenuData *m) {
20 draw_options_menu_bg(m);
21 draw_menu_title(m, "Select Stage");
22 draw_menu_list(m, 100, 100, NULL, SCREEN_H);
23 }
24
create_stage_menu(void)25 MenuData* create_stage_menu(void) {
26 char title[STGMENU_MAX_TITLE_LENGTH];
27 Difficulty lastdiff = D_Any;
28
29 MenuData *m = alloc_menu();
30
31 m->draw = draw_stage_menu;
32 m->logic = animate_menu_list;
33 m->flags = MF_Abortable;
34 m->transition = TransFadeBlack;
35
36 dynarray_foreach_elem(&stages, StageInfo *stg, {
37 Difficulty diff = stg->difficulty;
38
39 if(diff < lastdiff || (diff == D_Extra && lastdiff != D_Extra) || (diff && !lastdiff)) {
40 add_menu_separator(m);
41 }
42
43 snprintf(title, STGMENU_MAX_TITLE_LENGTH, "%s: %s", stg->title, stg->subtitle);
44 add_menu_entry(m, title, start_game, stg);
45
46 lastdiff = diff;
47 });
48
49 add_menu_separator(m);
50 add_menu_entry(m, "Back", menu_action_close, NULL);
51
52 return m;
53 }
54