X-Git-Url: http://vcs.maemo.org/git/?a=blobdiff_plain;f=ball%2Fst_title.c;h=7d5bf97207d0870f2362bb77c19edb7d2343ee5e;hb=4438862ba8c07519eff35ebf65e55f5a8f221ee3;hp=e5b3f3402d3f5c3c2085d2f3557a96e9dbd59593;hpb=7f6158e711fff2ce40b7040dec09a1a6df3fdbcd;p=neverball diff --git a/ball/st_title.c b/ball/st_title.c index e5b3f34..7d5bf97 100644 --- a/ball/st_title.c +++ b/ball/st_title.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2003 Robert Kooima * * NEVERBALL is free software; you can redistribute it and/or modify @@ -12,11 +12,8 @@ * General Public License for more details. */ -#include - #include "gui.h" #include "vec3.h" -#include "back.h" #include "demo.h" #include "game.h" #include "audio.h" @@ -24,6 +21,7 @@ #include "st_shared.h" #include "st_title.h" +#include "st_help.h" #include "st_demo.h" #include "st_conf.h" #include "st_set.h" @@ -32,9 +30,10 @@ /*---------------------------------------------------------------------------*/ static float real_time = 0.0f; -static float demo_time = 0.0f; static int mode = 0; +static int play_id = 0; + #define TITLE_PLAY 1 #define TITLE_HELP 2 #define TITLE_DEMO 3 @@ -43,21 +42,68 @@ static int mode = 0; static int title_action(int i) { + static const char keyphrase[] = "CHEAT"; + static char queue[sizeof (keyphrase)] = ""; + + size_t queue_len = strlen(queue); + char player[MAXNAM]; + audio_play(AUD_MENU, 1.0f); switch (i) { - case TITLE_PLAY: - config_get_s(CONFIG_PLAYER, player, MAXNAM); - if (player[0] == '\0') - return goto_name(&st_set, &st_title); - else - return goto_state(&st_set); - case TITLE_HELP: return goto_state(&st_help); - case TITLE_DEMO: return goto_state(&st_demo); - case TITLE_CONF: return goto_state(&st_conf); - case TITLE_EXIT: return 0; + case TITLE_PLAY: + config_get_s(CONFIG_PLAYER, player, MAXNAM); + + if (strlen(player) == 0) + return goto_name(&st_set, &st_title, 0); + else + return goto_state(&st_set); + + break; + + case TITLE_HELP: return goto_state(&st_help); break; + case TITLE_DEMO: return goto_state(&st_demo); break; + case TITLE_CONF: return goto_state(&st_conf); break; + case TITLE_EXIT: return 0; break; + + default: + + /* Let the queue fill up. */ + + if (queue_len < sizeof (queue) - 1) + { + queue[queue_len] = (char) i; + queue[queue_len + 1] = '\0'; + } + + /* Advance the queue before adding the new element. */ + + else + { + int k; + + for (k = 1; k < queue_len; k++) + queue[k - 1] = queue[k]; + + queue[queue_len - 1] = (char) i; + } + + if (strcmp(queue, keyphrase) == 0) + { + config_set_cheat(); + gui_set_label(play_id, sgettext("menu^Cheat")); + gui_pulse(play_id, 1.2f); + } + else if (config_cheat()) + { + config_clr_cheat(); + gui_set_label(play_id, sgettext("menu^Play")); + gui_pulse(play_id, 1.2f); + } + + break; } return 1; } @@ -72,7 +118,8 @@ static int title_enter(void) if ((id = gui_vstack(0))) { - gui_label(id, _("Neverball"), GUI_LRG, GUI_ALL, 0, 0); + gui_label(id, "Neverball", GUI_LRG, GUI_ALL, 0, 0); + gui_space(id); if ((jd = gui_harray(id))) @@ -81,7 +128,13 @@ static int title_enter(void) if ((kd = gui_varray(jd))) { - gui_start(kd, sgettext("menu^Play"), GUI_MED, TITLE_PLAY, 1); + if (config_cheat()) + play_id = gui_start(kd, sgettext("menu^Cheat"), + GUI_MED, TITLE_PLAY, 1); + else + play_id = gui_start(kd, sgettext("menu^Play"), + GUI_MED, TITLE_PLAY, 1); + gui_state(kd, sgettext("menu^Replay"), GUI_MED, TITLE_DEMO, 0); gui_state(kd, sgettext("menu^Help"), GUI_MED, TITLE_HELP, 0); gui_state(kd, sgettext("menu^Options"), GUI_MED, TITLE_CONF, 0); @@ -97,22 +150,21 @@ static int title_enter(void) audio_music_fade_to(0.5f, "bgm/title.ogg"); - /* Initialize the first level of the first set for display. */ - strcpy(title_level.file, config_data("map-rlk/title.sol")); - strcpy(title_level.back, "map-back/jupiter.sol"); - strcpy(title_level.grad, "png/space.png"); - + /* Initialize the title level for display. */ + level_load("map-medium/title.sol", &title_level); game_init(&title_level, 0, 0); real_time = 0.0f; - demo_time = 0.0f; mode = 0; + SDL_EnableUNICODE(1); + return id; } static void title_leave(int id) { + SDL_EnableUNICODE(0); demo_replay_stop(0); gui_delete(id); } @@ -120,7 +172,6 @@ static void title_leave(int id) static void title_timer(int id, float dt) { static const char *demo = NULL; - float t; real_time += dt; @@ -145,7 +196,7 @@ static void title_timer(int id, float dt) if ((demo = demo_pick())) { demo_replay_init(demo, NULL); - demo_time = 0.0f; + game_set_fly(0.0f); real_time = 0.0f; mode = 2; } @@ -160,16 +211,13 @@ static void title_timer(int id, float dt) case 2: /* Mode 2: Run demo. */ - while (demo_time < real_time) - if (demo_replay_step(&t)) - demo_time += t; - else - { - demo_replay_stop(0); - game_fade(+1.0f); - real_time = 0.0f; - mode = 3; - } + if (!demo_replay_step(dt)) + { + demo_replay_stop(0); + game_fade(+1.0f); + real_time = 0.0f; + mode = 3; + } break; case 3: /* Mode 3: Fade out. Load title level. */ @@ -184,17 +232,16 @@ static void title_timer(int id, float dt) } gui_timer(id, dt); - audio_timer(dt); game_step_fade(dt); } static int title_keybd(int c, int d) { - if (d && c == SDLK_c && ALLOW_CHEAT) - config_tgl_d(CONFIG_CHEAT); - return 1; + if (d && (c & 0xFF80) == 0 && c > ' ') + return title_action(c); + return 1; } - + static int title_buttn(int b, int d) { if (d) @@ -209,91 +256,6 @@ static int title_buttn(int b, int d) /*---------------------------------------------------------------------------*/ -static int help_enter(void) -{ - const char *s0 = - _("Move the mouse or joystick to tilt the floor\\" - "causing the ball to roll. Roll over coins to\\" - "collect them. Collect coins to unlock the goal\\" - "and finish the level. Earn an extra ball for\\" - "each 100 coins collected.\\"); - - const char *s4 = _("Left and right mouse buttons rotate the view."); - const char *s5 = _("Hold Shift for faster view rotation."); - const char *s6 = _("Pause / Release Pointer"); - const char *s7 = _("Exit / Cancel Menu"); - const char *s8 = _("Chase View"); - const char *s9 = _("Lazy View"); - const char *sA = _("Manual View"); - const char *sB = _("Comments? Problems? robert.kooima@gmail.com"); - - 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)); - - int id, jd; - - if ((id = gui_vstack(0))) - { - gui_multi(id, s0, GUI_SML, GUI_ALL, gui_wht, gui_wht); - gui_space(id); - - 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); - } - - 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(id); - gui_label(id, sB, GUI_SML, GUI_ALL, gui_wht, gui_wht); - - gui_layout(id, 0, 0); - } - return id; -} - -static int help_click(int b, int d) -{ - return d ? goto_state(&st_title) : 1; -} - -static int help_keybd(int c, int d) -{ - return d ? goto_state(&st_title) : 1; -} - -static int help_buttn(int b, int d) -{ - return d ? goto_state(&st_title) : 1; -} - -/*---------------------------------------------------------------------------*/ - struct state st_title = { title_enter, title_leave, @@ -301,21 +263,10 @@ struct state st_title = { title_timer, shared_point, shared_stick, + shared_angle, shared_click, title_keybd, title_buttn, 1, 0 }; -struct state st_help = { - help_enter, - shared_leave, - shared_paint, - shared_timer, - NULL, - NULL, - help_click, - help_keybd, - help_buttn, - 1, 0 -};