#include "st_level.h"
#include "st_play.h"
#include "st_start.h"
+#include "st_over.h"
/*---------------------------------------------------------------------------*/
-static int level_ok;
-
static int level_enter(void)
{
int id, jd, kd, ld;
int b;
const float *textcol1, *textcol2;
- /* Load the level */
- level_ok = level_play_go();
-
if ((id = gui_vstack(0)))
{
- if (lg->mode == MODE_SINGLE)
- {
- gui_label(id, _("Single Level"), GUI_LRG, GUI_TOP, 0, 0);
- }
- else if ((jd = gui_hstack(id)))
+ if ((jd = gui_hstack(id)))
{
ln = lg->level->repr;
b = lg->level->is_bonus;
}
gui_space(id);
- if (!level_ok)
- gui_label(id, _("Cannot load the level file."), GUI_SML, GUI_ALL,
- gui_red, gui_red);
- else if (lg->level->message[0] != '\0')
+ if (strlen(lg->level->message) != 0)
gui_multi(id, _(lg->level->message), GUI_SML, GUI_ALL, gui_wht,
gui_wht);
static void level_timer(int id, float dt)
{
game_step_fade(dt);
- audio_timer(dt);
}
static int level_click(int b, int d)
{
- if (b < 0 && d == 1)
- {
- if (level_ok)
- {
- return goto_state(&st_play_ready);
- }
- else
- {
- level_stop(GAME_NONE, 0, curr_clock(), curr_coins());
- return goto_end_level();
- }
- }
- return 1;
+ return (b < 0 && d == 1) ? goto_state(&st_play_ready) : 1;
}
static int level_keybd(int c, int d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
{
- if (level_ok)
- {
- return goto_state(&st_play_ready);
- }
- else
- {
- level_stop(GAME_NONE, 0, curr_clock(), curr_coins());
-
- return goto_end_level();
- }
+ return goto_state(&st_play_ready);
}
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
{
- level_stop(GAME_NONE, 0, curr_clock(), curr_coins());
- return goto_end_level();
+ level_stat(GAME_NONE, curr_clock(), curr_coins());
+ level_stop();
+ return goto_state(&st_over);
}
}
return 1;
static int poser_buttn(int c, int d)
{
- return (d && config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, c)) ? goto_state(&st_level) : 1;
+ if (d && config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, c))
+ return goto_state(&st_level);
+
+ return 1;
}
/*---------------------------------------------------------------------------*/