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"
26 /*---------------------------------------------------------------------------*/
36 static int tab = HELP_RULE;
38 /*---------------------------------------------------------------------------*/
40 static int help_action(int t)
42 audio_play(AUD_MENU, 1.0f);
48 return goto_state(&st_title);
52 if (demo_replay_init(config_data("gui/demo1.nbr"),
53 NULL, NULL, NULL, NULL, NULL))
54 return goto_state(&st_help_demo);
58 if (demo_replay_init(config_data("gui/demo2.nbr"),
59 NULL, NULL, NULL, NULL, NULL))
60 return goto_state(&st_help_demo);
65 return goto_state(&st_help);
71 /* -------------------------------------------------------------------------- */
73 static int help_button(int id, const char *text, int token)
75 int jd = gui_state(id, text, GUI_SML, token, (token == tab));
83 static int help_menu(int id)
89 if ((jd = gui_harray(id)))
91 help_button(jd, _("Techniques"), HELP_TECH);
92 help_button(jd, _("Modes"), HELP_MODE);
93 help_button(jd, _("Controls"), HELP_CONT);
94 help_button(jd, _("Rules"), HELP_RULE);
95 help_button(jd, _("Back"), HELP_BACK);
100 /* -------------------------------------------------------------------------- */
102 static int help_rules(int id)
105 "Move the mouse or joystick\\"
106 "or use keyboard arrows to\\"
107 "tilt the floor causing the\\"
110 "Roll over coins to collect\\"
111 "them. Collect coins to\\"
112 "unlock the goal and finish\\"
115 int w = config_get_d(CONFIG_WIDTH);
116 int h = config_get_d(CONFIG_HEIGHT);
120 if ((jd = gui_hstack(id)))
124 if ((kd = gui_varray(jd)))
126 if ((ld = gui_vstack(kd)))
129 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
133 if ((ld = gui_vstack(kd)))
136 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
143 if ((kd = gui_varray(jd)))
145 if ((ld = gui_vstack(kd)))
148 gui_image(ld, "gui/help1.jpg", 5 * w / 16, 5 * h / 16);
152 if ((ld = gui_vstack(kd)))
155 gui_image(ld, "gui/help2.jpg", 5 * w / 16, 5 * h / 16);
165 static int help_controls(int id)
167 const char *s4 = _("Left and right mouse buttons rotate the view.");
168 const char *s5 = _("Hold Shift for faster view rotation.");
169 const char *s6 = _("Pause / Release Pointer");
170 const char *s7 = _("Exit / Cancel Menu");
171 const char *s8 = _("Chase View");
172 const char *s9 = _("Lazy View");
173 const char *sA = _("Manual View");
174 const char *sC = _("Screenshot");
176 const char *k0 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_PAUSE));
177 const char *k1 = pretty_keyname(SDLK_ESCAPE);
178 const char *k2 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_1));
179 const char *k3 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_2));
180 const char *k4 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_3));
181 const char *k6 = pretty_keyname(SDLK_F10);
187 if ((jd = gui_harray(id)))
189 gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht);
190 gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel);
192 if ((jd = gui_harray(id)))
194 gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht);
195 gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel);
197 if ((jd = gui_harray(id)))
199 gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht);
200 gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel);
202 if ((jd = gui_harray(id)))
204 gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht);
205 gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel);
207 if ((jd = gui_harray(id)))
209 gui_label(jd, sA, GUI_SML, 0, gui_wht, gui_wht);
210 gui_label(jd, k4, GUI_SML, 0, gui_yel, gui_yel);
212 if ((jd = gui_harray(id)))
214 gui_label(jd, sC, GUI_SML, 0, gui_wht, gui_wht);
215 gui_label(jd, k6, GUI_SML, 0, gui_yel, gui_yel);
220 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
221 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
226 static int help_modes(int id)
232 if ((jd = gui_hstack(id)))
236 if ((kd = gui_vstack(jd)))
238 gui_label(kd, _("Normal Mode"), GUI_SML, GUI_TOP, 0, 0);
240 _("Finish a level before the time runs out.\\"
241 "You need to collect coins in order to open the goal."),
242 GUI_SML, GUI_BOT, gui_wht, gui_wht);
246 gui_label(kd, _("Challenge Mode"), GUI_SML, GUI_TOP, 0, 0);
248 _("Start playing from the first level of the set.\\"
249 "You start with only three balls, do not lose them.\\"
250 "Earn an extra ball for each 100 coins collected."),
251 GUI_SML, GUI_BOT, gui_wht, gui_wht);
259 static int help_techniques(int id)
262 "Corners can be used to jump.\\"
263 "Get rolling and take aim\\"
264 "at the angle. You may be able\\"
265 "to reach new places.\\");
267 "Tilting in 2 directions increases\\"
268 "the slope. Use the manual view\\"
269 "and turn the camera by 45\\"
270 "degrees for best results.\\");
272 int w = config_get_d(CONFIG_WIDTH);
273 int h = config_get_d(CONFIG_HEIGHT);
277 if ((jd = gui_hstack(id)))
281 if ((kd = gui_varray(jd)))
283 if ((ld = gui_vstack(kd)))
286 gui_image(ld, "gui/help3.jpg", w / 4, h / 4);
287 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
290 gui_active(ld, HELP_DEMO_1, 0);
293 if ((ld = gui_vstack(kd)))
296 gui_image(ld, "gui/help4.jpg", w / 4, h / 4);
297 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
300 gui_active(ld, HELP_DEMO_2, 0);
306 if ((kd = gui_varray(jd)))
308 if ((ld = gui_vstack(kd)))
311 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
315 if ((ld = gui_vstack(kd)))
318 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
328 /* -------------------------------------------------------------------------- */
330 static int help_enter(void)
334 if ((id = gui_vstack(0)))
340 case HELP_RULE: help_rules(id); break;
341 case HELP_CONT: help_controls(id); break;
342 case HELP_MODE: help_modes(id); break;
343 case HELP_TECH: help_techniques(id); break;
349 gui_layout(id, 0, +1);
354 static int help_buttn(int b, int d)
358 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
359 return help_action(gui_token(gui_click()));
360 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
361 return help_action(HELP_BACK);
366 /*---------------------------------------------------------------------------*/
368 static int help_demo_enter(void)
375 static void help_demo_leave(int id)
380 static void help_demo_paint(int id, float t)
385 static void help_demo_timer(int id, float dt)
389 if (!demo_replay_step(dt))
390 goto_state(&st_help);
393 static int help_demo_buttn(int b, int d)
397 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
398 return goto_state(&st_help);
402 /*---------------------------------------------------------------------------*/
404 struct state st_help = {
418 struct state st_help_demo = {