Store replay date/time as an ISO 8601 formatted string. This involves
[neverball] / ball / st_set.c
index 440a299..c888b25 100644 (file)
@@ -1,4 +1,4 @@
-/*   
+/*
  * Copyright (C) 2003 Robert Kooima
  *
  * NEVERBALL is  free software; you can redistribute  it and/or modify
 
 /*---------------------------------------------------------------------------*/
 
-#define SET_BACK -1
-#define SET_PREV -2
-#define SET_NEXT -3
-#define SET_NULL -4
-
 #define SET_GROUP 5 /* number of sets in one screen */
 
+static int last_set = 0;
+
 static int shot_id;
 static int desc_id;
 
@@ -47,22 +44,20 @@ static int set_action(int i)
         return goto_state(&st_title);
 
     case GUI_PREV:
-        config_set_d(CONFIG_LAST_SET,
-                     ((config_get_d(CONFIG_LAST_SET) / SET_GROUP) - 1) * SET_GROUP);
+        last_set = (last_set / SET_GROUP - 1) * SET_GROUP;
         return goto_state(&st_set);
-    
+
     case GUI_NEXT:
-        config_set_d(CONFIG_LAST_SET,
-                     ((config_get_d(CONFIG_LAST_SET) / SET_GROUP) + 1) * SET_GROUP);
+        last_set = (last_set / SET_GROUP + 1) * SET_GROUP;
         return goto_state(&st_set);
 
     case GUI_NULL:
         return 1;
-    
+
     default:
         if (set_exists(i))
         {
-            config_set_d(CONFIG_LAST_SET, i);
+            last_set = i;
             set_goto(i);
             return goto_state(&st_start);
         }
@@ -74,14 +69,14 @@ static void gui_set(int id, int i)
 {
     const struct set *s = get_set(i);
     int jd;
-    
-    if (set_completed(s)) 
+
+    if (set_completed(s))
         jd = gui_label(id, _(s->name), GUI_SML, GUI_ALL, gui_yel, gui_wht);
-    else if (set_unlocked(s)) 
+    else if (set_unlocked(s))
         jd = gui_label(id, _(s->name), GUI_SML, GUI_ALL, gui_grn, gui_wht);
     else
         jd = gui_label(id, _(s->name), GUI_SML, GUI_ALL, gui_wht, gui_wht);
-    
+
     gui_active(jd, i, 0);
 }
 
@@ -89,21 +84,18 @@ static int set_enter(void)
 {
     int w = config_get_d(CONFIG_WIDTH);
     int h = config_get_d(CONFIG_HEIGHT);
-    int last_set = config_get_d(CONFIG_LAST_SET);
     int b = last_set / SET_GROUP;
     int i;
 
     int id, jd, kd;
 
-
     set_init();
-    
-    /* Reset last set if it do not exists */
+
+    /* Reset last set if it does not exist */
     if (!set_exists(last_set))
     {
         b = 0;
         last_set = 0;
-        config_set_d(CONFIG_LAST_SET, 0);
     }
 
     audio_music_fade_to(0.5f, "bgm/inter.ogg");
@@ -120,23 +112,24 @@ static int set_enter(void)
 
         if ((jd = gui_harray(id)))
         {
-            shot_id = gui_image(jd, get_set(last_set)->shot, 7 * w / 16,
-                                7 * h / 16);
+            shot_id = gui_image(jd, get_set(last_set)->shot,
+                                7 * w / 16, 7 * h / 16);
 
             if ((kd = gui_varray(jd)))
             {
-                /* Display levels */
+                /* Display sets */
                 for (i = b * SET_GROUP; i < (b + 1) * SET_GROUP && set_exists(i); i++)
                     gui_set(kd, i);
-                
+
                 /* Display empty slots */
                 for(; i < (b + 1) * SET_GROUP; i++)
                     gui_filler(kd);
-            }          
+            }
         }
 
         gui_space(id);
-        desc_id = gui_multi(id, " \\ \\ \\ \\ \\", GUI_SML, GUI_ALL, gui_yel, gui_wht);
+        desc_id = gui_multi(id, " \\ \\ \\ \\ \\", GUI_SML, GUI_ALL,
+                            gui_yel, gui_wht);
 
         gui_layout(id, 0, 0);
     }