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 /*---------------------------------------------------------------------------*/
35 static int tab = HELP_RULE;
37 /*---------------------------------------------------------------------------*/
39 static int help_action(int t)
41 audio_play(AUD_MENU, 1.0f);
47 return goto_state(&st_title);
51 if (demo_replay_init(config_data("gui/demo1.nbr"), NULL))
52 return goto_state(&st_help_demo);
56 if (demo_replay_init(config_data("gui/demo2.nbr"), NULL))
57 return goto_state(&st_help_demo);
62 return goto_state(&st_help);
68 /* -------------------------------------------------------------------------- */
70 static int help_button(int id, const char *text, int token)
72 int jd = gui_state(id, text, GUI_SML, token, (token == tab));
80 static int help_menu(int id)
86 if ((jd = gui_harray(id)))
88 help_button(jd, _("Techniques"), HELP_TECH);
89 help_button(jd, _("Modes"), HELP_MODE);
90 help_button(jd, _("Controls"), HELP_CONT);
91 help_button(jd, _("Rules"), HELP_RULE);
92 help_button(jd, _("Back"), HELP_BACK);
97 /* -------------------------------------------------------------------------- */
99 static int help_rules(int id)
102 "Move the mouse or joystick\\"
103 "or use keyboard arrows to\\"
104 "tilt the floor causing the\\"
107 "Roll over coins to collect\\"
108 "them. Collect coins to\\"
109 "unlock the goal and finish\\"
112 int w = config_get_d(CONFIG_WIDTH);
113 int h = config_get_d(CONFIG_HEIGHT);
117 if ((jd = gui_hstack(id)))
121 if ((kd = gui_varray(jd)))
123 if ((ld = gui_vstack(kd)))
126 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
130 if ((ld = gui_vstack(kd)))
133 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
140 if ((kd = gui_varray(jd)))
142 if ((ld = gui_vstack(kd)))
145 gui_image(ld, "gui/help1.jpg", 5 * w / 16, 5 * h / 16);
149 if ((ld = gui_vstack(kd)))
152 gui_image(ld, "gui/help2.jpg", 5 * w / 16, 5 * h / 16);
162 static int help_controls(int id)
164 const char *s4 = _("Left and right mouse buttons rotate the view.");
165 const char *s5 = _("Hold Shift for faster view rotation.");
166 const char *s6 = _("Pause / Release Pointer");
167 const char *s7 = _("Exit / Cancel Menu");
168 const char *s8 = _("Chase View");
169 const char *s9 = _("Lazy View");
170 const char *sA = _("Manual View");
171 const char *sC = _("Screenshot");
173 const char *k0 = _(SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_PAUSE)));
174 const char *k1 = _("Escape");
175 const char *k2 = SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_CAMERA_1));
176 const char *k3 = SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_CAMERA_2));
177 const char *k4 = SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_CAMERA_3));
178 const char *k6 = SDL_GetKeyName(SDLK_F10);
184 if ((jd = gui_harray(id)))
186 gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht);
187 gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel);
189 if ((jd = gui_harray(id)))
191 gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht);
192 gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel);
194 if ((jd = gui_harray(id)))
196 gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht);
197 gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel);
199 if ((jd = gui_harray(id)))
201 gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht);
202 gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel);
204 if ((jd = gui_harray(id)))
206 gui_label(jd, sA, GUI_SML, 0, gui_wht, gui_wht);
207 gui_label(jd, k4, GUI_SML, 0, gui_yel, gui_yel);
209 if ((jd = gui_harray(id)))
211 gui_label(jd, sC, GUI_SML, 0, gui_wht, gui_wht);
212 gui_label(jd, k6, GUI_SML, 0, gui_yel, gui_yel);
217 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
218 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
223 static int help_modes(int id)
229 if ((jd = gui_hstack(id)))
233 if ((kd = gui_vstack(jd)))
235 gui_label(kd, _("Normal Mode"), GUI_SML, GUI_TOP, 0, 0);
237 _("Finish a level before the time runs out.\\"
238 "You need to collect coins in order to open the goal."),
239 GUI_SML, GUI_BOT, gui_wht, gui_wht);
243 gui_label(kd, _("Practice Mode"), GUI_SML, GUI_TOP, 0, 0);
245 _("Play without time limit or coin constraint.\\"
246 "Levels cannot be unlocked in this mode."),
247 GUI_SML, GUI_BOT, gui_wht, gui_wht);
251 gui_label(kd, _("Challenge Mode"), GUI_SML, GUI_TOP, 0, 0);
253 _("Start playing from the first level of the set.\\"
254 "You start with only four balls, do not lose them.\\"
255 "Earn an extra ball for each 100 coins collected."),
256 GUI_SML, GUI_BOT, gui_wht, gui_wht);
264 static int help_techniques(int id)
267 "Corners can be used to jump.\\"
268 "Get rolling and take aim\\"
269 "at the angle. You may be able\\"
270 "to reach new places.\\");
272 "Tilting in 2 directions increases\\"
273 "the slope. Use the manual view\\"
274 "and turn the camera by 45\\"
275 "degrees for best results.\\");
277 int w = config_get_d(CONFIG_WIDTH);
278 int h = config_get_d(CONFIG_HEIGHT);
282 if ((jd = gui_hstack(id)))
286 if ((kd = gui_varray(jd)))
288 if ((ld = gui_vstack(kd)))
291 gui_image(ld, "gui/help3.jpg", w / 4, h / 4);
292 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
295 gui_active(ld, HELP_DEMO_1, 0);
298 if ((ld = gui_vstack(kd)))
301 gui_image(ld, "gui/help4.jpg", w / 4, h / 4);
302 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
305 gui_active(ld, HELP_DEMO_2, 0);
311 if ((kd = gui_varray(jd)))
313 if ((ld = gui_vstack(kd)))
316 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
320 if ((ld = gui_vstack(kd)))
323 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
333 /* -------------------------------------------------------------------------- */
335 static int help_enter(void)
339 if ((id = gui_vstack(0)))
345 case HELP_RULE: help_rules(id); break;
346 case HELP_CONT: help_controls(id); break;
347 case HELP_MODE: help_modes(id); break;
348 case HELP_TECH: help_techniques(id); break;
354 gui_layout(id, 0, +1);
359 static int help_buttn(int b, int d)
363 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
364 return help_action(gui_token(gui_click()));
365 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
366 return help_action(HELP_BACK);
371 /*---------------------------------------------------------------------------*/
373 static int help_demo_enter(void)
380 static void help_demo_leave(int id)
385 static void help_demo_paint(int id, float t)
390 static void help_demo_timer(int id, float dt)
394 if (!demo_replay_step(dt))
395 goto_state(&st_help);
398 static int help_demo_buttn(int b, int d)
402 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
403 return goto_state(&st_help);
407 /*---------------------------------------------------------------------------*/
409 struct state st_help = {
423 struct state st_help_demo = {