Oops! Fixed newly envmapped glass being scheduled as opaque.
[neverball] / share / st_resol.c
index 1301ae5..e294046 100644 (file)
@@ -1,5 +1,6 @@
-/*   
- * Copyright (C) 2003 Robert Kooima
+/*
+ * Copyright (C) 2003 Robert Kooima - 2006 Jean Privat
+ * Part of the Neverball Project http://icculus.org/neverball/
  *
  * NEVERBALL is  free software; you can redistribute  it and/or modify
  * it under the  terms of the GNU General  Public License as published
@@ -12,6 +13,7 @@
  * General Public License for more details.
  */
 
+
 #include <string.h>
 
 #include "gui.h"
 extern struct state st_conf;
 extern struct state st_null;
 
-SDL_Rect ** resolutions;
+static SDL_Rect **modes;
 
 /*---------------------------------------------------------------------------*/
 
-#define LANG_BACK 100
+#define RESOL_BACK -1
 
 static int resol_action(int i)
 {
-    int f = config_get_d(CONFIG_FULLSCREEN);
     int r = 1;
-    
+
     switch (i)
     {
-    case LANG_BACK:
+    case RESOL_BACK:
         goto_state(&st_conf);
         break;
 
     default:
-       goto_state(&st_null);
-       r = config_mode(f, resolutions[i-1]->w, resolutions[i-1]->h);
-       goto_state(&st_conf);
+        goto_state(&st_null);
+        r = config_mode(config_get_d(CONFIG_FULLSCREEN),
+                        modes[i]->w, modes[i]->h);
+        goto_state(&st_resol);
         break;
     }
 
@@ -55,65 +57,45 @@ static int resol_action(int i)
 
 static int resol_enter(void)
 {
-    int id, jd, kd;
+    int id, jd;
     int i;
-    int w, h;
-    int wp, hp;
-    int c;
 
     back_init("back/gui.png", config_get_d(CONFIG_GEOMETRY));
 
-    /* Get the current resolution. */
-    w = config_get_d(CONFIG_WIDTH);
-    h = config_get_d(CONFIG_HEIGHT);
-    
-    /* Get the resolution list. */
-    resolutions = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
+    modes = SDL_ListModes(NULL, SDL_OPENGL | SDL_FULLSCREEN);
 
-    if ((int)resolutions == -1)
-    {
-       resolutions = NULL;
-       printf("Any resolution\n");
-    }
-    else if (resolutions == NULL)
-    {
-       printf("No resolution\n");
-    }
+    if ((int) modes == -1)
+        modes = NULL;
 
-    if ((id = gui_harray(0)))
+    if ((id = gui_vstack(0)))
     {
-        if ((jd = gui_varray(id)))
+        if ((jd = gui_harray(id)))
+        {
+            gui_label(jd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
+            gui_filler(jd);
+            gui_start(jd, _("Back"), GUI_SML, RESOL_BACK, 0);
+        }
+
+        if (modes)
         {
-            if ((kd = gui_harray(jd)))
+            for(i = 0; modes[i]; i++)
             {
-                gui_label(kd, _("Resolution"), GUI_SML, GUI_ALL, 0, 0);
-               gui_filler(kd);
-                gui_start(kd, _("Back"),     GUI_SML, LANG_BACK, 0);
+                char s[20];
+
+                sprintf(s, "%d x %d", modes[i]->w, modes[i]->h);
+
+                if (i % 4 == 0)
+                    jd = gui_harray(id);
+
+                gui_state(jd, s, GUI_SML, i,
+                          config_get_d(CONFIG_WIDTH)  == modes[i]->w &&
+                          config_get_d(CONFIG_HEIGHT) == modes[i]->h);
             }
-           
-           if (resolutions != NULL)
-           {
-               hp = wp = -1;
-               c = 0;
-               for(i=0; resolutions[i]; i++)
-               {
-                   if (wp!=resolutions[i]->w || hp!=resolutions[i]->h)
-                   {
-                       static char st[100];
-                       wp = resolutions[i]->w;
-                       hp = resolutions[i]->h;
-                       sprintf(st, "%d x %d", wp, hp);
-                       if (c % 4 == 0)
-                               kd = gui_harray(jd);
-                       gui_state(kd, st,   GUI_SML, i+1, (w==wp) && (h==hp));
-                       c++;
-                   }
-               }
-               
-               for(; c%4!=0; c++)
-                       gui_filler(kd);
-           }
+
+            for(; i % 4 != 0; i++)
+                gui_space(jd);
         }
+
         gui_layout(id, 0, 0);
     }
 
@@ -141,7 +123,6 @@ static void resol_paint(int id, float st)
 static void resol_timer(int id, float dt)
 {
     gui_timer(id, dt);
-    audio_timer(dt);
 }
 
 static void resol_point(int id, int x, int y, int dx, int dy)