-
Notifications
You must be signed in to change notification settings - Fork 41
/
NS_01005E9016BDE000_MAGES_The_Quintessential_Quintuplets_The_Movie.js
66 lines (52 loc) · 1.84 KB
/
NS_01005E9016BDE000_MAGES_The_Quintessential_Quintuplets_The_Movie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// ==UserScript==
// @name [01005E9016BDE000] The Quintessential Quintuplets the Movie: Five Memories of My Time with You (JP)
// @version 1.0.0
// @author koukdw
// @description Yuzu
// * MAGES. inc.
// * Kaleido ADV Workshop
// ==/UserScript==
const gameVer = '1.0.0';
const { setHook } = require('./libYuzu.js');
const mainHandler = trans.send(handler, '250+');
setHook({
'1.0.0': {
[0x80011688 - 0x80004000]: mainHandler.bind_(null, 1, "dialogue, menu, choice, name"),
}
}[globalThis.gameVer = globalThis.gameVer ?? gameVer]);
let pre = '';
function handler(regs, index, hookname) {
const address = regs[index].value;
//console.log('onEnter ' + hookname);
//console.log(hexdump(address, { header: false, ansi: false, length: 0x50 }));
let s = address.readUtf8String();
if (pre.indexOf(s) !== -1) {
return null; // skip duplicate (menu, color)
}
pre = s;
s = s.replace(/\\n/g, ' '); // single line
return s;
}
trans.replace(function (s) {
pre = '';
// print rubi: と[けい]痙[れん]攣
const patt = /\[[^\]]+./g;
const rubis = s.matchAll(patt);
for (const rubi of rubis) {
const ruby = rubi[0];
const n = parseInt(ruby.match(/\d+\]$/) ?? 0) + 1;
let q = ruby.indexOf(',');
q = q !== -1 ? q : ruby.length - 2;
console.log('rubi: ' + ruby.substr(1, q));
console.log('rube: ' + s.substr(rubi.index + ruby.length, n));
}
// remove rubi
s = s.replace(patt, '');
// remove control: %p-1;――
s = s.replace(/\\k|\\x|%C|%B|%p-1;/g, '');
// color, remove end tag (pre)
// #0084ff;color1%r default text #0084ff;color2%r #0084ff;color 3
// color1
s = s.replace(/\#[0-9a-fA-F]+\;([^%#]+)(%r)?/g, '$1');
return s;
});