Added support for setting up end sequence animations on levels.
[supertux.git] / src / leveleditor.cpp
index 2dab421..7be8284 100644 (file)
@@ -330,7 +330,7 @@ int LevelEditor::run(char* filename)
         default:
           if(i >= 1)
           {
-            if(load_level_subset(subset_load_menu->item[i+1].text))
+            if(load_level_subset(subset_load_menu->item[i+1].text.c_str()))
               return 1;
           }
           break;
@@ -348,7 +348,7 @@ int LevelEditor::run(char* filename)
           {
           case MNID_CREATESUBSET:
             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);
+            le_level_subset->load(subset_new_menu->get_item_by_id(MNID_SUBSETNAME).input.c_str());
             leveleditor_menu->get_item_by_id(MNID_SUBSETSETTINGS).kind = MN_GOTO;
             goto_level(1);
             subset_new_menu->get_item_by_id(MNID_SUBSETNAME).change_input("");
@@ -496,7 +496,7 @@ void LevelEditor::init_menus()
       for(std::vector<int>::const_iterator sit = (*it).tiles.begin();
           sit != (*it).tiles.end(); ++sit, ++i)
       {
-        Tile& tile = TileManager::instance()->get(*sit);
+/*        Tile& tile = TileManager::instance()->get(*sit);
         Surface* image;
         if(tile.editor_images.size() > 0)
           image = tile.editor_images[0];
@@ -508,7 +508,7 @@ void LevelEditor::init_menus()
 
         Button* button = new Button(image, it->name, SDLKey(SDLK_a + i),
                                     0, 0, 32, 32);
-        tilegroups_map[it->name]->additem(button, *sit);
+        tilegroups_map[it->name]->additem(button, *sit);*/
       }
     }
   select_tilegroup_menu->additem(MN_HL,"",0,0);
@@ -544,8 +544,8 @@ void LevelEditor::update_level_settings_menu()
   level_settings_menu->get_item_by_id(MNID_NAME).change_input(le_level->name.c_str());
   level_settings_menu->get_item_by_id(MNID_AUTHOR).change_input(le_level->author.c_str());
 
-  level_settings_menu->get_item_by_id(MNID_SONG).list.first = FileSystem::dfiles("music/",NULL, "-fast");
-  level_settings_menu->get_item_by_id(MNID_BGIMG).list.first = FileSystem::dfiles("images/background",NULL, NULL);
+  level_settings_menu->get_item_by_id(MNID_SONG).list.first = FileSystem::dfiles("music/","", "-fast");
+  level_settings_menu->get_item_by_id(MNID_BGIMG).list.first = FileSystem::dfiles("images/background","", "");
   level_settings_menu->get_item_by_id(MNID_BGIMG).list.first.insert("");
   level_settings_menu->get_item_by_id(MNID_PARTICLE).list.first.insert("");
   level_settings_menu->get_item_by_id(MNID_PARTICLE).list.first.insert("snow");
@@ -599,7 +599,7 @@ void LevelEditor::apply_level_settings_menu()
 
   if(le_level->get_sector("main")->background->get_image().compare((*level_settings_menu->get_item_by_id(MNID_BGIMG).list.second)) != 0)
   {
-    le_level->get_sector("main")->background->set_image((*level_settings_menu->get_item_by_id(MNID_BGIMG).list.second), atoi(level_settings_menu->get_item_by_id(MNID_BGSPEED).input));
+    le_level->get_sector("main")->background->set_image((*level_settings_menu->get_item_by_id(MNID_BGIMG).list.second), atoi(level_settings_menu->get_item_by_id(MNID_BGSPEED).input.c_str()));
     i = true;
   }
 
