Skip to content

Commit

Permalink
Allow pressing shift to not hide menu
Browse files Browse the repository at this point in the history
  • Loading branch information
TheIndra55 committed Mar 16, 2024
1 parent 44df0c8 commit ca07aa1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/menu/Menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void Menu::OnPresent()
ImGui::NewFrame();

// Draw the menu
if (m_focus)
if (m_visible)
{
Draw();
}
Expand All @@ -79,7 +79,7 @@ void Menu::OnMessage(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_KEYUP && wParam == VK_F8)
{
SetFocus(!m_focus);
SetFocus(!m_focus, ImGui::IsKeyDown(ImGuiKey_LeftShift));
}

if (m_focus)
Expand All @@ -92,7 +92,7 @@ void Menu::Draw() noexcept
{
auto& modules = Hook::GetInstance().GetModules();

if (ImGui::BeginMainMenuBar())
if (m_focus && ImGui::BeginMainMenuBar())
{
// Draw all modules menus
for (auto& [hash, mod] : modules)
Expand Down Expand Up @@ -131,9 +131,15 @@ void Menu::DrawMenu() noexcept
}
}

void Menu::SetFocus(bool focus) noexcept
void Menu::SetFocus(bool focus, bool dontHide) noexcept
{
m_focus = focus;
m_visible = focus;

if (!focus && dontHide)
{
m_visible = true;
}

// Disable the cursor lock and game input
MouseHook::DisableCursorLock(focus);
Expand Down
4 changes: 3 additions & 1 deletion src/menu/Menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class Menu : public cdc::PCInternalResource
{
private:
bool m_initialized = false;

bool m_visible = false;
bool m_focus = false;

public:
Expand All @@ -19,7 +21,7 @@ class Menu : public cdc::PCInternalResource
bool OnCreateDevice();
void OnDestroyDevice();

void SetFocus(bool focus) noexcept;
void SetFocus(bool focus, bool dontHide = false) noexcept;
bool HasFocus() const noexcept;

private:
Expand Down

0 comments on commit ca07aa1

Please sign in to comment.