-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImGuiManager.cpp
More file actions
86 lines (75 loc) · 2.96 KB
/
ImGuiManager.cpp
File metadata and controls
86 lines (75 loc) · 2.96 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
81
82
83
84
85
86
#include "pch.h"
#include "ImGuiManager.h"
#include "ImGuiStyles.h"
#include "GameContext.h"
ImGuiManager::ImGuiManager()
{
}
ImGuiManager::~ImGuiManager()
{
}
void ImGuiManager::RenderInitialize()
{
// Setup Dear ImGui context
IMGUI_CHECKVERSION();
ImGui::CreateContext();
ImGuiIO& io = ImGui::GetIO();
//auto wpath = GameContext::GetSaveHandler().GetDir() + L"GuiSettings.ini";
//m_settingFile = std::string(wpath.begin(), wpath.end());
//io.IniFilename = m_settingFile.c_str();
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
// Setup Dear ImGui style
ImGui::StyleColorsDark();
//ImGui::StyleColorsClassic();
{
auto& style = ImGui::GetStyle();
//ImGuiStyles::darkTheme(style);
//ImGuiStyles::cyberTheme(style);
ImGuiStyles::darkrichTheme(style);
}
// Setup Platform/Renderer bindings
ImGui_ImplWin32_Init(GameContext::Get<HWND>());
ImGui_ImplDX11_Init(GameContext::Get<DX::DeviceResources>().GetD3DDevice(), GameContext::Get<DX::DeviceResources>().GetD3DDeviceContext());
// Load Fonts
// - If no fonts are loaded, dear imgui will use the default font. You can also load multiple fonts and use ImGui::PushFont()/PopFont() to select them.
// - AddFontFromFileTTF() will return the ImFont* so you can store it if you need to select the font among multiple.
// - If the file cannot be loaded, the function will return NULL. Please handle those errors in your application (e.g. use an assertion, or display an error and quit).
// - The fonts will be rasterized at a given size (w/ oversampling) and stored into a texture when calling ImFontAtlas::Build()/GetTexDataAsXXXX(), which ImGui_ImplXXXX_NewFrame below will call.
// - Read 'misc/fonts/README.txt' for more instructions and details.
// - Remember that in C/C++ if you want to include a backslash \ in a string literal you need to write a double backslash \\ !
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Roboto-Medium.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/Cousine-Regular.ttf", 15.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/DroidSans.ttf", 16.0f);
//io.Fonts->AddFontFromFileTTF("../../misc/fonts/ProggyTiny.ttf", 10.0f);
ImFont* font = io.Fonts->AddFontFromFileTTF("Resources/Fonts/logofont.ttf", 12.0f, NULL, io.Fonts->GetGlyphRangesJapanese());
IM_ASSERT(font != NULL);
io.Fonts->AddFontDefault();
}
void ImGuiManager::Begin()
{
// Start the Dear ImGui frame
{
ImGui_ImplDX11_NewFrame();
ImGui_ImplWin32_NewFrame();
ImGuiIO& io = ImGui::GetIO();
//if (Input::GetMouseMode() != DirectX::Mouse::Mode::MODE_ABSOLUTE)
// io.MousePos = ImVec2(-FLT_MAX, -FLT_MAX);
ImGui::NewFrame();
}
}
void ImGuiManager::End()
{
// Rendering
{
ImGui::Render();
ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData());
}
}
void ImGuiManager::RenderFinalize()
{
// Cleanup
ImGui_ImplDX11_Shutdown();
ImGui_ImplWin32_Shutdown();
ImGui::DestroyContext();
}