diff --git a/LunaHook/engines/v8/v8.cpp b/LunaHook/engines/v8/v8.cpp index 882cb97..0dcf4be 100644 --- a/LunaHook/engines/v8/v8.cpp +++ b/LunaHook/engines/v8/v8.cpp @@ -1,6 +1,7 @@ #include"types.h" #include"main.h" #include"v8.h" +#include"embed_util.h" #ifndef _WIN64 #define arg2 stack[2] #else @@ -21,7 +22,12 @@ namespace{ hp.hook_after=[](hook_stack*s,void* data, size_t len){ HGLOBAL hClipboardData = GlobalAlloc(GMEM_MOVEABLE, len +2); auto pchData = (wchar_t*)GlobalLock(hClipboardData); - wcscpy(pchData, (wchar_t*)data); + std::wstring transwithfont; + transwithfont+=L'\x01'; + transwithfont+=embedsharedmem->fontFamily; + transwithfont+=L'\x01'; + transwithfont+=std::wstring((wchar_t*)data,len/2); + wcscpy(pchData, (wchar_t*)transwithfont.c_str()); GlobalUnlock(hClipboardData); s->arg2=(uintptr_t)hClipboardData; }; diff --git a/LunaHook/resource/lunajspatch.js b/LunaHook/resource/lunajspatch.js index 6ed6d36..7f4f0cf 100644 --- a/LunaHook/resource/lunajspatch.js +++ b/LunaHook/resource/lunajspatch.js @@ -1,13 +1,34 @@ - - +var fontface=''; +function splitfonttext(transwithfont){ + if(transwithfont[0]=='\x01'){ + transwithfont=transwithfont.substr(1) + split=transwithfont.search('\x01') + if(split==-1)return transwithfont; + fontface=transwithfont.substr(0,split) + text=transwithfont.substr(split+1) + return text; + } + else{ + return transwithfont; + } +} function NWjshook(){ function NWjssend(s) { const _clipboard = require('nw.gui').Clipboard.get(); _clipboard.set(s, 'text'); - return _clipboard.get('text') + transwithfont=_clipboard.get('text'); + if(transwithfont.length==0)return s; + return splitfonttext(transwithfont) } + if(Window_Message.prototype.originstartMessage)return; Window_Message.prototype.originstartMessage=Window_Message.prototype.startMessage; + Bitmap.prototype.origin_makeFontNameText=Bitmap.prototype._makeFontNameText; + Bitmap.prototype._makeFontNameText=function(){ + if(fontface=='')return this.origin_makeFontNameText(); + return (this.fontItalic ? 'Italic ' : '') + + this.fontSize + 'px ' + fontface; + } Window_Message.prototype.startMessage = function() { gametext = $gameMessage.allText(); @@ -22,13 +43,18 @@ function Electronhook() { function Electronsend(s) { const clipboard = require('electron').clipboard; clipboard.writeText(s); - return clipboard.readText(); + transwithfont= clipboard.readText(); + if(transwithfont.length==0)return s; + return splitfonttext(transwithfont) } if(tyrano.plugin.kag.tag.text.originstart)return; tyrano.plugin.kag.tag.text.originstart=tyrano.plugin.kag.tag.text.start; tyrano.plugin.kag.tag.text.start = function (pm) { if (1 != this.kag.stat.is_script && 1 != this.kag.stat.is_html) { pm.val=Electronsend(pm.val); + if(fontface!=''){ + this.kag.stat.font.face=fontface + } } return this.originstart(pm) }