diff --git a/cpp/LunaHook/LunaHook/engine64/UnrealEngine.cpp b/cpp/LunaHook/LunaHook/engine64/UnrealEngine.cpp index df4dff19..21925a73 100644 --- a/cpp/LunaHook/LunaHook/engine64/UnrealEngine.cpp +++ b/cpp/LunaHook/LunaHook/engine64/UnrealEngine.cpp @@ -23,7 +23,7 @@ bool InsertENTERGRAM() 0x48, 0x89, 0x6C, 0x24, 0x40, 0x48, 0x0F, 0x45, 0xF8}; auto addr = MemDbg::findBytes(BYTES, sizeof(BYTES), processStartAddress, processStopAddress); - if (addr == 0) + if (!addr) return false; HookParam hp; hp.address = addr + 14; @@ -33,7 +33,34 @@ bool InsertENTERGRAM() hp.lineSeparator = L"\\n"; return NewHook(hp, "UnrealEngine"); } +namespace +{ + bool ue5() + { + // https://github.com/HIllya51/LunaTranslator/issues/1175 + const BYTE BYTES[] = { + 0x48, 0x89, 0x5C, 0x24, 0x08, 0x48, 0x89, 0x6C, 0x24, 0x10, 0x48, 0x89, 0x74, 0x24, 0x18, 0x57, 0x41, 0x56, 0x41, 0x57, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x8B, 0x59, 0x10, 0x45, 0x33, 0xF6, 0x4C, 0x8B, 0xFA, 0x48, 0x8B, 0xF1, 0x48, 0x85, 0xDB, 0x74, XX, 0x8B, 0x43, 0x08, 0x85, 0xC0, 0x74, XX, 0x8D, 0x48, 0x01, 0xF0, 0x0F, 0xB1, 0x4B, 0x08, 0x74, XX, 0x85, 0xc0, 0x75, XX, 0x33, 0xdb, 0x49, 0x8b, 0x06, 0xb9, 0x40, 0x00, 0x00, 0x00}; + auto addr = MemDbg::findBytes(BYTES, sizeof(BYTES), processStartAddress, processStopAddress); + if (!addr) + return false; + HookParam hp; + hp.address = addr; + hp.type = USING_STRING | CODEC_UTF16 | NO_CONTEXT; + hp.offset = get_stack(5); + hp.filter_fun = [](TextBuffer *buffer, HookParam *hp) + { + auto s = buffer->strW(); + static std::wstring last; + if (startWith(s, last)) + { + buffer->from(s.substr(last.size(), s.size() - last.size())); + } + last = s; + }; + return NewHook(hp, "UnrealEngine5"); + } +} bool UnrealEngine::attach_function() { - return InsertENTERGRAM(); + return InsertENTERGRAM() || ue5(); } diff --git a/cpp/LunaHook/LunaHook/engine64/UnrealEngine.h b/cpp/LunaHook/LunaHook/engine64/UnrealEngine.h index 47083113..39d58983 100644 --- a/cpp/LunaHook/LunaHook/engine64/UnrealEngine.h +++ b/cpp/LunaHook/LunaHook/engine64/UnrealEngine.h @@ -12,7 +12,8 @@ public: { // Copyright Epic Games, Inc. All Rights Reserved. //++UE4+Release-4.27-CL-0 - return Util::SearchResourceString(L"Copyright Epic Games") || Util::SearchResourceString(L"UnrealEngine") || GetProcAddress(GetModuleHandleA(0), "agsCheckDriverVersion"); + //"++UE5+Release-5.0-CL-20979098" + return Util::SearchResourceString(L"Copyright Epic Games") || Util::SearchResourceString(L"UnrealEngine") || Util::SearchResourceString(L"++UE5+Release") || Util::SearchResourceString(L"++UE4+Release"); }; }; bool attach_function(); diff --git a/cpp/LunaHook/LunaHook/engine64/yuzu.cpp b/cpp/LunaHook/LunaHook/engine64/yuzu.cpp index 14234591..a5b86223 100644 --- a/cpp/LunaHook/LunaHook/engine64/yuzu.cpp +++ b/cpp/LunaHook/LunaHook/engine64/yuzu.cpp @@ -1753,6 +1753,21 @@ namespace strReplace(s, "#", ""); buffer->from(s); } + void F01002BB00A662000(TextBuffer *buffer, HookParam *hp) + { + auto s = buffer->strA(); + strReplace(s, "#n", ""); + strReplace(s, "\x81\x40", ""); + s = std::regex_replace(s, std::regex(R"(#Ruby\[(.*?),(.*?)\])"), "$1"); + buffer->from(s); + } + void F01002BB00A662000_1(TextBuffer *buffer, HookParam *hp) + { + F01002BB00A662000(buffer, hp); + auto s = buffer->strA(); + s = std::regex_replace(s, std::regex(R"(#(\w+?)\[[\d,]+?\])"), ""); // #Pos[0,42]#Speed[5]#Effect[0]#Scale[1] + buffer->from(s); + } void F01008BA00F172000(TextBuffer *buffer, HookParam *hp) { auto s = buffer->strA(); @@ -3320,6 +3335,10 @@ namespace // EVE ghost enemies {0x80053900, {0, 1, 0, 0, F01008BA00F172000, "01007BE0160D6000", "1.0.0"}}, {0x80052440, {0, 1, 0, 0, F01008BA00F172000, "01007BE0160D6000", "1.0.1"}}, + // ニル・アドミラリの天秤 色ドリ撫子 + {0x8000BDD0, {0, 8, 0, 0, F01002BB00A662000, "01002BB00A662000", "1.0.0"}}, // text + {0x80019260, {0, 0, 0, 0, F01002BB00A662000_1, "01002BB00A662000", "1.0.0"}}, // name+text + }; return 1; }(); diff --git a/cpp/version.cmake b/cpp/version.cmake index 871d8fcf..60df77d9 100644 --- a/cpp/version.cmake +++ b/cpp/version.cmake @@ -1,7 +1,7 @@ set(VERSION_MAJOR 6) set(VERSION_MINOR 5) -set(VERSION_PATCH 0) +set(VERSION_PATCH 1) set(VERSION_REVISION 0) set(LUNA_VERSION "{${VERSION_MAJOR},${VERSION_MINOR},${VERSION_PATCH},${VERSION_REVISION}}") add_library(VERSION_DEF INTERFACE) diff --git a/py/LunaTranslator/LunaTranslator.py b/py/LunaTranslator/LunaTranslator.py index 84c08cc1..838836ae 100644 --- a/py/LunaTranslator/LunaTranslator.py +++ b/py/LunaTranslator/LunaTranslator.py @@ -9,8 +9,8 @@ from myutils.config import ( savehook_new_data, static_data, getlanguse, - set_font_default, _TR, + get_platform, isascii, ) from myutils.utils import ( @@ -1054,11 +1054,49 @@ class MAINUI: font.setPointSizeF(globalconfig["settingfontsize"]) QApplication.instance().setFont(font) + def get_font_default(self, lang: str, issetting: bool) -> str: + # global font_default_used + # if lang in font_default_used.keys(): + # return font_default_used[lang] + + t = "setting_font_type_default" if issetting else "font_type_default" + l = lang if lang in static_data[t].keys() else "default" + + font_default = "" + + if isinstance(static_data[t][l], list): + fontlist = static_data[t][l] + elif isinstance(static_data[t][l], dict): + if get_platform() == "xp": + target = "xp" + else: + target = "normal" + fontlist = static_data[t][l].get(target, []) + else: + fontlist = [] + is_font_installed = lambda font: QFont(font).exactMatch() + for font in fontlist: + if is_font_installed(font): + font_default = font + break + if font_default == "": + font_default = QFontDatabase.systemFont( + QFontDatabase.SystemFont.GeneralFont + ).family() + + # font_default_used["lang"] = font_default + return font_default + + def set_font_default(self, lang: str, fonttype: str) -> None: + globalconfig[fonttype] = self.get_font_default( + lang, True if fonttype == "settingfonttype" else False + ) + def parsedefaultfont(self): for k in ["fonttype", "fonttype2", "settingfonttype"]: if globalconfig[k] == "": l = "ja" if k == "fonttype" else getlanguse() - set_font_default(l, k) + self.set_font_default(l, k) # globalconfig[k] = QFontDatabase.systemFont( # QFontDatabase.SystemFont.GeneralFont # ).family() diff --git a/py/LunaTranslator/myutils/config.py b/py/LunaTranslator/myutils/config.py index 4d6384eb..c78d5015 100644 --- a/py/LunaTranslator/myutils/config.py +++ b/py/LunaTranslator/myutils/config.py @@ -1,7 +1,6 @@ import json import os, time, uuid, shutil, sys, platform from traceback import print_exc -from qtsymbols import * def isascii(s: str): @@ -727,10 +726,6 @@ def saveallconfig(test=False): ) -def is_font_installed(font: str) -> bool: - return QFont(font).exactMatch() - - # font_default_used = {} def get_platform(): if tuple(sys.version_info)[:2] == (3, 4): @@ -740,42 +735,3 @@ def get_platform(): elif platform.architecture()[0] == "32bit": bit = "32" return bit - - -def get_font_default(lang: str, issetting: bool) -> str: - # global font_default_used - # if lang in font_default_used.keys(): - # return font_default_used[lang] - - t = "setting_font_type_default" if issetting else "font_type_default" - l = lang if lang in static_data[t].keys() else "default" - - font_default = "" - - if isinstance(static_data[t][l], list): - fontlist = static_data[t][l] - elif isinstance(static_data[t][l], dict): - if get_platform() == "xp": - target = "xp" - else: - target = "normal" - fontlist = static_data[t][l].get(target, []) - else: - fontlist = [] - for font in fontlist: - if is_font_installed(font): - font_default = font - break - if font_default == "": - font_default = QFontDatabase.systemFont( - QFontDatabase.SystemFont.GeneralFont - ).family() - - # font_default_used["lang"] = font_default - return font_default - - -def set_font_default(lang: str, fonttype: str) -> None: - globalconfig[fonttype] = get_font_default( - lang, True if fonttype == "settingfonttype" else False - )