Misc tweaks

This commit is contained in:
Manu
2023-06-10 13:34:11 +02:00
parent 35ba2411fa
commit 011eae8ff3
16 changed files with 2744 additions and 2761 deletions

View File

@@ -1,424 +1,423 @@
namespace SwitchGiftDataManager.WinForm
namespace SwitchGiftDataManager.WinForm;
partial class MainWindow
{
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)
{
/// <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))
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
components.Dispose();
}
#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()
{
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
BtnLGPE = new Button();
BtnSWSH = new Button();
BtnBDSP = new Button();
BtnSCVI = new Button();
BtnPLA = new Button();
ListBoxWC = new ListBox();
BtnOpen = new Button();
BtnSave = new Button();
GrpBCAT = new GroupBox();
ChkRepeatable = new CheckBox();
BtnApply = new Button();
GrpContent = new GroupBox();
LblInfo7 = new Label();
LblInfo6 = new Label();
LblInfo5 = new Label();
LblInfo4 = new Label();
LblInfo3 = new Label();
LblInfo2 = new Label();
LblInfo1 = new Label();
TxtWCID = new TextBox();
LblWCID = new Label();
ContextMenuStripWC = new ContextMenuStrip(components);
BtnRemove = new ToolStripMenuItem();
BtnRemoveAll = new ToolStripMenuItem();
OpenFileDialogWC = new OpenFileDialog();
ToolTipWcid = new ToolTip(components);
GrpBCAT.SuspendLayout();
GrpContent.SuspendLayout();
ContextMenuStripWC.SuspendLayout();
SuspendLayout();
//
// BtnLGPE
//
BtnLGPE.AccessibleDescription = "";
BtnLGPE.AccessibleName = "";
BtnLGPE.Cursor = Cursors.Hand;
BtnLGPE.FlatStyle = FlatStyle.Flat;
BtnLGPE.Location = new Point(5, 12);
BtnLGPE.Name = "BtnLGPE";
BtnLGPE.Size = new Size(136, 60);
BtnLGPE.TabIndex = 0;
BtnLGPE.TabStop = false;
BtnLGPE.Text = "LGPE";
BtnLGPE.UseVisualStyleBackColor = true;
BtnLGPE.Click += BtnLGPE_Click;
//
// BtnSWSH
//
BtnSWSH.AccessibleDescription = "";
BtnSWSH.AccessibleName = "";
BtnSWSH.Cursor = Cursors.Hand;
BtnSWSH.FlatStyle = FlatStyle.Flat;
BtnSWSH.Location = new Point(147, 12);
BtnSWSH.Name = "BtnSWSH";
BtnSWSH.Size = new Size(136, 60);
BtnSWSH.TabIndex = 1;
BtnSWSH.TabStop = false;
BtnSWSH.Text = "SWSH";
BtnSWSH.UseVisualStyleBackColor = true;
BtnSWSH.Click += BtnSWSH_Click;
//
// BtnBDSP
//
BtnBDSP.AccessibleDescription = "";
BtnBDSP.AccessibleName = "";
BtnBDSP.Cursor = Cursors.Hand;
BtnBDSP.FlatStyle = FlatStyle.Flat;
BtnBDSP.Location = new Point(289, 12);
BtnBDSP.Name = "BtnBDSP";
BtnBDSP.Size = new Size(136, 60);
BtnBDSP.TabIndex = 2;
BtnBDSP.TabStop = false;
BtnBDSP.Text = "BDSP";
BtnBDSP.UseVisualStyleBackColor = true;
BtnBDSP.Click += BtnBDSP_Click;
//
// BtnSCVI
//
BtnSCVI.AccessibleDescription = "";
BtnSCVI.AccessibleName = "";
BtnSCVI.Cursor = Cursors.Hand;
BtnSCVI.FlatStyle = FlatStyle.Flat;
BtnSCVI.Location = new Point(573, 12);
BtnSCVI.Name = "BtnSCVI";
BtnSCVI.Size = new Size(136, 60);
BtnSCVI.TabIndex = 3;
BtnSCVI.TabStop = false;
BtnSCVI.Text = "SCVI";
BtnSCVI.UseVisualStyleBackColor = true;
BtnSCVI.Click += BtnSCVI_Click;
//
// BtnPLA
//
BtnPLA.AccessibleDescription = "";
BtnPLA.AccessibleName = "";
BtnPLA.Cursor = Cursors.Hand;
BtnPLA.FlatStyle = FlatStyle.Flat;
BtnPLA.Location = new Point(431, 12);
BtnPLA.Name = "BtnPLA";
BtnPLA.Size = new Size(136, 60);
BtnPLA.TabIndex = 4;
BtnPLA.TabStop = false;
BtnPLA.Text = "PLA";
BtnPLA.UseVisualStyleBackColor = true;
BtnPLA.Click += BtnPLA_Click;
//
// ListBoxWC
//
ListBoxWC.AllowDrop = true;
ListBoxWC.DrawMode = DrawMode.OwnerDrawFixed;
ListBoxWC.FormattingEnabled = true;
ListBoxWC.ItemHeight = 20;
ListBoxWC.Location = new Point(7, 96);
ListBoxWC.Name = "ListBoxWC";
ListBoxWC.Size = new Size(214, 304);
ListBoxWC.TabIndex = 5;
ToolTipWcid.SetToolTip(ListBoxWC, " Wondercards with duplicated WC ID will not be seen by the game. ");
ListBoxWC.DrawItem += ListBoxWC_DrawItem;
ListBoxWC.SelectedIndexChanged += ListBoxWC_SelectedIndexChanged;
ListBoxWC.DragDrop += FileDragDrop;
ListBoxWC.DragEnter += FileDragEnter;
ListBoxWC.MouseUp += ListBoxWC_MouseUp;
//
// BtnOpen
//
BtnOpen.Location = new Point(7, 26);
BtnOpen.Name = "BtnOpen";
BtnOpen.Size = new Size(214, 29);
BtnOpen.TabIndex = 6;
BtnOpen.Text = "Open Wondercard Files...";
BtnOpen.UseVisualStyleBackColor = true;
BtnOpen.Click += BtnOpen_Click;
//
// BtnSave
//
BtnSave.Enabled = false;
BtnSave.Location = new Point(6, 61);
BtnSave.Name = "BtnSave";
BtnSave.Size = new Size(214, 29);
BtnSave.TabIndex = 7;
BtnSave.Text = "Save as BCAT Package...";
BtnSave.UseVisualStyleBackColor = true;
BtnSave.Click += BtnSave_Click;
//
// GrpBCAT
//
GrpBCAT.Controls.Add(ChkRepeatable);
GrpBCAT.Controls.Add(BtnApply);
GrpBCAT.Controls.Add(GrpContent);
GrpBCAT.Controls.Add(TxtWCID);
GrpBCAT.Controls.Add(LblWCID);
GrpBCAT.Controls.Add(ListBoxWC);
GrpBCAT.Controls.Add(BtnSave);
GrpBCAT.Controls.Add(BtnOpen);
GrpBCAT.Enabled = false;
GrpBCAT.Location = new Point(5, 78);
GrpBCAT.Name = "GrpBCAT";
GrpBCAT.Size = new Size(704, 409);
GrpBCAT.TabIndex = 8;
GrpBCAT.TabStop = false;
GrpBCAT.Text = "BCAT Manager";
//
// ChkRepeatable
//
ChkRepeatable.AutoSize = true;
ChkRepeatable.Location = new Point(510, 69);
ChkRepeatable.Name = "ChkRepeatable";
ChkRepeatable.Size = new Size(121, 24);
ChkRepeatable.TabIndex = 12;
ChkRepeatable.Text = "Is Repeatable";
ChkRepeatable.UseVisualStyleBackColor = true;
ChkRepeatable.CheckedChanged += ChkRepeatable_CheckedChanged;
//
// BtnApply
//
BtnApply.Enabled = false;
BtnApply.Location = new Point(426, 368);
BtnApply.Name = "BtnApply";
BtnApply.Size = new Size(97, 32);
BtnApply.TabIndex = 11;
BtnApply.Text = "Apply";
BtnApply.UseVisualStyleBackColor = true;
BtnApply.Click += BtnApply_Click;
//
// GrpContent
//
GrpContent.Controls.Add(LblInfo7);
GrpContent.Controls.Add(LblInfo6);
GrpContent.Controls.Add(LblInfo5);
GrpContent.Controls.Add(LblInfo4);
GrpContent.Controls.Add(LblInfo3);
GrpContent.Controls.Add(LblInfo2);
GrpContent.Controls.Add(LblInfo1);
GrpContent.Enabled = false;
GrpContent.Location = new Point(294, 99);
GrpContent.Name = "GrpContent";
GrpContent.Size = new Size(358, 263);
GrpContent.TabIndex = 10;
GrpContent.TabStop = false;
GrpContent.Text = "Gift Content";
//
// LblInfo7
//
LblInfo7.AutoSize = true;
LblInfo7.Location = new Point(158, 230);
LblInfo7.Name = "LblInfo7";
LblInfo7.Size = new Size(49, 20);
LblInfo7.TabIndex = 6;
LblInfo7.Text = "Info_7";
LblInfo7.Visible = false;
LblInfo7.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo6
//
LblInfo6.AutoSize = true;
LblInfo6.Location = new Point(158, 198);
LblInfo6.Name = "LblInfo6";
LblInfo6.Size = new Size(49, 20);
LblInfo6.TabIndex = 5;
LblInfo6.Text = "Info_6";
LblInfo6.Visible = false;
LblInfo6.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo5
//
LblInfo5.AutoSize = true;
LblInfo5.Location = new Point(158, 165);
LblInfo5.Name = "LblInfo5";
LblInfo5.Size = new Size(49, 20);
LblInfo5.TabIndex = 4;
LblInfo5.Text = "Info_5";
LblInfo5.Visible = false;
LblInfo5.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo4
//
LblInfo4.AutoSize = true;
LblInfo4.Location = new Point(158, 132);
LblInfo4.Name = "LblInfo4";
LblInfo4.Size = new Size(49, 20);
LblInfo4.TabIndex = 3;
LblInfo4.Text = "Info_4";
LblInfo4.Visible = false;
LblInfo4.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo3
//
LblInfo3.AutoSize = true;
LblInfo3.Location = new Point(158, 99);
LblInfo3.Name = "LblInfo3";
LblInfo3.Size = new Size(49, 20);
LblInfo3.TabIndex = 2;
LblInfo3.Text = "Info_3";
LblInfo3.Visible = false;
LblInfo3.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo2
//
LblInfo2.AutoSize = true;
LblInfo2.Location = new Point(158, 66);
LblInfo2.Name = "LblInfo2";
LblInfo2.Size = new Size(49, 20);
LblInfo2.TabIndex = 1;
LblInfo2.Text = "Info_2";
LblInfo2.Visible = false;
LblInfo2.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo1
//
LblInfo1.AutoSize = true;
LblInfo1.Location = new Point(158, 33);
LblInfo1.Name = "LblInfo1";
LblInfo1.Size = new Size(49, 20);
LblInfo1.TabIndex = 0;
LblInfo1.Text = "Info_1";
LblInfo1.Visible = false;
LblInfo1.SizeChanged += LblInfo_SizeChanged;
//
// TxtWCID
//
TxtWCID.Enabled = false;
TxtWCID.Location = new Point(379, 66);
TxtWCID.MaxLength = 4;
TxtWCID.Name = "TxtWCID";
TxtWCID.Size = new Size(115, 27);
TxtWCID.TabIndex = 9;
TxtWCID.TextChanged += TxtWCID_TextChanged;
TxtWCID.KeyPress += TxtWCID_KeyPress;
//
// LblWCID
//
LblWCID.AutoSize = true;
LblWCID.Enabled = false;
LblWCID.Location = new Point(319, 69);
LblWCID.Name = "LblWCID";
LblWCID.Size = new Size(54, 20);
LblWCID.TabIndex = 8;
LblWCID.Text = "WC ID:";
//
// ContextMenuStripWC
//
ContextMenuStripWC.ImageScalingSize = new Size(20, 20);
ContextMenuStripWC.Items.AddRange(new ToolStripItem[] { BtnRemove, BtnRemoveAll });
ContextMenuStripWC.Name = "ConextMenuStripWC";
ContextMenuStripWC.Size = new Size(155, 52);
ContextMenuStripWC.Text = "Remove";
//
// BtnRemove
//
BtnRemove.Name = "BtnRemove";
BtnRemove.Size = new Size(154, 24);
BtnRemove.Text = "Remove";
BtnRemove.Click += BtnRemove_Click;
//
// BtnRemoveAll
//
BtnRemoveAll.Name = "BtnRemoveAll";
BtnRemoveAll.Size = new Size(154, 24);
BtnRemoveAll.Text = "Remove All";
BtnRemoveAll.Click += BtnRemoveAll_Click;
//
// OpenFileDialogWC
//
OpenFileDialogWC.Multiselect = true;
//
// ToolTipWcid
//
ToolTipWcid.AutoPopDelay = 100000;
ToolTipWcid.InitialDelay = 500;
ToolTipWcid.OwnerDraw = true;
ToolTipWcid.ReshowDelay = 100;
ToolTipWcid.UseAnimation = false;
ToolTipWcid.UseFading = false;
ToolTipWcid.Draw += ToolTipWcid_Draw;
//
// MainWindow
//
AllowDrop = true;
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(715, 495);
Controls.Add(GrpBCAT);
Controls.Add(BtnPLA);
Controls.Add(BtnSCVI);
Controls.Add(BtnBDSP);
Controls.Add(BtnSWSH);
Controls.Add(BtnLGPE);
Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false;
MinimizeBox = false;
Name = "MainWindow";
Text = "Switch Gift Data Manager v";
DragDrop += FileDragDrop;
DragEnter += FileDragEnter;
GrpBCAT.ResumeLayout(false);
GrpBCAT.PerformLayout();
GrpContent.ResumeLayout(false);
GrpContent.PerformLayout();
ContextMenuStripWC.ResumeLayout(false);
ResumeLayout(false);
}
#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;
private Label LblInfo7;
private Label LblInfo6;
private CheckBox ChkRepeatable;
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()
{
components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
BtnLGPE = new Button();
BtnSWSH = new Button();
BtnBDSP = new Button();
BtnSCVI = new Button();
BtnPLA = new Button();
ListBoxWC = new ListBox();
BtnOpen = new Button();
BtnSave = new Button();
GrpBCAT = new GroupBox();
ChkRepeatable = new CheckBox();
BtnApply = new Button();
GrpContent = new GroupBox();
LblInfo7 = new Label();
LblInfo6 = new Label();
LblInfo5 = new Label();
LblInfo4 = new Label();
LblInfo3 = new Label();
LblInfo2 = new Label();
LblInfo1 = new Label();
TxtWCID = new TextBox();
LblWCID = new Label();
ContextMenuStripWC = new ContextMenuStrip(components);
BtnRemove = new ToolStripMenuItem();
BtnRemoveAll = new ToolStripMenuItem();
OpenFileDialogWC = new OpenFileDialog();
ToolTipWcid = new ToolTip(components);
GrpBCAT.SuspendLayout();
GrpContent.SuspendLayout();
ContextMenuStripWC.SuspendLayout();
SuspendLayout();
//
// BtnLGPE
//
BtnLGPE.AccessibleDescription = "";
BtnLGPE.AccessibleName = "";
BtnLGPE.Cursor = Cursors.Hand;
BtnLGPE.FlatStyle = FlatStyle.Flat;
BtnLGPE.Location = new Point(5, 12);
BtnLGPE.Name = "BtnLGPE";
BtnLGPE.Size = new Size(136, 60);
BtnLGPE.TabIndex = 0;
BtnLGPE.TabStop = false;
BtnLGPE.Text = "LGPE";
BtnLGPE.UseVisualStyleBackColor = true;
BtnLGPE.Click += BtnLGPE_Click;
//
// BtnSWSH
//
BtnSWSH.AccessibleDescription = "";
BtnSWSH.AccessibleName = "";
BtnSWSH.Cursor = Cursors.Hand;
BtnSWSH.FlatStyle = FlatStyle.Flat;
BtnSWSH.Location = new Point(147, 12);
BtnSWSH.Name = "BtnSWSH";
BtnSWSH.Size = new Size(136, 60);
BtnSWSH.TabIndex = 1;
BtnSWSH.TabStop = false;
BtnSWSH.Text = "SWSH";
BtnSWSH.UseVisualStyleBackColor = true;
BtnSWSH.Click += BtnSWSH_Click;
//
// BtnBDSP
//
BtnBDSP.AccessibleDescription = "";
BtnBDSP.AccessibleName = "";
BtnBDSP.Cursor = Cursors.Hand;
BtnBDSP.FlatStyle = FlatStyle.Flat;
BtnBDSP.Location = new Point(289, 12);
BtnBDSP.Name = "BtnBDSP";
BtnBDSP.Size = new Size(136, 60);
BtnBDSP.TabIndex = 2;
BtnBDSP.TabStop = false;
BtnBDSP.Text = "BDSP";
BtnBDSP.UseVisualStyleBackColor = true;
BtnBDSP.Click += BtnBDSP_Click;
//
// BtnSCVI
//
BtnSCVI.AccessibleDescription = "";
BtnSCVI.AccessibleName = "";
BtnSCVI.Cursor = Cursors.Hand;
BtnSCVI.FlatStyle = FlatStyle.Flat;
BtnSCVI.Location = new Point(573, 12);
BtnSCVI.Name = "BtnSCVI";
BtnSCVI.Size = new Size(136, 60);
BtnSCVI.TabIndex = 3;
BtnSCVI.TabStop = false;
BtnSCVI.Text = "SCVI";
BtnSCVI.UseVisualStyleBackColor = true;
BtnSCVI.Click += BtnSCVI_Click;
//
// BtnPLA
//
BtnPLA.AccessibleDescription = "";
BtnPLA.AccessibleName = "";
BtnPLA.Cursor = Cursors.Hand;
BtnPLA.FlatStyle = FlatStyle.Flat;
BtnPLA.Location = new Point(431, 12);
BtnPLA.Name = "BtnPLA";
BtnPLA.Size = new Size(136, 60);
BtnPLA.TabIndex = 4;
BtnPLA.TabStop = false;
BtnPLA.Text = "PLA";
BtnPLA.UseVisualStyleBackColor = true;
BtnPLA.Click += BtnPLA_Click;
//
// ListBoxWC
//
ListBoxWC.AllowDrop = true;
ListBoxWC.DrawMode = DrawMode.OwnerDrawFixed;
ListBoxWC.FormattingEnabled = true;
ListBoxWC.ItemHeight = 20;
ListBoxWC.Location = new Point(7, 96);
ListBoxWC.Name = "ListBoxWC";
ListBoxWC.Size = new Size(214, 304);
ListBoxWC.TabIndex = 5;
ToolTipWcid.SetToolTip(ListBoxWC, " Wondercards with duplicated WC ID will not be seen by the game. ");
ListBoxWC.DrawItem += ListBoxWC_DrawItem;
ListBoxWC.SelectedIndexChanged += ListBoxWC_SelectedIndexChanged;
ListBoxWC.DragDrop += FileDragDrop;
ListBoxWC.DragEnter += FileDragEnter;
ListBoxWC.MouseUp += ListBoxWC_MouseUp;
//
// BtnOpen
//
BtnOpen.Location = new Point(7, 26);
BtnOpen.Name = "BtnOpen";
BtnOpen.Size = new Size(214, 29);
BtnOpen.TabIndex = 6;
BtnOpen.Text = "Open Wondercard Files...";
BtnOpen.UseVisualStyleBackColor = true;
BtnOpen.Click += BtnOpen_Click;
//
// BtnSave
//
BtnSave.Enabled = false;
BtnSave.Location = new Point(6, 61);
BtnSave.Name = "BtnSave";
BtnSave.Size = new Size(214, 29);
BtnSave.TabIndex = 7;
BtnSave.Text = "Save as BCAT Package...";
BtnSave.UseVisualStyleBackColor = true;
BtnSave.Click += BtnSave_Click;
//
// GrpBCAT
//
GrpBCAT.Controls.Add(ChkRepeatable);
GrpBCAT.Controls.Add(BtnApply);
GrpBCAT.Controls.Add(GrpContent);
GrpBCAT.Controls.Add(TxtWCID);
GrpBCAT.Controls.Add(LblWCID);
GrpBCAT.Controls.Add(ListBoxWC);
GrpBCAT.Controls.Add(BtnSave);
GrpBCAT.Controls.Add(BtnOpen);
GrpBCAT.Enabled = false;
GrpBCAT.Location = new Point(5, 78);
GrpBCAT.Name = "GrpBCAT";
GrpBCAT.Size = new Size(704, 409);
GrpBCAT.TabIndex = 8;
GrpBCAT.TabStop = false;
GrpBCAT.Text = "BCAT Manager";
//
// ChkRepeatable
//
ChkRepeatable.AutoSize = true;
ChkRepeatable.Location = new Point(510, 69);
ChkRepeatable.Name = "ChkRepeatable";
ChkRepeatable.Size = new Size(121, 24);
ChkRepeatable.TabIndex = 12;
ChkRepeatable.Text = "Is Repeatable";
ChkRepeatable.UseVisualStyleBackColor = true;
ChkRepeatable.CheckedChanged += ChkRepeatable_CheckedChanged;
//
// BtnApply
//
BtnApply.Enabled = false;
BtnApply.Location = new Point(426, 368);
BtnApply.Name = "BtnApply";
BtnApply.Size = new Size(97, 32);
BtnApply.TabIndex = 11;
BtnApply.Text = "Apply";
BtnApply.UseVisualStyleBackColor = true;
BtnApply.Click += BtnApply_Click;
//
// GrpContent
//
GrpContent.Controls.Add(LblInfo7);
GrpContent.Controls.Add(LblInfo6);
GrpContent.Controls.Add(LblInfo5);
GrpContent.Controls.Add(LblInfo4);
GrpContent.Controls.Add(LblInfo3);
GrpContent.Controls.Add(LblInfo2);
GrpContent.Controls.Add(LblInfo1);
GrpContent.Enabled = false;
GrpContent.Location = new Point(294, 99);
GrpContent.Name = "GrpContent";
GrpContent.Size = new Size(358, 263);
GrpContent.TabIndex = 10;
GrpContent.TabStop = false;
GrpContent.Text = "Gift Content";
//
// LblInfo7
//
LblInfo7.AutoSize = true;
LblInfo7.Location = new Point(158, 230);
LblInfo7.Name = "LblInfo7";
LblInfo7.Size = new Size(49, 20);
LblInfo7.TabIndex = 6;
LblInfo7.Text = "Info_7";
LblInfo7.Visible = false;
LblInfo7.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo6
//
LblInfo6.AutoSize = true;
LblInfo6.Location = new Point(158, 198);
LblInfo6.Name = "LblInfo6";
LblInfo6.Size = new Size(49, 20);
LblInfo6.TabIndex = 5;
LblInfo6.Text = "Info_6";
LblInfo6.Visible = false;
LblInfo6.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo5
//
LblInfo5.AutoSize = true;
LblInfo5.Location = new Point(158, 165);
LblInfo5.Name = "LblInfo5";
LblInfo5.Size = new Size(49, 20);
LblInfo5.TabIndex = 4;
LblInfo5.Text = "Info_5";
LblInfo5.Visible = false;
LblInfo5.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo4
//
LblInfo4.AutoSize = true;
LblInfo4.Location = new Point(158, 132);
LblInfo4.Name = "LblInfo4";
LblInfo4.Size = new Size(49, 20);
LblInfo4.TabIndex = 3;
LblInfo4.Text = "Info_4";
LblInfo4.Visible = false;
LblInfo4.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo3
//
LblInfo3.AutoSize = true;
LblInfo3.Location = new Point(158, 99);
LblInfo3.Name = "LblInfo3";
LblInfo3.Size = new Size(49, 20);
LblInfo3.TabIndex = 2;
LblInfo3.Text = "Info_3";
LblInfo3.Visible = false;
LblInfo3.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo2
//
LblInfo2.AutoSize = true;
LblInfo2.Location = new Point(158, 66);
LblInfo2.Name = "LblInfo2";
LblInfo2.Size = new Size(49, 20);
LblInfo2.TabIndex = 1;
LblInfo2.Text = "Info_2";
LblInfo2.Visible = false;
LblInfo2.SizeChanged += LblInfo_SizeChanged;
//
// LblInfo1
//
LblInfo1.AutoSize = true;
LblInfo1.Location = new Point(158, 33);
LblInfo1.Name = "LblInfo1";
LblInfo1.Size = new Size(49, 20);
LblInfo1.TabIndex = 0;
LblInfo1.Text = "Info_1";
LblInfo1.Visible = false;
LblInfo1.SizeChanged += LblInfo_SizeChanged;
//
// TxtWCID
//
TxtWCID.Enabled = false;
TxtWCID.Location = new Point(379, 66);
TxtWCID.MaxLength = 4;
TxtWCID.Name = "TxtWCID";
TxtWCID.Size = new Size(115, 27);
TxtWCID.TabIndex = 9;
TxtWCID.TextChanged += TxtWCID_TextChanged;
TxtWCID.KeyPress += TxtWCID_KeyPress;
//
// LblWCID
//
LblWCID.AutoSize = true;
LblWCID.Enabled = false;
LblWCID.Location = new Point(319, 69);
LblWCID.Name = "LblWCID";
LblWCID.Size = new Size(54, 20);
LblWCID.TabIndex = 8;
LblWCID.Text = "WC ID:";
//
// ContextMenuStripWC
//
ContextMenuStripWC.ImageScalingSize = new Size(20, 20);
ContextMenuStripWC.Items.AddRange(new ToolStripItem[] { BtnRemove, BtnRemoveAll });
ContextMenuStripWC.Name = "ConextMenuStripWC";
ContextMenuStripWC.Size = new Size(155, 52);
ContextMenuStripWC.Text = "Remove";
//
// BtnRemove
//
BtnRemove.Name = "BtnRemove";
BtnRemove.Size = new Size(154, 24);
BtnRemove.Text = "Remove";
BtnRemove.Click += BtnRemove_Click;
//
// BtnRemoveAll
//
BtnRemoveAll.Name = "BtnRemoveAll";
BtnRemoveAll.Size = new Size(154, 24);
BtnRemoveAll.Text = "Remove All";
BtnRemoveAll.Click += BtnRemoveAll_Click;
//
// OpenFileDialogWC
//
OpenFileDialogWC.Multiselect = true;
//
// ToolTipWcid
//
ToolTipWcid.AutoPopDelay = 100000;
ToolTipWcid.InitialDelay = 500;
ToolTipWcid.OwnerDraw = true;
ToolTipWcid.ReshowDelay = 100;
ToolTipWcid.UseAnimation = false;
ToolTipWcid.UseFading = false;
ToolTipWcid.Draw += ToolTipWcid_Draw;
//
// MainWindow
//
AllowDrop = true;
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(715, 495);
Controls.Add(GrpBCAT);
Controls.Add(BtnPLA);
Controls.Add(BtnSCVI);
Controls.Add(BtnBDSP);
Controls.Add(BtnSWSH);
Controls.Add(BtnLGPE);
Icon = (Icon)resources.GetObject("$this.Icon");
MaximizeBox = false;
MinimizeBox = false;
Name = "MainWindow";
Text = "Switch Gift Data Manager v";
DragDrop += FileDragDrop;
DragEnter += FileDragEnter;
GrpBCAT.ResumeLayout(false);
GrpBCAT.PerformLayout();
GrpContent.ResumeLayout(false);
GrpContent.PerformLayout();
ContextMenuStripWC.ResumeLayout(false);
ResumeLayout(false);
}
#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;
private Label LblInfo7;
private Label LblInfo6;
private CheckBox ChkRepeatable;
}

