diff --git a/LunaHook/engines/v8/v8.cpp b/LunaHook/engines/v8/v8.cpp index 8381d53..4b73870 100644 --- a/LunaHook/engines/v8/v8.cpp +++ b/LunaHook/engines/v8/v8.cpp @@ -24,9 +24,16 @@ namespace auto spl = wcschr(text, L'\x03'); strcpy(hp->name, wcasta(std::wstring(text, spl - text)).c_str()); text = spl + 1; - spl = wcschr(text, L'\x02'); + spl = wcschr(text, L'\x04'); *split = std::stoi(std::wstring(text, spl - text)); text = spl + 1; + auto embedable = wcschr(text, L'\x02'); + auto isembedabl = std::stoi(std::wstring(text, embedable - text)); + if (isembedabl) + hp->type |= EMBED_ABLE; + else + hp->type &= ~EMBED_ABLE; + text = embedable + 1; *data = (uintptr_t)text; *len = wcslen(text) * 2; } diff --git a/LunaHook/resource/lunajspatch.js b/LunaHook/resource/lunajspatch.js index b8914f4..c058b41 100644 --- a/LunaHook/resource/lunajspatch.js +++ b/LunaHook/resource/lunajspatch.js @@ -21,11 +21,11 @@ function splitfonttext(transwithfont) { return transwithfont; } } -function cppjsio(name, s_raw, lpsplit) { +function cppjsio(name, s_raw, lpsplit, embedable = true) { if (!s_raw) return s_raw transwithfont = '' - s = magicsend + name + '\x03' + lpsplit.toString() + '\x02' + s_raw; + s = magicsend + name + '\x03' + lpsplit.toString() + '\x04' + (embedable ? '1' : '0') + '\x02' + s_raw; if (internal_http_port) { var xhr = new XMLHttpRequest(); var url = 'http://127.0.0.1:' + internal_http_port + '/fuck' @@ -62,6 +62,7 @@ function rpgmakerhook() { Window_Base.prototype.drawTextEx_origin = Window_Base.prototype.drawTextEx; Window_Base.prototype.drawText_origin = Window_Base.prototype.drawText; Window_Message.prototype.originstartMessage = Window_Message.prototype.startMessage; + Window_Message.prototype.updateMessage_ori = Window_Message.prototype.updateMessage; Bitmap.prototype.drawText_ori = Bitmap.prototype.drawText; Bitmap.prototype.last_y = 0; @@ -77,7 +78,7 @@ function rpgmakerhook() { setInterval(function () { for (lpsplit in Bitmap.prototype.collectstring) { if (Bitmap.prototype.collectstring[lpsplit].length) { - cppjsio('rpgmakermv', Bitmap.prototype.collectstring[lpsplit], lpsplit) + cppjsio('rpgmakermv', Bitmap.prototype.collectstring[lpsplit], lpsplit, false) Bitmap.prototype.collectstring[lpsplit] = '' } } @@ -103,6 +104,16 @@ function rpgmakerhook() { $gameMessage._texts = [resp] this.originstartMessage(); }; + Window_Message.prototype.lastalltext = '' + Window_Message.prototype.updateMessage = function () { + if (this._textState) { + if (Window_Message.prototype.lastalltext != $gameMessage.allText()) { + cppjsio('rpgmakermv', $gameMessage.allText(), 18, false); + Window_Message.prototype.lastalltext = $gameMessage.allText() + } + } + return this.updateMessage_ori(); + }; Window_Base.prototype.drawText = function (text, x, y, maxWidth, align) { text = cppjsio('rpgmakermv', text, 1) return this.drawText_origin(text, x, y, maxWidth, align) diff --git a/LunaHost/LunaHostDll.cpp b/LunaHost/LunaHostDll.cpp index 58e230e..825e43f 100644 --- a/LunaHost/LunaHostDll.cpp +++ b/LunaHost/LunaHostDll.cpp @@ -16,7 +16,8 @@ BOOL APIENTRY DllMain(HMODULE hModule, } typedef void (*ProcessEvent)(DWORD); -typedef void (*ThreadEvent)(const wchar_t *, const char *, ThreadParam); +typedef void (*ThreadEvent)(const wchar_t *, const char *, ThreadParam, bool); +typedef void (*ThreadEvent_2)(const wchar_t *, const char *, ThreadParam); typedef bool (*OutputCallback)(const wchar_t *, const char *, ThreadParam, const wchar_t *); typedef void (*ConsoleHandler)(const wchar_t *); typedef void (*HookInsertHandler)(uint64_t, const wchar_t *); @@ -28,13 +29,13 @@ std::optional checkoption(bool check, T &&t) return std::move(t); return {}; } -C_LUNA_API void Luna_Start(ProcessEvent Connect, ProcessEvent Disconnect, ThreadEvent Create, ThreadEvent Destroy, OutputCallback Output, ConsoleHandler console, HookInsertHandler hookinsert, EmbedCallback embed, ConsoleHandler Warning) +C_LUNA_API void Luna_Start(ProcessEvent Connect, ProcessEvent Disconnect, ThreadEvent Create, ThreadEvent_2 Destroy, OutputCallback Output, ConsoleHandler console, HookInsertHandler hookinsert, EmbedCallback embed, ConsoleHandler Warning) { Host::StartEx( checkoption(Connect, std::function(Connect)), checkoption(Disconnect, std::function(Disconnect)), checkoption(Create, [=](const TextThread &thread) - { Create(thread.hp.hookcode, thread.hp.name, thread.tp); }), + { Create(thread.hp.hookcode, thread.hp.name, thread.tp, thread.hp.type & EMBED_ABLE); }), checkoption(Destroy, [=](const TextThread &thread) { Destroy(thread.hp.hookcode, thread.hp.name, thread.tp); }), checkoption(Output, [=](const TextThread &thread, std::wstring &output)