diff --git a/docs/changelog.txt b/docs/changelog.txt index ca6f42372..6fff8b61b 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -43,6 +43,7 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Documentation ## API +- Gui focus strings will no longer get the "dfhack/" prefix if the string "dfhack/" already exists in the focus string ## Lua -@ ``gui.INTERIOR_FRAME``: a panel frame style for use in highlighting off interior areas of a UI 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; }