mirror of
https://github.com/MrUnknownDE/VRCX.git
synced 2026-05-07 14:56:06 +02:00
Fix up PRs
This commit is contained in:
+106
-40
@@ -1892,7 +1892,10 @@ speechSynthesis.getVoices();
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
@@ -5859,7 +5862,10 @@ speechSynthesis.getVoices();
|
||||
* @param {string} str2
|
||||
* @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 = [];
|
||||
for (let i = 0; i <= str1.length; i++) {
|
||||
lcs.push(new Array(str2.length + 1).fill(0));
|
||||
@@ -5874,7 +5880,7 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
}
|
||||
return lcs;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Merge differences in both strings to get the longest common subsequence
|
||||
@@ -5883,8 +5889,8 @@ speechSynthesis.getVoices();
|
||||
*/
|
||||
$app.methods.regoupDifferences = function regoupDifferences(res) {
|
||||
let regrouped = [];
|
||||
let text = "";
|
||||
let type = "";
|
||||
let text = '';
|
||||
let type = '';
|
||||
for (let i = 0; i < res.length; i++) {
|
||||
if (i == 0) {
|
||||
text = res[i].text;
|
||||
@@ -5899,7 +5905,7 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
regrouped.push({ text: text, type: type });
|
||||
return regrouped;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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>',
|
||||
markerDeletion = '<span class="x-text-removed">{{text}}</span>'
|
||||
) {
|
||||
[oldString, newString] = [oldString, newString].map((s) => s
|
||||
[oldString, newString] = [oldString, newString].map((s) =>
|
||||
s
|
||||
.replaceAll(/&/g, '&')
|
||||
.replaceAll(/</g, '<')
|
||||
.replaceAll(/>/g, '>')
|
||||
@@ -5925,8 +5932,12 @@ speechSynthesis.getVoices();
|
||||
.replaceAll(/\n/g, '<br>')
|
||||
);
|
||||
|
||||
const oldWords = oldString.split(/\s+/).flatMap((word) => word.split(/(<br>)/));
|
||||
const newWords = newString.split(/\s+/).flatMap((word) => word.split(/(<br>)/));
|
||||
const oldWords = oldString
|
||||
.split(/\s+/)
|
||||
.flatMap((word) => word.split(/(<br>)/));
|
||||
const newWords = newString
|
||||
.split(/\s+/)
|
||||
.flatMap((word) => word.split(/(<br>)/));
|
||||
|
||||
function findLongestMatch(oldStart, oldEnd, newStart, newEnd) {
|
||||
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) {
|
||||
@@ -5972,15 +5987,27 @@ speechSynthesis.getVoices();
|
||||
// Handle differences before the match
|
||||
if (oldStart < match.oldStart || newStart < match.newStart) {
|
||||
result.push(
|
||||
...buildDiff(oldStart, match.oldStart, newStart, match.newStart)
|
||||
...buildDiff(
|
||||
oldStart,
|
||||
match.oldStart,
|
||||
newStart,
|
||||
match.newStart
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// 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
|
||||
if (match.oldStart + match.size < oldEnd || match.newStart + match.size < newEnd) {
|
||||
if (
|
||||
match.oldStart + match.size < oldEnd ||
|
||||
match.newStart + match.size < newEnd
|
||||
) {
|
||||
result.push(
|
||||
...buildDiff(
|
||||
match.oldStart + match.size,
|
||||
@@ -5993,35 +6020,40 @@ speechSynthesis.getVoices();
|
||||
} else {
|
||||
function build(words, start, end, pattern) {
|
||||
let r = [];
|
||||
let ts = words.slice(start, end)
|
||||
let ts = words
|
||||
.slice(start, end)
|
||||
.filter((w) => w.length > 0)
|
||||
.join(" ")
|
||||
.split("<br>");
|
||||
.join(' ')
|
||||
.split('<br>');
|
||||
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;
|
||||
r.push(pattern.replace("{{text}}", ts[i]));
|
||||
r.push(pattern.replace('{{text}}', ts[i]));
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
// Add deletions
|
||||
if (oldStart < oldEnd)
|
||||
result.push(...build(oldWords, oldStart, oldEnd, markerDeletion));
|
||||
result.push(
|
||||
...build(oldWords, oldStart, oldEnd, markerDeletion)
|
||||
);
|
||||
|
||||
// Add insertions
|
||||
if (newStart < newEnd)
|
||||
result.push(...build(newWords, newStart, newEnd, markerAddition));
|
||||
result.push(
|
||||
...build(newWords, newStart, newEnd, markerAddition)
|
||||
);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
return buildDiff(0, oldWords.length, 0, newWords.length)
|
||||
.join(" ")
|
||||
.replace(/<br>[ ]+<br>/g, "<br><br>")
|
||||
.replace(/<br> /g, "<br>");
|
||||
}
|
||||
.join(' ')
|
||||
.replace(/<br>[ ]+<br>/g, '<br><br>')
|
||||
.replace(/<br> /g, '<br>');
|
||||
};
|
||||
|
||||
// #endregion
|
||||
// #region | App: gameLog
|
||||
@@ -8599,6 +8631,10 @@ speechSynthesis.getVoices();
|
||||
case 'VRCX_saveInstancePrints':
|
||||
this.saveInstancePrints = !this.saveInstancePrints;
|
||||
break;
|
||||
case 'VRCX_cropInstancePrints':
|
||||
this.cropInstancePrints = !this.cropInstancePrints;
|
||||
this.cropPrintsChanged();
|
||||
break;
|
||||
case 'VRCX_saveInstanceStickers':
|
||||
this.saveInstanceStickers = !this.saveInstanceStickers;
|
||||
break;
|
||||
@@ -8636,6 +8672,7 @@ speechSynthesis.getVoices();
|
||||
'VRCX_cropInstancePrints',
|
||||
this.cropInstancePrints
|
||||
);
|
||||
|
||||
await configRepository.setBool(
|
||||
'VRCX_saveInstanceStickers',
|
||||
this.saveInstanceStickers
|
||||
@@ -10716,7 +10753,8 @@ speechSynthesis.getVoices();
|
||||
if (type === 'search') {
|
||||
try {
|
||||
var response = await webApiService.execute({
|
||||
url: `${this.avatarRemoteDatabaseProvider
|
||||
url: `${
|
||||
this.avatarRemoteDatabaseProvider
|
||||
}?${type}=${encodeURIComponent(search)}&n=5000`,
|
||||
method: 'GET',
|
||||
headers: {
|
||||
@@ -12343,17 +12381,22 @@ speechSynthesis.getVoices();
|
||||
case 'Regenerate Imposter':
|
||||
API.deleteImposter({
|
||||
avatarId: D.id
|
||||
}).then((args) => {return args;});
|
||||
})
|
||||
.then((args) => {
|
||||
return args;
|
||||
})
|
||||
.finally(() => {
|
||||
API.createImposter({
|
||||
avatarId: D.id
|
||||
}).then((args) => {
|
||||
this.$message({
|
||||
message: 'Imposter deleted and queued for creation',
|
||||
message:
|
||||
'Imposter deleted and queued for creation',
|
||||
type: 'success'
|
||||
});
|
||||
this.showAvatarDialog(D.id);
|
||||
return args;
|
||||
});
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -18152,24 +18195,47 @@ speechSynthesis.getVoices();
|
||||
// #endregion
|
||||
// #region | Prints
|
||||
$app.methods.cropPrintsChanged = function () {
|
||||
if (!this.cropInstancePrints)
|
||||
return;
|
||||
if (!this.cropInstancePrints) return;
|
||||
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'),
|
||||
cancelButtonText: $t('view.settings.advanced.advanced.save_instance_prints_to_file.crop_convert_old_cancel'),
|
||||
confirmButtonText: $t(
|
||||
'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',
|
||||
showInput: false,
|
||||
callback: (action) => {
|
||||
callback: async (action) => {
|
||||
if (action === 'confirm') {
|
||||
AppApi.CropAllPrints(this.ugcFolderPath);
|
||||
}
|
||||
}
|
||||
var msgBox = this.$message({
|
||||
message: 'Batch print cropping in progress...',
|
||||
type: 'warning',
|
||||
duration: 0
|
||||
});
|
||||
|
||||
this.saveVRCXWindowOption();
|
||||
try {
|
||||
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 () {
|
||||
$app.printTable = [];
|
||||
@@ -18406,7 +18472,7 @@ speechSynthesis.getVoices();
|
||||
}
|
||||
}, 2_500);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$app.methods.trySavePrintToFile = async function (printId) {
|
||||
var args = await API.getPrint({ printId });
|
||||
|
||||
@@ -508,8 +508,8 @@
|
||||
"header": "Save Instance Prints To File",
|
||||
"header_tooltip": "Requires \"--enable-sdk-log-levels\" VRC launch option",
|
||||
"description": "Save spawned prints to your VRChat Pictures folder",
|
||||
"crop": "Automatically crop saved prints to remove the white border",
|
||||
"crop_convert_old": "Do you want to crop all prints that have already been saved?",
|
||||
"crop": "Automatically remove white border from prints",
|
||||
"crop_convert_old": "Would you like to crop all prints that have already been saved?",
|
||||
"crop_convert_old_confirm": "Yes",
|
||||
"crop_convert_old_cancel": "No"
|
||||
},
|
||||
|
||||
@@ -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')")
|
||||
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.crop")' :value='cropInstancePrints' @change='saveVRCXWindowOption("VRCX_cropInstancePrints")' :long-label='true')
|
||||
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') }}
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user