}
+/* Save data for level: */
+
+void savelevel(st_level* plevel, char * subset, int level)
+{
+ FILE * fi;
+ char * filename;
+ int y;
+ char str[80];
+
+ /* Save data file: */
+
+ filename = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + 20) + strlen(subset));
+ sprintf(filename, "%s/levels/%s/level%d.dat", DATA_PREFIX, subset, level);
+ fi = fopen(filename, "w");
+ if (fi == NULL)
+ {
+ perror(filename);
+ st_shutdown();
+ free(filename);
+ exit(-1);
+ }
+ free(filename);
+
+ fputs(plevel->name, fi);
+ fputs("\n", fi);
+ fputs(plevel->theme, fi);
+ fputs("\n", fi);
+ sprintf(str, "%d\n", plevel->time_left); /* time */
+ fputs(str, fi);
+ fputs(plevel->song_title, fi); /* song filename */
+ fputs("\n",fi);
+ fputs(plevel->bkgd_image, fi); /* background image */
+ sprintf(str, "\n%d\n", plevel->bkgd_red); /* red background color */
+ fputs(str, fi);
+ sprintf(str, "%d\n", plevel->bkgd_green); /* green background color */
+ fputs(str, fi);
+ sprintf(str, "%d\n", plevel->bkgd_blue); /* blue background color */
+ fputs(str, fi);
+ sprintf(str, "%d\n", plevel->width); /* level width */
+ fputs(str, fi);
+
+ for(y = 0; y < 15; ++y)
+ {
+ fputs(plevel->tiles[y], fi);
+ fputs("\n", fi);
+ }
+
+ fclose(fi);
+}
+
+
/* Unload data for this level: */
void unloadlevel(st_level* plevel)
texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2];
void loadlevel(st_level* plevel, char * subset, int level);
+void savelevel(st_level* plevel, char * subset, int level);
void unloadlevel(st_level* plevel);
void loadlevelgfx(st_level* plevel);
void unloadlevelgfx();
bad_guys[i].base.alive = NO;
}
-/* Save data for this level: */
-void savelevel(void)
-{
- FILE * fi;
- char * filename;
- int y;
- char str[80];
-
- /* Save data file: */
-
- filename = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) + 20) + strlen(level_subset));
- sprintf(filename, "%s/levels/%s/level%d.dat", DATA_PREFIX, level_subset, level);
- fi = fopen(filename, "w");
- if (fi == NULL)
- {
- perror(filename);
- st_shutdown();
- free(filename);
- exit(-1);
- }
- free(filename);
-
-
- /* sptrinf("# Level created by SuperTux built-in editor", fi); */
-
- fputs(current_level.name, fi);
- fputs("\n", fi);
- fputs(current_level.theme, fi);
- fputs("\n", fi);
- sprintf(str, "%d\n", current_level.time_left); /* time */
- fputs(str, fi);
- fputs(current_level.song_title, fi); /* song filename */
- fputs("\n",fi);
- fputs(current_level.bkgd_image, fi); /* background image */
- sprintf(str, "\n%d\n", current_level.bkgd_red); /* red background color */
- fputs(str, fi);
- sprintf(str, "%d\n", current_level.bkgd_green); /* green background color */
- fputs(str, fi);
- sprintf(str, "%d\n", current_level.bkgd_blue); /* blue background color */
- fputs(str, fi);
- sprintf(str, "%d\n", current_level.width); /* level width */
- fputs(str, fi);
-
- for(y = 0; y < 15; ++y)
- {
- fputs(current_level.tiles[y], fi);
- fputs("\n", fi);
- }
-
- fclose(fi);
-
- text_drawf(&gold_text, "SAVED!", 0, 240, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
- flipscreen();
- SDL_Delay(1000);
-}
-
void showhelp()
{
SDL_Event event;
int level_editor_started;
int leveleditor();
-void savelevel(void);
void newlevel(void);
void selectlevel(void);
#include "screen.h"
#include "setup.h"
#include "sound.h"
+#include "scene.h"
#include "leveleditor.h"
#include "gameloop.h"
#include "timer.h"
if(menuaction == MN_HIT) /* Save the current level in the level-editor. */
{
show_menu = 0;
- savelevel();
+ savelevel(¤t_level,"default",level);
+ text_drawf(&gold_text, "SAVED!", 0, 240, A_HMIDDLE, A_TOP, 1, NO_UPDATE);
+ flipscreen();
+ SDL_Delay(1000);
}
}
else