Skip to content

Commit

Permalink
More prints info
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Nov 16, 2024
1 parent 6f85c76 commit db410a3
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 21 deletions.
5 changes: 2 additions & 3 deletions Dotnet/AppApi/AppApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -577,9 +577,8 @@ public string GetFileBase64(string path)

public async Task<bool> SavePrintToFile(string url, string fileName)
{
var directory = Path.Combine(GetVRChatPhotosLocation(), "Prints");
Directory.CreateDirectory(directory);
var path = Path.Combine(directory, fileName);
var path = Path.Combine(GetVRChatPhotosLocation(), fileName);
Directory.CreateDirectory(Path.GetDirectoryName(path));
if (File.Exists(path))
return false;

Expand Down
57 changes: 43 additions & 14 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17450,31 +17450,52 @@ speechSynthesis.getVoices();
$app.methods.refreshPrintTable = function () {
this.galleryDialogPrintsLoading = true;
var params = {
n: 100,
tag: 'print'
n: 100
};
API.getFileList(params);
API.getPrints(params);
};

API.$on('FILES:LIST', function (args) {
if (args.params.tag === 'print') {
$app.printTable = args.json.reverse();
$app.galleryDialogPrintsLoading = false;
}
});
API.getPrints = function (params) {
return this.call(`prints/user/${API.currentUser.id}`, {
method: 'GET',
params
}).then((json) => {
var args = {
json,
params
};
this.$emit('PRINT:LIST', args);
return args;
});
};

$app.methods.deletePrint = function (fileId) {
API.deleteFile(fileId).then((args) => {
API.$emit('PRINT:DELETE', args);
API.deletePrint = function (printId) {
return this.call(`prints/${printId}`, {
method: 'DELETE'
}).then((json) => {
var args = {
json,
printId
};
this.$emit('PRINT:DELETE', args);
return args;
});
};

API.$on('PRINT:LIST', function (args) {
$app.printTable = args.json.reverse();
$app.galleryDialogPrintsLoading = false;
});

$app.methods.deletePrint = function (printId) {
API.deletePrint(printId);
};

API.$on('PRINT:DELETE', function (args) {
var array = $app.printTable;
var { length } = array;
for (var i = 0; i < length; ++i) {
if (args.fileId === array[i].id) {
if (args.printId === array[i].id) {
array.splice(i, 1);
break;
}
Expand Down Expand Up @@ -17594,7 +17615,15 @@ speechSynthesis.getVoices();
console.error('Print image URL is missing', print);
return;
}
var fileName = `${printId}.png`;
var createdAt = new Date(print.json.createdAt);
var authorName = print.json.authorName;
// fileDate format: 2024-11-03_16-14-25.757
var fileNameDate = createdAt
.toISOString()
.replace(/:/g, '-')
.replace(/T/g, '_')
.replace(/Z/g, '');
var fileName = `Prints\\${createdAt.toISOString().slice(0, 7)}\\${authorName}_${fileNameDate}_${printId}.png`;
var status = await AppApi.SavePrintToFile(imageUrl, fileName);
if (status) {
console.log(`Print saved to file: ${fileName}`);
Expand Down
2 changes: 2 additions & 0 deletions html/src/localization/en/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@
},
"save_instance_prints_to_file": {
"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"
},
"remote_database": {
Expand Down Expand Up @@ -652,6 +653,7 @@
"sort_by": "Sort by:",
"edit_mode": "Edit Mode",
"exit_edit_mode": "Exit Edit Mode",
"hold_shift": "Hold shift to leave without confirmation",
"own_groups": "Own Groups",
"mutual_groups": "Mutual Groups",
"groups": "Groups",
Expand Down
14 changes: 10 additions & 4 deletions html/src/mixins/dialogs/currentUser.pug
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,15 @@ mixin currentUser()
el-button(type="default" size="small" @click="refreshPrintTable" icon="el-icon-refresh") {{ $t('dialog.gallery_icons.refresh') }}
//- el-button(type="default" size="small" @click="displayPrintUpload" icon="el-icon-upload2" :disabled="!API.currentUser.$isVRCPlus") {{ $t('dialog.gallery_icons.upload') }}
br
.x-friend-item(v-if="image.versions && image.versions.length > 0" v-for="image in printTable" :key="image.id" style="display:inline-block;margin-top:10px;width:unset;cursor:default")
.vrcplus-icon(v-if="image.versions[image.versions.length - 1].file.url" style="overflow:hidden" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)")
img.avatar(v-lazy="image.versions[image.versions.length - 1].file.url")
.x-friend-item(v-for="image in printTable" :key="image.id" style="display:inline-block;margin-top:10px;width:unset;cursor:default")
.vrcplus-icon(style="overflow:hidden" @click="showFullscreenImageDialog(image.files.image)")
img.avatar(v-lazy="image.files.image")
div(style="margin-top:5px")
span(v-text="image.note")
br
location(v-if="image.worldId" :location="image.worldId" :hint="image.worldName")
br
display-name(v-if="image.authorId" :userid="image.authorId" :hint="image.authorName" style="color:#909399;font-family:monospace")
div(style="float:right;margin-top:5px")
el-button(type="default" @click="showFullscreenImageDialog(image.versions[image.versions.length - 1].file.url)" size="mini" icon="el-icon-picture-outline" circle)
el-button(type="default" @click="showFullscreenImageDialog(image.files.image)" size="mini" icon="el-icon-picture-outline" circle)
el-button(type="default" @click="deletePrint(image.id)" size="mini" icon="el-icon-delete" circle style="margin-left:5px")
2 changes: 2 additions & 0 deletions html/src/mixins/dialogs/userDialog.pug
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ mixin userDialog()
el-tab-pane(:label="$t('dialog.user.groups.header')")
el-button(type="default" :loading="userDialog.isGroupsLoading" @click="getUserGroups(userDialog.id)" size="mini" icon="el-icon-refresh" circle)
span(style="margin-left:5px") {{ $t('dialog.user.groups.total_count', { count: userGroups.groups.length }) }}
template(v-if="userDialogGroupEditMode")
span(style="margin-left:10px;color:#909399;font-size:10px") {{ $t('dialog.user.groups.hold_shift') }}
div(style="float:right")
template(v-if="!userDialogGroupEditMode")
span(style="margin-right:5px") {{ $t('dialog.user.groups.sort_by') }}
Expand Down
2 changes: 2 additions & 0 deletions html/src/mixins/tabs/settings.pug
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ mixin settingsTab()
span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.local_world_persistence.description') }}
el-switch(v-model="disableWorldDatabase" :active-value="false" :inactive-value="true" @change="saveVRCXWindowOption")
span.sub-header {{ $t('view.settings.advanced.advanced.save_instance_prints_to_file.header') }}
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
div.options-container-item
span.name(style="min-width:300px") {{ $t('view.settings.advanced.advanced.save_instance_prints_to_file.description') }}
el-switch(v-model="saveInstancePrints" @change="saveVRCXWindowOption")
Expand Down

0 comments on commit db410a3

Please sign in to comment.