From e595eb9a02b9b216315be59bc3d3165b7529a5d9 Mon Sep 17 00:00:00 2001 From: SaiyansKing <38609240+SaiyansKing@users.noreply.github.com> Date: Tue, 20 Dec 2022 06:07:52 +0100 Subject: [PATCH 1/5] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ec5086fb..3772a3ab 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ The new renderer is able to utilize more of the current GPU generation's power. * Hardware Tessellation * Editor-Panel to insert some of the renderers features into the world * Custom-Built UI-Framework based on Direct2D +* Rewritten bink player for better compatibility with bink videos * FPS-Limiter ## Installation & Usage From 7bd686dc24b6b3c0edae94b9e6995b69cb11be39 Mon Sep 17 00:00:00 2001 From: SaiyansKing <38609240+SaiyansKing@users.noreply.github.com> Date: Fri, 23 Dec 2022 19:43:45 +0100 Subject: [PATCH 2/5] Fix loading commandlines when UserSettings.ini doesn't exist --- D3D11Engine/GothicAPI.cpp | 215 +++++++++++++++++++------------------- 1 file changed, 105 insertions(+), 110 deletions(-) diff --git a/D3D11Engine/GothicAPI.cpp b/D3D11Engine/GothicAPI.cpp index 8bfd4cde..57b61b14 100644 --- a/D3D11Engine/GothicAPI.cpp +++ b/D3D11Engine/GothicAPI.cpp @@ -3989,121 +3989,116 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { // Get path to Gothic.Ini auto ini = std::string( NPath, len ).append( "\\" + file ); - - if ( !Toolbox::FileExists( ini ) ) { - LogWarn() << "Settings file not found: " << ini; - return XR_FAILED; - } - LogInfo() << "Loading menu settings from " << ini; - - - GothicRendererSettings defaultRendererSettings; - defaultRendererSettings.SetDefault(); - GothicRendererSettings& s = RendererState.RendererSettings; + if ( !Toolbox::FileExists( ini ) ) { + LogInfo() << "Loading menu settings from " << ini; + + GothicRendererSettings defaultRendererSettings; + defaultRendererSettings.SetDefault(); + + s.ChangeWindowPreset = GetPrivateProfileIntA( "General", "ChangeToMode", 0, ini.c_str() ); + s.DrawFog = GetPrivateProfileBoolA( "General", "EnableFog", true, ini ); + s.AtmosphericScattering = GetPrivateProfileBoolA( "General", "AtmosphericScattering", true, ini ); + s.EnableHDR = GetPrivateProfileBoolA( "General", "EnableHDR", false, ini ); + s.HDRToneMap = GothicRendererSettings::E_HDRToneMap( GetPrivateProfileIntA( "General", "HDRToneMap", 4, ini.c_str() ) ); + s.EnableDebugLog = GetPrivateProfileBoolA( "General", "EnableDebugLog", defaultRendererSettings.EnableDebugLog, ini ); + s.EnableAutoupdates = GetPrivateProfileBoolA( "General", "EnableAutoupdates", defaultRendererSettings.EnableAutoupdates, ini ); + s.EnableGodRays = GetPrivateProfileBoolA( "General", "EnableGodRays", defaultRendererSettings.EnableGodRays, ini ); + s.AllowNormalmaps = GetPrivateProfileBoolA( "General", "AllowNormalmaps", defaultRendererSettings.AllowNormalmaps, ini ); + s.AllowNumpadKeys = GetPrivateProfileBoolA( "General", "AllowNumpadKeys", defaultRendererSettings.AllowNumpadKeys, ini ); + s.EnableInactiveFpsLock = GetPrivateProfileBoolA( "General", "EnableInactiveFpsLock", defaultRendererSettings.EnableInactiveFpsLock, ini ); + s.MTResoureceManager = GetPrivateProfileBoolA( "General", "MultiThreadResourceManager", defaultRendererSettings.MTResoureceManager, ini ); + s.CompressBackBuffer = GetPrivateProfileBoolA( "General", "CompressBackBuffer", defaultRendererSettings.CompressBackBuffer, ini ); + s.AnimateStaticVobs = GetPrivateProfileBoolA( "General", "AnimateStaticVobs", defaultRendererSettings.AnimateStaticVobs, ini ); + s.DrawSectionIntersections = GetPrivateProfileBoolA( "General", "DrawWorldSectionIntersections", defaultRendererSettings.DrawSectionIntersections, ini ); + s.SunLightStrength = GetPrivateProfileFloatA( "General", "SunLightStrength", defaultRendererSettings.SunLightStrength, ini ); + s.DrawG1ForestPortals = GetPrivateProfileBoolA( "General", "DrawG1ForestPortals", defaultRendererSettings.DrawG1ForestPortals, ini ); - s.ChangeWindowPreset = GetPrivateProfileIntA( "General", "ChangeToMode", 0, ini.c_str() ); - s.DrawFog = GetPrivateProfileBoolA( "General", "EnableFog", true, ini ); - s.AtmosphericScattering = GetPrivateProfileBoolA( "General", "AtmosphericScattering", true, ini ); - s.EnableHDR = GetPrivateProfileBoolA( "General", "EnableHDR", false, ini ); - s.HDRToneMap = GothicRendererSettings::E_HDRToneMap( GetPrivateProfileIntA( "General", "HDRToneMap", 4, ini.c_str() ) ); - s.EnableDebugLog = GetPrivateProfileBoolA( "General", "EnableDebugLog", defaultRendererSettings.EnableDebugLog, ini ); - s.EnableAutoupdates = GetPrivateProfileBoolA( "General", "EnableAutoupdates", defaultRendererSettings.EnableAutoupdates, ini ); - s.EnableGodRays = GetPrivateProfileBoolA( "General", "EnableGodRays", defaultRendererSettings.EnableGodRays, ini ); - s.AllowNormalmaps = GetPrivateProfileBoolA( "General", "AllowNormalmaps", defaultRendererSettings.AllowNormalmaps, ini ); - s.AllowNumpadKeys = GetPrivateProfileBoolA( "General", "AllowNumpadKeys", defaultRendererSettings.AllowNumpadKeys, ini ); - s.EnableInactiveFpsLock = GetPrivateProfileBoolA( "General", "EnableInactiveFpsLock", defaultRendererSettings.EnableInactiveFpsLock, ini ); - s.MTResoureceManager = GetPrivateProfileBoolA( "General", "MultiThreadResourceManager", defaultRendererSettings.MTResoureceManager, ini ); - s.CompressBackBuffer = GetPrivateProfileBoolA( "General", "CompressBackBuffer", defaultRendererSettings.CompressBackBuffer, ini ); - s.AnimateStaticVobs = GetPrivateProfileBoolA( "General", "AnimateStaticVobs", defaultRendererSettings.AnimateStaticVobs, ini ); - s.DrawSectionIntersections = GetPrivateProfileBoolA( "General", "DrawWorldSectionIntersections", defaultRendererSettings.DrawSectionIntersections, ini ); - s.SunLightStrength = GetPrivateProfileFloatA( "General", "SunLightStrength", defaultRendererSettings.SunLightStrength, ini ); - s.DrawG1ForestPortals = GetPrivateProfileBoolA( "General", "DrawG1ForestPortals", defaultRendererSettings.DrawG1ForestPortals, ini ); - - /* - * Draw-distance is Loaded on a per World basis using LoadRendererWorldSettings - */ + /* + * Draw-distance is Loaded on a per World basis using LoadRendererWorldSettings + */ + + s.EnableOcclusionCulling = GetPrivateProfileBoolA( "General", "EnableOcclusionCulling", defaultRendererSettings.EnableOcclusionCulling, ini ); + s.FpsLimit = GetPrivateProfileIntA( "General", "FpsLimit", 0, ini.c_str() ); + + // override INI settings with GMP minimum values. + if ( GMPModeActive ) { + s.OutdoorVobDrawRadius = std::max( 20000.f, s.OutdoorVobDrawRadius ); + s.OutdoorSmallVobDrawRadius = std::max( 20000.f, s.OutdoorSmallVobDrawRadius ); + s.SectionDrawRadius = std::max( 3, s.SectionDrawRadius ); + s.EnableHDR = false; + } - s.EnableOcclusionCulling = GetPrivateProfileBoolA( "General", "EnableOcclusionCulling", defaultRendererSettings.EnableOcclusionCulling, ini ); - s.FpsLimit = GetPrivateProfileIntA( "General", "FpsLimit", 0, ini.c_str() ); - - // override INI settings with GMP minimum values. - if ( GMPModeActive ) { - s.OutdoorVobDrawRadius = std::max( 20000.f, s.OutdoorVobDrawRadius ); - s.OutdoorSmallVobDrawRadius = std::max( 20000.f, s.OutdoorSmallVobDrawRadius ); - s.SectionDrawRadius = std::max( 3, s.SectionDrawRadius ); - s.EnableHDR = false; - } - - static XMFLOAT3 defaultLightDirection = XMFLOAT3( 1, 1, 1 ); - - s.EnableShadows = GetPrivateProfileBoolA( "Shadows", "EnableShadows", defaultRendererSettings.EnableShadows, ini ); - s.EnableSoftShadows = GetPrivateProfileBoolA( "Shadows", "EnableSoftShadows", defaultRendererSettings.EnableSoftShadows, ini ); - s.ShadowMapSize = GetPrivateProfileIntA( "Shadows", "ShadowMapSize", defaultRendererSettings.ShadowMapSize, ini.c_str() ); - s.EnablePointlightShadows = GothicRendererSettings::EPointLightShadowMode( GetPrivateProfileIntA( "Shadows", "PointlightShadows", GothicRendererSettings::EPointLightShadowMode::PLS_STATIC_ONLY, ini.c_str() ) ); - s.WorldShadowRangeScale = GetPrivateProfileFloatA( "Shadows", "WorldShadowRangeScale", 1.0f, ini ); - s.EnableDynamicLighting = GetPrivateProfileBoolA( "Shadows", "EnableDynamicLighting", defaultRendererSettings.EnableDynamicLighting, ini ); - s.SmoothShadowCameraUpdate = GetPrivateProfileBoolA( "Shadows", "SmoothCameraUpdate", defaultRendererSettings.SmoothShadowCameraUpdate, ini ); - s.ShadowStrength = GetPrivateProfileFloatA( "Shadows", "ShadowStrength", defaultRendererSettings.ShadowStrength, ini ); - s.ShadowAOStrength = GetPrivateProfileFloatA( "Shadows", "ShadowAOStrength", defaultRendererSettings.ShadowAOStrength, ini ); - s.WorldAOStrength = GetPrivateProfileFloatA( "Shadows", "WorldAOStrength", defaultRendererSettings.WorldAOStrength, ini ); - - INT2 res = {}; - RECT desktopRect; - GetClientRect( GetDesktopWindow(), &desktopRect ); - s.textureMaxSize = std::max( 32, GetPrivateProfileIntA( "Display", "TextureQuality", 16384, ini.c_str() ) ); - res.x = GetPrivateProfileIntA( "Display", "Width", desktopRect.right, ini.c_str() ); - res.y = GetPrivateProfileIntA( "Display", "Height", desktopRect.bottom, ini.c_str() ); - s.EnableVSync = GetPrivateProfileBoolA( "Display", "VSync", false, ini ); - s.ForceFOV = GetPrivateProfileBoolA( "Display", "ForceFOV", defaultRendererSettings.ForceFOV, ini ); - s.FOVHoriz = GetPrivateProfileIntA( "Display", "FOVHoriz", 90, ini.c_str() ); - s.FOVVert = GetPrivateProfileIntA( "Display", "FOVVert", 90, ini.c_str() ); - s.GammaValue = GetPrivateProfileFloatA( "Display", "Gamma", 1.0f, ini ); - s.BrightnessValue = GetPrivateProfileFloatA( "Display", "Brightness", 1.0f, ini ); - s.DisplayFlip = GetPrivateProfileBoolA( "Display", "DisplayFlip", false, ini ); - s.LowLatency = GetPrivateProfileBoolA( "Display", "LowLatency", false, ini ); - s.HDR_Monitor = GetPrivateProfileBoolA( "Display", "HDR_Monitor", false, ini ); - s.StretchWindow = GetPrivateProfileBoolA( "Display", "StretchWindow", false, ini ); - s.GothicUIScale = GetPrivateProfileFloatA( "Display", "UIScale", 1.0f, ini ); - s.EnableRain = GetPrivateProfileBoolA( "Display", "Rain", true, ini ); - s.EnableRainEffects = GetPrivateProfileBoolA( "Display", "RainEffects", true, ini ); - s.LimitLightIntesity = GetPrivateProfileBoolA( "Display", "LimitLightIntesity", false, ini ); - - s.EnableSMAA = GetPrivateProfileBoolA( "SMAA", "Enabled", false, ini ); - s.SharpenFactor = GetPrivateProfileFloatA( "SMAA", "SharpenFactor", 0.30f, ini ); + static XMFLOAT3 defaultLightDirection = XMFLOAT3( 1, 1, 1 ); + + s.EnableShadows = GetPrivateProfileBoolA( "Shadows", "EnableShadows", defaultRendererSettings.EnableShadows, ini ); + s.EnableSoftShadows = GetPrivateProfileBoolA( "Shadows", "EnableSoftShadows", defaultRendererSettings.EnableSoftShadows, ini ); + s.ShadowMapSize = GetPrivateProfileIntA( "Shadows", "ShadowMapSize", defaultRendererSettings.ShadowMapSize, ini.c_str() ); + s.EnablePointlightShadows = GothicRendererSettings::EPointLightShadowMode( GetPrivateProfileIntA( "Shadows", "PointlightShadows", GothicRendererSettings::EPointLightShadowMode::PLS_STATIC_ONLY, ini.c_str() ) ); + s.WorldShadowRangeScale = GetPrivateProfileFloatA( "Shadows", "WorldShadowRangeScale", 1.0f, ini ); + s.EnableDynamicLighting = GetPrivateProfileBoolA( "Shadows", "EnableDynamicLighting", defaultRendererSettings.EnableDynamicLighting, ini ); + s.SmoothShadowCameraUpdate = GetPrivateProfileBoolA( "Shadows", "SmoothCameraUpdate", defaultRendererSettings.SmoothShadowCameraUpdate, ini ); + s.ShadowStrength = GetPrivateProfileFloatA( "Shadows", "ShadowStrength", defaultRendererSettings.ShadowStrength, ini ); + s.ShadowAOStrength = GetPrivateProfileFloatA( "Shadows", "ShadowAOStrength", defaultRendererSettings.ShadowAOStrength, ini ); + s.WorldAOStrength = GetPrivateProfileFloatA( "Shadows", "WorldAOStrength", defaultRendererSettings.WorldAOStrength, ini ); + + INT2 res = {}; + RECT desktopRect; + GetClientRect( GetDesktopWindow(), &desktopRect ); + s.textureMaxSize = std::max( 32, GetPrivateProfileIntA( "Display", "TextureQuality", 16384, ini.c_str() ) ); + res.x = GetPrivateProfileIntA( "Display", "Width", desktopRect.right, ini.c_str() ); + res.y = GetPrivateProfileIntA( "Display", "Height", desktopRect.bottom, ini.c_str() ); + s.EnableVSync = GetPrivateProfileBoolA( "Display", "VSync", false, ini ); + s.ForceFOV = GetPrivateProfileBoolA( "Display", "ForceFOV", defaultRendererSettings.ForceFOV, ini ); + s.FOVHoriz = GetPrivateProfileIntA( "Display", "FOVHoriz", 90, ini.c_str() ); + s.FOVVert = GetPrivateProfileIntA( "Display", "FOVVert", 90, ini.c_str() ); + s.GammaValue = GetPrivateProfileFloatA( "Display", "Gamma", 1.0f, ini ); + s.BrightnessValue = GetPrivateProfileFloatA( "Display", "Brightness", 1.0f, ini ); + s.DisplayFlip = GetPrivateProfileBoolA( "Display", "DisplayFlip", false, ini ); + s.LowLatency = GetPrivateProfileBoolA( "Display", "LowLatency", false, ini ); + s.HDR_Monitor = GetPrivateProfileBoolA( "Display", "HDR_Monitor", false, ini ); + s.StretchWindow = GetPrivateProfileBoolA( "Display", "StretchWindow", false, ini ); + s.GothicUIScale = GetPrivateProfileFloatA( "Display", "UIScale", 1.0f, ini ); + s.EnableRain = GetPrivateProfileBoolA( "Display", "Rain", true, ini ); + s.EnableRainEffects = GetPrivateProfileBoolA( "Display", "RainEffects", true, ini ); + s.LimitLightIntesity = GetPrivateProfileBoolA( "Display", "LimitLightIntesity", false, ini ); + + s.EnableSMAA = GetPrivateProfileBoolA( "SMAA", "Enabled", false, ini ); + s.SharpenFactor = GetPrivateProfileFloatA( "SMAA", "SharpenFactor", 0.30f, ini ); + + #if ENABLE_TESSELATION > 0 + s.AllowWorldMeshTesselation = GetPrivateProfileBoolA( "Tesselation", "AllowWorldMeshTesselation", false, ini ); + s.EnableTesselation = GetPrivateProfileBoolA( "Tesselation", "EnableTesselation", false, ini ); + #endif -#if ENABLE_TESSELATION > 0 - s.AllowWorldMeshTesselation = GetPrivateProfileBoolA( "Tesselation", "AllowWorldMeshTesselation", false, ini ); - s.EnableTesselation = GetPrivateProfileBoolA( "Tesselation", "EnableTesselation", false, ini ); -#endif + HBAOSettings defaultHBAOSettings; + s.HbaoSettings.Enabled = GetPrivateProfileBoolA( "HBAO", "Enabled", defaultHBAOSettings.Enabled, ini ); + s.HbaoSettings.Bias = GetPrivateProfileFloatA( "HBAO", "Bias", defaultHBAOSettings.Bias, ini ); + s.HbaoSettings.Radius = GetPrivateProfileFloatA( "HBAO", "Radius", defaultHBAOSettings.Radius, ini ); + s.HbaoSettings.PowerExponent = GetPrivateProfileFloatA( "HBAO", "PowerExponent", defaultHBAOSettings.PowerExponent, ini ); + s.HbaoSettings.BlurSharpness = GetPrivateProfileFloatA( "HBAO", "BlurSharpness", defaultHBAOSettings.BlurSharpness, ini ); + //s.HbaoSettings.EnableDualLayerAO = GetPrivateProfileIntA( "HBAO", "EnableDualLayerAO", defaultHBAOSettings.EnableDualLayerAO, ini.c_str() ); + s.HbaoSettings.EnableBlur = GetPrivateProfileBoolA( "HBAO", "EnableBlur", defaultHBAOSettings.EnableBlur, ini ); + s.HbaoSettings.SsaoBlurRadius = GetPrivateProfileIntA( "HBAO", "SsaoBlurRadius", defaultHBAOSettings.SsaoBlurRadius, ini.c_str() ); + s.HbaoSettings.SsaoStepCount = GetPrivateProfileIntA( "HBAO", "SsaoStepCount", defaultHBAOSettings.SsaoStepCount, ini.c_str() ); + + s.EnableCustomFontRendering = GetPrivateProfileBoolA( "FontRendering", "Enable", defaultRendererSettings.EnableCustomFontRendering, ini ); + + // Fix the shadow range + s.WorldShadowRangeScale = Toolbox::GetRecommendedWorldShadowRangeScaleForSize( s.ShadowMapSize ); + + // Fix the resolution if the players maximum resolution got lower + /*RECT r; + GetClientRect( GetDesktopWindow(), &r ); + if ( res.x > r.right || res.y > r.bottom ) { + LogInfo() << "Reducing resolution from (" << res.x << ", " << res.y << " to (" << r.right << ", " << r.bottom << ") because users desktop resolution got lowered"; + res = INT2( r.right, r.bottom ); + }*/ - HBAOSettings defaultHBAOSettings; - s.HbaoSettings.Enabled = GetPrivateProfileBoolA( "HBAO", "Enabled", defaultHBAOSettings.Enabled, ini ); - s.HbaoSettings.Bias = GetPrivateProfileFloatA( "HBAO", "Bias", defaultHBAOSettings.Bias, ini ); - s.HbaoSettings.Radius = GetPrivateProfileFloatA( "HBAO", "Radius", defaultHBAOSettings.Radius, ini ); - s.HbaoSettings.PowerExponent = GetPrivateProfileFloatA( "HBAO", "PowerExponent", defaultHBAOSettings.PowerExponent, ini ); - s.HbaoSettings.BlurSharpness = GetPrivateProfileFloatA( "HBAO", "BlurSharpness", defaultHBAOSettings.BlurSharpness, ini ); - //s.HbaoSettings.EnableDualLayerAO = GetPrivateProfileIntA( "HBAO", "EnableDualLayerAO", defaultHBAOSettings.EnableDualLayerAO, ini.c_str() ); - s.HbaoSettings.EnableBlur = GetPrivateProfileBoolA( "HBAO", "EnableBlur", defaultHBAOSettings.EnableBlur, ini ); - s.HbaoSettings.SsaoBlurRadius = GetPrivateProfileIntA( "HBAO", "SsaoBlurRadius", defaultHBAOSettings.SsaoBlurRadius, ini.c_str() ); - s.HbaoSettings.SsaoStepCount = GetPrivateProfileIntA( "HBAO", "SsaoStepCount", defaultHBAOSettings.SsaoStepCount, ini.c_str() ); - - s.EnableCustomFontRendering = GetPrivateProfileBoolA( "FontRendering", "Enable", defaultRendererSettings.EnableCustomFontRendering, ini ); - - // Fix the shadow range - s.WorldShadowRangeScale = Toolbox::GetRecommendedWorldShadowRangeScaleForSize( s.ShadowMapSize ); - - // Fix the resolution if the players maximum resolution got lower - /*RECT r; - GetClientRect( GetDesktopWindow(), &r ); - if ( res.x > r.right || res.y > r.bottom ) { - LogInfo() << "Reducing resolution from (" << res.x << ", " << res.y << " to (" << r.right << ", " << r.bottom << ") because users desktop resolution got lowered"; - res = INT2( r.right, r.bottom ); - }*/ - - res.x = std::max( res.x, 800 ); - res.y = std::max( res.y, 600 ); - s.LoadedResolution = res; + res.x = std::max( res.x, 800 ); + res.y = std::max( res.y, 600 ); + s.LoadedResolution = res; + } LogInfo() << "Applying Commandline-Overrides ..."; // Override Settings from Commandline Parameters From 542b9a7c4b9b629dda9af14907713b89f3998a00 Mon Sep 17 00:00:00 2001 From: SaiyansKing <38609240+SaiyansKing@users.noreply.github.com> Date: Fri, 23 Dec 2022 19:44:45 +0100 Subject: [PATCH 3/5] Save StretchWindow variable for different window modes --- D3D11Engine/GothicAPI.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/D3D11Engine/GothicAPI.cpp b/D3D11Engine/GothicAPI.cpp index 57b61b14..571f7bba 100644 --- a/D3D11Engine/GothicAPI.cpp +++ b/D3D11Engine/GothicAPI.cpp @@ -4138,6 +4138,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { zCOption::GetOptions()->WriteString( section, "zStartupWindowed", defValue ); WritePrivateProfileStringA( "Display", "DisplayFlip", "0", ini.c_str() ); WritePrivateProfileStringA( "Display", "LowLatency", "0", ini.c_str() ); + WritePrivateProfileStringA( "Display", "StretchWindow", "1", ini.c_str() ); break; } case WINDOW_MODE_FULLSCREEN_BORDERLESS: { @@ -4146,6 +4147,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { s.StretchWindow = true; WritePrivateProfileStringA( "Display", "DisplayFlip", "1", ini.c_str() ); WritePrivateProfileStringA( "Display", "LowLatency", "0", ini.c_str() ); + WritePrivateProfileStringA( "Display", "StretchWindow", "1", ini.c_str() ); break; } case WINDOW_MODE_FULLSCREEN_LOWLATENCY: { @@ -4154,6 +4156,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { s.StretchWindow = true; WritePrivateProfileStringA( "Display", "DisplayFlip", "1", ini.c_str() ); WritePrivateProfileStringA( "Display", "LowLatency", "1", ini.c_str() ); + WritePrivateProfileStringA( "Display", "StretchWindow", "1", ini.c_str() ); break; } case WINDOW_MODE_WINDOWED: { @@ -4163,6 +4166,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { zCOption::GetOptions()->WriteString( section, "zStartupWindowed", defValue ); WritePrivateProfileStringA( "Display", "DisplayFlip", "0", ini.c_str() ); WritePrivateProfileStringA( "Display", "LowLatency", "0", ini.c_str() ); + WritePrivateProfileStringA( "Display", "StretchWindow", "0", ini.c_str() ); break; } } From 50d0dcfd3e954ae3d6b5221bd15c0eec28b9a7c0 Mon Sep 17 00:00:00 2001 From: SaiyansKing <38609240+SaiyansKing@users.noreply.github.com> Date: Fri, 23 Dec 2022 22:56:54 +0100 Subject: [PATCH 4/5] Update GothicAPI.cpp --- D3D11Engine/GothicAPI.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/D3D11Engine/GothicAPI.cpp b/D3D11Engine/GothicAPI.cpp index 571f7bba..05dcbb4f 100644 --- a/D3D11Engine/GothicAPI.cpp +++ b/D3D11Engine/GothicAPI.cpp @@ -3990,7 +3990,7 @@ XRESULT GothicAPI::LoadMenuSettings( const std::string& file ) { auto ini = std::string( NPath, len ).append( "\\" + file ); GothicRendererSettings& s = RendererState.RendererSettings; - if ( !Toolbox::FileExists( ini ) ) { + if ( Toolbox::FileExists( ini ) ) { LogInfo() << "Loading menu settings from " << ini; GothicRendererSettings defaultRendererSettings; From 7a4acfffe778ce1630c12f0e6c0600818a09094c Mon Sep 17 00:00:00 2001 From: SaiyansKing <38609240+SaiyansKing@users.noreply.github.com> Date: Sat, 24 Dec 2022 01:50:48 +0100 Subject: [PATCH 5/5] Use C++17 std::filesystem for some file operations --- D3D11Engine/D3D11GraphicsEngine.cpp | 11 +++++---- D3D11Engine/Toolbox.cpp | 36 +++++++++++------------------ D3D11Engine/pch.h | 1 + 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/D3D11Engine/D3D11GraphicsEngine.cpp b/D3D11Engine/D3D11GraphicsEngine.cpp index 4371bbda..ff66bd0e 100644 --- a/D3D11Engine/D3D11GraphicsEngine.cpp +++ b/D3D11Engine/D3D11GraphicsEngine.cpp @@ -6260,6 +6260,12 @@ void D3D11GraphicsEngine::UpdateOcclusion() { void D3D11GraphicsEngine::SaveScreenshot() { HRESULT hr; + // Create new folder if needed + if ( !Toolbox::FolderExists( "system\\Screenshots" ) ) { + if ( !Toolbox::CreateDirectoryRecursive( "system\\Screenshots" ) ) + return; + } + // Buffer for scaling down the image auto rt = std::make_unique( GetDevice().Get(), Resolution.x, Resolution.y, DXGI_FORMAT_R8G8B8A8_UNORM ); @@ -6295,9 +6301,6 @@ void D3D11GraphicsEngine::SaveScreenshot() { GetDateFormat( LOCALE_SYSTEM_DEFAULT, 0, nullptr, "yyyy-MM-dd", date, 50 ); GetTimeFormat( LOCALE_SYSTEM_DEFAULT, 0, nullptr, "hh-mm-ss", time, 50 ); - // Create new folder if needed - CreateDirectory( "system\\Screenshots", nullptr ); - std::string name = "system\\screenshots\\GD3D11_" + std::string( date ) + "__" + std::string( time ) + ".jpg"; @@ -6313,7 +6316,7 @@ void D3D11GraphicsEngine::SaveScreenshot() { varValues[0].vt = VT_R4; varValues[0].fltVal = 0.95f; - (void)props->Write( 1, options, varValues ); + props->Write( 1, options, varValues ); }, false ) ); // Inform the user that a screenshot has been taken diff --git a/D3D11Engine/Toolbox.cpp b/D3D11Engine/Toolbox.cpp index b21130af..f2d858f6 100644 --- a/D3D11Engine/Toolbox.cpp +++ b/D3D11Engine/Toolbox.cpp @@ -94,25 +94,19 @@ namespace Toolbox { } bool CreateDirectoryRecursive( const std::string& dirName ) { - unsigned int pos = 0; - do { - pos = dirName.find_first_of( "\\/", pos + 1 ); - if ( CreateDirectory( dirName.substr( 0, pos ).c_str(), NULL ) == 0 && GetLastError() != ERROR_ALREADY_EXISTS ) { - return false; - } - } while ( pos != std::string::npos ); - return true; + try { + return std::filesystem::create_directories( dirName ); + } catch ( const std::exception& e ) { + return false; + } } bool FolderExists( const std::string& dirName_in ) { - DWORD ftyp = GetFileAttributesA( dirName_in.c_str() ); - if ( ftyp == INVALID_FILE_ATTRIBUTES ) - return false; //something is wrong with your path! - - if ( ftyp & FILE_ATTRIBUTE_DIRECTORY ) - return true; // this is a directory! - - return false; // this is not a directory! + try { + return std::filesystem::is_directory( dirName_in ); + } catch ( const std::exception& e ) { + return false; + } } static std::size_t hash_value( float value ) { @@ -305,13 +299,11 @@ namespace Toolbox { /** Returns whether the given file exists */ bool FileExists( const std::string& file ) { - FILE* f = fopen( file.c_str(), "rb" ); - - if ( f ) { - fclose( f ); - return true; + try { + return std::filesystem::exists( file ); + } catch ( const std::exception& e ) { + return false; } - return false; } /** Saves a std::string to a FILE* */ diff --git a/D3D11Engine/pch.h b/D3D11Engine/pch.h index e97e6b47..3d615c93 100644 --- a/D3D11Engine/pch.h +++ b/D3D11Engine/pch.h @@ -16,6 +16,7 @@ #include #include #include +#include #include "Logger.h" #include "Types.h"