push to github

This commit is contained in:
Manu
2022-11-02 22:49:00 +01:00
parent 79556c3909
commit 75fd9ea7f1
48 changed files with 12281 additions and 0 deletions

View File

@@ -0,0 +1,385 @@
namespace SwitchGiftDataManager.WinForm
{
partial class MainWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
this.BtnLGPE = new System.Windows.Forms.Button();
this.BtnSWSH = new System.Windows.Forms.Button();
this.BtnBDSP = new System.Windows.Forms.Button();
this.BtnSCVI = new System.Windows.Forms.Button();
this.BtnPLA = new System.Windows.Forms.Button();
this.ListBoxWC = new System.Windows.Forms.ListBox();
this.BtnOpen = new System.Windows.Forms.Button();
this.BtnSave = new System.Windows.Forms.Button();
this.GrpBCAT = new System.Windows.Forms.GroupBox();
this.BtnApply = new System.Windows.Forms.Button();
this.GrpContent = new System.Windows.Forms.GroupBox();
this.LblInfo5 = new System.Windows.Forms.Label();
this.LblInfo4 = new System.Windows.Forms.Label();
this.LblInfo3 = new System.Windows.Forms.Label();
this.LblInfo2 = new System.Windows.Forms.Label();
this.LblInfo1 = new System.Windows.Forms.Label();
this.TxtWCID = new System.Windows.Forms.TextBox();
this.LblWCID = new System.Windows.Forms.Label();
this.ContextMenuStripWC = new System.Windows.Forms.ContextMenuStrip(this.components);
this.BtnRemove = new System.Windows.Forms.ToolStripMenuItem();
this.BtnRemoveAll = new System.Windows.Forms.ToolStripMenuItem();
this.OpenFileDialogWC = new System.Windows.Forms.OpenFileDialog();
this.ToolTipWcid = new System.Windows.Forms.ToolTip(this.components);
this.GrpBCAT.SuspendLayout();
this.GrpContent.SuspendLayout();
this.ContextMenuStripWC.SuspendLayout();
this.SuspendLayout();
//
// BtnLGPE
//
this.BtnLGPE.AccessibleDescription = "";
this.BtnLGPE.AccessibleName = "";
this.BtnLGPE.Cursor = System.Windows.Forms.Cursors.Hand;
this.BtnLGPE.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnLGPE.Location = new System.Drawing.Point(5, 12);
this.BtnLGPE.Name = "BtnLGPE";
this.BtnLGPE.Size = new System.Drawing.Size(136, 60);
this.BtnLGPE.TabIndex = 0;
this.BtnLGPE.TabStop = false;
this.BtnLGPE.Text = "LGPE";
this.BtnLGPE.UseVisualStyleBackColor = true;
this.BtnLGPE.Click += new System.EventHandler(this.BtnLGPE_Click);
//
// BtnSWSH
//
this.BtnSWSH.AccessibleDescription = "";
this.BtnSWSH.AccessibleName = "";
this.BtnSWSH.Cursor = System.Windows.Forms.Cursors.Hand;
this.BtnSWSH.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnSWSH.Location = new System.Drawing.Point(147, 12);
this.BtnSWSH.Name = "BtnSWSH";
this.BtnSWSH.Size = new System.Drawing.Size(136, 60);
this.BtnSWSH.TabIndex = 1;
this.BtnSWSH.TabStop = false;
this.BtnSWSH.Text = "SWSH";
this.BtnSWSH.UseVisualStyleBackColor = true;
this.BtnSWSH.Click += new System.EventHandler(this.BtnSWSH_Click);
//
// BtnBDSP
//
this.BtnBDSP.AccessibleDescription = "";
this.BtnBDSP.AccessibleName = "";
this.BtnBDSP.Cursor = System.Windows.Forms.Cursors.Hand;
this.BtnBDSP.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnBDSP.Location = new System.Drawing.Point(289, 12);
this.BtnBDSP.Name = "BtnBDSP";
this.BtnBDSP.Size = new System.Drawing.Size(136, 60);
this.BtnBDSP.TabIndex = 2;
this.BtnBDSP.TabStop = false;
this.BtnBDSP.Text = "BDSP";
this.BtnBDSP.UseVisualStyleBackColor = true;
this.BtnBDSP.Click += new System.EventHandler(this.BtnBDSP_Click);
//
// BtnSCVI
//
this.BtnSCVI.AccessibleDescription = "";
this.BtnSCVI.AccessibleName = "";
this.BtnSCVI.Cursor = System.Windows.Forms.Cursors.Hand;
this.BtnSCVI.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnSCVI.Location = new System.Drawing.Point(573, 12);
this.BtnSCVI.Name = "BtnSCVI";
this.BtnSCVI.Size = new System.Drawing.Size(136, 60);
this.BtnSCVI.TabIndex = 3;
this.BtnSCVI.TabStop = false;
this.BtnSCVI.Text = "SCVI";
this.BtnSCVI.UseVisualStyleBackColor = true;
this.BtnSCVI.Click += new System.EventHandler(this.BtnSCVI_Click);
//
// BtnPLA
//
this.BtnPLA.AccessibleDescription = "";
this.BtnPLA.AccessibleName = "";
this.BtnPLA.Cursor = System.Windows.Forms.Cursors.Hand;
this.BtnPLA.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.BtnPLA.Location = new System.Drawing.Point(431, 12);
this.BtnPLA.Name = "BtnPLA";
this.BtnPLA.Size = new System.Drawing.Size(136, 60);
this.BtnPLA.TabIndex = 4;
this.BtnPLA.TabStop = false;
this.BtnPLA.Text = "PLA";
this.BtnPLA.UseVisualStyleBackColor = true;
this.BtnPLA.Click += new System.EventHandler(this.BtnPLA_Click);
//
// ListBoxWC
//
this.ListBoxWC.AllowDrop = true;
this.ListBoxWC.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawFixed;
this.ListBoxWC.FormattingEnabled = true;
this.ListBoxWC.ItemHeight = 20;
this.ListBoxWC.Location = new System.Drawing.Point(7, 96);
this.ListBoxWC.Name = "ListBoxWC";
this.ListBoxWC.Size = new System.Drawing.Size(214, 304);
this.ListBoxWC.TabIndex = 5;
this.ToolTipWcid.SetToolTip(this.ListBoxWC, " Wondercards with duplicated WC ID will not be seen by the" +
" game. ");
this.ListBoxWC.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.ListBoxWC_DrawItem);
this.ListBoxWC.SelectedIndexChanged += new System.EventHandler(this.ListBoxWC_SelectedIndexChanged);
this.ListBoxWC.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ListBoxWC_MouseUp);
this.ListBoxWC.DragEnter += new DragEventHandler(this.FileDragEnter);
this.ListBoxWC.DragDrop += new DragEventHandler(this.FileDragDrop);
//
// BtnOpen
//
this.BtnOpen.Location = new System.Drawing.Point(7, 26);
this.BtnOpen.Name = "BtnOpen";
this.BtnOpen.Size = new System.Drawing.Size(214, 29);
this.BtnOpen.TabIndex = 6;
this.BtnOpen.Text = "Open Wondercard Files...";
this.BtnOpen.UseVisualStyleBackColor = true;
this.BtnOpen.Click += new System.EventHandler(this.BtnOpen_Click);
//
// BtnSave
//
this.BtnSave.Enabled = false;
this.BtnSave.Location = new System.Drawing.Point(6, 61);
this.BtnSave.Name = "BtnSave";
this.BtnSave.Size = new System.Drawing.Size(214, 29);
this.BtnSave.TabIndex = 7;
this.BtnSave.Text = "Save as BCAT Package...";
this.BtnSave.UseVisualStyleBackColor = true;
this.BtnSave.Click += new System.EventHandler(this.BtnSave_Click);
//
// GrpBCAT
//
this.GrpBCAT.Controls.Add(this.BtnApply);
this.GrpBCAT.Controls.Add(this.GrpContent);
this.GrpBCAT.Controls.Add(this.TxtWCID);
this.GrpBCAT.Controls.Add(this.LblWCID);
this.GrpBCAT.Controls.Add(this.ListBoxWC);
this.GrpBCAT.Controls.Add(this.BtnSave);
this.GrpBCAT.Controls.Add(this.BtnOpen);
this.GrpBCAT.Enabled = false;
this.GrpBCAT.Location = new System.Drawing.Point(5, 78);
this.GrpBCAT.Name = "GrpBCAT";
this.GrpBCAT.Size = new System.Drawing.Size(704, 409);
this.GrpBCAT.TabIndex = 8;
this.GrpBCAT.TabStop = false;
this.GrpBCAT.Text = "BCAT Manager";
//
// BtnApply
//
this.BtnApply.Enabled = false;
this.BtnApply.Location = new System.Drawing.Point(426, 355);
this.BtnApply.Name = "BtnApply";
this.BtnApply.Size = new System.Drawing.Size(97, 32);
this.BtnApply.TabIndex = 11;
this.BtnApply.Text = "Apply";
this.BtnApply.UseVisualStyleBackColor = true;
this.BtnApply.Click += new System.EventHandler(this.BtnApply_Click);
//
// GrpContent
//
this.GrpContent.Controls.Add(this.LblInfo5);
this.GrpContent.Controls.Add(this.LblInfo4);
this.GrpContent.Controls.Add(this.LblInfo3);
this.GrpContent.Controls.Add(this.LblInfo2);
this.GrpContent.Controls.Add(this.LblInfo1);
this.GrpContent.Enabled = false;
this.GrpContent.Location = new System.Drawing.Point(294, 99);
this.GrpContent.Name = "GrpContent";
this.GrpContent.Size = new System.Drawing.Size(358, 250);
this.GrpContent.TabIndex = 10;
this.GrpContent.TabStop = false;
this.GrpContent.Text = "Gift Content";
//
// LblInfo5
//
this.LblInfo5.AutoSize = true;
this.LblInfo5.Location = new System.Drawing.Point(152, 188);
this.LblInfo5.Name = "LblInfo5";
this.LblInfo5.Size = new System.Drawing.Size(49, 20);
this.LblInfo5.TabIndex = 4;
this.LblInfo5.Text = "Info_5";
this.LblInfo5.Visible = false;
this.LblInfo5.SizeChanged += new System.EventHandler(this.LblInfo_SizeChanged);
//
// LblInfo4
//
this.LblInfo4.AutoSize = true;
this.LblInfo4.Location = new System.Drawing.Point(152, 153);
this.LblInfo4.Name = "LblInfo4";
this.LblInfo4.Size = new System.Drawing.Size(49, 20);
this.LblInfo4.TabIndex = 3;
this.LblInfo4.Text = "Info_4";
this.LblInfo4.Visible = false;
this.LblInfo4.SizeChanged += new System.EventHandler(this.LblInfo_SizeChanged);
//
// LblInfo3
//
this.LblInfo3.AutoSize = true;
this.LblInfo3.Location = new System.Drawing.Point(152, 118);
this.LblInfo3.Name = "LblInfo3";
this.LblInfo3.Size = new System.Drawing.Size(49, 20);
this.LblInfo3.TabIndex = 2;
this.LblInfo3.Text = "Info_3";
this.LblInfo3.Visible = false;
this.LblInfo3.SizeChanged += new System.EventHandler(this.LblInfo_SizeChanged);
//
// LblInfo2
//
this.LblInfo2.AutoSize = true;
this.LblInfo2.Location = new System.Drawing.Point(152, 83);
this.LblInfo2.Name = "LblInfo2";
this.LblInfo2.Size = new System.Drawing.Size(49, 20);
this.LblInfo2.TabIndex = 1;
this.LblInfo2.Text = "Info_2";
this.LblInfo2.Visible = false;
this.LblInfo2.SizeChanged += new System.EventHandler(this.LblInfo_SizeChanged);
//
// LblInfo1
//
this.LblInfo1.AutoSize = true;
this.LblInfo1.Location = new System.Drawing.Point(152, 48);
this.LblInfo1.Name = "LblInfo1";
this.LblInfo1.Size = new System.Drawing.Size(49, 20);
this.LblInfo1.TabIndex = 0;
this.LblInfo1.Text = "Info_1";
this.LblInfo1.Visible = false;
this.LblInfo1.SizeChanged += new System.EventHandler(this.LblInfo_SizeChanged);
//
// TxtWCID
//
this.TxtWCID.Enabled = false;
this.TxtWCID.Location = new System.Drawing.Point(435, 63);
this.TxtWCID.MaxLength = 4;
this.TxtWCID.Name = "TxtWCID";
this.TxtWCID.Size = new System.Drawing.Size(115, 27);
this.TxtWCID.TabIndex = 9;
this.TxtWCID.TextChanged += new System.EventHandler(this.TxtWCID_TextChanged);
this.TxtWCID.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.TxtWCID_KeyPress);
//
// LblWCID
//
this.LblWCID.AutoSize = true;
this.LblWCID.Enabled = false;
this.LblWCID.Location = new System.Drawing.Point(375, 66);
this.LblWCID.Name = "LblWCID";
this.LblWCID.Size = new System.Drawing.Size(54, 20);
this.LblWCID.TabIndex = 8;
this.LblWCID.Text = "WC ID:";
//
// ContextMenuStripWC
//
this.ContextMenuStripWC.ImageScalingSize = new System.Drawing.Size(20, 20);
this.ContextMenuStripWC.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.BtnRemove,
this.BtnRemoveAll});
this.ContextMenuStripWC.Name = "ConextMenuStripWC";
this.ContextMenuStripWC.Size = new System.Drawing.Size(155, 52);
this.ContextMenuStripWC.Text = "Remove";
//
// BtnRemove
//
this.BtnRemove.Name = "BtnRemove";
this.BtnRemove.Size = new System.Drawing.Size(154, 24);
this.BtnRemove.Text = "Remove";
this.BtnRemove.Click += new System.EventHandler(this.BtnRemove_Click);
//
// BtnRemoveAll
//
this.BtnRemoveAll.Name = "BtnRemoveAll";
this.BtnRemoveAll.Size = new System.Drawing.Size(154, 24);
this.BtnRemoveAll.Text = "Remove All";
this.BtnRemoveAll.Click += new System.EventHandler(this.BtnRemoveAll_Click);
//
// OpenFileDialogWC
//
this.OpenFileDialogWC.Multiselect = true;
//
// ToolTipWcid
//
this.ToolTipWcid.AutoPopDelay = 100000;
this.ToolTipWcid.InitialDelay = 500;
this.ToolTipWcid.OwnerDraw = true;
this.ToolTipWcid.ReshowDelay = 100;
this.ToolTipWcid.UseAnimation = false;
this.ToolTipWcid.UseFading = false;
this.ToolTipWcid.Draw += new System.Windows.Forms.DrawToolTipEventHandler(this.ToolTipWcid_Draw);
//
// MainWindow
//
this.AllowDrop = true;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(715, 495);
this.Controls.Add(this.GrpBCAT);
this.Controls.Add(this.BtnPLA);
this.Controls.Add(this.BtnSCVI);
this.Controls.Add(this.BtnBDSP);
this.Controls.Add(this.BtnSWSH);
this.Controls.Add(this.BtnLGPE);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainWindow";
this.Text = "Switch Gift Data Manager v1.0.0";
this.GrpBCAT.ResumeLayout(false);
this.GrpBCAT.PerformLayout();
this.GrpContent.ResumeLayout(false);
this.GrpContent.PerformLayout();
this.ContextMenuStripWC.ResumeLayout(false);
this.ResumeLayout(false);
this.DragEnter += new DragEventHandler(this.FileDragEnter);
this.DragDrop += new DragEventHandler(this.FileDragDrop);
}
#endregion
private Button BtnLGPE;
private Button BtnSWSH;
private Button BtnBDSP;
private Button BtnSCVI;
private Button BtnPLA;
private ListBox ListBoxWC;
private Button BtnOpen;
private Button BtnSave;
private GroupBox GrpBCAT;
private Button BtnApply;
private GroupBox GrpContent;
private TextBox TxtWCID;
private Label LblWCID;
private ContextMenuStrip ContextMenuStripWC;
private ToolStripMenuItem BtnRemove;
private Label LblInfo5;
private Label LblInfo4;
private Label LblInfo3;
private Label LblInfo2;
private Label LblInfo1;
private OpenFileDialog OpenFileDialogWC;
private ToolStripMenuItem BtnRemoveAll;
private ToolTip ToolTipWcid;
}
}

