├── Menu remake part 1 ├── External Menu Base.sln ├── Loader Base.vcxproj ├── Loader Base.vcxproj.filters ├── Loader Base.vcxproj.user ├── Loader.cpp ├── Loader.h ├── font.h ├── functions.cpp ├── functions.h ├── iconcpp.h ├── icons.h ├── imgui │ ├── imconfig.h │ ├── imgui.cpp │ ├── imgui.h │ ├── imgui_demo.cpp │ ├── imgui_draw.cpp │ ├── imgui_impl_dx9.cpp │ ├── imgui_impl_dx9.h │ ├── imgui_impl_win32.cpp │ ├── imgui_impl_win32.h │ ├── imgui_internal.h │ ├── imgui_widgets.cpp │ ├── imstb_rectpack.h │ ├── imstb_textedit.h │ └── imstb_truetype.h ├── imguipp.cpp ├── imguipp.h ├── menu.cpp ├── menu.h └── settings.h └── Menu remake part 2 ├── External Menu Base.sln ├── Loader Base.vcxproj ├── Loader Base.vcxproj.filters ├── Loader Base.vcxproj.user ├── Loader.cpp ├── Loader.h ├── TextEditor.cpp ├── TextEditor.h ├── font.h ├── functions.cpp ├── functions.h ├── iconcpp.h ├── icons.h ├── imgui ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_impl_dx9.cpp ├── imgui_impl_dx9.h ├── imgui_impl_win32.cpp ├── imgui_impl_win32.h ├── imgui_internal.h ├── imgui_widgets.cpp ├── imstb_rectpack.h ├── imstb_textedit.h └── imstb_truetype.h ├── imguipp.cpp ├── imguipp.h ├── menu.cpp ├── menu.h └── settings.h /Menu remake part 1/External Menu Base.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31129.286 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Loader Base", "Loader Base.vcxproj", "{AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x64.ActiveCfg = Debug|x64 17 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x64.Build.0 = Debug|x64 18 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x86.ActiveCfg = Debug|Win32 19 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x86.Build.0 = Debug|Win32 20 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x64.ActiveCfg = Release|x64 21 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x64.Build.0 = Release|x64 22 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x86.ActiveCfg = Release|Win32 23 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D24F0276-5924-4762-96C3-86AFE66E2846} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Menu remake part 1/Loader Base.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {aeaa4cef-8d6d-4061-bcf1-c31cddcca231} 25 | LoaderBase 26 | 10.0 27 | External Menu Base 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v142 53 | true 54 | Unicode 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | true 82 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui;$(IncludePath) 83 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) 84 | 85 | 86 | false 87 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui;$(IncludePath) 88 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) 89 | 90 | 91 | 92 | Level3 93 | true 94 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 95 | true 96 | 97 | 98 | Console 99 | true 100 | 101 | 102 | 103 | 104 | Level3 105 | true 106 | true 107 | true 108 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 109 | true 110 | 111 | 112 | Console 113 | true 114 | true 115 | true 116 | 117 | 118 | 119 | 120 | Level3 121 | true 122 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 123 | true 124 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui 125 | 126 | 127 | Windows 128 | true 129 | 130 | 131 | 132 | 133 | Level3 134 | true 135 | true 136 | true 137 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 138 | true 139 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui 140 | 141 | 142 | Windows 143 | true 144 | true 145 | true 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | -------------------------------------------------------------------------------- /Menu remake part 1/Loader Base.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {3915832f-f15f-453b-99ad-aaee2acaa8a6} 10 | 11 | 12 | {39dbd3a4-bda5-4317-a3ef-50064f12ff10} 13 | 14 | 15 | {00794305-ea9a-47a5-bd71-f81cc5517c52} 16 | 17 | 18 | {494a0a43-7957-4989-a7a2-7dfe71516f68} 19 | 20 | 21 | {3056aec4-4ff8-48fc-a8ad-6695d07a4d3e} 22 | 23 | 24 | {6ca62923-0f53-409a-89d8-4645b470d87b} 25 | 26 | 27 | {3b78753f-124f-416a-a776-d54e6fdd5f2a} 28 | 29 | 30 | 31 | 32 | Source Files 33 | 34 | 35 | Framework\imgui 36 | 37 | 38 | Framework\imgui 39 | 40 | 41 | Framework\imgui 42 | 43 | 44 | Framework\imgui 45 | 46 | 47 | Framework\imgui 48 | 49 | 50 | Framework\imgui 51 | 52 | 53 | Framework\menu 54 | 55 | 56 | Framework\functions 57 | 58 | 59 | 60 | 61 | 62 | Framework\imgui 63 | 64 | 65 | Framework\imgui 66 | 67 | 68 | Framework\imgui 69 | 70 | 71 | Framework\imgui 72 | 73 | 74 | Framework\imgui 75 | 76 | 77 | Framework\imgui 78 | 79 | 80 | Framework\imgui 81 | 82 | 83 | Framework\imgui 84 | 85 | 86 | Source Files 87 | 88 | 89 | Framework\menu 90 | 91 | 92 | Framework\settings 93 | 94 | 95 | Framework\functions 96 | 97 | 98 | Framework\menu\font 99 | 100 | 101 | icons 102 | 103 | 104 | icons 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /Menu remake part 1/Loader Base.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | 6 | -------------------------------------------------------------------------------- /Menu remake part 1/Loader.cpp: -------------------------------------------------------------------------------- 1 | #include "Loader.h" 2 | #include "menu.h" 3 | #include "font.h" 4 | #include "functions.h" 5 | #include "iconcpp.h" 6 | 7 | /* 8 | Make sure to compile on x64 Release. 9 | Enjoy! xo1337. 10 | 11 | This main code was used from: https://github.com/noteffex/ImGui-Loader-Base/ , 12 | everything else was coded by xo1337. 13 | */ 14 | 15 | int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) 16 | { 17 | WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(0), 0, 0, 0, 0, L"External Menu Base", 0 }; 18 | RegisterClassEx(&wc); 19 | Window = CreateWindow(wc.lpszClassName, L"External Menu Base", WS_POPUP, 0, 0, 5, 5, 0, 0, wc.hInstance, 0); 20 | 21 | if (!CreateDeviceD3D(Window)) { 22 | CleanupDeviceD3D(); 23 | UnregisterClass(wc.lpszClassName, wc.hInstance); 24 | return 1; 25 | } 26 | 27 | ShowWindow(Window, SW_HIDE); 28 | UpdateWindow(Window); 29 | 30 | ImGui::CreateContext(); 31 | 32 | ImGuiIO& io = ImGui::GetIO(); 33 | io.IniFilename = nullptr; 34 | io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; 35 | 36 | static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; 37 | ImFontConfig icons_config; 38 | 39 | ImFontConfig CustomFont; 40 | CustomFont.FontDataOwnedByAtlas = false; 41 | 42 | 43 | icons_config.MergeMode = true; 44 | icons_config.PixelSnapH = true; 45 | icons_config.OversampleH = 2.5; 46 | icons_config.OversampleV = 2.5; 47 | 48 | io.Fonts->AddFontFromMemoryTTF(const_cast(Custom), sizeof(Custom), 21.f, &CustomFont); 49 | io.Fonts->AddFontFromMemoryCompressedTTF(font_awesome_data, font_awesome_size, 19.0f, &icons_config, icons_ranges); 50 | io.Fonts->AddFontDefault(); 51 | 52 | ImGuiStyle& style = ImGui::GetStyle(); 53 | if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) 54 | { 55 | style.WindowRounding = 0.0f; 56 | style.Colors[ImGuiCol_WindowBg].w = 1.0f; 57 | } 58 | 59 | ImGui_ImplWin32_Init(Window); 60 | ImGui_ImplDX9_Init(g_pd3dDevice); 61 | MSG msg; 62 | ZeroMemory(&msg, sizeof(msg)); 63 | while (msg.message != WM_QUIT) 64 | { 65 | if (PeekMessage(&msg, 0, 0U, 0U, PM_REMOVE)) 66 | { 67 | TranslateMessage(&msg); 68 | DispatchMessage(&msg); 69 | continue; 70 | } 71 | 72 | ImGui_ImplDX9_NewFrame(); 73 | ImGui_ImplWin32_NewFrame(); 74 | ImGui::NewFrame(); 75 | Menu::Theme(); 76 | { 77 | ImGui::Begin("HamMafia.co", 0, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoResize); 78 | { 79 | Menu::Render(); 80 | } 81 | ImGui::End(); 82 | } 83 | ImGui::EndFrame(); 84 | 85 | g_pd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0); 86 | if (g_pd3dDevice->BeginScene() >= 0) 87 | { 88 | ImGui::Render(); 89 | ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); 90 | g_pd3dDevice->EndScene(); 91 | } 92 | 93 | if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) 94 | { 95 | ImGui::UpdatePlatformWindows(); 96 | ImGui::RenderPlatformWindowsDefault(); 97 | } 98 | 99 | HRESULT result = g_pd3dDevice->Present(0, 0, 0, 0); 100 | if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) { 101 | ResetDevice(); 102 | } 103 | if (!Enabled) { 104 | msg.message = WM_QUIT; 105 | } 106 | } 107 | 108 | ImGui_ImplDX9_Shutdown(); 109 | ImGui_ImplWin32_Shutdown(); 110 | ImGui::DestroyContext(); 111 | 112 | CleanupDeviceD3D(); 113 | DestroyWindow(Window); 114 | UnregisterClass(wc.lpszClassName, wc.hInstance); 115 | 116 | return 0; 117 | } 118 | 119 | LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { 120 | if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) 121 | return true; 122 | 123 | switch (msg) 124 | { 125 | case WM_SIZE: 126 | if (g_pd3dDevice != 0 && wParam != SIZE_MINIMIZED) 127 | { 128 | g_d3dpp.BackBufferWidth = LOWORD(lParam); 129 | g_d3dpp.BackBufferHeight = HIWORD(lParam); 130 | ResetDevice(); 131 | } 132 | return 0; 133 | case WM_SYSCOMMAND: 134 | if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu 135 | return 0; 136 | break; 137 | case WM_DESTROY: 138 | PostQuitMessage(0); 139 | return 0; 140 | } 141 | return DefWindowProc(hWnd, msg, wParam, lParam); 142 | } -------------------------------------------------------------------------------- /Menu remake part 1/Loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #pragma comment(lib,"d3d9.lib") 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | static bool Enabled = true; 14 | HWND Window = nullptr; 15 | 16 | LPDIRECT3DDEVICE9 g_pd3dDevice; 17 | D3DPRESENT_PARAMETERS g_d3dpp; 18 | LPDIRECT3D9 g_pD3D; 19 | 20 | #define LOADER_NAME "Cheat Loader" 21 | 22 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 23 | LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 24 | 25 | const int WINDOW_WIDTH = 1200; 26 | const int WINDOW_HEIGHT = 800; 27 | 28 | bool CreateDeviceD3D(HWND hWnd) 29 | { 30 | if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) 31 | return false; 32 | ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); 33 | g_d3dpp.Windowed = TRUE; 34 | g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; 35 | g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; 36 | g_d3dpp.EnableAutoDepthStencil = TRUE; 37 | g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; 38 | g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; 39 | if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) 40 | return false; 41 | return true; 42 | } 43 | 44 | void CleanupDeviceD3D() 45 | { 46 | if (g_pd3dDevice) { 47 | g_pd3dDevice->Release(); g_pd3dDevice = NULL; 48 | } 49 | if (g_pD3D) { 50 | g_pD3D->Release(); g_pD3D = NULL; 51 | } 52 | } 53 | 54 | void ResetDevice() 55 | { 56 | ImGui_ImplDX9_InvalidateDeviceObjects(); 57 | HRESULT Result = g_pd3dDevice->Reset(&g_d3dpp); 58 | if (Result == D3DERR_INVALIDCALL) 59 | IM_ASSERT(0); 60 | ImGui_ImplDX9_CreateDeviceObjects(); 61 | } -------------------------------------------------------------------------------- /Menu remake part 1/functions.cpp: -------------------------------------------------------------------------------- 1 | #include "functions.h" 2 | 3 | void Functions::Inject(std::string game) 4 | { 5 | if (game == "game_name") 6 | { 7 | // Do your injection code :) 8 | } 9 | } 10 | 11 | void Functions::Rainbow() 12 | { 13 | //This function was not made by me (xo1337), i found it off unknown cheats. 14 | float rainbowSpeed = 0.00060; 15 | static float staticHue = 0; 16 | ImDrawList* draw_list = ImGui::GetWindowDrawList(); 17 | ImVec2 panelPos = ImGui::GetWindowPos(); 18 | staticHue -= rainbowSpeed; 19 | if (staticHue < -1.f) staticHue += 1.f; 20 | for (int i = 0; i < 1200; i++) 21 | { 22 | float hue = staticHue + (1.f / (float)1200) * i; 23 | if (hue < 0.f) hue += 1.0f; 24 | ImColor cRainbow = ImColor::HSV(hue, 1.f, 1.f); 25 | draw_list->AddRectFilled(ImVec2(panelPos.x + i, panelPos.y + 2), ImVec2(panelPos.x + i + 1, panelPos.y + 4), cRainbow); 26 | } 27 | } 28 | 29 | void Functions::Line(const char* Id, int width = ImGui::GetContentRegionAvailWidth(), int height = 1) 30 | { 31 | ImGui::BeginChild(Id, ImVec2(width, height), TRUE); 32 | ImGui::EndChild(); 33 | } 34 | 35 | void Functions::LineEx(const char* Id) 36 | { 37 | Functions::Line(Id, ImGui::GetContentRegionAvailWidth(), 1); 38 | } 39 | 40 | void Functions::LineVertical() 41 | { 42 | ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); 43 | } 44 | 45 | void Functions::Helpmarker(const char* Text, ImColor Color) 46 | { 47 | ImGui::TextColored(Color, "(?)"); 48 | if (ImGui::IsItemHovered()) 49 | ImGui::SetTooltip(Text); 50 | } -------------------------------------------------------------------------------- /Menu remake part 1/functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | enum GAME_STATUS 8 | { 9 | UNDETECTED, 10 | UPDATING, 11 | DETECTED, 12 | COMING_SOON 13 | }; 14 | 15 | namespace Functions 16 | { 17 | void Rainbow(); 18 | void Helpmarker(const char* Text, ImColor Color); 19 | void Line(const char* Id, int width, int height); 20 | void LineEx(const char* Id); 21 | void LineVertical(); 22 | 23 | void Inject(std::string game); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Menu remake part 1/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | //#define IMGUI_API __declspec( dllexport ) 25 | //#define IMGUI_API __declspec( dllimport ) 26 | 27 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 28 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 29 | 30 | //---- Disable all of Dear ImGui or don't implement standard windows. 31 | // It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. 32 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 33 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. 34 | //#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty. 35 | 36 | //---- Don't implement some functions to reduce linkage requirements. 37 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. 38 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. 39 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). 40 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 41 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 42 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 43 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 44 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 45 | 46 | //---- Include imgui_user.h at the end of imgui.h as a convenience 47 | //#define IMGUI_INCLUDE_IMGUI_USER_H 48 | 49 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 50 | //#define IMGUI_USE_BGRA_PACKED_COLOR 51 | 52 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 53 | //#define IMGUI_USE_WCHAR32 54 | 55 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 56 | // By default the embedded implementations are declared static and not available outside of imgui cpp files. 57 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 58 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 59 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 60 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 61 | 62 | //---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library. 63 | // Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. 64 | // #define IMGUI_USE_STB_SPRINTF 65 | 66 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 67 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 68 | /* 69 | #define IM_VEC2_CLASS_EXTRA \ 70 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 71 | operator MyVec2() const { return MyVec2(x,y); } 72 | 73 | #define IM_VEC4_CLASS_EXTRA \ 74 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 75 | operator MyVec4() const { return MyVec4(x,y,z,w); } 76 | */ 77 | 78 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 79 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 80 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 81 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 82 | //#define ImDrawIdx unsigned int 83 | 84 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 85 | //struct ImDrawList; 86 | //struct ImDrawCmd; 87 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 88 | //#define ImDrawCallback MyImDrawCallback 89 | 90 | //---- Debug Tools: Macro to break in Debugger 91 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 92 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 93 | //#define IM_DEBUG_BREAK __debugbreak() 94 | 95 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), 96 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) 97 | // This adds a small runtime cost which is why it is not enabled by default. 98 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX 99 | 100 | //---- Debug Tools: Enable slower asserts 101 | //#define IMGUI_DEBUG_PARANOID 102 | 103 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 104 | /* 105 | namespace ImGui 106 | { 107 | void MyFunction(const char* name, const MyMatrix44& v); 108 | } 109 | */ 110 | -------------------------------------------------------------------------------- /Menu remake part 1/imgui/imgui_impl_dx9.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 7 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 8 | 9 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | // CHANGELOG 14 | // (minor and older changes stripped away, please see git history for details) 15 | // 2020-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. 16 | // 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. 17 | // 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. 18 | // 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). 19 | // 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. 20 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. 21 | // 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. 22 | // 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. 23 | // 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. 24 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. 25 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. 26 | 27 | #include "imgui.h" 28 | #include "imgui_impl_dx9.h" 29 | 30 | // DirectX 31 | #include 32 | #define DIRECTINPUT_VERSION 0x0800 33 | #include 34 | 35 | // DirectX data 36 | static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; 37 | static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; 38 | static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL; 39 | static LPDIRECT3DTEXTURE9 g_FontTexture = NULL; 40 | static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; 41 | 42 | struct CUSTOMVERTEX 43 | { 44 | float pos[3]; 45 | D3DCOLOR col; 46 | float uv[2]; 47 | }; 48 | #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) 49 | 50 | // Forward Declarations 51 | static void ImGui_ImplDX9_InitPlatformInterface(); 52 | static void ImGui_ImplDX9_ShutdownPlatformInterface(); 53 | static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows(); 54 | static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows(); 55 | 56 | static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) 57 | { 58 | // Setup viewport 59 | D3DVIEWPORT9 vp; 60 | vp.X = vp.Y = 0; 61 | vp.Width = (DWORD)draw_data->DisplaySize.x; 62 | vp.Height = (DWORD)draw_data->DisplaySize.y; 63 | vp.MinZ = 0.0f; 64 | vp.MaxZ = 1.0f; 65 | g_pd3dDevice->SetViewport(&vp); 66 | 67 | // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) 68 | g_pd3dDevice->SetPixelShader(NULL); 69 | g_pd3dDevice->SetVertexShader(NULL); 70 | g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); 71 | g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 72 | g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); 73 | g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); 74 | g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); 75 | g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); 76 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); 77 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 78 | g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); 79 | g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 80 | g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 81 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); 82 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); 83 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); 84 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); 85 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); 86 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); 87 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); 88 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); 89 | 90 | // Setup orthographic projection matrix 91 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. 92 | // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() 93 | { 94 | float L = draw_data->DisplayPos.x + 0.5f; 95 | float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; 96 | float T = draw_data->DisplayPos.y + 0.5f; 97 | float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; 98 | D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; 99 | D3DMATRIX mat_projection = 100 | { { { 101 | 2.0f/(R-L), 0.0f, 0.0f, 0.0f, 102 | 0.0f, 2.0f/(T-B), 0.0f, 0.0f, 103 | 0.0f, 0.0f, 0.5f, 0.0f, 104 | (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f 105 | } } }; 106 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); 107 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); 108 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); 109 | } 110 | } 111 | 112 | // Render function. 113 | void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) 114 | { 115 | // Avoid rendering when minimized 116 | if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) 117 | return; 118 | 119 | // Create and grow buffers if needed 120 | if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) 121 | { 122 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 123 | g_VertexBufferSize = draw_data->TotalVtxCount + 5000; 124 | if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0) 125 | return; 126 | } 127 | if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) 128 | { 129 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 130 | g_IndexBufferSize = draw_data->TotalIdxCount + 10000; 131 | if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0) 132 | return; 133 | } 134 | 135 | // Backup the DX9 state 136 | IDirect3DStateBlock9* d3d9_state_block = NULL; 137 | if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) 138 | return; 139 | 140 | // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) 141 | D3DMATRIX last_world, last_view, last_projection; 142 | g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); 143 | g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); 144 | g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); 145 | 146 | // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. 147 | // FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and 148 | // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR 149 | // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } 150 | CUSTOMVERTEX* vtx_dst; 151 | ImDrawIdx* idx_dst; 152 | if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) 153 | return; 154 | if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) 155 | return; 156 | for (int n = 0; n < draw_data->CmdListsCount; n++) 157 | { 158 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 159 | const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; 160 | for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) 161 | { 162 | vtx_dst->pos[0] = vtx_src->pos.x; 163 | vtx_dst->pos[1] = vtx_src->pos.y; 164 | vtx_dst->pos[2] = 0.0f; 165 | vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 166 | vtx_dst->uv[0] = vtx_src->uv.x; 167 | vtx_dst->uv[1] = vtx_src->uv.y; 168 | vtx_dst++; 169 | vtx_src++; 170 | } 171 | memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); 172 | idx_dst += cmd_list->IdxBuffer.Size; 173 | } 174 | g_pVB->Unlock(); 175 | g_pIB->Unlock(); 176 | g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); 177 | g_pd3dDevice->SetIndices(g_pIB); 178 | g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); 179 | 180 | // Setup desired DX state 181 | ImGui_ImplDX9_SetupRenderState(draw_data); 182 | 183 | // Render command lists 184 | // (Because we merged all buffers into a single one, we maintain our own offset into them) 185 | int global_vtx_offset = 0; 186 | int global_idx_offset = 0; 187 | ImVec2 clip_off = draw_data->DisplayPos; 188 | for (int n = 0; n < draw_data->CmdListsCount; n++) 189 | { 190 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 191 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) 192 | { 193 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; 194 | if (pcmd->UserCallback != NULL) 195 | { 196 | // User callback, registered via ImDrawList::AddCallback() 197 | // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) 198 | if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) 199 | ImGui_ImplDX9_SetupRenderState(draw_data); 200 | else 201 | pcmd->UserCallback(cmd_list, pcmd); 202 | } 203 | else 204 | { 205 | const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) }; 206 | const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId; 207 | g_pd3dDevice->SetTexture(0, texture); 208 | g_pd3dDevice->SetScissorRect(&r); 209 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); 210 | } 211 | } 212 | global_idx_offset += cmd_list->IdxBuffer.Size; 213 | global_vtx_offset += cmd_list->VtxBuffer.Size; 214 | } 215 | 216 | // When using multi-viewports, it appears that there's an odd logic in DirectX9 which prevent subsequent windows 217 | // from rendering until the first window submits at least one draw call, even once. That's our workaround. (see #2560) 218 | if (global_vtx_offset == 0) 219 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0); 220 | 221 | // Restore the DX9 transform 222 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); 223 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); 224 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); 225 | 226 | // Restore the DX9 state 227 | d3d9_state_block->Apply(); 228 | d3d9_state_block->Release(); 229 | } 230 | 231 | bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) 232 | { 233 | // Setup backend capabilities flags 234 | ImGuiIO& io = ImGui::GetIO(); 235 | io.BackendRendererName = "imgui_impl_dx9"; 236 | io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. 237 | io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional) 238 | 239 | g_pd3dDevice = device; 240 | g_pd3dDevice->AddRef(); 241 | 242 | if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) 243 | ImGui_ImplDX9_InitPlatformInterface(); 244 | 245 | return true; 246 | } 247 | 248 | void ImGui_ImplDX9_Shutdown() 249 | { 250 | ImGui_ImplDX9_ShutdownPlatformInterface(); 251 | ImGui_ImplDX9_InvalidateDeviceObjects(); 252 | if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } 253 | } 254 | 255 | static bool ImGui_ImplDX9_CreateFontsTexture() 256 | { 257 | // Build texture atlas 258 | ImGuiIO& io = ImGui::GetIO(); 259 | unsigned char* pixels; 260 | int width, height, bytes_per_pixel; 261 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); 262 | 263 | // Upload texture to graphics system 264 | g_FontTexture = NULL; 265 | if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0) 266 | return false; 267 | D3DLOCKED_RECT tex_locked_rect; 268 | if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) 269 | return false; 270 | for (int y = 0; y < height; y++) 271 | memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel)); 272 | g_FontTexture->UnlockRect(0); 273 | 274 | // Store our identifier 275 | io.Fonts->TexID = (ImTextureID)g_FontTexture; 276 | 277 | return true; 278 | } 279 | 280 | bool ImGui_ImplDX9_CreateDeviceObjects() 281 | { 282 | if (!g_pd3dDevice) 283 | return false; 284 | if (!ImGui_ImplDX9_CreateFontsTexture()) 285 | return false; 286 | ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows(); 287 | return true; 288 | } 289 | 290 | void ImGui_ImplDX9_InvalidateDeviceObjects() 291 | { 292 | if (!g_pd3dDevice) 293 | return; 294 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 295 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 296 | if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. 297 | ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows(); 298 | } 299 | 300 | void ImGui_ImplDX9_NewFrame() 301 | { 302 | if (!g_FontTexture) 303 | ImGui_ImplDX9_CreateDeviceObjects(); 304 | } 305 | 306 | //-------------------------------------------------------------------------------------------------------- 307 | // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT 308 | // This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. 309 | // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. 310 | //-------------------------------------------------------------------------------------------------------- 311 | 312 | // Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. 313 | struct ImGuiViewportDataDx9 314 | { 315 | IDirect3DSwapChain9* SwapChain; 316 | D3DPRESENT_PARAMETERS d3dpp; 317 | 318 | ImGuiViewportDataDx9() { SwapChain = NULL; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); } 319 | ~ImGuiViewportDataDx9() { IM_ASSERT(SwapChain == NULL); } 320 | }; 321 | 322 | static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport) 323 | { 324 | ImGuiViewportDataDx9* data = IM_NEW(ImGuiViewportDataDx9)(); 325 | viewport->RendererUserData = data; 326 | 327 | // PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*). 328 | // Some backends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. 329 | HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle; 330 | IM_ASSERT(hwnd != 0); 331 | 332 | ZeroMemory(&data->d3dpp, sizeof(D3DPRESENT_PARAMETERS)); 333 | data->d3dpp.Windowed = TRUE; 334 | data->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; 335 | data->d3dpp.BackBufferWidth = (UINT)viewport->Size.x; 336 | data->d3dpp.BackBufferHeight = (UINT)viewport->Size.y; 337 | data->d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; 338 | data->d3dpp.hDeviceWindow = hwnd; 339 | data->d3dpp.EnableAutoDepthStencil = FALSE; 340 | data->d3dpp.AutoDepthStencilFormat = D3DFMT_D16; 341 | data->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync 342 | 343 | HRESULT hr = g_pd3dDevice->CreateAdditionalSwapChain(&data->d3dpp, &data->SwapChain); IM_UNUSED(hr); 344 | IM_ASSERT(hr == D3D_OK); 345 | IM_ASSERT(data->SwapChain != NULL); 346 | } 347 | 348 | static void ImGui_ImplDX9_DestroyWindow(ImGuiViewport* viewport) 349 | { 350 | // The main viewport (owned by the application) will always have RendererUserData == NULL since we didn't create the data for it. 351 | if (ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData) 352 | { 353 | if (data->SwapChain) 354 | data->SwapChain->Release(); 355 | data->SwapChain = NULL; 356 | ZeroMemory(&data->d3dpp, sizeof(D3DPRESENT_PARAMETERS)); 357 | IM_DELETE(data); 358 | } 359 | viewport->RendererUserData = NULL; 360 | } 361 | 362 | static void ImGui_ImplDX9_SetWindowSize(ImGuiViewport* viewport, ImVec2 size) 363 | { 364 | ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData; 365 | if (data->SwapChain) 366 | { 367 | data->SwapChain->Release(); 368 | data->SwapChain = NULL; 369 | data->d3dpp.BackBufferWidth = (UINT)size.x; 370 | data->d3dpp.BackBufferHeight = (UINT)size.y; 371 | HRESULT hr = g_pd3dDevice->CreateAdditionalSwapChain(&data->d3dpp, &data->SwapChain); IM_UNUSED(hr); 372 | IM_ASSERT(hr == D3D_OK); 373 | } 374 | } 375 | 376 | static void ImGui_ImplDX9_RenderWindow(ImGuiViewport* viewport, void*) 377 | { 378 | ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData; 379 | ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f); 380 | 381 | LPDIRECT3DSURFACE9 render_target = NULL; 382 | LPDIRECT3DSURFACE9 last_render_target = NULL; 383 | LPDIRECT3DSURFACE9 last_depth_stencil = NULL; 384 | data->SwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &render_target); 385 | g_pd3dDevice->GetRenderTarget(0, &last_render_target); 386 | g_pd3dDevice->GetDepthStencilSurface(&last_depth_stencil); 387 | g_pd3dDevice->SetRenderTarget(0, render_target); 388 | g_pd3dDevice->SetDepthStencilSurface(NULL); 389 | 390 | if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear)) 391 | { 392 | D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f)); 393 | g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, clear_col_dx, 1.0f, 0); 394 | } 395 | 396 | ImGui_ImplDX9_RenderDrawData(viewport->DrawData); 397 | 398 | // Restore render target 399 | g_pd3dDevice->SetRenderTarget(0, last_render_target); 400 | g_pd3dDevice->SetDepthStencilSurface(last_depth_stencil); 401 | render_target->Release(); 402 | last_render_target->Release(); 403 | if (last_depth_stencil) last_depth_stencil->Release(); 404 | } 405 | 406 | static void ImGui_ImplDX9_SwapBuffers(ImGuiViewport* viewport, void*) 407 | { 408 | ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData; 409 | HRESULT hr = data->SwapChain->Present(NULL, NULL, data->d3dpp.hDeviceWindow, NULL, NULL); 410 | // Let main application handle D3DERR_DEVICELOST by resetting the device. 411 | IM_ASSERT(hr == D3D_OK || hr == D3DERR_DEVICELOST); 412 | } 413 | 414 | static void ImGui_ImplDX9_InitPlatformInterface() 415 | { 416 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); 417 | platform_io.Renderer_CreateWindow = ImGui_ImplDX9_CreateWindow; 418 | platform_io.Renderer_DestroyWindow = ImGui_ImplDX9_DestroyWindow; 419 | platform_io.Renderer_SetWindowSize = ImGui_ImplDX9_SetWindowSize; 420 | platform_io.Renderer_RenderWindow = ImGui_ImplDX9_RenderWindow; 421 | platform_io.Renderer_SwapBuffers = ImGui_ImplDX9_SwapBuffers; 422 | } 423 | 424 | static void ImGui_ImplDX9_ShutdownPlatformInterface() 425 | { 426 | ImGui::DestroyPlatformWindows(); 427 | } 428 | 429 | static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows() 430 | { 431 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); 432 | for (int i = 1; i < platform_io.Viewports.Size; i++) 433 | if (!platform_io.Viewports[i]->RendererUserData) 434 | ImGui_ImplDX9_CreateWindow(platform_io.Viewports[i]); 435 | } 436 | 437 | static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows() 438 | { 439 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); 440 | for (int i = 1; i < platform_io.Viewports.Size; i++) 441 | if (platform_io.Viewports[i]->RendererUserData) 442 | ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]); 443 | } 444 | -------------------------------------------------------------------------------- /Menu remake part 1/imgui/imgui_impl_dx9.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 7 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 8 | 9 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include "imgui.h" // IMGUI_IMPL_API 15 | 16 | struct IDirect3DDevice9; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); 19 | IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); 25 | IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /Menu remake part 1/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 13 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 14 | 15 | #pragma once 16 | #include "imgui.h" // IMGUI_IMPL_API 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 21 | 22 | // Configuration 23 | // - Disable gamepad support or linking with xinput.lib 24 | //#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 25 | //#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT 26 | 27 | // Win32 message handler your application need to call. 28 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 29 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 30 | #if 0 31 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 32 | #endif 33 | 34 | // DPI-related helpers (optional) 35 | // - Use to enable DPI awareness without having to create an application manifest. 36 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 37 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 38 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 39 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 40 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 41 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 42 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 43 | -------------------------------------------------------------------------------- /Menu remake part 1/imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.00. 3 | // Those changes would need to be pushed into nothings/stb: 4 | // - Added STBRP__CDECL 5 | // Grep for [DEAR IMGUI] to find the changes. 6 | 7 | // stb_rect_pack.h - v1.00 - public domain - rectangle packing 8 | // Sean Barrett 2014 9 | // 10 | // Useful for e.g. packing rectangular textures into an atlas. 11 | // Does not do rotation. 12 | // 13 | // Not necessarily the awesomest packing method, but better than 14 | // the totally naive one in stb_truetype (which is primarily what 15 | // this is meant to replace). 16 | // 17 | // Has only had a few tests run, may have issues. 18 | // 19 | // More docs to come. 20 | // 21 | // No memory allocations; uses qsort() and assert() from stdlib. 22 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 23 | // 24 | // This library currently uses the Skyline Bottom-Left algorithm. 25 | // 26 | // Please note: better rectangle packers are welcome! Please 27 | // implement them to the same API, but with a different init 28 | // function. 29 | // 30 | // Credits 31 | // 32 | // Library 33 | // Sean Barrett 34 | // Minor features 35 | // Martins Mozeiko 36 | // github:IntellectualKitty 37 | // 38 | // Bugfixes / warning fixes 39 | // Jeremy Jaussaud 40 | // Fabian Giesen 41 | // 42 | // Version history: 43 | // 44 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 45 | // 0.99 (2019-02-07) warning fixes 46 | // 0.11 (2017-03-03) return packing success/fail result 47 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 48 | // 0.09 (2016-08-27) fix compiler warnings 49 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 50 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 51 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 52 | // 0.05: added STBRP_ASSERT to allow replacing assert 53 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 54 | // 0.01: initial release 55 | // 56 | // LICENSE 57 | // 58 | // See end of file for license information. 59 | 60 | ////////////////////////////////////////////////////////////////////////////// 61 | // 62 | // INCLUDE SECTION 63 | // 64 | 65 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 66 | #define STB_INCLUDE_STB_RECT_PACK_H 67 | 68 | #define STB_RECT_PACK_VERSION 1 69 | 70 | #ifdef STBRP_STATIC 71 | #define STBRP_DEF static 72 | #else 73 | #define STBRP_DEF extern 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | 80 | typedef struct stbrp_context stbrp_context; 81 | typedef struct stbrp_node stbrp_node; 82 | typedef struct stbrp_rect stbrp_rect; 83 | 84 | #ifdef STBRP_LARGE_RECTS 85 | typedef int stbrp_coord; 86 | #else 87 | typedef unsigned short stbrp_coord; 88 | #endif 89 | 90 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 91 | // Assign packed locations to rectangles. The rectangles are of type 92 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 93 | // are 'num_rects' many of them. 94 | // 95 | // Rectangles which are successfully packed have the 'was_packed' flag 96 | // set to a non-zero value and 'x' and 'y' store the minimum location 97 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 98 | // if you imagine y increasing downwards). Rectangles which do not fit 99 | // have the 'was_packed' flag set to 0. 100 | // 101 | // You should not try to access the 'rects' array from another thread 102 | // while this function is running, as the function temporarily reorders 103 | // the array while it executes. 104 | // 105 | // To pack into another rectangle, you need to call stbrp_init_target 106 | // again. To continue packing into the same rectangle, you can call 107 | // this function again. Calling this multiple times with multiple rect 108 | // arrays will probably produce worse packing results than calling it 109 | // a single time with the full rectangle array, but the option is 110 | // available. 111 | // 112 | // The function returns 1 if all of the rectangles were successfully 113 | // packed and 0 otherwise. 114 | 115 | struct stbrp_rect 116 | { 117 | // reserved for your use: 118 | int id; 119 | 120 | // input: 121 | stbrp_coord w, h; 122 | 123 | // output: 124 | stbrp_coord x, y; 125 | int was_packed; // non-zero if valid packing 126 | 127 | }; // 16 bytes, nominally 128 | 129 | 130 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 131 | // Initialize a rectangle packer to: 132 | // pack a rectangle that is 'width' by 'height' in dimensions 133 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 134 | // 135 | // You must call this function every time you start packing into a new target. 136 | // 137 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 138 | // the following stbrp_pack_rects() call (or calls), but can be freed after 139 | // the call (or calls) finish. 140 | // 141 | // Note: to guarantee best results, either: 142 | // 1. make sure 'num_nodes' >= 'width' 143 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 144 | // 145 | // If you don't do either of the above things, widths will be quantized to multiples 146 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 147 | // 148 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 149 | // may run out of temporary storage and be unable to pack some rectangles. 150 | 151 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 152 | // Optionally call this function after init but before doing any packing to 153 | // change the handling of the out-of-temp-memory scenario, described above. 154 | // If you call init again, this will be reset to the default (false). 155 | 156 | 157 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 158 | // Optionally select which packing heuristic the library should use. Different 159 | // heuristics will produce better/worse results for different data sets. 160 | // If you call init again, this will be reset to the default. 161 | 162 | enum 163 | { 164 | STBRP_HEURISTIC_Skyline_default=0, 165 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 166 | STBRP_HEURISTIC_Skyline_BF_sortHeight 167 | }; 168 | 169 | 170 | ////////////////////////////////////////////////////////////////////////////// 171 | // 172 | // the details of the following structures don't matter to you, but they must 173 | // be visible so you can handle the memory allocations for them 174 | 175 | struct stbrp_node 176 | { 177 | stbrp_coord x,y; 178 | stbrp_node *next; 179 | }; 180 | 181 | struct stbrp_context 182 | { 183 | int width; 184 | int height; 185 | int align; 186 | int init_mode; 187 | int heuristic; 188 | int num_nodes; 189 | stbrp_node *active_head; 190 | stbrp_node *free_head; 191 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 192 | }; 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif 199 | 200 | ////////////////////////////////////////////////////////////////////////////// 201 | // 202 | // IMPLEMENTATION SECTION 203 | // 204 | 205 | #ifdef STB_RECT_PACK_IMPLEMENTATION 206 | #ifndef STBRP_SORT 207 | #include 208 | #define STBRP_SORT qsort 209 | #endif 210 | 211 | #ifndef STBRP_ASSERT 212 | #include 213 | #define STBRP_ASSERT assert 214 | #endif 215 | 216 | // [DEAR IMGUI] Added STBRP__CDECL 217 | #ifdef _MSC_VER 218 | #define STBRP__NOTUSED(v) (void)(v) 219 | #define STBRP__CDECL __cdecl 220 | #else 221 | #define STBRP__NOTUSED(v) (void)sizeof(v) 222 | #define STBRP__CDECL 223 | #endif 224 | 225 | enum 226 | { 227 | STBRP__INIT_skyline = 1 228 | }; 229 | 230 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 231 | { 232 | switch (context->init_mode) { 233 | case STBRP__INIT_skyline: 234 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 235 | context->heuristic = heuristic; 236 | break; 237 | default: 238 | STBRP_ASSERT(0); 239 | } 240 | } 241 | 242 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 243 | { 244 | if (allow_out_of_mem) 245 | // if it's ok to run out of memory, then don't bother aligning them; 246 | // this gives better packing, but may fail due to OOM (even though 247 | // the rectangles easily fit). @TODO a smarter approach would be to only 248 | // quantize once we've hit OOM, then we could get rid of this parameter. 249 | context->align = 1; 250 | else { 251 | // if it's not ok to run out of memory, then quantize the widths 252 | // so that num_nodes is always enough nodes. 253 | // 254 | // I.e. num_nodes * align >= width 255 | // align >= width / num_nodes 256 | // align = ceil(width/num_nodes) 257 | 258 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 259 | } 260 | } 261 | 262 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 263 | { 264 | int i; 265 | #ifndef STBRP_LARGE_RECTS 266 | STBRP_ASSERT(width <= 0xffff && height <= 0xffff); 267 | #endif 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | #ifdef STBRP_LARGE_RECTS 287 | context->extra[1].y = (1<<30); 288 | #else 289 | context->extra[1].y = 65535; 290 | #endif 291 | context->extra[1].next = NULL; 292 | } 293 | 294 | // find minimum y position if it starts at x1 295 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 296 | { 297 | stbrp_node *node = first; 298 | int x1 = x0 + width; 299 | int min_y, visited_width, waste_area; 300 | 301 | STBRP__NOTUSED(c); 302 | 303 | STBRP_ASSERT(first->x <= x0); 304 | 305 | #if 0 306 | // skip in case we're past the node 307 | while (node->next->x <= x0) 308 | ++node; 309 | #else 310 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 311 | #endif 312 | 313 | STBRP_ASSERT(node->x <= x0); 314 | 315 | min_y = 0; 316 | waste_area = 0; 317 | visited_width = 0; 318 | while (node->x < x1) { 319 | if (node->y > min_y) { 320 | // raise min_y higher. 321 | // we've accounted for all waste up to min_y, 322 | // but we'll now add more waste for everything we've visted 323 | waste_area += visited_width * (node->y - min_y); 324 | min_y = node->y; 325 | // the first time through, visited_width might be reduced 326 | if (node->x < x0) 327 | visited_width += node->next->x - x0; 328 | else 329 | visited_width += node->next->x - node->x; 330 | } else { 331 | // add waste area 332 | int under_width = node->next->x - node->x; 333 | if (under_width + visited_width > width) 334 | under_width = width - visited_width; 335 | waste_area += under_width * (min_y - node->y); 336 | visited_width += under_width; 337 | } 338 | node = node->next; 339 | } 340 | 341 | *pwaste = waste_area; 342 | return min_y; 343 | } 344 | 345 | typedef struct 346 | { 347 | int x,y; 348 | stbrp_node **prev_link; 349 | } stbrp__findresult; 350 | 351 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 352 | { 353 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 354 | stbrp__findresult fr; 355 | stbrp_node **prev, *node, *tail, **best = NULL; 356 | 357 | // align to multiple of c->align 358 | width = (width + c->align - 1); 359 | width -= width % c->align; 360 | STBRP_ASSERT(width % c->align == 0); 361 | 362 | // if it can't possibly fit, bail immediately 363 | if (width > c->width || height > c->height) { 364 | fr.prev_link = NULL; 365 | fr.x = fr.y = 0; 366 | return fr; 367 | } 368 | 369 | node = c->active_head; 370 | prev = &c->active_head; 371 | while (node->x + width <= c->width) { 372 | int y,waste; 373 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 374 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 375 | // bottom left 376 | if (y < best_y) { 377 | best_y = y; 378 | best = prev; 379 | } 380 | } else { 381 | // best-fit 382 | if (y + height <= c->height) { 383 | // can only use it if it first vertically 384 | if (y < best_y || (y == best_y && waste < best_waste)) { 385 | best_y = y; 386 | best_waste = waste; 387 | best = prev; 388 | } 389 | } 390 | } 391 | prev = &node->next; 392 | node = node->next; 393 | } 394 | 395 | best_x = (best == NULL) ? 0 : (*best)->x; 396 | 397 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 398 | // 399 | // e.g, if fitting 400 | // 401 | // ____________________ 402 | // |____________________| 403 | // 404 | // into 405 | // 406 | // | | 407 | // | ____________| 408 | // |____________| 409 | // 410 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 411 | // 412 | // This makes BF take about 2x the time 413 | 414 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 415 | tail = c->active_head; 416 | node = c->active_head; 417 | prev = &c->active_head; 418 | // find first node that's admissible 419 | while (tail->x < width) 420 | tail = tail->next; 421 | while (tail) { 422 | int xpos = tail->x - width; 423 | int y,waste; 424 | STBRP_ASSERT(xpos >= 0); 425 | // find the left position that matches this 426 | while (node->next->x <= xpos) { 427 | prev = &node->next; 428 | node = node->next; 429 | } 430 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 431 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 432 | if (y + height <= c->height) { 433 | if (y <= best_y) { 434 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 435 | best_x = xpos; 436 | STBRP_ASSERT(y <= best_y); 437 | best_y = y; 438 | best_waste = waste; 439 | best = prev; 440 | } 441 | } 442 | } 443 | tail = tail->next; 444 | } 445 | } 446 | 447 | fr.prev_link = best; 448 | fr.x = best_x; 449 | fr.y = best_y; 450 | return fr; 451 | } 452 | 453 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 454 | { 455 | // find best position according to heuristic 456 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 457 | stbrp_node *node, *cur; 458 | 459 | // bail if: 460 | // 1. it failed 461 | // 2. the best node doesn't fit (we don't always check this) 462 | // 3. we're out of memory 463 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 464 | res.prev_link = NULL; 465 | return res; 466 | } 467 | 468 | // on success, create new node 469 | node = context->free_head; 470 | node->x = (stbrp_coord) res.x; 471 | node->y = (stbrp_coord) (res.y + height); 472 | 473 | context->free_head = node->next; 474 | 475 | // insert the new node into the right starting point, and 476 | // let 'cur' point to the remaining nodes needing to be 477 | // stiched back in 478 | 479 | cur = *res.prev_link; 480 | if (cur->x < res.x) { 481 | // preserve the existing one, so start testing with the next one 482 | stbrp_node *next = cur->next; 483 | cur->next = node; 484 | cur = next; 485 | } else { 486 | *res.prev_link = node; 487 | } 488 | 489 | // from here, traverse cur and free the nodes, until we get to one 490 | // that shouldn't be freed 491 | while (cur->next && cur->next->x <= res.x + width) { 492 | stbrp_node *next = cur->next; 493 | // move the current node to the free list 494 | cur->next = context->free_head; 495 | context->free_head = cur; 496 | cur = next; 497 | } 498 | 499 | // stitch the list back in 500 | node->next = cur; 501 | 502 | if (cur->x < res.x + width) 503 | cur->x = (stbrp_coord) (res.x + width); 504 | 505 | #ifdef _DEBUG 506 | cur = context->active_head; 507 | while (cur->x < context->width) { 508 | STBRP_ASSERT(cur->x < cur->next->x); 509 | cur = cur->next; 510 | } 511 | STBRP_ASSERT(cur->next == NULL); 512 | 513 | { 514 | int count=0; 515 | cur = context->active_head; 516 | while (cur) { 517 | cur = cur->next; 518 | ++count; 519 | } 520 | cur = context->free_head; 521 | while (cur) { 522 | cur = cur->next; 523 | ++count; 524 | } 525 | STBRP_ASSERT(count == context->num_nodes+2); 526 | } 527 | #endif 528 | 529 | return res; 530 | } 531 | 532 | // [DEAR IMGUI] Added STBRP__CDECL 533 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 534 | { 535 | const stbrp_rect *p = (const stbrp_rect *) a; 536 | const stbrp_rect *q = (const stbrp_rect *) b; 537 | if (p->h > q->h) 538 | return -1; 539 | if (p->h < q->h) 540 | return 1; 541 | return (p->w > q->w) ? -1 : (p->w < q->w); 542 | } 543 | 544 | // [DEAR IMGUI] Added STBRP__CDECL 545 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 546 | { 547 | const stbrp_rect *p = (const stbrp_rect *) a; 548 | const stbrp_rect *q = (const stbrp_rect *) b; 549 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 550 | } 551 | 552 | #ifdef STBRP_LARGE_RECTS 553 | #define STBRP__MAXVAL 0xffffffff 554 | #else 555 | #define STBRP__MAXVAL 0xffff 556 | #endif 557 | 558 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 559 | { 560 | int i, all_rects_packed = 1; 561 | 562 | // we use the 'was_packed' field internally to allow sorting/unsorting 563 | for (i=0; i < num_rects; ++i) { 564 | rects[i].was_packed = i; 565 | } 566 | 567 | // sort according to heuristic 568 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 569 | 570 | for (i=0; i < num_rects; ++i) { 571 | if (rects[i].w == 0 || rects[i].h == 0) { 572 | rects[i].x = rects[i].y = 0; // empty rect needs no space 573 | } else { 574 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 575 | if (fr.prev_link) { 576 | rects[i].x = (stbrp_coord) fr.x; 577 | rects[i].y = (stbrp_coord) fr.y; 578 | } else { 579 | rects[i].x = rects[i].y = STBRP__MAXVAL; 580 | } 581 | } 582 | } 583 | 584 | // unsort 585 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 586 | 587 | // set was_packed flags and all_rects_packed status 588 | for (i=0; i < num_rects; ++i) { 589 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 590 | if (!rects[i].was_packed) 591 | all_rects_packed = 0; 592 | } 593 | 594 | // return the all_rects_packed status 595 | return all_rects_packed; 596 | } 597 | #endif 598 | 599 | /* 600 | ------------------------------------------------------------------------------ 601 | This software is available under 2 licenses -- choose whichever you prefer. 602 | ------------------------------------------------------------------------------ 603 | ALTERNATIVE A - MIT License 604 | Copyright (c) 2017 Sean Barrett 605 | Permission is hereby granted, free of charge, to any person obtaining a copy of 606 | this software and associated documentation files (the "Software"), to deal in 607 | the Software without restriction, including without limitation the rights to 608 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 609 | of the Software, and to permit persons to whom the Software is furnished to do 610 | so, subject to the following conditions: 611 | The above copyright notice and this permission notice shall be included in all 612 | copies or substantial portions of the Software. 613 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 614 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 615 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 616 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 617 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 618 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 619 | SOFTWARE. 620 | ------------------------------------------------------------------------------ 621 | ALTERNATIVE B - Public Domain (www.unlicense.org) 622 | This is free and unencumbered software released into the public domain. 623 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 624 | software, either in source code form or as a compiled binary, for any purpose, 625 | commercial or non-commercial, and by any means. 626 | In jurisdictions that recognize copyright laws, the author or authors of this 627 | software dedicate any and all copyright interest in the software to the public 628 | domain. We make this dedication for the benefit of the public at large and to 629 | the detriment of our heirs and successors. We intend this dedication to be an 630 | overt act of relinquishment in perpetuity of all present and future rights to 631 | this software under copyright law. 632 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 633 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 634 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 635 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 636 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 637 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 638 | ------------------------------------------------------------------------------ 639 | */ 640 | -------------------------------------------------------------------------------- /Menu remake part 1/imguipp.cpp: -------------------------------------------------------------------------------- 1 | #include "imguipp.h" 2 | namespace imguipp 3 | { 4 | 5 | float getx() 6 | { 7 | return ImGui::GetContentRegionAvail().x; 8 | } 9 | 10 | float gety() 11 | { 12 | return ImGui::GetContentRegionAvail().y; 13 | } 14 | 15 | void button(const char* label, int& currentTab, int newTab, ImVec2 size) 16 | { 17 | if (ImGui::Button(label, size)) 18 | currentTab = newTab; 19 | } 20 | 21 | void line(int newId) 22 | { 23 | std::string id = ("imguipp_line_" + std::to_string(newId)); 24 | ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0)); 25 | { 26 | ImGui::BeginChild(id.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 1), false); 27 | ImGui::Separator(); 28 | ImGui::EndChild(); 29 | } 30 | ImGui::PopStyleColor(); 31 | } 32 | 33 | void linevertical() 34 | { 35 | ImGui::SameLine(); 36 | ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); 37 | ImGui::SameLine(); 38 | } 39 | 40 | void center_text(const char* text, int lineId , bool separator) 41 | { 42 | if (text == nullptr) 43 | return; 44 | 45 | ImGui::Spacing(); 46 | ImGui::SameLine((ImGui::GetContentRegionAvail().x / 2) - (ImGui::CalcTextSize(text).x / 2)); 47 | ImGui::Text(text); 48 | ImGui::Spacing(); 49 | 50 | if (true == separator) 51 | line(lineId); 52 | } 53 | 54 | void center_text_ex(const char* text, float width_available, int lineId, bool separator) 55 | { 56 | if (text == nullptr) 57 | return; 58 | 59 | ImGui::Spacing(); 60 | ImGui::SameLine((width_available / 2) - (ImGui::CalcTextSize(text).x / 2)); 61 | ImGui::Text(text); 62 | ImGui::Spacing(); 63 | 64 | if (true == separator) 65 | line(lineId); 66 | } 67 | 68 | namespace other 69 | { 70 | float get_window_size_x() 71 | { 72 | return ImGui::GetWindowSize().x; 73 | } 74 | 75 | float get_window_size_y() 76 | { 77 | return ImGui::GetWindowSize().y; 78 | } 79 | 80 | ImVec2 get_window_size() 81 | { 82 | return ImGui::GetWindowSize(); 83 | } 84 | 85 | char* get_window_name() 86 | { 87 | return ImGui::GetCurrentWindow()->Name; 88 | } 89 | 90 | ImDrawList* get_drawlist() 91 | { 92 | return ImGui::GetCurrentWindow()->DrawList; 93 | } 94 | } 95 | 96 | ImVec4 to_vec4(float r, float g, float b, float a) 97 | { 98 | return ImVec4(r / 255.0, g / 255.0, b / 255.0, a / 255.0); 99 | } 100 | } -------------------------------------------------------------------------------- /Menu remake part 1/imguipp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef IMGUIPP_H 3 | #include 4 | #include 5 | #include 6 | 7 | namespace imguipp 8 | { 9 | 10 | 11 | float getx(); 12 | float gety(); 13 | 14 | void button(const char* label, int& currentTab, int newTab, ImVec2 size = ImVec2()); 15 | 16 | void line(int newId); 17 | void linevertical(); 18 | 19 | void center_text(const char* text, int lineId, bool separator); 20 | void center_text_ex(const char* text, float width_available, int lineId, bool separator); 21 | 22 | namespace other 23 | { 24 | float get_window_size_x(); 25 | float get_window_size_y(); 26 | 27 | ImVec2 get_window_size(); 28 | char* get_window_name(); 29 | ImDrawList* get_drawlist(); 30 | } 31 | 32 | ImVec4 to_vec4(float r, float g, float b, float a); 33 | 34 | } 35 | #define IMGUIPP_H 36 | #endif -------------------------------------------------------------------------------- /Menu remake part 1/menu.cpp: -------------------------------------------------------------------------------- 1 | #include "menu.h" 2 | #include "settings.h" 3 | #include "functions.h" 4 | #include "imguipp.h" 5 | #include "icons.h" 6 | 7 | void Menu::Render() 8 | { 9 | ImGui::Columns(2); 10 | ImGui::SetColumnOffset(1, 230); 11 | 12 | { 13 | //Left side 14 | 15 | static ImVec4 active = imguipp::to_vec4(41, 40, 41, 255); 16 | static ImVec4 inactive = imguipp::to_vec4(31, 30, 31, 255); 17 | 18 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 1 ? active : inactive); 19 | if (ImGui::Button(ICON_FA_CODE " Executor", ImVec2(230 - 15, 41))) 20 | Settings::Tab = 1; 21 | 22 | ImGui::Spacing(); 23 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 2 ? active : inactive); 24 | if (ImGui::Button(ICON_FA_DOWNLOAD " Dumper", ImVec2(230 - 15, 41))) 25 | Settings::Tab = 2; 26 | 27 | ImGui::Spacing(); 28 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 3 ? active : inactive); 29 | if (ImGui::Button(ICON_FA_BUG " Blocker", ImVec2(230 - 15, 41))) 30 | Settings::Tab = 3; 31 | 32 | ImGui::Spacing(); 33 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 4 ? active : inactive); 34 | if (ImGui::Button(ICON_FA_BOOK " Menus", ImVec2(230 - 15, 41))) 35 | Settings::Tab = 4; 36 | 37 | ImGui::PopStyleColor(4); 38 | 39 | ImGui::SetCursorPosY(ImGui::GetWindowHeight() - 30); 40 | imguipp::center_text_ex("DeCuttMutt2", 230, 1, false); 41 | } 42 | 43 | ImGui::NextColumn(); 44 | 45 | //Right side 46 | { 47 | //Dumper Tab 48 | if (Settings::Tab == 2) 49 | { 50 | static ImGuiTextFilter filter; 51 | static std::vector resources = 52 | { 53 | "_cfx_internal", 54 | "mysql-async", 55 | "essentialmode", 56 | "async", 57 | "es_extended" 58 | }; 59 | 60 | filter.Draw(ICON_FA_SEARCH" Search", 240); 61 | ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 0)); 62 | if (ImGui::ListBoxHeader("##ResourcesList", ImVec2(imguipp::getx(), imguipp::gety() - 35))) 63 | { 64 | for (const auto& resource : resources) 65 | { 66 | if (filter.PassFilter(resource.c_str())) 67 | { 68 | if (ImGui::TreeNode(resource.c_str())) 69 | ImGui::TreePop(); 70 | } 71 | } 72 | ImGui::ListBoxFooter(); 73 | } 74 | ImGui::PopStyleColor(); 75 | if (ImGui::Button(ICON_FA_FOLDER_OPEN" Save to folder", ImVec2(205, 34))) {} 76 | } 77 | } 78 | } 79 | 80 | void Menu::Theme() 81 | { 82 | ImGuiStyle* style = &ImGui::GetStyle(); 83 | 84 | style->WindowBorderSize = 0; 85 | style->WindowTitleAlign = ImVec2(0.5, 0.5); 86 | style->WindowMinSize = ImVec2(900, 430); 87 | 88 | style->FramePadding = ImVec2(8, 6); 89 | 90 | style->Colors[ImGuiCol_TitleBg] = ImColor(255, 101, 53, 255); 91 | style->Colors[ImGuiCol_TitleBgActive] = ImColor(255, 101, 53, 255); 92 | style->Colors[ImGuiCol_TitleBgCollapsed] = ImColor(0, 0, 0, 130); 93 | 94 | style->Colors[ImGuiCol_Button] = ImColor(31, 30, 31, 255); 95 | style->Colors[ImGuiCol_ButtonActive] = ImColor(31, 30, 31, 255); 96 | style->Colors[ImGuiCol_ButtonHovered] = ImColor(41, 40, 41, 255); 97 | 98 | style->Colors[ImGuiCol_Separator] = ImColor(70, 70, 70, 255); 99 | style->Colors[ImGuiCol_SeparatorActive] = ImColor(76, 76, 76, 255); 100 | style->Colors[ImGuiCol_SeparatorHovered] = ImColor(76, 76, 76, 255); 101 | 102 | style->Colors[ImGuiCol_FrameBg] = ImColor(37, 36, 37, 255); 103 | style->Colors[ImGuiCol_FrameBgActive] = ImColor(37, 36, 37, 255); 104 | style->Colors[ImGuiCol_FrameBgHovered] = ImColor(37, 36, 37, 255); 105 | 106 | style->Colors[ImGuiCol_Header] = ImColor(0, 0, 0, 0); 107 | style->Colors[ImGuiCol_HeaderActive] = ImColor(0, 0, 0, 0); 108 | style->Colors[ImGuiCol_HeaderHovered] = ImColor(46, 46, 46, 255); 109 | } -------------------------------------------------------------------------------- /Menu remake part 1/menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Menu 5 | { 6 | void Theme(); 7 | void Render(); 8 | } -------------------------------------------------------------------------------- /Menu remake part 1/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Settings 6 | { 7 | static int Tab = 0; 8 | } -------------------------------------------------------------------------------- /Menu remake part 2/External Menu Base.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.31129.286 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Loader Base", "Loader Base.vcxproj", "{AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x64.ActiveCfg = Debug|x64 17 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x64.Build.0 = Debug|x64 18 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x86.ActiveCfg = Debug|Win32 19 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Debug|x86.Build.0 = Debug|Win32 20 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x64.ActiveCfg = Release|x64 21 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x64.Build.0 = Release|x64 22 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x86.ActiveCfg = Release|Win32 23 | {AEAA4CEF-8D6D-4061-BCF1-C31CDDCCA231}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {D24F0276-5924-4762-96C3-86AFE66E2846} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Menu remake part 2/Loader Base.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | Debug 14 | x64 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 16.0 23 | Win32Proj 24 | {aeaa4cef-8d6d-4061-bcf1-c31cddcca231} 25 | LoaderBase 26 | 10.0 27 | External Menu Base 28 | 29 | 30 | 31 | Application 32 | true 33 | v142 34 | Unicode 35 | 36 | 37 | Application 38 | false 39 | v142 40 | true 41 | Unicode 42 | 43 | 44 | Application 45 | true 46 | v142 47 | Unicode 48 | 49 | 50 | Application 51 | false 52 | v142 53 | true 54 | Unicode 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | true 76 | 77 | 78 | false 79 | 80 | 81 | true 82 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui;$(IncludePath) 83 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) 84 | 85 | 86 | false 87 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui;$(IncludePath) 88 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x64;$(LibraryPath) 89 | 90 | 91 | 92 | Level3 93 | true 94 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) 95 | true 96 | 97 | 98 | Console 99 | true 100 | 101 | 102 | 103 | 104 | Level3 105 | true 106 | true 107 | true 108 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 109 | true 110 | 111 | 112 | Console 113 | true 114 | true 115 | true 116 | 117 | 118 | 119 | 120 | Level3 121 | true 122 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions) 123 | true 124 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui 125 | 126 | 127 | Windows 128 | true 129 | 130 | 131 | 132 | 133 | Level3 134 | true 135 | true 136 | true 137 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions) 138 | true 139 | C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Include;$(SolutionDir)/imgui 140 | 141 | 142 | Windows 143 | true 144 | true 145 | true 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | -------------------------------------------------------------------------------- /Menu remake part 2/Loader Base.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {3915832f-f15f-453b-99ad-aaee2acaa8a6} 10 | 11 | 12 | {39dbd3a4-bda5-4317-a3ef-50064f12ff10} 13 | 14 | 15 | {00794305-ea9a-47a5-bd71-f81cc5517c52} 16 | 17 | 18 | {494a0a43-7957-4989-a7a2-7dfe71516f68} 19 | 20 | 21 | {3056aec4-4ff8-48fc-a8ad-6695d07a4d3e} 22 | 23 | 24 | {6ca62923-0f53-409a-89d8-4645b470d87b} 25 | 26 | 27 | {3b78753f-124f-416a-a776-d54e6fdd5f2a} 28 | 29 | 30 | 31 | 32 | Source Files 33 | 34 | 35 | Framework\imgui 36 | 37 | 38 | Framework\imgui 39 | 40 | 41 | Framework\imgui 42 | 43 | 44 | Framework\imgui 45 | 46 | 47 | Framework\imgui 48 | 49 | 50 | Framework\imgui 51 | 52 | 53 | Framework\menu 54 | 55 | 56 | Framework\functions 57 | 58 | 59 | 60 | Framework\menu 61 | 62 | 63 | 64 | 65 | Framework\imgui 66 | 67 | 68 | Framework\imgui 69 | 70 | 71 | Framework\imgui 72 | 73 | 74 | Framework\imgui 75 | 76 | 77 | Framework\imgui 78 | 79 | 80 | Framework\imgui 81 | 82 | 83 | Framework\imgui 84 | 85 | 86 | Framework\imgui 87 | 88 | 89 | Source Files 90 | 91 | 92 | Framework\menu 93 | 94 | 95 | Framework\settings 96 | 97 | 98 | Framework\functions 99 | 100 | 101 | Framework\menu\font 102 | 103 | 104 | icons 105 | 106 | 107 | icons 108 | 109 | 110 | 111 | Framework\menu 112 | 113 | 114 | -------------------------------------------------------------------------------- /Menu remake part 2/Loader Base.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | false 5 | 6 | -------------------------------------------------------------------------------- /Menu remake part 2/Loader.cpp: -------------------------------------------------------------------------------- 1 | #include "Loader.h" 2 | #include "menu.h" 3 | #include "font.h" 4 | #include "functions.h" 5 | #include "iconcpp.h" 6 | 7 | /* 8 | Make sure to compile on x64 Release. 9 | Enjoy! xo1337. 10 | 11 | This main code was used from: https://github.com/noteffex/ImGui-Loader-Base/ , 12 | everything else was coded by xo1337. 13 | */ 14 | 15 | ImFont* Consolas = nullptr; 16 | int APIENTRY WinMain(HINSTANCE, HINSTANCE, LPSTR, int) 17 | { 18 | WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(0), 0, 0, 0, 0, L"External Menu Base", 0 }; 19 | RegisterClassEx(&wc); 20 | Window = CreateWindow(wc.lpszClassName, L"External Menu Base", WS_POPUP, 0, 0, 5, 5, 0, 0, wc.hInstance, 0); 21 | 22 | if (!CreateDeviceD3D(Window)) { 23 | CleanupDeviceD3D(); 24 | UnregisterClass(wc.lpszClassName, wc.hInstance); 25 | return 1; 26 | } 27 | 28 | ShowWindow(Window, SW_HIDE); 29 | UpdateWindow(Window); 30 | 31 | ImGui::CreateContext(); 32 | 33 | ImGuiIO& io = ImGui::GetIO(); 34 | io.IniFilename = nullptr; 35 | io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; 36 | 37 | static const ImWchar icons_ranges[] = { 0xf000, 0xf3ff, 0 }; 38 | ImFontConfig icons_config; 39 | 40 | ImFontConfig CustomFont; 41 | CustomFont.FontDataOwnedByAtlas = false; 42 | 43 | 44 | icons_config.MergeMode = true; 45 | icons_config.PixelSnapH = true; 46 | icons_config.OversampleH = 2.5; 47 | icons_config.OversampleV = 2.5; 48 | 49 | io.Fonts->AddFontFromMemoryTTF(const_cast(Custom), sizeof(Custom), 21.f, &CustomFont); 50 | io.Fonts->AddFontFromMemoryCompressedTTF(font_awesome_data, font_awesome_size, 19.0f, &icons_config, icons_ranges); 51 | Consolas = io.Fonts->AddFontFromFileTTF("C:\\Windows\\Fonts\\Consola.ttf", 17); 52 | io.Fonts->AddFontDefault(); 53 | 54 | ImGuiStyle& style = ImGui::GetStyle(); 55 | if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) 56 | { 57 | style.WindowRounding = 0.0f; 58 | style.Colors[ImGuiCol_WindowBg].w = 1.0f; 59 | } 60 | 61 | ImGui_ImplWin32_Init(Window); 62 | ImGui_ImplDX9_Init(g_pd3dDevice); 63 | MSG msg; 64 | ZeroMemory(&msg, sizeof(msg)); 65 | while (msg.message != WM_QUIT) 66 | { 67 | if (PeekMessage(&msg, 0, 0U, 0U, PM_REMOVE)) 68 | { 69 | TranslateMessage(&msg); 70 | DispatchMessage(&msg); 71 | continue; 72 | } 73 | 74 | ImGui_ImplDX9_NewFrame(); 75 | ImGui_ImplWin32_NewFrame(); 76 | ImGui::NewFrame(); 77 | Menu::Theme(); 78 | { 79 | ImGui::Begin("HamMafia.co", 0, ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse | ImGuiWindowFlags_NoResize); 80 | { 81 | Menu::Render(); 82 | } 83 | ImGui::End(); 84 | } 85 | ImGui::EndFrame(); 86 | 87 | g_pd3dDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0); 88 | if (g_pd3dDevice->BeginScene() >= 0) 89 | { 90 | ImGui::Render(); 91 | ImGui_ImplDX9_RenderDrawData(ImGui::GetDrawData()); 92 | g_pd3dDevice->EndScene(); 93 | } 94 | 95 | if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) 96 | { 97 | ImGui::UpdatePlatformWindows(); 98 | ImGui::RenderPlatformWindowsDefault(); 99 | } 100 | 101 | HRESULT result = g_pd3dDevice->Present(0, 0, 0, 0); 102 | if (result == D3DERR_DEVICELOST && g_pd3dDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET) { 103 | ResetDevice(); 104 | } 105 | if (!Enabled) { 106 | msg.message = WM_QUIT; 107 | } 108 | } 109 | 110 | ImGui_ImplDX9_Shutdown(); 111 | ImGui_ImplWin32_Shutdown(); 112 | ImGui::DestroyContext(); 113 | 114 | CleanupDeviceD3D(); 115 | DestroyWindow(Window); 116 | UnregisterClass(wc.lpszClassName, wc.hInstance); 117 | 118 | return 0; 119 | } 120 | 121 | LRESULT CALLBACK WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { 122 | if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) 123 | return true; 124 | 125 | switch (msg) 126 | { 127 | case WM_SIZE: 128 | if (g_pd3dDevice != 0 && wParam != SIZE_MINIMIZED) 129 | { 130 | g_d3dpp.BackBufferWidth = LOWORD(lParam); 131 | g_d3dpp.BackBufferHeight = HIWORD(lParam); 132 | ResetDevice(); 133 | } 134 | return 0; 135 | case WM_SYSCOMMAND: 136 | if ((wParam & 0xfff0) == SC_KEYMENU) // Disable ALT application menu 137 | return 0; 138 | break; 139 | case WM_DESTROY: 140 | PostQuitMessage(0); 141 | return 0; 142 | } 143 | return DefWindowProc(hWnd, msg, wParam, lParam); 144 | } -------------------------------------------------------------------------------- /Menu remake part 2/Loader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | #pragma comment(lib,"d3d9.lib") 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | static bool Enabled = true; 14 | HWND Window = nullptr; 15 | 16 | LPDIRECT3DDEVICE9 g_pd3dDevice; 17 | D3DPRESENT_PARAMETERS g_d3dpp; 18 | LPDIRECT3D9 g_pD3D; 19 | 20 | #define LOADER_NAME "Cheat Loader" 21 | 22 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 23 | LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 24 | 25 | const int WINDOW_WIDTH = 1200; 26 | const int WINDOW_HEIGHT = 800; 27 | 28 | bool CreateDeviceD3D(HWND hWnd) 29 | { 30 | if ((g_pD3D = Direct3DCreate9(D3D_SDK_VERSION)) == NULL) 31 | return false; 32 | ZeroMemory(&g_d3dpp, sizeof(g_d3dpp)); 33 | g_d3dpp.Windowed = TRUE; 34 | g_d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; 35 | g_d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; 36 | g_d3dpp.EnableAutoDepthStencil = TRUE; 37 | g_d3dpp.AutoDepthStencilFormat = D3DFMT_D16; 38 | g_d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_ONE; 39 | if (g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_d3dpp, &g_pd3dDevice) < 0) 40 | return false; 41 | return true; 42 | } 43 | 44 | void CleanupDeviceD3D() 45 | { 46 | if (g_pd3dDevice) { 47 | g_pd3dDevice->Release(); g_pd3dDevice = NULL; 48 | } 49 | if (g_pD3D) { 50 | g_pD3D->Release(); g_pD3D = NULL; 51 | } 52 | } 53 | 54 | void ResetDevice() 55 | { 56 | ImGui_ImplDX9_InvalidateDeviceObjects(); 57 | HRESULT Result = g_pd3dDevice->Reset(&g_d3dpp); 58 | if (Result == D3DERR_INVALIDCALL) 59 | IM_ASSERT(0); 60 | ImGui_ImplDX9_CreateDeviceObjects(); 61 | } -------------------------------------------------------------------------------- /Menu remake part 2/TextEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "imgui.h" 12 | 13 | class TextEditor 14 | { 15 | public: 16 | enum class PaletteIndex 17 | { 18 | Default, 19 | Keyword, 20 | Number, 21 | String, 22 | CharLiteral, 23 | Punctuation, 24 | Preprocessor, 25 | Identifier, 26 | KnownIdentifier, 27 | PreprocIdentifier, 28 | Comment, 29 | MultiLineComment, 30 | Background, 31 | Cursor, 32 | Selection, 33 | ErrorMarker, 34 | Breakpoint, 35 | LineNumber, 36 | CurrentLineFill, 37 | CurrentLineFillInactive, 38 | CurrentLineEdge, 39 | Max 40 | }; 41 | 42 | enum class SelectionMode 43 | { 44 | Normal, 45 | Word, 46 | Line 47 | }; 48 | 49 | struct Breakpoint 50 | { 51 | int mLine; 52 | bool mEnabled; 53 | std::string mCondition; 54 | 55 | Breakpoint() 56 | : mLine(-1) 57 | , mEnabled(false) 58 | {} 59 | }; 60 | 61 | // Represents a character coordinate from the user's point of view, 62 | // i. e. consider an uniform grid (assuming fixed-width font) on the 63 | // screen as it is rendered, and each cell has its own coordinate, starting from 0. 64 | // Tabs are counted as [1..mTabSize] count empty spaces, depending on 65 | // how many space is necessary to reach the next tab stop. 66 | // For example, coordinate (1, 5) represents the character 'B' in a line "\tABC", when mTabSize = 4, 67 | // because it is rendered as " ABC" on the screen. 68 | struct Coordinates 69 | { 70 | int mLine, mColumn; 71 | Coordinates() : mLine(0), mColumn(0) {} 72 | Coordinates(int aLine, int aColumn) : mLine(aLine), mColumn(aColumn) 73 | { 74 | assert(aLine >= 0); 75 | assert(aColumn >= 0); 76 | } 77 | static Coordinates Invalid() { static Coordinates invalid(-1, -1); return invalid; } 78 | 79 | bool operator ==(const Coordinates& o) const 80 | { 81 | return 82 | mLine == o.mLine && 83 | mColumn == o.mColumn; 84 | } 85 | 86 | bool operator !=(const Coordinates& o) const 87 | { 88 | return 89 | mLine != o.mLine || 90 | mColumn != o.mColumn; 91 | } 92 | 93 | bool operator <(const Coordinates& o) const 94 | { 95 | if (mLine != o.mLine) 96 | return mLine < o.mLine; 97 | return mColumn < o.mColumn; 98 | } 99 | 100 | bool operator >(const Coordinates& o) const 101 | { 102 | if (mLine != o.mLine) 103 | return mLine > o.mLine; 104 | return mColumn > o.mColumn; 105 | } 106 | 107 | bool operator <=(const Coordinates& o) const 108 | { 109 | if (mLine != o.mLine) 110 | return mLine < o.mLine; 111 | return mColumn <= o.mColumn; 112 | } 113 | 114 | bool operator >=(const Coordinates& o) const 115 | { 116 | if (mLine != o.mLine) 117 | return mLine > o.mLine; 118 | return mColumn >= o.mColumn; 119 | } 120 | }; 121 | 122 | struct Identifier 123 | { 124 | Coordinates mLocation; 125 | std::string mDeclaration; 126 | }; 127 | 128 | typedef std::string String; 129 | typedef std::unordered_map Identifiers; 130 | typedef std::unordered_set Keywords; 131 | typedef std::map ErrorMarkers; 132 | typedef std::unordered_set Breakpoints; 133 | typedef std::array Palette; 134 | typedef uint8_t Char; 135 | 136 | struct Glyph 137 | { 138 | Char mChar; 139 | PaletteIndex mColorIndex = PaletteIndex::Default; 140 | bool mComment : 1; 141 | bool mMultiLineComment : 1; 142 | bool mPreprocessor : 1; 143 | 144 | Glyph(Char aChar, PaletteIndex aColorIndex) : mChar(aChar), mColorIndex(aColorIndex), 145 | mComment(false), mMultiLineComment(false), mPreprocessor(false) {} 146 | }; 147 | 148 | typedef std::vector Line; 149 | typedef std::vector Lines; 150 | 151 | struct LanguageDefinition 152 | { 153 | typedef std::pair TokenRegexString; 154 | typedef std::vector TokenRegexStrings; 155 | typedef bool(*TokenizeCallback)(const char* in_begin, const char* in_end, const char*& out_begin, const char*& out_end, PaletteIndex& paletteIndex); 156 | 157 | std::string mName; 158 | Keywords mKeywords; 159 | Identifiers mIdentifiers; 160 | Identifiers mPreprocIdentifiers; 161 | std::string mCommentStart, mCommentEnd, mSingleLineComment; 162 | char mPreprocChar; 163 | bool mAutoIndentation; 164 | 165 | TokenizeCallback mTokenize; 166 | 167 | TokenRegexStrings mTokenRegexStrings; 168 | 169 | bool mCaseSensitive; 170 | 171 | LanguageDefinition() 172 | : mPreprocChar('#'), mAutoIndentation(true), mTokenize(nullptr), mCaseSensitive(true) 173 | { 174 | } 175 | 176 | static const LanguageDefinition& CPlusPlus(); 177 | static const LanguageDefinition& HLSL(); 178 | static const LanguageDefinition& GLSL(); 179 | static const LanguageDefinition& C(); 180 | static const LanguageDefinition& SQL(); 181 | static const LanguageDefinition& AngelScript(); 182 | static const LanguageDefinition& Lua(); 183 | }; 184 | 185 | TextEditor(); 186 | ~TextEditor(); 187 | 188 | void SetLanguageDefinition(const LanguageDefinition& aLanguageDef); 189 | const LanguageDefinition& GetLanguageDefinition() const { return mLanguageDefinition; } 190 | 191 | const Palette& GetPalette() const { return mPaletteBase; } 192 | void SetPalette(const Palette& aValue); 193 | 194 | void SetErrorMarkers(const ErrorMarkers& aMarkers) { mErrorMarkers = aMarkers; } 195 | void SetBreakpoints(const Breakpoints& aMarkers) { mBreakpoints = aMarkers; } 196 | 197 | void Render(const char* aTitle, const ImVec2& aSize = ImVec2(), bool aBorder = false); 198 | void SetText(const std::string& aText); 199 | std::string GetText() const; 200 | 201 | void SetTextLines(const std::vector& aLines); 202 | std::vector GetTextLines() const; 203 | 204 | std::string GetSelectedText() const; 205 | std::string GetCurrentLineText()const; 206 | 207 | int GetTotalLines() const { return (int)mLines.size(); } 208 | bool IsOverwrite() const { return mOverwrite; } 209 | 210 | void SetReadOnly(bool aValue); 211 | bool IsReadOnly() const { return mReadOnly; } 212 | bool IsTextChanged() const { return mTextChanged; } 213 | bool IsCursorPositionChanged() const { return mCursorPositionChanged; } 214 | 215 | bool IsColorizerEnabled() const { return mColorizerEnabled; } 216 | void SetColorizerEnable(bool aValue); 217 | 218 | Coordinates GetCursorPosition() const { return GetActualCursorCoordinates(); } 219 | void SetCursorPosition(const Coordinates& aPosition); 220 | 221 | inline void SetHandleMouseInputs(bool aValue) { mHandleMouseInputs = aValue; } 222 | inline bool IsHandleMouseInputsEnabled() const { return mHandleKeyboardInputs; } 223 | 224 | inline void SetHandleKeyboardInputs(bool aValue) { mHandleKeyboardInputs = aValue; } 225 | inline bool IsHandleKeyboardInputsEnabled() const { return mHandleKeyboardInputs; } 226 | 227 | inline void SetImGuiChildIgnored(bool aValue) { mIgnoreImGuiChild = aValue; } 228 | inline bool IsImGuiChildIgnored() const { return mIgnoreImGuiChild; } 229 | 230 | inline void SetShowWhitespaces(bool aValue) { mShowWhitespaces = aValue; } 231 | inline bool IsShowingWhitespaces() const { return mShowWhitespaces; } 232 | 233 | void SetTabSize(int aValue); 234 | inline int GetTabSize() const { return mTabSize; } 235 | 236 | void InsertText(const std::string& aValue); 237 | void InsertText(const char* aValue); 238 | 239 | void MoveUp(int aAmount = 1, bool aSelect = false); 240 | void MoveDown(int aAmount = 1, bool aSelect = false); 241 | void MoveLeft(int aAmount = 1, bool aSelect = false, bool aWordMode = false); 242 | void MoveRight(int aAmount = 1, bool aSelect = false, bool aWordMode = false); 243 | void MoveTop(bool aSelect = false); 244 | void MoveBottom(bool aSelect = false); 245 | void MoveHome(bool aSelect = false); 246 | void MoveEnd(bool aSelect = false); 247 | 248 | void SetSelectionStart(const Coordinates& aPosition); 249 | void SetSelectionEnd(const Coordinates& aPosition); 250 | void SetSelection(const Coordinates& aStart, const Coordinates& aEnd, SelectionMode aMode = SelectionMode::Normal); 251 | void SelectWordUnderCursor(); 252 | void SelectAll(); 253 | bool HasSelection() const; 254 | 255 | void Copy(); 256 | void Cut(); 257 | void Paste(); 258 | void Delete(); 259 | 260 | bool CanUndo() const; 261 | bool CanRedo() const; 262 | void Undo(int aSteps = 1); 263 | void Redo(int aSteps = 1); 264 | 265 | static const Palette& GetDarkPalette(); 266 | static const Palette& GetLightPalette(); 267 | static const Palette& GetRetroBluePalette(); 268 | 269 | private: 270 | typedef std::vector> RegexList; 271 | 272 | struct EditorState 273 | { 274 | Coordinates mSelectionStart; 275 | Coordinates mSelectionEnd; 276 | Coordinates mCursorPosition; 277 | }; 278 | 279 | class UndoRecord 280 | { 281 | public: 282 | UndoRecord() {} 283 | ~UndoRecord() {} 284 | 285 | UndoRecord( 286 | const std::string& aAdded, 287 | const TextEditor::Coordinates aAddedStart, 288 | const TextEditor::Coordinates aAddedEnd, 289 | 290 | const std::string& aRemoved, 291 | const TextEditor::Coordinates aRemovedStart, 292 | const TextEditor::Coordinates aRemovedEnd, 293 | 294 | TextEditor::EditorState& aBefore, 295 | TextEditor::EditorState& aAfter); 296 | 297 | void Undo(TextEditor* aEditor); 298 | void Redo(TextEditor* aEditor); 299 | 300 | std::string mAdded; 301 | Coordinates mAddedStart; 302 | Coordinates mAddedEnd; 303 | 304 | std::string mRemoved; 305 | Coordinates mRemovedStart; 306 | Coordinates mRemovedEnd; 307 | 308 | EditorState mBefore; 309 | EditorState mAfter; 310 | }; 311 | 312 | typedef std::vector UndoBuffer; 313 | 314 | void ProcessInputs(); 315 | void Colorize(int aFromLine = 0, int aCount = -1); 316 | void ColorizeRange(int aFromLine = 0, int aToLine = 0); 317 | void ColorizeInternal(); 318 | float TextDistanceToLineStart(const Coordinates& aFrom) const; 319 | void EnsureCursorVisible(); 320 | int GetPageSize() const; 321 | std::string GetText(const Coordinates& aStart, const Coordinates& aEnd) const; 322 | Coordinates GetActualCursorCoordinates() const; 323 | Coordinates SanitizeCoordinates(const Coordinates& aValue) const; 324 | void Advance(Coordinates& aCoordinates) const; 325 | void DeleteRange(const Coordinates& aStart, const Coordinates& aEnd); 326 | int InsertTextAt(Coordinates& aWhere, const char* aValue); 327 | void AddUndo(UndoRecord& aValue); 328 | Coordinates ScreenPosToCoordinates(const ImVec2& aPosition) const; 329 | Coordinates FindWordStart(const Coordinates& aFrom) const; 330 | Coordinates FindWordEnd(const Coordinates& aFrom) const; 331 | Coordinates FindNextWord(const Coordinates& aFrom) const; 332 | int GetCharacterIndex(const Coordinates& aCoordinates) const; 333 | int GetCharacterColumn(int aLine, int aIndex) const; 334 | int GetLineCharacterCount(int aLine) const; 335 | int GetLineMaxColumn(int aLine) const; 336 | bool IsOnWordBoundary(const Coordinates& aAt) const; 337 | void RemoveLine(int aStart, int aEnd); 338 | void RemoveLine(int aIndex); 339 | Line& InsertLine(int aIndex); 340 | void EnterCharacter(ImWchar aChar, bool aShift); 341 | void Backspace(); 342 | void DeleteSelection(); 343 | std::string GetWordUnderCursor() const; 344 | std::string GetWordAt(const Coordinates& aCoords) const; 345 | ImU32 GetGlyphColor(const Glyph& aGlyph) const; 346 | 347 | void HandleKeyboardInputs(); 348 | void HandleMouseInputs(); 349 | void Render(); 350 | 351 | float mLineSpacing; 352 | Lines mLines; 353 | EditorState mState; 354 | UndoBuffer mUndoBuffer; 355 | int mUndoIndex; 356 | 357 | int mTabSize; 358 | bool mOverwrite; 359 | bool mReadOnly; 360 | bool mWithinRender; 361 | bool mScrollToCursor; 362 | bool mScrollToTop; 363 | bool mTextChanged; 364 | bool mColorizerEnabled; 365 | float mTextStart; // position (in pixels) where a code line starts relative to the left of the TextEditor. 366 | int mLeftMargin; 367 | bool mCursorPositionChanged; 368 | int mColorRangeMin, mColorRangeMax; 369 | SelectionMode mSelectionMode; 370 | bool mHandleKeyboardInputs; 371 | bool mHandleMouseInputs; 372 | bool mIgnoreImGuiChild; 373 | bool mShowWhitespaces; 374 | 375 | Palette mPaletteBase; 376 | Palette mPalette; 377 | LanguageDefinition mLanguageDefinition; 378 | RegexList mRegexList; 379 | 380 | bool mCheckComments; 381 | Breakpoints mBreakpoints; 382 | ErrorMarkers mErrorMarkers; 383 | ImVec2 mCharAdvance; 384 | Coordinates mInteractiveStart, mInteractiveEnd; 385 | std::string mLineBuffer; 386 | uint64_t mStartTime; 387 | 388 | float mLastClick; 389 | }; -------------------------------------------------------------------------------- /Menu remake part 2/functions.cpp: -------------------------------------------------------------------------------- 1 | #include "functions.h" 2 | 3 | void Functions::Inject(std::string game) 4 | { 5 | if (game == "game_name") 6 | { 7 | // Do your injection code :) 8 | } 9 | } 10 | 11 | void Functions::Rainbow() 12 | { 13 | //This function was not made by me (xo1337), i found it off unknown cheats. 14 | float rainbowSpeed = 0.00060; 15 | static float staticHue = 0; 16 | ImDrawList* draw_list = ImGui::GetWindowDrawList(); 17 | ImVec2 panelPos = ImGui::GetWindowPos(); 18 | staticHue -= rainbowSpeed; 19 | if (staticHue < -1.f) staticHue += 1.f; 20 | for (int i = 0; i < 1200; i++) 21 | { 22 | float hue = staticHue + (1.f / (float)1200) * i; 23 | if (hue < 0.f) hue += 1.0f; 24 | ImColor cRainbow = ImColor::HSV(hue, 1.f, 1.f); 25 | draw_list->AddRectFilled(ImVec2(panelPos.x + i, panelPos.y + 2), ImVec2(panelPos.x + i + 1, panelPos.y + 4), cRainbow); 26 | } 27 | } 28 | 29 | void Functions::Line(const char* Id, int width = ImGui::GetContentRegionAvailWidth(), int height = 1) 30 | { 31 | ImGui::BeginChild(Id, ImVec2(width, height), TRUE); 32 | ImGui::EndChild(); 33 | } 34 | 35 | void Functions::LineEx(const char* Id) 36 | { 37 | Functions::Line(Id, ImGui::GetContentRegionAvailWidth(), 1); 38 | } 39 | 40 | void Functions::LineVertical() 41 | { 42 | ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); 43 | } 44 | 45 | void Functions::Helpmarker(const char* Text, ImColor Color) 46 | { 47 | ImGui::TextColored(Color, "(?)"); 48 | if (ImGui::IsItemHovered()) 49 | ImGui::SetTooltip(Text); 50 | } -------------------------------------------------------------------------------- /Menu remake part 2/functions.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | enum GAME_STATUS 8 | { 9 | UNDETECTED, 10 | UPDATING, 11 | DETECTED, 12 | COMING_SOON 13 | }; 14 | 15 | namespace Functions 16 | { 17 | void Rainbow(); 18 | void Helpmarker(const char* Text, ImColor Color); 19 | void Line(const char* Id, int width, int height); 20 | void LineEx(const char* Id); 21 | void LineVertical(); 22 | 23 | void Inject(std::string game); 24 | } 25 | 26 | -------------------------------------------------------------------------------- /Menu remake part 2/imgui/imconfig.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // COMPILE-TIME OPTIONS FOR DEAR IMGUI 3 | // Runtime options (clipboard callbacks, enabling various features, etc.) can generally be set via the ImGuiIO structure. 4 | // You can use ImGui::SetAllocatorFunctions() before calling ImGui::CreateContext() to rewire memory allocation functions. 5 | //----------------------------------------------------------------------------- 6 | // A) You may edit imconfig.h (and not overwrite it when updating Dear ImGui, or maintain a patch/rebased branch with your modifications to it) 7 | // B) or '#define IMGUI_USER_CONFIG "my_imgui_config.h"' in your project and then add directives in your own file without touching this template. 8 | //----------------------------------------------------------------------------- 9 | // You need to make sure that configuration settings are defined consistently _everywhere_ Dear ImGui is used, which include the imgui*.cpp 10 | // files but also _any_ of your code that uses Dear ImGui. This is because some compile-time options have an affect on data structures. 11 | // Defining those options in imconfig.h will ensure every compilation unit gets to see the same data structure layouts. 12 | // Call IMGUI_CHECKVERSION() from your .cpp files to verify that the data structures your files are using are matching the ones imgui.cpp is using. 13 | //----------------------------------------------------------------------------- 14 | 15 | #pragma once 16 | 17 | //---- Define assertion handler. Defaults to calling assert(). 18 | // If your macro uses multiple statements, make sure is enclosed in a 'do { .. } while (0)' block so it can be used as a single statement. 19 | //#define IM_ASSERT(_EXPR) MyAssert(_EXPR) 20 | //#define IM_ASSERT(_EXPR) ((void)(_EXPR)) // Disable asserts 21 | 22 | //---- Define attributes of all API symbols declarations, e.g. for DLL under Windows 23 | // Using dear imgui via a shared library is not recommended, because of function call overhead and because we don't guarantee backward nor forward ABI compatibility. 24 | //#define IMGUI_API __declspec( dllexport ) 25 | //#define IMGUI_API __declspec( dllimport ) 26 | 27 | //---- Don't define obsolete functions/enums/behaviors. Consider enabling from time to time after updating to avoid using soon-to-be obsolete function/names. 28 | //#define IMGUI_DISABLE_OBSOLETE_FUNCTIONS 29 | 30 | //---- Disable all of Dear ImGui or don't implement standard windows. 31 | // It is very strongly recommended to NOT disable the demo windows during development. Please read comments in imgui_demo.cpp. 32 | //#define IMGUI_DISABLE // Disable everything: all headers and source files will be empty. 33 | //#define IMGUI_DISABLE_DEMO_WINDOWS // Disable demo windows: ShowDemoWindow()/ShowStyleEditor() will be empty. Not recommended. 34 | //#define IMGUI_DISABLE_METRICS_WINDOW // Disable debug/metrics window: ShowMetricsWindow() will be empty. 35 | 36 | //---- Don't implement some functions to reduce linkage requirements. 37 | //#define IMGUI_DISABLE_WIN32_DEFAULT_CLIPBOARD_FUNCTIONS // [Win32] Don't implement default clipboard handler. Won't use and link with OpenClipboard/GetClipboardData/CloseClipboard etc. 38 | //#define IMGUI_DISABLE_WIN32_DEFAULT_IME_FUNCTIONS // [Win32] Don't implement default IME handler. Won't use and link with ImmGetContext/ImmSetCompositionWindow. 39 | //#define IMGUI_DISABLE_WIN32_FUNCTIONS // [Win32] Won't use and link with any Win32 function (clipboard, ime). 40 | //#define IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS // [OSX] Implement default OSX clipboard handler (need to link with '-framework ApplicationServices', this is why this is not the default). 41 | //#define IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS // Don't implement ImFormatString/ImFormatStringV so you can implement them yourself (e.g. if you don't want to link with vsnprintf) 42 | //#define IMGUI_DISABLE_DEFAULT_MATH_FUNCTIONS // Don't implement ImFabs/ImSqrt/ImPow/ImFmod/ImCos/ImSin/ImAcos/ImAtan2 so you can implement them yourself. 43 | //#define IMGUI_DISABLE_DEFAULT_FILE_FUNCTIONS // Don't implement ImFileOpen/ImFileClose/ImFileRead/ImFileWrite so you can implement them yourself if you don't want to link with fopen/fclose/fread/fwrite. This will also disable the LogToTTY() function. 44 | //#define IMGUI_DISABLE_DEFAULT_ALLOCATORS // Don't implement default allocators calling malloc()/free() to avoid linking with them. You will need to call ImGui::SetAllocatorFunctions(). 45 | 46 | //---- Include imgui_user.h at the end of imgui.h as a convenience 47 | //#define IMGUI_INCLUDE_IMGUI_USER_H 48 | 49 | //---- Pack colors to BGRA8 instead of RGBA8 (to avoid converting from one to another) 50 | //#define IMGUI_USE_BGRA_PACKED_COLOR 51 | 52 | //---- Use 32-bit for ImWchar (default is 16-bit) to support unicode planes 1-16. (e.g. point beyond 0xFFFF like emoticons, dingbats, symbols, shapes, ancient languages, etc...) 53 | //#define IMGUI_USE_WCHAR32 54 | 55 | //---- Avoid multiple STB libraries implementations, or redefine path/filenames to prioritize another version 56 | // By default the embedded implementations are declared static and not available outside of imgui cpp files. 57 | //#define IMGUI_STB_TRUETYPE_FILENAME "my_folder/stb_truetype.h" 58 | //#define IMGUI_STB_RECT_PACK_FILENAME "my_folder/stb_rect_pack.h" 59 | //#define IMGUI_DISABLE_STB_TRUETYPE_IMPLEMENTATION 60 | //#define IMGUI_DISABLE_STB_RECT_PACK_IMPLEMENTATION 61 | 62 | //---- Unless IMGUI_DISABLE_DEFAULT_FORMAT_FUNCTIONS is defined, use the much faster STB sprintf library implementation of vsnprintf instead of the one from the default C library. 63 | // Note that stb_sprintf.h is meant to be provided by the user and available in the include path at compile time. Also, the compatibility checks of the arguments and formats done by clang and GCC will be disabled in order to support the extra formats provided by STB sprintf. 64 | // #define IMGUI_USE_STB_SPRINTF 65 | 66 | //---- Define constructor and implicit cast operators to convert back<>forth between your math types and ImVec2/ImVec4. 67 | // This will be inlined as part of ImVec2 and ImVec4 class declarations. 68 | /* 69 | #define IM_VEC2_CLASS_EXTRA \ 70 | ImVec2(const MyVec2& f) { x = f.x; y = f.y; } \ 71 | operator MyVec2() const { return MyVec2(x,y); } 72 | 73 | #define IM_VEC4_CLASS_EXTRA \ 74 | ImVec4(const MyVec4& f) { x = f.x; y = f.y; z = f.z; w = f.w; } \ 75 | operator MyVec4() const { return MyVec4(x,y,z,w); } 76 | */ 77 | 78 | //---- Use 32-bit vertex indices (default is 16-bit) is one way to allow large meshes with more than 64K vertices. 79 | // Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices). 80 | // Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer. 81 | // Read about ImGuiBackendFlags_RendererHasVtxOffset for details. 82 | //#define ImDrawIdx unsigned int 83 | 84 | //---- Override ImDrawCallback signature (will need to modify renderer backends accordingly) 85 | //struct ImDrawList; 86 | //struct ImDrawCmd; 87 | //typedef void (*MyImDrawCallback)(const ImDrawList* draw_list, const ImDrawCmd* cmd, void* my_renderer_user_data); 88 | //#define ImDrawCallback MyImDrawCallback 89 | 90 | //---- Debug Tools: Macro to break in Debugger 91 | // (use 'Metrics->Tools->Item Picker' to pick widgets with the mouse and break into them for easy debugging.) 92 | //#define IM_DEBUG_BREAK IM_ASSERT(0) 93 | //#define IM_DEBUG_BREAK __debugbreak() 94 | 95 | //---- Debug Tools: Have the Item Picker break in the ItemAdd() function instead of ItemHoverable(), 96 | // (which comes earlier in the code, will catch a few extra items, allow picking items other than Hovered one.) 97 | // This adds a small runtime cost which is why it is not enabled by default. 98 | //#define IMGUI_DEBUG_TOOL_ITEM_PICKER_EX 99 | 100 | //---- Debug Tools: Enable slower asserts 101 | //#define IMGUI_DEBUG_PARANOID 102 | 103 | //---- Tip: You can add extra functions within the ImGui:: namespace, here or in your own headers files. 104 | /* 105 | namespace ImGui 106 | { 107 | void MyFunction(const char* name, const MyMatrix44& v); 108 | } 109 | */ 110 | -------------------------------------------------------------------------------- /Menu remake part 2/imgui/imgui_impl_dx9.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 7 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 8 | 9 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | // CHANGELOG 14 | // (minor and older changes stripped away, please see git history for details) 15 | // 2020-XX-XX: Platform: Added support for multiple windows via the ImGuiPlatformIO interface. 16 | // 2019-05-29: DirectX9: Added support for large mesh (64K+ vertices), enable ImGuiBackendFlags_RendererHasVtxOffset flag. 17 | // 2019-04-30: DirectX9: Added support for special ImDrawCallback_ResetRenderState callback to reset render state. 18 | // 2019-03-29: Misc: Fixed erroneous assert in ImGui_ImplDX9_InvalidateDeviceObjects(). 19 | // 2019-01-16: Misc: Disabled fog before drawing UI's. Fixes issue #2288. 20 | // 2018-11-30: Misc: Setting up io.BackendRendererName so it can be displayed in the About Window. 21 | // 2018-06-08: Misc: Extracted imgui_impl_dx9.cpp/.h away from the old combined DX9+Win32 example. 22 | // 2018-06-08: DirectX9: Use draw_data->DisplayPos and draw_data->DisplaySize to setup projection matrix and clipping rectangle. 23 | // 2018-05-07: Render: Saving/restoring Transform because they don't seem to be included in the StateBlock. Setting shading mode to Gouraud. 24 | // 2018-02-16: Misc: Obsoleted the io.RenderDrawListsFn callback and exposed ImGui_ImplDX9_RenderDrawData() in the .h file so you can call it yourself. 25 | // 2018-02-06: Misc: Removed call to ImGui::Shutdown() which is not available from 1.60 WIP, user needs to call CreateContext/DestroyContext themselves. 26 | 27 | #include "imgui.h" 28 | #include "imgui_impl_dx9.h" 29 | 30 | // DirectX 31 | #include 32 | #define DIRECTINPUT_VERSION 0x0800 33 | #include 34 | 35 | // DirectX data 36 | static LPDIRECT3DDEVICE9 g_pd3dDevice = NULL; 37 | static LPDIRECT3DVERTEXBUFFER9 g_pVB = NULL; 38 | static LPDIRECT3DINDEXBUFFER9 g_pIB = NULL; 39 | static LPDIRECT3DTEXTURE9 g_FontTexture = NULL; 40 | static int g_VertexBufferSize = 5000, g_IndexBufferSize = 10000; 41 | 42 | struct CUSTOMVERTEX 43 | { 44 | float pos[3]; 45 | D3DCOLOR col; 46 | float uv[2]; 47 | }; 48 | #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) 49 | 50 | // Forward Declarations 51 | static void ImGui_ImplDX9_InitPlatformInterface(); 52 | static void ImGui_ImplDX9_ShutdownPlatformInterface(); 53 | static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows(); 54 | static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows(); 55 | 56 | static void ImGui_ImplDX9_SetupRenderState(ImDrawData* draw_data) 57 | { 58 | // Setup viewport 59 | D3DVIEWPORT9 vp; 60 | vp.X = vp.Y = 0; 61 | vp.Width = (DWORD)draw_data->DisplaySize.x; 62 | vp.Height = (DWORD)draw_data->DisplaySize.y; 63 | vp.MinZ = 0.0f; 64 | vp.MaxZ = 1.0f; 65 | g_pd3dDevice->SetViewport(&vp); 66 | 67 | // Setup render state: fixed-pipeline, alpha-blending, no face culling, no depth testing, shade mode (for gradient) 68 | g_pd3dDevice->SetPixelShader(NULL); 69 | g_pd3dDevice->SetVertexShader(NULL); 70 | g_pd3dDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE); 71 | g_pd3dDevice->SetRenderState(D3DRS_LIGHTING, FALSE); 72 | g_pd3dDevice->SetRenderState(D3DRS_ZENABLE, FALSE); 73 | g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE); 74 | g_pd3dDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); 75 | g_pd3dDevice->SetRenderState(D3DRS_BLENDOP, D3DBLENDOP_ADD); 76 | g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA); 77 | g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA); 78 | g_pd3dDevice->SetRenderState(D3DRS_SCISSORTESTENABLE, TRUE); 79 | g_pd3dDevice->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_GOURAUD); 80 | g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, FALSE); 81 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE); 82 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); 83 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE); 84 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE); 85 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); 86 | g_pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); 87 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); 88 | g_pd3dDevice->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); 89 | 90 | // Setup orthographic projection matrix 91 | // Our visible imgui space lies from draw_data->DisplayPos (top left) to draw_data->DisplayPos+data_data->DisplaySize (bottom right). DisplayPos is (0,0) for single viewport apps. 92 | // Being agnostic of whether or can be used, we aren't relying on D3DXMatrixIdentity()/D3DXMatrixOrthoOffCenterLH() or DirectX::XMMatrixIdentity()/DirectX::XMMatrixOrthographicOffCenterLH() 93 | { 94 | float L = draw_data->DisplayPos.x + 0.5f; 95 | float R = draw_data->DisplayPos.x + draw_data->DisplaySize.x + 0.5f; 96 | float T = draw_data->DisplayPos.y + 0.5f; 97 | float B = draw_data->DisplayPos.y + draw_data->DisplaySize.y + 0.5f; 98 | D3DMATRIX mat_identity = { { { 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f } } }; 99 | D3DMATRIX mat_projection = 100 | { { { 101 | 2.0f/(R-L), 0.0f, 0.0f, 0.0f, 102 | 0.0f, 2.0f/(T-B), 0.0f, 0.0f, 103 | 0.0f, 0.0f, 0.5f, 0.0f, 104 | (L+R)/(L-R), (T+B)/(B-T), 0.5f, 1.0f 105 | } } }; 106 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &mat_identity); 107 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &mat_identity); 108 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &mat_projection); 109 | } 110 | } 111 | 112 | // Render function. 113 | void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data) 114 | { 115 | // Avoid rendering when minimized 116 | if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) 117 | return; 118 | 119 | // Create and grow buffers if needed 120 | if (!g_pVB || g_VertexBufferSize < draw_data->TotalVtxCount) 121 | { 122 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 123 | g_VertexBufferSize = draw_data->TotalVtxCount + 5000; 124 | if (g_pd3dDevice->CreateVertexBuffer(g_VertexBufferSize * sizeof(CUSTOMVERTEX), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_DEFAULT, &g_pVB, NULL) < 0) 125 | return; 126 | } 127 | if (!g_pIB || g_IndexBufferSize < draw_data->TotalIdxCount) 128 | { 129 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 130 | g_IndexBufferSize = draw_data->TotalIdxCount + 10000; 131 | if (g_pd3dDevice->CreateIndexBuffer(g_IndexBufferSize * sizeof(ImDrawIdx), D3DUSAGE_DYNAMIC | D3DUSAGE_WRITEONLY, sizeof(ImDrawIdx) == 2 ? D3DFMT_INDEX16 : D3DFMT_INDEX32, D3DPOOL_DEFAULT, &g_pIB, NULL) < 0) 132 | return; 133 | } 134 | 135 | // Backup the DX9 state 136 | IDirect3DStateBlock9* d3d9_state_block = NULL; 137 | if (g_pd3dDevice->CreateStateBlock(D3DSBT_ALL, &d3d9_state_block) < 0) 138 | return; 139 | 140 | // Backup the DX9 transform (DX9 documentation suggests that it is included in the StateBlock but it doesn't appear to) 141 | D3DMATRIX last_world, last_view, last_projection; 142 | g_pd3dDevice->GetTransform(D3DTS_WORLD, &last_world); 143 | g_pd3dDevice->GetTransform(D3DTS_VIEW, &last_view); 144 | g_pd3dDevice->GetTransform(D3DTS_PROJECTION, &last_projection); 145 | 146 | // Copy and convert all vertices into a single contiguous buffer, convert colors to DX9 default format. 147 | // FIXME-OPT: This is a waste of resource, the ideal is to use imconfig.h and 148 | // 1) to avoid repacking colors: #define IMGUI_USE_BGRA_PACKED_COLOR 149 | // 2) to avoid repacking vertices: #define IMGUI_OVERRIDE_DRAWVERT_STRUCT_LAYOUT struct ImDrawVert { ImVec2 pos; float z; ImU32 col; ImVec2 uv; } 150 | CUSTOMVERTEX* vtx_dst; 151 | ImDrawIdx* idx_dst; 152 | if (g_pVB->Lock(0, (UINT)(draw_data->TotalVtxCount * sizeof(CUSTOMVERTEX)), (void**)&vtx_dst, D3DLOCK_DISCARD) < 0) 153 | return; 154 | if (g_pIB->Lock(0, (UINT)(draw_data->TotalIdxCount * sizeof(ImDrawIdx)), (void**)&idx_dst, D3DLOCK_DISCARD) < 0) 155 | return; 156 | for (int n = 0; n < draw_data->CmdListsCount; n++) 157 | { 158 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 159 | const ImDrawVert* vtx_src = cmd_list->VtxBuffer.Data; 160 | for (int i = 0; i < cmd_list->VtxBuffer.Size; i++) 161 | { 162 | vtx_dst->pos[0] = vtx_src->pos.x; 163 | vtx_dst->pos[1] = vtx_src->pos.y; 164 | vtx_dst->pos[2] = 0.0f; 165 | vtx_dst->col = (vtx_src->col & 0xFF00FF00) | ((vtx_src->col & 0xFF0000) >> 16) | ((vtx_src->col & 0xFF) << 16); // RGBA --> ARGB for DirectX9 166 | vtx_dst->uv[0] = vtx_src->uv.x; 167 | vtx_dst->uv[1] = vtx_src->uv.y; 168 | vtx_dst++; 169 | vtx_src++; 170 | } 171 | memcpy(idx_dst, cmd_list->IdxBuffer.Data, cmd_list->IdxBuffer.Size * sizeof(ImDrawIdx)); 172 | idx_dst += cmd_list->IdxBuffer.Size; 173 | } 174 | g_pVB->Unlock(); 175 | g_pIB->Unlock(); 176 | g_pd3dDevice->SetStreamSource(0, g_pVB, 0, sizeof(CUSTOMVERTEX)); 177 | g_pd3dDevice->SetIndices(g_pIB); 178 | g_pd3dDevice->SetFVF(D3DFVF_CUSTOMVERTEX); 179 | 180 | // Setup desired DX state 181 | ImGui_ImplDX9_SetupRenderState(draw_data); 182 | 183 | // Render command lists 184 | // (Because we merged all buffers into a single one, we maintain our own offset into them) 185 | int global_vtx_offset = 0; 186 | int global_idx_offset = 0; 187 | ImVec2 clip_off = draw_data->DisplayPos; 188 | for (int n = 0; n < draw_data->CmdListsCount; n++) 189 | { 190 | const ImDrawList* cmd_list = draw_data->CmdLists[n]; 191 | for (int cmd_i = 0; cmd_i < cmd_list->CmdBuffer.Size; cmd_i++) 192 | { 193 | const ImDrawCmd* pcmd = &cmd_list->CmdBuffer[cmd_i]; 194 | if (pcmd->UserCallback != NULL) 195 | { 196 | // User callback, registered via ImDrawList::AddCallback() 197 | // (ImDrawCallback_ResetRenderState is a special callback value used by the user to request the renderer to reset render state.) 198 | if (pcmd->UserCallback == ImDrawCallback_ResetRenderState) 199 | ImGui_ImplDX9_SetupRenderState(draw_data); 200 | else 201 | pcmd->UserCallback(cmd_list, pcmd); 202 | } 203 | else 204 | { 205 | const RECT r = { (LONG)(pcmd->ClipRect.x - clip_off.x), (LONG)(pcmd->ClipRect.y - clip_off.y), (LONG)(pcmd->ClipRect.z - clip_off.x), (LONG)(pcmd->ClipRect.w - clip_off.y) }; 206 | const LPDIRECT3DTEXTURE9 texture = (LPDIRECT3DTEXTURE9)pcmd->TextureId; 207 | g_pd3dDevice->SetTexture(0, texture); 208 | g_pd3dDevice->SetScissorRect(&r); 209 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, pcmd->VtxOffset + global_vtx_offset, 0, (UINT)cmd_list->VtxBuffer.Size, pcmd->IdxOffset + global_idx_offset, pcmd->ElemCount / 3); 210 | } 211 | } 212 | global_idx_offset += cmd_list->IdxBuffer.Size; 213 | global_vtx_offset += cmd_list->VtxBuffer.Size; 214 | } 215 | 216 | // When using multi-viewports, it appears that there's an odd logic in DirectX9 which prevent subsequent windows 217 | // from rendering until the first window submits at least one draw call, even once. That's our workaround. (see #2560) 218 | if (global_vtx_offset == 0) 219 | g_pd3dDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 0, 0, 0, 0); 220 | 221 | // Restore the DX9 transform 222 | g_pd3dDevice->SetTransform(D3DTS_WORLD, &last_world); 223 | g_pd3dDevice->SetTransform(D3DTS_VIEW, &last_view); 224 | g_pd3dDevice->SetTransform(D3DTS_PROJECTION, &last_projection); 225 | 226 | // Restore the DX9 state 227 | d3d9_state_block->Apply(); 228 | d3d9_state_block->Release(); 229 | } 230 | 231 | bool ImGui_ImplDX9_Init(IDirect3DDevice9* device) 232 | { 233 | // Setup backend capabilities flags 234 | ImGuiIO& io = ImGui::GetIO(); 235 | io.BackendRendererName = "imgui_impl_dx9"; 236 | io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes. 237 | io.BackendFlags |= ImGuiBackendFlags_RendererHasViewports; // We can create multi-viewports on the Renderer side (optional) 238 | 239 | g_pd3dDevice = device; 240 | g_pd3dDevice->AddRef(); 241 | 242 | if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) 243 | ImGui_ImplDX9_InitPlatformInterface(); 244 | 245 | return true; 246 | } 247 | 248 | void ImGui_ImplDX9_Shutdown() 249 | { 250 | ImGui_ImplDX9_ShutdownPlatformInterface(); 251 | ImGui_ImplDX9_InvalidateDeviceObjects(); 252 | if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = NULL; } 253 | } 254 | 255 | static bool ImGui_ImplDX9_CreateFontsTexture() 256 | { 257 | // Build texture atlas 258 | ImGuiIO& io = ImGui::GetIO(); 259 | unsigned char* pixels; 260 | int width, height, bytes_per_pixel; 261 | io.Fonts->GetTexDataAsRGBA32(&pixels, &width, &height, &bytes_per_pixel); 262 | 263 | // Upload texture to graphics system 264 | g_FontTexture = NULL; 265 | if (g_pd3dDevice->CreateTexture(width, height, 1, D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, D3DPOOL_DEFAULT, &g_FontTexture, NULL) < 0) 266 | return false; 267 | D3DLOCKED_RECT tex_locked_rect; 268 | if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) 269 | return false; 270 | for (int y = 0; y < height; y++) 271 | memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel)); 272 | g_FontTexture->UnlockRect(0); 273 | 274 | // Store our identifier 275 | io.Fonts->TexID = (ImTextureID)g_FontTexture; 276 | 277 | return true; 278 | } 279 | 280 | bool ImGui_ImplDX9_CreateDeviceObjects() 281 | { 282 | if (!g_pd3dDevice) 283 | return false; 284 | if (!ImGui_ImplDX9_CreateFontsTexture()) 285 | return false; 286 | ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows(); 287 | return true; 288 | } 289 | 290 | void ImGui_ImplDX9_InvalidateDeviceObjects() 291 | { 292 | if (!g_pd3dDevice) 293 | return; 294 | if (g_pVB) { g_pVB->Release(); g_pVB = NULL; } 295 | if (g_pIB) { g_pIB->Release(); g_pIB = NULL; } 296 | if (g_FontTexture) { g_FontTexture->Release(); g_FontTexture = NULL; ImGui::GetIO().Fonts->TexID = NULL; } // We copied g_pFontTextureView to io.Fonts->TexID so let's clear that as well. 297 | ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows(); 298 | } 299 | 300 | void ImGui_ImplDX9_NewFrame() 301 | { 302 | if (!g_FontTexture) 303 | ImGui_ImplDX9_CreateDeviceObjects(); 304 | } 305 | 306 | //-------------------------------------------------------------------------------------------------------- 307 | // MULTI-VIEWPORT / PLATFORM INTERFACE SUPPORT 308 | // This is an _advanced_ and _optional_ feature, allowing the backend to create and handle multiple viewports simultaneously. 309 | // If you are new to dear imgui or creating a new binding for dear imgui, it is recommended that you completely ignore this section first.. 310 | //-------------------------------------------------------------------------------------------------------- 311 | 312 | // Helper structure we store in the void* RenderUserData field of each ImGuiViewport to easily retrieve our backend data. 313 | struct ImGuiViewportDataDx9 314 | { 315 | IDirect3DSwapChain9* SwapChain; 316 | D3DPRESENT_PARAMETERS d3dpp; 317 | 318 | ImGuiViewportDataDx9() { SwapChain = NULL; ZeroMemory(&d3dpp, sizeof(D3DPRESENT_PARAMETERS)); } 319 | ~ImGuiViewportDataDx9() { IM_ASSERT(SwapChain == NULL); } 320 | }; 321 | 322 | static void ImGui_ImplDX9_CreateWindow(ImGuiViewport* viewport) 323 | { 324 | ImGuiViewportDataDx9* data = IM_NEW(ImGuiViewportDataDx9)(); 325 | viewport->RendererUserData = data; 326 | 327 | // PlatformHandleRaw should always be a HWND, whereas PlatformHandle might be a higher-level handle (e.g. GLFWWindow*, SDL_Window*). 328 | // Some backends will leave PlatformHandleRaw NULL, in which case we assume PlatformHandle will contain the HWND. 329 | HWND hwnd = viewport->PlatformHandleRaw ? (HWND)viewport->PlatformHandleRaw : (HWND)viewport->PlatformHandle; 330 | IM_ASSERT(hwnd != 0); 331 | 332 | ZeroMemory(&data->d3dpp, sizeof(D3DPRESENT_PARAMETERS)); 333 | data->d3dpp.Windowed = TRUE; 334 | data->d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; 335 | data->d3dpp.BackBufferWidth = (UINT)viewport->Size.x; 336 | data->d3dpp.BackBufferHeight = (UINT)viewport->Size.y; 337 | data->d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; 338 | data->d3dpp.hDeviceWindow = hwnd; 339 | data->d3dpp.EnableAutoDepthStencil = FALSE; 340 | data->d3dpp.AutoDepthStencilFormat = D3DFMT_D16; 341 | data->d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; // Present without vsync 342 | 343 | HRESULT hr = g_pd3dDevice->CreateAdditionalSwapChain(&data->d3dpp, &data->SwapChain); IM_UNUSED(hr); 344 | IM_ASSERT(hr == D3D_OK); 345 | IM_ASSERT(data->SwapChain != NULL); 346 | } 347 | 348 | static void ImGui_ImplDX9_DestroyWindow(ImGuiViewport* viewport) 349 | { 350 | // The main viewport (owned by the application) will always have RendererUserData == NULL since we didn't create the data for it. 351 | if (ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData) 352 | { 353 | if (data->SwapChain) 354 | data->SwapChain->Release(); 355 | data->SwapChain = NULL; 356 | ZeroMemory(&data->d3dpp, sizeof(D3DPRESENT_PARAMETERS)); 357 | IM_DELETE(data); 358 | } 359 | viewport->RendererUserData = NULL; 360 | } 361 | 362 | static void ImGui_ImplDX9_SetWindowSize(ImGuiViewport* viewport, ImVec2 size) 363 | { 364 | ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData; 365 | if (data->SwapChain) 366 | { 367 | data->SwapChain->Release(); 368 | data->SwapChain = NULL; 369 | data->d3dpp.BackBufferWidth = (UINT)size.x; 370 | data->d3dpp.BackBufferHeight = (UINT)size.y; 371 | HRESULT hr = g_pd3dDevice->CreateAdditionalSwapChain(&data->d3dpp, &data->SwapChain); IM_UNUSED(hr); 372 | IM_ASSERT(hr == D3D_OK); 373 | } 374 | } 375 | 376 | static void ImGui_ImplDX9_RenderWindow(ImGuiViewport* viewport, void*) 377 | { 378 | ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData; 379 | ImVec4 clear_color = ImVec4(0.0f, 0.0f, 0.0f, 1.0f); 380 | 381 | LPDIRECT3DSURFACE9 render_target = NULL; 382 | LPDIRECT3DSURFACE9 last_render_target = NULL; 383 | LPDIRECT3DSURFACE9 last_depth_stencil = NULL; 384 | data->SwapChain->GetBackBuffer(0, D3DBACKBUFFER_TYPE_MONO, &render_target); 385 | g_pd3dDevice->GetRenderTarget(0, &last_render_target); 386 | g_pd3dDevice->GetDepthStencilSurface(&last_depth_stencil); 387 | g_pd3dDevice->SetRenderTarget(0, render_target); 388 | g_pd3dDevice->SetDepthStencilSurface(NULL); 389 | 390 | if (!(viewport->Flags & ImGuiViewportFlags_NoRendererClear)) 391 | { 392 | D3DCOLOR clear_col_dx = D3DCOLOR_RGBA((int)(clear_color.x*255.0f), (int)(clear_color.y*255.0f), (int)(clear_color.z*255.0f), (int)(clear_color.w*255.0f)); 393 | g_pd3dDevice->Clear(0, NULL, D3DCLEAR_TARGET, clear_col_dx, 1.0f, 0); 394 | } 395 | 396 | ImGui_ImplDX9_RenderDrawData(viewport->DrawData); 397 | 398 | // Restore render target 399 | g_pd3dDevice->SetRenderTarget(0, last_render_target); 400 | g_pd3dDevice->SetDepthStencilSurface(last_depth_stencil); 401 | render_target->Release(); 402 | last_render_target->Release(); 403 | if (last_depth_stencil) last_depth_stencil->Release(); 404 | } 405 | 406 | static void ImGui_ImplDX9_SwapBuffers(ImGuiViewport* viewport, void*) 407 | { 408 | ImGuiViewportDataDx9* data = (ImGuiViewportDataDx9*)viewport->RendererUserData; 409 | HRESULT hr = data->SwapChain->Present(NULL, NULL, data->d3dpp.hDeviceWindow, NULL, NULL); 410 | // Let main application handle D3DERR_DEVICELOST by resetting the device. 411 | IM_ASSERT(hr == D3D_OK || hr == D3DERR_DEVICELOST); 412 | } 413 | 414 | static void ImGui_ImplDX9_InitPlatformInterface() 415 | { 416 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); 417 | platform_io.Renderer_CreateWindow = ImGui_ImplDX9_CreateWindow; 418 | platform_io.Renderer_DestroyWindow = ImGui_ImplDX9_DestroyWindow; 419 | platform_io.Renderer_SetWindowSize = ImGui_ImplDX9_SetWindowSize; 420 | platform_io.Renderer_RenderWindow = ImGui_ImplDX9_RenderWindow; 421 | platform_io.Renderer_SwapBuffers = ImGui_ImplDX9_SwapBuffers; 422 | } 423 | 424 | static void ImGui_ImplDX9_ShutdownPlatformInterface() 425 | { 426 | ImGui::DestroyPlatformWindows(); 427 | } 428 | 429 | static void ImGui_ImplDX9_CreateDeviceObjectsForPlatformWindows() 430 | { 431 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); 432 | for (int i = 1; i < platform_io.Viewports.Size; i++) 433 | if (!platform_io.Viewports[i]->RendererUserData) 434 | ImGui_ImplDX9_CreateWindow(platform_io.Viewports[i]); 435 | } 436 | 437 | static void ImGui_ImplDX9_InvalidateDeviceObjectsForPlatformWindows() 438 | { 439 | ImGuiPlatformIO& platform_io = ImGui::GetPlatformIO(); 440 | for (int i = 1; i < platform_io.Viewports.Size; i++) 441 | if (platform_io.Viewports[i]->RendererUserData) 442 | ImGui_ImplDX9_DestroyWindow(platform_io.Viewports[i]); 443 | } 444 | -------------------------------------------------------------------------------- /Menu remake part 2/imgui/imgui_impl_dx9.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer Backend for DirectX9 2 | // This needs to be used along with a Platform Backend (e.g. Win32) 3 | 4 | // Implemented features: 5 | // [X] Renderer: User texture binding. Use 'LPDIRECT3DTEXTURE9' as ImTextureID. Read the FAQ about ImTextureID! 6 | // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 7 | // [X] Renderer: Support for large meshes (64k+ vertices) with 16-bit indices. 8 | 9 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 10 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 11 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 12 | 13 | #pragma once 14 | #include "imgui.h" // IMGUI_IMPL_API 15 | 16 | struct IDirect3DDevice9; 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplDX9_Init(IDirect3DDevice9* device); 19 | IMGUI_IMPL_API void ImGui_ImplDX9_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplDX9_NewFrame(); 21 | IMGUI_IMPL_API void ImGui_ImplDX9_RenderDrawData(ImDrawData* draw_data); 22 | 23 | // Use if you want to reset your rendering device without losing Dear ImGui state. 24 | IMGUI_IMPL_API bool ImGui_ImplDX9_CreateDeviceObjects(); 25 | IMGUI_IMPL_API void ImGui_ImplDX9_InvalidateDeviceObjects(); 26 | -------------------------------------------------------------------------------- /Menu remake part 2/imgui/imgui_impl_win32.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Backend for Windows (standard windows API for 32 and 64 bits applications) 2 | // This needs to be used along with a Renderer (e.g. DirectX11, OpenGL3, Vulkan..) 3 | 4 | // Implemented features: 5 | // [X] Platform: Clipboard support (for Win32 this is actually part of core dear imgui) 6 | // [X] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. 7 | // [X] Platform: Keyboard arrays indexed using VK_* Virtual Key Codes, e.g. ImGui::IsKeyPressed(VK_SPACE). 8 | // [X] Platform: Gamepad support. Enabled with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 9 | // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See examples/ folder for examples of using this. 12 | // If you are new to Dear ImGui, read documentation from the docs/ folder + read the top of imgui.cpp. 13 | // Read online: https://github.com/ocornut/imgui/tree/master/docs 14 | 15 | #pragma once 16 | #include "imgui.h" // IMGUI_IMPL_API 17 | 18 | IMGUI_IMPL_API bool ImGui_ImplWin32_Init(void* hwnd); 19 | IMGUI_IMPL_API void ImGui_ImplWin32_Shutdown(); 20 | IMGUI_IMPL_API void ImGui_ImplWin32_NewFrame(); 21 | 22 | // Configuration 23 | // - Disable gamepad support or linking with xinput.lib 24 | //#define IMGUI_IMPL_WIN32_DISABLE_GAMEPAD 25 | //#define IMGUI_IMPL_WIN32_DISABLE_LINKING_XINPUT 26 | 27 | // Win32 message handler your application need to call. 28 | // - Intentionally commented out in a '#if 0' block to avoid dragging dependencies on from this helper. 29 | // - You should COPY the line below into your .cpp code to forward declare the function and then you can call it. 30 | #if 0 31 | extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); 32 | #endif 33 | 34 | // DPI-related helpers (optional) 35 | // - Use to enable DPI awareness without having to create an application manifest. 36 | // - Your own app may already do this via a manifest or explicit calls. This is mostly useful for our examples/ apps. 37 | // - In theory we could call simple functions from Windows SDK such as SetProcessDPIAware(), SetProcessDpiAwareness(), etc. 38 | // but most of the functions provided by Microsoft require Windows 8.1/10+ SDK at compile time and Windows 8/10+ at runtime, 39 | // neither we want to require the user to have. So we dynamically select and load those functions to avoid dependencies. 40 | IMGUI_IMPL_API void ImGui_ImplWin32_EnableDpiAwareness(); 41 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForHwnd(void* hwnd); // HWND hwnd 42 | IMGUI_IMPL_API float ImGui_ImplWin32_GetDpiScaleForMonitor(void* monitor); // HMONITOR monitor 43 | -------------------------------------------------------------------------------- /Menu remake part 2/imgui/imstb_rectpack.h: -------------------------------------------------------------------------------- 1 | // [DEAR IMGUI] 2 | // This is a slightly modified version of stb_rect_pack.h 1.00. 3 | // Those changes would need to be pushed into nothings/stb: 4 | // - Added STBRP__CDECL 5 | // Grep for [DEAR IMGUI] to find the changes. 6 | 7 | // stb_rect_pack.h - v1.00 - public domain - rectangle packing 8 | // Sean Barrett 2014 9 | // 10 | // Useful for e.g. packing rectangular textures into an atlas. 11 | // Does not do rotation. 12 | // 13 | // Not necessarily the awesomest packing method, but better than 14 | // the totally naive one in stb_truetype (which is primarily what 15 | // this is meant to replace). 16 | // 17 | // Has only had a few tests run, may have issues. 18 | // 19 | // More docs to come. 20 | // 21 | // No memory allocations; uses qsort() and assert() from stdlib. 22 | // Can override those by defining STBRP_SORT and STBRP_ASSERT. 23 | // 24 | // This library currently uses the Skyline Bottom-Left algorithm. 25 | // 26 | // Please note: better rectangle packers are welcome! Please 27 | // implement them to the same API, but with a different init 28 | // function. 29 | // 30 | // Credits 31 | // 32 | // Library 33 | // Sean Barrett 34 | // Minor features 35 | // Martins Mozeiko 36 | // github:IntellectualKitty 37 | // 38 | // Bugfixes / warning fixes 39 | // Jeremy Jaussaud 40 | // Fabian Giesen 41 | // 42 | // Version history: 43 | // 44 | // 1.00 (2019-02-25) avoid small space waste; gracefully fail too-wide rectangles 45 | // 0.99 (2019-02-07) warning fixes 46 | // 0.11 (2017-03-03) return packing success/fail result 47 | // 0.10 (2016-10-25) remove cast-away-const to avoid warnings 48 | // 0.09 (2016-08-27) fix compiler warnings 49 | // 0.08 (2015-09-13) really fix bug with empty rects (w=0 or h=0) 50 | // 0.07 (2015-09-13) fix bug with empty rects (w=0 or h=0) 51 | // 0.06 (2015-04-15) added STBRP_SORT to allow replacing qsort 52 | // 0.05: added STBRP_ASSERT to allow replacing assert 53 | // 0.04: fixed minor bug in STBRP_LARGE_RECTS support 54 | // 0.01: initial release 55 | // 56 | // LICENSE 57 | // 58 | // See end of file for license information. 59 | 60 | ////////////////////////////////////////////////////////////////////////////// 61 | // 62 | // INCLUDE SECTION 63 | // 64 | 65 | #ifndef STB_INCLUDE_STB_RECT_PACK_H 66 | #define STB_INCLUDE_STB_RECT_PACK_H 67 | 68 | #define STB_RECT_PACK_VERSION 1 69 | 70 | #ifdef STBRP_STATIC 71 | #define STBRP_DEF static 72 | #else 73 | #define STBRP_DEF extern 74 | #endif 75 | 76 | #ifdef __cplusplus 77 | extern "C" { 78 | #endif 79 | 80 | typedef struct stbrp_context stbrp_context; 81 | typedef struct stbrp_node stbrp_node; 82 | typedef struct stbrp_rect stbrp_rect; 83 | 84 | #ifdef STBRP_LARGE_RECTS 85 | typedef int stbrp_coord; 86 | #else 87 | typedef unsigned short stbrp_coord; 88 | #endif 89 | 90 | STBRP_DEF int stbrp_pack_rects (stbrp_context *context, stbrp_rect *rects, int num_rects); 91 | // Assign packed locations to rectangles. The rectangles are of type 92 | // 'stbrp_rect' defined below, stored in the array 'rects', and there 93 | // are 'num_rects' many of them. 94 | // 95 | // Rectangles which are successfully packed have the 'was_packed' flag 96 | // set to a non-zero value and 'x' and 'y' store the minimum location 97 | // on each axis (i.e. bottom-left in cartesian coordinates, top-left 98 | // if you imagine y increasing downwards). Rectangles which do not fit 99 | // have the 'was_packed' flag set to 0. 100 | // 101 | // You should not try to access the 'rects' array from another thread 102 | // while this function is running, as the function temporarily reorders 103 | // the array while it executes. 104 | // 105 | // To pack into another rectangle, you need to call stbrp_init_target 106 | // again. To continue packing into the same rectangle, you can call 107 | // this function again. Calling this multiple times with multiple rect 108 | // arrays will probably produce worse packing results than calling it 109 | // a single time with the full rectangle array, but the option is 110 | // available. 111 | // 112 | // The function returns 1 if all of the rectangles were successfully 113 | // packed and 0 otherwise. 114 | 115 | struct stbrp_rect 116 | { 117 | // reserved for your use: 118 | int id; 119 | 120 | // input: 121 | stbrp_coord w, h; 122 | 123 | // output: 124 | stbrp_coord x, y; 125 | int was_packed; // non-zero if valid packing 126 | 127 | }; // 16 bytes, nominally 128 | 129 | 130 | STBRP_DEF void stbrp_init_target (stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes); 131 | // Initialize a rectangle packer to: 132 | // pack a rectangle that is 'width' by 'height' in dimensions 133 | // using temporary storage provided by the array 'nodes', which is 'num_nodes' long 134 | // 135 | // You must call this function every time you start packing into a new target. 136 | // 137 | // There is no "shutdown" function. The 'nodes' memory must stay valid for 138 | // the following stbrp_pack_rects() call (or calls), but can be freed after 139 | // the call (or calls) finish. 140 | // 141 | // Note: to guarantee best results, either: 142 | // 1. make sure 'num_nodes' >= 'width' 143 | // or 2. call stbrp_allow_out_of_mem() defined below with 'allow_out_of_mem = 1' 144 | // 145 | // If you don't do either of the above things, widths will be quantized to multiples 146 | // of small integers to guarantee the algorithm doesn't run out of temporary storage. 147 | // 148 | // If you do #2, then the non-quantized algorithm will be used, but the algorithm 149 | // may run out of temporary storage and be unable to pack some rectangles. 150 | 151 | STBRP_DEF void stbrp_setup_allow_out_of_mem (stbrp_context *context, int allow_out_of_mem); 152 | // Optionally call this function after init but before doing any packing to 153 | // change the handling of the out-of-temp-memory scenario, described above. 154 | // If you call init again, this will be reset to the default (false). 155 | 156 | 157 | STBRP_DEF void stbrp_setup_heuristic (stbrp_context *context, int heuristic); 158 | // Optionally select which packing heuristic the library should use. Different 159 | // heuristics will produce better/worse results for different data sets. 160 | // If you call init again, this will be reset to the default. 161 | 162 | enum 163 | { 164 | STBRP_HEURISTIC_Skyline_default=0, 165 | STBRP_HEURISTIC_Skyline_BL_sortHeight = STBRP_HEURISTIC_Skyline_default, 166 | STBRP_HEURISTIC_Skyline_BF_sortHeight 167 | }; 168 | 169 | 170 | ////////////////////////////////////////////////////////////////////////////// 171 | // 172 | // the details of the following structures don't matter to you, but they must 173 | // be visible so you can handle the memory allocations for them 174 | 175 | struct stbrp_node 176 | { 177 | stbrp_coord x,y; 178 | stbrp_node *next; 179 | }; 180 | 181 | struct stbrp_context 182 | { 183 | int width; 184 | int height; 185 | int align; 186 | int init_mode; 187 | int heuristic; 188 | int num_nodes; 189 | stbrp_node *active_head; 190 | stbrp_node *free_head; 191 | stbrp_node extra[2]; // we allocate two extra nodes so optimal user-node-count is 'width' not 'width+2' 192 | }; 193 | 194 | #ifdef __cplusplus 195 | } 196 | #endif 197 | 198 | #endif 199 | 200 | ////////////////////////////////////////////////////////////////////////////// 201 | // 202 | // IMPLEMENTATION SECTION 203 | // 204 | 205 | #ifdef STB_RECT_PACK_IMPLEMENTATION 206 | #ifndef STBRP_SORT 207 | #include 208 | #define STBRP_SORT qsort 209 | #endif 210 | 211 | #ifndef STBRP_ASSERT 212 | #include 213 | #define STBRP_ASSERT assert 214 | #endif 215 | 216 | // [DEAR IMGUI] Added STBRP__CDECL 217 | #ifdef _MSC_VER 218 | #define STBRP__NOTUSED(v) (void)(v) 219 | #define STBRP__CDECL __cdecl 220 | #else 221 | #define STBRP__NOTUSED(v) (void)sizeof(v) 222 | #define STBRP__CDECL 223 | #endif 224 | 225 | enum 226 | { 227 | STBRP__INIT_skyline = 1 228 | }; 229 | 230 | STBRP_DEF void stbrp_setup_heuristic(stbrp_context *context, int heuristic) 231 | { 232 | switch (context->init_mode) { 233 | case STBRP__INIT_skyline: 234 | STBRP_ASSERT(heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight || heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight); 235 | context->heuristic = heuristic; 236 | break; 237 | default: 238 | STBRP_ASSERT(0); 239 | } 240 | } 241 | 242 | STBRP_DEF void stbrp_setup_allow_out_of_mem(stbrp_context *context, int allow_out_of_mem) 243 | { 244 | if (allow_out_of_mem) 245 | // if it's ok to run out of memory, then don't bother aligning them; 246 | // this gives better packing, but may fail due to OOM (even though 247 | // the rectangles easily fit). @TODO a smarter approach would be to only 248 | // quantize once we've hit OOM, then we could get rid of this parameter. 249 | context->align = 1; 250 | else { 251 | // if it's not ok to run out of memory, then quantize the widths 252 | // so that num_nodes is always enough nodes. 253 | // 254 | // I.e. num_nodes * align >= width 255 | // align >= width / num_nodes 256 | // align = ceil(width/num_nodes) 257 | 258 | context->align = (context->width + context->num_nodes-1) / context->num_nodes; 259 | } 260 | } 261 | 262 | STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, stbrp_node *nodes, int num_nodes) 263 | { 264 | int i; 265 | #ifndef STBRP_LARGE_RECTS 266 | STBRP_ASSERT(width <= 0xffff && height <= 0xffff); 267 | #endif 268 | 269 | for (i=0; i < num_nodes-1; ++i) 270 | nodes[i].next = &nodes[i+1]; 271 | nodes[i].next = NULL; 272 | context->init_mode = STBRP__INIT_skyline; 273 | context->heuristic = STBRP_HEURISTIC_Skyline_default; 274 | context->free_head = &nodes[0]; 275 | context->active_head = &context->extra[0]; 276 | context->width = width; 277 | context->height = height; 278 | context->num_nodes = num_nodes; 279 | stbrp_setup_allow_out_of_mem(context, 0); 280 | 281 | // node 0 is the full width, node 1 is the sentinel (lets us not store width explicitly) 282 | context->extra[0].x = 0; 283 | context->extra[0].y = 0; 284 | context->extra[0].next = &context->extra[1]; 285 | context->extra[1].x = (stbrp_coord) width; 286 | #ifdef STBRP_LARGE_RECTS 287 | context->extra[1].y = (1<<30); 288 | #else 289 | context->extra[1].y = 65535; 290 | #endif 291 | context->extra[1].next = NULL; 292 | } 293 | 294 | // find minimum y position if it starts at x1 295 | static int stbrp__skyline_find_min_y(stbrp_context *c, stbrp_node *first, int x0, int width, int *pwaste) 296 | { 297 | stbrp_node *node = first; 298 | int x1 = x0 + width; 299 | int min_y, visited_width, waste_area; 300 | 301 | STBRP__NOTUSED(c); 302 | 303 | STBRP_ASSERT(first->x <= x0); 304 | 305 | #if 0 306 | // skip in case we're past the node 307 | while (node->next->x <= x0) 308 | ++node; 309 | #else 310 | STBRP_ASSERT(node->next->x > x0); // we ended up handling this in the caller for efficiency 311 | #endif 312 | 313 | STBRP_ASSERT(node->x <= x0); 314 | 315 | min_y = 0; 316 | waste_area = 0; 317 | visited_width = 0; 318 | while (node->x < x1) { 319 | if (node->y > min_y) { 320 | // raise min_y higher. 321 | // we've accounted for all waste up to min_y, 322 | // but we'll now add more waste for everything we've visted 323 | waste_area += visited_width * (node->y - min_y); 324 | min_y = node->y; 325 | // the first time through, visited_width might be reduced 326 | if (node->x < x0) 327 | visited_width += node->next->x - x0; 328 | else 329 | visited_width += node->next->x - node->x; 330 | } else { 331 | // add waste area 332 | int under_width = node->next->x - node->x; 333 | if (under_width + visited_width > width) 334 | under_width = width - visited_width; 335 | waste_area += under_width * (min_y - node->y); 336 | visited_width += under_width; 337 | } 338 | node = node->next; 339 | } 340 | 341 | *pwaste = waste_area; 342 | return min_y; 343 | } 344 | 345 | typedef struct 346 | { 347 | int x,y; 348 | stbrp_node **prev_link; 349 | } stbrp__findresult; 350 | 351 | static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int width, int height) 352 | { 353 | int best_waste = (1<<30), best_x, best_y = (1 << 30); 354 | stbrp__findresult fr; 355 | stbrp_node **prev, *node, *tail, **best = NULL; 356 | 357 | // align to multiple of c->align 358 | width = (width + c->align - 1); 359 | width -= width % c->align; 360 | STBRP_ASSERT(width % c->align == 0); 361 | 362 | // if it can't possibly fit, bail immediately 363 | if (width > c->width || height > c->height) { 364 | fr.prev_link = NULL; 365 | fr.x = fr.y = 0; 366 | return fr; 367 | } 368 | 369 | node = c->active_head; 370 | prev = &c->active_head; 371 | while (node->x + width <= c->width) { 372 | int y,waste; 373 | y = stbrp__skyline_find_min_y(c, node, node->x, width, &waste); 374 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BL_sortHeight) { // actually just want to test BL 375 | // bottom left 376 | if (y < best_y) { 377 | best_y = y; 378 | best = prev; 379 | } 380 | } else { 381 | // best-fit 382 | if (y + height <= c->height) { 383 | // can only use it if it first vertically 384 | if (y < best_y || (y == best_y && waste < best_waste)) { 385 | best_y = y; 386 | best_waste = waste; 387 | best = prev; 388 | } 389 | } 390 | } 391 | prev = &node->next; 392 | node = node->next; 393 | } 394 | 395 | best_x = (best == NULL) ? 0 : (*best)->x; 396 | 397 | // if doing best-fit (BF), we also have to try aligning right edge to each node position 398 | // 399 | // e.g, if fitting 400 | // 401 | // ____________________ 402 | // |____________________| 403 | // 404 | // into 405 | // 406 | // | | 407 | // | ____________| 408 | // |____________| 409 | // 410 | // then right-aligned reduces waste, but bottom-left BL is always chooses left-aligned 411 | // 412 | // This makes BF take about 2x the time 413 | 414 | if (c->heuristic == STBRP_HEURISTIC_Skyline_BF_sortHeight) { 415 | tail = c->active_head; 416 | node = c->active_head; 417 | prev = &c->active_head; 418 | // find first node that's admissible 419 | while (tail->x < width) 420 | tail = tail->next; 421 | while (tail) { 422 | int xpos = tail->x - width; 423 | int y,waste; 424 | STBRP_ASSERT(xpos >= 0); 425 | // find the left position that matches this 426 | while (node->next->x <= xpos) { 427 | prev = &node->next; 428 | node = node->next; 429 | } 430 | STBRP_ASSERT(node->next->x > xpos && node->x <= xpos); 431 | y = stbrp__skyline_find_min_y(c, node, xpos, width, &waste); 432 | if (y + height <= c->height) { 433 | if (y <= best_y) { 434 | if (y < best_y || waste < best_waste || (waste==best_waste && xpos < best_x)) { 435 | best_x = xpos; 436 | STBRP_ASSERT(y <= best_y); 437 | best_y = y; 438 | best_waste = waste; 439 | best = prev; 440 | } 441 | } 442 | } 443 | tail = tail->next; 444 | } 445 | } 446 | 447 | fr.prev_link = best; 448 | fr.x = best_x; 449 | fr.y = best_y; 450 | return fr; 451 | } 452 | 453 | static stbrp__findresult stbrp__skyline_pack_rectangle(stbrp_context *context, int width, int height) 454 | { 455 | // find best position according to heuristic 456 | stbrp__findresult res = stbrp__skyline_find_best_pos(context, width, height); 457 | stbrp_node *node, *cur; 458 | 459 | // bail if: 460 | // 1. it failed 461 | // 2. the best node doesn't fit (we don't always check this) 462 | // 3. we're out of memory 463 | if (res.prev_link == NULL || res.y + height > context->height || context->free_head == NULL) { 464 | res.prev_link = NULL; 465 | return res; 466 | } 467 | 468 | // on success, create new node 469 | node = context->free_head; 470 | node->x = (stbrp_coord) res.x; 471 | node->y = (stbrp_coord) (res.y + height); 472 | 473 | context->free_head = node->next; 474 | 475 | // insert the new node into the right starting point, and 476 | // let 'cur' point to the remaining nodes needing to be 477 | // stiched back in 478 | 479 | cur = *res.prev_link; 480 | if (cur->x < res.x) { 481 | // preserve the existing one, so start testing with the next one 482 | stbrp_node *next = cur->next; 483 | cur->next = node; 484 | cur = next; 485 | } else { 486 | *res.prev_link = node; 487 | } 488 | 489 | // from here, traverse cur and free the nodes, until we get to one 490 | // that shouldn't be freed 491 | while (cur->next && cur->next->x <= res.x + width) { 492 | stbrp_node *next = cur->next; 493 | // move the current node to the free list 494 | cur->next = context->free_head; 495 | context->free_head = cur; 496 | cur = next; 497 | } 498 | 499 | // stitch the list back in 500 | node->next = cur; 501 | 502 | if (cur->x < res.x + width) 503 | cur->x = (stbrp_coord) (res.x + width); 504 | 505 | #ifdef _DEBUG 506 | cur = context->active_head; 507 | while (cur->x < context->width) { 508 | STBRP_ASSERT(cur->x < cur->next->x); 509 | cur = cur->next; 510 | } 511 | STBRP_ASSERT(cur->next == NULL); 512 | 513 | { 514 | int count=0; 515 | cur = context->active_head; 516 | while (cur) { 517 | cur = cur->next; 518 | ++count; 519 | } 520 | cur = context->free_head; 521 | while (cur) { 522 | cur = cur->next; 523 | ++count; 524 | } 525 | STBRP_ASSERT(count == context->num_nodes+2); 526 | } 527 | #endif 528 | 529 | return res; 530 | } 531 | 532 | // [DEAR IMGUI] Added STBRP__CDECL 533 | static int STBRP__CDECL rect_height_compare(const void *a, const void *b) 534 | { 535 | const stbrp_rect *p = (const stbrp_rect *) a; 536 | const stbrp_rect *q = (const stbrp_rect *) b; 537 | if (p->h > q->h) 538 | return -1; 539 | if (p->h < q->h) 540 | return 1; 541 | return (p->w > q->w) ? -1 : (p->w < q->w); 542 | } 543 | 544 | // [DEAR IMGUI] Added STBRP__CDECL 545 | static int STBRP__CDECL rect_original_order(const void *a, const void *b) 546 | { 547 | const stbrp_rect *p = (const stbrp_rect *) a; 548 | const stbrp_rect *q = (const stbrp_rect *) b; 549 | return (p->was_packed < q->was_packed) ? -1 : (p->was_packed > q->was_packed); 550 | } 551 | 552 | #ifdef STBRP_LARGE_RECTS 553 | #define STBRP__MAXVAL 0xffffffff 554 | #else 555 | #define STBRP__MAXVAL 0xffff 556 | #endif 557 | 558 | STBRP_DEF int stbrp_pack_rects(stbrp_context *context, stbrp_rect *rects, int num_rects) 559 | { 560 | int i, all_rects_packed = 1; 561 | 562 | // we use the 'was_packed' field internally to allow sorting/unsorting 563 | for (i=0; i < num_rects; ++i) { 564 | rects[i].was_packed = i; 565 | } 566 | 567 | // sort according to heuristic 568 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_height_compare); 569 | 570 | for (i=0; i < num_rects; ++i) { 571 | if (rects[i].w == 0 || rects[i].h == 0) { 572 | rects[i].x = rects[i].y = 0; // empty rect needs no space 573 | } else { 574 | stbrp__findresult fr = stbrp__skyline_pack_rectangle(context, rects[i].w, rects[i].h); 575 | if (fr.prev_link) { 576 | rects[i].x = (stbrp_coord) fr.x; 577 | rects[i].y = (stbrp_coord) fr.y; 578 | } else { 579 | rects[i].x = rects[i].y = STBRP__MAXVAL; 580 | } 581 | } 582 | } 583 | 584 | // unsort 585 | STBRP_SORT(rects, num_rects, sizeof(rects[0]), rect_original_order); 586 | 587 | // set was_packed flags and all_rects_packed status 588 | for (i=0; i < num_rects; ++i) { 589 | rects[i].was_packed = !(rects[i].x == STBRP__MAXVAL && rects[i].y == STBRP__MAXVAL); 590 | if (!rects[i].was_packed) 591 | all_rects_packed = 0; 592 | } 593 | 594 | // return the all_rects_packed status 595 | return all_rects_packed; 596 | } 597 | #endif 598 | 599 | /* 600 | ------------------------------------------------------------------------------ 601 | This software is available under 2 licenses -- choose whichever you prefer. 602 | ------------------------------------------------------------------------------ 603 | ALTERNATIVE A - MIT License 604 | Copyright (c) 2017 Sean Barrett 605 | Permission is hereby granted, free of charge, to any person obtaining a copy of 606 | this software and associated documentation files (the "Software"), to deal in 607 | the Software without restriction, including without limitation the rights to 608 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 609 | of the Software, and to permit persons to whom the Software is furnished to do 610 | so, subject to the following conditions: 611 | The above copyright notice and this permission notice shall be included in all 612 | copies or substantial portions of the Software. 613 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 614 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 615 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 616 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 617 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 618 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 619 | SOFTWARE. 620 | ------------------------------------------------------------------------------ 621 | ALTERNATIVE B - Public Domain (www.unlicense.org) 622 | This is free and unencumbered software released into the public domain. 623 | Anyone is free to copy, modify, publish, use, compile, sell, or distribute this 624 | software, either in source code form or as a compiled binary, for any purpose, 625 | commercial or non-commercial, and by any means. 626 | In jurisdictions that recognize copyright laws, the author or authors of this 627 | software dedicate any and all copyright interest in the software to the public 628 | domain. We make this dedication for the benefit of the public at large and to 629 | the detriment of our heirs and successors. We intend this dedication to be an 630 | overt act of relinquishment in perpetuity of all present and future rights to 631 | this software under copyright law. 632 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 633 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 634 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 635 | AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 636 | ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 637 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 638 | ------------------------------------------------------------------------------ 639 | */ 640 | -------------------------------------------------------------------------------- /Menu remake part 2/imguipp.cpp: -------------------------------------------------------------------------------- 1 | #include "imguipp.h" 2 | namespace imguipp 3 | { 4 | 5 | float getx() 6 | { 7 | return ImGui::GetContentRegionAvail().x; 8 | } 9 | 10 | float gety() 11 | { 12 | return ImGui::GetContentRegionAvail().y; 13 | } 14 | 15 | void button(const char* label, int& currentTab, int newTab, ImVec2 size) 16 | { 17 | if (ImGui::Button(label, size)) 18 | currentTab = newTab; 19 | } 20 | 21 | void line(int newId) 22 | { 23 | std::string id = ("imguipp_line_" + std::to_string(newId)); 24 | ImGui::PushStyleColor(ImGuiCol_ChildBg, IM_COL32(0, 0, 0, 0)); 25 | { 26 | ImGui::BeginChild(id.c_str(), ImVec2(ImGui::GetContentRegionAvail().x, 1), false); 27 | ImGui::Separator(); 28 | ImGui::EndChild(); 29 | } 30 | ImGui::PopStyleColor(); 31 | } 32 | 33 | void linevertical() 34 | { 35 | ImGui::SameLine(); 36 | ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical); 37 | ImGui::SameLine(); 38 | } 39 | 40 | void center_text(const char* text, int lineId , bool separator) 41 | { 42 | if (text == nullptr) 43 | return; 44 | 45 | ImGui::Spacing(); 46 | ImGui::SameLine((ImGui::GetContentRegionAvail().x / 2) - (ImGui::CalcTextSize(text).x / 2)); 47 | ImGui::Text(text); 48 | ImGui::Spacing(); 49 | 50 | if (true == separator) 51 | line(lineId); 52 | } 53 | 54 | void center_text_ex(const char* text, float width_available, int lineId, bool separator) 55 | { 56 | if (text == nullptr) 57 | return; 58 | 59 | ImGui::Spacing(); 60 | ImGui::SameLine((width_available / 2) - (ImGui::CalcTextSize(text).x / 2)); 61 | ImGui::Text(text); 62 | ImGui::Spacing(); 63 | 64 | if (true == separator) 65 | line(lineId); 66 | } 67 | 68 | namespace other 69 | { 70 | float get_window_size_x() 71 | { 72 | return ImGui::GetWindowSize().x; 73 | } 74 | 75 | float get_window_size_y() 76 | { 77 | return ImGui::GetWindowSize().y; 78 | } 79 | 80 | ImVec2 get_window_size() 81 | { 82 | return ImGui::GetWindowSize(); 83 | } 84 | 85 | char* get_window_name() 86 | { 87 | return ImGui::GetCurrentWindow()->Name; 88 | } 89 | 90 | ImDrawList* get_drawlist() 91 | { 92 | return ImGui::GetCurrentWindow()->DrawList; 93 | } 94 | } 95 | 96 | ImVec4 to_vec4(float r, float g, float b, float a) 97 | { 98 | return ImVec4(r / 255.0, g / 255.0, b / 255.0, a / 255.0); 99 | } 100 | } -------------------------------------------------------------------------------- /Menu remake part 2/imguipp.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef IMGUIPP_H 3 | #include 4 | #include 5 | #include 6 | 7 | namespace imguipp 8 | { 9 | 10 | 11 | float getx(); 12 | float gety(); 13 | 14 | void button(const char* label, int& currentTab, int newTab, ImVec2 size = ImVec2()); 15 | 16 | void line(int newId); 17 | void linevertical(); 18 | 19 | void center_text(const char* text, int lineId, bool separator); 20 | void center_text_ex(const char* text, float width_available, int lineId, bool separator); 21 | 22 | namespace other 23 | { 24 | float get_window_size_x(); 25 | float get_window_size_y(); 26 | 27 | ImVec2 get_window_size(); 28 | char* get_window_name(); 29 | ImDrawList* get_drawlist(); 30 | } 31 | 32 | ImVec4 to_vec4(float r, float g, float b, float a); 33 | 34 | } 35 | #define IMGUIPP_H 36 | #endif -------------------------------------------------------------------------------- /Menu remake part 2/menu.cpp: -------------------------------------------------------------------------------- 1 | #include "menu.h" 2 | #include "settings.h" 3 | #include "functions.h" 4 | #include "imguipp.h" 5 | #include "icons.h" 6 | #include "TextEditor.h" 7 | 8 | extern ImFont* Consolas; 9 | void Menu::Render() 10 | { 11 | ImGui::Columns(2); 12 | ImGui::SetColumnOffset(1, 230); 13 | 14 | { 15 | //Left side 16 | 17 | static ImVec4 active = imguipp::to_vec4(41, 40, 41, 255); 18 | static ImVec4 inactive = imguipp::to_vec4(31, 30, 31, 255); 19 | 20 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 1 ? active : inactive); 21 | if (ImGui::Button(ICON_FA_CODE " Executor", ImVec2(230 - 15, 41))) 22 | Settings::Tab = 1; 23 | 24 | ImGui::Spacing(); 25 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 2 ? active : inactive); 26 | if (ImGui::Button(ICON_FA_DOWNLOAD " Dumper", ImVec2(230 - 15, 41))) 27 | Settings::Tab = 2; 28 | 29 | ImGui::Spacing(); 30 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 3 ? active : inactive); 31 | if (ImGui::Button(ICON_FA_BUG " Blocker", ImVec2(230 - 15, 41))) 32 | Settings::Tab = 3; 33 | 34 | ImGui::Spacing(); 35 | ImGui::PushStyleColor(ImGuiCol_Button, Settings::Tab == 4 ? active : inactive); 36 | if (ImGui::Button(ICON_FA_BOOK " Menus", ImVec2(230 - 15, 41))) 37 | Settings::Tab = 4; 38 | 39 | ImGui::PopStyleColor(4); 40 | 41 | ImGui::SetCursorPosY(ImGui::GetWindowHeight() - 30); 42 | imguipp::center_text_ex("DeCuttMutt2", 230, 1, false); 43 | } 44 | 45 | ImGui::NextColumn(); 46 | 47 | //Right side 48 | { 49 | 50 | // Executor tab 51 | if (Settings::Tab == 1) 52 | { 53 | static TextEditor editor; 54 | 55 | editor.SetShowWhitespaces(false); 56 | editor.SetReadOnly(false); 57 | editor.SetPalette(TextEditor::GetDarkPalette()); 58 | editor.SetLanguageDefinition(TextEditor::LanguageDefinition::Lua()); 59 | 60 | if (ImGui::Button(ICON_FA_FILE" Execute from file", ImVec2(200, 35))) {} 61 | 62 | ImGui::Spacing(); 63 | ImGui::PushStyleVar(ImGuiStyleVar_ScrollbarRounding, 0); 64 | ImGui::PushFont(Consolas); 65 | editor.Render("##EditorWindow", ImVec2(imguipp::getx(), 300)); 66 | ImGui::PopFont(); 67 | ImGui::PopStyleVar(); 68 | ImGui::Spacing(); 69 | ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(7, 7)); 70 | if (ImGui::BeginCombo("##CheatList", "_cfx_internal")) 71 | { 72 | ImGui::EndCombo(); 73 | } 74 | ImGui::PopStyleVar(); 75 | ImGui::SameLine(); 76 | if (ImGui::Button(ICON_FA_CHECK" Execute", ImVec2(115, 34))) {} 77 | ImGui::SameLine(); 78 | if (ImGui::Button(ICON_FA_SQUARE" Stop", ImVec2(imguipp::getx(), 34))) {} 79 | } 80 | 81 | // Dumper Tab 82 | else if (Settings::Tab == 2) 83 | { 84 | static ImGuiTextFilter filter; 85 | static std::vector resources = 86 | { 87 | "_cfx_internal", 88 | "mysql-async", 89 | "essentialmode", 90 | "async", 91 | "es_extended" 92 | }; 93 | 94 | filter.Draw(ICON_FA_SEARCH" Search", 240); 95 | ImGui::PushStyleColor(ImGuiCol_FrameBg, IM_COL32(0, 0, 0, 0)); 96 | if (ImGui::ListBoxHeader("##ResourcesList", ImVec2(imguipp::getx(), imguipp::gety() - 35))) 97 | { 98 | for (const auto& resource : resources) 99 | { 100 | if (filter.PassFilter(resource.c_str())) 101 | { 102 | if (ImGui::TreeNode(resource.c_str())) 103 | ImGui::TreePop(); 104 | } 105 | } 106 | ImGui::ListBoxFooter(); 107 | } 108 | ImGui::PopStyleColor(); 109 | if (ImGui::Button(ICON_FA_FOLDER_OPEN" Save to folder", ImVec2(205, 34))) {} 110 | } 111 | } 112 | } 113 | 114 | void Menu::Theme() 115 | { 116 | ImGuiStyle* style = &ImGui::GetStyle(); 117 | 118 | style->WindowBorderSize = 0; 119 | style->WindowTitleAlign = ImVec2(0.5, 0.5); 120 | style->WindowMinSize = ImVec2(900, 430); 121 | 122 | style->FramePadding = ImVec2(8, 6); 123 | 124 | style->Colors[ImGuiCol_TitleBg] = ImColor(255, 101, 53, 255); 125 | style->Colors[ImGuiCol_TitleBgActive] = ImColor(255, 101, 53, 255); 126 | style->Colors[ImGuiCol_TitleBgCollapsed] = ImColor(0, 0, 0, 130); 127 | 128 | style->Colors[ImGuiCol_Button] = ImColor(31, 30, 31, 255); 129 | style->Colors[ImGuiCol_ButtonActive] = ImColor(41, 40, 41, 255); 130 | style->Colors[ImGuiCol_ButtonHovered] = ImColor(41, 40, 41, 255); 131 | 132 | style->Colors[ImGuiCol_Separator] = ImColor(70, 70, 70, 255); 133 | style->Colors[ImGuiCol_SeparatorActive] = ImColor(76, 76, 76, 255); 134 | style->Colors[ImGuiCol_SeparatorHovered] = ImColor(76, 76, 76, 255); 135 | 136 | style->Colors[ImGuiCol_FrameBg] = ImColor(37, 36, 37, 255); 137 | style->Colors[ImGuiCol_FrameBgActive] = ImColor(37, 36, 37, 255); 138 | style->Colors[ImGuiCol_FrameBgHovered] = ImColor(37, 36, 37, 255); 139 | 140 | style->Colors[ImGuiCol_Header] = ImColor(0, 0, 0, 0); 141 | style->Colors[ImGuiCol_HeaderActive] = ImColor(0, 0, 0, 0); 142 | style->Colors[ImGuiCol_HeaderHovered] = ImColor(46, 46, 46, 255); 143 | } -------------------------------------------------------------------------------- /Menu remake part 2/menu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace Menu 5 | { 6 | void Theme(); 7 | void Render(); 8 | } -------------------------------------------------------------------------------- /Menu remake part 2/settings.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace Settings 6 | { 7 | static int Tab = 0; 8 | } --------------------------------------------------------------------------------