oops! fixed
[neverball] / ball / st_set.c
index ac10cc6..7246263 100644 (file)
 
 #include "gui.h"
 #include "set.h"
-#include "levels.h"
-#include "game.h"
+#include "progress.h"
 #include "audio.h"
 #include "config.h"
 #include "util.h"
-#include "st_shared.h"
+#include "common.h"
+
+#include "game_common.h"
 
 #include "st_set.h"
 #include "st_title.h"
 #include "st_start.h"
+#include "st_shared.h"
 
 /*---------------------------------------------------------------------------*/
 
-#define SET_STEP    5
+#define SET_STEP 6
 
 static int total = 0;
 static int first = 0;
@@ -35,7 +37,7 @@ static int first = 0;
 static int shot_id;
 static int desc_id;
 
-static int should_prompt = 1;
+static int do_init = 1;
 
 static int set_action(int i)
 {
@@ -44,6 +46,7 @@ static int set_action(int i)
     switch (i)
     {
     case GUI_BACK:
+        set_quit();
         return goto_state(&st_title);
         break;
 
@@ -51,7 +54,7 @@ static int set_action(int i)
 
         first -= SET_STEP;
 
-        should_prompt = 0;
+        do_init = 0;
         return goto_state(&st_set);
 
         break;
@@ -60,7 +63,7 @@ static int set_action(int i)
 
         first += SET_STEP;
 
-        should_prompt = 0;
+        do_init = 0;
         return goto_state(&st_set);
 
         break;
@@ -82,10 +85,8 @@ static int set_action(int i)
 
 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);
 }
@@ -99,13 +100,15 @@ static int set_enter(void)
 
     int i;
 
-    total = set_init();
-
-    audio_music_fade_to(0.5f, "bgm/inter.ogg");
+    if (do_init)
+    {
+        total = set_init();
+        first = MIN(first, (total - 1) - ((total - 1) % SET_STEP));
 
-    if (should_prompt)
+        audio_music_fade_to(0.5f, "bgm/inter.ogg");
         audio_play(AUD_START, 1.f);
-    else should_prompt = 1;
+    }
+    else do_init = 1;
 
     if ((id = gui_vstack(0)))
     {
@@ -113,13 +116,14 @@ static int set_enter(void)
         {
             gui_label(jd, _("Level Set"), GUI_SML, GUI_ALL, gui_yel, gui_red);
             gui_filler(jd);
-            gui_back_prev_next(jd, first > 0, first + SET_STEP < total);
+            gui_navig(jd, first > 0, first + SET_STEP < total);
         }
 
+        gui_space(id);
+
         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)))
             {
@@ -139,8 +143,8 @@ static int set_enter(void)
 
 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)
@@ -180,6 +184,7 @@ struct state st_set = {
     shared_timer,
     set_point,
     set_stick,
+    shared_angle,
     shared_click,
     NULL,
     set_buttn,