* svn:ignored .externalToolBuilders in root directory (Eclipse+CDT)
[supertux.git] / src / leveleditor.cpp
index 9ae0dc1..7cc0756 100644 (file)
@@ -1,3 +1,23 @@
+//  $Id$
+// 
+//  SuperTux
+//  Copyright (C) 2005 Matthias Braun <matze@braunis.de>
+//
+//  This program is free software; you can redistribute it and/or
+//  modify it under the terms of the GNU General Public License
+//  as published by the Free Software Foundation; either version 2
+//  of the License, or (at your option) any later version.
+//
+//  This program is distributed in the hope that it will be useful,
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//  GNU General Public License for more details.
+// 
+//  You should have received a copy of the GNU General Public License
+//  along with this program; if not, write to the Free Software
+//  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+//  02111-1307, USA.
+
 /***************************************************************************
                   leveleditor.cpp  -  built'in leveleditor
                      -------------------
@@ -14,7 +34,7 @@
  *   (at your option) any later version.                                   *
  *                                                                         *
  ***************************************************************************/
-
+#if 0
 #include <config.h>
 
 #include <stdlib.h>
 #include "gui/button.h"
 #include "audio/sound_manager.h"
 #include "app/gettext.h"
-#include "app/setup.h"
-#include "app/globals.h"
-#include "special/sprite.h"
+#include "sprite/sprite.h"
 #include "leveleditor.h"
 #include "resources.h"
 #include "tile.h"
 #include "tile_manager.h"
 #include "sector.h"
-#include "gameloop.h"
+#include "game_session.h"
 #include "object_factory.h"
 #include "object/gameobjs.h"
 #include "object/camera.h"
@@ -59,7 +77,7 @@ LevelEditor::LevelEditor()
   /* Creating menus */
   level_subsets = FileSystem::dsubdirs("/levels", "info");
   subset_menu = new Menu();
-  subset_menu->additem(MN_LABEL,_("Load Subset"),0,0);
+  subset_menu->add_label(_("Load Subset"));
   subset_menu->additem(MN_HL,"",0,0);
   int i = 0;
   for(std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it, ++i)
@@ -99,7 +117,7 @@ LevelEditor::LevelEditor()
   /* Creating button groups */
   load_buttons_gfx();
 
-  tiles_board = new ButtonGroup(Vector(screen->w - 140, 100),
+  tiles_board = new ButtonGroup(Vector(SCREEN_WIDTH - 140, 100),
             Vector(32,32), Vector(4,8));
 
   tiles_board->add_button(Button(img_rubber_bt, _("Eraser"), SDLKey(SDLK_DELETE)), 0);
@@ -128,7 +146,7 @@ LevelEditor::LevelEditor()
                             SDLKey(SDLK_1+id)), id++);
   }
 
