Fix performance stat "None", auto status change with company check, print crop and centering

This commit is contained in:
Natsumi
2024-12-27 12:48:16 +13:00
parent 5cf492c735
commit 87b79c9b7e
2 changed files with 62 additions and 16 deletions
+30 -11
View File
@@ -141,35 +141,51 @@ namespace VRCX
public byte[] ResizePrintImage(byte[] imageData) public byte[] ResizePrintImage(byte[] imageData)
{ {
var inputImage = ResizeImageToFitLimits(imageData, false, 1920, 1080); const int desiredWidth = 1920;
using var fileMemoryStream = new MemoryStream(inputImage); const int desiredHeight = 1080;
using var fileMemoryStream = new MemoryStream(imageData);
var image = new Bitmap(fileMemoryStream); var image = new Bitmap(fileMemoryStream);
// increase size to 1920x1080 // increase size to 1920x1080
if (image.Width < 1920 || image.Height < 1080) if (image.Width < desiredWidth || image.Height < desiredHeight)
{ {
var newHeight = image.Height; var newHeight = image.Height;
var newWidth = image.Width; var newWidth = image.Width;
if (image.Width < 1920) if (image.Width < desiredWidth)
{ {
newWidth = 1920; newWidth = desiredWidth;
newHeight = (int)Math.Round(image.Height / (image.Width / (double)newWidth)); newHeight = (int)Math.Round(image.Height / (image.Width / (double)newWidth));
} }
if (image.Height < 1080) if (image.Height < desiredHeight)
{ {
newHeight = 1080; newHeight = desiredHeight;
newWidth = (int)Math.Round(image.Width / (image.Height / (double)newHeight)); newWidth = (int)Math.Round(image.Width / (image.Height / (double)newHeight));
} }
var resizedImage = new Bitmap(1920, 1080); var resizedImage = new Bitmap(desiredWidth, desiredHeight);
using var graphics1 = Graphics.FromImage(resizedImage); using var graphics1 = Graphics.FromImage(resizedImage);
graphics1.Clear(Color.White); graphics1.Clear(Color.White);
var x = (1920 - newWidth) / 2; var x = (desiredWidth - newWidth) / 2;
var y = (1080 - newHeight) / 2; var y = (desiredHeight - newHeight) / 2;
graphics1.DrawImage(image, new Rectangle(x, y, newWidth, newHeight)); graphics1.DrawImage(image, new Rectangle(x, y, newWidth, newHeight));
image.Dispose(); image.Dispose();
image = resizedImage; image = resizedImage;
} }
// limit size to 1920x1080
if (image.Width > desiredWidth)
{
var sizingFactor = image.Width / (double)desiredWidth;
var newHeight = (int)Math.Round(image.Height / sizingFactor);
image = new Bitmap(image, desiredWidth, newHeight);
}
if (image.Height > desiredHeight)
{
var sizingFactor = image.Height / (double)desiredHeight;
var newWidth = (int)Math.Round(image.Width / sizingFactor);
image = new Bitmap(image, newWidth, desiredHeight);
}
// add white border // add white border
// wtf are these magic numbers // wtf are these magic numbers
const int xOffset = 64; // 2048 / 32 const int xOffset = 64; // 2048 / 32
@@ -177,7 +193,10 @@ namespace VRCX
var newImage = new Bitmap(2048, 1440); var newImage = new Bitmap(2048, 1440);
using var graphics = Graphics.FromImage(newImage); using var graphics = Graphics.FromImage(newImage);
graphics.Clear(Color.White); graphics.Clear(Color.White);
graphics.DrawImage(image, new Rectangle(xOffset, yOffset, image.Width, image.Height)); // graphics.DrawImage(image, new Rectangle(xOffset, yOffset, image.Width, image.Height));
var newX = (2048 - image.Width) / 2;
var newY = yOffset;
graphics.DrawImage(image, new Rectangle(newX, newY, image.Width, image.Height));
image.Dispose(); image.Dispose();
image = newImage; image = newImage;
+32 -5
View File
@@ -1876,6 +1876,12 @@ speechSynthesis.getVoices();
}); });
}; };
API.$on('AVATAR:IMPOSTER:DELETE', function (args) {
if (args.json && $app.avatarDialog.visible) {
$app.showAvatarDialog($app.avatarDialog.id);
}
});
// #endregion // #endregion
// #region | API: Notification // #region | API: Notification
@@ -6253,7 +6259,7 @@ speechSynthesis.getVoices();
var withCompany = this.lastLocation.playerList.size > 1; var withCompany = this.lastLocation.playerList.size > 1;
if (this.autoStateChangeNoFriends) { if (this.autoStateChangeNoFriends) {
withCompany = this.lastLocation.friendList.size > 1; withCompany = this.lastLocation.friendList.size >= 1;
} }
var currentStatus = API.currentUser.status; var currentStatus = API.currentUser.status;
@@ -10317,10 +10323,28 @@ speechSynthesis.getVoices();
continue; continue;
} }
if (unityPackage.platform === 'standalonewindows') { if (unityPackage.platform === 'standalonewindows') {
if (
unityPackage.performanceRating === 'None' &&
pc.performanceRating
) {
continue;
}
pc = unityPackage; pc = unityPackage;
} else if (unityPackage.platform === 'android') { } else if (unityPackage.platform === 'android') {
if (
unityPackage.performanceRating === 'None' &&
android.performanceRating
) {
continue;
}
android = unityPackage; android = unityPackage;
} else if (unityPackage.platform === 'ios') { } else if (unityPackage.platform === 'ios') {
if (
unityPackage.performanceRating === 'None' &&
ios.performanceRating
) {
continue;
}
ios = unityPackage; ios = unityPackage;
} }
} }
@@ -12019,7 +12043,6 @@ speechSynthesis.getVoices();
message: 'Imposter deleted', message: 'Imposter deleted',
type: 'success' type: 'success'
}); });
this.showAvatarDialog(D.id);
return args; return args;
}); });
break; break;
@@ -16346,8 +16369,12 @@ speechSynthesis.getVoices();
}; };
$app.methods.getAndDisplayScreenshotFromFile = async function () { $app.methods.getAndDisplayScreenshotFromFile = async function () {
var filePath = await AppApi.OpenFileSelectorDialog(await AppApi.GetVRChatPhotosLocation(), ".png", "PNG Files (*.png)|*.png"); var filePath = await AppApi.OpenFileSelectorDialog(
if (filePath === "") { await AppApi.GetVRChatPhotosLocation(),
'.png',
'PNG Files (*.png)|*.png'
);
if (filePath === '') {
return; return;
} }
@@ -22247,7 +22274,7 @@ speechSynthesis.getVoices();
var unityPackage = D.ref.unityPackages[i]; var unityPackage = D.ref.unityPackages[i];
if ( if (
unityPackage.variant && unityPackage.variant &&
unityPackage.variant !== 'standard' && // unityPackage.variant !== 'standard' &&
unityPackage.variant !== 'security' unityPackage.variant !== 'security'
) { ) {
continue; continue;