Replay pause/end screen: removed info and reordered buttons.
[neverball] / ball / st_demo.c
index cae19ac..d612ffe 100644 (file)
@@ -131,15 +131,10 @@ static int gui_demo_status(int id, const struct demo *d)
         mode = mode_to_str(0, 0);
         j = strlen(mode);
 
-        /* FIXME
-         *
-         * This stuff should not require changes each time a mode is
-         * added or removed.
-         */
-
-        for (i = 1; i <= MODE_PRACTICE; i++)
+        for (i = 1; i <= MODE_COUNT; i++)
         {
             k = strlen(mode_to_str(i, 0));
+
             if (k > j)
             {
                 j = k;
@@ -270,9 +265,7 @@ static int demo_enter(void)
     }
     else
     {
-        gui_label(id, _("No Replays"), GUI_MED, GUI_ALL, 0,0);
-        gui_filler(id);
-        gui_start(id, _("Back"), GUI_SML, GUI_BACK, 0);
+        gui_label(id, _("No Replays"), GUI_MED, GUI_ALL, 0, 0);
         gui_layout(id, 0, 0);
     }
 
@@ -281,6 +274,15 @@ static int demo_enter(void)
     return id;
 }
 
+static void demo_timer(int id, float dt)
+{
+    if (total == 0 && time_state() > 4.0f)
+        goto_state(&st_title);
+
+    gui_timer(id, dt);
+    audio_timer(dt);
+}
+
 static void demo_point(int id, int x, int y, int dx, int dy)
 {
     int jd = shared_point_basic(id, x, y);
@@ -304,7 +306,7 @@ static int demo_buttn(int b, int d)
     if (d)
     {
         if (config_tst_d(CONFIG_JOYSTICK_BUTTON_A, b))
-            return demo_action(gui_token(gui_click()));
+            return demo_action(total ? gui_token(gui_click()) : GUI_BACK);
         if (config_tst_d(CONFIG_JOYSTICK_BUTTON_EXIT, b))
             return demo_action(GUI_BACK);
     }
@@ -357,7 +359,7 @@ static void demo_play_paint(int id, float st)
     hud_paint();
 
     if (time_state() < 1.f)
-        gui_paint(id, 0);
+        gui_paint(id);
 }
 
 static void demo_play_timer(int id, float dt)
@@ -460,27 +462,25 @@ static int demo_end_enter(void)
 
         if ((jd = gui_harray(id)))
         {
-            if (demo_paused)
-                gui_start(jd, _("Continue"), GUI_SML, DEMO_CONTINUE, 0);
-            else
-                gui_start(jd, _("Replay Again"), GUI_SML, DEMO_REPLAY, 0);
+            int start_id = 0;
 
             if (simple_play)
-                gui_start(jd, _("OK"),       GUI_SML, DEMO_QUIT,   1);
+            {
+                start_id = gui_start(jd, _("Quit"), GUI_SML, DEMO_QUIT, 1);
+            }
             else
             {
-                gui_start(jd, _("Keep"),     GUI_SML, DEMO_KEEP,   1);
-                gui_state(jd, _("Delete"),   GUI_SML, DEMO_DEL,    0);
+                start_id = gui_start(jd, _("Keep"), GUI_SML, DEMO_KEEP, 1);
+                gui_state(jd, _("Delete"), GUI_SML, DEMO_DEL, 0);
             }
-        }
-
-        gui_filler(id);
 
-        if ((jd = gui_hstack(id)))
-        {
-            gui_filler(jd);
-            gui_demo_status(jd, curr_demo_replay());
-            gui_filler(jd);
+            if (demo_paused)
+            {
+                gui_start(jd, _("Continue"), GUI_SML, DEMO_CONTINUE, 1);
+                gui_toggle(start_id);
+            }
+            else
+                gui_state(jd, _("Repeat"),   GUI_SML, DEMO_REPLAY,   0);
         }
 
         gui_pulse(kd, 1.2f);
@@ -495,7 +495,7 @@ static int demo_end_enter(void)
 static void demo_end_paint(int id, float st)
 {
     game_draw(0, st);
-    gui_paint(id, 0);
+    gui_paint(id);
 
     if (demo_paused)
         hud_paint();
@@ -575,7 +575,7 @@ struct state st_demo = {
     demo_enter,
     shared_leave,
     shared_paint,
-    shared_timer,
+    demo_timer,
     demo_point,
     demo_stick,
     shared_click,