Add unlock window size. Fixed lyrics localify.

This commit is contained in:
chinosk
2025-03-22 10:56:41 +00:00
parent 1fc9e69ded
commit 4be0798660
10 changed files with 235 additions and 30 deletions
+113
View File
@@ -514,6 +514,26 @@ namespace GakumasLocal::HookMain {
UpdateFont(self);
}
DEFINE_HOOK(void, TMP_Text_SetText_2, (void* self, Il2cppString* sourceText, bool syncTextInputBox, void* mtd)) {
if (!sourceText) {
return TMP_Text_SetText_2_Orig(self, sourceText, syncTextInputBox, mtd);
}
const std::string origText = sourceText->ToString();
std::string transText;
if (Local::GetGenericText(origText, &transText)) {
const auto newText = UnityResolve::UnityType::String::New(transText);
UpdateFont(self);
return TMP_Text_SetText_2_Orig(self, newText, syncTextInputBox, mtd);
}
if (Config::textTest) {
TMP_Text_SetText_2_Orig(self, UnityResolve::UnityType::String::New("[TS]" + sourceText->ToString()), syncTextInputBox, mtd);
}
else {
TMP_Text_SetText_2_Orig(self, sourceText, syncTextInputBox, mtd);
}
UpdateFont(self);
}
DEFINE_HOOK(void, TextMeshProUGUI_Awake, (void* self, void* method)) {
// Log::InfoFmt("TextMeshProUGUI_Awake at %p, self at %p", TextMeshProUGUI_Awake_Orig, self);
@@ -1240,6 +1260,70 @@ namespace GakumasLocal::HookMain {
return ret;
}
#ifdef GKMS_WINDOWS
// DMM Only
DEFINE_HOOK(void*, WindowHandle_SetWindowLong, (int32_t nIndex, intptr_t dwNewLong, void* mtd)) {
if (GakumasLocal::Config::dmmUnlockSize) {
// Log::DebugFmt("WindowHandle_SetWindowLong: %d, %p\n", nIndex, dwNewLong);
if (nIndex == GWLP_WNDPROC) {
return 0;
}
}
return WindowHandle_SetWindowLong_Orig(nIndex, dwNewLong, mtd);
}
// DMM Only
void SetResolution(int width, int height, bool fullscreen) {
static auto Screen_SetResolution = reinterpret_cast<void (*)(UINT, UINT, UINT, void*)>(
Il2cppUtils::il2cpp_resolve_icall("UnityEngine.Screen::SetResolution_Injected(System.Int32,System.Int32,UnityEngine.FullScreenMode,UnityEngine.RefreshRate&)"));
int64_t v8[3];
v8[0] = 0x100000000LL;
Screen_SetResolution(width, height, 2 * !fullscreen + 1, v8);
}
// DMM Only
DEFINE_HOOK(void, WindowManager_ApplyOrientationSettings, (int orientation, void* method)) {
if (!GakumasLocal::Config::dmmUnlockSize) return WindowManager_ApplyOrientationSettings_Orig(orientation, method);
static auto get_Height = reinterpret_cast<int (*)()>(Il2cppUtils::il2cpp_resolve_icall("UnityEngine.Screen::get_height()"));
static auto get_Width = reinterpret_cast<int (*)()>(Il2cppUtils::il2cpp_resolve_icall("UnityEngine.Screen::get_width()"));
static auto lastWidth = -1;
static auto lastHeight = -1;
const auto currWidth = get_Width();
const auto currHeight = get_Height();
if (lastWidth == -1) {
lastWidth = currWidth;
lastHeight = currHeight;
return;
}
const bool lastIsPortrait = lastWidth < lastHeight;
const bool currIsPortrait = currWidth < currHeight;
if (lastIsPortrait == currIsPortrait) {
lastWidth = currWidth;
lastHeight = currHeight;
return;
}
SetResolution(lastWidth, lastHeight, false);
lastWidth = currWidth;
lastHeight = currHeight;
Log::DebugFmt("WindowManager_ApplyOrientationSettings: %d (%d, %d)\n", orientation, get_Width(), get_Height());
}
// DMM Only
DEFINE_HOOK(void, AspectRatioHandler_NudgeWindow, (void* method)) {
if (!GakumasLocal::Config::dmmUnlockSize) return AspectRatioHandler_NudgeWindow_Orig(method);
// printf("AspectRatioHandler_NudgeWindow\n");
}
#endif
void UpdateSwingBreastBonesData(void* initializeData) {
if (!Config::enableBreastParam) return;
@@ -1444,6 +1528,9 @@ namespace GakumasLocal::HookMain {
ADD_HOOK(TMP_Text_PopulateTextBackingArray, Il2cppUtils::GetMethodPointer("Unity.TextMeshPro.dll", "TMPro",
"TMP_Text", "PopulateTextBackingArray",
{"System.String", "System.Int32", "System.Int32"}));
ADD_HOOK(TMP_Text_SetText_2, Il2cppUtils::GetMethodPointer("Unity.TextMeshPro.dll", "TMPro",
"TMP_Text", "SetText",
{ "System.String", "System.Boolean" }));
ADD_HOOK(TextField_set_value, Il2cppUtils::GetMethodPointer("UnityEngine.UIElementsModule.dll", "UnityEngine.UIElements",
"TextField", "set_value"));
@@ -1634,6 +1721,32 @@ namespace GakumasLocal::HookMain {
"RenderPipeline", "EndCameraRendering"));
#ifdef GKMS_WINDOWS
ADD_HOOK(WindowHandle_SetWindowLong, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
"WindowHandle", "SetWindowLong"));
//ADD_HOOK(WindowHandle_SetWindowLong32, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
// "WindowHandle", "SetWindowLong32"));
//ADD_HOOK(WindowHandle_SetWindowLongPtr64, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
// "WindowHandle", "SetWindowLongPtr64"));
//ADD_HOOK(WindowSizeUtility_RestoreWindowSize, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
// "WindowSizeUtility", "RestoreWindowSize"));
ADD_HOOK(WindowManager_ApplyOrientationSettings, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
"WindowManager", "ApplyOrientationSettings"));
ADD_HOOK(AspectRatioHandler_NudgeWindow, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
"AspectRatioHandler", "NudgeWindow"));
//ADD_HOOK(AspectRatioHandler_WindowProc, Il2cppUtils::GetMethodPointer("Assembly-CSharp.dll", "Campus.Common.StandAloneWindow",
// "AspectRatioHandler", "WindowProc"));
if (GakumasLocal::Config::dmmUnlockSize) {
std::thread([]() {
std::this_thread::sleep_for(std::chrono::seconds(3));
auto hWnd = FindWindowW(L"UnityWndClass", L"gakumas");
// 添加可调整大小的边框和最大化按钮
LONG style = GetWindowLong(hWnd, GWL_STYLE);
style |= WS_THICKFRAME | WS_MAXIMIZEBOX;
SetWindowLong(hWnd, GWL_STYLE, style);
}).detach();
}
g_extra_assetbundle_paths.push_back((gakumasLocalPath / "local-files/gakumasassets").string());
LoadExtraAssetBundle();
GkmsResourceUpdate::CheckUpdateFromAPI(false);