g_screen_manager->push_screen(std::unique_ptr<Screen>(new TextScroller(filename)));
}
-void load_worldmap(const std::string& filename)
-{
- using namespace worldmap;
-
- if(World::current() == NULL)
- throw std::runtime_error("Can't start WorldMap without active world.");
-
- g_screen_manager->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, World::current()->get_player_status())));
-}
-
-void load_level(const std::string& filename)
-{
- if(GameSession::current() == NULL)
- throw std::runtime_error("Can't start level without active level.");
-
- g_screen_manager->push_screen(std::unique_ptr<Screen>(new GameSession(filename, GameSession::current()->get_player_status())));
-}
-
void import(HSQUIRRELVM vm, const std::string& filename)
{
IFileStream in(filename);
WorldMap::current()->get_tux()->set_ghost_mode(enable);
}
-void save_state()
-{
- using namespace worldmap;
-
- if(World::current() == NULL || WorldMap::current() == NULL)
- throw std::runtime_error("Can't save state without active World");
-
- WorldMap::current()->save_state();
- World::current()->save_state();
-}
-
-void update_worldmap()
-{
- using namespace worldmap;
-
- if(WorldMap::current() == NULL)
- throw std::runtime_error("Can't update Worldmap: none active");
-
- WorldMap::current()->load_state();
-}
-
// not added to header, function to only be used by others
// in this file
bool validate_sector_player()
}
-static SQInteger load_worldmap_wrapper(HSQUIRRELVM vm)
-{
- const SQChar* arg0;
- if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) {
- sq_throwerror(vm, _SC("Argument 1 not a string"));
- return SQ_ERROR;
- }
-
- try {
- scripting::load_worldmap(arg0);
-
- return 0;
-
- } catch(std::exception& e) {
- sq_throwerror(vm, e.what());
- return SQ_ERROR;
- } catch(...) {
- sq_throwerror(vm, _SC("Unexpected exception while executing function 'load_worldmap'"));
- return SQ_ERROR;
- }
-
-}
-
-static SQInteger load_level_wrapper(HSQUIRRELVM vm)
-{
- const SQChar* arg0;
- if(SQ_FAILED(sq_getstring(vm, 2, &arg0))) {
- sq_throwerror(vm, _SC("Argument 1 not a string"));
- return SQ_ERROR;
- }
-
- try {
- scripting::load_level(arg0);
-
- return 0;
-
- } catch(std::exception& e) {
- sq_throwerror(vm, e.what());
- return SQ_ERROR;
- } catch(...) {
- sq_throwerror(vm, _SC("Unexpected exception while executing function 'load_level'"));
- return SQ_ERROR;
- }
-
-}
-
static SQInteger wait_wrapper(HSQUIRRELVM vm)
{
HSQUIRRELVM arg0 = vm;
}
-static SQInteger save_state_wrapper(HSQUIRRELVM vm)
-{
- (void) vm;
-
- try {
- scripting::save_state();
-
- return 0;
-
- } catch(std::exception& e) {
- sq_throwerror(vm, e.what());
- return SQ_ERROR;
- } catch(...) {
- sq_throwerror(vm, _SC("Unexpected exception while executing function 'save_state'"));
- return SQ_ERROR;
- }
-
-}
-
-static SQInteger update_worldmap_wrapper(HSQUIRRELVM vm)
-{
- (void) vm;
-
- try {
- scripting::update_worldmap();
-
- return 0;
-
- } catch(std::exception& e) {
- sq_throwerror(vm, e.what());
- return SQ_ERROR;
- } catch(...) {
- sq_throwerror(vm, _SC("Unexpected exception while executing function 'update_worldmap'"));
- return SQ_ERROR;
- }
-
-}
-
static SQInteger debug_collrects_wrapper(HSQUIRRELVM vm)
{
SQBool arg0;
throw SquirrelError(v, "Couldn't register function 'display_text_file'");
}
- sq_pushstring(v, "load_worldmap", -1);
- sq_newclosure(v, &load_worldmap_wrapper, 0);
- sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|ts");
- if(SQ_FAILED(sq_createslot(v, -3))) {
- throw SquirrelError(v, "Couldn't register function 'load_worldmap'");
- }
-
- sq_pushstring(v, "load_level", -1);
- sq_newclosure(v, &load_level_wrapper, 0);
- sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|ts");
- if(SQ_FAILED(sq_createslot(v, -3))) {
- throw SquirrelError(v, "Couldn't register function 'load_level'");
- }
-
sq_pushstring(v, "wait", -1);
sq_newclosure(v, &wait_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tn");
throw SquirrelError(v, "Couldn't register function 'import'");
}
- sq_pushstring(v, "save_state", -1);
- sq_newclosure(v, &save_state_wrapper, 0);
- sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|t");
- if(SQ_FAILED(sq_createslot(v, -3))) {
- throw SquirrelError(v, "Couldn't register function 'save_state'");
- }
-
- sq_pushstring(v, "update_worldmap", -1);
- sq_newclosure(v, &update_worldmap_wrapper, 0);
- sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|t");
- if(SQ_FAILED(sq_createslot(v, -3))) {
- throw SquirrelError(v, "Couldn't register function 'update_worldmap'");
- }
-
sq_pushstring(v, "debug_collrects", -1);
sq_newclosure(v, &debug_collrects_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb");