This commit is contained in:
恍兮惚兮 2024-12-21 22:46:35 +08:00
parent 9931fd9c2d
commit 69fc0010e9
27 changed files with 67 additions and 32 deletions

View File

@ -274,8 +274,17 @@ bool TextHook::waitfornotify(TextBuffer *buff, ThreadParam tp)
if (hp.lineSeparator) if (hp.lineSeparator)
strReplace(translate, L"\n", hp.lineSeparator); strReplace(translate, L"\n", hp.lineSeparator);
translate = adjustSpacesSTD(translate, hp); translate = adjustSpacesSTD(translate, hp);
if (commonsharedmem->keeprawtext) switch (commonsharedmem->displaymode)
{
case Displaymode::TRANS:
break;
case Displaymode::ORI_TRANS:
translate = origin + L" " + translate; translate = origin + L" " + translate;
break;
case Displaymode::TRANS_ORI:
translate = translate + L" " + origin;
break;
}
solvefont(hp); solvefont(hp);
cast_back(hp, buff, translate, false); cast_back(hp, buff, translate, false);
return true; return true;

View File

@ -103,7 +103,7 @@ C_LUNA_API void Luna_FindHooks(DWORD pid, SearchParam sp, findhookcallback_t fin
wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode); wcscpy_s(hookcode,HOOKCODE_LEN, hp.hookcode);
findhookcallback(hookcode,text.c_str()); }); 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); auto sm = Host::GetCommonSharedMem(pid);
if (!sm) if (!sm)
@ -112,7 +112,7 @@ C_LUNA_API void Luna_EmbedSettings(DWORD pid, UINT32 waittime, UINT8 fontCharSet
sm->fontCharSet = fontCharSet; sm->fontCharSet = fontCharSet;
sm->fontCharSetEnabled = fontCharSetEnabled; sm->fontCharSetEnabled = fontCharSetEnabled;
wcscpy_s(sm->fontFamily, 100, fontFamily); wcscpy_s(sm->fontFamily, 100, fontFamily);
sm->keeprawtext = keeprawtext; sm->displaymode = displaymode;
sm->fastskipignore = fastskipignore; sm->fastskipignore = fastskipignore;
} }
C_LUNA_API bool Luna_checkisusingembed(ThreadParam tp) C_LUNA_API bool Luna_checkisusingembed(ThreadParam tp)

View File

@ -375,11 +375,16 @@ struct TextBuffer
size = 0; size = 0;
} }
}; };
enum class Displaymode
{
TRANS,
ORI_TRANS,
TRANS_ORI
};
struct CommonSharedMem struct CommonSharedMem
{ {
UINT32 waittime; UINT32 waittime;
UINT32 keeprawtext; Displaymode displaymode;
uint64_t hash; uint64_t hash;
wchar_t text[1000]; wchar_t text[1000];
bool fontCharSetEnabled; bool fontCharSetEnabled;

View File

@ -92,7 +92,7 @@ std::map<std::string, std::string> translation;
std::unordered_set<DWORD> connectedpids; std::unordered_set<DWORD> connectedpids;
void (*Luna_Start)(ProcessEvent Connect, ProcessEvent Disconnect, void *, void *, void *, void *, HookInsertHandler hookinsert, EmbedCallback embed); void (*Luna_Start)(ProcessEvent Connect, ProcessEvent Disconnect, void *, void *, void *, void *, HookInsertHandler hookinsert, EmbedCallback embed);
void (*Luna_Inject)(DWORD pid, LPCWSTR basepath); 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_useembed)(ThreadParam, bool use);
void (*Luna_embedcallback)(ThreadParam, LPCWSTR text, LPCWSTR trans); void (*Luna_embedcallback)(ThreadParam, LPCWSTR text, LPCWSTR trans);
std::set<std::string> notranslation; std::set<std::string> notranslation;
@ -118,7 +118,7 @@ public:
Luna_Start( Luna_Start(
[](DWORD pid) [](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); connectedpids.insert(pid);
}, },
[](DWORD pid) [](DWORD pid)

View File

@ -66,10 +66,11 @@ def gethookgrid_em(self):
"", "",
], ],
[ [
"保留原文", "显示模式",
D_getsimpleswitch( D_getsimplecombobox(
["翻译", "原文_翻译", "翻译_原文"],
globalconfig["embedded"], globalconfig["embedded"],
"keeprawtext", "displaymode",
callback=lambda _: gobject.baseobject.textsource.flashembedsettings(), callback=lambda _: gobject.baseobject.textsource.flashembedsettings(),
), ),
], ],