@@ -616,17 +616,17 @@ void LevelEditor::apply_level_settings_menu()
   le_level->get_sector("main")->song_title = (*level_settings_menu->get_item_by_id(MNID_SONG).list.second);
 
   le_level->get_sector("main")->solids->resize(
-      atoi(level_settings_menu->get_item_by_id(MNID_LENGTH).input),
-      atoi(level_settings_menu->get_item_by_id(MNID_HEIGHT).input));
-  le_level->time_left = atoi(level_settings_menu->get_item_by_id(MNID_TIME).input);
-  le_level->get_sector("main")->gravity = atof(level_settings_menu->get_item_by_id(MNID_GRAVITY).input);
+      atoi(level_settings_menu->get_item_by_id(MNID_LENGTH).input.c_str()),
+      atoi(level_settings_menu->get_item_by_id(MNID_HEIGHT).input.c_str()));
+  le_level->time_left = atoi(level_settings_menu->get_item_by_id(MNID_TIME).input.c_str());
+  le_level->get_sector("main")->gravity = atof(level_settings_menu->get_item_by_id(MNID_GRAVITY).input.c_str());
   le_level->get_sector("main")->background->set_gradient(Color(
-      atoi(level_settings_menu->get_item_by_id(MNID_TopRed).input),
-      atoi(level_settings_menu->get_item_by_id(MNID_TopGreen).input),
-      atoi(level_settings_menu->get_item_by_id(MNID_TopBlue).input)), Color(
-      atoi(level_settings_menu->get_item_by_id(MNID_BottomRed).input),
-      atoi(level_settings_menu->get_item_by_id(MNID_BottomGreen).input),
-      atoi(level_settings_menu->get_item_by_id(MNID_BottomBlue).input)));
+      atoi(level_settings_menu->get_item_by_id(MNID_TopRed).input.c_str()),
+      atoi(level_settings_menu->get_item_by_id(MNID_TopGreen).input.c_str()),
+      atoi(level_settings_menu->get_item_by_id(MNID_TopBlue).input.c_str())), Color(
+      atoi(level_settings_menu->get_item_by_id(MNID_BottomRed).input.c_str()),
+      atoi(level_settings_menu->get_item_by_id(MNID_BottomGreen).input.c_str()),
+      atoi(level_settings_menu->get_item_by_id(MNID_BottomBlue).input.c_str())));
 }
 
 void LevelEditor::save_subset_settings_menu()
@@ -827,20 +827,20 @@ void LevelEditor::drawinterface(DrawingContext &context)
     }
 
     sprintf(str, "%d/%d", le_levelnb, le_level_subset->get_num_levels());
-    context.draw_text(white_text, str, Vector((le_level_subset->get_num_levels() < 10) ? -10 : 0, 16), LAYER_GUI);
+    context.draw_text(white_text, str, Vector((le_level_subset->get_num_levels() < 10) ? -10 : 0, 16), LEFT_ALLIGN, LAYER_GUI);
 
     if(!le_help_shown)
-      context.draw_text(white_small_text, "F1 for Help", Vector(10, 430), LAYER_GUI);
+      context.draw_text(white_small_text, "F1 for Help", Vector(10, 430), LEFT_ALLIGN, LAYER_GUI);
 
     if(display_level_info.check())
-      context.draw_text_center(white_text, le_level->name.c_str(), Vector(0, 0), LAYER_GUI);
+      context.draw_text(white_text, le_level->name.c_str(), Vector(screen->w/2, 0), CENTER_ALLIGN, LAYER_GUI);
   }
   else
   {
     if(!Menu::current())
-      context.draw_text(white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", Vector(10, 430), LAYER_GUI);
+      context.draw_text(white_small_text, "No Level Subset loaded - Press ESC and choose one in the menu", Vector(10, 430), LEFT_ALLIGN, LAYER_GUI);
     else
-      context.draw_text(white_small_text, "No Level Subset loaded", Vector(10, 430), LAYER_GUI);
+      context.draw_text(white_small_text, "No Level Subset loaded", Vector(10, 430), LEFT_ALLIGN, LAYER_GUI);
   }
 
 }
@@ -930,7 +930,7 @@ le_level->get_sector("main")->solids->draw(context);
 
   /* Draw the player: */
   /* for now, the position is fixed at (100, 240) */
-  largetux.walk_right->draw(context, Vector(100 - pos_x, 240 - pos_y), LAYER_OBJECTS-1);
+//  largetux.walk_right->draw(context, Vector(100 - pos_x, 240 - pos_y), LAYER_OBJECTS-1);
 }
 
 void LevelEditor::change_object_properties(GameObject *pobj)
@@ -1782,13 +1782,13 @@ void LevelEditor::showhelp()
     context.draw_gradient(Color(0,0,0), Color(255,255,255), LAYER_BACKGROUND0);
     drawinterface(context);
 
-    context.draw_text_center(blue_text, "- Help -", Vector(0, 30), LAYER_GUI);
+    context.draw_text(blue_text, "- Help -", Vector(screen->w/2, 30), CENTER_ALLIGN, LAYER_GUI);
 
     for(unsigned int t = 0; t < sizeof(text[i])/sizeof(char *); t++)
-      context.draw_text(white_text, text[i][t], Vector(5, 80+(t*white_text->get_height())), LAYER_GUI);
+      context.draw_text(white_text, text[i][t], Vector(5, 80+(t*white_text->get_height())), LEFT_ALLIGN, LAYER_GUI);
 
     sprintf(str,"Press any key to continue - Page %d/%d?", i, static_cast<int>(sizeof(text)));
-    context.draw_text(gold_text, str, Vector(0, 0), LAYER_GUI);
+    context.draw_text(gold_text, str, Vector(0, 0), LEFT_ALLIGN, LAYER_GUI);
 
     context.do_drawing();