Console logging is now identical in all builds; warning and error show the console...
[supertux.git] / src / scripting / functions.cpp
index fa2fad4..4fb1a6a 100644 (file)
@@ -29,6 +29,7 @@
 #include "supertux/sector.hpp"
 #include "supertux/shrinkfade.hpp"
 #include "supertux/textscroller.hpp"
+#include "supertux/tile.hpp"
 #include "supertux/world.hpp"
 #include "util/gettext.hpp"
 #include "worldmap/tux.hpp"
@@ -36,7 +37,7 @@
 #include "scripting/squirrel_util.hpp"
 #include "scripting/time_scheduler.hpp"
 
-namespace Scripting {
+namespace scripting {
 
 SQInteger display(HSQUIRRELVM vm)
 {
@@ -97,24 +98,20 @@ void display_text_file(const std::string& filename)
 
 void load_worldmap(const std::string& filename)
 {
-  using namespace WorldMapNS;
+  using namespace worldmap;
 
-  g_screen_manager->push_screen(new WorldMap(filename));
-}
+  if(World::current() == NULL)
+    throw std::runtime_error("Can't start WorldMap without active world.");
 
-void load_level(const std::string& filename)
-{
-  g_screen_manager->push_screen(new GameSession(filename));
+  g_screen_manager->push_screen(new WorldMap(filename, World::current()->get_player_status()));
 }
 
-static SQInteger squirrel_read_char(SQUserPointer file)
+void load_level(const std::string& filename)
 {
-  std::istream* in = reinterpret_cast<std::istream*> (file);
-  char c = in->get();
-  if(in->eof())
-    return 0;
+  if(GameSession::current() == NULL)
+    throw std::runtime_error("Can't start level without active level.");
 
-  return c;
+  g_screen_manager->push_screen(new GameSession(filename, GameSession::current()->get_player_status()));
 }
 
 void import(HSQUIRRELVM vm, const std::string& filename)
@@ -148,9 +145,14 @@ void debug_draw_solids_only(bool enable)
   Sector::draw_solids_only = enable;
 }
 
+void debug_draw_editor_images(bool enable)
+{
+  Tile::draw_editor_images = enable;
+}
+
 void debug_worldmap_ghost(bool enable)
 {
-  using namespace WorldMapNS;
+  using namespace worldmap;
 
   if(WorldMap::current() == NULL)
     throw std::runtime_error("Can't change ghost mode without active WorldMap");
@@ -160,7 +162,7 @@ void debug_worldmap_ghost(bool enable)
 
 void save_state()
 {
-  using namespace WorldMapNS;
+  using namespace worldmap;
 
   if(World::current() == NULL || WorldMap::current() == NULL)
     throw std::runtime_error("Can't save state without active World");
@@ -171,7 +173,7 @@ void save_state()
 
 void update_worldmap()
 {
-  using namespace WorldMapNS;
+  using namespace worldmap;
 
   if(WorldMap::current() == NULL)
     throw std::runtime_error("Can't update Worldmap: none active");
@@ -210,7 +212,7 @@ void play_sound(const std::string& filename)
 void grease()
 {
   if (!validate_sector_player()) return;
-  ::Player* tux = Sector::current()->player; // Scripting::Player != ::Player
+  ::Player* tux = Sector::current()->player; // scripting::Player != ::Player
   tux->get_physic().set_velocity_x(tux->get_physic().get_velocity_x()*3);
 }