/* crutial ones (main loop) */
int le_init();
void le_quit();
-int le_load_level(char *filename);
+int le_load_level_subset(char *filename);
void le_drawlevel();
void le_drawinterface();
void le_checkevents();
void le_showhelp();
void le_set_defaults(void);
void le_activate_bad_guys(void);
-
+void le_goto_level(int levelnb);
void le_highlight_selection();
void apply_level_settings_menu();
static string_list_type level_subsets;
static bool le_level_changed; /* if changes, ask for saving, when quiting*/
static bool show_minimap;
+static bool show_selections;
static bool le_help_shown;
static int pos_x, cursor_x, cursor_y, fire;
static int le_level;
{}
if(filename != NULL)
- if(le_load_level(filename))
+ if(le_load_level_subset(filename))
return 1;
while(true)
default:
if(i >= 1)
{
- if(le_load_level(level_subsets.item[i-1]))
+ if(le_load_level_subset(level_subsets.item[i-1]))
return 1;
}
break;
LevelSubset::create(subset_new_menu->get_item_by_id(MNID_SUBSETNAME).input);
le_level_subset->load(subset_new_menu->get_item_by_id(MNID_SUBSETNAME).input);
leveleditor_menu->get_item_by_id(MNID_SUBSETSETTINGS).kind = MN_GOTO;
- delete le_world;
- le_world = new World(le_level_subset->name,1);
+ le_goto_level(1);
subset_new_menu->get_item_by_id(MNID_SUBSETNAME).change_input("");
Menu::set_current(subset_settings_menu);
return done;
}
-int le_load_level(char *filename)
+int le_load_level_subset(char *filename)
{
le_level_subset->load(filename);
leveleditor_menu->get_item_by_id(MNID_SUBSETSETTINGS).kind = MN_GOTO;
le_level = 1;
- delete le_world;
- le_world = new World(filename,le_level);
+ le_goto_level(1);
//GameSession* session = new GameSession(datadir + "/levels/" + le_level_subset->name + "/level1.stl", 0, ST_GL_DEMO_GAME);
active_tm = TM_IA;
le_show_grid = true;
+ show_selections = true;
scroll_x = 0;
fire = DOWN;
/* Load buttons */
le_save_level_bt = new Button("/images/icons/save.png","Save level", SDLK_F6,screen->w-64,32);
- le_exit_bt = new Button("/images/icons/exit.png","Exit", SDLK_F6,screen->w-32,32);
+ le_exit_bt = new Button("/images/icons/exit.png","Exit", SDLK_F9,screen->w-32,32);
le_next_level_bt = new Button("/images/icons/up.png","Next level", SDLK_PAGEUP,screen->w-64,0);
le_previous_level_bt = new Button("/images/icons/down.png","Previous level",SDLK_PAGEDOWN,screen->w-32,0);
le_rubber_bt = new Button("/images/icons/rubber.png","Rubber",SDLK_DELETE,screen->w-32,48);
le_move_left_bt = new Button("/images/icons/left.png","Move left",SDLK_LEFT,0,0);
le_move_right_bt = new Button("/images/icons/right.png","Move right",SDLK_RIGHT,screen->w-80,0);
le_tilegroup_bt = new Button("/images/icons/tilegroup.png","Select Tilegroup", SDLK_F7,screen->w-64,64);
- le_objects_bt = new Button("/images/icons/objects.png","Select Objects", SDLK_F7,screen->w-64,80);
+ le_objects_bt = new Button("/images/icons/objects.png","Select Objects", SDLK_F8,screen->w-64,80);
le_tilemap_panel = new ButtonPanel(screen->w-64,screen->h-32,32,32);
le_tilemap_panel->set_button_size(32,10);
le_level_subset->save();
}
-void le_goto_level(int levelnb)
+void le_unload_level()
{
+ if(le_level_changed)
+ {
+ le_drawlevel();
+ le_drawinterface();
+ char str[1024];
+ sprintf(str,"Save changes to level %d of %s?",le_level,le_level_subset->name.c_str());
+ if(confirm_dialog(str))
+ {
+ le_world->get_level()->save(le_level_subset->name.c_str(),le_level);
+ }
+ }
+
delete le_world;
+ le_level_changed = false;
+}
+
+void le_goto_level(int levelnb)
+{
+ le_unload_level();
le_world = new World(le_level_subset->name, levelnb);
}
void le_quit(void)
{
- /*if(level_changed == true)
- if(askforsaving() == CANCEL)
- return;*/ //FIXME
-
SDL_EnableKeyRepeat(0, 0); // disables key repeating
+ le_unload_level();
delete le_selection;
delete leveleditor_menu;
delete subset_load_menu;
if(show_minimap) // use_gl because the minimap isn't shown correctly in software mode. Any idea? FIXME Possible reasons: SDL_SoftStretch is a hack itsself || an alpha blitting issue SDL can't handle in software mode
le_drawminimap();
+ if(show_selections)
+ {
if(le_selection_mode == CURSOR)
{
if(le_current.IsTile())
le_selection->draw( cursor_x - pos_x, cursor_y);
- }
- else if(le_selection_mode == SQUARE)
- {
- int w, h;
- le_highlight_selection();
- /* draw current selection */
- w = selection.x2 - selection.x1;
- h = selection.y2 - selection.y1;
- fillrect(selection.x1 - pos_x, selection.y1, w, SELECT_W, SELECT_CLR);
- fillrect(selection.x1 - pos_x + w, selection.y1, SELECT_W, h, SELECT_CLR);
- fillrect(selection.x1 - pos_x, selection.y1 + h, w, SELECT_W, SELECT_CLR);
- fillrect(selection.x1 - pos_x, selection.y1, SELECT_W, h, SELECT_CLR);
- }
+ }
+ else if(le_selection_mode == SQUARE)
+ {
+ int w, h;
+ le_highlight_selection();
+ /* draw current selection */
+ w = selection.x2 - selection.x1;
+ h = selection.y2 - selection.y1;
+ fillrect(selection.x1 - pos_x, selection.y1, w, SELECT_W, SELECT_CLR);
+ fillrect(selection.x1 - pos_x + w, selection.y1, SELECT_W, h, SELECT_CLR);
+ fillrect(selection.x1 - pos_x, selection.y1 + h, w, SELECT_W, SELECT_CLR);
+ fillrect(selection.x1 - pos_x, selection.y1, SELECT_W, h, SELECT_CLR);
+ }
+ }
/* draw button bar */
{
Menu::current()->event(event);
if(!le_world && !Menu::current())
- Menu::set_current(leveleditor_menu);
+ Menu::set_current(leveleditor_menu);
}
else
{
{
case SDLK_ESCAPE:
Menu::set_current(leveleditor_menu);
- break;
+ break;
case SDLK_LEFT:
if(fire == DOWN)
cursor_x -= KEY_CURSOR_SPEED;
{
if(le_current.IsObject())
{
+ le_level_changed = true;
std::string type = le_current.obj->type();
if(type == "BadGuy")
{
int x1, x2, y1, y2;
unsigned int i = 0;
- /* level_changed = true; */
-
+ le_level_changed = true;
+
switch(le_selection_mode)
{
case CURSOR:
bool tmp_show_grid = le_show_grid;
int temp_le_selection_mode = le_selection_mode;
le_selection_mode = NONE;
+ show_selections = true;
le_show_grid = false;
le_help_shown = true;
"the left mouse button over the map",
"to \"paint\" your selection over",
"the screen.",
+ "",
"There are three layers for painting",
"tiles upon, Background layer,",
"the Interactive layer, and the",
"the Interactive layer are those",
"which actually effect Tux in the",
"game.",
+ "",
"Click the objects menu to put ",
"bad guys and other objects in the",
"game. Unlike placing tiles, you",
"cannot \"paint\" enemies. Click",
"them onto the screen one at a time.",
+ "",
"To change the settings of your",
"level, click the button with the",
"screwdriver and wrench. From here",
"you can change the background,",
- "music, length of the level, and more.",
- "You may have more than one levelset.",
+ "music, length of the level,",
+ "and more."
+ };
+
+ char *text3[] = {
+
+ " - Supertux level editor tutorial - ",
+ "",
+ "You may have more than one level.",
"Pressing the up and down buttons",
- "above the button bar lets you choose",
- "which one you are working on.",
+ "above the button bar lets you",
+ "choose which one you are working on.",
+ "",
"If you would like to speed up your",
"level editing, a useful trick is",
- "to learn the keyboard shortcuts. They",
- "are easy to learn, just right-",
+ "to learn the keyboard shortcuts.",
+ "They are easy to learn, just right-",
+ "click on the buttons.",
+ "",
"Have fun making levels! If you make",
"some good ones, send them to us on",
"the SuperTux mailing list!",
"- SuperTux team"
};
-
+
+
blue_text->drawf("- Help -", 0, 30, A_HMIDDLE, A_TOP, 2);
for(i = 0; i < sizeof(text)/sizeof(char *); i++)
white_text->draw(text[i], 5, 80+(i*white_text->h), 1);
- gold_text->drawf("Press Any Key to Continue - Page 1/2", 0, 0, A_LEFT, A_BOTTOM, 1);
+ gold_text->drawf("Press Anything to Continue - Page 1/3", 0, 0, A_LEFT, A_BOTTOM, 1);
flipscreen();
for(i = 0; i < sizeof(text2)/sizeof(char *); i++)
white_text->draw(text2[i], 5, 80+(i*white_text->h), 1);
- gold_text->drawf("Press Any Key to Continue - Page 2/2", 0, 0, A_LEFT, A_BOTTOM, 1);
+ gold_text->drawf("Press Anything to Continue - Page 2/3", 0, 0, A_LEFT, A_BOTTOM, 1);
+
+ flipscreen();
+
+ done_ = 0;
+
+ while(done_ == 0)
+ {
+ done_ = wait_for_event(event);
+ SDL_Delay(50);
+ }
+
+ drawgradient(Color(0,0,0), Color(255,255,255));
+ le_drawinterface();
+
+
+ blue_text->drawf("- Help -", 0, 30, A_HMIDDLE, A_TOP, 2);
+
+ for(i = 0; i < sizeof(text3)/sizeof(char *); i++)
+ white_text->draw(text3[i], 5, 80+(i*white_text->h), 1);
+
+ gold_text->drawf("Press Anything to Continue - Page 3/3", 0, 0, A_LEFT, A_BOTTOM, 1);
flipscreen();
SDL_Delay(50);
}
+ show_selections = true;
le_show_grid = tmp_show_grid;
- le_help_shown = false;
le_selection_mode = temp_le_selection_mode;
+ le_help_shown = false;
}