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"
25 /*---------------------------------------------------------------------------*/
27 struct state st_help_demo;
29 /*---------------------------------------------------------------------------*/
39 static int tab = HELP_RULE;
41 /*---------------------------------------------------------------------------*/
43 static int help_action(int t)
45 audio_play(AUD_MENU, 1.0f);
51 return goto_state(&st_title);
55 demo_replay_init(config_data("gui/demo1.nbr"), NULL);
56 return goto_state(&st_help_demo);
60 demo_replay_init(config_data("gui/demo2.nbr"), NULL);
61 return goto_state(&st_help_demo);
66 return goto_state(&st_help);
72 /* -------------------------------------------------------------------------- */
74 static int help_button(int id, const char *text, int token)
76 int jd = gui_state(id, text, GUI_SML, token, (token == tab));
84 static int help_menu(int id)
90 if ((jd = gui_harray(id)))
92 help_button(jd, _("Techniques"), HELP_TECH);
93 help_button(jd, _("Modes"), HELP_MODE);
94 help_button(jd, _("Controls"), HELP_CONT);
95 help_button(jd, _("Rules"), HELP_RULE);
96 help_button(jd, _("Back"), HELP_BACK);
101 /* -------------------------------------------------------------------------- */
103 static int help_rules(int id)
106 "Move the mouse or joystick\\"
107 "or use keyboard arrows to\\"
108 "tilt the floor causing the\\"
111 "Roll over coins to collect\\"
112 "them. Collect coins to\\"
113 "unlock the goal and finish\\"
116 int w = config_get_d(CONFIG_WIDTH);
117 int h = config_get_d(CONFIG_HEIGHT);
121 if ((jd = gui_hstack(id)))
125 if ((kd = gui_varray(jd)))
127 if ((ld = gui_vstack(kd)))
130 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
134 if ((ld = gui_vstack(kd)))
137 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
144 if ((kd = gui_varray(jd)))
146 if ((ld = gui_vstack(kd)))
149 gui_image(ld, "gui/help1.jpg", 5 * w / 16, 5 * h / 16);
153 if ((ld = gui_vstack(kd)))
156 gui_image(ld, "gui/help2.jpg", 5 * w / 16, 5 * h / 16);
166 static int help_controls(int id)
168 const char *s4 = _("Left and right mouse buttons rotate the view.");
169 const char *s5 = _("Hold Shift for faster view rotation.");
170 const char *s6 = _("Pause / Release Pointer");
171 const char *s7 = _("Exit / Cancel Menu");
172 const char *s8 = _("Chase View");
173 const char *s9 = _("Lazy View");
174 const char *sA = _("Manual View");
175 const char *sC = _("Screenshot");
176 const char *sD = _("Toggle Fullscreen");
178 const char *k0 = _(SDL_GetKeyName(config_get_d(CONFIG_KEY_PAUSE)));
179 const char *k1 = _("Escape");
180 const char *k2 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_1));
181 const char *k3 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_2));
182 const char *k4 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_3));
183 const char *k6 = SDL_GetKeyName(SDLK_F10);
184 const char *k7 = SDL_GetKeyName(SDLK_F11);
190 if ((jd = gui_harray(id)))
192 gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht);
193 gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel);
195 if ((jd = gui_harray(id)))
197 gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht);
198 gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel);
200 if ((jd = gui_harray(id)))
202 gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht);
203 gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel);
205 if ((jd = gui_harray(id)))
207 gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht);
208 gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel);
210 if ((jd = gui_harray(id)))
212 gui_label(jd, sA, GUI_SML, 0, gui_wht, gui_wht);
213 gui_label(jd, k4, GUI_SML, 0, gui_yel, gui_yel);
215 if ((jd = gui_harray(id)))
217 gui_label(jd, sC, GUI_SML, 0, gui_wht, gui_wht);
218 gui_label(jd, k6, GUI_SML, 0, gui_yel, gui_yel);
220 if ((jd = gui_harray(id)))
222 gui_label(jd, sD, GUI_SML, GUI_SE, gui_wht, gui_wht);
223 gui_label(jd, k7, GUI_SML, GUI_SW, gui_yel, gui_yel);
228 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
229 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
234 static int help_modes(int id)
240 if ((jd = gui_hstack(id)))
244 if ((kd = gui_vstack(jd)))
246 gui_label(kd, _("Normal Mode"), GUI_SML, GUI_TOP, 0, 0);
248 _("Finish a level before the time runs out.\\"
249 "You need to collect coins in order to open the goal."),
250 GUI_SML, GUI_BOT, gui_wht, gui_wht);
254 gui_label(kd, _("Practice Mode"), GUI_SML, GUI_TOP, 0, 0);
256 _("Play without time limit or coin constraint.\\"
257 "Levels cannot be unlocked in this mode."),
258 GUI_SML, GUI_BOT, gui_wht, gui_wht);
262 gui_label(kd, _("Challenge Mode"), GUI_SML, GUI_TOP, 0, 0);
264 _("Start playing from the first level of the set.\\"
265 "You start with only four balls, do not lose them.\\"
266 "Earn an extra ball for each 100 coins collected."),
267 GUI_SML, GUI_BOT, gui_wht, gui_wht);
275 static int help_techniques(int id)
278 "Corners can be used to jump.\\"
279 "Get rolling and take aim\\"
280 "at the angle. You may be able\\"
281 "to reach new places.\\");
283 "Tilting in 2 directions increases\\"
284 "the slope. Use the manual view\\"
285 "and turn the camera by 45\\"
286 "degrees for best results.\\");
288 int w = config_get_d(CONFIG_WIDTH);
289 int h = config_get_d(CONFIG_HEIGHT);
293 if ((jd = gui_hstack(id)))
297 if ((kd = gui_varray(jd)))
299 if ((ld = gui_vstack(kd)))
302 gui_image(ld, "gui/help3.jpg", w / 4, h / 4);
303 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
306 gui_active(ld, HELP_DEMO_1, 0);
309 if ((ld = gui_vstack(kd)))
312 gui_image(ld, "gui/help4.jpg", w / 4, h / 4);
313 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
316 gui_active(ld, HELP_DEMO_2, 0);
322 if ((kd = gui_varray(jd)))
324 if ((ld = gui_vstack(kd)))
327 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
331 if ((ld = gui_vstack(kd)))
334 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
344 /* -------------------------------------------------------------------------- */
346 static int help_enter(void)
350 if ((id = gui_vstack(0)))
356 case HELP_RULE: help_rules(id); break;
357 case HELP_CONT: help_controls(id); break;
358 case HELP_MODE: help_modes(id); break;
359 case HELP_TECH: help_techniques(id); break;
365 gui_layout(id, 0, +1);
370 static int help_buttn(int b, int d)
374 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
375 return help_action(gui_token(gui_click()));
376 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
377 return help_action(HELP_BACK);
382 /*---------------------------------------------------------------------------*/
384 static float real_time;
385 static float demo_time;
387 static int help_demo_enter(void)
397 static void help_demo_leave(int id)
402 static void help_demo_paint(int id, float st)
407 static void help_demo_timer(int id, float dt)
415 while (demo_time < real_time)
416 if (demo_replay_step(&t))
420 goto_state(&st_help);
425 static int help_demo_buttn(int b, int d)
429 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
430 return goto_state(&st_help);
434 /*---------------------------------------------------------------------------*/
436 struct state st_help = {
449 struct state st_help_demo = {