49 lines
939 B
C++
49 lines
939 B
C++
|
#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);
|
||
|
}
|
||
|
|
||
|
}
|