From d7d3dcb0beae631370dc4d824fdd8ce44f561dc2 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 19 Feb 2023 23:27:16 -0800 Subject: [PATCH] keep focus strings if they are already labeled i.e. don't add a "dfhack/" prefix if the focus string already has the string "dfhack" in it --- library/modules/Gui.cpp | 7 ++++++- library/modules/Screen.cpp | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/library/modules/Gui.cpp b/library/modules/Gui.cpp index e3a7ba983..6ea0a5ff0 100644 --- a/library/modules/Gui.cpp +++ b/library/modules/Gui.cpp @@ -491,7 +491,12 @@ bool Gui::matchFocusString(std::string focus_string, df::viewscreen *top) { static void push_dfhack_focus_string(dfhack_viewscreen *vs, std::vector &focusStrings) { auto name = vs->getFocusString(); - focusStrings.push_back(name.empty() ? "dfhack" : "dfhack/" + name); + if (name.empty()) + name = "dfhack"; + else if (string::npos == name.find("dfhack/")) + name = "dfhack/" + name; + + focusStrings.push_back(name); } std::vector Gui::getFocusStrings(df::viewscreen* top) diff --git a/library/modules/Screen.cpp b/library/modules/Screen.cpp index a78a36a3f..ca0876904 100644 --- a/library/modules/Screen.cpp +++ b/library/modules/Screen.cpp @@ -877,7 +877,7 @@ void dfhack_lua_viewscreen::update_focus(lua_State *L, int idx) if (focus.empty()) focus = "lua"; - else + else if (string::npos == focus.find("lua/")) focus = "lua/"+focus; }