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);
51 if (player[0] == '\0')
52 return goto_name(&st_set, &st_title);
54 return goto_state(&st_set);
55 case TITLE_HELP: return goto_state(&st_help);
56 case TITLE_DEMO: return goto_state(&st_demo);
57 case TITLE_CONF: return goto_state(&st_conf);
58 case TITLE_EXIT: return 0;
63 static struct level title_level;
65 static int title_enter(void)
69 /* Build the title GUI. */
71 if ((id = gui_vstack(0)))
73 gui_label(id, "Neverball", GUI_LRG, GUI_ALL, 0, 0);
76 if ((jd = gui_harray(id)))
80 if ((kd = gui_varray(jd)))
82 gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1);
83 gui_state(kd, sgettext("menu^Replay"), GUI_MED, TITLE_DEMO, 0);
84 gui_state(kd, sgettext("menu^Help"), GUI_MED, TITLE_HELP, 0);
85 gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0);
86 gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
94 /* Start the title screen music. */
96 audio_music_fade_to(0.5f, "bgm/title.ogg");
98 /* Initialize the first level of the first set for display. */
99 level_load(config_data("map-rlk/title.sol"), &title_level);
100 game_init(&title_level, 0, 0);
109 static void title_leave(int id)
115 static void title_timer(int id, float dt)
117 static const char *demo = NULL;
124 case 0: /* Mode 0: Pan across title level. */
126 if (real_time <= 20.0f)
127 game_set_fly(fcosf(V_PI * real_time / 20.0f));
136 case 1: /* Mode 1: Fade out. Load demo level. */
138 if (real_time > 1.0f)
140 if ((demo = demo_pick()))
142 demo_replay_init(demo, NULL);
156 case 2: /* Mode 2: Run demo. */
158 while (demo_time < real_time)
159 if (demo_replay_step(&t))
170 case 3: /* Mode 3: Fade out. Load title level. */
172 if (real_time > 1.0f)
174 game_init(&title_level, 0, 0);
186 static int title_keybd(int c, int d)
188 if (d && c == SDLK_c && ALLOW_CHEAT)
189 config_tgl_d(CONFIG_CHEAT);
193 static int title_buttn(int b, int d)
197 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
198 return title_action(gui_token(gui_click()));
199 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
205 /*---------------------------------------------------------------------------*/
207 struct state st_title = {