MCPcopy Create free account
hub / github.com/DFHack/dfhack / getFocusStrings

Method getFocusStrings

library/modules/Gui.cpp:948–987  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

946}
947
948std::vector<std::string> Gui::getFocusStrings(df::viewscreen* top)
949{
950 std::vector<std::string> focusStrings;
951
952 if (!top)
953 return focusStrings;
954
955 if (dfhack_viewscreen::is_instance(top))
956 {
957 dfhack_viewscreen *vs = static_cast<dfhack_viewscreen*>(top);
958 if (vs->isFocused())
959 {
960 push_dfhack_focus_string(vs, focusStrings);
961 return focusStrings;
962 }
963 top = Gui::getDFViewscreen(top);
964 if (dfhack_viewscreen::is_instance(top))
965 {
966 push_dfhack_focus_string(static_cast<dfhack_viewscreen*>(top), focusStrings);
967 return focusStrings;
968 }
969 }
970
971 if (const virtual_identity *id = virtual_identity::get(top))
972 {
973 std::string name = getNameChunk(id, 11, 2);
974
975 auto handler = map_find(getFocusStringsHandlers, id);
976 if (handler)
977 handler(name, focusStrings, top);
978 }
979
980 if (!focusStrings.size())
981 {
982 Core &core = Core::getInstance();
983 std::string name = core.p->readClassName(*(void**)top);
984 focusStrings.push_back(name.substr(11, name.size()-11-2));
985 }
986 return focusStrings;
987}
988
989// Predefined common guard functions
990

Callers

nothing calls this directly

Calls 6

is_instanceFunction · 0.85
push_dfhack_focus_stringFunction · 0.85
getNameChunkFunction · 0.85
map_findFunction · 0.85
getFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected