2024-03-19 23:14:08 +08:00
|
|
|
|
var fontface='';
|
2024-03-20 22:51:24 +08:00
|
|
|
|
|
2024-03-19 23:14:08 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-20 22:51:24 +08:00
|
|
|
|
function clipboardsender(s){
|
|
|
|
|
try{
|
2024-03-15 21:51:59 +08:00
|
|
|
|
const _clipboard = require('nw.gui').Clipboard.get();
|
|
|
|
|
_clipboard.set(s, 'text');
|
2024-03-19 23:14:08 +08:00
|
|
|
|
transwithfont=_clipboard.get('text');
|
2024-03-15 21:51:59 +08:00
|
|
|
|
}
|
2024-03-20 22:51:24 +08:00
|
|
|
|
catch(err){
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
const clipboard = require('electron').clipboard;
|
|
|
|
|
clipboard.writeText(s);
|
|
|
|
|
transwithfont= clipboard.readText();
|
|
|
|
|
}
|
|
|
|
|
catch(err2){
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(transwithfont.length==0)return s;
|
|
|
|
|
return splitfonttext(transwithfont)
|
|
|
|
|
}
|
|
|
|
|
function rpgmakerhook(){
|
2024-03-19 23:14:08 +08:00
|
|
|
|
|
2024-03-15 21:51:59 +08:00
|
|
|
|
if(Window_Message.prototype.originstartMessage)return;
|
|
|
|
|
Window_Message.prototype.originstartMessage=Window_Message.prototype.startMessage;
|
2024-03-19 23:14:08 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
2024-03-15 21:51:59 +08:00
|
|
|
|
Window_Message.prototype.startMessage = function()
|
|
|
|
|
{
|
|
|
|
|
gametext = $gameMessage.allText();
|
2024-03-20 22:51:24 +08:00
|
|
|
|
resp=clipboardsender(gametext);
|
2024-03-15 21:51:59 +08:00
|
|
|
|
$gameMessage._texts=[resp]
|
|
|
|
|
this.originstartMessage();
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2024-03-20 22:51:24 +08:00
|
|
|
|
function tyranohook() {
|
2024-03-15 21:51:59 +08:00
|
|
|
|
|
2024-03-17 02:09:28 +08:00
|
|
|
|
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) {
|
2024-03-20 22:51:24 +08:00
|
|
|
|
pm.val=clipboardsender(pm.val);
|
2024-03-19 23:14:08 +08:00
|
|
|
|
if(fontface!=''){
|
|
|
|
|
this.kag.stat.font.face=fontface
|
|
|
|
|
}
|
2024-03-17 02:09:28 +08:00
|
|
|
|
}
|
|
|
|
|
return this.originstart(pm)
|
2024-03-15 21:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function retryinject(times){
|
|
|
|
|
if(times==0)return;
|
2024-03-16 13:40:08 +08:00
|
|
|
|
try{
|
|
|
|
|
if(window.tyrano && tyrano.plugin){
|
2024-03-20 22:51:24 +08:00
|
|
|
|
tyranohook();
|
2024-03-16 13:40:08 +08:00
|
|
|
|
}
|
|
|
|
|
else if(window.Utils && Utils.RPGMAKER_NAME){
|
2024-03-20 22:51:24 +08:00
|
|
|
|
rpgmakerhook();
|
2024-03-16 13:40:08 +08:00
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
setTimeout(retryinject,3000,times-1);
|
|
|
|
|
}
|
2024-03-15 21:51:59 +08:00
|
|
|
|
}
|
2024-03-16 13:40:08 +08:00
|
|
|
|
catch(err){
|
|
|
|
|
//非主线程,甚至没有window对象,会弹窗报错
|
2024-03-15 21:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2024-03-17 00:16:21 +08:00
|
|
|
|
setTimeout(retryinject,1000,3);
|