2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
21 #include "st_shared.h"
30 /*---------------------------------------------------------------------------*/
32 static float real_time = 0.0f;
33 static float demo_time = 0.0f;
42 static int title_action(int i)
45 audio_play(AUD_MENU, 1.0f);
50 config_get_s(CONFIG_PLAYER, player, MAXNAM);
52 if (strlen(player) == 0)
53 return goto_name(&st_set, &st_title);
55 return goto_state(&st_set);
59 case TITLE_HELP: return goto_state(&st_help); break;
60 case TITLE_DEMO: return goto_state(&st_demo); break;
61 case TITLE_CONF: return goto_state(&st_conf); break;
62 case TITLE_EXIT: return 0; break;
67 static struct level title_level;
69 static int title_enter(void)
73 /* Build the title GUI. */
75 if ((id = gui_vstack(0)))
77 gui_label(id, "Neverball", GUI_LRG, GUI_ALL, 0, 0);
80 if ((jd = gui_harray(id)))
84 if ((kd = gui_varray(jd)))
86 gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1);
87 gui_state(kd, sgettext("menu^Replay"), GUI_MED, TITLE_DEMO, 0);
88 gui_state(kd, sgettext("menu^Help"), GUI_MED, TITLE_HELP, 0);
89 gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0);
90 gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
98 /* Start the title screen music. */
100 audio_music_fade_to(0.5f, "bgm/title.ogg");
102 /* Initialize the title level for display. */
103 level_load("map-medium/title.sol", &title_level);
104 game_init(&title_level, 0, 0);
113 static void title_leave(int id)
119 static void title_timer(int id, float dt)
121 static const char *demo = NULL;
128 case 0: /* Mode 0: Pan across title level. */
130 if (real_time <= 20.0f)
131 game_set_fly(fcosf(V_PI * real_time / 20.0f));
140 case 1: /* Mode 1: Fade out. Load demo level. */
142 if (real_time > 1.0f)
144 if ((demo = demo_pick()))
146 demo_replay_init(demo, NULL);
160 case 2: /* Mode 2: Run demo. */
162 while (demo_time < real_time)
163 if (demo_replay_step(&t))
174 case 3: /* Mode 3: Fade out. Load title level. */
176 if (real_time > 1.0f)
178 game_init(&title_level, 0, 0);
190 static int title_keybd(int c, int d)
192 if (d && c == SDLK_c && ALLOW_CHEAT)
193 config_tgl_d(CONFIG_CHEAT);
197 static int title_buttn(int b, int d)
201 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
202 return title_action(gui_token(gui_click()));
203 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
209 /*---------------------------------------------------------------------------*/
211 struct state st_title = {