-/*
+/*
* Copyright (C) 2003 Robert Kooima
*
* NEVERBALL is free software; you can redistribute it and/or modify
#include "game.h"
#include "util.h"
#include "demo.h"
-#include "level.h"
+#include "progress.h"
#include "audio.h"
#include "config.h"
+#include "st_shared.h"
#include "st_done.h"
#include "st_start.h"
/*---------------------------------------------------------------------------*/
#define DONE_OK 1
-#define DONE_NAME 2
-extern struct state st_done_bis;
+/* Bread crumbs. */
-static int high;
-static int time_i;
-static int coin_i;
+static int new_name;
+static int resume;
static int done_action(int i)
{
case DONE_OK:
return goto_state(&st_start);
- case DONE_NAME:
- return goto_name(&st_done_bis);
+ case GUI_NAME:
+ new_name = 1;
+ return goto_name(&st_done, &st_done, 0);
+
+ case GUI_MOST_COINS:
+ case GUI_BEST_TIMES:
+ case GUI_UNLOCK_GOAL:
+ gui_score_set(i);
+ resume = 1;
+ return goto_state(&st_done);
}
return 1;
}
-static int done_init(int * gidp)
+static int done_enter(void)
{
- const char *s1 = _("New Challenge Record");
- const char *s2 = _("Challenge Complete");
+ const char *s1 = _("New Set Record");
+ const char *s2 = _("Set Complete");
int id, jd;
+ int high = progress_set_high();
+
+ if (new_name)
+ {
+ progress_rename(1);
+ new_name = 0;
+ }
+
if ((id = gui_vstack(0)))
{
int gid;
else
gid = gui_label(id, s2, GUI_MED, GUI_ALL, gui_blu, gui_grn);
- if (gidp)
- *gidp = gid;
-
gui_space(id);
- if ((jd = gui_harray(id)))
- {
- gui_most_coins(jd, 3, 1);
- gui_best_times(jd, 3, 1);
- }
+ if ((jd = gui_hstack(id)))
+ gui_score_board(jd, GUI_MOST_COINS |
+ GUI_BEST_TIMES, 1, high);
gui_space(id);
-
- if ((jd = gui_harray(id)))
- {
- if (high)
- gui_state(jd, _("Change Player Name"), GUI_SML, DONE_NAME, 0);
- gui_start(jd, _("OK"), GUI_SML, DONE_OK, 0);
- }
-
- gui_layout(id, 0, 0);
- }
- set_most_coins(0, coin_i);
- set_best_times(0, time_i);
+ gui_start(id, _("Select Level"), GUI_SML, DONE_OK, 0);
- return id;
-}
-
-static int done_enter(void)
-{
- int gid, r;
-
- time_i = 3;
- coin_i = 3;
- high = level_done(&time_i, &coin_i);
-
- r = done_init(&gid);
- gui_pulse(gid, 1.2f);
- return r;
-}
-
-static int done_bis_enter(void)
-{
- char player[MAXNAM];
- config_get_s(CONFIG_PLAYER, player, MAXNAM);
- level_name(0, player, time_i, coin_i);
- return done_init(NULL);
-}
+ if (!resume)
+ gui_pulse(gid, 1.2f);
-static void done_leave(int id)
-{
- gui_delete(id);
-}
+ gui_layout(id, 0, 0);
+ }
-static void done_paint(int id, float st)
-{
- game_draw(0, st);
- gui_paint(id);
-}
+ set_score_board(set_coin_score(curr_set()), progress_score_rank(),
+ set_time_score(curr_set()), progress_times_rank(),
+ set_time_score(curr_set()), progress_times_rank());
-static void done_timer(int id, float dt)
-{
- gui_timer(id, dt);
- audio_timer(dt);
-}
+ /* Reset hack. */
+ resume = 0;
-static void done_point(int id, int x, int y, int dx, int dy)
-{
- gui_pulse(gui_point(id, x, y), 1.2f);
+ return id;
}
-static void done_stick(int id, int a, int v)
+static int done_keybd(int c, int d)
{
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_X, a))
- gui_pulse(gui_stick(id, v, 0), 1.2f);
- if (config_tst_d(CONFIG_JOYSTICK_AXIS_Y, a))
- gui_pulse(gui_stick(id, 0, v), 1.2f);
-}
+ if (d && config_tst_d(CONFIG_KEY_SCORE_NEXT, c))
+ return done_action(gui_score_next(gui_score_get()));
-static int done_click(int b, int d)
-{
- if (b <= 0 && d == 1)
- return done_action(gui_token(gui_click()));
return 1;
}
if (d)
{
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
- return done_click(0, 1);
+ return done_action(gui_token(gui_click()));
if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
return done_action(DONE_OK);
}
struct state st_done = {
done_enter,
- done_leave,
- done_paint,
- done_timer,
- done_point,
- done_stick,
- done_click,
- NULL,
+ shared_leave,
+ shared_paint,
+ shared_timer,
+ shared_point,
+ shared_stick,
+ shared_angle,
+ shared_click,
+ done_keybd,
done_buttn,
1, 0
};
-
-struct state st_done_bis = {
- done_bis_enter,
- done_leave,
- done_paint,
- done_timer,
- done_point,
- done_stick,
- done_click,
- NULL,
- done_buttn,
- 1, 0
-};
-