mirror of
https://github.com/kwsch/PKHeX.git
synced 2026-09-30 16:57:59 -05:00
Show Type/Value of block more cleanly
Show Type in DropDown Show Value in TextLabel Export Value as filename after Key, helps show value Import filename ignore content after Key (import accounting for value in export filename)
This commit is contained in:
@@ -399,10 +399,11 @@ private void InitializeComponent()
|
||||
//
|
||||
this.CB_Key.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest;
|
||||
this.CB_Key.AutoCompleteSource = System.Windows.Forms.AutoCompleteSource.ListItems;
|
||||
this.CB_Key.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.CB_Key.FormattingEnabled = true;
|
||||
this.CB_Key.Location = new System.Drawing.Point(89, 12);
|
||||
this.CB_Key.Name = "CB_Key";
|
||||
this.CB_Key.Size = new System.Drawing.Size(121, 21);
|
||||
this.CB_Key.Size = new System.Drawing.Size(183, 22);
|
||||
this.CB_Key.TabIndex = 0;
|
||||
this.CB_Key.SelectedIndexChanged += new System.EventHandler(this.CB_Key_SelectedIndexChanged);
|
||||
//
|
||||
|
||||
@@ -19,7 +19,7 @@ public SAV_BlockDump8(SaveFile sav)
|
||||
WinFormsUtil.TranslateInterface(this, Main.CurrentLanguage);
|
||||
SAV = (SAV8SWSH)sav;
|
||||
|
||||
var blocks = SAV.AllBlocks.Select((z, i) => new ComboItem($"{z.Key:X8} - {i:0000}", (int)z.Key));
|
||||
var blocks = SAV.AllBlocks.Select((z, i) => new ComboItem($"{z.Key:X8} - {i:0000} {z.Type}", (int)z.Key));
|
||||
CB_Key.InitializeBinding();
|
||||
CB_Key.DataSource = blocks.ToArray();
|
||||
}
|
||||
@@ -44,7 +44,7 @@ private void B_ExportAll_Click(object sender, EventArgs e)
|
||||
private static void ExportAllBlocks(IEnumerable<SCBlock> blocks, string path)
|
||||
{
|
||||
foreach (var b in blocks.Where(z => z.Data.Length != 0))
|
||||
File.WriteAllBytes(Path.Combine(path, $"{b.Key:X8}.bin"), b.Data);
|
||||
File.WriteAllBytes(Path.Combine(path, $"{GetBlockFileNameWithoutExtension(b)}.bin"), b.Data);
|
||||
}
|
||||
|
||||
private void B_ImportFolder_Click(object sender, EventArgs e)
|
||||
@@ -75,8 +75,8 @@ private void B_ExportAllSingle_Click(object sender, EventArgs e)
|
||||
|
||||
private static void ExportSelectBlock(SCBlock block)
|
||||
{
|
||||
var key = block.Key;
|
||||
using var sfd = new SaveFileDialog {FileName = $"{key:X8}.bin"};
|
||||
var name = GetBlockFileNameWithoutExtension(block);
|
||||
using var sfd = new SaveFileDialog {FileName = $"{name}.bin"};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
return;
|
||||
File.WriteAllBytes(sfd.FileName, block.Data);
|
||||
@@ -131,14 +131,28 @@ private static void ExportAllBlocksAsSingleFile(IReadOnlyList<SCBlock> blocks, s
|
||||
File.WriteAllBytes(path, data);
|
||||
}
|
||||
|
||||
private static string GetBlockFileNameWithoutExtension(SCBlock block)
|
||||
{
|
||||
var key = block.Key;
|
||||
var name = $"{key:X8}";
|
||||
if (block.HasValue())
|
||||
name += $" {block.GetValue()}";
|
||||
return name;
|
||||
}
|
||||
|
||||
private static string GetBlockSummary(SCBlock b)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
sb
|
||||
.Append("Key: ").AppendFormat("{0:X8}", b.Key).AppendLine()
|
||||
.Append("Length: ").AppendFormat("{0:X8}", b.Data.Length).AppendLine()
|
||||
.Append("Type: ").Append(b.Type).AppendLine()
|
||||
.Append("SubType: ").Append(b.SubType).AppendLine();
|
||||
sb.Append("Key: ").AppendFormat("{0:X8}", b.Key).AppendLine();
|
||||
sb.Append("Type: ").Append(b.Type).AppendLine();
|
||||
if (b.Data.Length != 0)
|
||||
sb.Append("Length: ").AppendFormat("{0:X8}", b.Data.Length).AppendLine();
|
||||
|
||||
if (b.SubType != 0)
|
||||
sb.Append("SubType: ").Append(b.SubType).AppendLine();
|
||||
else if (b.HasValue())
|
||||
sb.Append("Value: ").Append(b.GetValue()).AppendLine();
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
@@ -149,6 +163,12 @@ private static List<string> ImportBlocksFromFolder(string path, SAV8SWSH sav)
|
||||
foreach (var f in files)
|
||||
{
|
||||
var fn = Path.GetFileNameWithoutExtension(f);
|
||||
|
||||
// Trim off Value summary if present
|
||||
var space = fn.IndexOf(' ');
|
||||
if (space >= 0)
|
||||
fn = fn.Substring(0, space);
|
||||
|
||||
var hex = Util.GetHexValue(fn);
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user