-/*
+/*
* Copyright (C) 2003 Robert Kooima
*
* NEVERBALL is free software; you can redistribute it and/or modify
/*---------------------------------------------------------------------------*/
-int goto_end_level(void)
-/* Action once the level sequence is ended (from goal or fail states) */
-{
- int mode = curr_lg()->mode;
- if (mode == MODE_SINGLE)
- return 0;
- else if (mode == MODE_CHALLENGE)
- return goto_state(&st_over);
- else
- return goto_state(&st_start);
-}
-
-
-/*---------------------------------------------------------------------------*/
-
-#define START_BACK -1
-#define START_PRACTICE -2
-#define START_NORMAL -3
+#define START_BACK -1
+#define START_PRACTICE -2
+#define START_NORMAL -3
#define START_CHALLENGE -4
static int shot_id;
static void gui_level(int id, int i)
{
+ const GLfloat *fore, *back;
+
const struct set *s = curr_set();
const struct level *l;
- int jd = 0;
- const GLfloat *fore, *back;
-
+
+ int jd;
+
if (!set_level_exists(s, i))
{
gui_space(id);
return;
}
-
+
l = get_level(i);
-
+
if (!l->is_locked)
{
- fore = l->is_bonus ? gui_grn : gui_wht;
- back = l->is_completed ? fore : gui_yel;
+ fore = l->is_bonus ? gui_grn : gui_wht;
+ back = l->is_completed ? fore : gui_yel;
}
else
fore = back = gui_gry;
- jd = gui_label(id, l->numbername, GUI_SML, GUI_ALL, back, fore);
+
+ jd = gui_label(id, l->repr, GUI_SML, GUI_ALL, back, fore);
+
gui_active(jd, i, 0);
}
-static void start_over_level(i)
+static void start_over_level(int i)
{
const struct level *l = get_level(i);
- if (!l->is_locked || config_get_d(CONFIG_CHEAT))
+ if (!l->is_locked || config_cheat())
{
gui_set_image(shot_id, l->shot);
- set_most_coins(&l->coin_score, -1);
+ set_most_coins(&l->score.most_coins, -1);
- if (config_get_d(CONFIG_MODE) == MODE_PRACTICE)
+ if (curr_mode() == MODE_PRACTICE)
{
- set_best_times(&l->time_score, -1, 0);
+ set_best_times(&l->score.best_times, -1, 0);
if (l->is_bonus)
gui_set_label(status_id,
_("Play this bonus level in practice mode"));
}
else
{
- set_best_times(&l->goal_score, -1, 1);
+ set_best_times(&l->score.unlock_goal, -1, 1);
if (l->is_bonus)
gui_set_label(status_id,
_("Play this bonus level in normal mode"));
else
gui_set_label(status_id, _("Play this level in normal mode"));
}
- if (config_get_d(CONFIG_CHEAT))
+ if (config_cheat())
{
gui_set_label(status_id, l->file);
}
_("Finish previous levels to unlock this level"));
}
-static void start_over(id)
+static void start_over(int id)
{
int i;
gui_pulse(id, 1.2f);
if (id == 0)
return;
-
+
i = gui_token(id);
-
+
switch (i)
{
set_best_times(&curr_set()->time_score, -1, 0);
gui_set_label(status_id, _("Challenge all levels from the first one"));
break;
-
+
case START_NORMAL:
gui_set_label(status_id, _("Collect coins and unlock next level"));
break;
-
+
case START_PRACTICE:
gui_set_label(status_id, _("Train yourself without time nor coin"));
break;
}
-
+
if (i >= 0)
start_over_level(i);
}
static int start_action(int i)
{
- int mode = config_get_d(CONFIG_MODE);
+ int mode = curr_mode();
+
audio_play(AUD_MENU, 1.0f);
- if (i == START_BACK)
- return goto_state(&st_set);
- else if (i == START_NORMAL)
+ switch (i)
{
- config_set_d(CONFIG_MODE, MODE_NORMAL);
+ case START_BACK:
+ return goto_state(&st_set);
+ case START_NORMAL:
+ mode_set(MODE_NORMAL);
return goto_state(&st_start);
- }
- else if (i == START_PRACTICE)
- {
- config_set_d(CONFIG_MODE, MODE_PRACTICE);
+ case START_PRACTICE:
+ mode_set(MODE_PRACTICE);
return goto_state(&st_start);
}
-
+
if (i == START_CHALLENGE)
{
/* On cheat, start challenge mode where you want */
- if (config_get_d(CONFIG_CHEAT))
+ if (config_cheat())
{
- config_set_d(CONFIG_MODE, MODE_CHALLENGE);
+ mode_set(MODE_CHALLENGE);
return goto_state(&st_start);
}
i = 0;
if (i >= 0)
{
const struct level *l = get_level(i);
- if (!l->is_locked || config_get_d(CONFIG_CHEAT))
+
+ if (!l->is_locked || config_cheat())
{
- level_play(l, mode);
- return goto_state(&st_level);
+ if (level_play(l, mode))
+ {
+ return goto_state(&st_level);
+ }
+ else
+ {
+ level_stop();
+ return 1;
+ }
}
}
return 1;
{
int w = config_get_d(CONFIG_WIDTH);
int h = config_get_d(CONFIG_HEIGHT);
- int m = config_get_d(CONFIG_MODE);
+ int m = curr_mode();
int i, j;
int id, jd, kd, ld;
- /* Desactivate cheat */
- if (m == MODE_CHALLENGE && !config_get_d(CONFIG_CHEAT))
+ /* Deactivate cheat */
+
+ if (m == MODE_CHALLENGE && !config_cheat())
{
+ mode_set(MODE_NORMAL);
m = MODE_NORMAL;
- config_set_d(CONFIG_MODE, m);
}
-
+
if ((id = gui_vstack(0)))
{
if ((jd = gui_hstack(id)))
{
-
- gui_label(jd, _(curr_set()->name), GUI_SML, GUI_ALL, gui_yel, gui_red);
+
+ gui_label(jd, _(curr_set()->name), GUI_SML, GUI_ALL,
+ gui_yel, gui_red);
gui_filler(jd);
- if (set_completed(curr_set()))
- {
- gui_label(jd, _("Set Complete"), GUI_SML, GUI_ALL, gui_yel, gui_grn);
- gui_filler(jd);
- }
gui_start(jd, _("Back"), GUI_SML, START_BACK, 0);
}
-
+
if ((jd = gui_harray(id)))
{
shot_id = gui_image(jd, curr_set()->shot, 7 * w / 16, 7 * h / 16);
for (j = 4; j >= 0; j--)
gui_level(ld, i * 5 + j);
- gui_state(kd, _("Challenge"), GUI_SML, START_CHALLENGE ,
+ gui_state(kd, _("Challenge"), GUI_SML, START_CHALLENGE,
m == MODE_CHALLENGE);
}
}
gui_most_coins(jd, 0);
gui_best_times(jd, 0);
}
-
gui_space(id);
-
+
status_id = gui_label(id, _("Choose a level to play"), GUI_SML, GUI_ALL,
gui_yel, gui_wht);
-
+
gui_layout(id, 0, 0);
-
+
set_most_coins(NULL, -1);
set_best_times(NULL, -1, m != MODE_PRACTICE);
}
+ audio_music_fade_to(0.5f, "bgm/inter.ogg");
+
return id;
}
{
int x = (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a)) ? v : 0;
int y = (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a)) ? v : 0;
-
+
start_over(gui_stick(id, x, y));
}
static int start_keybd(int c, int d)
{
- if (d && c == SDLK_c && config_get_d(CONFIG_CHEAT))
+ if (d && c == SDLK_c && config_cheat())
{
set_cheat();
return goto_state(&st_start);
}
-
+
if (d && c == SDLK_F12)
{
int i;