View File

@ -525,7 +525,7 @@ class texthook(basetext):
if globalconfig["embedded"]["changefont"] if globalconfig["embedded"]["changefont"]
else "" else ""
), ),
globalconfig["embedded"]["keeprawtext"], globalconfig["embedded"]["displaymode"],
True, True,
) )

View File

@ -316,7 +316,7 @@
"use_appointed_translate": false, "use_appointed_translate": false,
"timeout_translate": 2, "timeout_translate": 2,
"trans_kanji": false, "trans_kanji": false,
"keeprawtext": false, "displaymode": 0,
"insertspace_policy": 0, "insertspace_policy": 0,
"changefont": false, "changefont": false,
"changefont_font": "", "changefont_font": "",

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "فتح نافذة اختيار النص", "打开选择文本窗口": "فتح نافذة اختيار النص",
"成功": "النجاح .", "成功": "النجاح .",
"Win32通用钩子": "win32 هوك العالمي", "Win32通用钩子": "win32 هوك العالمي",
"特殊码无效": "رمز خاص غير صالح" "特殊码无效": "رمز خاص غير صالح",
"显示模式": "طريقة العرض"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "打開選擇文字視窗", "打开选择文本窗口": "打開選擇文字視窗",
"成功": "成功", "成功": "成功",
"Win32通用钩子": "Win32通用鉤子", "Win32通用钩子": "Win32通用鉤子",
"特殊码无效": "特殊碼無效" "特殊码无效": "特殊碼無效",
"显示模式": "顯示模式"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Otevřít textové okno výběru", "打开选择文本窗口": "Otevřít textové okno výběru",
"成功": "úspěch", "成功": "úspěch",
"Win32通用钩子": "Univerzální hák Win32", "Win32通用钩子": "Univerzální hák Win32",
"特殊码无效": "Speciální kód je neplatný" "特殊码无效": "Speciální kód je neplatný",
"显示模式": "režim zobrazení"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Öffnen des Auswahltextfensters", "打开选择文本窗口": "Öffnen des Auswahltextfensters",
"成功": "Erfolg", "成功": "Erfolg",
"Win32通用钩子": "Win32 Universal Hook", "Win32通用钩子": "Win32 Universal Hook",
"特殊码无效": "Der spezielle Code ist ungültig" "特殊码无效": "Der spezielle Code ist ungültig",
"显示模式": "Anzeigemodus"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Open the selection text window", "打开选择文本窗口": "Open the selection text window",
"成功": "success", "成功": "success",
"Win32通用钩子": "Win32 Universal Hook", "Win32通用钩子": "Win32 Universal Hook",
"特殊码无效": "The special code is invalid" "特殊码无效": "The special code is invalid",
"显示模式": "display mode"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Abrir la ventana de texto de selección", "打开选择文本窗口": "Abrir la ventana de texto de selección",
"成功": "éxito", "成功": "éxito",
"Win32通用钩子": "Gancho universal Win32", "Win32通用钩子": "Gancho universal Win32",
"特殊码无效": "El código especial no es válido" "特殊码无效": "El código especial no es válido",
"显示模式": "Modo de visualización"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Ouvrir la fenêtre sélectionner le texte", "打开选择文本窗口": "Ouvrir la fenêtre sélectionner le texte",
"成功": "Succès", "成功": "Succès",
"Win32通用钩子": "Win32 crochet universel", "Win32通用钩子": "Win32 crochet universel",
"特殊码无效": "Code spécial invalide" "特殊码无效": "Code spécial invalide",
"显示模式": "Mode d'affichage"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Apri la finestra del testo di selezione", "打开选择文本窗口": "Apri la finestra del testo di selezione",
"成功": "successo", "成功": "successo",
"Win32通用钩子": "Win32 Universal Hook", "Win32通用钩子": "Win32 Universal Hook",
"特殊码无效": "Il codice speciale non è valido" "特殊码无效": "Il codice speciale non è valido",
"显示模式": "modalità di visualizzazione"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "テキストの選択ウィンドウを開く", "打开选择文本窗口": "テキストの選択ウィンドウを開く",
"成功": "成功", "成功": "成功",
"Win32通用钩子": "Win 32汎用フック", "Win32通用钩子": "Win 32汎用フック",
"特殊码无效": "特殊コードが無効です" "特殊码无效": "特殊コードが無効です",
"显示模式": "表示モード"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "텍스트 선택 창 열기", "打开选择文本窗口": "텍스트 선택 창 열기",
"成功": "성공", "成功": "성공",
"Win32通用钩子": "Win32 범용 갈고리", "Win32通用钩子": "Win32 범용 갈고리",
"特殊码无效": "잘못된 특수 코드" "特殊码无效": "잘못된 특수 코드",
"显示模式": "디스플레이 모드"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Het selectietekstvenster openen", "打开选择文本窗口": "Het selectietekstvenster openen",
"成功": "succes", "成功": "succes",
"Win32通用钩子": "Win32 universele haak", "Win32通用钩子": "Win32 universele haak",
"特殊码无效": "De speciale code is ongeldig" "特殊码无效": "De speciale code is ongeldig",
"显示模式": "weergavemodus"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Otwórz okno tekstowe zaznaczenia", "打开选择文本窗口": "Otwórz okno tekstowe zaznaczenia",
"成功": "sukces", "成功": "sukces",
"Win32通用钩子": "Uniwersalny hak Win32", "Win32通用钩子": "Uniwersalny hak Win32",
"特殊码无效": "Kod specjalny jest nieprawidłowy" "特殊码无效": "Kod specjalny jest nieprawidłowy",
"显示模式": "tryb wyświetlania"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Abrir a janela de texto da selecção", "打开选择文本窗口": "Abrir a janela de texto da selecção",
"成功": "sucesso", "成功": "sucesso",
"Win32通用钩子": "Gancho Universal Win32", "Win32通用钩子": "Gancho Universal Win32",
"特殊码无效": "O código especial é inválido" "特殊码无效": "O código especial é inválido",
"显示模式": "modo de visualização"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Открыть окно выбора текста", "打开选择文本窗口": "Открыть окно выбора текста",
"成功": "Успех", "成功": "Успех",
"Win32通用钩子": "Win32 Универсальный крюк", "Win32通用钩子": "Win32 Универсальный крюк",
"特殊码无效": "Специальный код не работает." "特殊码无效": "Специальный код не работает.",
"显示模式": "Показать режим"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Öppna markeringstextfönstret", "打开选择文本窗口": "Öppna markeringstextfönstret",
"成功": "framgång", "成功": "framgång",
"Win32通用钩子": "Win32 universalkrok", "Win32通用钩子": "Win32 universalkrok",
"特殊码无效": "Specialkoden är ogiltig" "特殊码无效": "Specialkoden är ogiltig",
"显示模式": "visningsläge"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "เปิดหน้าต่างเลือกข้อความ", "打开选择文本窗口": "เปิดหน้าต่างเลือกข้อความ",
"成功": "ความสำเร็จ", "成功": "ความสำเร็จ",
"Win32通用钩子": "ตะขอสากล Win32", "Win32通用钩子": "ตะขอสากล Win32",
"特殊码无效": "รหัสพิเศษไม่ถูกต้อง" "特殊码无效": "รหัสพิเศษไม่ถูกต้อง",
"显示模式": "โหมดการแสดงผล"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Seçim metin penceresini aç", "打开选择文本窗口": "Seçim metin penceresini aç",
"成功": "başarılı", "成功": "başarılı",
"Win32通用钩子": "Win32 Universal Hook", "Win32通用钩子": "Win32 Universal Hook",
"特殊码无效": "Özel kodu geçersiz." "特殊码无效": "Özel kodu geçersiz.",
"显示模式": "Görüntü modusu"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Відкрити текстове вікно вибору", "打开选择文本窗口": "Відкрити текстове вікно вибору",
"成功": "успіх", "成功": "успіх",
"Win32通用钩子": "Win32 Universal Hook", "Win32通用钩子": "Win32 Universal Hook",
"特殊码无效": "Некоректний особливий код" "特殊码无效": "Некоректний особливий код",
"显示模式": "режим показу"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "Mở cửa sổ Select Text", "打开选择文本窗口": "Mở cửa sổ Select Text",
"成功": "Thành công", "成功": "Thành công",
"Win32通用钩子": "Win32 phổ Hook", "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ị"
} }

View File

@ -755,5 +755,6 @@
"打开选择文本窗口": "", "打开选择文本窗口": "",
"成功": "", "成功": "",
"Win32通用钩子": "", "Win32通用钩子": "",
"特殊码无效": "" "特殊码无效": "",
"显示模式": ""
} }