Implement new shot name generation using a persistent index.
authorparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 10 Mar 2008 02:50:23 +0000 (02:50 +0000)
committerparasti <parasti@78b8d119-cf0a-0410-b17c-f493084dd1d7>
Mon, 10 Mar 2008 02:50:23 +0000 (02:50 +0000)
This is a brought up to date and modified version of a patch provided by Josh
Bush.  *Cough, cough* Cheese wins *cough*.

git-svn-id: https://s.snth.net/svn/neverball/trunk@1869 78b8d119-cf0a-0410-b17c-f493084dd1d7

ball/main.c
putt/main.c
share/config.c
share/config.h
share/image.c
share/image.h

index d28c3b8..dd5dea9 100644 (file)
 static void shot(void)
 {
     static char filename[MAXSTR];
-    static int  num = 0;
 
-    sprintf(filename, "screen%02d.png", num++);
-
-    image_snap(filename);
+    sprintf(filename, "screen%05d.png", config_screenshot());
+    image_snap(config_user(filename));
 }
 
 /*---------------------------------------------------------------------------*/
index aa033e3..7c80ae3 100644 (file)
 static int shot(void)
 {
     static char filename[MAXSTR];
-    static int  num = 0;
 
-    sprintf(filename, "screen%02d.png", num++);
-
-    image_snap(filename);
+    sprintf(filename, "screen%05d.png", config_screenshot());
+    image_snap(config_user(filename));
 
     return 1;
 }
-
 /*---------------------------------------------------------------------------*/
 
 static void toggle_wire(void)
index b37a9f0..bd37109 100644 (file)
@@ -124,6 +124,7 @@ void config_init(void)
     config_set_d(CONFIG_KEY_RIGHT,            DEFAULT_KEY_RIGHT);
     config_set_d(CONFIG_KEY_PAUSE,            DEFAULT_KEY_PAUSE);
     config_set_d(CONFIG_KEY_RESTART,          DEFAULT_KEY_RESTART);
+    config_set_d(CONFIG_SCREENSHOT,           DEFAULT_SCREENSHOT);
 }
 
 void config_load(void)
@@ -256,6 +257,8 @@ void config_load(void)
                     config_set_d(CONFIG_STATS, atoi(val));
                 else if (strcmp(key, "uniform") == 0)
                     config_set_d(CONFIG_UNIFORM, atoi(val));
+                else if (strcmp(key, "screenshot") == 0)
+                    config_set_d(CONFIG_SCREENSHOT, atoi(val));
             }
 
         fclose(fp);
@@ -385,6 +388,9 @@ void config_save(void)
                 option_d[CONFIG_STATS]);
         fprintf(fp, "uniform              %d\n",
                 option_d[CONFIG_UNIFORM]);
+        fprintf(fp, "screenshot           %d\n",
+            option_d[CONFIG_SCREENSHOT]);
+
         if (config_cheat())
             fprintf(fp, "cheat                %d\n", option_d[CONFIG_CHEAT]);
 
@@ -649,6 +655,13 @@ void config_clr_cheat(void)
 
 /*---------------------------------------------------------------------------*/
 
+int config_screenshot(void)
+{
+    return ++option_d[CONFIG_SCREENSHOT];
+}
+
+/*---------------------------------------------------------------------------*/
+
 void config_push_persp(float fov, float n, float f)
 {
     GLdouble m[4][4];
index 5d8adfd..3cb5af3 100644 (file)
@@ -88,6 +88,7 @@ enum {
     CONFIG_CHEAT,
     CONFIG_STATS,
     CONFIG_UNIFORM,
+    CONFIG_SCREENSHOT,
 
     CONFIG_OPTION_D_COUNT
 };
@@ -162,6 +163,7 @@ enum {
 #define DEFAULT_KEY_RESTART          SDLK_r
 #define DEFAULT_STATS                0
 #define DEFAULT_UNIFORM              0
+#define DEFAULT_SCREENSHOT           0
 
 /*---------------------------------------------------------------------------*/
 
@@ -198,6 +200,10 @@ void config_clr_cheat(void);
 
 /*---------------------------------------------------------------------------*/
 
+int config_screenshot(void);
+
+/*---------------------------------------------------------------------------*/
+
 void config_push_persp(float, float, float);
 void config_push_ortho(void);
 void config_pop_matrix(void);
index e8d713d..c5d574f 100644 (file)
@@ -26,7 +26,7 @@
 
 /*---------------------------------------------------------------------------*/
 
-void image_snap(char *filename)
+void image_snap(const char *filename)
 {
     FILE       *filep  = NULL;
     png_structp writep = NULL;
index 685e39e..c029efd 100644 (file)
@@ -9,7 +9,7 @@
 
 /*---------------------------------------------------------------------------*/
 
-void   image_snap(char *);
+void   image_snap(const char *);
 
 GLuint make_image_from_file(const char *);
 GLuint make_image_from_font(int *, int *,