Added invoke_plan, removed viewer
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
#include "luastack.hpp"
|
||||
#include "util.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "viewer.hpp"
|
||||
#include "world.hpp"
|
||||
#include "traceback.hpp"
|
||||
#include "textgame.hpp"
|
||||
#include "luaconsole.hpp"
|
||||
@@ -44,7 +44,7 @@ static void l_message(const char *msg)
|
||||
}
|
||||
|
||||
void TextGame::do_lua(const std::string &exp) {
|
||||
lua_State *L = viewer_.state();
|
||||
lua_State *L = world_->state();
|
||||
int status = luaL_loadbuffer(L, exp.c_str(), exp.size(), "=stdin");
|
||||
assert(status == LUA_OK);
|
||||
globalL = L;
|
||||
@@ -81,8 +81,8 @@ void TextGame::do_view_command(const StringVec &cmd) {
|
||||
std::cerr << "v command (view) takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
for (int64_t id : viewer_.get_near()) {
|
||||
const Tangible *tan = viewer_.tangible_get(id);
|
||||
for (int64_t id : world_->get_near(1, 100)) {
|
||||
const Tangible *tan = world_->tangible_get(id);
|
||||
const AnimQueue &aq = tan->anim_queue_;
|
||||
std::cerr << id << ": " << aq.get_graphic() << " " << aq.get_plane() << " " << aq.get_xyz() << std::endl;
|
||||
}
|
||||
@@ -98,8 +98,8 @@ void TextGame::do_menu_command(const StringVec &cmd) {
|
||||
std::cerr << "m command (menu) expects a tangible ID or defaults to 1" << std::endl;
|
||||
return;
|
||||
}
|
||||
gui_id_ = id;
|
||||
viewer_.update_gui(id, &gui_);
|
||||
gui_place_ = id;
|
||||
world_->update_gui(1, id, &gui_);
|
||||
int index = 0;
|
||||
for (const GuiElt &elt : gui_.elts()) {
|
||||
std::cerr << index << " " << elt.label() << std::endl;
|
||||
@@ -120,7 +120,9 @@ void TextGame::do_choose_command(const StringVec &cmd) {
|
||||
std::cerr << "No menu item #" << index << std::endl;
|
||||
return;
|
||||
}
|
||||
std::cerr << "Choosing menu item: " << elts[index].id() << std::endl;
|
||||
std::string action = elts[index].action();
|
||||
std::cerr << "Invoking plan: " << action << std::endl;
|
||||
world_->invoke_plan(1, gui_place_, action, &gui_);
|
||||
}
|
||||
|
||||
void TextGame::do_snapshot_command(const StringVec &cmd) {
|
||||
@@ -128,7 +130,7 @@ void TextGame::do_snapshot_command(const StringVec &cmd) {
|
||||
std::cerr << "s command (snapshot) takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
viewer_.snapshot();
|
||||
world_->snapshot();
|
||||
}
|
||||
|
||||
void TextGame::do_rollback_command(const StringVec &cmd) {
|
||||
@@ -136,7 +138,7 @@ void TextGame::do_rollback_command(const StringVec &cmd) {
|
||||
std::cerr << "r command (rollback) takes no arguments" << std::endl;
|
||||
return;
|
||||
}
|
||||
viewer_.rollback();
|
||||
world_->rollback();
|
||||
}
|
||||
|
||||
void TextGame::do_quit_command(const StringVec &cmd) {
|
||||
@@ -161,6 +163,8 @@ void TextGame::do_command(const StringVec &words) {
|
||||
|
||||
void TextGame::run()
|
||||
{
|
||||
world_.reset(new World);
|
||||
world_->init_standalone();
|
||||
console_.clear();
|
||||
while (true) {
|
||||
console_.add_stdin();
|
||||
|
||||
Reference in New Issue
Block a user