-  tiles_layer = new ButtonGroup(Vector(12, screen->h-64), Vector(80,20), Vector(1,3));
+  tiles_layer = new ButtonGroup(Vector(12, SCREEN_HEIGHT-64), Vector(80,20), Vector(1,3));
   tiles_layer->add_button(Button(img_foreground_bt, _("Edtit foreground tiles"),
                          SDLK_F10), LAYER_FOREGROUNDTILES);
   tiles_layer->add_button(Button(img_interactive_bt, _("Edit interactive tiles"),
@@ -136,7 +154,7 @@ LevelEditor::LevelEditor()
   tiles_layer->add_button(Button(img_background_bt, _("Edit background tiles"),
                          SDLK_F12), LAYER_BACKGROUNDTILES);
 
-  level_options = new ButtonGroup(Vector(screen->w-164, screen->h-36), Vector(32,32), Vector(5,1));
+  level_options = new ButtonGroup(Vector(SCREEN_WIDTH-164, SCREEN_HEIGHT-36), Vector(32,32), Vector(5,1));
   level_options->add_pair_of_buttons(Button(img_next_sector_bt, _("Next sector"), SDLKey(0)), BT_NEXT_SECTOR,
                  Button(img_previous_sector_bt, _("Prevous sector"), SDLKey(0)), BT_PREVIOUS_SECTOR);
   level_options->add_pair_of_buttons(Button(img_next_level_bt, _("Next level"), SDLKey(0)), BT_NEXT_LEVEL,
@@ -201,7 +219,7 @@ delete img_next_sector_bt;
 
 void LevelEditor::run(const std::string filename)
 {
-  SoundManager::get()->halt_music();
+  sound_manager->halt_music();
   Menu::set_current(0);
 
   DrawingContext context;
@@ -469,7 +487,7 @@ void LevelEditor::events()
               scroll.x = 0;
               break;
             case SDLK_END:
-              scroll.x = sector->solids->get_height()*32 - screen->w;
+              scroll.x = sector->solids->get_height()*32 - SCREEN_WIDTH;
               break;
             case SDLK_LEFT:
               scroll.x -= 80;
@@ -532,14 +550,14 @@ void LevelEditor::action()
     float width = sector->solids->get_width() * 32;
     float height = sector->solids->get_height() * 32;
 
-    if(scroll.x < -screen->w/2)
-      scroll.x = -screen->w/2;
-    if(scroll.x > width - screen->w/2)
-      scroll.x = width - screen->w/2;
-    if(scroll.y < -screen->h/2)
-      scroll.y = -screen->h/2;
-    if(scroll.y > height - screen->h/2)
-      scroll.y = height - screen->h/2;
+    if(scroll.x < -SCREEN_WIDTH/2)
+      scroll.x = -SCREEN_WIDTH/2;
+    if(scroll.x > width - SCREEN_WIDTH/2)
+      scroll.x = width - SCREEN_WIDTH/2;
+    if(scroll.y < -SCREEN_HEIGHT/2)
+      scroll.y = -SCREEN_HEIGHT/2;
+    if(scroll.y > height - SCREEN_HEIGHT/2)
+      scroll.y = height - SCREEN_HEIGHT/2;
 
     // set camera translation, since BadGuys like it
     sector->camera->set_scrolling((int)scroll.x, (int)scroll.y);
@@ -561,7 +579,7 @@ void LevelEditor::draw(DrawingContext& context)
   mouse_cursor->draw(context);
 
   // draw a filled background
-  context.draw_filled_rect(Vector(0,0), Vector(screen->w,screen->h), Color(60,60,60), LAYER_BACKGROUND0-1);
+  context.draw_filled_rect(Vector(0,0), Vector(SCREEN_WIDTH,SCREEN_HEIGHT), Color(60,60,60), LAYER_BACKGROUND0-1);
 
   if(level_name_timer.check())
     {
@@ -569,12 +587,12 @@ void LevelEditor::draw(DrawingContext& context)
     if(level_name_timer.get_timeleft() < FADING_TIME)
       context.set_alpha(int(level_name_timer.get_timeleft() * 255 / FADING_TIME));
 
-    context.draw_text(gold_text, level->name, Vector(screen->w/2, 30), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(gold_text, level->name, Vector(SCREEN_WIDTH/2, 30), CENTER_ALLIGN, LAYER_GUI);
     if(level_nb != -1)
       {
       char str[128];
       sprintf(str, "%i/%i", level_nb+1, level_subset->get_num_levels());
-      context.draw_text(gold_text, str, Vector(screen->w/2, 50), CENTER_ALLIGN, LAYER_GUI);
+      context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, 50), CENTER_ALLIGN, LAYER_GUI);
       }
 
     context.pop_transform();
@@ -657,16 +675,16 @@ void LevelEditor::draw(DrawingContext& context)
 
     if(show_grid)
       {
-      for(int x = 0; x < screen->w / (32*zoom); x++)
+      for(int x = 0; x < SCREEN_WIDTH / (32*zoom); x++)
         {
         int pos = (int)(x*32*zoom) - ((int)scroll.x % 32);
-        context.draw_filled_rect(Vector (pos, 0), Vector(1, screen->h),
+        context.draw_filled_rect(Vector (pos, 0), Vector(1, SCREEN_HEIGHT),
                   Color(225, 225, 225), LAYER_GUI-50);
         }
-      for(int y = 0; y < screen->h / (32*zoom); y++)
+      for(int y = 0; y < SCREEN_HEIGHT / (32*zoom); y++)
         {
         int pos = (int)(y*32*zoom) - ((int)scroll.y % 32);
-        context.draw_filled_rect(Vector (0, pos), Vector(screen->w, 1),
+        context.draw_filled_rect(Vector (0, pos), Vector(SCREEN_WIDTH, 1),
                   Color(225, 225, 225), LAYER_GUI-50);
         }
       }
@@ -704,7 +722,7 @@ void LevelEditor::draw(DrawingContext& context)
     context.pop_transform();
     }
   else
-    context.draw_filled_rect(Vector(0,0), Vector(screen->w,screen->h),Color(0,0,0), LAYER_BACKGROUND0);
+    context.draw_filled_rect(Vector(0,0), Vector(SCREEN_WIDTH,SCREEN_HEIGHT),Color(0,0,0), LAYER_BACKGROUND0);
 
   context.do_drawing();
 }
@@ -834,7 +852,7 @@ void LevelEditor::test_level()
   GameSession session(level_filename, ST_GL_TEST);
   session.run();
   //  player_status.reset();
-  SoundManager::get()->halt_music();
+  sound_manager->halt_music();
 }
 
 void LevelEditor::change(int x, int y, int newtile, int layer)
@@ -995,12 +1013,12 @@ void LevelEditor::show_help()
     {
     draw(context);
 
-    context.draw_text(blue_text, _("- Level Editor's Help -"), Vector(screen->w/2, 60), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(blue_text, _("- Level Editor's Help -"), Vector(SCREEN_WIDTH/2, 60), CENTER_ALLIGN, LAYER_GUI);
 
     context.draw_text(white_small_text, *text[i], Vector(20, 120), LEFT_ALLIGN, LAYER_GUI);
 
     sprintf(str,_("Press any key to continue - Page %d/%d"), i+1, sizeof(text) / sizeof(text[0]));
-    context.draw_text(gold_text, str, Vector(screen->w/2, screen->h-60), CENTER_ALLIGN, LAYER_GUI);
+    context.draw_text(gold_text, str, Vector(SCREEN_WIDTH/2, SCREEN_HEIGHT-60), CENTER_ALLIGN, LAYER_GUI);
 
     context.do_drawing();
 
@@ -1032,3 +1050,4 @@ LevelEditor::create_sector(const std::string& name, size_t width, size_t height)
   return sector;
 }
 
+#endif