Fix duped key issue with sarc

This commit is contained in:
KillzXGaming 2019-05-18 13:17:43 -04:00
parent 387e8685fd
commit bcd21b9e4f
11 changed files with 42 additions and 2 deletions

Binary file not shown.

View file

@ -576,7 +576,7 @@ namespace FirstPlugin
sarcEntry.sarc = this; sarcEntry.sarc = this;
sarcEntry.Data = data; sarcEntry.Data = data;
Files.Add(name, data); Files.Add(fullName, data);
string ext = Path.GetExtension(name); string ext = Path.GetExtension(name);
string SarcEx = SARCExt.SARC.GuessFileExtension(data); string SarcEx = SARCExt.SARC.GuessFileExtension(data);

View file

@ -130,13 +130,18 @@
this.chkKeepAspectRatio.TabIndex = 15; this.chkKeepAspectRatio.TabIndex = 15;
this.chkKeepAspectRatio.Text = "Keep aspect ratio"; this.chkKeepAspectRatio.Text = "Keep aspect ratio";
this.chkKeepAspectRatio.UseVisualStyleBackColor = true; this.chkKeepAspectRatio.UseVisualStyleBackColor = true;
this.chkKeepAspectRatio.CheckedChanged += new System.EventHandler(this.chkKeepAspectRatio_CheckedChanged);
// //
// resampleCB // resampleCB
// //
this.resampleCB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); this.resampleCB.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.resampleCB.BorderColor = System.Drawing.Color.Empty;
this.resampleCB.BorderStyle = System.Windows.Forms.ButtonBorderStyle.Solid;
this.resampleCB.ButtonColor = System.Drawing.Color.Empty;
this.resampleCB.FormattingEnabled = true; this.resampleCB.FormattingEnabled = true;
this.resampleCB.Location = new System.Drawing.Point(564, 52); this.resampleCB.Location = new System.Drawing.Point(564, 52);
this.resampleCB.Name = "resampleCB"; this.resampleCB.Name = "resampleCB";
this.resampleCB.ReadOnly = true;
this.resampleCB.Size = new System.Drawing.Size(149, 21); this.resampleCB.Size = new System.Drawing.Size(149, 21);
this.resampleCB.TabIndex = 16; this.resampleCB.TabIndex = 16;
this.resampleCB.SelectedIndexChanged += new System.EventHandler(this.resampleCB_SelectedIndexChanged); this.resampleCB.SelectedIndexChanged += new System.EventHandler(this.resampleCB_SelectedIndexChanged);

View file

@ -41,16 +41,33 @@ namespace Switch_Toolbox.Library.Forms
UpdateImage(); UpdateImage();
} }
private bool IsUpdating = false;
private void UpdateImage() private void UpdateImage()
{ {
if (activeImage == null) if (activeImage == null)
return; return;
IsUpdating = true;
int ImageWidth = (int)widthUD.Value;
int ImageHeight = (int)heightUD.Value;
if (chkKeepAspectRatio.Checked)
ApplyRatio((int)widthUD.Value, (int)heightUD.Value, out ImageWidth, out ImageHeight);
if (ImageHeight <= 0) ImageHeight = 1;
if (ImageWidth <= 0) ImageWidth = 1;
widthUD.Value = ImageWidth;
heightUD.Value = ImageHeight;
newImage = BitmapExtension.ResizeImage( newImage = BitmapExtension.ResizeImage(
activeImage, (int)widthUD.Value, (int)heightUD.Value, activeImage, ImageWidth, ImageHeight,
(InterpolationMode)resampleCB.SelectedItem); (InterpolationMode)resampleCB.SelectedItem);
pictureBoxCustom1.Image = newImage; pictureBoxCustom1.Image = newImage;
IsUpdating = false;
} }
private void resampleCB_SelectedIndexChanged(object sender, EventArgs e) private void resampleCB_SelectedIndexChanged(object sender, EventArgs e)
@ -62,10 +79,28 @@ namespace Switch_Toolbox.Library.Forms
} }
private void widthUD_ValueChanged(object sender, EventArgs e) { private void widthUD_ValueChanged(object sender, EventArgs e) {
if (!IsUpdating)
UpdateImage(); UpdateImage();
} }
private void heightUD_ValueChanged(object sender, EventArgs e) { private void heightUD_ValueChanged(object sender, EventArgs e) {
if (!IsUpdating)
UpdateImage();
}
private void ApplyRatio(int Width, int Height, out int NewWidth, out int NewHeight)
{
double ratioX = (double)Width / (double)activeImage.Width;
double ratioY = (double)Height / (double)activeImage.Height;
// use whichever multiplier is smaller
double ratio = ratioX < ratioY ? ratioX : ratioY;
// now we can get the new height and width
NewHeight = Convert.ToInt32(activeImage.Height* ratio);
NewWidth = Convert.ToInt32(activeImage.Width* ratio);
}
private void chkKeepAspectRatio_CheckedChanged(object sender, EventArgs e) {
UpdateImage(); UpdateImage();
} }
} }