forked from YimMenu/YimMenuV2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUIManager.cpp
83 lines (66 loc) · 1.63 KB
/
UIManager.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "UIManager.hpp"
#include "game/pointers/Pointers.hpp"
namespace YimMenu
{
void UIManager::AddSubmenuImpl(const std::shared_ptr<Submenu>&& submenu)
{
if (!m_ActiveSubmenu)
m_ActiveSubmenu = submenu;
m_Submenus.push_back(std::move(submenu));
}
void UIManager::SetActiveSubmenuImpl(const std::shared_ptr<Submenu> Submenu)
{
m_ActiveSubmenu = Submenu;
}
void UIManager::DrawImpl()
{
auto pos = ImGui::GetCursorPos();
if (ImGui::BeginChild("##submenus", ImVec2(120, ImGui::GetContentRegionAvail().y - 20), true))
{
for (auto& submenu : m_Submenus)
{
if (ImGui::Selectable(submenu->m_Name.data(), (submenu == m_ActiveSubmenu)))
{
SetActiveSubmenu(submenu);
}
}
}
ImGui::EndChild();
ImGui::Text(YimMenu::SCVar().c_str());
pos.y -= 28;
ImGui::SetCursorPos(ImVec2(pos.x + 130, pos.y));
if (ImGui::BeginChild("##minisubmenus", ImVec2(0, 50), true, ImGuiWindowFlags_NoScrollbar))
{
if (m_ActiveSubmenu)
m_ActiveSubmenu->DrawCategorySelectors();
}
ImGui::EndChild();
ImGui::SetCursorPos(ImVec2(pos.x + 130, pos.y + 60));
if (ImGui::BeginChild("##options", ImVec2(0, 0), true))
{
if (m_OptionsFont)
ImGui::PushFont(m_OptionsFont);
if (m_ActiveSubmenu)
m_ActiveSubmenu->Draw();
if (m_OptionsFont)
ImGui::PopFont();
}
ImGui::EndChild();
}
std::shared_ptr<Submenu> UIManager::GetActiveSubmenuImpl()
{
if (m_ActiveSubmenu)
{
return m_ActiveSubmenu;
}
return nullptr;
}
std::shared_ptr<Category> UIManager::GetActiveCategoryImpl()
{
if (m_ActiveSubmenu)
{
return m_ActiveSubmenu->GetActiveCategory();
}
return nullptr;
}
}