locales: Improved words-fr.png texture
[neverball] / ball / st_time_out.c
index 99aa0e3..e2711dc 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "game.h"
 #include "util.h"
-#include "levels.h"
+#include "progress.h"
 #include "demo.h"
 #include "audio.h"
 #include "gui.h"
@@ -26,6 +26,7 @@
 #include "st_time_out.h"
 #include "st_level.h"
 #include "st_shared.h"
+#include "st_play.h"
 
 /*---------------------------------------------------------------------------*/
 
@@ -45,20 +46,22 @@ static int time_out_action(int i)
         /* Fall through. */
 
     case TIME_OUT_OVER:
-        level_stop();
+        progress_stop();
         return goto_state(&st_over);
 
     case TIME_OUT_SAVE:
-        level_stop();
+        progress_stop();
         return goto_save(&st_time_out, &st_time_out);
 
     case TIME_OUT_NEXT:
-        level_next();
-        return goto_state(&st_level);
+        if (progress_next())
+            return goto_state(&st_level);
+        break;
 
     case TIME_OUT_SAME:
-        level_same();
-        return goto_state(&st_level);
+        if (progress_same())
+            return goto_state(&st_level);
+        break;
     }
 
     return 1;
@@ -68,8 +71,6 @@ static int time_out_enter(void)
 {
     int id, jd, kd;
 
-    const struct level_game *lg = curr_lg();
-
     if ((id = gui_vstack(0)))
     {
         kd = gui_label(id, _("Time's Up!"), GUI_LRG, GUI_ALL, gui_gry, gui_red);
@@ -78,27 +79,17 @@ static int time_out_enter(void)
 
         if ((jd = gui_harray(id)))
         {
-            int next_id = 0, retry_id = 0;
-
-            next_id = gui_maybe(jd, _("Next Level"),  TIME_OUT_NEXT,
-                                lg->next_level != NULL);
-
-            if (lg->dead)
-                gui_start(jd, _("Game Over"), GUI_SML, TIME_OUT_OVER, 0);
-            else
-            {
-                retry_id = gui_state(jd, _("Retry Level"), GUI_SML,
-                                     TIME_OUT_SAME, 0);
-            }
+            if (progress_dead())
+                gui_start(jd, _("Exit"), GUI_SML, TIME_OUT_OVER, 0);
 
-            gui_maybe(jd, _("Save Replay"), TIME_OUT_SAVE, demo_saved());
+            if (progress_next_avail())
+                gui_start(jd, _("Next Level"), GUI_SML, TIME_OUT_NEXT, 0);
 
-            /* Default is next if the next level is newly unlocked. */
+            if (progress_same_avail())
+                gui_start(jd, _("Retry Level"), GUI_SML, TIME_OUT_SAME, 0);
 
-            if (next_id && lg->unlock)
-                gui_focus(next_id);
-            else if (retry_id)
-                gui_focus(retry_id);
+            if (demo_saved())
+                gui_state(jd, _("Save Replay"), GUI_SML, TIME_OUT_SAVE, 0);
         }
         gui_space(id);
 
@@ -114,6 +105,19 @@ static int time_out_enter(void)
     return id;
 }
 
+static int time_out_keybd(int c, int d)
+{
+    if (d)
+    {
+        if (config_tst_d(CONFIG_KEY_RESTART, c) && progress_same_avail())
+        {
+            if (progress_same())
+                goto_state(&st_play_ready);
+        }
+    }
+    return 1;
+}
+
 static int time_out_buttn(int b, int d)
 {
     if (d)
@@ -135,8 +139,9 @@ struct state st_time_out = {
     shared_timer,
     shared_point,
     shared_stick,
+    shared_angle,
     shared_click,
-    NULL,
+    time_out_keybd,
     time_out_buttn,
     1, 0
 };