locales: Improved words-fr.png texture
[neverball] / ball / st_done.c
index 186ddbd..ad832b1 100644 (file)
@@ -19,7 +19,7 @@
 #include "game.h"
 #include "util.h"
 #include "demo.h"
-#include "levels.h"
+#include "progress.h"
 #include "audio.h"
 #include "config.h"
 #include "st_shared.h"
 /*---------------------------------------------------------------------------*/
 
 #define DONE_OK   1
-#define DONE_NAME 2
 
-extern struct state st_done_bis;
+/* Bread crumbs. */
+
+static int new_name;
+static int resume;
 
 static int done_action(int i)
 {
@@ -44,20 +46,34 @@ static int done_action(int i)
     case DONE_OK:
         return goto_state(&st_start);
 
-    case DONE_NAME:
-        return goto_name(&st_done_bis, &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 = (curr_lg()->times_rank < 3) || (curr_lg()->score_rank < 3);
+    int high = progress_set_high();
+
+    if (new_name)
+    {
+        progress_rename(1);
+        new_name = 0;
+    }
 
     if ((id = gui_vstack(0)))
     {
@@ -68,48 +84,38 @@ static int done_init(int *gidp)
         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, 1);
-            gui_best_times(jd, 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_start(id, _("Select Level"), GUI_SML, DONE_OK, 0);
+
+        if (!resume)
+            gui_pulse(gid, 1.2f);
 
         gui_layout(id, 0, 0);
     }
 
-    set_best_times(&curr_set()->time_score, curr_lg()->times_rank, 0);
-    set_most_coins(&curr_set()->coin_score, curr_lg()->score_rank);
+    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());
+
+    /* Reset hack. */
+    resume = 0;
 
     return id;
 }
 
-static int done_enter(void)
+static int done_keybd(int c, int d)
 {
-    int gid, r;
+    if (d && config_tst_d(CONFIG_KEY_SCORE_NEXT, c))
+        return done_action(gui_score_next(gui_score_get()));
 
-    r = done_init(&gid);
-    gui_pulse(gid, 1.2f);
-    return r;
-}
-
-static int done_bis_enter(void)
-{
-    level_update_player_name();
-    return done_init(NULL);
+    return 1;
 }
 
 static int done_buttn(int b, int d)
@@ -133,22 +139,9 @@ struct state st_done = {
     shared_timer,
     shared_point,
     shared_stick,
+    shared_angle,
     shared_click,
-    NULL,
-    done_buttn,
-    1, 0
-};
-
-struct state st_done_bis = {
-    done_bis_enter,
-    shared_leave,
-    shared_paint,
-    shared_timer,
-    shared_point,
-    shared_stick,
-    shared_click,
-    NULL,
+    done_keybd,
     done_buttn,
     1, 0
 };
-