Replaced USE_ALPHA/IGNORE_ALPHA by booleans.
[supertux.git] / src / leveleditor.cpp
index 8ada081..c9c201f 100644 (file)
 
 #include <map>
 #include <typeinfo>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include <errno.h>
-#include <unistd.h>
-#include <SDL.h>
-#include <SDL_image.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <cmath>
+#include <cerrno>
 #include <algorithm>
 #include <iostream>
+#include <unistd.h>
 
-#include "leveleditor.h"
+#include "SDL.h"
+#include "SDL_image.h"
 
+#include "leveleditor.h"
 #include "screen/screen.h"
 #include "defines.h"
 #include "globals.h"
@@ -44,6 +44,7 @@
 #include "player.h"
 #include "scene.h"
 #include "tile.h"
+#include "tile_manager.h"
 #include "resources.h"
 #include "background.h"
 #include "camera.h"
@@ -96,7 +97,7 @@ LevelEditor::LevelEditor()
   le_mouse_clicked[LEFT] = false;
   le_mouse_clicked[RIGHT] = false;
 
-  le_selection = new Surface(datadir + "/images/leveleditor/select.png", USE_ALPHA);
+  le_selection = new Surface(datadir + "/images/leveleditor/select.png", true);
 
   select_tilegroup_menu_effect.init(false);
   select_objects_menu_effect.init(false);
@@ -491,7 +492,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];
@@ -821,8 +822,8 @@ void LevelEditor::drawinterface(DrawingContext &context)
       le_object_properties_bt->draw(context);
     }
 
-    sprintf(str, "%d/%d", le_levelnb,le_level_subset->levels);
-    context.draw_text(white_text, str, Vector((le_level_subset->levels < 10) ? -10 : 0, 16), LAYER_GUI);
+    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);
 
     if(!le_help_shown)
       context.draw_text(white_small_text, "F1 for Help", Vector(10, 430), LAYER_GUI);
@@ -1152,7 +1153,7 @@ void LevelEditor::checkevents()
           le_next_level_bt->event(event);
           if(le_next_level_bt->get_state() == BUTTON_CLICKED)
           {
-            if(le_levelnb < le_level_subset->levels)
+            if(le_levelnb < le_level_subset->get_num_levels())
             {
               goto_level(le_levelnb+1);
             }
@@ -1164,8 +1165,8 @@ void LevelEditor::checkevents()
               Surface* surf = new Surface(le_level->get_sector("main")->background->get_image(), false);
               if(confirm_dialog(surf, str))
               {
-                new_lev.save(le_level_subset->name.c_str());
-                le_level_subset->levels = le_levelnb;
+                le_level_subset->add_level("newlevel.stl");
+                new_lev.save(le_level_subset->get_level_filename(le_levelnb+1));
                 goto_level(le_levelnb);
               }
              if(surf != NULL)
@@ -1782,7 +1783,7 @@ void LevelEditor::showhelp()
     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);
 
-    sprintf(str,"Press any key to continue - Page %d/%d?", i, sizeof(text));
+    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.do_drawing();