- updated TODO
[supertux.git] / src / leveleditor.cpp
index fdc3433..cb8f714 100644 (file)
@@ -31,7 +31,7 @@
 #include <algorithm>
 #include "leveleditor.h"
 
-#include "screen.h"
+#include "screen/screen.h"
 #include "defines.h"
 #include "globals.h"
 #include "setup.h"
 #include "button.h"
 #include "tile.h"
 #include "resources.h"
-#include "music_manager.h"
 #include "background.h"
-#include "display_manager.h"
+
+// TODO
+#if 0
 
 /* definitions to aid development */
 
@@ -472,29 +473,18 @@ void le_init_menus()
       for(std::vector<int>::const_iterator sit = (*it).tiles.begin();
           sit != (*it).tiles.end(); ++sit, ++i)
       {
-        std::string imagefile = "/images/tilesets/" ;
-        bool only_editor_image = false;
-        if(!TileManager::instance()->get(*sit)->filenames.empty())
-        {
-          imagefile += TileManager::instance()->get(*sit)->filenames[0];
-        }
-        else if(!TileManager::instance()->get(*sit)->editor_filenames.empty())
-        {
-          imagefile += TileManager::instance()->get(*sit)->editor_filenames[0];
-          only_editor_image = true;
-        }
+        Tile& tile = *(TileManager::instance()->get(*sit));
+        Surface* image;
+        if(tile.editor_images.size() > 0)
+          image = tile.editor_images[0];
+        else if(tile.images.size() > 0)
+          image = tile.images[0];
         else
-        {
-          imagefile += "notile.png";
-        }
-        Button* button = new Button(imagefile, it->name, SDLKey(SDLK_a + i),
+          // TODO use some notile image...
+          image = 0;
+
+        Button* button = new Button(image, it->name, SDLKey(SDLK_a + i),
                                     0, 0, 32, 32);
-        if(!only_editor_image)
-          if(!TileManager::instance()->get(*sit)->editor_filenames.empty())
-          {
-            imagefile = "/images/tilesets/" + TileManager::instance()->get(*sit)->editor_filenames[0];
-            button->add_icon(imagefile,32,32);
-          }
         tilegroups_map[it->name]->additem(button, *sit);
       }
     }
@@ -511,7 +501,7 @@ void le_init_menus()
   for(int i = 0; i < NUM_BadGuyKinds; ++i)
   {
     BadGuy bad_tmp(dummy, BadGuyKind(i), 0, 0);
-    objects_map["BadGuys"]->additem(new Button("", "BadGuy",(SDLKey)(i+'a'),0,0,32,32),1000000+i);
+    objects_map["BadGuys"]->additem(new Button(0, "BadGuy",(SDLKey)(i+'a'),0,0,32,32),1000000+i);
     objects_map["BadGuys"]->manipulate_button(i)->set_drawable(new
         BadGuy(dummy,
           BadGuyKind(i),
@@ -785,9 +775,9 @@ void le_drawminimap()
   int left_offset = (screen->w - 64 - le_world->get_level()->width*mini_tile_width) / 2;
 
   int mini_tile_height;
-  if(screen->h - 64 > le_world->get_level()->height * 4)
+  if(screen->h > le_world->get_level()->height * 4)
     mini_tile_height = 4;
-  else if(screen->h - 64 > le_world->get_level()->height * 2)
+  else if(screen->h > le_world->get_level()->height * 2)
     mini_tile_height = 2;
   else
     mini_tile_height = 1;
@@ -797,24 +787,33 @@ void le_drawminimap()
     for (int x = 0; x < le_world->get_level()->width; ++x)
     {
 
-      Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4,
-          mini_tile_width , 4, level->bg_tiles[y * level->width + x]);
+      Tile::draw_stretched(left_offset + mini_tile_width*x, y * mini_tile_height,
+          mini_tile_width , mini_tile_height, level->bg_tiles[y * level->width + x]);
 
-      Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4,
-          mini_tile_width , 4, level->ia_tiles[y * level->width + x]);
+      Tile::draw_stretched(left_offset + mini_tile_width*x, y * mini_tile_height,
+          mini_tile_width , mini_tile_height, level->ia_tiles[y * level->width + x]);
 
-      Tile::draw_stretched(left_offset + mini_tile_width*x, y * 4,
-          mini_tile_width , 4, level->fg_tiles[y + level->width + x]);
+      Tile::draw_stretched(left_offset + mini_tile_width*x, y * mini_tile_height,
+          mini_tile_width , mini_tile_height, level->fg_tiles[y + level->width + x]);
 
     }
 
-  fillrect(left_offset, 0, le_world->get_level()->width*mini_tile_width, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 128);
-
-  fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 19*mini_tile_width, 2, 200, 200, 200, 200);
-  fillrect(left_offset + (pos_x/32)*mini_tile_width, 0, 2, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 200);
-  fillrect(left_offset + (pos_x/32)*mini_tile_width + 19*mini_tile_width - 2, 0, 2, le_world->get_level()->height*mini_tile_height, 200, 200, 200, 200);
-  fillrect(left_offset + (pos_x/32)*mini_tile_width, le_world->get_level()->height*mini_tile_height-2, 19*mini_tile_width, 2, 200, 200, 200, 200);
-
+  fillrect(left_offset, 0,
+             le_world->get_level()->width*mini_tile_width, le_world->get_level()->height*mini_tile_height,
+             200, 200, 200, 96);
+
+  fillrect(left_offset + (pos_x/32)*mini_tile_width, (pos_y/32)*mini_tile_height,
+             (VISIBLE_TILES_X-3)*mini_tile_width, 2,
+             200, 200, 200, 200);
+  fillrect(left_offset + (pos_x/32)*mini_tile_width, (pos_y/32)*mini_tile_height,
+             2, (VISIBLE_TILES_Y-1)*mini_tile_height,
+             200, 200, 200, 200);
+  fillrect(left_offset + (pos_x/32)*mini_tile_width + (VISIBLE_TILES_X-3)*mini_tile_width - 2, (pos_y/32)*mini_tile_height,
+             2, (VISIBLE_TILES_Y-1)*mini_tile_height,
+             200, 200, 200, 200);
+  fillrect(left_offset + (pos_x/32)*mini_tile_width, (pos_y/32)*mini_tile_height + (VISIBLE_TILES_Y-1)*mini_tile_height - 2,
+             (VISIBLE_TILES_X-3)*mini_tile_width, 2,
+             200, 200, 200, 200);
 }
 
 void le_drawinterface()
