fysxasteroids/asteroids/ModelCommands.cc

49 lines
939 B
C++
Raw Normal View History

2010-04-05 23:38:59 +02:00
#include "Model.h"
namespace asteroids {
static Model *ModelInstance = NULL;
bool Cmd_SaveLevel (const std::vector<std::string> args) {
assert (ModelInstance);
if (args.size() != 1) {
Engine::CommandSetErrorString ("usage: savelevel <path_to_level>");
return false;
}
if (ModelInstance->DoSaveLevel (args[0].c_str()) > 0)
return true;
// ToDo: Maybe some error output?
return false;
}
bool Cmd_LoadLevel (const std::vector<std::string> args) {
assert (ModelInstance);
if (args.size() != 1) {
Engine::CommandSetErrorString ("usage: loadlevel <path_to_level>");
return false;
}
if (ModelInstance->DoLoadLevel (args[0].c_str()) > 0)
return true;
// ToDo: Maybe some error output?
return false;
}
void Model::OnRegisterCommands () {
ModelInstance = this;
Engine::ModelBase::OnRegisterCommands ();
Engine::AddCommand ("savelevel", Cmd_SaveLevel);
Engine::AddCommand ("loadlevel", Cmd_LoadLevel);
}
}