Skip to content

Commit

Permalink
Fix custom stickers/print paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Natsumi-sama committed Dec 21, 2024
1 parent 3579dd1 commit 0395c03
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 22 deletions.
8 changes: 4 additions & 4 deletions Dotnet/AppApi/AppApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,9 +627,9 @@ public string GetFileBase64(string path)
return null;
}

public async Task<bool> SavePrintToFile(string url, string path, string fileName)
public async Task<bool> SavePrintToFile(string url, string ugcFolderPath, string monthFolder, string fileName)
{
var folder = Path.Combine(GetUGCPhotoLocation(), "Prints", MakeValidFileName(path));
var folder = Path.Combine(GetUGCPhotoLocation(ugcFolderPath), "Prints", MakeValidFileName(monthFolder));
Directory.CreateDirectory(folder);
var filePath = Path.Combine(folder, MakeValidFileName(fileName));
if (File.Exists(filePath))
Expand All @@ -638,9 +638,9 @@ public async Task<bool> SavePrintToFile(string url, string path, string fileName
return await ImageCache.SaveImageToFile(url, filePath);
}

public async Task<bool> SaveStickerToFile(string url, string path, string fileName)
public async Task<bool> SaveStickerToFile(string url, string ugcFolderPath, string monthFolder, string fileName)
{
var folder = Path.Combine(GetUGCPhotoLocation(), "Stickers", MakeValidFileName(path));
var folder = Path.Combine(GetUGCPhotoLocation(ugcFolderPath), "Stickers", MakeValidFileName(monthFolder));
Directory.CreateDirectory(folder);
var filePath = Path.Combine(folder, MakeValidFileName(fileName));
if (File.Exists(filePath))
Expand Down
2 changes: 1 addition & 1 deletion Dotnet/AppApi/Folders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public string GetUGCPhotoLocation(string path = "")
}
catch (Exception e)
{
Console.WriteLine(e);
logger.Error(e);
return GetVRChatPhotosLocation();
}
}
Expand Down
42 changes: 25 additions & 17 deletions html/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7918,7 +7918,7 @@ speechSynthesis.getVoices();
$app.data.overlayToast = await configRepository.getString(
'VRCX_overlayToast',
'Game Running'
)
);
$app.data.minimalFeed = await configRepository.getBool(
'VRCX_minimalFeed',
false
Expand Down Expand Up @@ -7946,7 +7946,7 @@ speechSynthesis.getVoices();

// It's not necessary to store it in configRepo because it's rarely used.
$app.data.isTestTTSVisible = false;

$app.data.notificationTTSVoice = await configRepository.getString(
'VRCX_notificationTTSVoice',
'0'
Expand Down Expand Up @@ -8135,7 +8135,7 @@ speechSynthesis.getVoices();
await configRepository.setString(
'VRCX_overlayToast',
this.overlayToast
)
);
await configRepository.setBool(
'VRCX_notificationTTSNickName',
this.notificationTTSNickName
Expand Down Expand Up @@ -17773,15 +17773,20 @@ speechSynthesis.getVoices();
var args = await API.call(`file/${fileId}`);
var imageUrl = args.versions[1].file.url;
var createdAt = args.versions[0].created_at;
var path = createdAt.slice(0, 7);
var monthFolder = createdAt.slice(0, 7);
var fileNameDate = createdAt
.replace(/:/g, '-')
.replace(/T/g, '_')
.replace(/Z/g, '');
var fileName = `${displayName}_${fileNameDate}_${fileId}.png`;
var status = await AppApi.SaveStickerToFile(imageUrl, path, fileName);
var status = await AppApi.SaveStickerToFile(
imageUrl,
this.ugcFolderPath,
monthFolder,
fileName
);
if (status) {
console.log(`Sticker saved to file: ${path}\\${fileName}`);
console.log(`Sticker saved to file: ${monthFolder}\\${fileName}`);
}
};

Expand Down Expand Up @@ -18011,11 +18016,16 @@ speechSynthesis.getVoices();
return;
}
var createdAt = this.getPrintLocalDate(args.json);
var path = createdAt.toISOString().slice(0, 7);
var monthFolder = createdAt.toISOString().slice(0, 7);
var fileName = this.getPrintFileName(args.json);
var status = await AppApi.SavePrintToFile(imageUrl, path, fileName);
var status = await AppApi.SavePrintToFile(
imageUrl,
this.ugcFolderPath,
monthFolder,
fileName
);
if (status) {
console.log(`Print saved to file: ${path}\\${fileName}`);
console.log(`Print saved to file: ${monthFolder}\\${fileName}`);
}
};

Expand Down Expand Up @@ -20474,16 +20484,13 @@ speechSynthesis.getVoices();
};

$app.methods.setUGCFolderPath = async function (path) {
await configRepository.setString(
'VRCX_userGeneratedContentPath',
path
);
await configRepository.setString('VRCX_userGeneratedContentPath', path);
this.ugcFolderPath = path;
};

$app.methods.resetUGCFolder = function () {
this.setUGCFolderPath('');
}
};

$app.methods.openUGCFolder = async function () {
await AppApi.OpenUGCPhotosFolder(this.ugcFolderPath);
Expand All @@ -20492,11 +20499,12 @@ speechSynthesis.getVoices();
$app.methods.openUGCFolderSelector = async function () {
var D = this.userGeneratedContentDialog;

if(D.visible)
return;
if (D.visible) return;

D.visible = true;
var newUGCFolder = await AppApi.OpenFolderSelectorDialog(this.ugcFolderPath);
var newUGCFolder = await AppApi.OpenFolderSelectorDialog(
this.ugcFolderPath
);
D.visible = false;

await this.setUGCFolderPath(newUGCFolder);
Expand Down

0 comments on commit 0395c03

Please sign in to comment.