View File

@@ -0,0 +1,404 @@
using System.Text.RegularExpressions;
using SwitchGiftDataManager.Core;
using Enums;
namespace SwitchGiftDataManager.WinForm
{
public partial class MainWindow : Form
{
private Games CurrentGame = Games.None;
private BCATManager PackageLGPE = new (Games.LGPE);
private BCATManager PackageSWSH = new (Games.SWSH);
private BCATManager PackageBDSP = new (Games.BDSP);
private BCATManager PackagePLA = new (Games.PLA);
private BCATManager PackageSCVI = new (Games.SCVI);
private List<ushort> Duplicated = new List<ushort>();
public MainWindow() => InitializeComponent();
private void ChangeGame(Games game)
{
GrpBCAT.Enabled = true;
CurrentGame = game;
RestoreMenu();
EditFileFilter();
EditGameButton();
UpdateWCList();
ListBoxWC.SelectedIndex = -1;
DisableContent();
}
private void RestoreMenu()
{
BtnLGPE.Enabled = true;
BtnSWSH.Enabled = true;
BtnBDSP.Enabled = true;
BtnPLA.Enabled = true;
BtnSCVI.Enabled = true;
BtnLGPE.Font = new Font(BtnLGPE.Font.Name, BtnLGPE.Font.Size, FontStyle.Regular);
BtnSWSH.Font = new Font(BtnSWSH.Font.Name, BtnSWSH.Font.Size, FontStyle.Regular);
BtnBDSP.Font = new Font(BtnBDSP.Font.Name, BtnBDSP.Font.Size, FontStyle.Regular);
BtnPLA.Font = new Font(BtnPLA.Font.Name, BtnPLA.Font.Size, FontStyle.Regular);
BtnSCVI.Font = new Font(BtnSCVI.Font.Name, BtnSCVI.Font.Size, FontStyle.Regular);
}
private void EditFileFilter()
{
OpenFileDialogWC.Filter = CurrentGame switch
{
Games.LGPE => "wb7full files (*.wb7full)|*.wb7full|All files (*.*)|*.*",
Games.SWSH => "wc8 files (*.wc8)|*.wc8|All files (*.*)|*.*",
Games.BDSP => "wb8 files (*.wb8)|*.wb8|All files (*.*)|*.*",
Games.PLA => "wa8 files (*.wa8)|*.wa8|All files (*.*)|*.*",
Games.SCVI => "wc9 files (*.wc9)|*.wc9|All files (*.*)|*.*",
_ => "All files (*.*)|*.*",
};
}
private void EditGameButton()
{
Button btn = CurrentGame switch
{
Games.LGPE => BtnLGPE,
Games.SWSH => BtnSWSH,
Games.BDSP => BtnBDSP,
Games.PLA => BtnPLA,
Games.SCVI => BtnSCVI,
_ => throw new ArgumentOutOfRangeException(),
};
EditSelectedButton(btn);
}
private void EditSelectedButton(Button btn)
{
btn.Font = new Font(btn.Font.Name, btn.Font.Size, FontStyle.Bold);
btn.Enabled = false;
}
private void UpdateWCList()
{
if (ListBoxWC.Items.Count > 0)
ListBoxWC.Items.Clear();
var list = CurrentGame switch
{
Games.LGPE => PackageLGPE.GetListNames(),
Games.SWSH => PackageSWSH.GetListNames(),
Games.BDSP => PackageBDSP.GetListNames(),
Games.PLA => PackagePLA.GetListNames(),
Games.SCVI => PackageSCVI.GetListNames(),
_ => throw new ArgumentOutOfRangeException(),
};
UpdateDuplicatedList();
foreach (var el in list)
ListBoxWC.Items.Add(el);
if (ListBoxWC.Items.Count > 0)
BtnSave.Enabled = true;
else
BtnSave.Enabled = false;
}
private void UpdateDuplicatedList()
{
var list = GetCurrentList().GetDuplicatedWCID();
if (list != null)
Duplicated = list;
else
Duplicated = new List<ushort> { 0 };
}
private BCATManager GetCurrentList()
{
return CurrentGame switch
{
Games.LGPE => PackageLGPE,
Games.SWSH => PackageSWSH,
Games.BDSP => PackageBDSP,
Games.PLA => PackagePLA,
Games.SCVI => PackageSCVI,
_ => throw new ArgumentOutOfRangeException(),
};
}
private void LoadLocalFiles(string[] files)
{
DisableContent();
var list = GetCurrentList();
var errList = new List<string>();
foreach (var path in files)
{
var data = File.ReadAllBytes(path);
var success = list.TryAddWondercards(data.AsSpan());
if (!success)
{
if (errList.Count == 0)
if (CurrentGame is Games.LGPE && list.Count() >= 1)
errList.Add("LGPE only supports one (1) wondercard at a time. Aborted file(s):\n");
else
errList.Add($"Attempted to load invalid files. Aborted file(s):\n");
errList.Add($"- {Path.GetFileName(path)}");
}
}
if (errList.Count > 0)
{
var msg = "";
foreach (var err in errList)
msg = $"{msg}\n{err}";
MessageBox.Show(msg);
}
list.Sort();
UpdateWCList();
}
private void BtnLGPE_Click(object sender, EventArgs e) => ChangeGame(Games.LGPE);
private void BtnSWSH_Click(object sender, EventArgs e) => ChangeGame(Games.SWSH);
private void BtnBDSP_Click(object sender, EventArgs e) => ChangeGame(Games.BDSP);
private void BtnPLA_Click(object sender, EventArgs e) => ChangeGame(Games.PLA);
private void BtnSCVI_Click(object sender, EventArgs e) //=> ChangeGame(Games.SCVI);
{
ChangeGame(Games.SCVI);
GrpBCAT.Enabled = false;
MessageBox.Show("Scarlet and Violet features still not available.");
}
private void BtnSave_Click(object sender, EventArgs e) => new SaveWindow(GetCurrentList(), CurrentGame).Show();
private void BtnApply_Click(object sender, EventArgs e)
{
try
{
var list = GetCurrentList();
var wcid = UInt16.Parse(TxtWCID.Text);
var index = list.GetIndex(wcid);
if (index == -1)
{
list.SetWCID(ListBoxWC.SelectedIndex, wcid);
list.Sort();
UpdateWCList();
ListBoxWC.SelectedIndex = list.GetIndex(wcid);
BtnApply.Enabled = false;
}
else
{
MessageBox.Show($"WCID {wcid} already exists.");
return;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
return;
}
}
private void BtnRemove_Click(object sender, EventArgs e)
{
var list = GetCurrentList();
list.RemoveWC(ListBoxWC.SelectedIndex);
ListBoxWC.SelectedIndex = -1;
DisableContent();
UpdateWCList();
}
private void BtnRemoveAll_Click(object sender, EventArgs e)
{
var list = GetCurrentList();
list.Reset();
ListBoxWC.SelectedIndex = -1;
DisableContent();
UpdateWCList();
}
private void BtnOpen_Click(object sender, EventArgs e)
{
if (OpenFileDialogWC.ShowDialog() == DialogResult.OK)
LoadLocalFiles(OpenFileDialogWC.FileNames);
}
void FileDragEnter(object sender, DragEventArgs e)
{
if(e.Data is not null && CurrentGame is not (Games.None or Games.SCVI))
if (e.Data.GetDataPresent(DataFormats.FileDrop))
e.Effect = DragDropEffects.Copy;
}
void FileDragDrop(object sender, DragEventArgs e)
{
if (e.Data is not null && CurrentGame is not (Games.None or Games.SCVI))
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
LoadLocalFiles(files);
}
}
private void TxtWCID_KeyPress(object sender, KeyPressEventArgs e)
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
}
private void TxtWCID_TextChanged(object sender, EventArgs e)
{
if (!TxtWCID.Text.Equals(""))
{
var list = GetCurrentList();
var newWcid = UInt16.Parse(TxtWCID.Text);
var oldWcid = list.GetWCID(ListBoxWC.SelectedIndex);
if (oldWcid > 0 && newWcid > 0 && newWcid != oldWcid)
BtnApply.Enabled = true;
else
BtnApply.Enabled = false;
}
}
private void ToolTipWcid_Draw(object sender, DrawToolTipEventArgs e)
{
Point screenPosition = ListBox.MousePosition;
Point listBoxClientAreaPosition = ListBoxWC.PointToClient(screenPosition);
int hoveredIndex = ListBoxWC.IndexFromPoint(listBoxClientAreaPosition);
if (hoveredIndex > -1)
{
var str = ListBoxWC.Items[hoveredIndex].ToString()!;
if (str.Contains('\u26A0'))
{
var msg = "Wondercards with duplicated identifiers may cause issues and will not be seen by the game.";
e.DrawBackground();
Graphics g = e.Graphics;
g.DrawString(msg, e.Font!, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
}
else if (str.Contains('\u2757'))
{
var msg = "Wondercard count is above the maximum allowed, or the WCID is over the maximum allowed.";
e.DrawBackground();
Graphics g = e.Graphics;
g.DrawString(msg, e.Font!, new SolidBrush(Color.Black), new PointF(e.Bounds.X, e.Bounds.Y));
}
else
{
ToolTipWcid.Hide(ListBoxWC);
}
}
else
ToolTipWcid.Hide(ListBoxWC);
}
private void ListBoxWC_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
var index = ListBoxWC.IndexFromPoint(e.X, e.Y);
if (index >= 0)
{
ListBoxWC.SelectedIndex = index;
ContextMenuStripWC.Show(Cursor.Position);
}
}
}
private void ListBoxWC_SelectedIndexChanged(object sender, EventArgs e)
{
if (ListBoxWC.SelectedIndex > -1)
{
var list = GetCurrentList();
var content = list.GetContentToString(ListBoxWC.SelectedIndex);
var nItem = content.Count();
if (nItem >= 1)
LblInfo1.Text = content.ElementAt(1);
if (nItem >= 2)
LblInfo2.Text = content.ElementAt(2);
if (nItem >= 3)
LblInfo3.Text = content.ElementAt(3);
if (nItem >= 4)
LblInfo4.Text = content.ElementAt(4);
if (nItem >= 5)
LblInfo5.Text = content.ElementAt(5);
TxtWCID.Text = content.ElementAt(0);
EnableContent();
}
else
DisableContent();
}
private void ListBoxWC_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index > -1)
{
e.DrawBackground();
Graphics g = e.Graphics;
var curr = ((ListBox)sender).Items[e.Index].ToString()!;
var wcid = UInt16.Parse(Regex.Match(curr, @"(?<=\#)(.*?)(?=\:)").Groups[1].Value);
var handled = false;
if ((CurrentGame is Games.BDSP && wcid >= 2048) || (CurrentGame is Games.SWSH && e.Index >= 129))
{
if(!curr.Contains('\u2757'))
((ListBox)sender).Items[e.Index] = $"{curr} \u2757";
g.FillRectangle(new SolidBrush(Color.IndianRed), e.Bounds);
g.DrawString(((ListBox)sender).Items[e.Index].ToString(), e.Font!, new SolidBrush(e.ForeColor), new PointF(e.Bounds.X, e.Bounds.Y));
handled = true;
}
foreach (var d in Duplicated)
{
if (d == wcid)
{
if (!curr.Contains('\u26A0'))
((ListBox)sender).Items[e.Index] = $"{curr} \u26A0";
g.FillRectangle(new SolidBrush(Color.Orange), e.Bounds);
g.DrawString(((ListBox)sender).Items[e.Index].ToString(), e.Font!, new SolidBrush(e.ForeColor), new PointF(e.Bounds.X, e.Bounds.Y));
handled = true;
}
}
if(!handled)
g.DrawString(curr, e.Font!, new SolidBrush(e.ForeColor), new PointF(e.Bounds.X, e.Bounds.Y));
}
}
private void LblInfo_SizeChanged(object sender, EventArgs e)
{
var lbl = (Label)sender;
lbl.Left = (GrpContent.Width - lbl.Width) / 2;
}
private void EnableContent()
{
TxtWCID.Enabled = true;
LblWCID.Enabled = true;
LblInfo1.Visible = true;
LblInfo2.Visible = true;
LblInfo3.Visible = true;
LblInfo4.Visible = true;
LblInfo5.Visible = true;
GrpContent.Enabled = true;
}
private void DisableContent()
{
TxtWCID.Text = "";
TxtWCID.Enabled = false;
LblWCID.Enabled = false;
LblInfo1.Text = "";
LblInfo1.Visible = false;
LblInfo2.Text = "";
LblInfo2.Visible = false;
LblInfo3.Text = "";
LblInfo3.Visible = false;
LblInfo4.Text = "";
LblInfo4.Visible = false;
LblInfo5.Text = "";
LblInfo5.Visible = false;
GrpContent.Enabled = false;
BtnApply.Enabled = false;
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,17 @@
namespace SwitchGiftDataManager.WinForm
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new MainWindow());
}
}
}

