diff --git a/Creation Kit Platform Extended Core/Core/EngineSFPatches.cpp b/Creation Kit Platform Extended Core/Core/EngineSFPatches.cpp
index 3909ece..db6b1c5 100644
--- a/Creation Kit Platform Extended Core/Core/EngineSFPatches.cpp
+++ b/Creation Kit Platform Extended Core/Core/EngineSFPatches.cpp
@@ -16,7 +16,7 @@
#include "Patches/SF/RemoveUselessMessagesSF.h"
#include "Patches/SF/RemoveUselessResizeInDialogs.h"
#include "Patches/SF/RemoveThreadDpi.h"
-#include "Patches/SF/LoadMaterialsAsync.h"
+#include "Patches/SF/LoadMaterialsQSplash.h"
#include "Patches/SF/FixQuoteCmdLineSF.h"
#include "Patches/SF/AllowSaveESMandMasterESPSF.h"
@@ -49,7 +49,7 @@ namespace CreationKitPlatformExtended
new Patches::RemoveUselessMessagesPatch(),
//new Patches::RemoveUselessResizeInDialogsPatch(),
new Patches::RemoveThreadDpiPatch(),
- //new Patches::LoadMaterialsAsyncPatch(),
+ new Patches::LoadMaterialsQSplashPatch(),
new Patches::FixQuoteCmdLinePatch(),
new Patches::AllowSaveESMandMasterESPPatch(),
diff --git a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj
index 8a67892..80b2ff4 100644
--- a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj
+++ b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj
@@ -256,7 +256,7 @@
-
+
@@ -656,7 +656,7 @@
-
+
diff --git a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters
index 66e2923..e5a2429 100644
--- a/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters
+++ b/Creation Kit Platform Extended Core/Creation Kit Platform Extended Core.vcxproj.filters
@@ -874,7 +874,7 @@
Patches\SF
-
+
Patches\SF
@@ -2152,7 +2152,7 @@
Patches\SF
-
+
Patches\SF
diff --git a/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.cpp b/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.cpp
deleted file mode 100644
index 54b8f17..0000000
--- a/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright © 2023-2024 aka perchik71. All rights reserved.
-// Contacts:
-// License: https://www.gnu.org/licenses/gpl-3.0.html
-
-#include "Core/Engine.h"
-#include "LoadMaterialsAsync.h"
-
-namespace CreationKitPlatformExtended
-{
- namespace Patches
- {
- namespace Starfield
- {
- uintptr_t pointer_LoadMaterialsAsyncPatch_sub0 = 0;
-
- LoadMaterialsAsyncPatch::LoadMaterialsAsyncPatch() : Module(GlobalEnginePtr)
- {}
-
- bool LoadMaterialsAsyncPatch::HasOption() const
- {
- return false;
- }
-
- bool LoadMaterialsAsyncPatch::HasCanRuntimeDisabled() const
- {
- return false;
- }
-
- const char* LoadMaterialsAsyncPatch::GetOptionName() const
- {
- return nullptr;
- }
-
- const char* LoadMaterialsAsyncPatch::GetName() const
- {
- return "Load Materials Async";
- }
-
- bool LoadMaterialsAsyncPatch::HasDependencies() const
- {
- return false;
- }
-
- Array LoadMaterialsAsyncPatch::GetDependencies() const
- {
- return {};
- }
-
- bool LoadMaterialsAsyncPatch::QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion,
- const char* lpcstrPlatformRuntimeVersion) const
- {
- return eEditorCurrentVersion >= EDITOR_EXECUTABLE_TYPE::EDITOR_STARFIELD_1_14_70_0;
- }
-
- bool LoadMaterialsAsyncPatch::Activate(const Relocator* lpRelocator,
- const RelocationDatabaseItem* lpRelocationDatabaseItem)
- {
- if (lpRelocationDatabaseItem->Version() == 1)
- {
- pointer_LoadMaterialsAsyncPatch_sub0 = _RELDATA_ADDR(0);
- lpRelocator->DetourCall(_RELDATA_RAV(1), (uintptr_t)&sub);
-
- return true;
- }
-
- return false;
- }
-
- bool LoadMaterialsAsyncPatch::Shutdown(const Relocator* lpRelocator,
- const RelocationDatabaseItem* lpRelocationDatabaseItem)
- {
- return false;
- }
-
- void LoadMaterialsAsyncPatch::sub(void* arg1, void* arg2)
- {
- auto mat_thread = std::thread([](void* arg1, void* arg2) {
- fastCall(pointer_LoadMaterialsAsyncPatch_sub0, arg1, arg2);
- }, arg1, arg2);
-
- SetThreadPriority(mat_thread.native_handle(), THREAD_PRIORITY_HIGHEST);
- mat_thread.join();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.cpp b/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.cpp
new file mode 100644
index 0000000..d64122e
--- /dev/null
+++ b/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.cpp
@@ -0,0 +1,135 @@
+// Copyright © 2023-2024 aka perchik71. All rights reserved.
+// Contacts:
+// License: https://www.gnu.org/licenses/gpl-3.0.html
+
+#include "Core/Engine.h"
+#include "LoadMaterialsQSplash.h"
+
+namespace CreationKitPlatformExtended
+{
+ namespace Patches
+ {
+ namespace Starfield
+ {
+ static constexpr const char* MESSAGE = "Initializing Materials...";
+
+ HANDLE g_LoadMaterialsQSplashPatch_wait = NULL;
+ uintptr_t pointer_LoadMaterialsQSplashPatch_sub0 = 0;
+#ifdef _CKPE_WITH_QT5
+ QSplashScreen* g_LoadMaterialsQSplashPatch_logoWin = nullptr;
+ QWidget* g_LoadMaterialsQSplashPatch_mainWin = nullptr;
+#endif // !_CKPE_WITH_QT5
+
+ LoadMaterialsQSplashPatch::LoadMaterialsQSplashPatch() : Module(GlobalEnginePtr)
+ {}
+
+ bool LoadMaterialsQSplashPatch::HasOption() const
+ {
+ return false;
+ }
+
+ bool LoadMaterialsQSplashPatch::HasCanRuntimeDisabled() const
+ {
+ return false;
+ }
+
+ const char* LoadMaterialsQSplashPatch::GetOptionName() const
+ {
+ return nullptr;
+ }
+
+ const char* LoadMaterialsQSplashPatch::GetName() const
+ {
+ return "Load Materials QSplash";
+ }
+
+ bool LoadMaterialsQSplashPatch::HasDependencies() const
+ {
+ return false;
+ }
+
+ Array LoadMaterialsQSplashPatch::GetDependencies() const
+ {
+ return {};
+ }
+
+ bool LoadMaterialsQSplashPatch::QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion,
+ const char* lpcstrPlatformRuntimeVersion) const
+ {
+ return eEditorCurrentVersion >= EDITOR_EXECUTABLE_TYPE::EDITOR_STARFIELD_1_14_70_0;
+ }
+
+ bool LoadMaterialsQSplashPatch::Activate(const Relocator* lpRelocator,
+ const RelocationDatabaseItem* lpRelocationDatabaseItem)
+ {
+#ifdef _CKPE_WITH_QT5
+ if (lpRelocationDatabaseItem->Version() == 1)
+ {
+ // Bethesda error: finish() must be called after show()
+ // READ DOC: https://doc.qt.io/qt-6/qsplashscreen.html#finish
+ // Erase error, replace it with our own
+ lpRelocator->DetourCall(_RELDATA_RAV(0), (uintptr_t)&hk_finish);
+ lpRelocator->PatchNop(_RELDATA_RAV(0) + 5, 0xA);
+
+ *(uintptr_t*)&pointer_LoadMaterialsQSplashPatch_sub0 =
+ voltek::detours_function_class_jump(_RELDATA_ADDR(1), (uintptr_t)&sub);
+
+ return true;
+ }
+#endif // !_CKPE_WITH_QT5
+
+ return false;
+ }
+
+ bool LoadMaterialsQSplashPatch::Shutdown(const Relocator* lpRelocator,
+ const RelocationDatabaseItem* lpRelocationDatabaseItem)
+ {
+ return false;
+ }
+
+#ifdef _CKPE_WITH_QT5
+ void LoadMaterialsQSplashPatch::hk_finish(QSplashScreen* logoWin, QWidget* mainWin)
+ {
+ logoWin->showMessage(MESSAGE, 1, Qt::red);
+ // Instead of QtCore::ProcessMessage, since CKPE Qt is not initialized
+ Utils::ProcessMessage();
+ // Wait loading materials
+ g_LoadMaterialsQSplashPatch_wait = CreateEvent(NULL, TRUE, FALSE, NULL);
+ ResetEvent(g_LoadMaterialsQSplashPatch_wait);
+ WaitForSingleObject(g_LoadMaterialsQSplashPatch_wait, INFINITE);
+ CloseHandle(g_LoadMaterialsQSplashPatch_wait);
+ // Show main window
+ mainWin->show();
+ logoWin->finish(mainWin);
+ }
+#endif // !_CKPE_WITH_QT5
+
+ void LoadMaterialsQSplashPatch::sub(void* arg1, void* arg2)
+ {
+ _CONSOLE(MESSAGE);
+ // To be processed faster by the process
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
+ // Load
+ _CONSOLE("%s %s", MESSAGE, LoadMaterials(arg1, arg2) ? "SUCCESS" : "FATAL");
+ // Return priority
+ SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL);
+ // End loading
+ SetEvent(g_LoadMaterialsQSplashPatch_wait);
+ }
+
+ bool LoadMaterialsQSplashPatch::LoadMaterials(void* arg1, void* arg2)
+ {
+ __try
+ {
+ fastCall(pointer_LoadMaterialsQSplashPatch_sub0, arg1, arg2);
+ }
+ __except (EXCEPTION_EXECUTE_HANDLER)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.h b/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.h
similarity index 68%
rename from Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.h
rename to Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.h
index 305fe70..7dfdbd6 100644
--- a/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.h
+++ b/Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.h
@@ -8,6 +8,11 @@
#include "Core/Relocator.h"
#include "Core/RelocationDatabase.h"
+#ifdef _CKPE_WITH_QT5
+# include "QtWidgets/qwidget.h"
+# include "QtWidgets/qsplashscreen.h"
+#endif // !_CKPE_WITH_QT5
+
namespace CreationKitPlatformExtended
{
namespace Patches
@@ -16,10 +21,10 @@ namespace CreationKitPlatformExtended
{
using namespace CreationKitPlatformExtended::Core;
- class LoadMaterialsAsyncPatch : public Module
+ class LoadMaterialsQSplashPatch : public Module
{
public:
- LoadMaterialsAsyncPatch();
+ LoadMaterialsQSplashPatch();
virtual bool HasOption() const;
virtual bool HasCanRuntimeDisabled() const;
@@ -28,15 +33,20 @@ namespace CreationKitPlatformExtended
virtual bool HasDependencies() const;
virtual Array GetDependencies() const;
+#ifdef _CKPE_WITH_QT5
+ static void hk_finish(QSplashScreen* logoWin, QWidget* mainWin);
+#endif // !_CKPE_WITH_QT5
+
static void sub(void* arg1, void* arg2);
+ static bool LoadMaterials(void* arg1, void* arg2);
protected:
virtual bool QueryFromPlatform(EDITOR_EXECUTABLE_TYPE eEditorCurrentVersion,
const char* lpcstrPlatformRuntimeVersion) const;
virtual bool Activate(const Relocator* lpRelocator, const RelocationDatabaseItem* lpRelocationDatabaseItem);
virtual bool Shutdown(const Relocator* lpRelocator, const RelocationDatabaseItem* lpRelocationDatabaseItem);
private:
- LoadMaterialsAsyncPatch(const LoadMaterialsAsyncPatch&) = default;
- LoadMaterialsAsyncPatch& operator=(const LoadMaterialsAsyncPatch&) = default;
+ LoadMaterialsQSplashPatch(const LoadMaterialsQSplashPatch&) = default;
+ LoadMaterialsQSplashPatch& operator=(const LoadMaterialsQSplashPatch&) = default;
};
}
}
diff --git a/Creation Kit Platform Extended Core/Version/build_version.txt b/Creation Kit Platform Extended Core/Version/build_version.txt
index d06c4bf..26b8d8c 100644
Binary files a/Creation Kit Platform Extended Core/Version/build_version.txt and b/Creation Kit Platform Extended Core/Version/build_version.txt differ
diff --git a/Creation Kit Platform Extended Core/Version/resource_version2.h b/Creation Kit Platform Extended Core/Version/resource_version2.h
index e734571..31d6064 100644
Binary files a/Creation Kit Platform Extended Core/Version/resource_version2.h and b/Creation Kit Platform Extended Core/Version/resource_version2.h differ
diff --git a/Database/SF/1_14_70_0/CreationKitPlatformExtended_SF_1_14_70_0.database b/Database/SF/1_14_70_0/CreationKitPlatformExtended_SF_1_14_70_0.database
index 2552c65..af3f825 100644
Binary files a/Database/SF/1_14_70_0/CreationKitPlatformExtended_SF_1_14_70_0.database and b/Database/SF/1_14_70_0/CreationKitPlatformExtended_SF_1_14_70_0.database differ
diff --git a/Database/SF/1_14_70_0/LoadMaterialsAsync.relb b/Database/SF/1_14_70_0/LoadMaterialsAsync.relb
deleted file mode 100644
index e83a693..0000000
--- a/Database/SF/1_14_70_0/LoadMaterialsAsync.relb
+++ /dev/null
@@ -1,5 +0,0 @@
-Load Materials Async
-1
-extended
-50B86D0 0
-50F2BA0 0
\ No newline at end of file
diff --git a/Database/SF/1_14_70_0/LoadMaterialsQSplash.relb b/Database/SF/1_14_70_0/LoadMaterialsQSplash.relb
new file mode 100644
index 0000000..2bf4d8b
--- /dev/null
+++ b/Database/SF/1_14_70_0/LoadMaterialsQSplash.relb
@@ -0,0 +1,5 @@
+Load Materials QSplash
+1
+extended
+19C2C60 0 FF15????????498BCEFF15????????498BCEE8????????EB??488D8D????????FF15????????498B86????????C680????????01B910030000E8????????488985????????4885C074??
+50B86D0 0 v0_48895C24??574883EC??488BFA488BD9488B89????????48894C24??4885C974??4883C1??E8????????488B8B????????4883C1??E8????????48894424??8B40??894424??48895C24??488D4F??
\ No newline at end of file