diff --git a/.gitignore b/.gitignore index 02d9c26..e3c20c5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ build src/bin/_empty.cpp src/bin/_empty.h .vscode/settings.json +dist +*log* \ No newline at end of file diff --git a/src/PCH.h b/src/PCH.h index f8f5d4c..9fadb53 100644 --- a/src/PCH.h +++ b/src/PCH.h @@ -26,6 +26,17 @@ namespace util using SKSE::stl::report_and_fail; } +#define INFO(...) logger::info(__VA_ARGS__) +#define WARN(...) logger::warn(__VA_ARGS__) +#define ERROR(...) logger::error(__VA_ARGS__) +#define CRITICAL(...) logger::critical(__VA_ARGS__) +#ifndef NDEBUG +#include +#define ASSERT(x) assert(x) +#else +#define ASSERT(x) +#endif + namespace std { template diff --git a/src/bin/Rendering/Drawer.cpp b/src/bin/Rendering/Drawer.cpp index 62d065c..bf1061f 100644 --- a/src/bin/Rendering/Drawer.cpp +++ b/src/bin/Rendering/Drawer.cpp @@ -194,7 +194,7 @@ void Drawer::draw_texture(ID3D11ShaderResourceView* a_texture, Utils::Color::MultAlpha(a_color, a_drawArgs.alphaMult); ImGui::GetWindowDrawList() - ->AddImageQuad(a_texture, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], a_color); + ->AddImageQuad((ImTextureID)a_texture, pos[0], pos[1], pos[2], pos[3], uvs[0], uvs[1], uvs[2], uvs[3], a_color); } void Drawer::draw_arc(ImVec2 center, diff --git a/src/bin/Rendering/RenderManager.cpp b/src/bin/Rendering/RenderManager.cpp index 059e0a3..96c5fa7 100644 --- a/src/bin/Rendering/RenderManager.cpp +++ b/src/bin/Rendering/RenderManager.cpp @@ -1,4 +1,5 @@ #include "RenderManager.h" +#include #include "FontLoader.h" #include @@ -47,35 +48,40 @@ void RenderManager::D3DInitHook::thunk() func(); INFO("RenderManager: Initializing..."); - auto render_manager = RE::BSRenderManager::GetSingleton(); - if (!render_manager) { - ERROR("Cannot find render manager. Initialization failed!"); + auto renderer = RE::BSGraphics::Renderer::GetSingleton(); + if (!renderer) { + ERROR("Cannot find renderer. Initialization failed!"); return; } - auto render_data = render_manager->GetRuntimeData(); + auto render_data = renderer->GetRendererData(); + if (!render_data) { + ERROR("Cannot find render data. Initialization failed!"); + return; + } INFO("Getting swapchain..."); - auto swapchain = render_data.swapChain; + auto window = renderer->GetCurrentRenderWindow(); + auto swapchain = window->swapChain; if (!swapchain) { ERROR("Cannot find swapchain. Initialization failed!"); return; } INFO("Getting swapchain desc..."); - DXGI_SWAP_CHAIN_DESC sd{}; - if (swapchain->GetDesc(std::addressof(sd)) < 0) { + REX::W32::DXGI_SWAP_CHAIN_DESC sd{}; + if (swapchain->GetDesc(&sd) < 0) { ERROR("IDXGISwapChain::GetDesc failed."); return; } - device = render_data.forwarder; + device = reinterpret_cast(render_data->forwarder); Texture::device_ = device; - context = render_data.context; + context = reinterpret_cast(render_data->context); INFO("Initializing ImGui..."); ImGui::CreateContext(); - if (!ImGui_ImplWin32_Init(sd.OutputWindow)) { + if (!ImGui_ImplWin32_Init(sd.outputWindow)) { ERROR("ImGui initialization failed (Win32)"); return; } @@ -90,7 +96,7 @@ void RenderManager::D3DInitHook::thunk() WndProcHook::func = reinterpret_cast( SetWindowLongPtrA( - sd.OutputWindow, + sd.outputWindow, GWLP_WNDPROC, reinterpret_cast(WndProcHook::thunk))); if (!WndProcHook::func) diff --git a/src/bin/Rendering/TextureManager.cpp b/src/bin/Rendering/TextureManager.cpp index 9ca951c..57a78a7 100644 --- a/src/bin/Rendering/TextureManager.cpp +++ b/src/bin/Rendering/TextureManager.cpp @@ -1,4 +1,5 @@ #include "TextureManager.h" +#include #define NANOSVG_IMPLEMENTATION #define NANOSVG_ALL_COLOR_KEYWORDS #include "include/lib/nanosvg.h" @@ -40,14 +41,14 @@ Texture::Image Texture::GetIconImage(icon_image_type a_imageType, RE::TESForm* a bool Texture::load_texture_from_file(const char* filename, ID3D11ShaderResourceView** out_srv, int& out_width, int& out_height) { ASSERT(device_ != nullptr); - auto* render_manager = RE::BSRenderManager::GetSingleton(); - if (!render_manager) { - logger::error("Cannot find render manager. Initialization failed."sv); + auto* renderer = RE::BSGraphics::Renderer::GetSingleton(); + if (!renderer) { + logger::error("Cannot find renderer. Initialization failed."sv); return false; } - auto [forwarder, context, unk58, unk60, unk68, swapChain, unk78, unk80, renderView, resourceView] = - render_manager->GetRuntimeData(); + auto render_data = renderer->GetRendererData(); + auto forwarder = render_data->forwarder; // Load from disk into a raw RGBA buffer auto* svg = nsvgParseFromFile(filename, "px", 96.0f); @@ -89,7 +90,10 @@ bool Texture::load_texture_from_file(const char* filename, ID3D11ShaderResourceV srv_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; srv_desc.Texture2D.MipLevels = desc.MipLevels; srv_desc.Texture2D.MostDetailedMip = 0; - forwarder->CreateShaderResourceView(p_texture, &srv_desc, out_srv); + forwarder->CreateShaderResourceView( + reinterpret_cast(p_texture), + reinterpret_cast(&srv_desc), + reinterpret_cast(out_srv)); p_texture->Release(); free(image_data); diff --git a/src/bin/Utilities/Utils.cpp b/src/bin/Utilities/Utils.cpp index c83cdf4..09aefe9 100644 --- a/src/bin/Utilities/Utils.cpp +++ b/src/bin/Utilities/Utils.cpp @@ -28,7 +28,11 @@ namespace Utils if (!aem) { return; } - auto* dummy = RE::TESForm::LookupByID(0x00020163)->As(); + // Use Iron Dagger as dummy weapon to clear slot + auto* dummy = RE::TESForm::LookupByID(0x0001397E)->As(); + if (!dummy) { + return; + } //sound false, queue false, force true aem->EquipObject(a_pc, dummy, nullptr, 1, a_slot, false, true, false); aem->UnequipObject(a_pc, dummy, nullptr, 1, a_slot, false, true, false); diff --git a/src/bin/main.cpp b/src/bin/main.cpp index c02ee48..4d4adb6 100644 --- a/src/bin/main.cpp +++ b/src/bin/main.cpp @@ -130,7 +130,7 @@ extern "C" DLLEXPORT constinit auto SKSEPlugin_Version = []() { extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_skse) { - REL::Module::reset(); // Clib-NG bug workaround + // REL::Module::reset(); // Clib-NG bug workaround //std::this_thread::sleep_for(std::chrono::milliseconds(10000)); InitializeLog(); logger::info("{} v{}"sv, Plugin::NAME, Plugin::VERSION.string()); diff --git a/src/include/lib/imgui_freetype.cpp b/src/include/lib/imgui_freetype.cpp index 503430a..5529e6e 100644 --- a/src/include/lib/imgui_freetype.cpp +++ b/src/include/lib/imgui_freetype.cpp @@ -398,7 +398,7 @@ struct ImFontBuildDstDataFT bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, unsigned int extra_flags) { - IM_ASSERT(atlas->ConfigData.Size > 0); + IM_ASSERT(atlas->Sources.Size > 0); ImFontAtlasBuildInit(atlas); @@ -413,16 +413,16 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u bool src_load_color = false; ImVector src_tmp_array; ImVector dst_tmp_array; - src_tmp_array.resize(atlas->ConfigData.Size); + src_tmp_array.resize(atlas->Sources.Size); dst_tmp_array.resize(atlas->Fonts.Size); memset((void*)src_tmp_array.Data, 0, (size_t)src_tmp_array.size_in_bytes()); memset((void*)dst_tmp_array.Data, 0, (size_t)dst_tmp_array.size_in_bytes()); // 1. Initialize font loading structure, check font data validity - for (int src_i = 0; src_i < atlas->ConfigData.Size; src_i++) + for (int src_i = 0; src_i < atlas->Sources.Size; src_i++) { ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - ImFontConfig& cfg = atlas->ConfigData[src_i]; + ImFontConfig& cfg = atlas->Sources[src_i]; FreeTypeFont& font_face = src_tmp.Font; IM_ASSERT(cfg.DstFont && (!cfg.DstFont->IsLoaded() || cfg.DstFont->ContainerAtlas == atlas)); @@ -530,7 +530,7 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u for (int src_i = 0; src_i < src_tmp_array.Size; src_i++) { ImFontBuildSrcDataFT& src_tmp = src_tmp_array[src_i]; - ImFontConfig& cfg = atlas->ConfigData[src_i]; + ImFontConfig& cfg = atlas->Sources[src_i]; if (src_tmp.GlyphsCount == 0) continue; @@ -642,7 +642,7 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u // When merging fonts with MergeMode=true: // - We can have multiple input fonts writing into a same destination font. // - dst_font->ConfigData is != from cfg which is our source configuration. - ImFontConfig& cfg = atlas->ConfigData[src_i]; + ImFontConfig& cfg = atlas->Sources[src_i]; ImFont* dst_font = cfg.DstFont; const float ascent = src_tmp.Font.Info.Ascender; diff --git a/vcpkg.json b/vcpkg.json index 10bff6e..8d1af6a 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -10,12 +10,13 @@ "rapidcsv", "nlohmann-json", "freetype", + "directxtk", { - "name": "imgui", - "features": [ - "dx11-binding", - "win32-binding" - ] + "name": "imgui", + "features": [ + "dx11-binding", + "win32-binding" + ] } ] -} +} \ No newline at end of file