mirror of
https://github.com/kwsch/pk3DS.git
synced 2026-10-02 05:46:47 -05:00
Finish TitleScreen editor
Added tooltip for the hidden workings. Fixed recomposition bug Added some logic to speed up repacking by using old compressed files if the file didn't change. Changed default form size and max/min dimensions
This commit is contained in:
8
pk3DS/Subforms/TitleScreen.Designer.cs
generated
8
pk3DS/Subforms/TitleScreen.Designer.cs
generated
@@ -40,7 +40,7 @@ private void InitializeComponent()
|
||||
//
|
||||
this.PB_Image.Location = new System.Drawing.Point(12, 66);
|
||||
this.PB_Image.Name = "PB_Image";
|
||||
this.PB_Image.Size = new System.Drawing.Size(315, 184);
|
||||
this.PB_Image.Size = new System.Drawing.Size(400, 240);
|
||||
this.PB_Image.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
|
||||
this.PB_Image.TabIndex = 0;
|
||||
this.PB_Image.TabStop = false;
|
||||
@@ -62,7 +62,7 @@ private void InitializeComponent()
|
||||
this.CB_File.FormattingEnabled = true;
|
||||
this.CB_File.Location = new System.Drawing.Point(12, 35);
|
||||
this.CB_File.Name = "CB_File";
|
||||
this.CB_File.Size = new System.Drawing.Size(315, 21);
|
||||
this.CB_File.Size = new System.Drawing.Size(400, 21);
|
||||
this.CB_File.TabIndex = 2;
|
||||
this.CB_File.SelectedIndexChanged += new System.EventHandler(this.changeFile);
|
||||
//
|
||||
@@ -88,7 +88,7 @@ private void InitializeComponent()
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(339, 262);
|
||||
this.ClientSize = new System.Drawing.Size(424, 316);
|
||||
this.Controls.Add(this.L_Dimensions);
|
||||
this.Controls.Add(this.L_DARCSelect);
|
||||
this.Controls.Add(this.CB_File);
|
||||
@@ -96,7 +96,7 @@ private void InitializeComponent()
|
||||
this.Controls.Add(this.PB_Image);
|
||||
this.MaximizeBox = false;
|
||||
this.MaximumSize = new System.Drawing.Size(555, 420);
|
||||
this.MinimumSize = new System.Drawing.Size(355, 220);
|
||||
this.MinimumSize = new System.Drawing.Size(440, 354);
|
||||
this.Name = "TitleScreen";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Title Screen Editor";
|
||||
|
||||
@@ -19,6 +19,9 @@ public TitleScreen()
|
||||
PB_Image.DragEnter += tabMain_DragEnter;
|
||||
PB_Image.DragDrop += tabMain_DragDrop;
|
||||
|
||||
// Add tooltip to image
|
||||
new ToolTip().SetToolTip(PB_Image, "Click to toggle Green Screen\nRightClick for I/O\nCTRL+Click for Copy->Clipboard.");
|
||||
|
||||
// Add context menus
|
||||
ContextMenuStrip mnu = new ContextMenuStrip();
|
||||
ToolStripMenuItem mnuR = new ToolStripMenuItem("Replace with...");
|
||||
@@ -47,7 +50,6 @@ public TitleScreen()
|
||||
usedFiles[i] = "titlescreen\\" + "dec_" + Path.GetFileName(files[darcFiles[i]]);
|
||||
// Decompress file
|
||||
CTR.LZSS.Decompress(files[darcFiles[i]], usedFiles[i]);
|
||||
File.Delete(files[darcFiles[i]]);
|
||||
// Read decompressed file
|
||||
var data = File.ReadAllBytes(usedFiles[i]);
|
||||
|
||||
@@ -122,7 +124,8 @@ private void changeFile(object sender, EventArgs e)
|
||||
}
|
||||
|
||||
PB_Image.Image = CropBMP;
|
||||
|
||||
Width
|
||||
Height
|
||||
// store image locally for saving if need be
|
||||
currentBytes = data;
|
||||
|
||||
@@ -197,7 +200,7 @@ private void tabMain_DragDrop(object sender, DragEventArgs e)
|
||||
|
||||
private void formClosing(object sender, FormClosingEventArgs e)
|
||||
{
|
||||
Util.Alert("Recompressing will take some time. Please let the form close on its own.");
|
||||
Util.Alert("Recompressing may take some time...", "Don't panic if the Progress Bar doesn't move!");
|
||||
// Write darcs
|
||||
for (int i = 0; i < darcs.Length; i++)
|
||||
{
|
||||
@@ -208,14 +211,20 @@ private void formClosing(object sender, FormClosingEventArgs e)
|
||||
pos += 4;
|
||||
if (pos >= data.Length) return;
|
||||
}
|
||||
byte[] preData = data.Skip(pos).ToArray();
|
||||
byte[] preData = data.Take(pos).ToArray();
|
||||
byte[] darcData = CTR.DARC.setDARC(darcs[i]);
|
||||
byte[] newData = preData.Concat(darcData).ToArray();
|
||||
|
||||
File.WriteAllBytes(usedFiles[i], newData);
|
||||
//// Compress Data
|
||||
//CTR.LZSS.Compress(usedFiles[i], files[darcFiles[i]]);
|
||||
//File.Delete(usedFiles[i]);
|
||||
byte[] oldDarc = File.ReadAllBytes(usedFiles[i]);
|
||||
if (newData.SequenceEqual(oldDarc)) // if same, just continue.
|
||||
{
|
||||
File.Delete(usedFiles[i]); // Use old compressed file (speedup)
|
||||
}
|
||||
else // File is different, replace and allow repacking to compress.
|
||||
{
|
||||
File.Delete(files[darcFiles[i]]); // delete the old compressed file
|
||||
File.WriteAllBytes(usedFiles[i], newData); // write the new edited (uncompressed) file
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user