styyx-util 1.0
Utility Header for SKSE Plugin development
Loading...
Searching...
No Matches
st-menu.h
Go to the documentation of this file.
1#pragma once
2
3namespace StyyxUtil
4{
5struct MenuUtil
6{
9 static void CloseMenu(const RE::BSFixedString& a_menuName)
10 {
11 if (const auto UIMsgQueue = RE::UIMessageQueue::GetSingleton(); UIMsgQueue)
12 {
13 UIMsgQueue->AddMessage(a_menuName, RE::UI_MESSAGE_TYPE::kHide, nullptr);
14 }
15 }
16
20 [[nodiscard]] static bool IsAnyOfMenuOpen(const std::vector<std::string>& a_menuNames)
21 {
22 const auto ui = RE::UI::GetSingleton();
23 if (!ui)
24 return true;
25 for (auto& menuName : a_menuNames)
26 {
27 if (const auto menu = ui->GetMenu(menuName); menu && menu->OnStack())
28 return true;
29 }
30 return false;
31 }
32
39 static void VisitMenuMembersRec(const char* a_path, RE::GFxValue& a_obj, int depth = 0, int max_depth = 4)
40 {
41 if (depth > max_depth)
42 {
43 return;
44 }
45
46 struct MemberVisitor : RE::GFxValue::ObjectVisitor
47 {
48 const char* path;
49 int depth;
50 int max_depth;
51
52 void Visit(const char* a_name, const RE::GFxValue& a_val) override
53 {
54 std::string full_path = std::string(path) + "." + a_name;
55 switch (a_val.GetType())
56 {
57 case RE::GFxValue::ValueType::kNumber:
58 SKSE::log::info("{} = {}", full_path, a_val.GetNumber());
59 break;
60 case RE::GFxValue::ValueType::kBoolean:
61 SKSE::log::info("{} = {}", full_path, a_val.GetBool());
62 break;
63 case RE::GFxValue::ValueType::kString:
64 SKSE::log::info("{} = {}", full_path, a_val.GetString());
65 break;
66 case RE::GFxValue::ValueType::kObject:
67 case RE::GFxValue::ValueType::kDisplayObject:
68 {
69 SKSE::log::info("{} = [object]", full_path);
70 auto val_copy = const_cast<RE::GFxValue&>(a_val);
71 VisitMenuMembersRec(full_path.c_str(), val_copy, depth + 1, max_depth);
72 break;
73 }
74 default:
75 SKSE::log::info("{} = [unknown]", full_path);
76 break;
77 }
78 }
79 };
80
81 MemberVisitor visitor;
82 visitor.path = a_path;
83 visitor.depth = depth;
84 visitor.max_depth = max_depth;
85 a_obj.VisitMembers(&visitor);
86 }
87};
88} // namespace StyyxUtil
Definition st-actor.h:7
Definition st-menu.h:6
static void VisitMenuMembersRec(const char *a_path, RE::GFxValue &a_obj, int depth=0, int max_depth=4)
print all members of a gfx path
Definition st-menu.h:39
static void CloseMenu(const RE::BSFixedString &a_menuName)
Closes the specified menu.
Definition st-menu.h:9
static bool IsAnyOfMenuOpen(const std::vector< std::string > &a_menuNames)
Check if any menu from a vector with menu names is open.
Definition st-menu.h:20