diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index 13514e4..b71ac7d 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -72,7 +72,15 @@ void CheatMenuMgr::Draw() bRunning = true; if (m_bVisible) { - ImGui::SetNextWindowSize(m_fSize); + ImGui::SetNextWindowSize(m_fSize, ImGuiCond_Once); + ImGui::SetNextWindowPos(m_fPos, ImGuiCond_Once); + + if (m_bWindowParamUpdated) + { + ImGui::SetNextWindowSize(m_fSize); + ImGui::SetNextWindowPos(m_fPos); + m_bWindowParamUpdated = false; + } if (ImGui::Begin(MENU_TITLE, NULL, ImGuiWindowFlags_NoCollapse || ImGuiWindowFlags_NoTitleBar)) { @@ -80,21 +88,17 @@ void CheatMenuMgr::Draw() ImGui::PushStyleVar(ImGuiStyleVar_WindowMinSize, ImVec2(250, 350)); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(ImGui::GetWindowWidth() / 85, ImGui::GetWindowHeight() / 200)); - PageHandler::DrawPages(); - if (m_bSizeUpdated) - { - m_bSizeUpdated = false; - } - else + if (ImGui::IsWindowHovered()) { m_fSize = ImGui::GetWindowSize(); + m_fPos = ImGui::GetWindowPos(); + gConfig.Set("Window.PosX", m_fPos.x); + gConfig.Set("Window.PosY", m_fPos.y); + gConfig.Set("Window.SizeX", m_fSize.x); + gConfig.Set("Window.SizeY", m_fSize.y); } - - gConfig.Set("Window.SizeX", m_fSize.x); - gConfig.Set("Window.SizeY", m_fSize.y); - ImGui::PopStyleVar(2); ImGui::End(); } @@ -215,6 +219,9 @@ CheatMenuMgr::CheatMenuMgr() // Load menu settings m_fSize.x = gConfig.Get("Window.SizeX", screen::GetScreenWidth() / 4.0f); m_fSize.y = gConfig.Get("Window.SizeY", screen::GetScreenHeight() / 1.2f); + m_fPos.x = gConfig.Get("Window.PosX", 50.0f); + m_fPos.y = gConfig.Get("Window.PosY", 50.0f); + srand(CTimer::m_snTimeInMilliseconds); }; @@ -322,9 +329,10 @@ void CheatMenuMgr::ApplyStyle() style->Colors[ImGuiCol_ModalWindowDimBg] = ImVec4(0.20f, 0.20f, 0.20f, 0.6f); } -void CheatMenuMgr::ResetSize() +void CheatMenuMgr::ResetParams() { m_fSize.x = screen::GetScreenWidth() / 4.0f; m_fSize.y = screen::GetScreenHeight() / 1.2f; - m_bSizeUpdated = true; + m_fPos = {50.0f, 50.0f}; + m_bWindowParamUpdated = true; } diff --git a/src/cheatmenu.h b/src/cheatmenu.h index be498a1..871537f 100644 --- a/src/cheatmenu.h +++ b/src/cheatmenu.h @@ -9,9 +9,9 @@ class CheatMenuMgr : public IFeature { private: - ImVec2 m_fSize; + ImVec2 m_fSize, m_fPos; bool m_bVisible; // should the menu be drawn - bool m_bSizeUpdated; // Was menu size change requested + bool m_bWindowParamUpdated; // Was menu size/pos changed bool m_bIsOnline; // SAMP & VCMP flag friend class IFeature; @@ -29,7 +29,7 @@ public: bool IsVisible(); // Resets the menu height & width to default - void ResetSize(); + void ResetParams(); }; extern CheatMenuMgr& CheatMenu; diff --git a/src/dllmain.cpp b/src/dllmain.cpp index ad3cbdb..d989f8c 100644 --- a/src/dllmain.cpp +++ b/src/dllmain.cpp @@ -5,7 +5,7 @@ LONG WINAPI CrashHandler(PEXCEPTION_POINTERS pInfo) { Log::Print(""); - Log::Print("Game crashed. Unhandled exception at {} (0x{:x})", + Log::Print("Unhandled exception at {} (0x{:x})", pInfo->ExceptionRecord->ExceptionAddress, pInfo->ExceptionRecord->ExceptionCode); return EXCEPTION_CONTINUE_SEARCH; } diff --git a/src/pages/menu.cpp b/src/pages/menu.cpp index a6f7162..ad4ba37 100644 --- a/src/pages/menu.cpp +++ b/src/pages/menu.cpp @@ -61,7 +61,7 @@ void MenuPage::Draw() ImGui::Spacing(); if (ImGui::Button(TEXT("Menu.ResetSize"), ImVec2(Widget::CalcSize(2)))) { - CheatMenu.ResetSize(); + CheatMenu.ResetParams(); } ImGui::SameLine(); if (ImGui::Button(TEXT("Menu.ReloadFonts"), ImVec2(Widget::CalcSize(2)))) @@ -78,7 +78,6 @@ void MenuPage::Draw() if (Locale::SetLocale(selected) == Locale::eReturnCodes::SUCCESS) { gConfig.Set("Menu.Language", vec[selected]); - // CheatMenu::GenHeaderList(); } else { diff --git a/tools/premake5.lua b/tools/premake5.lua index 7982267..bd0be74 100644 --- a/tools/premake5.lua +++ b/tools/premake5.lua @@ -7,11 +7,6 @@ ---------------------------- -- Should get picked up automatically if you installed them properly PSDK_DIR = os.getenv("PLUGIN_SDK_DIR") -DX9SDK_DIR = os.getenv("DXSDK_DIR") - -if (DX9SDK_DIR == nil) then - -- error("DXSDK_DIR environment variable not set") -end if (PSDK_DIR == nil) then error("PLUGIN_SDK_DIR environment variable not set") @@ -101,7 +96,8 @@ workspace "CheatMenu" "d3d9", "d3d11", "Pdh", - "urlmon" + "urlmon", + "Xinput9_1_0" } defines {