int joystick_num = 0;
char* level_startup_file = 0;
-bool launch_worldmap_mode = false;
+bool launch_leveleditor_mode = false;
/* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */
char *st_dir, *st_save_dir;
/** The number of the joystick that will be use in the game */
extern int joystick_num;
extern char* level_startup_file;
-extern bool launch_worldmap_mode;
+extern bool launch_leveleditor_mode;
/* SuperTux directory ($HOME/.supertux) and save directory($HOME/.supertux/save) */
extern char* st_dir;
/* crutial ones (main loop) */
int le_init();
void le_quit();
+int le_load_level(char *filename);
void le_drawlevel();
void le_drawinterface();
void le_checkevents();
}
}
-int leveleditor(int levelnb)
+int leveleditor(char* filename)
{
int last_time, now_time, i;
- le_level = levelnb;
+ le_level = 1;
+
if(le_init() != 0)
return 1;
while (SDL_PollEvent(&event))
{}
+ if(filename != NULL)
+ if(le_load_level(filename))
+ return 1;
+
while(true)
{
last_time = SDL_GetTicks();
default:
if(i >= 1)
{
- le_level_subset->load(level_subsets.item[i-1]);
- leveleditor_menu->get_item_by_id(MNID_SUBSETSETTINGS).kind = MN_GOTO;
- le_level = 1;
- le_world.arrays_free();
- delete le_current_level;
- le_current_level = new Level;
- if(le_current_level->load(le_level_subset->name, le_level) != 0)
- {
- le_quit();
- return 1;
- }
- le_set_defaults();
- le_current_level->load_gfx();
- le_world.activate_bad_guys();
-
- Menu::set_current(NULL);
+ if(le_load_level(level_subsets.item[i-1]))
+ return 1;
}
break;
}
return done;
}
+int le_load_level(char *filename)
+{
+le_level_subset->load(filename);
+leveleditor_menu->get_item_by_id(MNID_SUBSETSETTINGS).kind = MN_GOTO;
+le_level = 1;
+le_world.arrays_free();
+delete le_current_level;
+le_current_level = new Level;
+if(le_current_level->load(le_level_subset->name, le_level) != 0)
+ {
+ le_quit();
+ return 1;
+ }
+le_set_defaults();
+le_current_level->load_gfx();
+le_world.activate_bad_guys();
+
+Menu::set_current(NULL);
+
+return 0;
+}
void le_init_menus()
{
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
+
return 0;
}
<< " Start-Button: " << joystick_keymap.start_button << std::endl;
}
}
- else if (strcmp(argv[i], "--worldmap") == 0)
+ else if (strcmp(argv[i], "--leveleditor") == 0)
{
- launch_worldmap_mode = true;
+ launch_leveleditor_mode = true;
}
else if (strcmp(argv[i], "--datadir") == 0
|| strcmp(argv[i], "-d") == 0 )