Those sets haven't been merged.
[neverball] / ball / st_done.c
index e5010b7..5672fe5 100644 (file)
@@ -1,4 +1,4 @@
-/*   
+/*
  * Copyright (C) 2003 Robert Kooima
  *
  * NEVERBALL is  free software; you can redistribute  it and/or modify
 #define DONE_OK   1
 #define DONE_NAME 2
 
-extern struct state st_done_bis;
+/* Bread crumbs. */
 
-static int high;
-static int time_i;
-static int coin_i;
+static int new_name;
 
 static int done_action(int i)
 {
@@ -49,18 +47,27 @@ static int done_action(int i)
         return goto_state(&st_start);
 
     case DONE_NAME:
-       return goto_name(&st_done_bis, &st_done_bis);
+        new_name = 1;
+        return goto_name(&st_done, &st_done, 0);
     }
     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);
+
+    if (new_name)
+    {
+        level_update_player_name();
+        new_name = 0;
+    }
+
     if ((id = gui_vstack(0)))
     {
         int gid;
@@ -70,56 +77,36 @@ 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, 3, 1);
-            gui_best_times(jd, 3, 1);
+            gui_most_coins(jd, 1);
+            gui_best_times(jd, 1);
         }
 
         gui_space(id);
-       
-       if ((jd = gui_harray(id)))
-       {
+
+        if ((jd = gui_harray(id)))
+        {
+            /* FIXME, I'm ugly. */
+
             if (high)
-              gui_state(jd, _("Change Player Name"), GUI_SML, DONE_NAME, 0);
+               gui_state(jd, _("Change Player Name"), GUI_SML, DONE_NAME, 0);
+
             gui_start(jd, _("OK"), GUI_SML, DONE_OK, 0);
-       }
+        }
 
         gui_layout(id, 0, 0);
+        gui_pulse(gid, 1.2f);
     }
 
-    set_most_coins(0, coin_i);
-    set_best_times(0, time_i);
+    set_best_times(&curr_set()->time_score, curr_lg()->times_rank, 0);
+    set_most_coins(&curr_set()->coin_score, curr_lg()->score_rank);
 
     return id;
 }
 
-static int done_enter(void)
-{
-    int gid, r;
-    
-    time_i = 3;
-    coin_i = 3;
-    high   = level_done(&time_i, &coin_i);
-    
-    r = done_init(&gid);
-    gui_pulse(gid, 1.2f);    
-    return r;
-}
-
-static int done_bis_enter(void)
-{
-    char player[MAXNAM];
-    config_get_s(CONFIG_PLAYER, player, MAXNAM);
-    level_name(0, player, time_i, coin_i);
-    return done_init(NULL);
-}
-
 static int done_buttn(int b, int d)
 {
     if (d)
@@ -141,22 +128,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_buttn,
-    1, 0
-};
-