Skip to content

Commit

Permalink
fix: only use imgui io after init (#622)
Browse files Browse the repository at this point in the history
* fix: only use imgui io after init

* refactor: getsingleton
  • Loading branch information
doodlum authored Oct 10, 2024
1 parent 7ac4fa9 commit 0995e6a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/Hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,9 @@ namespace Hooks
{
static LRESULT thunk(HWND a_hwnd, UINT a_msg, WPARAM a_wParam, LPARAM a_lParam)
{
if (a_msg == WM_KILLFOCUS) {
Menu::GetSingleton()->OnFocusLost();
auto menu = Menu::GetSingleton();
if (a_msg == WM_KILLFOCUS && menu->initialized) {
menu->OnFocusLost();
auto& io = ImGui::GetIO();
io.ClearInputKeys();
io.ClearEventsQueue();
Expand Down
2 changes: 2 additions & 0 deletions src/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ void Menu::Init(IDXGISwapChain* swapchain, ID3D11Device* device, ID3D11DeviceCon
style.MouseCursorScale = 1.f;
auto& io = ImGui::GetIO();
io.FontGlobalScale = trueScale;

initialized = true;
}

void Menu::DrawSettings()
Expand Down
2 changes: 2 additions & 0 deletions src/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Menu
return &menu;
}

bool initialized = false;

void Load(json& o_json);
void Save(json& o_json);

Expand Down

0 comments on commit 0995e6a

Please sign in to comment.