View File

@@ -3,450 +3,449 @@ using SwitchGiftDataManager.Core;
using Enums;
using System.Diagnostics;
namespace SwitchGiftDataManager.WinForm
namespace SwitchGiftDataManager.WinForm;
public partial class MainWindow : Form
{
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()
{
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>();
Task.Run(TryUpdate).Wait();
InitializeComponent();
Text += BCATManager.Version;
}
public MainWindow()
private static async Task TryUpdate()
{
if (await GitHubUtil.IsUpdateAvailable())
{
Task.Run(TryUpdate).Wait();
InitializeComponent();
Text += BCATManager.Version;
var result = MessageBox.Show("A program update is available. Do you want to download the latest release?", "Update available", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
Process.Start(new ProcessStartInfo { FileName = @"https://github.com/Manu098vm/Switch-Gift-Data-Manager/releases", UseShellExecute = true });
}
}
private static async Task TryUpdate()
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
{
if (await GitHubUtil.IsUpdateAvailable())
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)
{
var result = MessageBox.Show("A program update is available. Do you want to download the latest release?", "Update available", MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
Process.Start(new ProcessStartInfo { FileName = @"https://github.com/Manu098vm/Switch-Gift-Data-Manager/releases", UseShellExecute = true });
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)}");
}
}
private void ChangeGame(Games game)
if (errList.Count > 0)
{
GrpBCAT.Enabled = true;
CurrentGame = game;
RestoreMenu();
EditFileFilter();
EditGameButton();
UpdateWCList();
ListBoxWC.SelectedIndex = -1;
DisableContent();
var msg = "";
foreach (var err in errList)
msg = $"{msg}\n{err}";
MessageBox.Show(msg);
}
private void RestoreMenu()
{
BtnLGPE.Enabled = true;
BtnSWSH.Enabled = true;
BtnBDSP.Enabled = true;
BtnPLA.Enabled = true;
BtnSCVI.Enabled = true;
list.Sort();
UpdateWCList();
}
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 BtnLGPE_Click(object sender, EventArgs e) => ChangeGame(Games.LGPE);
private void EditFileFilter()
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);
private void BtnSave_Click(object sender, EventArgs e)
{
this.Enabled = false;
var saveForm = new SaveWindow(GetCurrentList(), CurrentGame);
saveForm.FormClosed += (s, e) => this.Enabled = true;
saveForm.Location = this.Location;
saveForm.Show();
}
private void BtnApply_Click(object sender, EventArgs e)
{
var list = GetCurrentList();
var wcid = UInt16.Parse(TxtWCID.Text);
var repeatable = ChkRepeatable.Checked;
if (wcid != list.GetWCID(ListBoxWC.SelectedIndex))
{
OpenFileDialogWC.Filter = CurrentGame switch
var index = list.GetIndex(wcid);
if (index == -1)
{
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);
private void BtnSave_Click(object sender, EventArgs e)
{
this.Enabled = false;
var saveForm = new SaveWindow(GetCurrentList(), CurrentGame);
saveForm.FormClosed += (s, e) => this.Enabled = true;
saveForm.Location = this.Location;
saveForm.Show();
}
private void BtnApply_Click(object sender, EventArgs e)
{
var list = GetCurrentList();
var wcid = UInt16.Parse(TxtWCID.Text);
var repeatable = ChkRepeatable.Checked;
if (wcid != list.GetWCID(ListBoxWC.SelectedIndex))
{
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;
}
}
if (repeatable != list.GetIsRepeatable(ListBoxWC.SelectedIndex))
{
list.SetIsRepeatable(ListBoxWC.SelectedIndex, repeatable);
list.SetWCID(ListBoxWC.SelectedIndex, wcid);
list.Sort();
UpdateWCList();
ListBoxWC.SelectedIndex = list.GetIndex(wcid);
BtnApply.Enabled = false;
}
}
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)
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)
else
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop)!;
LoadLocalFiles(files);
MessageBox.Show($"WCID {wcid} already exists.");
return;
}
}
private void TxtWCID_KeyPress(object sender, KeyPressEventArgs e)
if (repeatable != list.GetIsRepeatable(ListBoxWC.SelectedIndex))
{
if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar))
e.Handled = true;
list.SetIsRepeatable(ListBoxWC.SelectedIndex, repeatable);
BtnApply.Enabled = false;
}
}
private void TxtWCID_TextChanged(object sender, EventArgs e)
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)
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)
{
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;
}
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop)!;
LoadLocalFiles(files);
}
}
private void ChkRepeatable_CheckedChanged(object sender, EventArgs e)
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 newBool = ChkRepeatable.Checked;
var oldBool = list.GetIsRepeatable(ListBoxWC.SelectedIndex);
var newWcid = UInt16.Parse(TxtWCID.Text);
var oldWcid = list.GetWCID(ListBoxWC.SelectedIndex);
if (newBool != oldBool)
if (oldWcid > 0 && newWcid > 0 && newWcid != oldWcid)
BtnApply.Enabled = true;
else
BtnApply.Enabled = false;
}
}
private void ToolTipWcid_Draw(object sender, DrawToolTipEventArgs e)
private void ChkRepeatable_CheckedChanged(object sender, EventArgs e)
{
var list = GetCurrentList();
var newBool = ChkRepeatable.Checked;
var oldBool = list.GetIsRepeatable(ListBoxWC.SelectedIndex);
if (newBool != oldBool)
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)
{
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 index = ListBoxWC.SelectedIndex;
var content = list.GetContentToString(index);
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);
if (nItem >= 6)
LblInfo6.Text = content.ElementAt(6);
if (nItem >= 7)
LblInfo7.Text = content.ElementAt(7);
TxtWCID.Text = content.ElementAt(0);
ChkRepeatable.Checked = list.GetIsRepeatable(index);
EnableContent();
}
else
DisableContent();
}
private void ListBoxWC_DrawItem(object sender, DrawItemEventArgs e)
{
if (e.Index > -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;
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))
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 index = ListBoxWC.SelectedIndex;
var content = list.GetContentToString(index);
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);
if (nItem >= 6)
LblInfo6.Text = content.ElementAt(6);
if (nItem >= 7)
LblInfo7.Text = content.ElementAt(7);
TxtWCID.Text = content.ElementAt(0);
ChkRepeatable.Checked = list.GetIsRepeatable(index);
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('\u2757'))
((ListBox)sender).Items[e.Index] = $"{curr} \u2757";
g.FillRectangle(new SolidBrush(Color.IndianRed), e.Bounds);
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;
}
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;
LblInfo6.Visible = true;
LblInfo7.Visible = true;
GrpContent.Enabled = true;
ChkRepeatable.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;
LblInfo6.Text = "";
LblInfo6.Visible = false;
LblInfo7.Text = "";
LblInfo7.Visible = false;
BtnApply.Enabled = false;
GrpContent.Enabled = false;
ChkRepeatable.Checked = false;
ChkRepeatable.Enabled = false;
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;
LblInfo6.Visible = true;
LblInfo7.Visible = true;
GrpContent.Enabled = true;
ChkRepeatable.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;
LblInfo6.Text = "";
LblInfo6.Visible = false;
LblInfo7.Text = "";
LblInfo7.Visible = false;
BtnApply.Enabled = false;
GrpContent.Enabled = false;
ChkRepeatable.Checked = false;
ChkRepeatable.Enabled = false;
}
}

