* General Public License for more details.
*/
+#include <string.h>
+
#include "gui.h"
#include "vec3.h"
#include "demo.h"
/*---------------------------------------------------------------------------*/
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
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);
+ if (strlen(player) == 0)
+ return goto_name(&st_set, &st_title, 0);
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;
+ 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;
}
-static struct level title_level;
-
static int title_enter(void)
{
int id, jd, kd;
if ((id = gui_vstack(0)))
{
gui_label(id, "Neverball", GUI_LRG, GUI_ALL, 0, 0);
+
gui_space(id);
if ((jd = gui_harray(id)))
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);
audio_music_fade_to(0.5f, "bgm/title.ogg");
/* Initialize the title level for display. */
- level_load("map-rlk/title.sol", &title_level);
- game_init(&title_level, 0, 0);
+
+ game_init("map-medium/title.sol", 0, 1);
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);
}
static void title_timer(int id, float dt)
{
static const char *demo = NULL;
- float t;
real_time += dt;
{
if ((demo = demo_pick()))
{
- demo_replay_init(demo, NULL);
- demo_time = 0.0f;
+ demo_replay_init(demo, NULL, NULL, NULL, NULL, NULL);
+ game_set_fly(0.0f);
real_time = 0.0f;
mode = 2;
}
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. */
if (real_time > 1.0f)
{
- game_init(&title_level, 0, 0);
+ game_init("map-medium/title.sol", 0, 1);
+
real_time = 0.0f;
mode = 0;
}
}
gui_timer(id, dt);
- audio_timer(dt);
game_step_fade(dt);
}
static int title_keybd(int c, int d)
{
- if (d && c == SDLK_c)
- config_tgl_cheat();
+ if (d && (c & 0xFF80) == 0 && c > ' ')
+ return title_action(c);
return 1;
}
title_timer,
shared_point,
shared_stick,
+ shared_angle,
shared_click,
title_keybd,
title_buttn,