#include "sprite/sprite_manager.hpp"
#include "supertux/game_session.hpp"
#include "supertux/globals.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/screen_manager.hpp"
#include "supertux/menu/menu_storage.hpp"
#include "supertux/menu/options_menu.hpp"
#include "supertux/menu/worldmap_menu.hpp"
static const float CAMERA_PAN_SPEED = 5.0;
-namespace WorldMapNS {
+namespace worldmap {
WorldMap* WorldMap::current_ = NULL;
-Direction reverse_dir(Direction direction)
-{
- switch(direction)
- {
- case D_WEST:
- return D_EAST;
- case D_EAST:
- return D_WEST;
- case D_NORTH:
- return D_SOUTH;
- case D_SOUTH:
- return D_NORTH;
- case D_NONE:
- return D_NONE;
- }
- return D_NONE;
-}
-
-std::string
-direction_to_string(Direction direction)
-{
- switch(direction)
- {
- case D_WEST:
- return "west";
- case D_EAST:
- return "east";
- case D_NORTH:
- return "north";
- case D_SOUTH:
- return "south";
- default:
- return "none";
- }
-}
-
-Direction
-string_to_direction(const std::string& directory)
-{
- if (directory == "west")
- return D_WEST;
- else if (directory == "east")
- return D_EAST;
- else if (directory == "north")
- return D_NORTH;
- else if (directory == "south")
- return D_SOUTH;
- else if (directory == "none")
- return D_NONE;
- else {
- log_warning << "unknown direction: \"" << directory << "\"" << std::endl;
- return D_NONE;
- }
-}
-
-//---------------------------------------------------------------------------
-
WorldMap::WorldMap(const std::string& filename, const std::string& force_spawnpoint) :
tux(0),
tileset(NULL),
worldmap_menu.reset(new WorldmapMenu());
// create a new squirrel table for the worldmap
- using namespace Scripting;
+ using namespace scripting;
sq_collectgarbage(global_vm);
sq_newtable(global_vm);
sq_pushroottable(global_vm);
if(SQ_FAILED(sq_setdelegate(global_vm, -2)))
- throw Scripting::SquirrelError(global_vm, "Couldn't set worldmap_table delegate");
+ throw scripting::SquirrelError(global_vm, "Couldn't set worldmap_table delegate");
sq_resetobject(&worldmap_table);
if(SQ_FAILED(sq_getstackobj(global_vm, -1, &worldmap_table)))
- throw Scripting::SquirrelError(global_vm, "Couldn't get table from stack");
+ throw scripting::SquirrelError(global_vm, "Couldn't get table from stack");
sq_addref(global_vm, &worldmap_table);
sq_pop(global_vm, 1);
WorldMap::~WorldMap()
{
- using namespace Scripting;
+ using namespace scripting;
if(free_tileset)
delete tileset;
{
ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
if(interface != NULL) {
- HSQUIRRELVM vm = Scripting::global_vm;
+ HSQUIRRELVM vm = scripting::global_vm;
sq_pushobject(vm, worldmap_table);
interface->expose(vm, -1);
sq_pop(vm, 1);
{
ScriptInterface* interface = dynamic_cast<ScriptInterface*> (object);
if(interface != NULL) {
- HSQUIRRELVM vm = Scripting::global_vm;
+ HSQUIRRELVM vm = scripting::global_vm;
SQInteger oldtop = sq_gettop(vm);
sq_pushobject(vm, worldmap_table);
try {
void
WorldMap::change(const std::string& filename, const std::string& force_spawnpoint)
{
- g_main_loop->exit_screen();
- g_main_loop->push_screen(new WorldMap(filename, force_spawnpoint));
+ g_screen_manager->exit_screen();
+ g_screen_manager->push_screen(new WorldMap(filename, force_spawnpoint));
}
void
MenuManager::set_current(0);
break;
case MNID_QUITWORLDMAP: // Quit Worldmap
- g_main_loop->exit_screen();
+ g_screen_manager->exit_screen();
break;
}
}
// update state and savegame
save_state();
- g_main_loop->push_screen(new GameSession(levelfile, &level->statistics),
+ g_screen_manager->push_screen(new GameSession(levelfile, &level->statistics),
new ShrinkFade(shrinkpos, 1.0f));
in_level = true;
} catch(std::exception& e) {
tux->setup();
// register worldmap_table as worldmap in scripting
- using namespace Scripting;
+ using namespace scripting;
sq_pushroottable(global_vm);
sq_pushstring(global_vm, "worldmap", -1);
void
WorldMap::leave()
{
- using namespace Scripting;
+ using namespace scripting;
// save state of world and player
save_state();
void
WorldMap::save_state()
{
- using namespace Scripting;
+ using namespace scripting;
HSQUIRRELVM vm = global_vm;
int oldtop = sq_gettop(vm);
sq_pushroottable(vm);
sq_pushstring(vm, "state", -1);
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't get state table");
+ throw scripting::SquirrelError(vm, "Couldn't get state table");
// get or create worlds table
sq_pushstring(vm, "worlds", -1);
sq_pushstring(vm, "worlds", -1);
sq_newtable(vm);
if(SQ_FAILED(sq_createslot(vm, -3)))
- throw Scripting::SquirrelError(vm, "Couldn't create state.worlds");
+ throw scripting::SquirrelError(vm, "Couldn't create state.worlds");
sq_pushstring(vm, "worlds", -1);
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't create.get state.worlds");
+ throw scripting::SquirrelError(vm, "Couldn't create.get state.worlds");
}
sq_pushstring(vm, map_filename.c_str(), map_filename.length());
void
WorldMap::load_state()
{
- using namespace Scripting;
+ using namespace scripting;
HSQUIRRELVM vm = global_vm;
int oldtop = sq_gettop(vm);
sq_pushroottable(vm);
sq_pushstring(vm, "state", -1);
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't get state table");
+ throw scripting::SquirrelError(vm, "Couldn't get state table");
// get worlds table
sq_pushstring(vm, "worlds", -1);
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't get state.worlds");
+ throw scripting::SquirrelError(vm, "Couldn't get state.worlds");
// get table for our world
sq_pushstring(vm, map_filename.c_str(), map_filename.length());
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't get state.worlds.mapfilename");
+ throw scripting::SquirrelError(vm, "Couldn't get state.worlds.mapfilename");
// load tux
sq_pushstring(vm, "tux", -1);
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't get tux");
+ throw scripting::SquirrelError(vm, "Couldn't get tux");
Vector p;
p.x = read_float(vm, "x");
// load levels
sq_pushstring(vm, "levels", -1);
if(SQ_FAILED(sq_get(vm, -2)))
- throw Scripting::SquirrelError(vm, "Couldn't get levels");
+ throw scripting::SquirrelError(vm, "Couldn't get levels");
for(LevelTiles::iterator i = levels.begin(); i != levels.end(); ++i) {
LevelTile* level = *i;
HSQUIRRELVM
WorldMap::run_script(std::istream& in, const std::string& sourcename)
{
- using namespace Scripting;
+ using namespace scripting;
// garbage collect thread list
for(ScriptList::iterator i = scripts.begin();
return height;
}
-} // namespace WorldMapNS
+} // namespace worldmap
/* EOF */