/*---------------------------------------------------------------------------*/
+struct set
+{
+ char file[PATHMAX];
+
+ char *id; /* Internal set identifier */
+ char *name; /* Set name */
+ char *desc; /* Set description */
+ char *shot; /* Set screen-shot */
+
+ char user_scores[PATHMAX]; /* User high-score file */
+
+ struct score time_score; /* Challenge score */
+ struct score coin_score; /* Challenge score */
+
+ /* Level stats */
+
+ unsigned int count; /* Number of levels */
+};
+
static int set_state = 0;
static int set;
/*---------------------------------------------------------------------------*/
-int set_exists(int i)
+int set_exists(int i)
{
return (0 <= i && i < count);
}
-const struct set *get_set(int i)
+const char *set_name(int i)
{
- return set_exists(i) ? &set_v[i] : NULL;
+ return set_exists(i) ? _(set_v[i].name) : NULL;
}
-/*---------------------------------------------------------------------------*/
+const char *set_desc(int i)
+{
+ return set_exists(i) ? _(set_v[i].desc) : NULL;
+}
-int set_level_exists(const struct set *s, int i)
+const char *set_shot(int i)
{
- return (i >= 0) && (i < s->count);
+ return set_exists(i) ? set_v[i].shot : NULL;
+}
+
+const struct score *set_time_score(int i)
+{
+ return set_exists(i) ? &set_v[i].time_score : NULL;
+}
+
+const struct score *set_coin_score(int i)
+{
+ return set_exists(i) ? &set_v[i].coin_score : NULL;
}
/*---------------------------------------------------------------------------*/
+int set_level_exists(int s, int i)
+{
+ return (i >= 0 && i < set_v[s].count);
+}
+
static void set_load_levels(void)
{
FILE *fin;
set_load_hs();
}
-const struct set *curr_set(void)
+int curr_set(void)
{
- return &set_v[set];
+ return set;
}
const struct level *get_level(int i)
static struct level *next_level(int i)
{
- return set_level_exists(&set_v[set], i + 1) ? &level_v[i + 1] : NULL;
+ return set_level_exists(set, i + 1) ? &level_v[i + 1] : NULL;
}
static struct level *next_normal_level(int i)
#include "base_config.h"
#include "level.h"
-/*---------------------------------------------------------------------------*/
-
#define SET_FILE "sets.txt"
#define MAXSET 16
#define MAXLVL 25
-struct set
-{
- char file[PATHMAX];
-
- char *id; /* Internal set identifier */
- char *name; /* Set name */
- char *desc; /* Set description */
- char *shot; /* Set screen-shot */
-
- char user_scores[PATHMAX]; /* User high-score file */
-
- struct score time_score; /* Challenge score */
- struct score coin_score; /* Challenge score */
-
- /* Level stats */
-
- unsigned int count; /* Number of levels */
-};
-
/*---------------------------------------------------------------------------*/
int set_init(void);
void set_free(void);
+/*---------------------------------------------------------------------------*/
+
int set_exists(int);
+void set_goto(int);
-const struct set *get_set(int);
+int curr_set(void);
-int set_level_exists(const struct set *, int);
+const char *set_name(int);
+const char *set_desc(int);
+const char *set_shot(int);
+const struct score *set_time_score(int);
+const struct score *set_coin_score(int);
-void set_goto(int i);
-const struct set * curr_set(void);
-const struct level *get_level(int);
/*---------------------------------------------------------------------------*/
+int set_level_exists(int, int);
+const struct level *get_level(int);
+
void set_finish_level(struct level_game *, const char *);
void score_change_name(struct level_game *, const char *);
-/*---------------------------------------------------------------------------*/
-
void level_snap(int);
void set_cheat(void);
gui_pulse(gid, 1.2f);
}
- set_best_times(&curr_set()->time_score, curr_lg()->times_rank, 0);
- set_most_coins(&curr_set()->coin_score, curr_lg()->score_rank);
+ set_best_times(set_time_score(curr_set()), curr_lg()->times_rank, 0);
+ set_most_coins(set_coin_score(curr_set()), curr_lg()->score_rank);
return id;
}
if ((kd = gui_vstack(jd)))
{
- gui_label(kd, _(curr_set()->name), GUI_SML,
- GUI_ALL, gui_wht, gui_wht);
+ gui_label(kd, set_name(curr_set()), GUI_SML, GUI_ALL,
+ gui_wht, gui_wht);
+
gui_space(kd);
if ((ld = gui_hstack(kd)))
static void gui_set(int id, int i)
{
- const struct set *s;
-
- if ((s = get_set(i)))
- gui_state(id, _(s->name), GUI_SML, i, 0);
+ if (set_exists(i))
+ gui_state(id, set_name(i), GUI_SML, i, 0);
else
gui_label(id, "", GUI_SML, GUI_ALL, 0, 0);
}
if ((jd = gui_harray(id)))
{
- shot_id = gui_image(jd, get_set(first)->shot,
- 7 * w / 16, 7 * h / 16);
+ shot_id = gui_image(jd, set_shot(first), 7 * w / 16, 7 * h / 16);
if ((kd = gui_varray(jd)))
{
static void set_over(int i)
{
- gui_set_image(shot_id, get_set(i)->shot);
- gui_set_multi(desc_id, _(get_set(i)->desc));
+ gui_set_image(shot_id, set_shot(i));
+ gui_set_multi(desc_id, set_desc(i));
}
static void set_point(int id, int x, int y, int dx, int dy)
static void gui_level(int id, int i)
{
const GLfloat *fore, *back;
-
- const struct set *s = curr_set();
const struct level *l;
int jd;
- if (!set_level_exists(s, i))
+ if (!set_level_exists(curr_set(), i))
{
gui_space(id);
return;
switch (i)
{
case START_CHALLENGE:
- gui_set_image(shot_id, curr_set()->shot);
- set_most_coins(&curr_set()->coin_score, -1);
- set_best_times(&curr_set()->time_score, -1, 0);
+ gui_set_image(shot_id, set_shot(curr_set()));
+ set_most_coins(set_coin_score(curr_set()), -1);
+ set_best_times(set_time_score(curr_set()), -1, 0);
gui_set_label(status_id, _("Challenge all levels from the first one"));
break;
if ((jd = gui_hstack(id)))
{
- gui_label(jd, _(curr_set()->name), GUI_SML, GUI_ALL,
+ gui_label(jd, set_name(curr_set()), GUI_SML, GUI_ALL,
gui_yel, gui_red);
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);
+ shot_id = gui_image(jd, set_shot(curr_set()), 7 * w / 16, 7 * h / 16);
if ((kd = gui_varray(jd)))
{