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.
24 #include "st_shared.h"
32 /*---------------------------------------------------------------------------*/
34 static float real_time = 0.0f;
35 static float demo_time = 0.0f;
44 static int title_action(int i)
47 audio_play(AUD_MENU, 1.0f);
52 config_get_s(CONFIG_PLAYER, player, MAXNAM);
53 if (player[0] == '\0')
54 return goto_name(&st_set, &st_title);
56 return goto_state(&st_set);
57 case TITLE_HELP: return goto_state(&st_help);
58 case TITLE_DEMO: return goto_state(&st_demo);
59 case TITLE_CONF: return goto_state(&st_conf);
60 case TITLE_EXIT: return 0;
65 static struct level title_level;
67 static int title_enter(void)
71 /* Build the title GUI. */
73 if ((id = gui_vstack(0)))
75 gui_label(id, "Neverball", GUI_LRG, GUI_ALL, 0, 0);
78 if ((jd = gui_harray(id)))
82 if ((kd = gui_varray(jd)))
84 gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1);
85 gui_state(kd, sgettext("menu^Replay"), GUI_MED, TITLE_DEMO, 0);
86 gui_state(kd, sgettext("menu^Help"), GUI_MED, TITLE_HELP, 0);
87 gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0);
88 gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
96 /* Start the title screen music. */
98 audio_music_fade_to(0.5f, "bgm/title.ogg");
100 /* Initialize the first level of the first set for display. */
101 level_load(config_data("map-rlk/title.sol"), &title_level);
102 game_init(&title_level, 0, 0);
111 static void title_leave(int id)
117 static void title_timer(int id, float dt)
119 static const char *demo = NULL;
126 case 0: /* Mode 0: Pan across title level. */
128 if (real_time <= 20.0f)
129 game_set_fly(fcosf(V_PI * real_time / 20.0f));
138 case 1: /* Mode 1: Fade out. Load demo level. */
140 if (real_time > 1.0f)
142 if ((demo = demo_pick()))
144 demo_replay_init(demo, NULL);
158 case 2: /* Mode 2: Run demo. */
160 while (demo_time < real_time)
161 if (demo_replay_step(&t))
172 case 3: /* Mode 3: Fade out. Load title level. */
174 if (real_time > 1.0f)
176 game_init(&title_level, 0, 0);
188 static int title_keybd(int c, int d)
190 if (d && c == SDLK_c && ALLOW_CHEAT)
191 config_tgl_d(CONFIG_CHEAT);
195 static int title_buttn(int b, int d)
199 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
200 return title_action(gui_token(gui_click()));
201 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
207 /*---------------------------------------------------------------------------*/
209 static int help_enter(void)
212 _("Move the mouse or joystick to tilt the floor\\"
213 "causing the ball to roll. Roll over coins to\\"
214 "collect them. Collect coins to unlock the goal\\"
215 "and finish the level. Earn an extra ball for\\"
216 "each 100 coins collected.\\");
218 const char *s4 = _("Left and right mouse buttons rotate the view.");
219 const char *s5 = _("Hold Shift for faster view rotation.");
220 const char *s6 = _("Pause / Release Pointer");
221 const char *s7 = _("Exit / Cancel Menu");
222 const char *s8 = _("Chase View");
223 const char *s9 = _("Lazy View");
224 const char *sA = _("Manual View");
225 const char *sB = _("Comments? Problems? robert.kooima@gmail.com");
227 const char *k0 = _("Spacebar");
228 const char *k1 = _("Escape");
229 const char *k2 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_1));
230 const char *k3 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_2));
231 const char *k4 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_3));
235 if ((id = gui_vstack(0)))
237 gui_multi(id, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
240 if ((jd = gui_harray(id)))
242 gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht);
243 gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel);
245 if ((jd = gui_harray(id)))
247 gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht);
248 gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel);
250 if ((jd = gui_harray(id)))
252 gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht);
253 gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel);
255 if ((jd = gui_harray(id)))
257 gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht);
258 gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel);
260 if ((jd = gui_harray(id)))
262 gui_label(jd, sA, GUI_SML, GUI_SE, gui_wht, gui_wht);
263 gui_label(jd, k4, GUI_SML, GUI_SW, gui_yel, gui_yel);
267 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
268 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
270 gui_label(id, sB, GUI_SML, GUI_ALL, gui_wht, gui_wht);
272 gui_layout(id, 0, 0);
277 static int help_click(int b, int d)
279 return d ? goto_state(&st_title) : 1;
282 static int help_keybd(int c, int d)
284 return d ? goto_state(&st_title) : 1;
287 static int help_buttn(int b, int d)
289 return d ? goto_state(&st_title) : 1;
292 /*---------------------------------------------------------------------------*/
294 struct state st_title = {
307 struct state st_help = {