Fix up PRs

This commit is contained in:
Natsumi
2025-01-09 13:31:14 +13:00
parent 60f59b9baa
commit a39eb9d5ed
3 changed files with 219 additions and 156 deletions
+106 -40
View File
@@ -1892,7 +1892,10 @@ speechSynthesis.getVoices();
}; };
API.$on('AVATAR:IMPOSTER:DELETE', function (args) { API.$on('AVATAR:IMPOSTER:DELETE', function (args) {
if (args.json && $app.avatarDialog.visible) { if (
$app.avatarDialog.visible &&
args.params.avatarId === $app.avatarDialog.id
) {
$app.showAvatarDialog($app.avatarDialog.id); $app.showAvatarDialog($app.avatarDialog.id);
} }
}); });
@@ -5859,7 +5862,10 @@ speechSynthesis.getVoices();
* @param {string} str2 * @param {string} str2
* @returns {number[][]} A matrix that contains the longest common subsequence between both strings * @returns {number[][]} A matrix that contains the longest common subsequence between both strings
*/ */
$app.methods.longestCommonSubsequence = function longestCommonSubsequence(str1, str2) { $app.methods.longestCommonSubsequence = function longestCommonSubsequence(
str1,
str2
) {
let lcs = []; let lcs = [];
for (let i = 0; i <= str1.length; i++) { for (let i = 0; i <= str1.length; i++) {
lcs.push(new Array(str2.length + 1).fill(0)); lcs.push(new Array(str2.length + 1).fill(0));
@@ -5874,7 +5880,7 @@ speechSynthesis.getVoices();
} }
} }
return lcs; return lcs;
} };
/** /**
* Merge differences in both strings to get the longest common subsequence * Merge differences in both strings to get the longest common subsequence
@@ -5883,8 +5889,8 @@ speechSynthesis.getVoices();
*/ */
$app.methods.regoupDifferences = function regoupDifferences(res) { $app.methods.regoupDifferences = function regoupDifferences(res) {
let regrouped = []; let regrouped = [];
let text = ""; let text = '';
let type = ""; let type = '';
for (let i = 0; i < res.length; i++) { for (let i = 0; i < res.length; i++) {
if (i == 0) { if (i == 0) {
text = res[i].text; text = res[i].text;
@@ -5899,7 +5905,7 @@ speechSynthesis.getVoices();
} }
regrouped.push({ text: text, type: type }); regrouped.push({ text: text, type: type });
return regrouped; return regrouped;
} };
/** /**
* Function that format the differences between two strings with HTML tags * Function that format the differences between two strings with HTML tags
@@ -5916,7 +5922,8 @@ speechSynthesis.getVoices();
markerAddition = '<span class="x-text-added">{{text}}</span>', markerAddition = '<span class="x-text-added">{{text}}</span>',
markerDeletion = '<span class="x-text-removed">{{text}}</span>' markerDeletion = '<span class="x-text-removed">{{text}}</span>'
) { ) {
[oldString, newString] = [oldString, newString].map((s) => s [oldString, newString] = [oldString, newString].map((s) =>
s
.replaceAll(/&/g, '&amp;') .replaceAll(/&/g, '&amp;')
.replaceAll(/</g, '&lt;') .replaceAll(/</g, '&lt;')
.replaceAll(/>/g, '&gt;') .replaceAll(/>/g, '&gt;')
@@ -5925,8 +5932,12 @@ speechSynthesis.getVoices();
.replaceAll(/\n/g, '<br>') .replaceAll(/\n/g, '<br>')
); );
const oldWords = oldString.split(/\s+/).flatMap((word) => word.split(/(<br>)/)); const oldWords = oldString
const newWords = newString.split(/\s+/).flatMap((word) => word.split(/(<br>)/)); .split(/\s+/)
.flatMap((word) => word.split(/(<br>)/));
const newWords = newString
.split(/\s+/)
.flatMap((word) => word.split(/(<br>)/));
function findLongestMatch(oldStart, oldEnd, newStart, newEnd) { function findLongestMatch(oldStart, oldEnd, newStart, newEnd) {
let bestOldStart = oldStart; let bestOldStart = oldStart;
@@ -5961,7 +5972,11 @@ speechSynthesis.getVoices();
} }
} }
return { oldStart: bestOldStart, newStart: bestNewStart, size: bestSize }; return {
oldStart: bestOldStart,
newStart: bestNewStart,
size: bestSize
};
} }
function buildDiff(oldStart, oldEnd, newStart, newEnd) { function buildDiff(oldStart, oldEnd, newStart, newEnd) {
@@ -5972,15 +5987,27 @@ speechSynthesis.getVoices();
// Handle differences before the match // Handle differences before the match
if (oldStart < match.oldStart || newStart < match.newStart) { if (oldStart < match.oldStart || newStart < match.newStart) {
result.push( result.push(
...buildDiff(oldStart, match.oldStart, newStart, match.newStart) ...buildDiff(
oldStart,
match.oldStart,
newStart,
match.newStart
)
); );
} }
// Add the matched words // Add the matched words
result.push(oldWords.slice(match.oldStart, match.oldStart + match.size).join(" ")); result.push(
oldWords
.slice(match.oldStart, match.oldStart + match.size)
.join(' ')
);
// Handle differences after the match // Handle differences after the match
if (match.oldStart + match.size < oldEnd || match.newStart + match.size < newEnd) { if (
match.oldStart + match.size < oldEnd ||
match.newStart + match.size < newEnd
) {
result.push( result.push(
...buildDiff( ...buildDiff(
match.oldStart + match.size, match.oldStart + match.size,
@@ -5993,35 +6020,40 @@ speechSynthesis.getVoices();
} else { } else {
function build(words, start, end, pattern) { function build(words, start, end, pattern) {
let r = []; let r = [];
let ts = words.slice(start, end) let ts = words
.slice(start, end)
.filter((w) => w.length > 0) .filter((w) => w.length > 0)
.join(" ") .join(' ')
.split("<br>"); .split('<br>');
for (let i = 0; i < ts.length; i++) { for (let i = 0; i < ts.length; i++) {
if (i > 0) r.push("<br>"); if (i > 0) r.push('<br>');
if (ts[i].length < 1) continue; if (ts[i].length < 1) continue;
r.push(pattern.replace("{{text}}", ts[i])); r.push(pattern.replace('{{text}}', ts[i]));
} }
return r; return r;
} }
// Add deletions // Add deletions
if (oldStart < oldEnd) if (oldStart < oldEnd)
result.push(...build(oldWords, oldStart, oldEnd, markerDeletion)); result.push(
...build(oldWords, oldStart, oldEnd, markerDeletion)
);
// Add insertions // Add insertions
if (newStart < newEnd) if (newStart < newEnd)
result.push(...build(newWords, newStart, newEnd, markerAddition)); result.push(
...build(newWords, newStart, newEnd, markerAddition)
);
} }
return result; return result;
} }
return buildDiff(0, oldWords.length, 0, newWords.length) return buildDiff(0, oldWords.length, 0, newWords.length)
.join(" ") .join(' ')
.replace(/<br>[ ]+<br>/g, "<br><br>") .replace(/<br>[ ]+<br>/g, '<br><br>')
.replace(/<br> /g, "<br>"); .replace(/<br> /g, '<br>');
} };
// #endregion // #endregion
// #region | App: gameLog // #region | App: gameLog
@@ -8599,6 +8631,10 @@ speechSynthesis.getVoices();
case 'VRCX_saveInstancePrints': case 'VRCX_saveInstancePrints':
this.saveInstancePrints = !this.saveInstancePrints; this.saveInstancePrints = !this.saveInstancePrints;
break; break;
case 'VRCX_cropInstancePrints':
this.cropInstancePrints = !this.cropInstancePrints;
this.cropPrintsChanged();
break;
case 'VRCX_saveInstanceStickers': case 'VRCX_saveInstanceStickers':
this.saveInstanceStickers = !this.saveInstanceStickers; this.saveInstanceStickers = !this.saveInstanceStickers;
break; break;
@@ -8636,6 +8672,7 @@ speechSynthesis.getVoices();
'VRCX_cropInstancePrints', 'VRCX_cropInstancePrints',
this.cropInstancePrints this.cropInstancePrints
); );
await configRepository.setBool( await configRepository.setBool(
'VRCX_saveInstanceStickers', 'VRCX_saveInstanceStickers',
this.saveInstanceStickers this.saveInstanceStickers
@@ -10716,7 +10753,8 @@ speechSynthesis.getVoices();
if (type === 'search') { if (type === 'search') {
try { try {
var response = await webApiService.execute({ var response = await webApiService.execute({
url: `${this.avatarRemoteDatabaseProvider url: `${
this.avatarRemoteDatabaseProvider
}?${type}=${encodeURIComponent(search)}&n=5000`, }?${type}=${encodeURIComponent(search)}&n=5000`,
method: 'GET', method: 'GET',
headers: { headers: {
@@ -12343,17 +12381,22 @@ speechSynthesis.getVoices();
case 'Regenerate Imposter': case 'Regenerate Imposter':
API.deleteImposter({ API.deleteImposter({
avatarId: D.id avatarId: D.id
}).then((args) => {return args;}); })
.then((args) => {
return args;
})
.finally(() => {
API.createImposter({ API.createImposter({
avatarId: D.id avatarId: D.id
}).then((args) => { }).then((args) => {
this.$message({ this.$message({
message: 'Imposter deleted and queued for creation', message:
'Imposter deleted and queued for creation',
type: 'success' type: 'success'
}); });
this.showAvatarDialog(D.id);
return args; return args;
}); });
});
break; break;
} }
} }
@@ -18152,24 +18195,47 @@ speechSynthesis.getVoices();
// #endregion // #endregion
// #region | Prints // #region | Prints
$app.methods.cropPrintsChanged = function () { $app.methods.cropPrintsChanged = function () {
if (!this.cropInstancePrints) if (!this.cropInstancePrints) return;
return;
this.$confirm( this.$confirm(
$t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old'), $t(
'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old'
),
{ {
confirmButtonText: $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_confirm'), confirmButtonText: $t(
cancelButtonText: $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'), 'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_confirm'
),
cancelButtonText: $t(
'view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'
),
type: 'info', type: 'info',
showInput: false, showInput: false,
callback: (action) => { callback: async (action) => {
if (action === 'confirm') { if (action === 'confirm') {
AppApi.CropAllPrints(this.ugcFolderPath); var msgBox = this.$message({
} message: 'Batch print cropping in progress...',
} type: 'warning',
duration: 0
}); });
try {
this.saveVRCXWindowOption(); await AppApi.CropAllPrints(this.ugcFolderPath);
this.$message({
message: 'Batch print cropping complete',
type: 'success'
});
} catch (err) {
console.error(err);
this.$message({
message: `Batch print cropping failed: ${err}`,
type: 'error'
});
} finally {
msgBox.close();
} }
}
}
}
);
};
API.$on('LOGIN', function () { API.$on('LOGIN', function () {
$app.printTable = []; $app.printTable = [];
@@ -18406,7 +18472,7 @@ speechSynthesis.getVoices();
} }
}, 2_500); }, 2_500);
} }
} };
$app.methods.trySavePrintToFile = async function (printId) { $app.methods.trySavePrintToFile = async function (printId) {
var args = await API.getPrint({ printId }); var args = await API.getPrint({ printId });
+2 -2
View File
@@ -508,8 +508,8 @@
"header": "Save Instance Prints To File", "header": "Save Instance Prints To File",
"header_tooltip": "Requires \"--enable-sdk-log-levels\" VRC launch option", "header_tooltip": "Requires \"--enable-sdk-log-levels\" VRC launch option",
"description": "Save spawned prints to your VRChat Pictures folder", "description": "Save spawned prints to your VRChat Pictures folder",
"crop": "Automatically crop saved prints to remove the white border", "crop": "Automatically remove white border from prints",
"crop_convert_old": "Do you want to crop all prints that have already been saved?", "crop_convert_old": "Would you like to crop all prints that have already been saved?",
"crop_convert_old_confirm": "Yes", "crop_convert_old_confirm": "Yes",
"crop_convert_old_cancel": "No" "crop_convert_old_cancel": "No"
}, },
+1 -4
View File
@@ -465,11 +465,8 @@ mixin settingsTab()
el-tooltip(placement="top" style="margin-left:5px" :content="$t('view.settings.advanced.advanced.save_instance_prints_to_file.header_tooltip')") el-tooltip(placement="top" style="margin-left:5px" :content="$t('view.settings.advanced.advanced.save_instance_prints_to_file.header_tooltip')")
i.el-icon-info i.el-icon-info
simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_prints_to_file.description")' :value='saveInstancePrints' @change='saveVRCXWindowOption("VRCX_saveInstancePrints")' :long-label='true') simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_prints_to_file.description")' :value='saveInstancePrints' @change='saveVRCXWindowOption("VRCX_saveInstancePrints")' :long-label='true')
simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_prints_to_file.crop")' :value='cropInstancePrints' @change='saveVRCXWindowOption("VRCX_cropInstancePrints")' :long-label='true')
br br
span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop') }}
el-switch(v-model="cropInstancePrints" @change="cropPrintsChanged")
br
span.sub-header {{ $t('view.settings.advanced.advanced.save_instance_stickers_to_file.header') }} span.sub-header {{ $t('view.settings.advanced.advanced.save_instance_stickers_to_file.header') }}
simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_stickers_to_file.description")' :value='saveInstanceStickers' @change='saveVRCXWindowOption("VRCX_saveInstanceStickers")' :long-label='true') simple-switch(:label='$t("view.settings.advanced.advanced.save_instance_stickers_to_file.description")' :value='saveInstanceStickers' @change='saveVRCXWindowOption("VRCX_saveInstanceStickers")' :long-label='true')
//- Advanced | Remote Avatar Database //- Advanced | Remote Avatar Database