From 36fde3d7e3fe50a442fde3423c54db6e8dc91eb0 Mon Sep 17 00:00:00 2001 From: lethosor Date: Fri, 5 Jun 2015 18:45:52 -0400 Subject: [PATCH] Allow Lua screens to allow OPTIONS to work --- library/include/modules/Screen.h | 2 ++ library/modules/Screen.cpp | 10 ++++++++++ 2 files changed, 12 insertions(+) diff --git a/library/include/modules/Screen.h b/library/include/modules/Screen.h index 3e9097c54..ab032c4e3 100644 --- a/library/include/modules/Screen.h +++ b/library/include/modules/Screen.h @@ -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 *keys); + virtual bool key_conflict(df::interface_key key); virtual void onShow(); virtual void onDismiss(); diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index 4866c80c1..517414766 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -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;