diff --git a/src/cheatmenu.cpp b/src/cheatmenu.cpp index d3533e4..9ee054c 100644 --- a/src/cheatmenu.cpp +++ b/src/cheatmenu.cpp @@ -72,8 +72,9 @@ void CheatMenu::DrawWindow() CheatMenu::CheatMenu() { + ImGui::CreateContext(); ApplyStyle(); - windowCallback = std::bind(&DrawWindow); + pCallbackFunc = std::bind(&DrawWindow); // Load menu settings Ui::m_HeaderId = gConfig.GetValue("window.id", std::string("")); @@ -152,9 +153,9 @@ void CheatMenu::ApplyStyle() style->Colors[ImGuiCol_TitleBgActive] = ImVec4(0.07f, 0.07f, 0.09f, 1.00f); style->Colors[ImGuiCol_MenuBarBg] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f); style->Colors[ImGuiCol_ScrollbarBg] = ImVec4(0.12f, 0.12f, 0.12f, 1.00f); - style->Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); - style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.16f, 0.16f, 0.16f, 1.00f); - style->Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); + style->Colors[ImGuiCol_ScrollbarGrab] = ImVec4(0.8f, 0.8f, 0.8f, 0.3f); + style->Colors[ImGuiCol_ScrollbarGrabHovered] = ImVec4(0.5f, 0.5f, 0.5f, 0.3f); + style->Colors[ImGuiCol_ScrollbarGrabActive] = ImVec4(0.2f, 0.2f, 0.2f, 1.00f); style->Colors[ImGuiCol_CheckMark] = ImVec4(0.80f, 0.80f, 0.83f, 0.31f); style->Colors[ImGuiCol_SliderGrab] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); style->Colors[ImGuiCol_SliderGrabActive] = ImVec4(0.20f, 0.20f, 0.20f, 1.00f); diff --git a/src/hook.cpp b/src/hook.cpp index 8acb847..9e5e07d 100644 --- a/src/hook.cpp +++ b/src/hook.cpp @@ -35,7 +35,7 @@ void Hook::RenderFrame(void* ptr) { if (!ImGui::GetCurrentContext()) { - return; + ImGui::CreateContext(); } ImGuiIO& io = ImGui::GetIO(); @@ -45,7 +45,7 @@ void Hook::RenderFrame(void* ptr) { ShowMouse(m_bShowMouse); - // handle window scaling here + // Scale the menu if game resolution changed static ImVec2 fScreenSize = ImVec2(-1, -1); ImVec2 size(screen::GetScreenWidth(), screen::GetScreenHeight()); if (fScreenSize.x != size.x && fScreenSize.y != size.y) @@ -86,9 +86,9 @@ void Hook::RenderFrame(void* ptr) ImGui::NewFrame(); - if (windowCallback != nullptr) + if (pCallbackFunc != nullptr) { - windowCallback(); + pCallbackFunc(); } ImGui::EndFrame(); @@ -106,7 +106,6 @@ void Hook::RenderFrame(void* ptr) else { bInit = true; - ImGuiStyle& style = ImGui::GetStyle(); ImGui_ImplWin32_Init(RsGlobal.ps->window); #ifdef GTASA @@ -139,7 +138,6 @@ void Hook::RenderFrame(void* ptr) io.LogFilename = nullptr; io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; - style.WindowTitleAlign = ImVec2(0.5, 0.5); oWndProc = (WNDPROC)SetWindowLongPtr(RsGlobal.ps->window, GWL_WNDPROC, (LRESULT)WndProc); } } @@ -243,7 +241,6 @@ void Hook::ShowMouse(bool state) Hook::Hook() { - ImGui::CreateContext(); // Nvidia Overlay crash fix if (init(kiero::RenderType::D3D9) == kiero::Status::Success) diff --git a/src/hook.h b/src/hook.h index 128e0b8..ad309d2 100644 --- a/src/hook.h +++ b/src/hook.h @@ -25,7 +25,7 @@ private: public: static inline bool m_bShowMouse = false; - static inline std::function windowCallback = nullptr; + static inline std::function pCallbackFunc = nullptr; #ifdef GTASA static void ApplyMouseFix(); diff --git a/src/hotkeys.cpp b/src/hotkeys.cpp index be99fc1..2f36497 100644 --- a/src/hotkeys.cpp +++ b/src/hotkeys.cpp @@ -61,7 +61,7 @@ bool Hotkey::DrawUI(const char* label) } if (ImGui::Button((text + std::string("##") + std::string(label)).c_str(), - ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight()))) + ImVec2(ImGui::GetWindowContentRegionWidth() / 3.5, ImGui::GetFrameHeight()*1.35f))) { if (!active) { diff --git a/src/ui.cpp b/src/ui.cpp index 8341c44..c42a464 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -43,7 +43,7 @@ bool Ui::DrawTitleBar() float cross_extent = (fontSize * 0.3f) - 1.0f; ImVec2 closePos = ImVec2(bb.GetCenter().x - cross_extent, rectMin.y); ImU32 closeCol = ImGui::GetColorU32(held || hovered ? ImVec4(0.80f, 0.0f, 0.0f, 1.0f) : ImVec4(0.80f, 0.80f, 0.80f, 1.00f)); - window->DrawList->AddText(closePos, closeCol, " X "); + window->DrawList->AddText(closePos, closeCol, "X"); ImGui::PopFont(); return pressed; @@ -189,18 +189,26 @@ bool Ui::ListBoxCustomNames(const char* label, std::vector& all_ite ImVec2 Ui::GetSize(short count, bool spacing) { if (count == 1) + { spacing = false; + } float factor = ImGui::GetStyle().ItemSpacing.x / 2.0f; float x; if (count == 3) + { factor = ImGui::GetStyle().ItemSpacing.x / 1.403f; + } if (spacing) + { x = ImGui::GetWindowContentRegionWidth() / count - factor; + } else + { x = ImGui::GetWindowContentRegionWidth() / count; + } return ImVec2(x, ImGui::GetFrameHeight() * 1.3f); } diff --git a/tools/premake5.lua b/tools/premake5.lua index 85fc70d..d5dd744 100644 --- a/tools/premake5.lua +++ b/tools/premake5.lua @@ -1,13 +1,13 @@ ---------------------------- --- Project Generator +-- Premake Project Generator ---------------------------- + -- Environment vars +---------------------------- +-- Should get picked up automatically if you installed them properly PSDK_DIR = os.getenv("PLUGIN_SDK_DIR") DX9SDK_DIR = os.getenv("DIRECTX9_SDK_DIR") -GTASA_DIR = "F:/GTASanAndreas" -GTAVC_DIR = "E:/GTA Vice City" -GTA3_DIR = "E:/GTA3" if (DX9SDK_DIR == nil) then error("DIRECTX9_SDK_DIR environment variable not set") @@ -16,6 +16,13 @@ end if (PSDK_DIR == nil) then error("PLUGIN_SDK_DIR environment variable not set") end + +-- Build directories +---------------------------- +GTASA_DIR = "F:/GTASanAndreas" +GTAVC_DIR = "E:/GTA Vice City" +GTA3_DIR = "E:/GTA3" + ---------------------------- workspace "CheatMenu"