View File

@@ -0,0 +1,83 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace SwitchGiftDataManager.WinForm.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SwitchGiftDataManager.WinForm.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Icon similar to (Icon).
/// </summary>
internal static System.Drawing.Icon icon {
get {
object obj = ResourceManager.GetObject("icon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon1 {
get {
object obj = ResourceManager.GetObject("icon1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="icon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

View File

@@ -0,0 +1,201 @@
namespace SwitchGiftDataManager.WinForm
{
partial class SaveWindow
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SaveWindow));
this.GrpBuild = new System.Windows.Forms.GroupBox();
this.RadioUnique = new System.Windows.Forms.RadioButton();
this.RadioMultiple = new System.Windows.Forms.RadioButton();
this.TxtDestPath = new System.Windows.Forms.TextBox();
this.BtnPath = new System.Windows.Forms.Button();
this.GrpDest = new System.Windows.Forms.GroupBox();
this.BtnCancel = new System.Windows.Forms.Button();
this.BtnSave = new System.Windows.Forms.Button();
this.FolderBrowser = new System.Windows.Forms.FolderBrowserDialog();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.BtnSrcBrowse = new System.Windows.Forms.Button();
this.TxtSourcePath = new System.Windows.Forms.TextBox();
this.GrpBuild.SuspendLayout();
this.GrpDest.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// GrpBuild
//
this.GrpBuild.Controls.Add(this.RadioUnique);
this.GrpBuild.Controls.Add(this.RadioMultiple);
this.GrpBuild.Location = new System.Drawing.Point(12, 12);
this.GrpBuild.Name = "GrpBuild";
this.GrpBuild.Size = new System.Drawing.Size(458, 58);
this.GrpBuild.TabIndex = 0;
this.GrpBuild.TabStop = false;
this.GrpBuild.Text = "Build Method";
//
// RadioUnique
//
this.RadioUnique.AutoSize = true;
this.RadioUnique.Location = new System.Drawing.Point(238, 26);
this.RadioUnique.Name = "RadioUnique";
this.RadioUnique.Size = new System.Drawing.Size(156, 24);
this.RadioUnique.TabIndex = 1;
this.RadioUnique.Text = "Keep separate files";
this.RadioUnique.UseVisualStyleBackColor = true;
//
// RadioMultiple
//
this.RadioMultiple.AutoSize = true;
this.RadioMultiple.Checked = true;
this.RadioMultiple.Location = new System.Drawing.Point(76, 26);
this.RadioMultiple.Name = "RadioMultiple";
this.RadioMultiple.Size = new System.Drawing.Size(145, 24);
this.RadioMultiple.TabIndex = 0;
this.RadioMultiple.TabStop = true;
this.RadioMultiple.Text = "Merge as one file";
this.RadioMultiple.UseVisualStyleBackColor = true;
//
// TxtDestPath
//
this.TxtDestPath.Location = new System.Drawing.Point(6, 26);
this.TxtDestPath.Name = "TxtDestPath";
this.TxtDestPath.Size = new System.Drawing.Size(358, 27);
this.TxtDestPath.TabIndex = 1;
//
// BtnPath
//
this.BtnPath.Location = new System.Drawing.Point(370, 26);
this.BtnPath.Name = "BtnPath";
this.BtnPath.Size = new System.Drawing.Size(82, 29);
this.BtnPath.TabIndex = 2;
this.BtnPath.Text = "Browse";
this.BtnPath.UseVisualStyleBackColor = true;
this.BtnPath.Click += new System.EventHandler(this.BtnPath_Click);
//
// GrpDest
//
this.GrpDest.Controls.Add(this.TxtDestPath);
this.GrpDest.Controls.Add(this.BtnPath);
this.GrpDest.Location = new System.Drawing.Point(12, 153);
this.GrpDest.Name = "GrpDest";
this.GrpDest.Size = new System.Drawing.Size(458, 66);
this.GrpDest.TabIndex = 3;
this.GrpDest.TabStop = false;
this.GrpDest.Text = "Destination BCAT Path";
//
// BtnCancel
//
this.BtnCancel.Location = new System.Drawing.Point(99, 225);
this.BtnCancel.Name = "BtnCancel";
this.BtnCancel.Size = new System.Drawing.Size(125, 29);
this.BtnCancel.TabIndex = 4;
this.BtnCancel.Text = "Cancel";
this.BtnCancel.UseVisualStyleBackColor = true;
this.BtnCancel.Click += new System.EventHandler(this.BtnCancel_Click);
//
// BtnSave
//
this.BtnSave.Location = new System.Drawing.Point(250, 225);
this.BtnSave.Name = "BtnSave";
this.BtnSave.Size = new System.Drawing.Size(125, 29);
this.BtnSave.TabIndex = 5;
this.BtnSave.Text = "Save";
this.BtnSave.UseVisualStyleBackColor = true;
this.BtnSave.Click += new System.EventHandler(this.BtnSave_Click);
//
// groupBox2
//
this.groupBox2.Controls.Add(this.BtnSrcBrowse);
this.groupBox2.Controls.Add(this.TxtSourcePath);
this.groupBox2.Location = new System.Drawing.Point(12, 76);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(458, 66);
this.groupBox2.TabIndex = 6;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Source BCAT Path";
//
// BtnSrcBrowse
//
this.BtnSrcBrowse.Location = new System.Drawing.Point(370, 26);
this.BtnSrcBrowse.Name = "BtnSrcBrowse";
this.BtnSrcBrowse.Size = new System.Drawing.Size(82, 27);
this.BtnSrcBrowse.TabIndex = 1;
this.BtnSrcBrowse.Text = "Browse";
this.BtnSrcBrowse.UseVisualStyleBackColor = true;
this.BtnSrcBrowse.Click += new System.EventHandler(this.BtnSrcBrowse_Click);
//
// TxtSourcePath
//
this.TxtSourcePath.Location = new System.Drawing.Point(6, 26);
this.TxtSourcePath.Name = "TxtSourcePath";
this.TxtSourcePath.Size = new System.Drawing.Size(358, 27);
this.TxtSourcePath.TabIndex = 0;
//
// SaveWindow
//
this.AcceptButton = this.BtnSave;
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.BtnCancel;
this.ClientSize = new System.Drawing.Size(483, 261);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.BtnSave);
this.Controls.Add(this.BtnCancel);
this.Controls.Add(this.GrpDest);
this.Controls.Add(this.GrpBuild);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "SaveWindow";
this.ShowInTaskbar = false;
this.Text = "Save BCAT Package";
this.GrpBuild.ResumeLayout(false);
this.GrpBuild.PerformLayout();
this.GrpDest.ResumeLayout(false);
this.GrpDest.PerformLayout();
this.groupBox2.ResumeLayout(false);
this.groupBox2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private GroupBox GrpBuild;
private RadioButton RadioUnique;
private RadioButton RadioMultiple;
private TextBox TxtDestPath;
private Button BtnPath;
private GroupBox GrpDest;
private Button BtnCancel;
private Button BtnSave;
private FolderBrowserDialog FolderBrowser;
private GroupBox groupBox2;
private Button BtnSrcBrowse;
private TextBox TxtSourcePath;
}
}

View File

@@ -0,0 +1,186 @@
using System.IO;
using SwitchGiftDataManager.Core;
using Enums;
namespace SwitchGiftDataManager.WinForm
{
public partial class SaveWindow : Form
{
private BCATManager Package;
private Games Game;
public SaveWindow(BCATManager bcat, Games game)
{
InitializeComponent();
Package = bcat;
Game = game;
if(Game is Games.LGPE)
{
RadioUnique.Checked = true;
RadioMultiple.Enabled = false;
}
}
private void BtnCancel_Click(object sender, EventArgs e) => this.Close();
private void BtnSrcBrowse_Click(object sender, EventArgs e)
{
if(FolderBrowser.ShowDialog() == DialogResult.OK)
{
TxtSourcePath.Text = FolderBrowser.SelectedPath;
TxtDestPath.Text = Path.GetDirectoryName(FolderBrowser.SelectedPath);
}
}
private void BtnPath_Click(object sender, EventArgs e)
{
if (FolderBrowser.ShowDialog() == DialogResult.OK)
TxtDestPath.Text = FolderBrowser.SelectedPath;
}
private void BtnSave_Click(object sender, EventArgs e)
{
if(!RadioUnique.Checked && !RadioMultiple.Checked)
{
MessageBox.Show("Select a Build Method.");
return;
}
if (!CheckValidBcatPath(TxtSourcePath.Text))
{
MessageBox.Show("Invalid BCAT source path");
return;
}
if (!CheckValidPath(TxtDestPath.Text))
{
MessageBox.Show("Invalid destination path.");
return;
}
var path = $"{TxtDestPath.Text}\\Forged_BCAT_{Game}";
CopyDirectory(TxtSourcePath.Text, path);
if (RadioMultiple.Checked)
{
try
{
var wcdata = Package.ConcatenateFiles();
var metadata = Package.ForgeMetaInfo(wcdata.ToArray());
var metadatapath = $"{path}\\directories\\{Package.GetDefaultBcatFolderName()}";
var wcpath = $"{metadatapath}\\files";
if (Directory.Exists(metadatapath))
DeleteFilesAndDirectory(metadatapath);
Directory.CreateDirectory(wcpath);
File.WriteAllBytes($"{metadatapath}\\files.meta", metadata.ToArray());
File.WriteAllBytes($"{wcpath}\\{Package.GetDefaultBcatFileName()}", wcdata.ToArray());
MessageBox.Show("Done");
this.Close();
}
catch (Exception)
{
MessageBox.Show("Internal Error");
this.Close();
}
}
else
{
var metadata = Package.ForgeMetaInfo();
var metadatapath = $"{path}\\directories\\{Package.GetDefaultBcatFolderName()}";
var wcspath = $"{metadatapath}\\files";
if (Directory.Exists(metadatapath))
DeleteFilesAndDirectory(metadatapath);
Directory.CreateDirectory(wcspath);
File.WriteAllBytes($"{metadatapath}\\files.meta", metadata.ToArray());
if (Package.TrySaveAllWondercards(wcspath))
{
MessageBox.Show("Done.");
this.Close();
}
else
{
MessageBox.Show("Internal error.");
this.Close();
}
}
}
private bool CheckValidBcatPath(string path)
{
if (string.IsNullOrWhiteSpace(path))
return false;
if (!Directory.Exists($"{path}\\directories"))
return false;
if (!File.Exists($"{path}\\directories.meta"))
return false;
if (!File.Exists($"{path}\\etag.bin"))
return false;
if (!File.Exists($"{path}\\list.msgpack"))
return false;
if (!File.Exists($"{path}\\na_required"))
return false;
if (!File.Exists($"{path}\\passphrase.bin"))
return false;
return true;
}
private bool CheckValidPath(string path)
{
if(string.IsNullOrWhiteSpace(path))
return false;
if (!Directory.Exists(path))
return false;
return true;
}
private static void CopyDirectory(string source, string dest)
{
var dir = new DirectoryInfo(source);
DirectoryInfo[] dirs = dir.GetDirectories();
Directory.CreateDirectory(dest);
foreach (FileInfo file in dir.GetFiles())
{
string targetFilePath = Path.Combine(dest, file.Name);
if(!File.Exists(targetFilePath))
file.CopyTo(targetFilePath);
}
foreach (DirectoryInfo subDir in dirs)
{
string newDestinationDir = Path.Combine(dest, subDir.Name);
CopyDirectory(subDir.FullName, newDestinationDir);
}
}
private void DeleteFilesAndDirectory(string targetDir)
{
string[] files = Directory.GetFiles(targetDir);
string[] dirs = Directory.GetDirectories(targetDir);
foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs)
DeleteFilesAndDirectory(dir);
Directory.Delete(targetDir, false);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,83 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<PackageIcon>Resources\icon.png</PackageIcon>
<ApplicationIcon>Resources\icon.ico</ApplicationIcon>
<Authors>Manu098vm</Authors>
<AssemblyName>$(MSBuildProjectName)</AssemblyName>
<Copyright>Copyright (C) 2022 Manu098vm</Copyright>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageTags>pokemon; mystery gift; wondercard; reader; nintendo; bcat; event injection;</PackageTags>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Company>Project Pokémon</Company>
<PackageProjectUrl>https://github.com/Manu098vm/Switch-Gift-Data-Manager</PackageProjectUrl>
<RepositoryUrl>https://github.com/Manu098vm/Switch-Gift-Data-Manager</RepositoryUrl>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebugType>embedded</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<DebugType>embedded</DebugType>
</PropertyGroup>
<ItemGroup>
<None Include="..\README.md">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<None Include="..\LICENSE">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SwitchGiftDataManager.Core\SwitchGiftDataManager.Core.csproj">
<Private>True</Private>
<CopyLocalSatelliteAssemblies>True</CopyLocalSatelliteAssemblies>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Resources\icon.png">
<Pack>True</Pack>
<PackagePath>\</PackagePath>
</None>
</ItemGroup>
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="$(ConfigurationName) == Release">
<Move SourceFiles="$(OUTDIR)\SwitchGiftDataManager.WinForm.exe" DestinationFiles="$(OUTDIR)\Switch Gift Data Manager.exe" />
</Target>
<Target Name="PostClean" AfterTargets="Clean" Condition="$(ConfigurationName) == Release">
<RemoveDir Directories="$(TargetDir)" />
<RemoveDir Directories="$(ProjectDir)$(BaseIntermediateOutputPath)" />
</Target>
</Project>

View File

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Compile Update="MainWindow.cs">
<SubType>Form</SubType>
</Compile>
<Compile Update="SaveWindow.cs">
<SubType>Form</SubType>
</Compile>
</ItemGroup>
</Project>