-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SF: - Refuse asunc load materials. - Fixed incorrect used QSplashScreen, swap finish() and show(); - Added "Initializing Materials..." in QSplashScreen;
- Loading branch information
Showing
11 changed files
with
160 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsAsync.cpp
This file was deleted.
Oops, something went wrong.
135 changes: 135 additions & 0 deletions
135
Creation Kit Platform Extended Core/Patches/SF/LoadMaterialsQSplash.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
// Copyright © 2023-2024 aka perchik71. All rights reserved. | ||
// Contacts: <email:[email protected]> | ||
// 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<String> 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<void>(pointer_LoadMaterialsQSplashPatch_sub0, arg1, arg2); | ||
} | ||
__except (EXCEPTION_EXECUTE_HANDLER) | ||
{ | ||
return false; | ||
} | ||
|
||
return true; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+0 Bytes
(100%)
Creation Kit Platform Extended Core/Version/build_version.txt
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Creation Kit Platform Extended Core/Version/resource_version2.h
Binary file not shown.
Binary file modified
BIN
+299 Bytes
(100%)
Database/SF/1_14_70_0/CreationKitPlatformExtended_SF_1_14_70_0.database
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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?? |