Skip to content

Commit a415d0c

Browse files
committed
Minor UI tweaks
1 parent ca80a6e commit a415d0c

File tree

1 file changed

+25
-11
lines changed

1 file changed

+25
-11
lines changed

src/SettingsApp/HTCCSettingsApp.cpp

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <shellapi.h>
1212
#include <wil/com.h>
1313
#include <wil/registry.h>
14+
#include <dwmapi.h>
1415
#include <wil/resource.h>
1516
#include <winuser.h>
1617

@@ -55,6 +56,20 @@ extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(
5556
WPARAM wParam,
5657
LPARAM lParam);
5758

59+
template<const GUID& TFolderID> auto GetKnownFolderPath() {
60+
static std::filesystem::path sPath;
61+
static std::once_flag sOnce;
62+
std::call_once(sOnce, [&path = sPath]() {
63+
wil::unique_cotaskmem_string buf;
64+
THROW_IF_FAILED(SHGetKnownFolderPath(TFolderID, KF_FLAG_DEFAULT, nullptr, buf.put()));
65+
path = { std::wstring_view { buf.get() } };
66+
if (std::filesystem::exists(path)) {
67+
path = std::filesystem::canonical(path);
68+
}
69+
});
70+
return sPath;
71+
}
72+
5873
class HTCCSettingsApp {
5974
public:
6075
HTCCSettingsApp() = delete;
@@ -87,12 +102,15 @@ class HTCCSettingsApp {
87102
nullptr,
88103
instance,
89104
nullptr));
90-
ImGui::GetMa
91105
}
92106
if (!mHwnd) {
93107
throw std::runtime_error(
94108
std::format("Failed to create window: {}", GetLastError()));
95109
}
110+
{
111+
BOOL darkMode { true};
112+
DwmSetWindowAttribute(mHwnd.get(), DWMWA_USE_IMMERSIVE_DARK_MODE, &darkMode, sizeof(darkMode));
113+
}
96114
RECT clientRect {};
97115
GetClientRect(mHwnd.get(), &clientRect);
98116

@@ -148,6 +166,8 @@ class HTCCSettingsApp {
148166
ImGui::CreateContext();
149167
auto& io = ImGui::GetIO();
150168
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard;
169+
io.IniFilename = mIniPath.c_str();
170+
151171
ImGui_ImplWin32_Init(mHwnd.get());
152172
ImGui_ImplDX11_Init(mD3DDevice.get(), mD3DContext.get());
153173

@@ -162,16 +182,7 @@ class HTCCSettingsApp {
162182
}
163183

164184
void LoadFonts() {
165-
static std::filesystem::path sFontsPath;
166-
static std::once_flag sFontsPathOnce;
167-
std::call_once(sFontsPathOnce, [&path = sFontsPath]() {
168-
wil::unique_cotaskmem_string buf;
169-
THROW_IF_FAILED(SHGetKnownFolderPath(FOLDERID_Fonts, KF_FLAG_DEFAULT, nullptr, buf.put()));
170-
path = { std::wstring_view { buf.get() } };
171-
if (std::filesystem::exists(path)) {
172-
path = std::filesystem::canonical(path);
173-
}
174-
});
185+
static const auto sFontsPath = GetKnownFolderPath<FOLDERID_Fonts>();
175186
if (sFontsPath.empty()) {
176187
return;
177188
}
@@ -303,6 +314,7 @@ class HTCCSettingsApp {
303314
ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove
304315
| ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
305316

317+
ImGui::SeparatorText("Common Settings");
306318
if (ImGui::Checkbox("Enable HTCC", &mIsAPILayerEnabled)) {
307319
const auto apiLayerPath = GetAPILayerPath();
308320
const DWORD disabled = mIsAPILayerEnabled ? 0 : 1;
@@ -474,6 +486,8 @@ class HTCCSettingsApp {
474486

475487
ImGui::EndCombo();
476488
}
489+
490+
const std::string mIniPath = (GetKnownFolderPath<FOLDERID_LocalAppData>() / "Fred Emmmott" / "HTCC" / "imgui.ini").string();
477491
};
478492

479493
HTCCSettingsApp* HTCCSettingsApp::gInstance {nullptr};

0 commit comments

Comments
 (0)