From 69fc0010e935a16c0d4f79e698fed21fa7b9d1ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Sat, 21 Dec 2024 22:46:35 +0800 Subject: [PATCH] . --- cpp/LunaHook/LunaHook/embed_util.cc | 11 ++++++++++- cpp/LunaHook/LunaHost/LunaHostDll.cpp | 4 ++-- cpp/LunaHook/include/types.h | 9 +++++++-- cpp/shareddllproxy/aspatch.cpp | 4 ++-- py/LunaTranslator/gui/setting_textinput.py | 7 ++++--- py/LunaTranslator/textsource/texthook.py | 2 +- py/files/defaultconfig/config.json | 2 +- py/files/lang/ar.json | 3 ++- py/files/lang/cht.json | 3 ++- py/files/lang/cs.json | 3 ++- py/files/lang/de.json | 3 ++- py/files/lang/en.json | 3 ++- py/files/lang/es.json | 3 ++- py/files/lang/fr.json | 3 ++- py/files/lang/it.json | 3 ++- py/files/lang/ja.json | 3 ++- py/files/lang/ko.json | 3 ++- py/files/lang/nl.json | 3 ++- py/files/lang/pl.json | 3 ++- py/files/lang/pt.json | 3 ++- py/files/lang/ru.json | 3 ++- py/files/lang/sv.json | 3 ++- py/files/lang/th.json | 3 ++- py/files/lang/tr.json | 3 ++- py/files/lang/uk.json | 3 ++- py/files/lang/vi.json | 3 ++- py/files/lang/zh.json | 3 ++- 27 files changed, 67 insertions(+), 32 deletions(-) diff --git a/cpp/LunaHook/LunaHook/embed_util.cc b/cpp/LunaHook/LunaHook/embed_util.cc index fbf1fb22..602016e2 100644 --- a/cpp/LunaHook/LunaHook/embed_util.cc +++ b/cpp/LunaHook/LunaHook/embed_util.cc @@ -274,8 +274,17 @@ bool TextHook::waitfornotify(TextBuffer *buff, ThreadParam tp) if (hp.lineSeparator) strReplace(translate, L"\n", hp.lineSeparator); translate = adjustSpacesSTD(translate, hp); - if (commonsharedmem->keeprawtext) + switch (commonsharedmem->displaymode) + { + case Displaymode::TRANS: + break; + case Displaymode::ORI_TRANS: translate = origin + L" " + translate; + break; + case Displaymode::TRANS_ORI: + translate = translate + L" " + origin; + break; + } solvefont(hp); cast_back(hp, buff, translate, false); return true; diff --git a/cpp/LunaHook/LunaHost/LunaHostDll.cpp b/cpp/LunaHook/LunaHost/LunaHostDll.cpp index e70642cc..f2bac7da 100644 --- a/cpp/LunaHook/LunaHost/LunaHostDll.cpp +++ b/cpp/LunaHook/LunaHost/LunaHostDll.cpp @@ -103,7 +103,7 @@ C_LUNA_API void Luna_FindHooks(DWORD pid, SearchParam sp, findhookcallback_t fin wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode); findhookcallback(hookcode,text.c_str()); }); } -C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 keeprawtext, bool fastskipignore) +C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, Displaymode displaymode, bool fastskipignore) { auto sm = Host::GetCommonSharedMem(pid); if (!sm) @@ -112,7 +112,7 @@ C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet sm->fontCharSet = fontCharSet; sm->fontCharSetEnabled = fontCharSetEnabled; wcscpy_s(sm->fontFamily, 100, fontFamily); - sm->keeprawtext = keeprawtext; + sm->displaymode = displaymode; sm->fastskipignore = fastskipignore; } C_LUNA_API bool Luna_checkisusingembed(ThreadParam tp) diff --git a/cpp/LunaHook/include/types.h b/cpp/LunaHook/include/types.h index e00ea248..b50072ed 100644 --- a/cpp/LunaHook/include/types.h +++ b/cpp/LunaHook/include/types.h @@ -375,11 +375,16 @@ struct TextBuffer size = 0; } }; - +enum class Displaymode +{ + TRANS, + ORI_TRANS, + TRANS_ORI +}; struct CommonSharedMem { UINT32 waittime; - UINT32 keeprawtext; + Displaymode displaymode; uint64_t hash; wchar_t text[1000]; bool fontCharSetEnabled; diff --git a/cpp/shareddllproxy/aspatch.cpp b/cpp/shareddllproxy/aspatch.cpp index 2dbab915..4552cd90 100644 --- a/cpp/shareddllproxy/aspatch.cpp +++ b/cpp/shareddllproxy/aspatch.cpp @@ -92,7 +92,7 @@ std::map translation; std::unordered_set connectedpids; void (*Luna_Start)(ProcessEvent Connect, ProcessEvent Disconnect, void *, void *, void *, void *, HookInsertHandler hookinsert, EmbedCallback embed); void (*Luna_Inject)(DWORD pid, LPCWSTR basepath); -void (*Luna_EmbedSettings)(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, UINT32 keeprawtext, bool fastskipignore); +void (*Luna_EmbedSettings)(DWORD pid, UINT32 waittime, UINT8 fontCharSet, bool fontCharSetEnabled, wchar_t *fontFamily, int displaymode, bool fastskipignore); void (*Luna_useembed)(ThreadParam, bool use); void (*Luna_embedcallback)(ThreadParam, LPCWSTR text, LPCWSTR trans); std::set notranslation; @@ -118,7 +118,7 @@ public: Luna_Start( [](DWORD pid) { - Luna_EmbedSettings(pid, 1000 * config["embedsettings"]["timeout_translate"], 2, false, config["embedsettings"]["changefont"] ? (StringToWideString(config["embedsettings"]["changefont_font"]).data()) : L"", config["embedsettings"]["keeprawtext"], false); + Luna_EmbedSettings(pid, 1000 * config["embedsettings"]["timeout_translate"], 2, false, config["embedsettings"]["changefont"] ? (StringToWideString(config["embedsettings"]["changefont_font"]).data()) : L"", config["embedsettings"]["displaymode"], false); connectedpids.insert(pid); }, [](DWORD pid) diff --git a/py/LunaTranslator/gui/setting_textinput.py b/py/LunaTranslator/gui/setting_textinput.py index fc3d6fa6..648e7209 100644 --- a/py/LunaTranslator/gui/setting_textinput.py +++ b/py/LunaTranslator/gui/setting_textinput.py @@ -66,10 +66,11 @@ def gethookgrid_em(self): "", ], [ - "保留原文", - D_getsimpleswitch( + "显示模式", + D_getsimplecombobox( + ["翻译", "原文_翻译", "翻译_原文"], globalconfig["embedded"], - "keeprawtext", + "displaymode", callback=lambda _: gobject.baseobject.textsource.flashembedsettings(), ), ], diff --git a/py/LunaTranslator/textsource/texthook.py b/py/LunaTranslator/textsource/texthook.py index 3572bfe4..d5bd63e8 100644 --- a/py/LunaTranslator/textsource/texthook.py +++ b/py/LunaTranslator/textsource/texthook.py @@ -525,7 +525,7 @@ class texthook(basetext): if globalconfig["embedded"]["changefont"] else "" ), - globalconfig["embedded"]["keeprawtext"], + globalconfig["embedded"]["displaymode"], True, ) diff --git a/py/files/defaultconfig/config.json b/py/files/defaultconfig/config.json index 70604f2e..dfcf43c4 100644 --- a/py/files/defaultconfig/config.json +++ b/py/files/defaultconfig/config.json @@ -316,7 +316,7 @@ "use_appointed_translate": false, "timeout_translate": 2, "trans_kanji": false, - "keeprawtext": false, + "displaymode": 0, "insertspace_policy": 0, "changefont": false, "changefont_font": "", diff --git a/py/files/lang/ar.json b/py/files/lang/ar.json index aa450fc7..ddb25dd3 100644 --- a/py/files/lang/ar.json +++ b/py/files/lang/ar.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "فتح نافذة اختيار النص", "成功": "النجاح .", "Win32通用钩子": "win32 هوك العالمي", - "特殊码无效": "رمز خاص غير صالح" + "特殊码无效": "رمز خاص غير صالح", + "显示模式": "طريقة العرض" } \ No newline at end of file diff --git a/py/files/lang/cht.json b/py/files/lang/cht.json index 79b943ea..05f1eb03 100644 --- a/py/files/lang/cht.json +++ b/py/files/lang/cht.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "打開選擇文字視窗", "成功": "成功", "Win32通用钩子": "Win32通用鉤子", - "特殊码无效": "特殊碼無效" + "特殊码无效": "特殊碼無效", + "显示模式": "顯示模式" } \ No newline at end of file diff --git a/py/files/lang/cs.json b/py/files/lang/cs.json index bdfc0e6a..8074898a 100644 --- a/py/files/lang/cs.json +++ b/py/files/lang/cs.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Otevřít textové okno výběru", "成功": "úspěch", "Win32通用钩子": "Univerzální hák Win32", - "特殊码无效": "Speciální kód je neplatný" + "特殊码无效": "Speciální kód je neplatný", + "显示模式": "režim zobrazení" } \ No newline at end of file diff --git a/py/files/lang/de.json b/py/files/lang/de.json index 7dc30c41..aa34e939 100644 --- a/py/files/lang/de.json +++ b/py/files/lang/de.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Öffnen des Auswahltextfensters", "成功": "Erfolg", "Win32通用钩子": "Win32 Universal Hook", - "特殊码无效": "Der spezielle Code ist ungültig" + "特殊码无效": "Der spezielle Code ist ungültig", + "显示模式": "Anzeigemodus" } \ No newline at end of file diff --git a/py/files/lang/en.json b/py/files/lang/en.json index 7a5160c3..114d10a0 100644 --- a/py/files/lang/en.json +++ b/py/files/lang/en.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Open the selection text window", "成功": "success", "Win32通用钩子": "Win32 Universal Hook", - "特殊码无效": "The special code is invalid" + "特殊码无效": "The special code is invalid", + "显示模式": "display mode" } \ No newline at end of file diff --git a/py/files/lang/es.json b/py/files/lang/es.json index 11fee3d5..c101e84a 100644 --- a/py/files/lang/es.json +++ b/py/files/lang/es.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Abrir la ventana de texto de selección", "成功": "éxito", "Win32通用钩子": "Gancho universal Win32", - "特殊码无效": "El código especial no es válido" + "特殊码无效": "El código especial no es válido", + "显示模式": "Modo de visualización" } \ No newline at end of file diff --git a/py/files/lang/fr.json b/py/files/lang/fr.json index 07e54073..3e66fdf8 100644 --- a/py/files/lang/fr.json +++ b/py/files/lang/fr.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Ouvrir la fenêtre sélectionner le texte", "成功": "Succès", "Win32通用钩子": "Win32 crochet universel", - "特殊码无效": "Code spécial invalide" + "特殊码无效": "Code spécial invalide", + "显示模式": "Mode d'affichage" } \ No newline at end of file diff --git a/py/files/lang/it.json b/py/files/lang/it.json index 201e88ab..7ef05396 100644 --- a/py/files/lang/it.json +++ b/py/files/lang/it.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Apri la finestra del testo di selezione", "成功": "successo", "Win32通用钩子": "Win32 Universal Hook", - "特殊码无效": "Il codice speciale non è valido" + "特殊码无效": "Il codice speciale non è valido", + "显示模式": "modalità di visualizzazione" } \ No newline at end of file diff --git a/py/files/lang/ja.json b/py/files/lang/ja.json index ac24b913..847cbce1 100644 --- a/py/files/lang/ja.json +++ b/py/files/lang/ja.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "テキストの選択ウィンドウを開く", "成功": "成功", "Win32通用钩子": "Win 32汎用フック", - "特殊码无效": "特殊コードが無効です" + "特殊码无效": "特殊コードが無効です", + "显示模式": "表示モード" } \ No newline at end of file diff --git a/py/files/lang/ko.json b/py/files/lang/ko.json index 32f33fa3..8dc1910a 100644 --- a/py/files/lang/ko.json +++ b/py/files/lang/ko.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "텍스트 선택 창 열기", "成功": "성공", "Win32通用钩子": "Win32 범용 갈고리", - "特殊码无效": "잘못된 특수 코드" + "特殊码无效": "잘못된 특수 코드", + "显示模式": "디스플레이 모드" } \ No newline at end of file diff --git a/py/files/lang/nl.json b/py/files/lang/nl.json index 23196361..36b2a180 100644 --- a/py/files/lang/nl.json +++ b/py/files/lang/nl.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Het selectietekstvenster openen", "成功": "succes", "Win32通用钩子": "Win32 universele haak", - "特殊码无效": "De speciale code is ongeldig" + "特殊码无效": "De speciale code is ongeldig", + "显示模式": "weergavemodus" } \ No newline at end of file diff --git a/py/files/lang/pl.json b/py/files/lang/pl.json index 14ae4e4e..223d2c5e 100644 --- a/py/files/lang/pl.json +++ b/py/files/lang/pl.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Otwórz okno tekstowe zaznaczenia", "成功": "sukces", "Win32通用钩子": "Uniwersalny hak Win32", - "特殊码无效": "Kod specjalny jest nieprawidłowy" + "特殊码无效": "Kod specjalny jest nieprawidłowy", + "显示模式": "tryb wyświetlania" } \ No newline at end of file diff --git a/py/files/lang/pt.json b/py/files/lang/pt.json index d85e71e3..4aac2eae 100644 --- a/py/files/lang/pt.json +++ b/py/files/lang/pt.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Abrir a janela de texto da selecção", "成功": "sucesso", "Win32通用钩子": "Gancho Universal Win32", - "特殊码无效": "O código especial é inválido" + "特殊码无效": "O código especial é inválido", + "显示模式": "modo de visualização" } \ No newline at end of file diff --git a/py/files/lang/ru.json b/py/files/lang/ru.json index 7c2366b5..a52e529d 100644 --- a/py/files/lang/ru.json +++ b/py/files/lang/ru.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Открыть окно выбора текста", "成功": "Успех", "Win32通用钩子": "Win32 Универсальный крюк", - "特殊码无效": "Специальный код не работает." + "特殊码无效": "Специальный код не работает.", + "显示模式": "Показать режим" } \ No newline at end of file diff --git a/py/files/lang/sv.json b/py/files/lang/sv.json index f785ab29..09c9d7f2 100644 --- a/py/files/lang/sv.json +++ b/py/files/lang/sv.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Öppna markeringstextfönstret", "成功": "framgång", "Win32通用钩子": "Win32 universalkrok", - "特殊码无效": "Specialkoden är ogiltig" + "特殊码无效": "Specialkoden är ogiltig", + "显示模式": "visningsläge" } \ No newline at end of file diff --git a/py/files/lang/th.json b/py/files/lang/th.json index 59e1f70e..97b75b0d 100644 --- a/py/files/lang/th.json +++ b/py/files/lang/th.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "เปิดหน้าต่างเลือกข้อความ", "成功": "ความสำเร็จ", "Win32通用钩子": "ตะขอสากล Win32", - "特殊码无效": "รหัสพิเศษไม่ถูกต้อง" + "特殊码无效": "รหัสพิเศษไม่ถูกต้อง", + "显示模式": "โหมดการแสดงผล" } \ No newline at end of file diff --git a/py/files/lang/tr.json b/py/files/lang/tr.json index 14873ef4..5c242db2 100644 --- a/py/files/lang/tr.json +++ b/py/files/lang/tr.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Seçim metin penceresini aç", "成功": "başarılı", "Win32通用钩子": "Win32 Universal Hook", - "特殊码无效": "Özel kodu geçersiz." + "特殊码无效": "Özel kodu geçersiz.", + "显示模式": "Görüntü modusu" } \ No newline at end of file diff --git a/py/files/lang/uk.json b/py/files/lang/uk.json index 1ddc57f7..7e203af0 100644 --- a/py/files/lang/uk.json +++ b/py/files/lang/uk.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Відкрити текстове вікно вибору", "成功": "успіх", "Win32通用钩子": "Win32 Universal Hook", - "特殊码无效": "Некоректний особливий код" + "特殊码无效": "Некоректний особливий код", + "显示模式": "режим показу" } \ No newline at end of file diff --git a/py/files/lang/vi.json b/py/files/lang/vi.json index 8214841c..aa6dd03f 100644 --- a/py/files/lang/vi.json +++ b/py/files/lang/vi.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "Mở cửa sổ Select Text", "成功": "Thành công", "Win32通用钩子": "Win32 phổ Hook", - "特殊码无效": "Mã đặc biệt không hợp lệ" + "特殊码无效": "Mã đặc biệt không hợp lệ", + "显示模式": "Chế độ hiển thị" } \ No newline at end of file diff --git a/py/files/lang/zh.json b/py/files/lang/zh.json index 69710a44..41d1fd4e 100644 --- a/py/files/lang/zh.json +++ b/py/files/lang/zh.json @@ -755,5 +755,6 @@ "打开选择文本窗口": "", "成功": "", "Win32通用钩子": "", - "特殊码无效": "" + "特殊码无效": "", + "显示模式": "" } \ No newline at end of file