change mode names
[neverball] / share / config.c
index b642408..9cc1cd1 100644 (file)
@@ -105,9 +105,12 @@ void config_init(void)
     config_set_d(CONFIG_VIEW_DZ,              DEFAULT_VIEW_DZ);
     config_set_d(CONFIG_ROTATE_FAST,          DEFAULT_ROTATE_FAST);
     config_set_d(CONFIG_ROTATE_SLOW,          DEFAULT_ROTATE_SLOW);
+    config_set_d(CONFIG_LAST_SET,             DEFAULT_LAST_SET);
+    config_set_d(CONFIG_MODE,                 DEFAULT_MODE);
     config_set_s(CONFIG_PLAYER,               DEFAULT_PLAYER);
     config_set_s(CONFIG_BALL,                 DEFAULT_BALL);
     config_set_s(CONFIG_COIN,                 DEFAULT_COIN);
+    config_set_s(CONFIG_LANG,                 DEFAULT_LANG);
 }
 
 void config_load(void)
@@ -195,6 +198,10 @@ void config_load(void)
                     config_set_d(CONFIG_ROTATE_FAST,          atoi(val));
                 else if (strcmp(key, "rotate_slow")           == 0)
                     config_set_d(CONFIG_ROTATE_SLOW,          atoi(val));
+                else if (strcmp(key, "last_set")              == 0)
+                    config_set_d(CONFIG_LAST_SET,             atoi(val));
+                else if (strcmp(key, "mode")                  == 0)
+                    config_set_d(CONFIG_MODE,                 atoi(val));
 
                 else if (strcmp(key, "key_camera_1")  == 0)
                     config_key(val, CONFIG_KEY_CAMERA_1, DEFAULT_KEY_CAMERA_1);
@@ -213,6 +220,8 @@ void config_load(void)
                     config_set_s(CONFIG_BALL,   val);
                 else if (strcmp(key, "coin")   == 0)
                     config_set_s(CONFIG_COIN,   val);
+                else if (strcmp(key, "lang")   == 0)
+                    config_set_s(CONFIG_LANG,   val);
             }
 
         fclose(fp);
@@ -299,6 +308,10 @@ void config_save(void)
                 option_d[CONFIG_ROTATE_FAST]);
         fprintf(fp, "rotate_slow          %d\n",
                 option_d[CONFIG_ROTATE_SLOW]);
+        fprintf(fp, "last_set             %d\n",
+                option_d[CONFIG_LAST_SET]);
+        fprintf(fp, "mode                 %d\n",
+                option_d[CONFIG_MODE]);
 
         fprintf(fp, "key_camera_1         %s\n",
                 SDL_GetKeyName(option_d[CONFIG_KEY_CAMERA_1]));
@@ -314,6 +327,7 @@ void config_save(void)
         fprintf(fp, "player               %s\n", option_s[CONFIG_PLAYER]);
         fprintf(fp, "ball                 %s\n", option_s[CONFIG_BALL]);
         fprintf(fp, "coin                 %s\n", option_s[CONFIG_COIN]);
+        fprintf(fp, "lang                 %s\n", option_s[CONFIG_LANG]);
 
         fclose(fp);
     }
@@ -335,10 +349,9 @@ int config_mode(int f, int w, int h)
 
     if (SDL_SetVideoMode(w, h, 0, SDL_OPENGL | (f ? SDL_FULLSCREEN : 0)))
     {
-        option_d[CONFIG_FULLSCREEN] = f;
-        option_d[CONFIG_WIDTH]      = w;
-        option_d[CONFIG_HEIGHT]     = h;
-        option_d[CONFIG_SHADOW]     = option_d[CONFIG_SHADOW];
+       config_set_d(CONFIG_FULLSCREEN, f);
+       config_set_d(CONFIG_WIDTH, w);
+       config_set_d(CONFIG_HEIGHT, h);
 
         glViewport(0, 0, w, h);
         glClearColor(0.0f, 0.0f, 0.1f, 0.0f);
@@ -505,6 +518,7 @@ void config_set_d(int i, int d)
 void config_tgl_d(int i)
 {
     option_d[i] = (option_d[i] ? 0 : 1);
+    dirty = 1;
 }
 
 int config_tst_d(int i, int d)
@@ -519,7 +533,7 @@ int config_get_d(int i)
 
 /*---------------------------------------------------------------------------*/
 
-void config_set_s(int i, char *src)
+void config_set_s(int i, const char *src)
 {
     int len = (int) strlen(src);
 
@@ -537,6 +551,11 @@ void config_get_s(int i, char *dst, int len)
     strncpy(dst, option_s[i], len);
 }
 
+const char * config_simple_get_s(int i)
+{
+       return option_s[i];
+}
+
 /*---------------------------------------------------------------------------*/
 
 static int grabbed = 0;