View File

@@ -1,201 +1,200 @@
namespace SwitchGiftDataManager.WinForm
namespace SwitchGiftDataManager.WinForm;
partial class SaveWindow
{
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)
{
/// <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))
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
components.Dispose();
}
#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.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
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;
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.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
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

@@ -2,189 +2,188 @@
using SwitchGiftDataManager.Core;
using Enums;
namespace SwitchGiftDataManager.WinForm
namespace SwitchGiftDataManager.WinForm;
public partial class SaveWindow : Form
{
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;
}
else if (Game is Games.BDSP)
RadioUnique.Enabled = false;
}
private void BtnCancel_Click(object sender, EventArgs e) => this.Close();
private void BtnSrcBrowse_Click(object sender, EventArgs e)
{
private BCATManager Package;
private Games Game;
if(FolderBrowser.ShowDialog() == DialogResult.OK)
{
TxtSourcePath.Text = FolderBrowser.SelectedPath;
TxtDestPath.Text = Path.GetDirectoryName(FolderBrowser.SelectedPath);
}
}
public SaveWindow(BCATManager bcat, Games game)
{
InitializeComponent();
private void BtnPath_Click(object sender, EventArgs e)
{
if (FolderBrowser.ShowDialog() == DialogResult.OK)
TxtDestPath.Text = FolderBrowser.SelectedPath;
}
Package = bcat;
Game = game;
if (Game is Games.LGPE)
{
RadioUnique.Checked = true;
RadioMultiple.Enabled = false;
}
else if (Game is Games.BDSP)
RadioUnique.Enabled = false;
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;
}
private void BtnCancel_Click(object sender, EventArgs e) => this.Close();
var path = Path.Combine(TxtDestPath.Text, $"Forged_BCAT_{Game}");
CopyDirectory(TxtSourcePath.Text, path);
private void BtnSrcBrowse_Click(object sender, EventArgs e)
if (RadioMultiple.Checked)
{
if(FolderBrowser.ShowDialog() == DialogResult.OK)
try
{
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 = Path.Combine(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.Combine(path, "directories");
metadatapath = Path.Combine(metadatapath, Package.GetDefaultBcatFolderName());
var wcpath = Path.Combine(metadatapath, "files");
if (Directory.Exists(metadatapath))
DeleteFilesAndDirectory(metadatapath);
Directory.CreateDirectory(wcpath);
File.WriteAllBytes(Path.Combine(metadatapath, "files.meta"), metadata.ToArray());
File.WriteAllBytes(Path.Combine(wcpath, Package.GetDefaultBcatFileName()), wcdata.ToArray());
MessageBox.Show($"Saved in {path}{Environment.NewLine}BCAT forge was successful.");
this.Close();
}
catch (Exception)
{
MessageBox.Show("Internal Error");
this.Close();
}
}
else
{
var metadata = Package.ForgeMetaInfo();
var wcdata = Package.ConcatenateFiles();
var metadata = Package.ForgeMetaInfo(wcdata.ToArray());
var metadatapath = Path.Combine(path, "directories");
metadatapath = Path.Combine(metadatapath, Package.GetDefaultBcatFolderName());
var wcspath = Path.Combine(metadatapath, "files");
var wcpath = Path.Combine(metadatapath, "files");
if (Directory.Exists(metadatapath))
DeleteFilesAndDirectory(metadatapath);
Directory.CreateDirectory(wcspath);
Directory.CreateDirectory(wcpath);
File.WriteAllBytes(Path.Combine(metadatapath, "files.meta"), metadata.ToArray());
if (Package.TrySaveAllWondercards(wcspath))
{
MessageBox.Show($"Saved in {path}{Environment.NewLine}BCAT forge was successful.");
this.Close();
}
else
{
MessageBox.Show("Internal error.");
this.Close();
}
File.WriteAllBytes(Path.Combine(wcpath, Package.GetDefaultBcatFileName()), wcdata.ToArray());
MessageBox.Show($"Saved in {path}{Environment.NewLine}BCAT forge was successful.");
this.Close();
}
}
private static bool CheckValidBcatPath(string path)
{
if (string.IsNullOrWhiteSpace(path))
return false;
if (!Directory.Exists(Path.Combine(path, "directories")))
return false;
if (!File.Exists(Path.Combine(path, "directories.meta")))
return false;
if (!File.Exists(Path.Combine(path, "etag.bin")))
return false;
if (!File.Exists(Path.Combine(path, "list.msgpack")))
return false;
if (!File.Exists(Path.Combine(path, "na_required")))
return false;
if (!File.Exists(Path.Combine(path, "passphrase.bin")))
return false;
return true;
}
private static 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())
catch (Exception)
{
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);
MessageBox.Show("Internal Error");
this.Close();
}
}
private void DeleteFilesAndDirectory(string targetDir)
else
{
string[] files = Directory.GetFiles(targetDir);
string[] dirs = Directory.GetDirectories(targetDir);
var metadata = Package.ForgeMetaInfo();
var metadatapath = Path.Combine(path, "directories");
metadatapath = Path.Combine(metadatapath, Package.GetDefaultBcatFolderName());
var wcspath = Path.Combine(metadatapath, "files");
foreach (string file in files)
if (Directory.Exists(metadatapath))
DeleteFilesAndDirectory(metadatapath);
Directory.CreateDirectory(wcspath);
File.WriteAllBytes(Path.Combine(metadatapath, "files.meta"), metadata.ToArray());
if (Package.TrySaveAllWondercards(wcspath))
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
MessageBox.Show($"Saved in {path}{Environment.NewLine}BCAT forge was successful.");
this.Close();
}
else
{
MessageBox.Show("Internal error.");
this.Close();
}
foreach (string dir in dirs)
DeleteFilesAndDirectory(dir);
Directory.Delete(targetDir, false);
}
}
private static bool CheckValidBcatPath(string path)
{
if (string.IsNullOrWhiteSpace(path))
return false;
if (!Directory.Exists(Path.Combine(path, "directories")))
return false;
if (!File.Exists(Path.Combine(path, "directories.meta")))
return false;
if (!File.Exists(Path.Combine(path, "etag.bin")))
return false;
if (!File.Exists(Path.Combine(path, "list.msgpack")))
return false;
if (!File.Exists(Path.Combine(path, "na_required")))
return false;
if (!File.Exists(Path.Combine(path, "passphrase.bin")))
return false;
return true;
}
private static 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);
}
}