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 "game_common.h"
22 #include "game_server.h"
23 #include "game_client.h"
25 #include "st_shared.h"
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 if (demo_replay_init(config_data("gui/demo1.nbr"),
56 NULL, NULL, NULL, NULL, NULL))
57 return goto_state(&st_help_demo);
61 if (demo_replay_init(config_data("gui/demo2.nbr"),
62 NULL, NULL, NULL, NULL, NULL))
63 return goto_state(&st_help_demo);
68 return goto_state(&st_help);
74 /* -------------------------------------------------------------------------- */
76 static int help_button(int id, const char *text, int token)
78 int jd = gui_state(id, text, GUI_SML, token, (token == tab));
86 static int help_menu(int id)
92 if ((jd = gui_harray(id)))
94 help_button(jd, _("Techniques"), HELP_TECH);
95 help_button(jd, _("Modes"), HELP_MODE);
96 help_button(jd, _("Controls"), HELP_CONT);
97 help_button(jd, _("Rules"), HELP_RULE);
98 help_button(jd, _("Back"), HELP_BACK);
103 /* -------------------------------------------------------------------------- */
105 static int help_rules(int id)
108 "Move the mouse or joystick\\"
109 "or use keyboard arrows to\\"
110 "tilt the floor causing the\\"
113 "Roll over coins to collect\\"
114 "them. Collect coins to\\"
115 "unlock the goal and finish\\"
118 int w = config_get_d(CONFIG_WIDTH);
119 int h = config_get_d(CONFIG_HEIGHT);
123 if ((jd = gui_hstack(id)))
127 if ((kd = gui_varray(jd)))
129 if ((ld = gui_vstack(kd)))
132 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
136 if ((ld = gui_vstack(kd)))
139 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
146 if ((kd = gui_varray(jd)))
148 if ((ld = gui_vstack(kd)))
151 gui_image(ld, "gui/help1.jpg", 5 * w / 16, 5 * h / 16);
155 if ((ld = gui_vstack(kd)))
158 gui_image(ld, "gui/help2.jpg", 5 * w / 16, 5 * h / 16);
168 static int help_controls(int id)
170 const char *s4 = _("Left and right mouse buttons rotate the view.");
171 const char *s5 = _("Hold Shift for faster view rotation.");
172 const char *s6 = _("Pause / Release Pointer");
173 const char *s7 = _("Exit / Cancel Menu");
174 const char *s8 = _("Chase View");
175 const char *s9 = _("Lazy View");
176 const char *sA = _("Manual View");
177 const char *sC = _("Screenshot");
179 const char *k0 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_PAUSE));
180 const char *k1 = pretty_keyname(SDLK_ESCAPE);
181 const char *k2 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_1));
182 const char *k3 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_2));
183 const char *k4 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_3));
184 const char *k6 = pretty_keyname(SDLK_F10);
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);
223 gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht);
224 gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht);
229 static int help_modes(int id)
235 if ((jd = gui_hstack(id)))
239 if ((kd = gui_vstack(jd)))
241 gui_label(kd, _("Normal Mode"), GUI_SML, GUI_TOP, 0, 0);
243 _("Finish a level before the time runs out.\\"
244 "You need to collect coins in order to open the goal."),
245 GUI_SML, GUI_BOT, gui_wht, gui_wht);
249 gui_label(kd, _("Challenge Mode"), GUI_SML, GUI_TOP, 0, 0);
251 _("Start playing from the first level of the set.\\"
252 "You start with only three balls, do not lose them.\\"
253 "Earn an extra ball for each 100 coins collected."),
254 GUI_SML, GUI_BOT, gui_wht, gui_wht);
262 static int help_techniques(int id)
265 "Corners can be used to jump.\\"
266 "Get rolling and take aim\\"
267 "at the angle. You may be able\\"
268 "to reach new places.\\");
270 "Tilting in 2 directions increases\\"
271 "the slope. Use the manual view\\"
272 "and turn the camera by 45\\"
273 "degrees for best results.\\");
275 int w = config_get_d(CONFIG_WIDTH);
276 int h = config_get_d(CONFIG_HEIGHT);
280 if ((jd = gui_hstack(id)))
284 if ((kd = gui_varray(jd)))
286 if ((ld = gui_vstack(kd)))
289 gui_image(ld, "gui/help3.jpg", w / 4, h / 4);
290 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
293 gui_active(ld, HELP_DEMO_1, 0);
296 if ((ld = gui_vstack(kd)))
299 gui_image(ld, "gui/help4.jpg", w / 4, h / 4);
300 gui_state(ld, _("Watch demo"), GUI_SML, 0, 0);
303 gui_active(ld, HELP_DEMO_2, 0);
309 if ((kd = gui_varray(jd)))
311 if ((ld = gui_vstack(kd)))
314 gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht);
318 if ((ld = gui_vstack(kd)))
321 gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht);
331 /* -------------------------------------------------------------------------- */
333 static int help_enter(void)
337 if ((id = gui_vstack(0)))
343 case HELP_RULE: help_rules(id); break;
344 case HELP_CONT: help_controls(id); break;
345 case HELP_MODE: help_modes(id); break;
346 case HELP_TECH: help_techniques(id); break;
352 gui_layout(id, 0, +1);
357 static int help_buttn(int b, int d)
361 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
362 return help_action(gui_token(gui_click()));
363 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
364 return help_action(HELP_BACK);
369 /*---------------------------------------------------------------------------*/
371 static int help_demo_enter(void)
373 game_set_fly(0.f, game_client_file());
374 game_client_step(NULL);
378 static void help_demo_leave(int id)
383 static void help_demo_paint(int id, float t)
388 static void help_demo_timer(int id, float dt)
392 if (!demo_replay_step(dt))
393 goto_state(&st_help);
396 static int help_demo_buttn(int b, int d)
400 if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
401 return goto_state(&st_help);
405 /*---------------------------------------------------------------------------*/
407 struct state st_help = {
421 struct state st_help_demo = {