From 77889e747e99744f495474d62f6d473011f27fbc Mon Sep 17 00:00:00 2001 From: Fujiwara <83638372+Bloodysharp@users.noreply.github.com> Date: Sat, 9 Nov 2024 02:03:00 -0500 Subject: [PATCH] Add files via upload --- .../example_win32_directx11.vcxproj | 196 ++++++++ .../example_win32_directx11.vcxproj.filters | 93 ++++ .../example_win32_directx11.vcxproj.user | 6 + imgui_features/imgui.ini | 100 +++++ imgui_features/main.cpp | 421 ++++++++++++++++++ imgui_features/main.h | 68 +++ imgui_features/notify.h | 266 +++++++++++ 7 files changed, 1150 insertions(+) create mode 100644 imgui_features/example_win32_directx11.vcxproj create mode 100644 imgui_features/example_win32_directx11.vcxproj.filters create mode 100644 imgui_features/example_win32_directx11.vcxproj.user create mode 100644 imgui_features/imgui.ini create mode 100644 imgui_features/main.cpp create mode 100644 imgui_features/main.h create mode 100644 imgui_features/notify.h diff --git a/imgui_features/example_win32_directx11.vcxproj b/imgui_features/example_win32_directx11.vcxproj new file mode 100644 index 0000000..1038b42 --- /dev/null +++ b/imgui_features/example_win32_directx11.vcxproj @@ -0,0 +1,196 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {9F316E83-5AE5-4939-A723-305A94F48005} + example_win32_directx11 + 10.0.22621.0 + imgui_win32_directx11 + + + + Application + true + Unicode + v143 + + + Application + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + Application + false + true + Unicode + v143 + + + + + + + + + + + + + + + + + + + $(ProjectDir)$(Configuration)\ + $(ProjectDir)$(Configuration)\ + + + $(ProjectDir)$(Configuration)\ + $(ProjectDir)$(Configuration)\ + + + $(ProjectDir)$(Configuration)\ + $(ProjectDir)$(Configuration)\ + + + $(ProjectDir)$(Configuration)\ + $(ProjectDir)$(Configuration)\ + C:\Users\NOins\Desktop\imgui-features-shadows\SDK\Include;C:\Users\NOins\Desktop\imgui-features-shadows\freetype\include;$(IncludePath) + C:\Users\NOins\Desktop\imgui-features-shadows\SDK\Lib\x64;C:\Users\NOins\Desktop\imgui-features-shadows\freetype\win64;$(LibraryPath) + + + + Level4 + Disabled + ..\..;..\..\backends;%(AdditionalIncludeDirectories); + /utf-8 %(AdditionalOptions) + stdcpp20 + + + true + d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) + $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) + Console + + + + + Level4 + Disabled + $(SolutionDir)IMGUI;$(SolutionDir)backends;$(SolutionDir)SDK\Include;$(SolutionDir)libs\freetype\include;%(AdditionalIncludeDirectories) + /utf-8 %(AdditionalOptions) + stdcpp20 + + + true + d3d11.lib;d3dcompiler.lib;dxgi.lib;freetype.lib;%(AdditionalDependencies) + $(DXSDK_DIR)Lib\x64;$(SolutionDir)\SDK\Lib\x64;$(SolutionDir)libs\freetype\win64;%(AdditionalLibraryDirectories) + Console + + + + + Level4 + MaxSpeed + true + true + ..\..;..\..\backends;%(AdditionalIncludeDirectories); + false + /utf-8 %(AdditionalOptions) + + + true + true + true + d3d11.lib;d3dcompiler.lib;dxgi.lib;%(AdditionalDependencies) + $(DXSDK_DIR)/Lib/x86;%(AdditionalLibraryDirectories) + Console + + + + + Level4 + MaxSpeed + true + true + $(SolutionDir)IMGUI;$(SolutionDir)backends;$(SolutionDir)SDK\Include;$(SolutionDir)libs\freetype\include;%(AdditionalIncludeDirectories) + false + /utf-8 %(AdditionalOptions) + stdcpp17 + + + true + true + true + d3d11.lib;d3dcompiler.lib;dxgi.lib;freetype.lib;%(AdditionalDependencies) + $(DXSDK_DIR)Lib\x64;$(SolutionDir)\SDK\Lib\x64;$(SolutionDir)libs\freetype\win64;%(AdditionalLibraryDirectories) + Console + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/imgui_features/example_win32_directx11.vcxproj.filters b/imgui_features/example_win32_directx11.vcxproj.filters new file mode 100644 index 0000000..0a153dd --- /dev/null +++ b/imgui_features/example_win32_directx11.vcxproj.filters @@ -0,0 +1,93 @@ + + + + + {0587d7a3-f2ce-4d56-b84f-a0005d3bfce6} + + + {08e36723-ce4f-4cff-9662-c40801cf1acf} + + + + + sources + + + sources + + + sources + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + + + + + sources + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + imgui + + + + + + + imgui + + + imgui + + + + + + imgui + + + \ No newline at end of file diff --git a/imgui_features/example_win32_directx11.vcxproj.user b/imgui_features/example_win32_directx11.vcxproj.user new file mode 100644 index 0000000..429333d --- /dev/null +++ b/imgui_features/example_win32_directx11.vcxproj.user @@ -0,0 +1,6 @@ + + + + true + + \ No newline at end of file diff --git a/imgui_features/imgui.ini b/imgui_features/imgui.ini new file mode 100644 index 0000000..c730088 --- /dev/null +++ b/imgui_features/imgui.ini @@ -0,0 +1,100 @@ +[Window][Debug##Default] +Pos=193,458 +Size=283,186 +Collapsed=0 + +[Window][ImGui Menu] +Pos=490,524 +Size=730,430 +Collapsed=0 + +[Window][##TOAST10] +Pos=1804,386 +Size=111,32 +Collapsed=0 + +[Window][##TOAST9] +Pos=1828,348 +Size=87,32 +Collapsed=0 + +[Window][##TOAST8] +Pos=1828,310 +Size=87,32 +Collapsed=0 + +[Window][##TOAST7] +Pos=1828,272 +Size=87,32 +Collapsed=0 + +[Window][##TOAST6] +Pos=1828,234 +Size=87,32 +Collapsed=0 + +[Window][##TOAST5] +Pos=1825,196 +Size=90,32 +Collapsed=0 + +[Window][##TOAST4] +Pos=1825,158 +Size=90,32 +Collapsed=0 + +[Window][##TOAST3] +Pos=1825,120 +Size=90,32 +Collapsed=0 + +[Window][##TOAST2] +Pos=1825,82 +Size=90,32 +Collapsed=0 + +[Window][##TOAST1] +Pos=1825,44 +Size=90,32 +Collapsed=0 + +[Window][##TOAST0] +Pos=1825,6 +Size=90,32 +Collapsed=0 + +[Window][##TOAST16] +Pos=1804,614 +Size=111,32 +Collapsed=0 + +[Window][##TOAST15] +Pos=1804,576 +Size=111,32 +Collapsed=0 + +[Window][##TOAST14] +Pos=1804,538 +Size=111,32 +Collapsed=0 + +[Window][##TOAST13] +Pos=1804,500 +Size=111,32 +Collapsed=0 + +[Window][##TOAST12] +Pos=1804,462 +Size=111,32 +Collapsed=0 + +[Window][##TOAST11] +Pos=1804,424 +Size=111,32 +Collapsed=0 + +[Window][Popupbox] +Pos=188,416 +Size=300,156 +Collapsed=0 + diff --git a/imgui_features/main.cpp b/imgui_features/main.cpp new file mode 100644 index 0000000..beba9c3 --- /dev/null +++ b/imgui_features/main.cpp @@ -0,0 +1,421 @@ +#include "main.h" + +int main(int, char**) +{ + + WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(nullptr), nullptr, nullptr, nullptr, nullptr, L"ImGui Example", nullptr }; + ::RegisterClassExW(&wc); + HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX11 Example", WS_POPUP, 0, 0, 1920, 1080, nullptr, nullptr, wc.hInstance, nullptr); + + if (!CreateDeviceD3D(hwnd)) + { + CleanupDeviceD3D(); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); + return 1; + } + + ::ShowWindow(hwnd, SW_SHOWDEFAULT); + ::UpdateWindow(hwnd); + + IMGUI_CHECKVERSION(); + ImGui::CreateContext(); + ImGuiIO& io = ImGui::GetIO(); (void)io; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; + io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; + + ImFontConfig cfg; + ImFontConfig cfg_regular; + + cfg.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_ForceAutoHint | ImGuiFreeTypeBuilderFlags_LightHinting | ImGuiFreeTypeBuilderFlags_LoadColor | ImGuiFreeTypeBuilderFlags_Bitmap; + cfg_regular.FontBuilderFlags = ImGuiFreeTypeBuilderFlags_ForceAutoHint | ImGuiFreeTypeBuilderFlags_LightHinting | ImGuiFreeTypeBuilderFlags_LoadColor; + + font::calibri_bold = io.Fonts->AddFontFromMemoryTTF(calibri_bold, sizeof(calibri_bold), 14.f, &cfg, io.Fonts->GetGlyphRangesCyrillic()); + font::calibri_bold_hint = io.Fonts->AddFontFromMemoryTTF(calibri_bold, sizeof(calibri_bold), 12.f, &cfg, io.Fonts->GetGlyphRangesCyrillic()); + + font::calibri_regular = io.Fonts->AddFontFromMemoryTTF(calibri_regular, sizeof(calibri_regular), 12.f, &cfg_regular, io.Fonts->GetGlyphRangesCyrillic()); + + for (int i = 14; i < 45; i++) + font::icomoon[i] = io.Fonts->AddFontFromMemoryTTF(icomoon, sizeof(icomoon), i, &cfg, io.Fonts->GetGlyphRangesCyrillic()); + + ImGui_ImplWin32_Init(hwnd); + ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext); + + bool show_demo_window = true; + bool show_another_window = false; + ImVec4 clear_color = ImVec4(0.00f, 0.00f, 0.00f, 1.00f); + + D3DX11_IMAGE_LOAD_INFO info; ID3DX11ThreadPump* pump{ nullptr }; + if (texture::background == nullptr) D3DX11CreateShaderResourceViewFromMemory(g_pd3dDevice, background, sizeof(background), &info, pump, &texture::background, 0); + if (texture::roughness == nullptr) D3DX11CreateShaderResourceViewFromMemory(g_pd3dDevice, roughness, sizeof(roughness), &info, pump, &texture::roughness, 0); + if (texture::logo == nullptr) D3DX11CreateShaderResourceViewFromMemory(g_pd3dDevice, logo, sizeof(logo), &info, pump, &texture::logo, 0); + + bool done = false; + while (!done) + { + MSG msg; + while (::PeekMessage(&msg, nullptr, 0U, 0U, PM_REMOVE)) + { + ::TranslateMessage(&msg); + ::DispatchMessage(&msg); + if (msg.message == WM_QUIT) + done = true; + } + if (done) break; + + if (g_ResizeWidth != 0 && g_ResizeHeight != 0) + { + CleanupRenderTarget(); + g_pSwapChain->ResizeBuffers(0, g_ResizeWidth, g_ResizeHeight, DXGI_FORMAT_UNKNOWN, 0); + g_ResizeWidth = g_ResizeHeight = 0; + CreateRenderTarget(); + } + + ImGui_ImplDX11_NewFrame(); + ImGui_ImplWin32_NewFrame(); + ImGui::NewFrame(); + { + ImGuiStyle* style = &ImGui::GetStyle(); + + static float color[4] = { 221 / 255.f, 255 / 255.f, 11 / 255.f, 1.f }; + c::accent = { color[0], color[1], color[2], 1.f }; + + style->WindowPadding = ImVec2(0, 0); + style->ItemSpacing = ImVec2(20, 20); + style->WindowBorderSize = 0; + style->ScrollbarSize = 10.f; + + ImGui::GetBackgroundDrawList()->AddImage(texture::background, ImVec2(0, 0), ImVec2(1920, 1080), ImVec2(0, 0), ImVec2(1, 1), ImColor(255, 255, 255, 200)); + + ImGui::SetNextWindowSize(ImVec2(c::bg::size)); + + ImGui::Begin("ImGui Menu", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoBringToFrontOnFocus); + { + const ImVec2& pos = ImGui::GetWindowPos(); + const ImVec2& region = ImGui::GetContentRegionMax(); + const ImVec2& spacing = style->ItemSpacing; + + ImGui::GetBackgroundDrawList()->AddRectFilled(pos, pos + ImVec2(region), ImGui::GetColorU32(c::bg::background), c::bg::rounding); + ImGui::GetBackgroundDrawList()->AddImageRounded(texture::roughness, pos, pos + ImVec2(region), ImVec2(0, 0), ImVec2(1, 1), ImGui::GetColorU32(c::bg::roughness), c::bg::rounding); + ImGui::PushFont(font::icomoon[30]); + //50 + // + // centered logo + ImGui::GetWindowDrawList()->AddText(pos + (ImVec2(200, 50) - ImGui::CalcTextSize("L")) / 2, ImGui::GetColorU32(c::accent), "L"); + ImGui::PopFont(); + + //ImGui::GetWindowDrawList()->AddText(pos + ImVec2((50 - ImGui::CalcTextSize("L").y) / 2, (50 - ImGui::CalcTextSize("L").y) / 2), ImGui::GetColorU32(c::accent), "L"); + + ImGui::PushFont(font::icomoon[21]); + //drawtablogo + //ImGui::GetWindowDrawList()->AddText(pos + ImVec2(200 + (50 - ImGui::CalcTextSize("a").y) / 2, (50 - ImGui::CalcTextSize("a").y) / 2), ImGui::GetColorU32(c::accent), "a"); + + + //ImGui::GetWindowDrawList()->AddText(pos + ImVec2(region.x - (50 + ImGui::CalcTextSize("b").y) / 2, (50 - ImGui::CalcTextSize("b").y) / 2), ImGui::GetColorU32(c::text::text), "b"); + + ImGui::PopFont(); + + // ImGui::GetWindowDrawList()->AddText(pos + ImVec2(200 + 45, (50 - ImGui::CalcTextSize("Aimb0t").y) / 2 + 1), ImGui::GetColorU32(c::text::text_active), "Aimb0t"); + //ImGui::GetWindowDrawList()->AddText(pos + ImVec2(45, (50 - ImGui::CalcTextSize("GEAR5.AC").y) / 2 + 1), ImGui::GetColorU32(c::text::text_active), "GEAR5.AC"); + + ImGui::GetBackgroundDrawList()->AddLine(pos + ImVec2(200, 0), pos + ImVec2(200, region.y), ImGui::GetColorU32(c::bg::outline), 1.f); + ImGui::GetBackgroundDrawList()->AddLine(pos + ImVec2(0, 50), pos + ImVec2(region.x, 50), ImGui::GetColorU32(c::bg::outline), 1.f); + + ImGui::SetCursorPos(ImVec2(0, 50 + spacing.y)); + ImGui::BeginGroup();//define tabs + { + //dqsg + if (ImGui::Tabs(0 == tabs, "a", "Aimbot", "Help with Aiming.", ImVec2(200, 50))) tabs = 0; + + if (ImGui::Tabs(1 == tabs, "b", "Visuals", "U can seen more.", ImVec2(200, 50))) tabs = 1; + + if (ImGui::Tabs(2 == tabs, "d", "World", "World modification.", ImVec2(200, 50))) tabs = 2; + + if (ImGui::Tabs(3 == tabs, "c", "Misc", "Other options.", ImVec2(200, 50))) tabs = 3; + + if (ImGui::Tabs(4 == tabs, "e", "Settings", "Setup your cheat.", ImVec2(200, 50))) tabs = 4; + } + ImGui::EndGroup(); + + ImGui::SetCursorPos(ImVec2(200 + spacing.x, 0)); + if (tabs == 0) { //aimbot tab + static int tabsHor = 0; + ImGui::BeginGroup(); + { + //settings + if (ImGui::TabsHor(0 == tabsHor, "c", "general", "Just a description of this tab", ImVec2(100, 50))) tabsHor = 0; + ImGui::SameLine(); + //finished + if (ImGui::TabsHor(1 == tabsHor, "b", "accuracy", "Just a description of this tab", ImVec2(100, 50))) tabsHor = 1; + ImGui::SameLine(); + //finished + if (ImGui::TabsHor(2 == tabsHor, "c", "triggerbot", "Just a description of this tab", ImVec2(100, 50))) tabsHor = 2; + ImGui::SameLine(); + //finished + if (ImGui::TabsHor(3 == tabsHor, "b", "hitscan", "Just a description of this tab", ImVec2(100, 50))) tabsHor = 3; + ImGui::SameLine(); + //finished + } + ImGui::EndGroup(); + + ImGui::SetCursorPos(ImVec2(200, 50) + spacing); + ImGui::BeginChild("Child", ImVec2(region.x - 200, region.y - 50) - spacing); + switch (tabsHor) + { + case 0: + + + { + ImGui::BeginGroup(); + { + ImGui::CustomBeginChild("dah child", ImVec2((region.x - (200 + spacing.x * 3)) / 2, 0)); + { + + ImGui::Checkbox("Checkbox", &checkbox); + + ImGui::Checkbox("Checkbox ", &checkbox_false); + + ImGui::SliderInt("Drag slider", &slider_int, 1, 100, "%d%%"); + + ImGui::Combo("Combobox", &select_combo, items, IM_ARRAYSIZE(items), ARRAYSIZE(items)); + + ImGui::InputTextEx("Textfield", "blah blah blah", field, 46, ImVec2(ImGui::GetContentRegionMax().x - style->WindowPadding.x, 30), NULL); + + } + ImGui::CustomEndChild(); + + ImGui::CustomBeginChild("sibling smh", ImVec2((region.x - (200 + spacing.x * 3)) / 2, 0)); + { + + ImGui::MultiCombo("Multicombo", multi_num, multi_items, ARRAYSIZE(multi_items)); + + + } + ImGui::CustomEndChild(); + } + ImGui::EndGroup(); + + ImGui::SameLine(); + + ImGui::BeginGroup(); + { + ImGui::CustomBeginChild("dah children", ImVec2(region.x - (200 + spacing.x * 3), 0) / 2); + { + + ImGui::ColorEdit4("Colorpicker", color, picker_flags); + + ImGui::Keybind("Keybind", &key, &m); + + } + ImGui::CustomEndChild(); + + ImGui::CustomBeginChild("aimbooty", ImVec2(region.x - (200 + spacing.x * 3), 0) / 2); + { + + if (ImGui::Button("Button", ImVec2(ImGui::GetContentRegionMax().x - style->WindowPadding.x, 30))) { + ImGui::InsertNotification({ ImGuiToastType_Error, 1500, field }); + text_add++; + } + ImGui::SliderFloat("Drag slider", &slider_float, 0.0, 1.0f, "%0.1fF"); + + + } + ImGui::CustomEndChild(); + + ImGui::CustomBeginChild("Test child", ImVec2((region.x - (200 + spacing.x * 3)) / 2, 0)); + { + static int int_knob = 0; + static float float_knob = 0; + static float knob_test = 0; + + ImGui::KnobInt("Drag int", &int_knob, 0, 200, "%d%%", NULL); + + ImGui::KnobFloat("Drag Float", &float_knob, 0.f, 25.f, "%0.3fF", NULL); + + ImGui::KnobFloat("Drag Tick", &knob_test, 0, 4500.f, "%0.1fF", NULL); + + + } + ImGui::CustomEndChild(); + } + ImGui::EndGroup(); + + ImGui::Spacing(); + + } + + break; + + case 1: + { + ImGui::BeginGroup(); + { + ImGui::CustomBeginChild("another one", ImVec2((region.x - (200 + spacing.x * 3)) / 2, 0)); + { + static bool checkbook = 0; + + ImGui::Checkbox("Checkbox", &checkbook); + + ImGui::Combo("Combobox", &select_combo, items, IM_ARRAYSIZE(items), ARRAYSIZE(items)); + + } + ImGui::CustomEndChild(); + } + ImGui::EndGroup(); + + ImGui::SameLine(); + + ImGui::BeginGroup(); + { + ImGui::CustomBeginChild("just a child haha", ImVec2(region.x - (200 + spacing.x * 3), 0) / 2); + { + + + ImGui::Keybind("Keybind", &key, &m); + + } + ImGui::CustomEndChild(); + } + ImGui::EndGroup(); + break; + } + case 2: + break; + case 3: + break; + + default: + break; + + } + ImGui::EndChild(); + } + + + + } + ImGui::End(); + + ImGui::Begin("Popupbox", nullptr, ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize); + { + ImGui::CustomBeginChild("antiaim!!?!", ImVec2(300, 0), ImGuiWindowFlags_NoBringToFrontOnFocus); + { + static int value = 10; + static float vertical = 50.f; + static bool checkbox = false; + + ImGui::Checkbox("enable", &checkbox); + + if (checkbox) { + ImGui::KnobInt("pitch", &value, 1, 100, "%d%%", NULL); + + ImGui::KnobFloat("yaw", &vertical, 0.f, 100.f, "%.2fF", NULL); + } + } + ImGui::CustomEndChild(); + + } + ImGui::End(); + + ImGui::RenderNotifications(); + + } + ImGui::Render(); + const float clear_color_with_alpha[4] = { clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w }; + g_pd3dDeviceContext->OMSetRenderTargets(1, &g_mainRenderTargetView, nullptr); + g_pd3dDeviceContext->ClearRenderTargetView(g_mainRenderTargetView, clear_color_with_alpha); + ImGui_ImplDX11_RenderDrawData(ImGui::GetDrawData()); + + g_pSwapChain->Present(1, 0); + + } + + ImGui_ImplDX11_Shutdown(); + ImGui_ImplWin32_Shutdown(); + ImGui::DestroyContext(); + + CleanupDeviceD3D(); + ::DestroyWindow(hwnd); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); + + return 0; +} + +bool CreateDeviceD3D(HWND hWnd) +{ + // Setup swap chain + DXGI_SWAP_CHAIN_DESC sd; + ZeroMemory(&sd, sizeof(sd)); + sd.BufferCount = 2; + sd.BufferDesc.Width = 0; + sd.BufferDesc.Height = 0; + sd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; + sd.BufferDesc.RefreshRate.Numerator = 60; + sd.BufferDesc.RefreshRate.Denominator = 1; + sd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH; + sd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; + sd.OutputWindow = hWnd; + sd.SampleDesc.Count = 1; + sd.SampleDesc.Quality = 0; + sd.Windowed = TRUE; + sd.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; + + UINT createDeviceFlags = 0; + + D3D_FEATURE_LEVEL featureLevel; + const D3D_FEATURE_LEVEL featureLevelArray[2] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0, }; + HRESULT res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext); + if (res == DXGI_ERROR_UNSUPPORTED) + res = D3D11CreateDeviceAndSwapChain(nullptr, D3D_DRIVER_TYPE_WARP, nullptr, createDeviceFlags, featureLevelArray, 2, D3D11_SDK_VERSION, &sd, &g_pSwapChain, &g_pd3dDevice, &featureLevel, &g_pd3dDeviceContext); + if (res != S_OK) + return false; + + CreateRenderTarget(); + return true; +} + +void CleanupDeviceD3D() +{ + CleanupRenderTarget(); + if (g_pSwapChain) { g_pSwapChain->Release(); g_pSwapChain = nullptr; } + if (g_pd3dDeviceContext) { g_pd3dDeviceContext->Release(); g_pd3dDeviceContext = nullptr; } + if (g_pd3dDevice) { g_pd3dDevice->Release(); g_pd3dDevice = nullptr; } +} + +void CreateRenderTarget() +{ + ID3D11Texture2D* pBackBuffer; + g_pSwapChain->GetBuffer(0, IID_PPV_ARGS(&pBackBuffer)); + g_pd3dDevice->CreateRenderTargetView(pBackBuffer, nullptr, &g_mainRenderTargetView); + pBackBuffer->Release(); +} + +void CleanupRenderTarget() +{ + if (g_mainRenderTargetView) { g_mainRenderTargetView->Release(); g_mainRenderTargetView = nullptr; } +} + +extern IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + +LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) +{ + if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam)) + return true; + + switch (msg) + { + case WM_SIZE: + if (wParam == SIZE_MINIMIZED) + return 0; + g_ResizeWidth = (UINT)LOWORD(lParam); + g_ResizeHeight = (UINT)HIWORD(lParam); + return 0; + case WM_SYSCOMMAND: + if ((wParam & 0xfff0) == SC_KEYMENU) + return 0; + break; + case WM_DESTROY: + ::PostQuitMessage(0); + return 0; + } + return ::DefWindowProcW(hWnd, msg, wParam, lParam); +} diff --git a/imgui_features/main.h b/imgui_features/main.h new file mode 100644 index 0000000..abf4573 --- /dev/null +++ b/imgui_features/main.h @@ -0,0 +1,68 @@ +#define IMGUI_DEFINE_MATH_OPERATORS + +#include "imgui_impl_win32.h" +#include "imgui_impl_dx11.h" +#include "imgui_internal.h" +#include "imgui_freetype.h" + +//#include +#include +#include + +#include "notify.h" + +#include +#pragma comment(lib, "D3DX11.lib") + +#include "texture.h" +#include "font.h" + +static ID3D11Device* g_pd3dDevice = nullptr; +static ID3D11DeviceContext* g_pd3dDeviceContext = nullptr; +static IDXGISwapChain* g_pSwapChain = nullptr; +static UINT g_ResizeWidth = 0, g_ResizeHeight = 0; +static ID3D11RenderTargetView* g_mainRenderTargetView = nullptr; + +bool CreateDeviceD3D(HWND hWnd); +void CleanupDeviceD3D(); +void CreateRenderTarget(); +void CleanupRenderTarget(); +LRESULT WINAPI WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam); + +int tabs = 0; + +int text_add = 0; +DWORD picker_flags = ImGuiColorEditFlags_NoSidePreview | ImGuiColorEditFlags_AlphaBar | ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_AlphaPreview; + +bool checkbox = true; +bool checkbox_false = false; +int slider_int = 50; +float slider_float = 0.5f; +char field[46] = { "" }; + +int select_combo = 0; +const char* items[3]{ "dah one", "dah other one", "dah other other one" }; + +bool multi_num[5] = { false, false, false, false, false }; +const char* multi_items[5] = { "One", "Two", "Three", "Four", "Five" }; + +std::vector words; + + +static int key, m; + +namespace font +{ + inline ImFont* calibri_bold = nullptr; + inline ImFont* calibri_bold_hint = nullptr; + inline ImFont* calibri_regular = nullptr; + inline ImFont* icomoon[14]; +} + +namespace texture +{ + inline ID3D11ShaderResourceView* background = nullptr; + inline ID3D11ShaderResourceView* roughness = nullptr; + inline ID3D11ShaderResourceView* logo = nullptr; + inline ID3D11ShaderResourceView* arrow = nullptr; +} \ No newline at end of file diff --git a/imgui_features/notify.h b/imgui_features/notify.h new file mode 100644 index 0000000..a723fa0 --- /dev/null +++ b/imgui_features/notify.h @@ -0,0 +1,266 @@ +#define IMGUI_NOTIFY + +#include +#include +#include "imgui.h" +#include +#include + +#include "imgui_elements.h" + +using namespace ImGui; + +extern const char* cheat_name; + +#define NOTIFY_MAX_MSG_LENGTH 4096 +#define NOTIFY_PADDING_X 5.f +#define NOTIFY_PADDING_Y 5.f +#define NOTIFY_PADDING_MESSAGE_Y 10.f +#define NOTIFY_FADE_IN_OUT_TIME 150 +#define NOTIFY_DEFAULT_DISMISS 3000 +#define NOTIFY_OPACITY 1.0f +#define NOTIFY_TOAST_FLAGS ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoBringToFrontOnFocus | ImGuiWindowFlags_NoFocusOnAppearing + +#define NOTIFY_INLINE inline +#define NOTIFY_NULL_OR_EMPTY(str) (!str ||! strlen(str)) +#define NOTIFY_FORMAT(fn, format, ...) if (format) { va_list args; va_start(args, format); fn(format, args, __VA_ARGS__); va_end(args); } + +typedef int ImGuiToastType; +typedef int ImGuiToastPhase; +typedef int ImGuiToastPos; + +enum ImGuiToastType_ +{ + ImGuiToastType_None, + ImGuiToastType_Success, + ImGuiToastType_Warning, + ImGuiToastType_Error, + ImGuiToastType_Info, + ImGuiToastType_COUNT +}; + +enum ImGuiToastPhase_ +{ + ImGuiToastPhase_FadeIn, + ImGuiToastPhase_Wait, + ImGuiToastPhase_FadeOut, + ImGuiToastPhase_Expired, + ImGuiToastPhase_COUNT +}; + +enum ImGuiToastPos_ +{ + ImGuiToastPos_TopLeft, + ImGuiToastPos_TopCenter, + ImGuiToastPos_TopRight, + ImGuiToastPos_BottomLeft, + ImGuiToastPos_BottomCenter, + ImGuiToastPos_BottomRight, + ImGuiToastPos_Center, + ImGuiToastPos_COUNT +}; + +class ImGuiToast +{ +private: + ImGuiToastType type = ImGuiToastType_None; + char title[NOTIFY_MAX_MSG_LENGTH]; + char content[NOTIFY_MAX_MSG_LENGTH]; + int dismiss_time = NOTIFY_DEFAULT_DISMISS; + uint64_t creation_time = 0; + +private: + // Setters + + NOTIFY_INLINE auto set_title(const char* format, va_list args) { vsnprintf(this->title, sizeof(this->title), format, args); } + + NOTIFY_INLINE auto set_content(const char* format, va_list args) { vsnprintf(this->content, sizeof(this->content), format, args); } + +public: + + NOTIFY_INLINE auto set_title(const char* format, ...) -> void { NOTIFY_FORMAT(this->set_title, format); } + + NOTIFY_INLINE auto set_content(const char* format, ...) -> void { NOTIFY_FORMAT(this->set_content, format); } + + NOTIFY_INLINE auto set_type(const ImGuiToastType& type) -> void { IM_ASSERT(type < ImGuiToastType_COUNT); this->type = type; }; + +public: + // Getters + + NOTIFY_INLINE auto get_title() -> char* { return this->title; }; + + NOTIFY_INLINE auto get_default_title() -> char* + { + if (!strlen(this->title)) + { + switch (this->type) + { + case ImGuiToastType_None: + return NULL; + /*case ImGuiToastType_Success: + return "Success"; + case ImGuiToastType_Warning: + return "Warning"; + case ImGuiToastType_Error: + return "Error"; + case ImGuiToastType_Info: + return "Info";*/ + } + } + + return this->title; + }; + + NOTIFY_INLINE auto get_type() -> const ImGuiToastType& { return this->type; }; + + NOTIFY_INLINE auto get_color() -> const ImVec4& + { + switch (this->type) + { + case ImGuiToastType_None: + return { 255, 255, 255, 255 }; + case ImGuiToastType_Success: + return { 74, 235, 138, 255 }; + case ImGuiToastType_Warning: + return { 235, 74, 116, 255 }; + case ImGuiToastType_Error: + return { 235, 74, 74, 255 }; + case ImGuiToastType_Info: + return { 74, 169, 235, 255 }; + } + } + + NOTIFY_INLINE auto get_content() -> char* { return this->content; }; + + NOTIFY_INLINE auto get_elapsed_time() { return GetTickCount64() - this->creation_time; } + + NOTIFY_INLINE auto get_phase() -> const ImGuiToastPhase& + { + const auto elapsed = get_elapsed_time(); + + if (elapsed > NOTIFY_FADE_IN_OUT_TIME + this->dismiss_time + NOTIFY_FADE_IN_OUT_TIME) + { + return ImGuiToastPhase_Expired; + } + else if (elapsed > NOTIFY_FADE_IN_OUT_TIME + this->dismiss_time) + { + return ImGuiToastPhase_FadeOut; + } + else if (elapsed > NOTIFY_FADE_IN_OUT_TIME) + { + return ImGuiToastPhase_Wait; + } + else + { + return ImGuiToastPhase_FadeIn; + } + } + + NOTIFY_INLINE auto get_fade_percent() -> const float + { + const auto phase = get_phase(); + const auto elapsed = get_elapsed_time(); + + if (phase == ImGuiToastPhase_FadeIn) + { + return ((float)elapsed / (float)NOTIFY_FADE_IN_OUT_TIME) * NOTIFY_OPACITY; + } + else if (phase == ImGuiToastPhase_FadeOut) + { + return (1.f - (((float)elapsed - (float)NOTIFY_FADE_IN_OUT_TIME - (float)this->dismiss_time) / (float)NOTIFY_FADE_IN_OUT_TIME)) * NOTIFY_OPACITY; + } + + return 1.f * NOTIFY_OPACITY; + } + +public: + + ImGuiToast(ImGuiToastType type, int dismiss_time = NOTIFY_DEFAULT_DISMISS) + { + IM_ASSERT(type < ImGuiToastType_COUNT); + + this->type = type; + this->dismiss_time = dismiss_time; + this->creation_time = GetTickCount64(); + + memset(this->title, 0, sizeof(this->title)); + memset(this->content, 0, sizeof(this->content)); + } + + ImGuiToast(ImGuiToastType type, const char* format, ...) : ImGuiToast(type) { NOTIFY_FORMAT(this->set_content, format); } + + ImGuiToast(ImGuiToastType type, int dismiss_time, const char* format, ...) : ImGuiToast(type, dismiss_time) { NOTIFY_FORMAT(this->set_content, format); } +}; + +namespace ImGui +{ + NOTIFY_INLINE std::vector notifications; + + NOTIFY_INLINE VOID InsertNotification(const ImGuiToast& toast) + { + notifications.push_back(toast); + } + + NOTIFY_INLINE VOID RemoveNotification(int index) + { + notifications.erase(notifications.begin() + index); + } + + NOTIFY_INLINE VOID RenderNotifications() + { + const auto vp_size = GetMainViewport()->Size; + + float height = 0.f; + + for (auto i = 0; i < notifications.size(); i++) + { + auto* current_toast = ¬ifications[i]; + + if (current_toast->get_phase() == ImGuiToastPhase_Expired) + { + RemoveNotification(i); + continue; + } + + const char* title = current_toast->get_title(); + const auto content = current_toast->get_content(); + const auto default_title = current_toast->get_default_title(); + const auto opacity = current_toast->get_fade_percent(); + + auto text_color = current_toast->get_color(); + text_color.w = opacity; + + char window_name[50]; + sprintf_s(window_name, "##TOAST%d", i); + + PushStyleVar(ImGuiStyleVar_Alpha, opacity); + SetNextWindowPos(ImVec2(vp_size.x - NOTIFY_PADDING_X, NOTIFY_PADDING_Y + height + 33), ImGuiCond_Always, ImVec2(1.f, 1.0f)); + + PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(8, 8)); + PushStyleVar(ImGuiStyleVar_WindowRounding, c::button::rounding); + PushStyleColor(ImGuiCol_WindowBg, GetColorU32(c::button::background, 0.6f)); + Begin(window_name, NULL, NOTIFY_TOAST_FLAGS); + + ImGui::GetForegroundDrawList()->AddRectFilled(GetCursorScreenPos() + ImVec2(GetContentRegionMax().x - 3, -8), GetCursorScreenPos() + ImVec2(GetContentRegionMax().x, 23), GetColorU32(c::accent), c::button::rounding, ImDrawFlags_RoundCornersRight); + + { + PushTextWrapPos(vp_size.x / 3.f); + + if (!NOTIFY_NULL_OR_EMPTY(content)) + { + SetCursorPosY(GetCursorPosY() - 1); + TextColored(ImColor(GetColorU32(c::text::text_active)), content); + } + + PopTextWrapPos(); + } + + height += GetWindowHeight() + 6; + + End(); + PopStyleVar(3); + PopStyleColor(); + } + } +} +