Skip to content

Commit 2a7c341

Browse files
committed
Restore previous _loadStructuredText() incase plugins are using but mark with a comment as deprecated for eventual removal
1 parent 35a646e commit 2a7c341

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

src/lib/compiler/scriptBuilder.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2034,7 +2034,12 @@ class ScriptBuilder {
20342034
this._string(text);
20352035
};
20362036

2037-
_loadStructuredText = (inputText: string) => {
2037+
// @deprecated Replace with _loadAndDisplayText which supports wait codes
2038+
_loadStructuredText = (
2039+
inputText: string,
2040+
avatarIndex?: number,
2041+
scrollHeight?: number
2042+
) => {
20382043
const { fonts, defaultFontId } = this.options;
20392044
let font = fonts.find((f) => f.id === defaultFontId);
20402045

@@ -2118,6 +2123,18 @@ class ScriptBuilder {
21182123
}
21192124
});
21202125

2126+
// Replace newlines with scroll code if larger than max dialogue size
2127+
if (scrollHeight) {
2128+
let numNewlines = 0;
2129+
text = text.replace(/\\012/g, (newline) => {
2130+
numNewlines++;
2131+
if (numNewlines > scrollHeight - 1) {
2132+
return "\\015";
2133+
}
2134+
return newline;
2135+
});
2136+
}
2137+
21212138
if (indirectVars.length > 0) {
21222139
for (const indirectVar of indirectVars) {
21232140
this._getInd(indirectVar.local, indirectVar.arg);
@@ -2130,6 +2147,23 @@ class ScriptBuilder {
21302147
this._dw(...usedVariableAliases);
21312148
}
21322149

2150+
// Add avatar
2151+
if (avatarIndex !== undefined) {
2152+
const { fonts } = this.options;
2153+
const avatarFontSize = 16;
2154+
const fontIndex = fonts.length + Math.floor(avatarIndex / avatarFontSize);
2155+
const baseCharCode = ((avatarIndex * 4) % (avatarFontSize * 4)) + 64;
2156+
text = `${textCodeSetSpeed(0)}${textCodeSetFont(
2157+
fontIndex
2158+
)}${String.fromCharCode(baseCharCode)}${String.fromCharCode(
2159+
baseCharCode + 1
2160+
)}\\n${String.fromCharCode(baseCharCode + 2)}${String.fromCharCode(
2161+
baseCharCode + 3
2162+
)}${textCodeSetSpeed(2)}${textCodeGotoRel(1, -1)}${textCodeSetFont(
2163+
0
2164+
)}${text}`;
2165+
}
2166+
21332167
this._string(text);
21342168
};
21352169

0 commit comments

Comments
 (0)