-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUIManager.cpp
More file actions
80 lines (64 loc) · 2.07 KB
/
UIManager.cpp
File metadata and controls
80 lines (64 loc) · 2.07 KB
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
#include "UIManager.h"
#include "GraphicsEngine.h"
#include "ProfilerScreen.h"
#include "MenuScreen.h"
#include "InspectorScreen.h"
#include "HierarchyScreen.h"
UIManager* UIManager::sharedInstance = NULL;
UIManager* UIManager::getInstance()
{
return sharedInstance;
}
void UIManager::initialize(HWND windowHandle)
{
sharedInstance = new UIManager(windowHandle);
}
void UIManager::destroy()
{
delete sharedInstance;
}
void UIManager::drawAllUI()
{
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGui::NewFrame();
for (int i = 0; i < this->uiList.size(); i++) {
this->uiList[i]->drawUI();
}
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
}
UIManager::UIManager(HWND windowHandle)
{
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
//io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // IF using Docking Branch
// Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
GraphicsEngine* graphEngine = GraphicsEngine::get();
// Setup Platform/Renderer backends
ImGui_ImplWin32_Init(windowHandle);
ImGui_ImplDX11_Init(graphEngine->getDirect3DDevice(), graphEngine->getImmediateDeviceContext()->getDeviceContext());
//populate UI table
UINames uiNames;
ProfilerScreen* profilerScreen = new ProfilerScreen();
this->uiTable[uiNames.PROFILER_SCREEN] = profilerScreen;
this->uiList.push_back(profilerScreen);
MenuScreen* menuScreen = new MenuScreen();
this->uiTable[uiNames.MENU_SCREEN] = menuScreen;
this->uiList.push_back(menuScreen);
InspectorScreen* inspectorScreen = new InspectorScreen();
this->uiTable[uiNames.INSPECTOR_SCREEN] = inspectorScreen;
this->uiList.push_back(inspectorScreen);
HierarchyScreen* hierarchyScreen = new HierarchyScreen();
this->uiTable[uiNames.HIERARCHY_SCREEN] = hierarchyScreen;
this->uiList.push_back(hierarchyScreen);
}
UIManager::~UIManager()
{
}