Allow Lua screens to allow OPTIONS to work

develop
lethosor 2015-06-05 18:45:52 -04:00
parent 091f53a9e1
commit 36fde3d7e3
2 changed files with 12 additions and 0 deletions

@ -334,6 +334,7 @@ namespace DFHack
static int do_notify(lua_State *L);
static int do_input(lua_State *L);
bool allow_options;
public:
dfhack_lua_viewscreen(lua_State *L, int table_idx);
virtual ~dfhack_lua_viewscreen();
@ -348,6 +349,7 @@ namespace DFHack
virtual void help();
virtual void resize(int w, int h);
virtual void feed(std::set<df::interface_key> *keys);
virtual bool key_conflict(df::interface_key key);
virtual void onShow();
virtual void onDismiss();

@ -659,6 +659,9 @@ void dfhack_lua_viewscreen::update_focus(lua_State *L, int idx)
lua_getfield(L, idx, "text_input_mode");
text_input_mode = lua_toboolean(L, -1);
lua_pop(L, 1);
lua_getfield(L, idx, "allow_options");
allow_options = lua_toboolean(L, -1);
lua_pop(L, 1);
lua_getfield(L, idx, "focus_path");
auto str = lua_tostring(L, -1);
@ -824,6 +827,13 @@ void dfhack_lua_viewscreen::logic()
safe_call_lua(do_notify, 1, 0);
}
bool dfhack_lua_viewscreen::key_conflict(df::interface_key key)
{
if (key == df::interface_key::OPTIONS)
return !allow_options;
return dfhack_viewscreen::key_conflict(key);
}
void dfhack_lua_viewscreen::help()
{
if (Screen::isDismissed(this)) return;