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.
22 #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 int title_enter(void)
67 /* Build the title GUI. */
69 if ((id = gui_vstack(0)))
71 gui_label(id, _("Neverball"), GUI_LRG, GUI_ALL, 0, 0);
74 if ((jd = gui_harray(id)))
78 if ((kd = gui_varray(jd)))
80 gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1);
81 gui_state(kd, sgettext("menu^Replay"), GUI_MED, TITLE_DEMO, 0);
82 gui_state(kd, sgettext("menu^Help"), GUI_MED, TITLE_HELP, 0);
83 gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0);
84 gui_state(kd, sgettext("menu^Exit"), GUI_MED, TITLE_EXIT, 0);
92 /* Start the title screen music. */
94 audio_music_fade_to(0.5f, "bgm/title.ogg");
96 /* Initialize the first level of the first set for display. */
98 game_init("map-rlk/title.sol", "map-back/jupiter.sol", "png/space.png", 0, 0);
107 static void title_leave(int id)
113 static void title_timer(int id, float dt)
115 static const char *demo = NULL;
122 case 0: /* Mode 0: Pan across title level. */
124 if (real_time <= 20.0f)
125 game_set_fly(fcosf(V_PI * real_time / 20.0f));
134 case 1: /* Mode 1: Fade out. Load demo level. */
136 if (real_time > 1.0f)
138 if ((demo = demo_pick()))
140 demo_replay_init(demo, NULL, NULL, NULL, NULL);
154 case 2: /* Mode 2: Run demo. */
156 while (demo_time < real_time)
157 if (demo_replay_step(&t))
168 case 3: /* Mode 3: Fade out. Load title level. */
170 if (real_time > 1.0f)
172 game_init("map-rlk/title.sol", "map-back/jupiter.sol", "png/space.png", 0, 0);
184 static int title_keybd(int c, int d)
186 if (d && c == SDLK_c && ALLOW_CHEAT)
187 config_tgl_d(CONFIG_CHEAT);
191 static int title_buttn(int b, int d)
195 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
196 return title_action(gui_token(gui_click()));
197 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
203 /*---------------------------------------------------------------------------*/
205 static int help_enter(void)
208 _("Move the mouse or joystick to tilt the floor\\"
209 "causing the ball to roll. Roll over coins to\\"
210 "collect them. Collect coins to unlock the goal\\"
211 "and finish the level. Earn an extra ball for\\"
212 "each 100 coins collected.\\");
214 const char *s4 = _("Left and right mouse buttons rotate the view.");
215 const char *s5 = _("Hold Shift for faster view rotation.");
216 const char *s6 = _("Pause / Release Pointer");
217 const char *s7 = _("Exit / Cancel Menu");
218 const char *s8 = _("Chase View");
219 const char *s9 = _("Lazy View");
220 const char *sA = _("Manual View");
221 const char *sB = _("Comments? Problems? robert.kooima@gmail.com");
223 const char *k0 = _("Spacebar");
224 const char *k1 = _("Escape");
225 const char *k2 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_1));
226 const char *k3 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_2));
227 const char *k4 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_3));
231 if ((id = gui_vstack(0)))
233 gui_multi(id, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
236 if ((jd = gui_harray(id)))
238 gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht);
239 gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel);
241 if ((jd = gui_harray(id)))
243 gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht);
244 gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel);
246 if ((jd = gui_harray(id)))
248 gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht);
249 gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel);
251 if ((jd = gui_harray(id)))
253 gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht);
254 gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel);
256 if ((jd = gui_harray(id)))
258 gui_label(jd, sA, GUI_SML, GUI_SE, gui_wht, gui_wht);
259 gui_label(jd, k4, GUI_SML, GUI_SW, gui_yel, gui_yel);
263 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
264 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
266 gui_label(id, sB, GUI_SML, GUI_ALL, gui_wht, gui_wht);
268 gui_layout(id, 0, 0);
273 static void help_paint(int id, float st)
280 static int help_click(int b, int d)
282 return d ? goto_state(&st_title) : 1;
285 static int help_keybd(int c, int d)
287 return d ? goto_state(&st_title) : 1;
290 static int help_buttn(int b, int d)
292 return d ? goto_state(&st_title) : 1;
295 /*---------------------------------------------------------------------------*/
297 struct state st_title = {
310 struct state st_help = {