#include "util/gettext.hpp"
#include "video/renderer.hpp"
#include "worldmap/tux.hpp"
+#include "worldmap/worldmap.hpp"
#include "scripting/squirrel_util.hpp"
#include "scripting/time_scheduler.hpp"
g_screen_manager->push_screen(std::unique_ptr<Screen>(new TextScroller(filename)));
}
+void load_worldmap(const std::string& filename)
+{
+ using namespace worldmap;
+
+ if (!WorldMap::current())
+ {
+ throw std::runtime_error("Can't start Worldmap without active WorldMap");
+ }
+ else
+ {
+ g_screen_manager->push_screen(std::unique_ptr<Screen>(new WorldMap(filename, WorldMap::current()->get_savegame())));
+ }
+}
+
+void load_level(const std::string& filename)
+{
+ if (!GameSession::current())
+ {
+ throw std::runtime_error("Can't start level without active level.");
+ }
+ else
+ {
+ g_screen_manager->push_screen(std::unique_ptr<Screen>(new GameSession(filename, GameSession::current()->get_savegame())));
+ }
+}
+
void import(HSQUIRRELVM vm, const std::string& filename)
{
IFileStream in(filename);
WorldMap::current()->get_tux()->set_ghost_mode(enable);
}
+void save_state()
+{
+ using worldmap::WorldMap;
+
+ if (!WorldMap::current())
+ {
+ throw std::runtime_error("Can't save state without active Worldmap");
+ }
+ else
+ {
+ WorldMap::current()->save_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 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, "debug_collrects", -1);
sq_newclosure(v, &debug_collrects_wrapper, 0);
sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, "x|tb");