Fixed the problem that in a rare case, a set is downloaded and the neverballrc is...
[neverball] / ball / st_help.c
index 59e0b5e..c5d5dc4 100644 (file)
@@ -52,13 +52,13 @@ static int help_action(int t)
         break;
 
     case HELP_DEMO_1:
-        demo_replay_init(config_data("gui/demo1.nbr"), NULL);
-        return goto_state(&st_help_demo);
+        if (demo_replay_init(config_data("gui/demo1.nbr"), NULL))
+            return goto_state(&st_help_demo);
         break;
 
     case HELP_DEMO_2:
-        demo_replay_init(config_data("gui/demo2.nbr"), NULL);
-        return goto_state(&st_help_demo);
+        if (demo_replay_init(config_data("gui/demo2.nbr"), NULL))
+            return goto_state(&st_help_demo);
         break;
 
     default:
@@ -66,7 +66,7 @@ static int help_action(int t)
         return goto_state(&st_help);
         break;
     }
-    return 0;
+    return 1;
 }
 
 /* -------------------------------------------------------------------------- */
@@ -85,6 +85,8 @@ static int help_menu(int id)
 {
     int jd;
 
+    gui_space(id);
+
     if ((jd = gui_harray(id)))
     {
         help_button(jd, _("Techniques"), HELP_TECH);
@@ -171,15 +173,13 @@ static int help_controls(int id)
     const char *s9 = _("Lazy View");
     const char *sA = _("Manual View");
     const char *sC = _("Screenshot");
-    const char *sD = _("Toggle Fullscreen");
-
-    const char *k0 = _("Spacebar");
+    
+    const char *k0 = _(SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_PAUSE)));
     const char *k1 = _("Escape");
-    const char *k2 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_1));
-    const char *k3 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_2));
-    const char *k4 = SDL_GetKeyName(config_get_d(CONFIG_KEY_CAMERA_3));
+    const char *k2 = SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_CAMERA_1));
+    const char *k3 = SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_CAMERA_2));
+    const char *k4 = SDL_GetKeyName((SDLKey) config_get_d(CONFIG_KEY_CAMERA_3));
     const char *k6 = SDL_GetKeyName(SDLK_F10);
-    const char *k7 = SDL_GetKeyName(SDLK_F11);
 
     int jd;
 
@@ -215,11 +215,6 @@ static int help_controls(int id)
         gui_label(jd, sC, GUI_SML, 0,      gui_wht, gui_wht);
         gui_label(jd, k6, GUI_SML, 0,      gui_yel, gui_yel);
     }
-    if ((jd = gui_harray(id)))
-    {
-        gui_label(jd, sD, GUI_SML, GUI_SE, gui_wht, gui_wht);
-        gui_label(jd, k7, GUI_SML, GUI_SW, gui_yel, gui_yel);
-    }
 
     gui_space(id);
 
@@ -351,25 +346,15 @@ static int help_enter(void)
 
         switch (tab)
         {
-        case HELP_RULE:
-            help_rules(id);
-            break;
-
-        case HELP_CONT:
-            help_controls(id);
-            break;
-
-        case HELP_MODE:
-            help_modes(id);
-            break;
-
-        case HELP_TECH:
-            help_techniques(id);
-            break;
+        case HELP_RULE: help_rules(id);      break;
+        case HELP_CONT: help_controls(id);   break;
+        case HELP_MODE: help_modes(id);      break;
+        case HELP_TECH: help_techniques(id); break;
 
         default:
             break;
         }
+
         gui_layout(id, 0, +1);
     }
     return id;
@@ -389,14 +374,8 @@ static int help_buttn(int b, int d)
 
 /*---------------------------------------------------------------------------*/
 
-static float real_time;
-static float demo_time;
-
 static int help_demo_enter(void)
 {
-    real_time = -1.f;
-    demo_time =  0.f;
-
     game_set_fly(0.f);
 
     return 0;
@@ -414,20 +393,10 @@ static void help_demo_paint(int id, float st)
 
 static void help_demo_timer(int id, float dt)
 {
-    float t;
-
-    real_time += dt;
-
     game_step_fade(dt);
 
-    while (demo_time < real_time)
-        if (demo_replay_step(&t))
-            demo_time += t;
-        else
-        {
-            goto_state(&st_help);
-            break;
-        }
+    if (!demo_replay_step(dt))
+        goto_state(&st_help);
 }
 
 static int help_demo_buttn(int b, int d)
@@ -448,6 +417,7 @@ struct state st_help = {
     shared_timer,
     shared_point,
     shared_stick,
+    shared_angle,
     shared_click,
     NULL,
     help_buttn,
@@ -463,6 +433,7 @@ struct state st_help_demo = {
     NULL,
     NULL,
     NULL,
+    NULL,
     help_demo_buttn,
     1, 0
 };