X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fst_help.c;h=8618116e73860b7cb3415c1cfe305e29f83d62c0;hb=1745b6a90dfd9e626e5c40d20c6aa595ec41d888;hp=8bed458ab11942d0aac465272afe617121001531;hpb=33852af055a4c36250e09d7c2236b3244d3d2a19;p=neverball diff --git a/ball/st_help.c b/ball/st_help.c index 8bed458..8618116 100644 --- a/ball/st_help.c +++ b/ball/st_help.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify @@ -16,102 +16,153 @@ #include "game.h" #include "audio.h" #include "config.h" -#include "st_shared.h" +#include "demo.h" +#include "keynames.h" +#include "st_shared.h" #include "st_title.h" #include "st_help.h" /*---------------------------------------------------------------------------*/ -#define HELP_BACK 1 -#define HELP_RULE 2 -#define HELP_CONT 3 -#define HELP_MODE 4 -#define HELP_CRED 5 +#define HELP_BACK 0 +#define HELP_RULE 1 +#define HELP_CONT 2 +#define HELP_MODE 3 +#define HELP_TECH 4 +#define HELP_DEMO_1 6 +#define HELP_DEMO_2 7 -extern struct state st_help2; -extern struct state st_help3; -extern struct state st_help4; +static int tab = HELP_RULE; -static int help_action(int i) +/*---------------------------------------------------------------------------*/ + +static int help_action(int t) { audio_play(AUD_MENU, 1.0f); - - switch(i) + + switch (t) { - case HELP_BACK: return goto_state(&st_title); - case HELP_RULE: return goto_state(&st_help); - case HELP_CONT: return goto_state(&st_help2); - case HELP_MODE: return goto_state(&st_help3); - case HELP_CRED: return goto_state(&st_help4); + case HELP_BACK: + tab = HELP_RULE; + return goto_state(&st_title); + break; + + case HELP_DEMO_1: + if (demo_replay_init(config_data("gui/demo1.nbr"), + NULL, NULL, NULL, NULL, NULL)) + return goto_state(&st_help_demo); + break; + + case HELP_DEMO_2: + if (demo_replay_init(config_data("gui/demo2.nbr"), + NULL, NULL, NULL, NULL, NULL)) + return goto_state(&st_help_demo); + break; + + default: + tab = t; + return goto_state(&st_help); + break; } return 1; } -static int help_button(int id, const char *text, int token, int atoken) +/* -------------------------------------------------------------------------- */ + +static int help_button(int id, const char *text, int token) { - int kd = gui_state(id, text, GUI_SML, token, token == atoken); - return kd; + int jd = gui_state(id, text, GUI_SML, token, (token == tab)); + + if (token == tab) + gui_focus(jd); + + return jd; } -static int help_menu(int id, int i) +static int help_menu(int id) { - int jd, kd; - gui_filler(id); + int jd; + + gui_space(id); + if ((jd = gui_harray(id))) { - help_button(jd, _("Credits"), HELP_CRED, i); - help_button(jd, _("Modes"), HELP_MODE, i); - help_button(jd, _("Controls"), HELP_CONT, i); - help_button(jd, _("Rules"), HELP_RULE, i); - kd = help_button(jd, _("Back"), HELP_BACK, i); - gui_focus(kd); + help_button(jd, _("Techniques"), HELP_TECH); + help_button(jd, _("Modes"), HELP_MODE); + help_button(jd, _("Controls"), HELP_CONT); + help_button(jd, _("Rules"), HELP_RULE); + help_button(jd, _("Back"), HELP_BACK); } - gui_filler(id); return jd; } -static int help1_enter(void) +/* -------------------------------------------------------------------------- */ + +static int help_rules(int id) { const char *s0 = _( - "Move the mouse or joystick\\" - "or use keyboard arrows to\\" - "tilt the floor causing the\\" - "ball to roll."); + "Move the mouse or joystick\\" + "or use keyboard arrows to\\" + "tilt the floor causing the\\" + "ball to roll.\\"); const char *s1 = _( - "Roll over coins to collect\\" - "them. Collect coins to\\" - "unlock the goal and finish\\" - "the level."); + "Roll over coins to collect\\" + "them. Collect coins to\\" + "unlock the goal and finish\\" + "the level.\\"); - int w = config_get_d(CONFIG_WIDTH); int h = config_get_d(CONFIG_HEIGHT); - - int id, jd; - if ((id = gui_vstack(0))) + int jd, kd, ld; + + if ((jd = gui_hstack(id))) { - help_menu(id, HELP_RULE); - - if ((jd = gui_hstack(id))) - { - gui_image(jd, "", 6 * w / 16, 6 * h / 16); - gui_filler(jd); - gui_multi(jd, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht); - } - if ((jd = gui_hstack(id))) - { - gui_multi(jd, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht); - gui_filler(jd); - gui_image(jd, "", 6 * w / 16, 6 * h / 16); - } - gui_layout(id, 0, +1); + gui_filler(jd); + + if ((kd = gui_varray(jd))) + { + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht); + gui_filler(ld); + } + + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht); + gui_filler(ld); + } + } + + gui_space(jd); + + if ((kd = gui_varray(jd))) + { + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_image(ld, "gui/help1.jpg", 5 * w / 16, 5 * h / 16); + gui_filler(ld); + } + + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_image(ld, "gui/help2.jpg", 5 * w / 16, 5 * h / 16); + gui_filler(ld); + } + } + + gui_filler(jd); } return id; } -static int help2_enter(void) +static int help_controls(int id) { const char *s4 = _("Left and right mouse buttons rotate the view."); const char *s5 = _("Hold Shift for faster view rotation."); @@ -120,149 +171,184 @@ static int help2_enter(void) const char *s8 = _("Chase View"); const char *s9 = _("Lazy View"); const char *sA = _("Manual View"); - const char *sB = _("Show FPS"); const char *sC = _("Screenshot"); - const char *sD = _("Toggle Fullscreen"); - - const char *k0 = _("Spacebar"); - const char *k1 = _("Escape"); - const char *k2 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_1)); - const char *k3 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_2)); - const char *k4 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_3)); - const char *k5 = SDL_GetKeyName(SDLK_F9); - const char *k6 = SDL_GetKeyName(SDLK_F10); - const char *k7 = SDL_GetKeyName(SDLK_F11); - - int id, jd; - - if ((id = gui_vstack(0))) + + const char *k0 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_PAUSE)); + const char *k1 = pretty_keyname(SDLK_ESCAPE); + const char *k2 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_1)); + const char *k3 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_2)); + const char *k4 = pretty_keyname((SDLKey) config_get_d(CONFIG_KEY_CAMERA_3)); + const char *k6 = pretty_keyname(SDLK_F10); + + int jd; + + gui_space(id); + + if ((jd = gui_harray(id))) { - help_menu(id, HELP_CONT); - - if ((jd = gui_harray(id))) - { - gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht); - gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) - { - gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht); - gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) - { - gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht); - gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) - { - gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht); - gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) - { - gui_label(jd, sA, GUI_SML, GUI_SE, gui_wht, gui_wht); - gui_label(jd, k4, GUI_SML, GUI_SW, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) - { - gui_label(jd, sB, GUI_SML, GUI_SE, gui_wht, gui_wht); - gui_label(jd, k5, GUI_SML, GUI_SW, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) - { - gui_label(jd, sC, GUI_SML, GUI_SE, gui_wht, gui_wht); - gui_label(jd, k6, GUI_SML, GUI_SW, gui_yel, gui_yel); - } - if ((jd = gui_harray(id))) + gui_label(jd, s6, GUI_SML, GUI_NE, gui_wht, gui_wht); + gui_label(jd, k0, GUI_SML, GUI_NW, gui_yel, gui_yel); + } + if ((jd = gui_harray(id))) + { + gui_label(jd, s7, GUI_SML, 0, gui_wht, gui_wht); + gui_label(jd, k1, GUI_SML, 0, gui_yel, gui_yel); + } + if ((jd = gui_harray(id))) + { + gui_label(jd, s8, GUI_SML, 0, gui_wht, gui_wht); + gui_label(jd, k2, GUI_SML, 0, gui_yel, gui_yel); + } + if ((jd = gui_harray(id))) + { + gui_label(jd, s9, GUI_SML, 0, gui_wht, gui_wht); + gui_label(jd, k3, GUI_SML, 0, gui_yel, gui_yel); + } + if ((jd = gui_harray(id))) + { + gui_label(jd, sA, GUI_SML, 0, gui_wht, gui_wht); + gui_label(jd, k4, GUI_SML, 0, gui_yel, gui_yel); + } + if ((jd = gui_harray(id))) + { + gui_label(jd, sC, GUI_SML, 0, gui_wht, gui_wht); + gui_label(jd, k6, GUI_SML, 0, gui_yel, gui_yel); + } + + gui_space(id); + + gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht); + gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht); + + return id; +} + +static int help_modes(int id) +{ + int jd, kd; + + gui_space(id); + + if ((jd = gui_hstack(id))) + { + gui_filler(jd); + + if ((kd = gui_vstack(jd))) { - gui_label(jd, sD, GUI_SML, GUI_SE, gui_wht, gui_wht); - gui_label(jd, k7, GUI_SML, GUI_SW, gui_yel, gui_yel); - } + gui_label(kd, _("Normal Mode"), GUI_SML, GUI_TOP, 0, 0); + gui_multi(kd, + _("Finish a level before the time runs out.\\" + "You need to collect coins in order to open the goal."), + GUI_SML, GUI_BOT, gui_wht, gui_wht); - gui_space(id); - gui_label(id, s4, GUI_SML, GUI_TOP, gui_wht, gui_wht); - gui_label(id, s5, GUI_SML, GUI_BOT, gui_wht, gui_wht); + gui_space(kd); - gui_layout(id, 0, +1); + gui_label(kd, _("Challenge Mode"), GUI_SML, GUI_TOP, 0, 0); + gui_multi(kd, + _("Start playing from the first level of the set.\\" + "You start with only three balls, do not lose them.\\" + "Earn an extra ball for each 100 coins collected."), + GUI_SML, GUI_BOT, gui_wht, gui_wht); + } + + gui_filler(jd); } return id; } -static int help3_enter(void) +static int help_techniques(int id) { - int id, jd; - - if ((id = gui_vstack(0))) + const char *s0 = _( + "Corners can be used to jump.\\" + "Get rolling and take aim\\" + "at the angle. You may be able\\" + "to reach new places.\\"); + const char *s1 = _( + "Tilting in 2 directions increases\\" + "the slope. Use the manual view\\" + "and turn the camera by 45\\" + "degrees for best results.\\"); + + int w = config_get_d(CONFIG_WIDTH); + int h = config_get_d(CONFIG_HEIGHT); + + int jd, kd, ld; + + if ((jd = gui_hstack(id))) { - help_menu(id, HELP_MODE); - - if ((jd = gui_hstack(id))) - gui_label(jd, _("Normal"), GUI_SML, GUI_TOP, 0, 0); - gui_multi(id, - "Finish a level before the time run out.\\" - "You need to collect coins in order to open the goal.", - GUI_SML, GUI_BOT | GUI_RGT, gui_wht, gui_wht); - - gui_space(id); - - if ((jd = gui_hstack(id))) - { - gui_label(jd, _("Practice"), GUI_SML, GUI_TOP, 0, 0); - gui_filler(jd); - } - gui_multi(id, - "Play a level without time or coin constraint.", - GUI_SML, GUI_BOT | GUI_LFT, gui_wht, gui_wht); - - gui_space(id); - - if ((jd = gui_hstack(id))) - gui_label(jd, _("Challenge"), GUI_SML, GUI_TOP, 0, 0); - gui_multi(id, - "Start playing from the first level of the level set.\\" - "You start with only four balls, do not lose them.\\" - "Earn an extra ball for each 100 coins collected.", - GUI_SML, GUI_BOT | GUI_RGT, gui_wht, gui_wht); + gui_filler(jd); - gui_layout(id, 0, +1); + if ((kd = gui_varray(jd))) + { + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_image(ld, "gui/help3.jpg", w / 4, h / 4); + gui_state(ld, _("Watch demo"), GUI_SML, 0, 0); + gui_filler(ld); + + gui_active(ld, HELP_DEMO_1, 0); + } + + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_image(ld, "gui/help4.jpg", w / 4, h / 4); + gui_state(ld, _("Watch demo"), GUI_SML, 0, 0); + gui_filler(ld); + + gui_active(ld, HELP_DEMO_2, 0); + } + } + + gui_space(jd); + + if ((kd = gui_varray(jd))) + { + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_multi(ld, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht); + gui_filler(ld); + } + + if ((ld = gui_vstack(kd))) + { + gui_space(ld); + gui_multi(ld, s1, GUI_SML, GUI_ALL, gui_wht, gui_wht); + gui_filler(ld); + } + } + + gui_filler(jd); } return id; - } -static int help4_enter(void) +/* -------------------------------------------------------------------------- */ + +static int help_enter(void) { int id; - + if ((id = gui_vstack(0))) { - help_menu(id, HELP_CRED); - - gui_label(id, _("LEAD MAINTAINER"), GUI_SML, GUI_TOP, 0, 0); - gui_label(id, "Robert Kooima ", GUI_SML, GUI_BOT , gui_wht, gui_wht); - - gui_space(id); - - gui_label(id, _("DEVELOPERS"), GUI_SML, GUI_TOP, 0, 0); - gui_label(id, "Robert Kooima - Jean Privat", GUI_SML, GUI_BOT , gui_wht, gui_wht); - - gui_space(id); - - gui_label(id, _("LEVEL CONTRIBUTION"), GUI_SML, GUI_TOP, 0, 0); - gui_multi(id, "Pasi Kallinen - Robert Kooima\\Michael Middleton - Jānis Rūcis\\Paul Tompkins - Mehdi Yousfi-Monod", GUI_SML, GUI_BOT , gui_wht, gui_wht); - - gui_space(id); - - gui_label(id, _("TRANSLATION"), GUI_SML, GUI_TOP, 0, 0); - gui_multi(id, "French: Jean Privat - Mehdi Yousfi-Monod\\" - "German: Georg Wachter\\" - "Latavian: Jānis Rūcis", GUI_SML, GUI_BOT , gui_wht, gui_wht); - + help_menu(id); + + switch (tab) + { + case HELP_RULE: help_rules(id); break; + case HELP_CONT: help_controls(id); break; + case HELP_MODE: help_modes(id); break; + case HELP_TECH: help_techniques(id); break; + + default: + break; + } + gui_layout(id, 0, +1); } return id; - } static int help_buttn(int b, int d) @@ -279,54 +365,66 @@ static int help_buttn(int b, int d) /*---------------------------------------------------------------------------*/ +static int help_demo_enter(void) +{ + game_set_fly(0.f); + + return 0; +} + +static void help_demo_leave(int id) +{ + demo_replay_stop(0); +} + +static void help_demo_paint(int id, float t) +{ + game_draw(0, t); +} + +static void help_demo_timer(int id, float dt) +{ + game_step_fade(dt); + + if (!demo_replay_step(dt)) + goto_state(&st_help); +} + +static int help_demo_buttn(int b, int d) +{ + if (d) + { + if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b)) + return goto_state(&st_help); + } + return 1; +} +/*---------------------------------------------------------------------------*/ + struct state st_help = { - help1_enter, + help_enter, shared_leave, shared_paint, shared_timer, shared_point, shared_stick, + shared_angle, shared_click, NULL, help_buttn, 1, 0 }; -struct state st_help2 = { - help2_enter, - shared_leave, - shared_paint, - shared_timer, - shared_point, - shared_stick, - shared_click, +struct state st_help_demo = { + help_demo_enter, + help_demo_leave, + help_demo_paint, + help_demo_timer, NULL, - help_buttn, - 1, 0 -}; - -struct state st_help3 = { - help3_enter, - shared_leave, - shared_paint, - shared_timer, - shared_point, - shared_stick, - shared_click, NULL, - help_buttn, - 1, 0 -}; - -struct state st_help4 = { - help4_enter, - shared_leave, - shared_paint, - shared_timer, - shared_point, - shared_stick, - shared_click, NULL, - help_buttn, + NULL, + NULL, + help_demo_buttn, 1, 0 };