Removed the old menu system (/menu and /choose) entirely
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include "world.hpp"
|
||||
#include "idalloc.hpp"
|
||||
#include "animqueue.hpp"
|
||||
#include "gui.hpp"
|
||||
#include "traceback.hpp"
|
||||
#include "pprint.hpp"
|
||||
#include "util.hpp"
|
||||
@@ -48,9 +47,6 @@ World::World(WorldType wt) {
|
||||
// Put the world pointer into the lua registry.
|
||||
World::store_global_pointer(state(), this);
|
||||
|
||||
// Clear the global GUI pointer.
|
||||
Gui::store_global_pointer(state(), nullptr);
|
||||
|
||||
// Clear the lthread state.
|
||||
clear_lthread_state();
|
||||
|
||||
@@ -347,52 +343,6 @@ eng::string World::probe_lua(int64_t actor_id, std::string_view lua) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void World::update_gui(int64_t actor_id, int64_t place_id, Gui *gui) {
|
||||
assert(stack_is_clear());
|
||||
gui->clear(place_id);
|
||||
lua_State *L = state();
|
||||
|
||||
LuaVar actor, place, ugui, func, tangibles, mt, index;
|
||||
LuaExtStack LS(L, actor, place, ugui, func, tangibles, mt, index);
|
||||
|
||||
// Get the actor and place.
|
||||
LS.rawget(tangibles, LuaRegistry, "tangibles");
|
||||
LS.rawget(actor, tangibles, actor_id);
|
||||
LS.rawget(place, tangibles, place_id);
|
||||
if (!LS.istable(actor) || !LS.istable(place)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the interface closure.
|
||||
LS.getmetatable(mt, place);
|
||||
if (!LS.istable(mt)) {
|
||||
return;
|
||||
}
|
||||
LS.rawget(index, mt, "__index");
|
||||
if (!LS.istable(index)) {
|
||||
return;
|
||||
}
|
||||
LS.rawget(func, index, "interface");
|
||||
if (!LS.isfunction(func)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Call the interface function.
|
||||
lua_pushvalue(L, func.index());
|
||||
lua_pushvalue(L, actor.index());
|
||||
lua_pushvalue(L, place.index());
|
||||
Gui::store_global_pointer(L, gui);
|
||||
open_lthread_state(actor_id, place_id, 0, false, false);
|
||||
eng::string msg = traceback_pcall(L, 2, 0);
|
||||
close_lthread_state();
|
||||
Gui::store_global_pointer(L, nullptr);
|
||||
if (!msg.empty()) {
|
||||
gui->clear(0);
|
||||
util::dprint(msg);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// This is called from World::update_source, and also
|
||||
// from World::patch_source in the difference transmitter.
|
||||
//
|
||||
@@ -563,7 +513,6 @@ HttpServerResponse World::http_serve(const HttpParser &request) {
|
||||
int oldtop = lua_gettop(L);
|
||||
lua_pushvalue(L, func.index());
|
||||
lua_pushvalue(L, reqtab.index());
|
||||
Gui::store_global_pointer(L, nullptr);
|
||||
open_lthread_state(0, 0, 0, false, false);
|
||||
eng::string msg = traceback_pcall(L, 1, LUA_MULTRET);
|
||||
close_lthread_state();
|
||||
@@ -602,9 +551,6 @@ void World::run_unittests() {
|
||||
|
||||
void World::invoke(const Invocation &inv) {
|
||||
switch (inv.kind()) {
|
||||
case Invocation::KIND_CHOOSE:
|
||||
invoke_choose(inv.actor(), inv.place(), inv.datapack());
|
||||
break;
|
||||
case Invocation::KIND_ENGIO:
|
||||
invoke_engio(inv.actor(), inv.place(), inv.datapack());
|
||||
break;
|
||||
@@ -757,40 +703,6 @@ void World::invoke_lua(int64_t actor_id, int64_t place_id, std::string_view data
|
||||
assert(stack_is_clear());
|
||||
}
|
||||
|
||||
void World::invoke_choose(int64_t actor_id, int64_t place_id, std::string_view datapack) {
|
||||
assert(stack_is_clear());
|
||||
|
||||
// Validate that the action is legal.
|
||||
Gui validation_gui;
|
||||
update_gui(actor_id, place_id, &validation_gui);
|
||||
if (!validation_gui.has_action(datapack)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure the action starts with "cb_"
|
||||
if (!sv::has_prefix(datapack, "cb_")) {
|
||||
return;
|
||||
}
|
||||
{
|
||||
lua_State *L = state();
|
||||
LuaVar func, invdata;
|
||||
LuaExtStack LS(L, func, invdata);
|
||||
|
||||
|
||||
LS.set(func, datapack);
|
||||
|
||||
// We're planning to add the ability to pass data in as a table.
|
||||
// For now the table is always empty.
|
||||
LS.newtable(invdata);
|
||||
|
||||
// Spawn the thread and run it.
|
||||
int nargs = 1;
|
||||
lua_pushvalue(L, invdata.index());
|
||||
spawn(LS, actor_id, place_id, func, true, nargs, false);
|
||||
}
|
||||
run_scheduled_threads();
|
||||
assert(stack_is_clear());
|
||||
}
|
||||
|
||||
// Read a SimpleDynamic value from the streambuffer and push
|
||||
// it onto the lua stack.
|
||||
|
||||
Reference in New Issue
Block a user