@@ -1024,7 +1023,8 @@ void le_drawlevel()
 
 void le_change_object_properties(GameObject *pobj)
 {
-  Surface* cap_screen = Surface::CaptureScreen();
+  //Surface* cap_screen = Surface::CaptureScreen();
+    
   Menu* object_properties_menu = new Menu();
   bool loop = true;
 
@@ -1060,7 +1060,7 @@ void le_change_object_properties(GameObject *pobj)
       object_properties_menu->event(event);
     }
 
-    cap_screen->draw(0,0);
+    //cap_screen->draw(0,0);
 
     object_properties_menu->draw();
     object_properties_menu->action();
@@ -1090,7 +1090,7 @@ void le_change_object_properties(GameObject *pobj)
     SDL_Delay(25);
   }
 
-  delete cap_screen;
+  //delete cap_screen;
   Menu::set_current(0);
   delete object_properties_menu;
 }
@@ -1538,6 +1538,9 @@ void le_checkevents()
   {
     show_minimap = false;
 
+    if (event.type == SDL_KEYDOWN && event.key.keysym.sym == SDLK_TAB)
+      show_minimap = true;
+
     le_move_left_bt->event(event);
     le_move_right_bt->event(event);
     le_move_up_bt->event(event);
@@ -1610,19 +1613,17 @@ void le_checkevents()
       break;
     }
 
-      /* checking if pos_x and pos_y is within the limits... */
-      if(pos_x > (le_world->get_level()->width * 32 + 32*2) - screen->w)
-        pos_x = (le_world->get_level()->width * 32 + 32*2) - screen->w;
-      if(pos_x < 0)
-        pos_x = 0;
-
-      if(pos_y > (le_world->get_level()->height * 32) - screen->h)
-        pos_y = (le_world->get_level()->height * 32) - screen->h;
-      if(pos_y < 0)
-        pos_y = 0;
+    /* checking if pos_x and pos_y is within the limits... */
+    if(pos_x > (le_world->get_level()->width * 32 + 32*2) - screen->w)
+      pos_x = (le_world->get_level()->width * 32 + 32*2) - screen->w;
+    if(pos_x < 0)
+      pos_x = 0;
 
+    if(pos_y > (le_world->get_level()->height * 32) - screen->h)
+      pos_y = (le_world->get_level()->height * 32) - screen->h;
+    if(pos_y < 0)
+      pos_y = 0;
   }
-
 }
 
 void le_highlight_selection()
@@ -1925,3 +1926,5 @@ void le_showhelp()
   le_selection_mode = temp_le_selection_mode;
   le_help_shown = false;
 }
+
+#endif