From d399e783a39e3a0913cf2f43d6b62a1d717a83ca Mon Sep 17 00:00:00 2001 From: Yako Date: Wed, 23 Jul 2025 23:42:10 +0200 Subject: [PATCH 01/11] create trade data --- DS_Map/DSPRE.csproj | 7 ++ DS_Map/Editors/TradeEditor.Designer.cs | 39 +++++++++ DS_Map/Editors/TradeEditor.cs | 20 +++++ DS_Map/ROMFiles/TradeData.cs | 115 +++++++++++++++++++++++++ DS_Map/RomInfo.cs | 13 ++- 5 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 DS_Map/Editors/TradeEditor.Designer.cs create mode 100644 DS_Map/Editors/TradeEditor.cs create mode 100644 DS_Map/ROMFiles/TradeData.cs diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj index b6c1915..2ab79af 100644 --- a/DS_Map/DSPRE.csproj +++ b/DS_Map/DSPRE.csproj @@ -230,6 +230,12 @@ TextEditor.cs + + Form + + + TradeEditor.cs + UserControl @@ -346,6 +352,7 @@ + diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs new file mode 100644 index 0000000..59fbe5c --- /dev/null +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -0,0 +1,39 @@ +namespace DSPRE.Editors +{ + partial class TradeEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "TradeEditor"; + } + + #endregion + } +} \ No newline at end of file diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs new file mode 100644 index 0000000..79794b3 --- /dev/null +++ b/DS_Map/Editors/TradeEditor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DSPRE.Editors +{ + public partial class TradeEditor : Form + { + public TradeEditor() + { + InitializeComponent(); + } + } +} diff --git a/DS_Map/ROMFiles/TradeData.cs b/DS_Map/ROMFiles/TradeData.cs new file mode 100644 index 0000000..267d709 --- /dev/null +++ b/DS_Map/ROMFiles/TradeData.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static DSPRE.RomInfo; + +namespace DSPRE.ROMFiles +{ + internal class TradeData : RomFile + { + + public int id; + + // TradeData structure in narc + public int species; + public int hpIV; + public int atkIV; + public int defIV; + public int speedIV; + public int spAtkIV; + public int spDefIV; + public int ability; // unused + public int otID; + public int cool; + public int beauty; + public int cute; + public int smart; + public int tough; + public int pid; + public int heldItem; + public int otGender; + public int sheen; + public int language; + public int requestedSpecies; + public int unknown; // unused? + + public TradeData(Stream stream, int id) + { + this.id = id; + using (BinaryReader br = new BinaryReader(stream)) + { + species = br.ReadInt32(); + hpIV = br.ReadInt32(); + atkIV = br.ReadInt32(); + defIV = br.ReadInt32(); + speedIV = br.ReadInt32(); + spAtkIV = br.ReadInt32(); + spDefIV = br.ReadInt32(); + ability = br.ReadInt32(); // unused + otID = br.ReadInt32(); + cool = br.ReadInt32(); + beauty = br.ReadInt32(); + cute = br.ReadInt32(); + smart = br.ReadInt32(); + tough = br.ReadInt32(); + pid = br.ReadInt32(); + heldItem = br.ReadInt32(); + otGender = br.ReadInt32(); + sheen = br.ReadInt32(); + language = br.ReadInt32(); + requestedSpecies = br.ReadInt32(); + unknown = br.ReadInt32(); // unused? + } + } + + public TradeData(int id) : this(new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Open), id) { } + + public override byte[] ToByteArray() + { + using (MemoryStream ms = new MemoryStream()) + using (BinaryWriter bw = new BinaryWriter(ms)) + { + bw.Write(species); + bw.Write(hpIV); + bw.Write(atkIV); + bw.Write(defIV); + bw.Write(speedIV); + bw.Write(spAtkIV); + bw.Write(spDefIV); + bw.Write(ability); // unused + bw.Write(otID); + bw.Write(cool); + bw.Write(beauty); + bw.Write(cute); + bw.Write(smart); + bw.Write(tough); + bw.Write(pid); + bw.Write(heldItem); + bw.Write(otGender); + bw.Write(sheen); + bw.Write(language); + bw.Write(requestedSpecies); + + if (RomInfo.gameFamily == GameFamilies.HGSS) + { + bw.Write(unknown); // HGSS only + } + + return ms.ToArray(); + } + } + + public void SaveToFileDefaultDir(int IDtoReplace, bool showSuccessMessage = true) + { + SaveToFileDefaultDir(DirNames.tradeData, IDtoReplace, showSuccessMessage); + } + public void SaveToFileExplorePath(string suggestedFileName, bool showSuccessMessage = true) + { + SaveToFileExplorePath("Gen IV Trade data", "bin", suggestedFileName, showSuccessMessage); + } + + } +} diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index bc104bd..55c3dc2 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -175,7 +175,9 @@ namespace DSPRE evolutions, itemData, - itemIcons + itemIcons, + + tradeData }; public static Dictionary gameDirs { get; private set; } @@ -1470,7 +1472,9 @@ namespace DSPRE [DirNames.otherPokemonBattleSprites] = @"data\poketool\pokegra\otherpoke.narc", [DirNames.itemData] = @"data\itemtool\itemdata\item_data.narc", - [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc" + [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc", + + [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; //Personal Data archive is different for Pearl @@ -1525,7 +1529,9 @@ namespace DSPRE [DirNames.evolutions] = @"data\poketool\personal\evo.narc", [DirNames.itemData] = @"data\itemtool\itemdata\pl_item_data.narc", - [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc" + [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc", + + [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; break; @@ -1567,6 +1573,7 @@ namespace DSPRE [DirNames.evolutions] = @"data\a\0\3\4", [DirNames.itemData] = @"data\a\0\1\7", [DirNames.itemIcons] = @"data\a\0\1\8", + [DirNames.tradeData] = @"data\a\1\1\2", [DirNames.safariZone] = @"data\a\2\3\0", [DirNames.headbutt] = @"data\a\2\5\2", //both versions use the same folder with different data From 2a11c38bc8268465528d8244bb16690fcee52a17 Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 18:47:23 +0200 Subject: [PATCH 02/11] this should be fully functional now --- DS_Map/DSPRE.csproj | 3 + DS_Map/Editors/TextEditor.Designer.cs | 1 + DS_Map/Editors/TradeEditor.Designer.cs | 743 ++++++++++++++++++++++++- DS_Map/Editors/TradeEditor.cs | 301 +++++++++- DS_Map/Editors/TradeEditor.resx | 123 ++++ DS_Map/Main Window.Designer.cs | 12 +- DS_Map/Main Window.cs | 8 + DS_Map/ROMFiles/TradeData.cs | 14 +- DS_Map/RomInfo.cs | 30 + 9 files changed, 1230 insertions(+), 5 deletions(-) create mode 100644 DS_Map/Editors/TradeEditor.resx diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj index 2ab79af..8765a2b 100644 --- a/DS_Map/DSPRE.csproj +++ b/DS_Map/DSPRE.csproj @@ -531,6 +531,9 @@ TextEditor.cs + + TradeEditor.cs + TrainerEditor.cs diff --git a/DS_Map/Editors/TextEditor.Designer.cs b/DS_Map/Editors/TextEditor.Designer.cs index 6f45fbb..a360188 100644 --- a/DS_Map/Editors/TextEditor.Designer.cs +++ b/DS_Map/Editors/TextEditor.Designer.cs @@ -331,6 +331,7 @@ this.textSearchResultsListBox.Size = new System.Drawing.Size(267, 244); this.textSearchResultsListBox.TabIndex = 38; this.textSearchResultsListBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textSearchResultsListBox_KeyDown); + this.textSearchResultsListBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.textSearchResultsListBox_GoToEntryResult); // // replaceTextLabel // diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs index 59fbe5c..645291b 100644 --- a/DS_Map/Editors/TradeEditor.Designer.cs +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -29,11 +29,752 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + this.mainPanel = new System.Windows.Forms.Panel(); + this.saveTextDataButton = new System.Windows.Forms.Button(); + this.saveTradeButton = new System.Windows.Forms.Button(); + this.textDataGroupBox = new System.Windows.Forms.GroupBox(); + this.nicknameTextBox = new System.Windows.Forms.TextBox(); + this.otNameTextBox = new System.Windows.Forms.TextBox(); + this.nicknameLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.tradeDataGroupBox = new System.Windows.Forms.GroupBox(); + this.requestedComboBox = new System.Windows.Forms.ComboBox(); + this.requestedLabel = new System.Windows.Forms.Label(); + this.otGenderComboBox = new System.Windows.Forms.ComboBox(); + this.otGenderLabel = new System.Windows.Forms.Label(); + this.otIDNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.otIDLabel = new System.Windows.Forms.Label(); + this.monDataGroupBox = new System.Windows.Forms.GroupBox(); + this.monDataPanel = new System.Windows.Forms.Panel(); + this.abilityComboBox = new System.Windows.Forms.ComboBox(); + this.abilityLabel = new System.Windows.Forms.Label(); + this.unknownNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.unknownLabel = new System.Windows.Forms.Label(); + this.pidNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.pidLabel = new System.Windows.Forms.Label(); + this.langComboBox = new System.Windows.Forms.ComboBox(); + this.langLabel = new System.Windows.Forms.Label(); + this.heldItemComboBox = new System.Windows.Forms.ComboBox(); + this.heldItemLabel = new System.Windows.Forms.Label(); + this.contestGroupBox = new System.Windows.Forms.GroupBox(); + this.toughNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.smartNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.cuteNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.beautyNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.coolNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.sheenNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.toughLabel = new System.Windows.Forms.Label(); + this.smartLabel = new System.Windows.Forms.Label(); + this.cuteLabel = new System.Windows.Forms.Label(); + this.beautyLabel = new System.Windows.Forms.Label(); + this.coolLabel = new System.Windows.Forms.Label(); + this.sheenLabel = new System.Windows.Forms.Label(); + this.IVGroupBox = new System.Windows.Forms.GroupBox(); + this.speIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.spdIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.spaIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.defIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.atkIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.hpIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.speIVLabel = new System.Windows.Forms.Label(); + this.spdIVLabel = new System.Windows.Forms.Label(); + this.spaIVLabel = new System.Windows.Forms.Label(); + this.defIVLabel = new System.Windows.Forms.Label(); + this.atkIVLabel = new System.Windows.Forms.Label(); + this.hpIVLabel = new System.Windows.Forms.Label(); + this.speciesComboBox = new System.Windows.Forms.ComboBox(); + this.speciesLabel = new System.Windows.Forms.Label(); + this.tradeIDNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.tradeIDLabel = new System.Windows.Forms.Label(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.mainPanel.SuspendLayout(); + this.textDataGroupBox.SuspendLayout(); + this.tradeDataGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.otIDNumericUpDown)).BeginInit(); + this.monDataGroupBox.SuspendLayout(); + this.monDataPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.unknownNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pidNumericUpDown)).BeginInit(); + this.contestGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.toughNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.smartNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cuteNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.beautyNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.coolNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.sheenNumericUpDown)).BeginInit(); + this.IVGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.speIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.spdIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.spaIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.defIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.atkIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.hpIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tradeIDNumericUpDown)).BeginInit(); + this.SuspendLayout(); + // + // mainPanel + // + this.mainPanel.Controls.Add(this.saveTextDataButton); + this.mainPanel.Controls.Add(this.saveTradeButton); + this.mainPanel.Controls.Add(this.textDataGroupBox); + this.mainPanel.Controls.Add(this.tradeDataGroupBox); + this.mainPanel.Location = new System.Drawing.Point(12, 12); + this.mainPanel.Name = "mainPanel"; + this.mainPanel.Size = new System.Drawing.Size(624, 444); + this.mainPanel.TabIndex = 0; + // + // saveTextDataButton + // + this.saveTextDataButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveTextDataButton.Image = global::DSPRE.Properties.Resources.saveButton; + this.saveTextDataButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + this.saveTextDataButton.Location = new System.Drawing.Point(479, 156); + this.saveTextDataButton.Name = "saveTextDataButton"; + this.saveTextDataButton.Size = new System.Drawing.Size(126, 44); + this.saveTextDataButton.TabIndex = 5; + this.saveTextDataButton.Text = "Save Text Data"; + this.saveTextDataButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.saveTextDataButton.UseVisualStyleBackColor = true; + this.saveTextDataButton.Click += new System.EventHandler(this.saveTextDataButton_Click); + // + // saveTradeButton + // + this.saveTradeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveTradeButton.Image = global::DSPRE.Properties.Resources.saveButton; + this.saveTradeButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.saveTradeButton.Location = new System.Drawing.Point(470, 383); + this.saveTradeButton.Name = "saveTradeButton"; + this.saveTradeButton.Size = new System.Drawing.Size(147, 47); + this.saveTradeButton.TabIndex = 4; + this.saveTradeButton.Text = "Save Trade Data"; + this.saveTradeButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.saveTradeButton.UseVisualStyleBackColor = true; + this.saveTradeButton.Click += new System.EventHandler(this.saveTradeButton_Click); + // + // textDataGroupBox + // + this.textDataGroupBox.Controls.Add(this.nicknameTextBox); + this.textDataGroupBox.Controls.Add(this.otNameTextBox); + this.textDataGroupBox.Controls.Add(this.nicknameLabel); + this.textDataGroupBox.Controls.Add(this.label1); + this.textDataGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textDataGroupBox.Location = new System.Drawing.Point(470, 3); + this.textDataGroupBox.Name = "textDataGroupBox"; + this.textDataGroupBox.Size = new System.Drawing.Size(147, 147); + this.textDataGroupBox.TabIndex = 3; + this.textDataGroupBox.TabStop = false; + this.textDataGroupBox.Text = "Text Data"; + // + // nicknameTextBox + // + this.nicknameTextBox.Location = new System.Drawing.Point(9, 100); + this.nicknameTextBox.Name = "nicknameTextBox"; + this.nicknameTextBox.Size = new System.Drawing.Size(126, 22); + this.nicknameTextBox.TabIndex = 17; + // + // otNameTextBox + // + this.otNameTextBox.Location = new System.Drawing.Point(9, 46); + this.otNameTextBox.Name = "otNameTextBox"; + this.otNameTextBox.Size = new System.Drawing.Size(126, 22); + this.otNameTextBox.TabIndex = 16; + // + // nicknameLabel + // + this.nicknameLabel.AutoSize = true; + this.nicknameLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.nicknameLabel.Location = new System.Drawing.Point(6, 79); + this.nicknameLabel.Name = "nicknameLabel"; + this.nicknameLabel.Size = new System.Drawing.Size(129, 16); + this.nicknameLabel.TabIndex = 15; + this.nicknameLabel.Text = "Pokémon Nickname"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(6, 25); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 16); + this.label1.TabIndex = 13; + this.label1.Text = "OT Name"; + // + // tradeDataGroupBox + // + this.tradeDataGroupBox.Controls.Add(this.requestedComboBox); + this.tradeDataGroupBox.Controls.Add(this.requestedLabel); + this.tradeDataGroupBox.Controls.Add(this.otGenderComboBox); + this.tradeDataGroupBox.Controls.Add(this.otGenderLabel); + this.tradeDataGroupBox.Controls.Add(this.otIDNumericUpDown); + this.tradeDataGroupBox.Controls.Add(this.otIDLabel); + this.tradeDataGroupBox.Controls.Add(this.monDataGroupBox); + this.tradeDataGroupBox.Controls.Add(this.tradeIDNumericUpDown); + this.tradeDataGroupBox.Controls.Add(this.tradeIDLabel); + this.tradeDataGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tradeDataGroupBox.Location = new System.Drawing.Point(3, 3); + this.tradeDataGroupBox.Name = "tradeDataGroupBox"; + this.tradeDataGroupBox.Size = new System.Drawing.Size(461, 437); + this.tradeDataGroupBox.TabIndex = 2; + this.tradeDataGroupBox.TabStop = false; + this.tradeDataGroupBox.Text = "Trade Data"; + // + // requestedComboBox + // + this.requestedComboBox.FormattingEnabled = true; + this.requestedComboBox.Location = new System.Drawing.Point(165, 44); + this.requestedComboBox.Name = "requestedComboBox"; + this.requestedComboBox.Size = new System.Drawing.Size(150, 24); + this.requestedComboBox.TabIndex = 12; + // + // requestedLabel + // + this.requestedLabel.AutoSize = true; + this.requestedLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.requestedLabel.Location = new System.Drawing.Point(162, 25); + this.requestedLabel.Name = "requestedLabel"; + this.requestedLabel.Size = new System.Drawing.Size(135, 16); + this.requestedLabel.TabIndex = 11; + this.requestedLabel.Text = "Requested Pokémon"; + // + // otGenderComboBox + // + this.otGenderComboBox.FormattingEnabled = true; + this.otGenderComboBox.Location = new System.Drawing.Point(165, 98); + this.otGenderComboBox.Name = "otGenderComboBox"; + this.otGenderComboBox.Size = new System.Drawing.Size(150, 24); + this.otGenderComboBox.TabIndex = 10; + // + // otGenderLabel + // + this.otGenderLabel.AutoSize = true; + this.otGenderLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otGenderLabel.Location = new System.Drawing.Point(162, 79); + this.otGenderLabel.Name = "otGenderLabel"; + this.otGenderLabel.Size = new System.Drawing.Size(74, 16); + this.otGenderLabel.TabIndex = 9; + this.otGenderLabel.Text = "OT Gender"; + // + // otIDNumericUpDown + // + this.otIDNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otIDNumericUpDown.Location = new System.Drawing.Point(21, 98); + this.otIDNumericUpDown.Name = "otIDNumericUpDown"; + this.otIDNumericUpDown.Size = new System.Drawing.Size(120, 22); + this.otIDNumericUpDown.TabIndex = 6; + // + // otIDLabel + // + this.otIDLabel.AutoSize = true; + this.otIDLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otIDLabel.Location = new System.Drawing.Point(18, 79); + this.otIDLabel.Name = "otIDLabel"; + this.otIDLabel.Size = new System.Drawing.Size(42, 16); + this.otIDLabel.TabIndex = 7; + this.otIDLabel.Text = "OT ID"; + // + // monDataGroupBox + // + this.monDataGroupBox.Controls.Add(this.monDataPanel); + this.monDataGroupBox.Location = new System.Drawing.Point(9, 139); + this.monDataGroupBox.Name = "monDataGroupBox"; + this.monDataGroupBox.Size = new System.Drawing.Size(441, 288); + this.monDataGroupBox.TabIndex = 5; + this.monDataGroupBox.TabStop = false; + this.monDataGroupBox.Text = "Pokémon Data"; + // + // monDataPanel + // + this.monDataPanel.Controls.Add(this.abilityComboBox); + this.monDataPanel.Controls.Add(this.abilityLabel); + this.monDataPanel.Controls.Add(this.unknownNumericUpDown); + this.monDataPanel.Controls.Add(this.unknownLabel); + this.monDataPanel.Controls.Add(this.pidNumericUpDown); + this.monDataPanel.Controls.Add(this.pidLabel); + this.monDataPanel.Controls.Add(this.langComboBox); + this.monDataPanel.Controls.Add(this.langLabel); + this.monDataPanel.Controls.Add(this.heldItemComboBox); + this.monDataPanel.Controls.Add(this.heldItemLabel); + this.monDataPanel.Controls.Add(this.contestGroupBox); + this.monDataPanel.Controls.Add(this.IVGroupBox); + this.monDataPanel.Controls.Add(this.speciesComboBox); + this.monDataPanel.Controls.Add(this.speciesLabel); + this.monDataPanel.Location = new System.Drawing.Point(6, 21); + this.monDataPanel.Name = "monDataPanel"; + this.monDataPanel.Size = new System.Drawing.Size(418, 257); + this.monDataPanel.TabIndex = 4; + // + // abilityComboBox + // + this.abilityComboBox.FormattingEnabled = true; + this.abilityComboBox.Location = new System.Drawing.Point(6, 218); + this.abilityComboBox.Name = "abilityComboBox"; + this.abilityComboBox.Size = new System.Drawing.Size(147, 24); + this.abilityComboBox.TabIndex = 26; + // + // abilityLabel + // + this.abilityLabel.AutoSize = true; + this.abilityLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.abilityLabel.Location = new System.Drawing.Point(3, 198); + this.abilityLabel.Name = "abilityLabel"; + this.abilityLabel.Size = new System.Drawing.Size(43, 16); + this.abilityLabel.TabIndex = 27; + this.abilityLabel.Text = "Ability"; + // + // unknownNumericUpDown + // + this.unknownNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.unknownNumericUpDown.Location = new System.Drawing.Point(294, 220); + this.unknownNumericUpDown.Name = "unknownNumericUpDown"; + this.unknownNumericUpDown.Size = new System.Drawing.Size(111, 22); + this.unknownNumericUpDown.TabIndex = 24; + // + // unknownLabel + // + this.unknownLabel.AutoSize = true; + this.unknownLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.unknownLabel.Location = new System.Drawing.Point(291, 201); + this.unknownLabel.Name = "unknownLabel"; + this.unknownLabel.Size = new System.Drawing.Size(100, 16); + this.unknownLabel.TabIndex = 25; + this.unknownLabel.Text = "Unknown Value"; + // + // pidNumericUpDown + // + this.pidNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.pidNumericUpDown.Location = new System.Drawing.Point(169, 220); + this.pidNumericUpDown.Name = "pidNumericUpDown"; + this.pidNumericUpDown.Size = new System.Drawing.Size(111, 22); + this.pidNumericUpDown.TabIndex = 11; + // + // pidLabel + // + this.pidLabel.AutoSize = true; + this.pidLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.pidLabel.Location = new System.Drawing.Point(166, 201); + this.pidLabel.Name = "pidLabel"; + this.pidLabel.Size = new System.Drawing.Size(29, 16); + this.pidLabel.TabIndex = 23; + this.pidLabel.Text = "PID"; + // + // langComboBox + // + this.langComboBox.FormattingEnabled = true; + this.langComboBox.Location = new System.Drawing.Point(6, 166); + this.langComboBox.Name = "langComboBox"; + this.langComboBox.Size = new System.Drawing.Size(147, 24); + this.langComboBox.TabIndex = 20; + // + // langLabel + // + this.langLabel.AutoSize = true; + this.langLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.langLabel.Location = new System.Drawing.Point(3, 146); + this.langLabel.Name = "langLabel"; + this.langLabel.Size = new System.Drawing.Size(106, 16); + this.langLabel.TabIndex = 21; + this.langLabel.Text = "Origin Language"; + // + // heldItemComboBox + // + this.heldItemComboBox.FormattingEnabled = true; + this.heldItemComboBox.Location = new System.Drawing.Point(6, 98); + this.heldItemComboBox.Name = "heldItemComboBox"; + this.heldItemComboBox.Size = new System.Drawing.Size(147, 24); + this.heldItemComboBox.TabIndex = 18; + // + // heldItemLabel + // + this.heldItemLabel.AutoSize = true; + this.heldItemLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.heldItemLabel.Location = new System.Drawing.Point(3, 78); + this.heldItemLabel.Name = "heldItemLabel"; + this.heldItemLabel.Size = new System.Drawing.Size(64, 16); + this.heldItemLabel.TabIndex = 19; + this.heldItemLabel.Text = "Held Item"; + // + // contestGroupBox + // + this.contestGroupBox.Controls.Add(this.toughNumericUpDown); + this.contestGroupBox.Controls.Add(this.smartNumericUpDown); + this.contestGroupBox.Controls.Add(this.cuteNumericUpDown); + this.contestGroupBox.Controls.Add(this.beautyNumericUpDown); + this.contestGroupBox.Controls.Add(this.coolNumericUpDown); + this.contestGroupBox.Controls.Add(this.sheenNumericUpDown); + this.contestGroupBox.Controls.Add(this.toughLabel); + this.contestGroupBox.Controls.Add(this.smartLabel); + this.contestGroupBox.Controls.Add(this.cuteLabel); + this.contestGroupBox.Controls.Add(this.beautyLabel); + this.contestGroupBox.Controls.Add(this.coolLabel); + this.contestGroupBox.Controls.Add(this.sheenLabel); + this.contestGroupBox.Location = new System.Drawing.Point(285, 10); + this.contestGroupBox.Name = "contestGroupBox"; + this.contestGroupBox.Size = new System.Drawing.Size(120, 180); + this.contestGroupBox.TabIndex = 17; + this.contestGroupBox.TabStop = false; + this.contestGroupBox.Text = "Contest Stats"; + // + // toughNumericUpDown + // + this.toughNumericUpDown.Location = new System.Drawing.Point(64, 148); + this.toughNumericUpDown.Name = "toughNumericUpDown"; + this.toughNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.toughNumericUpDown.TabIndex = 16; + // + // smartNumericUpDown + // + this.smartNumericUpDown.Location = new System.Drawing.Point(64, 123); + this.smartNumericUpDown.Name = "smartNumericUpDown"; + this.smartNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.smartNumericUpDown.TabIndex = 15; + // + // cuteNumericUpDown + // + this.cuteNumericUpDown.Location = new System.Drawing.Point(64, 97); + this.cuteNumericUpDown.Name = "cuteNumericUpDown"; + this.cuteNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.cuteNumericUpDown.TabIndex = 14; + // + // beautyNumericUpDown + // + this.beautyNumericUpDown.Location = new System.Drawing.Point(64, 72); + this.beautyNumericUpDown.Name = "beautyNumericUpDown"; + this.beautyNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.beautyNumericUpDown.TabIndex = 13; + // + // coolNumericUpDown + // + this.coolNumericUpDown.Location = new System.Drawing.Point(64, 47); + this.coolNumericUpDown.Name = "coolNumericUpDown"; + this.coolNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.coolNumericUpDown.TabIndex = 12; + // + // sheenNumericUpDown + // + this.sheenNumericUpDown.Location = new System.Drawing.Point(64, 22); + this.sheenNumericUpDown.Name = "sheenNumericUpDown"; + this.sheenNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.sheenNumericUpDown.TabIndex = 11; + // + // toughLabel + // + this.toughLabel.AutoSize = true; + this.toughLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toughLabel.Location = new System.Drawing.Point(6, 150); + this.toughLabel.Name = "toughLabel"; + this.toughLabel.Size = new System.Drawing.Size(46, 16); + this.toughLabel.TabIndex = 10; + this.toughLabel.Text = "Tough"; + // + // smartLabel + // + this.smartLabel.AutoSize = true; + this.smartLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.smartLabel.Location = new System.Drawing.Point(6, 125); + this.smartLabel.Name = "smartLabel"; + this.smartLabel.Size = new System.Drawing.Size(42, 16); + this.smartLabel.TabIndex = 9; + this.smartLabel.Text = "Smart"; + // + // cuteLabel + // + this.cuteLabel.AutoSize = true; + this.cuteLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cuteLabel.Location = new System.Drawing.Point(6, 100); + this.cuteLabel.Name = "cuteLabel"; + this.cuteLabel.Size = new System.Drawing.Size(34, 16); + this.cuteLabel.TabIndex = 8; + this.cuteLabel.Text = "Cute"; + // + // beautyLabel + // + this.beautyLabel.AutoSize = true; + this.beautyLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.beautyLabel.Location = new System.Drawing.Point(6, 75); + this.beautyLabel.Name = "beautyLabel"; + this.beautyLabel.Size = new System.Drawing.Size(49, 16); + this.beautyLabel.TabIndex = 7; + this.beautyLabel.Text = "Beauty"; + // + // coolLabel + // + this.coolLabel.AutoSize = true; + this.coolLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.coolLabel.Location = new System.Drawing.Point(6, 50); + this.coolLabel.Name = "coolLabel"; + this.coolLabel.Size = new System.Drawing.Size(35, 16); + this.coolLabel.TabIndex = 6; + this.coolLabel.Text = "Cool"; + // + // sheenLabel + // + this.sheenLabel.AutoSize = true; + this.sheenLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.sheenLabel.Location = new System.Drawing.Point(6, 25); + this.sheenLabel.Name = "sheenLabel"; + this.sheenLabel.Size = new System.Drawing.Size(46, 16); + this.sheenLabel.TabIndex = 5; + this.sheenLabel.Text = "Sheen"; + // + // IVGroupBox + // + this.IVGroupBox.Controls.Add(this.speIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.spdIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.spaIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.defIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.atkIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.hpIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.speIVLabel); + this.IVGroupBox.Controls.Add(this.spdIVLabel); + this.IVGroupBox.Controls.Add(this.spaIVLabel); + this.IVGroupBox.Controls.Add(this.defIVLabel); + this.IVGroupBox.Controls.Add(this.atkIVLabel); + this.IVGroupBox.Controls.Add(this.hpIVLabel); + this.IVGroupBox.Location = new System.Drawing.Point(160, 10); + this.IVGroupBox.Name = "IVGroupBox"; + this.IVGroupBox.Size = new System.Drawing.Size(120, 180); + this.IVGroupBox.TabIndex = 4; + this.IVGroupBox.TabStop = false; + this.IVGroupBox.Text = "IVs"; + // + // speIVNumericUpDown + // + this.speIVNumericUpDown.Location = new System.Drawing.Point(50, 148); + this.speIVNumericUpDown.Name = "speIVNumericUpDown"; + this.speIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.speIVNumericUpDown.TabIndex = 16; + // + // spdIVNumericUpDown + // + this.spdIVNumericUpDown.Location = new System.Drawing.Point(50, 123); + this.spdIVNumericUpDown.Name = "spdIVNumericUpDown"; + this.spdIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.spdIVNumericUpDown.TabIndex = 15; + // + // spaIVNumericUpDown + // + this.spaIVNumericUpDown.Location = new System.Drawing.Point(50, 97); + this.spaIVNumericUpDown.Name = "spaIVNumericUpDown"; + this.spaIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.spaIVNumericUpDown.TabIndex = 14; + // + // defIVNumericUpDown + // + this.defIVNumericUpDown.Location = new System.Drawing.Point(50, 72); + this.defIVNumericUpDown.Name = "defIVNumericUpDown"; + this.defIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.defIVNumericUpDown.TabIndex = 13; + // + // atkIVNumericUpDown + // + this.atkIVNumericUpDown.Location = new System.Drawing.Point(50, 47); + this.atkIVNumericUpDown.Name = "atkIVNumericUpDown"; + this.atkIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.atkIVNumericUpDown.TabIndex = 12; + // + // hpIVNumericUpDown + // + this.hpIVNumericUpDown.Location = new System.Drawing.Point(50, 22); + this.hpIVNumericUpDown.Name = "hpIVNumericUpDown"; + this.hpIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.hpIVNumericUpDown.TabIndex = 11; + // + // speIVLabel + // + this.speIVLabel.AutoSize = true; + this.speIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.speIVLabel.Location = new System.Drawing.Point(6, 150); + this.speIVLabel.Name = "speIVLabel"; + this.speIVLabel.Size = new System.Drawing.Size(32, 16); + this.speIVLabel.TabIndex = 10; + this.speIVLabel.Text = "Spe"; + // + // spdIVLabel + // + this.spdIVLabel.AutoSize = true; + this.spdIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.spdIVLabel.Location = new System.Drawing.Point(6, 125); + this.spdIVLabel.Name = "spdIVLabel"; + this.spdIVLabel.Size = new System.Drawing.Size(34, 16); + this.spdIVLabel.TabIndex = 9; + this.spdIVLabel.Text = "SpD"; + // + // spaIVLabel + // + this.spaIVLabel.AutoSize = true; + this.spaIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.spaIVLabel.Location = new System.Drawing.Point(6, 100); + this.spaIVLabel.Name = "spaIVLabel"; + this.spaIVLabel.Size = new System.Drawing.Size(33, 16); + this.spaIVLabel.TabIndex = 8; + this.spaIVLabel.Text = "SpA"; + // + // defIVLabel + // + this.defIVLabel.AutoSize = true; + this.defIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.defIVLabel.Location = new System.Drawing.Point(6, 75); + this.defIVLabel.Name = "defIVLabel"; + this.defIVLabel.Size = new System.Drawing.Size(28, 16); + this.defIVLabel.TabIndex = 7; + this.defIVLabel.Text = "Def"; + // + // atkIVLabel + // + this.atkIVLabel.AutoSize = true; + this.atkIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.atkIVLabel.Location = new System.Drawing.Point(6, 50); + this.atkIVLabel.Name = "atkIVLabel"; + this.atkIVLabel.Size = new System.Drawing.Size(26, 16); + this.atkIVLabel.TabIndex = 6; + this.atkIVLabel.Text = "Atk"; + // + // hpIVLabel + // + this.hpIVLabel.AutoSize = true; + this.hpIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.hpIVLabel.Location = new System.Drawing.Point(6, 25); + this.hpIVLabel.Name = "hpIVLabel"; + this.hpIVLabel.Size = new System.Drawing.Size(26, 16); + this.hpIVLabel.TabIndex = 5; + this.hpIVLabel.Text = "HP"; + // + // speciesComboBox + // + this.speciesComboBox.FormattingEnabled = true; + this.speciesComboBox.Location = new System.Drawing.Point(6, 30); + this.speciesComboBox.Name = "speciesComboBox"; + this.speciesComboBox.Size = new System.Drawing.Size(147, 24); + this.speciesComboBox.TabIndex = 2; + // + // speciesLabel + // + this.speciesLabel.AutoSize = true; + this.speciesLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.speciesLabel.Location = new System.Drawing.Point(3, 10); + this.speciesLabel.Name = "speciesLabel"; + this.speciesLabel.Size = new System.Drawing.Size(57, 16); + this.speciesLabel.TabIndex = 3; + this.speciesLabel.Text = "Species"; + // + // tradeIDNumericUpDown + // + this.tradeIDNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tradeIDNumericUpDown.Location = new System.Drawing.Point(21, 46); + this.tradeIDNumericUpDown.Name = "tradeIDNumericUpDown"; + this.tradeIDNumericUpDown.Size = new System.Drawing.Size(120, 22); + this.tradeIDNumericUpDown.TabIndex = 0; + this.tradeIDNumericUpDown.ValueChanged += new System.EventHandler(this.tradeIDNumericUpDown_ValueChanged); + // + // tradeIDLabel + // + this.tradeIDLabel.AutoSize = true; + this.tradeIDLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tradeIDLabel.Location = new System.Drawing.Point(18, 27); + this.tradeIDLabel.Name = "tradeIDLabel"; + this.tradeIDLabel.Size = new System.Drawing.Size(60, 16); + this.tradeIDLabel.TabIndex = 1; + this.tradeIDLabel.Text = "Trade ID"; + // + // TradeEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(641, 460); + this.Controls.Add(this.mainPanel); + this.Name = "TradeEditor"; this.Text = "TradeEditor"; + this.mainPanel.ResumeLayout(false); + this.textDataGroupBox.ResumeLayout(false); + this.textDataGroupBox.PerformLayout(); + this.tradeDataGroupBox.ResumeLayout(false); + this.tradeDataGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.otIDNumericUpDown)).EndInit(); + this.monDataGroupBox.ResumeLayout(false); + this.monDataPanel.ResumeLayout(false); + this.monDataPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.unknownNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pidNumericUpDown)).EndInit(); + this.contestGroupBox.ResumeLayout(false); + this.contestGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.toughNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.smartNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cuteNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.beautyNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.coolNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.sheenNumericUpDown)).EndInit(); + this.IVGroupBox.ResumeLayout(false); + this.IVGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.speIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.spdIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.spaIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.defIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.atkIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.hpIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tradeIDNumericUpDown)).EndInit(); + this.ResumeLayout(false); + } #endregion + + private System.Windows.Forms.Panel mainPanel; + private System.Windows.Forms.NumericUpDown tradeIDNumericUpDown; + private System.Windows.Forms.Label tradeIDLabel; + private System.Windows.Forms.GroupBox tradeDataGroupBox; + private System.Windows.Forms.GroupBox textDataGroupBox; + private System.Windows.Forms.Label speciesLabel; + private System.Windows.Forms.ComboBox speciesComboBox; + private System.Windows.Forms.Panel monDataPanel; + private System.Windows.Forms.GroupBox IVGroupBox; + private System.Windows.Forms.Label speIVLabel; + private System.Windows.Forms.Label spdIVLabel; + private System.Windows.Forms.Label spaIVLabel; + private System.Windows.Forms.Label defIVLabel; + private System.Windows.Forms.Label atkIVLabel; + private System.Windows.Forms.Label hpIVLabel; + private System.Windows.Forms.NumericUpDown speIVNumericUpDown; + private System.Windows.Forms.NumericUpDown spdIVNumericUpDown; + private System.Windows.Forms.NumericUpDown spaIVNumericUpDown; + private System.Windows.Forms.NumericUpDown defIVNumericUpDown; + private System.Windows.Forms.NumericUpDown atkIVNumericUpDown; + private System.Windows.Forms.NumericUpDown hpIVNumericUpDown; + private System.Windows.Forms.GroupBox contestGroupBox; + private System.Windows.Forms.NumericUpDown toughNumericUpDown; + private System.Windows.Forms.NumericUpDown smartNumericUpDown; + private System.Windows.Forms.NumericUpDown cuteNumericUpDown; + private System.Windows.Forms.NumericUpDown beautyNumericUpDown; + private System.Windows.Forms.NumericUpDown coolNumericUpDown; + private System.Windows.Forms.NumericUpDown sheenNumericUpDown; + private System.Windows.Forms.Label toughLabel; + private System.Windows.Forms.Label smartLabel; + private System.Windows.Forms.Label cuteLabel; + private System.Windows.Forms.Label beautyLabel; + private System.Windows.Forms.Label coolLabel; + private System.Windows.Forms.Label sheenLabel; + private System.Windows.Forms.ComboBox heldItemComboBox; + private System.Windows.Forms.Label heldItemLabel; + private System.Windows.Forms.GroupBox monDataGroupBox; + private System.Windows.Forms.ComboBox langComboBox; + private System.Windows.Forms.Label langLabel; + private System.Windows.Forms.NumericUpDown otIDNumericUpDown; + private System.Windows.Forms.Label otIDLabel; + private System.Windows.Forms.Label otGenderLabel; + private System.Windows.Forms.ComboBox otGenderComboBox; + private System.Windows.Forms.NumericUpDown pidNumericUpDown; + private System.Windows.Forms.Label pidLabel; + private System.Windows.Forms.NumericUpDown unknownNumericUpDown; + private System.Windows.Forms.Label unknownLabel; + private System.Windows.Forms.ComboBox abilityComboBox; + private System.Windows.Forms.Label abilityLabel; + private System.Windows.Forms.ComboBox requestedComboBox; + private System.Windows.Forms.Label requestedLabel; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.Button saveTradeButton; + private System.Windows.Forms.TextBox nicknameTextBox; + private System.Windows.Forms.TextBox otNameTextBox; + private System.Windows.Forms.Label nicknameLabel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button saveTextDataButton; } } \ No newline at end of file diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 79794b3..45ff993 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -1,4 +1,5 @@ -using System; +using DSPRE.ROMFiles; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +13,307 @@ namespace DSPRE.Editors { public partial class TradeEditor : Form { + + private TradeData curTradeData; + private TextArchive tradeArchive; + + #region Enums + public enum OriginLang + { + NONE = 0, + JAPANESE = 1, + ENGLISH = 2, + FRENCH = 3, + ITALIAN = 4, + GERMAN = 5, + UNUSED = 6, + SPANISH = 7, + KOREAN = 8 + } + #endregion + public TradeEditor() { + Helpers.DisableHandlers(); + InitializeComponent(); + InitLimits(); + InitDataRanges(); + SetToolTips(); + + if (TradeData.GetTradeCount() == 0) + { + MessageBox.Show("No trades could be found! The narc may have failed to unpack.", "Loading Trades Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error("TradeEditor: Loading trades failed."); + return; + } + + if (RomInfo.gameFamily != RomInfo.GameFamilies.HGSS) + { + unknownNumericUpDown.Enabled = false; + } + + tradeArchive = new TextArchive(GetTextBankIndex()); + LoadFromFile(0); + } + + public void LoadFromFile(int tradeID) + { + Helpers.DisableHandlers(); + curTradeData = new TradeData(tradeID); + tradeIDNumericUpDown.Value = tradeID; + speciesComboBox.SelectedIndex = curTradeData.species; + hpIVNumericUpDown.Value = curTradeData.hpIV; + atkIVNumericUpDown.Value = curTradeData.atkIV; + defIVNumericUpDown.Value = curTradeData.defIV; + speIVNumericUpDown.Value = curTradeData.speedIV; + spaIVNumericUpDown.Value = curTradeData.spAtkIV; + spdIVNumericUpDown.Value = curTradeData.spDefIV; + abilityComboBox.SelectedIndex = curTradeData.ability; + otIDNumericUpDown.Value = curTradeData.otID; + coolNumericUpDown.Value = curTradeData.cool; + beautyNumericUpDown.Value = curTradeData.beauty; + cuteNumericUpDown.Value = curTradeData.cute; + smartNumericUpDown.Value = curTradeData.smart; + toughNumericUpDown.Value = curTradeData.tough; + pidNumericUpDown.Value = curTradeData.pid; + heldItemComboBox.SelectedIndex = curTradeData.heldItem; + otGenderComboBox.SelectedIndex = curTradeData.otGender; + sheenNumericUpDown.Value = curTradeData.sheen; + langComboBox.SelectedIndex = curTradeData.language; + requestedComboBox.SelectedIndex = curTradeData.requestedSpecies; + unknownNumericUpDown.Value = curTradeData.unknown; + + otNameTextBox.Text = GetOTName(tradeID); + nicknameTextBox.Text = GetMonNickname(tradeID); + + Helpers.EnableHandlers(); + } + + private void SaveToFile() + { + curTradeData.species = speciesComboBox.SelectedIndex; + curTradeData.hpIV = (int)hpIVNumericUpDown.Value; + curTradeData.atkIV = (int)atkIVNumericUpDown.Value; + curTradeData.defIV = (int)defIVNumericUpDown.Value; + curTradeData.speedIV = (int)speIVNumericUpDown.Value; + curTradeData.spAtkIV = (int)spaIVNumericUpDown.Value; + curTradeData.spDefIV = (int)spdIVNumericUpDown.Value; + curTradeData.ability = abilityComboBox.SelectedIndex; + curTradeData.otID = (int)otIDNumericUpDown.Value; + curTradeData.cool = (int)coolNumericUpDown.Value; + curTradeData.beauty = (int)beautyNumericUpDown.Value; + curTradeData.cute = (int)cuteNumericUpDown.Value; + curTradeData.smart = (int)smartNumericUpDown.Value; + curTradeData.tough = (int)toughNumericUpDown.Value; + curTradeData.pid = (int)pidNumericUpDown.Value; + curTradeData.heldItem = heldItemComboBox.SelectedIndex; + curTradeData.otGender = otGenderComboBox.SelectedIndex; + curTradeData.sheen = (int)sheenNumericUpDown.Value; + curTradeData.language = langComboBox.SelectedIndex; + curTradeData.requestedSpecies = requestedComboBox.SelectedIndex; + + if (RomInfo.gameFamily == RomInfo.GameFamilies.HGSS) + { + curTradeData.unknown = (int)unknownNumericUpDown.Value; + } + else + { + curTradeData.unknown = 0; + } + + curTradeData.SaveToFileDefaultDir((int)tradeIDNumericUpDown.Value, true); + } + + private void InitLimits() + { + // IVs: 0-31 + hpIVNumericUpDown.Minimum = 0; + hpIVNumericUpDown.Maximum = 31; + atkIVNumericUpDown.Minimum = 0; + atkIVNumericUpDown.Maximum = 31; + defIVNumericUpDown.Minimum = 0; + defIVNumericUpDown.Maximum = 31; + speIVNumericUpDown.Minimum = 0; + speIVNumericUpDown.Maximum = 31; + spaIVNumericUpDown.Minimum = 0; + spaIVNumericUpDown.Maximum = 31; + spdIVNumericUpDown.Minimum = 0; + spdIVNumericUpDown.Maximum = 31; + + // Contest stats: 0-255 + coolNumericUpDown.Minimum = 0; + coolNumericUpDown.Maximum = 255; + beautyNumericUpDown.Minimum = 0; + beautyNumericUpDown.Maximum = 255; + cuteNumericUpDown.Minimum = 0; + cuteNumericUpDown.Maximum = 255; + smartNumericUpDown.Minimum = 0; + smartNumericUpDown.Maximum = 255; + toughNumericUpDown.Minimum = 0; + toughNumericUpDown.Maximum = 255; + + // PID: (32-bit unsigned) + pidNumericUpDown.Minimum = 0; + pidNumericUpDown.Maximum = int.MaxValue; + + // Sheen: 0-255 + sheenNumericUpDown.Minimum = 0; + sheenNumericUpDown.Maximum = 255; + + // Unknown: (32-bit unsigned) + unknownNumericUpDown.Minimum = 0; + unknownNumericUpDown.Maximum = int.MaxValue; + + // Trade ID: (dynamic based on loaded data) + tradeIDNumericUpDown.Minimum = 0; + tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount()-1; + + // OT ID: (32-bit unsigned) + otIDNumericUpDown.Minimum = 0; + otIDNumericUpDown.Maximum = int.MaxValue; + + // Text fields + otNameTextBox.MaxLength = 7; + nicknameTextBox.MaxLength = 10; + } + + private void InitDataRanges() + { + // Species Names + speciesComboBox.DataSource = RomInfo.GetPokemonNames(); + requestedComboBox.DataSource = RomInfo.GetPokemonNames(); + + // Abilities + abilityComboBox.DataSource = RomInfo.GetAbilityNames(); + + // Held Items + heldItemComboBox.DataSource = RomInfo.GetItemNames(); + + // OT Gender + otGenderComboBox.DataSource = new string[] {"Male", "Female"}; + + // Languages + langComboBox.DataSource = Enum.GetNames(typeof(OriginLang)); + } + + private void SetToolTips() + { + toolTip.SetToolTip(tradeIDNumericUpDown, "The Trade ID to edit."); + toolTip.SetToolTip(speciesComboBox, "The species of the Pokémon being traded."); + toolTip.SetToolTip(IVGroupBox, "Individual Values (IVs)"); + toolTip.SetToolTip(abilityComboBox, "The ability of the Pokémon.\nThis value is unused!"); + toolTip.SetToolTip(otIDNumericUpDown, "The Original Trainer ID of the Pokémon."); + toolTip.SetToolTip(contestGroupBox, "Contest stats for the Pokémon."); + toolTip.SetToolTip(pidNumericUpDown, "The PID of the Pokémon."); + toolTip.SetToolTip(heldItemComboBox, "The held item of the Pokémon."); + toolTip.SetToolTip(otGenderComboBox, "The gender of the Original Trainer (OT).\nThe OT name is determined by the text bank."); + toolTip.SetToolTip(langComboBox, "The language of origin of the traded Pokémon."); + toolTip.SetToolTip(requestedComboBox, "The species of the requested Pokémon.\nWhether the Pokémon selected by the player matches this species or not is checked via scripting."); + toolTip.SetToolTip(unknownNumericUpDown, "An unknown value, present in HGSS only.\nAppears to be unused."); + + } + + private void tradeIDNumericUpDown_ValueChanged(object sender, EventArgs e) + { + if (Helpers.HandlersDisabled) + { + return; + } + + int tradeID = (int)tradeIDNumericUpDown.Value; + if (tradeID < 0 || tradeID >= TradeData.GetTradeCount()) + { + MessageBox.Show("Invalid Trade ID selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + LoadFromFile(tradeID); + + } + + private void saveTradeButton_Click(object sender, EventArgs e) + { + SaveToFile(); + } + + private int GetTextBankIndex() + { + switch (RomInfo.gameFamily) + { + case RomInfo.GameFamilies.DP: + switch (RomInfo.gameLanguage) + { + case RomInfo.GameLanguages.Japanese: + return 325; // not confirmed to be correct + default: + return 326; + } + case RomInfo.GameFamilies.Plat: + switch (RomInfo.gameLanguage) + { + case RomInfo.GameLanguages.Japanese: + return 369; + default: + return 370; + } + case RomInfo.GameFamilies.HGSS: + switch (RomInfo.gameLanguage) + { + case RomInfo.GameLanguages.Japanese: + return 198; + default: + return 200; + } + default: + AppLogger.Error("TradeEditor: Invalid game family for text bank index retrieval."); + MessageBox.Show("Invalid game family for text bank index retrieval.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return 0; + } + + } + private string GetMonNickname(int tradeID) + { + string msg = tradeArchive.messages[tradeID]; + if (msg.Length > nicknameTextBox.MaxLength) + { + msg = msg.Substring(0, nicknameTextBox.MaxLength); + } + return msg; + } + + private string GetOTName(int tradeID) + { + int index = tradeID + TradeData.GetTradeCount(); + string msg = tradeArchive.messages[index]; + if (msg.Length > otNameTextBox.MaxLength) + { + msg = msg.Substring(0, otNameTextBox.MaxLength); + } + return msg; + } + + private void saveTextDataButton_Click(object sender, EventArgs e) + { + Helpers.DisableHandlers(); + int tradeID = (int)tradeIDNumericUpDown.Value; + + if (tradeID < 0 || tradeID + TradeData.GetTradeCount() > tradeArchive.messages.Count) + { + MessageBox.Show("Can't save to text bank. Index is out of range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error("TradeEditor: Can't save to text bank. Index is out of range."); + Helpers.EnableHandlers(); + return; + } + + // Nickname + tradeArchive.messages[tradeID] = nicknameTextBox.Text; + + // OT Name + tradeArchive.messages[tradeID + TradeData.GetTradeCount()] = otNameTextBox.Text; + + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + Helpers.EnableHandlers(); } } } diff --git a/DS_Map/Editors/TradeEditor.resx b/DS_Map/Editors/TradeEditor.resx new file mode 100644 index 0000000..8766f29 --- /dev/null +++ b/DS_Map/Editors/TradeEditor.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/DS_Map/Main Window.Designer.cs b/DS_Map/Main Window.Designer.cs index fd8df7a..a756fdd 100644 --- a/DS_Map/Main Window.Designer.cs +++ b/DS_Map/Main Window.Designer.cs @@ -536,6 +536,7 @@ this.flyWarpEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.itemEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.overworldEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tradeEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); @@ -6735,7 +6736,8 @@ this.moveDataEditorToolStripMenuItem, this.flyWarpEditorToolStripMenuItem, this.itemEditorToolStripMenuItem, - this.overworldEditorToolStripMenuItem}); + this.overworldEditorToolStripMenuItem, + this.tradeEditorToolStripMenuItem}); this.otherEditorsToolStripMenuItem.Enabled = false; this.otherEditorsToolStripMenuItem.Name = "otherEditorsToolStripMenuItem"; this.otherEditorsToolStripMenuItem.Size = new System.Drawing.Size(88, 20); @@ -6789,6 +6791,13 @@ this.overworldEditorToolStripMenuItem.Size = new System.Drawing.Size(174, 22); this.overworldEditorToolStripMenuItem.Text = "Overworld Editor"; this.overworldEditorToolStripMenuItem.Click += new System.EventHandler(this.overworldEditorToolStripMenuItem_Click); + // + // tradeEditorToolStripMenuItem + // + this.tradeEditorToolStripMenuItem.Name = "tradeEditorToolStripMenuItem"; + this.tradeEditorToolStripMenuItem.Size = new System.Drawing.Size(174, 22); + this.tradeEditorToolStripMenuItem.Text = "Trade Editor"; + this.tradeEditorToolStripMenuItem.Click += new System.EventHandler(this.tradeEditorToolStripMenuItem_Click); // // aboutToolStripMenuItem1 // @@ -7946,6 +7955,7 @@ private System.Windows.Forms.Panel panel1; private System.Windows.Forms.ToolStripMenuItem flyWarpEditorToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem itemEditorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem tradeEditorToolStripMenuItem; private System.Windows.Forms.Button popoutTextEditorButton; private System.Windows.Forms.Label textEditorPoppedOutLabel; private System.Windows.Forms.Button popoutLevelScriptEditorButton; diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 6d5e810..60b8560 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -7270,6 +7270,14 @@ namespace DSPRE { flyEditor.Show(); } + private void tradeEditorToolStripMenuItem_Click(object sender, EventArgs e) + { + DSUtils.TryUnpackNarcs(new List { DirNames.tradeData }); + + TradeEditor tradeEditor = new TradeEditor(); + tradeEditor.Show(); + } + private void itemEditorToolStripMenuItem_Click(object sender, EventArgs e) { Helpers.statusLabelMessage("Setting up Item Data Editor..."); diff --git a/DS_Map/ROMFiles/TradeData.cs b/DS_Map/ROMFiles/TradeData.cs index 267d709..4091eb9 100644 --- a/DS_Map/ROMFiles/TradeData.cs +++ b/DS_Map/ROMFiles/TradeData.cs @@ -48,7 +48,7 @@ namespace DSPRE.ROMFiles speedIV = br.ReadInt32(); spAtkIV = br.ReadInt32(); spDefIV = br.ReadInt32(); - ability = br.ReadInt32(); // unused + ability = br.ReadInt32(); // appears unused otID = br.ReadInt32(); cool = br.ReadInt32(); beauty = br.ReadInt32(); @@ -61,7 +61,12 @@ namespace DSPRE.ROMFiles sheen = br.ReadInt32(); language = br.ReadInt32(); requestedSpecies = br.ReadInt32(); - unknown = br.ReadInt32(); // unused? + + if (RomInfo.gameFamily == GameFamilies.HGSS) + { + unknown = br.ReadInt32(); // unused? + } + } } @@ -111,5 +116,10 @@ namespace DSPRE.ROMFiles SaveToFileExplorePath("Gen IV Trade data", "bin", suggestedFileName, showSuccessMessage); } + public static int GetTradeCount() + { + return Directory.GetFiles(RomInfo.gameDirs[DirNames.tradeData].unpackedDir, "*.*").Length; + } + } } diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 55c3dc2..e64f3cb 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -1486,6 +1486,11 @@ namespace DSPRE personal += @"\personal.narc"; packedDirsDict[DirNames.personalPokeData] = personal; + if (gameLanguage != GameLanguages.Japanese) + { + packedDirsDict[DirNames.tradeData] = $@"data\resource\{GetLangResFolderName()}\pokemon_trade\fld_trade.narc"; + } + break; case GameFamilies.Plat: @@ -1533,6 +1538,12 @@ namespace DSPRE [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; + + if (gameLanguage != GameLanguages.Japanese) + { + packedDirsDict[DirNames.tradeData] = $@"data\resource\{GetLangResFolderName()}\pokemon_trade\fld_trade.narc"; + } + break; case GameFamilies.HGSS: @@ -1591,6 +1602,25 @@ namespace DSPRE } } + public static string GetLangResFolderName() + { + switch (gameLanguage) + { + case GameLanguages.English: + return "eng"; + case GameLanguages.Italian: + return "ita"; + case GameLanguages.French: + return "fra"; + case GameLanguages.German: + return "ger"; + case GameLanguages.Spanish: + return "spa"; + default: + return ""; + } + } + public void ResetMapCellsColorDictionary() { switch (gameFamily) From 3370cfe65994266255f39ac3c17cea8942f0a3ae Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 19:44:22 +0200 Subject: [PATCH 03/11] fix JP DP trade text bank and revert text editor changes --- DS_Map/Editors/TextEditor.Designer.cs | 1 - DS_Map/Editors/TradeEditor.cs | 2 +- DS_Map/RomInfo.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/DS_Map/Editors/TextEditor.Designer.cs b/DS_Map/Editors/TextEditor.Designer.cs index a360188..6f45fbb 100644 --- a/DS_Map/Editors/TextEditor.Designer.cs +++ b/DS_Map/Editors/TextEditor.Designer.cs @@ -331,7 +331,6 @@ this.textSearchResultsListBox.Size = new System.Drawing.Size(267, 244); this.textSearchResultsListBox.TabIndex = 38; this.textSearchResultsListBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textSearchResultsListBox_KeyDown); - this.textSearchResultsListBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.textSearchResultsListBox_GoToEntryResult); // // replaceTextLabel // diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 45ff993..d6daef4 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -245,7 +245,7 @@ namespace DSPRE.Editors switch (RomInfo.gameLanguage) { case RomInfo.GameLanguages.Japanese: - return 325; // not confirmed to be correct + return 324; default: return 326; } diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index e64f3cb..02c653b 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -1026,7 +1026,7 @@ namespace DSPRE switch (gameFamily) { case GameFamilies.DP: - itemNamesTextNumber = 344; + itemNamesTextNumber = gameLanguage == GameLanguages.Japanese ? 341 : 344; itemDescriptionsTextNumber = 0; break; From 2e530552f59268ca493f0a77657efa05a82fba0b Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 22:40:28 +0200 Subject: [PATCH 04/11] trade editor complete except for adding / removing trades --- DS_Map/Editors/TradeEditor.Designer.cs | 99 +++++-- DS_Map/Editors/TradeEditor.cs | 376 ++++++++++++++++++------- 2 files changed, 347 insertions(+), 128 deletions(-) diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs index 645291b..454e2b4 100644 --- a/DS_Map/Editors/TradeEditor.Designer.cs +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -30,13 +30,14 @@ { this.components = new System.ComponentModel.Container(); this.mainPanel = new System.Windows.Forms.Panel(); + this.saveAllButton = new System.Windows.Forms.Button(); this.saveTextDataButton = new System.Windows.Forms.Button(); this.saveTradeButton = new System.Windows.Forms.Button(); this.textDataGroupBox = new System.Windows.Forms.GroupBox(); this.nicknameTextBox = new System.Windows.Forms.TextBox(); this.otNameTextBox = new System.Windows.Forms.TextBox(); this.nicknameLabel = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); + this.otNameLabel = new System.Windows.Forms.Label(); this.tradeDataGroupBox = new System.Windows.Forms.GroupBox(); this.requestedComboBox = new System.Windows.Forms.ComboBox(); this.requestedLabel = new System.Windows.Forms.Label(); @@ -87,6 +88,8 @@ this.tradeIDNumericUpDown = new System.Windows.Forms.NumericUpDown(); this.tradeIDLabel = new System.Windows.Forms.Label(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.addFileButton = new System.Windows.Forms.Button(); + this.removeLastButton = new System.Windows.Forms.Button(); this.mainPanel.SuspendLayout(); this.textDataGroupBox.SuspendLayout(); this.tradeDataGroupBox.SuspendLayout(); @@ -114,6 +117,9 @@ // // mainPanel // + this.mainPanel.Controls.Add(this.removeLastButton); + this.mainPanel.Controls.Add(this.saveAllButton); + this.mainPanel.Controls.Add(this.addFileButton); this.mainPanel.Controls.Add(this.saveTextDataButton); this.mainPanel.Controls.Add(this.saveTradeButton); this.mainPanel.Controls.Add(this.textDataGroupBox); @@ -123,28 +129,42 @@ this.mainPanel.Size = new System.Drawing.Size(624, 444); this.mainPanel.TabIndex = 0; // + // saveAllButton + // + this.saveAllButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveAllButton.Image = global::DSPRE.Properties.Resources.saveButton; + this.saveAllButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.saveAllButton.Location = new System.Drawing.Point(470, 389); + this.saveAllButton.Name = "saveAllButton"; + this.saveAllButton.Size = new System.Drawing.Size(147, 47); + this.saveAllButton.TabIndex = 6; + this.saveAllButton.Text = "Save All"; + this.saveAllButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.saveAllButton.UseVisualStyleBackColor = true; + this.saveAllButton.Click += new System.EventHandler(this.saveAllButton_Click); + // // saveTextDataButton // this.saveTextDataButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.saveTextDataButton.Image = global::DSPRE.Properties.Resources.saveButton; - this.saveTextDataButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.saveTextDataButton.Location = new System.Drawing.Point(479, 156); + this.saveTextDataButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.saveTextDataButton.Location = new System.Drawing.Point(479, 142); this.saveTextDataButton.Name = "saveTextDataButton"; - this.saveTextDataButton.Size = new System.Drawing.Size(126, 44); + this.saveTextDataButton.Size = new System.Drawing.Size(126, 40); this.saveTextDataButton.TabIndex = 5; this.saveTextDataButton.Text = "Save Text Data"; - this.saveTextDataButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.saveTextDataButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; this.saveTextDataButton.UseVisualStyleBackColor = true; this.saveTextDataButton.Click += new System.EventHandler(this.saveTextDataButton_Click); // // saveTradeButton // - this.saveTradeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveTradeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.saveTradeButton.Image = global::DSPRE.Properties.Resources.saveButton; this.saveTradeButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; - this.saveTradeButton.Location = new System.Drawing.Point(470, 383); + this.saveTradeButton.Location = new System.Drawing.Point(480, 342); this.saveTradeButton.Name = "saveTradeButton"; - this.saveTradeButton.Size = new System.Drawing.Size(147, 47); + this.saveTradeButton.Size = new System.Drawing.Size(126, 40); this.saveTradeButton.TabIndex = 4; this.saveTradeButton.Text = "Save Trade Data"; this.saveTradeButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; @@ -156,11 +176,11 @@ this.textDataGroupBox.Controls.Add(this.nicknameTextBox); this.textDataGroupBox.Controls.Add(this.otNameTextBox); this.textDataGroupBox.Controls.Add(this.nicknameLabel); - this.textDataGroupBox.Controls.Add(this.label1); + this.textDataGroupBox.Controls.Add(this.otNameLabel); this.textDataGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.textDataGroupBox.Location = new System.Drawing.Point(470, 3); this.textDataGroupBox.Name = "textDataGroupBox"; - this.textDataGroupBox.Size = new System.Drawing.Size(147, 147); + this.textDataGroupBox.Size = new System.Drawing.Size(147, 133); this.textDataGroupBox.TabIndex = 3; this.textDataGroupBox.TabStop = false; this.textDataGroupBox.Text = "Text Data"; @@ -189,15 +209,15 @@ this.nicknameLabel.TabIndex = 15; this.nicknameLabel.Text = "Pokémon Nickname"; // - // label1 + // otNameLabel // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(6, 25); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(66, 16); - this.label1.TabIndex = 13; - this.label1.Text = "OT Name"; + this.otNameLabel.AutoSize = true; + this.otNameLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otNameLabel.Location = new System.Drawing.Point(6, 25); + this.otNameLabel.Name = "otNameLabel"; + this.otNameLabel.Size = new System.Drawing.Size(66, 16); + this.otNameLabel.TabIndex = 13; + this.otNameLabel.Text = "OT Name"; // // tradeDataGroupBox // @@ -220,6 +240,7 @@ // // requestedComboBox // + this.requestedComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.requestedComboBox.FormattingEnabled = true; this.requestedComboBox.Location = new System.Drawing.Point(165, 44); this.requestedComboBox.Name = "requestedComboBox"; @@ -305,6 +326,7 @@ // // abilityComboBox // + this.abilityComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.abilityComboBox.FormattingEnabled = true; this.abilityComboBox.Location = new System.Drawing.Point(6, 218); this.abilityComboBox.Name = "abilityComboBox"; @@ -317,9 +339,9 @@ this.abilityLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.abilityLabel.Location = new System.Drawing.Point(3, 198); this.abilityLabel.Name = "abilityLabel"; - this.abilityLabel.Size = new System.Drawing.Size(43, 16); + this.abilityLabel.Size = new System.Drawing.Size(101, 16); this.abilityLabel.TabIndex = 27; - this.abilityLabel.Text = "Ability"; + this.abilityLabel.Text = "Ability (Unused)"; // // unknownNumericUpDown // @@ -359,6 +381,7 @@ // // langComboBox // + this.langComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.langComboBox.FormattingEnabled = true; this.langComboBox.Location = new System.Drawing.Point(6, 166); this.langComboBox.Name = "langComboBox"; @@ -377,6 +400,7 @@ // // heldItemComboBox // + this.heldItemComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.heldItemComboBox.FormattingEnabled = true; this.heldItemComboBox.Location = new System.Drawing.Point(6, 98); this.heldItemComboBox.Name = "heldItemComboBox"; @@ -641,6 +665,7 @@ // // speciesComboBox // + this.speciesComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.speciesComboBox.FormattingEnabled = true; this.speciesComboBox.Location = new System.Drawing.Point(6, 30); this.speciesComboBox.Name = "speciesComboBox"; @@ -676,6 +701,34 @@ this.tradeIDLabel.TabIndex = 1; this.tradeIDLabel.Text = "Trade ID"; // + // addFileButton + // + this.addFileButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.addFileButton.Image = global::DSPRE.Properties.Resources.addIcon; + this.addFileButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.addFileButton.Location = new System.Drawing.Point(480, 242); + this.addFileButton.Name = "addFileButton"; + this.addFileButton.Size = new System.Drawing.Size(126, 40); + this.addFileButton.TabIndex = 13; + this.addFileButton.Text = "Add File"; + this.addFileButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.addFileButton.UseVisualStyleBackColor = true; + this.addFileButton.Click += new System.EventHandler(this.addFileButton_Click); + // + // removeLastButton + // + this.removeLastButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.removeLastButton.Image = global::DSPRE.Properties.Resources.deleteIcon; + this.removeLastButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.removeLastButton.Location = new System.Drawing.Point(480, 292); + this.removeLastButton.Name = "removeLastButton"; + this.removeLastButton.Size = new System.Drawing.Size(126, 40); + this.removeLastButton.TabIndex = 14; + this.removeLastButton.Text = "Remove Last"; + this.removeLastButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.removeLastButton.UseVisualStyleBackColor = true; + this.removeLastButton.Click += new System.EventHandler(this.removeLastButton_Click); + // // TradeEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -684,6 +737,7 @@ this.Controls.Add(this.mainPanel); this.Name = "TradeEditor"; this.Text = "TradeEditor"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TradeEditor_FormClosing); this.mainPanel.ResumeLayout(false); this.textDataGroupBox.ResumeLayout(false); this.textDataGroupBox.PerformLayout(); @@ -774,7 +828,10 @@ private System.Windows.Forms.TextBox nicknameTextBox; private System.Windows.Forms.TextBox otNameTextBox; private System.Windows.Forms.Label nicknameLabel; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label otNameLabel; private System.Windows.Forms.Button saveTextDataButton; + private System.Windows.Forms.Button saveAllButton; + private System.Windows.Forms.Button addFileButton; + private System.Windows.Forms.Button removeLastButton; } } \ No newline at end of file diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index d6daef4..931c01b 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -17,6 +17,10 @@ namespace DSPRE.Editors private TradeData curTradeData; private TextArchive tradeArchive; + // Track if any changes have been made + private bool tradeDirty = false; + private bool textDirty = false; + #region Enums public enum OriginLang { @@ -40,6 +44,7 @@ namespace DSPRE.Editors InitLimits(); InitDataRanges(); SetToolTips(); + RegisterMarkDirtyHandlers(); if (TradeData.GetTradeCount() == 0) { @@ -53,78 +58,14 @@ namespace DSPRE.Editors unknownNumericUpDown.Enabled = false; } + // Disable buttons until trade expansion is implemented + addFileButton.Enabled = false; + removeLastButton.Enabled = false; + tradeArchive = new TextArchive(GetTextBankIndex()); LoadFromFile(0); } - public void LoadFromFile(int tradeID) - { - Helpers.DisableHandlers(); - curTradeData = new TradeData(tradeID); - tradeIDNumericUpDown.Value = tradeID; - speciesComboBox.SelectedIndex = curTradeData.species; - hpIVNumericUpDown.Value = curTradeData.hpIV; - atkIVNumericUpDown.Value = curTradeData.atkIV; - defIVNumericUpDown.Value = curTradeData.defIV; - speIVNumericUpDown.Value = curTradeData.speedIV; - spaIVNumericUpDown.Value = curTradeData.spAtkIV; - spdIVNumericUpDown.Value = curTradeData.spDefIV; - abilityComboBox.SelectedIndex = curTradeData.ability; - otIDNumericUpDown.Value = curTradeData.otID; - coolNumericUpDown.Value = curTradeData.cool; - beautyNumericUpDown.Value = curTradeData.beauty; - cuteNumericUpDown.Value = curTradeData.cute; - smartNumericUpDown.Value = curTradeData.smart; - toughNumericUpDown.Value = curTradeData.tough; - pidNumericUpDown.Value = curTradeData.pid; - heldItemComboBox.SelectedIndex = curTradeData.heldItem; - otGenderComboBox.SelectedIndex = curTradeData.otGender; - sheenNumericUpDown.Value = curTradeData.sheen; - langComboBox.SelectedIndex = curTradeData.language; - requestedComboBox.SelectedIndex = curTradeData.requestedSpecies; - unknownNumericUpDown.Value = curTradeData.unknown; - - otNameTextBox.Text = GetOTName(tradeID); - nicknameTextBox.Text = GetMonNickname(tradeID); - - Helpers.EnableHandlers(); - } - - private void SaveToFile() - { - curTradeData.species = speciesComboBox.SelectedIndex; - curTradeData.hpIV = (int)hpIVNumericUpDown.Value; - curTradeData.atkIV = (int)atkIVNumericUpDown.Value; - curTradeData.defIV = (int)defIVNumericUpDown.Value; - curTradeData.speedIV = (int)speIVNumericUpDown.Value; - curTradeData.spAtkIV = (int)spaIVNumericUpDown.Value; - curTradeData.spDefIV = (int)spdIVNumericUpDown.Value; - curTradeData.ability = abilityComboBox.SelectedIndex; - curTradeData.otID = (int)otIDNumericUpDown.Value; - curTradeData.cool = (int)coolNumericUpDown.Value; - curTradeData.beauty = (int)beautyNumericUpDown.Value; - curTradeData.cute = (int)cuteNumericUpDown.Value; - curTradeData.smart = (int)smartNumericUpDown.Value; - curTradeData.tough = (int)toughNumericUpDown.Value; - curTradeData.pid = (int)pidNumericUpDown.Value; - curTradeData.heldItem = heldItemComboBox.SelectedIndex; - curTradeData.otGender = otGenderComboBox.SelectedIndex; - curTradeData.sheen = (int)sheenNumericUpDown.Value; - curTradeData.language = langComboBox.SelectedIndex; - curTradeData.requestedSpecies = requestedComboBox.SelectedIndex; - - if (RomInfo.gameFamily == RomInfo.GameFamilies.HGSS) - { - curTradeData.unknown = (int)unknownNumericUpDown.Value; - } - else - { - curTradeData.unknown = 0; - } - - curTradeData.SaveToFileDefaultDir((int)tradeIDNumericUpDown.Value, true); - } - private void InitLimits() { // IVs: 0-31 @@ -167,7 +108,7 @@ namespace DSPRE.Editors // Trade ID: (dynamic based on loaded data) tradeIDNumericUpDown.Minimum = 0; - tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount()-1; + tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount() - 1; // OT ID: (32-bit unsigned) otIDNumericUpDown.Minimum = 0; @@ -191,7 +132,7 @@ namespace DSPRE.Editors heldItemComboBox.DataSource = RomInfo.GetItemNames(); // OT Gender - otGenderComboBox.DataSource = new string[] {"Male", "Female"}; + otGenderComboBox.DataSource = new string[] { "Male", "Female" }; // Languages langComboBox.DataSource = Enum.GetNames(typeof(OriginLang)); @@ -199,42 +140,143 @@ namespace DSPRE.Editors private void SetToolTips() { - toolTip.SetToolTip(tradeIDNumericUpDown, "The Trade ID to edit."); - toolTip.SetToolTip(speciesComboBox, "The species of the Pokémon being traded."); - toolTip.SetToolTip(IVGroupBox, "Individual Values (IVs)"); - toolTip.SetToolTip(abilityComboBox, "The ability of the Pokémon.\nThis value is unused!"); - toolTip.SetToolTip(otIDNumericUpDown, "The Original Trainer ID of the Pokémon."); - toolTip.SetToolTip(contestGroupBox, "Contest stats for the Pokémon."); - toolTip.SetToolTip(pidNumericUpDown, "The PID of the Pokémon."); - toolTip.SetToolTip(heldItemComboBox, "The held item of the Pokémon."); - toolTip.SetToolTip(otGenderComboBox, "The gender of the Original Trainer (OT).\nThe OT name is determined by the text bank."); - toolTip.SetToolTip(langComboBox, "The language of origin of the traded Pokémon."); - toolTip.SetToolTip(requestedComboBox, "The species of the requested Pokémon.\nWhether the Pokémon selected by the player matches this species or not is checked via scripting."); - toolTip.SetToolTip(unknownNumericUpDown, "An unknown value, present in HGSS only.\nAppears to be unused."); - + SetToolTipsForControls(new Control[] { tradeIDNumericUpDown, tradeIDLabel }, "The Trade ID to edit."); + SetToolTipsForControls(new Control[] { speciesComboBox, speciesLabel }, "The species of the Pokémon being traded."); + SetToolTipsForControls(new Control[] { IVGroupBox }, "Individual Values (IVs)"); + SetToolTipsForControls(new Control[] { abilityComboBox, abilityLabel }, "The ability of the Pokémon.\nThis value is unused and will have no effect!"); + SetToolTipsForControls(new Control[] { otIDNumericUpDown, otIDLabel }, "The Original Trainer ID of the Pokémon."); + SetToolTipsForControls(new Control[] { contestGroupBox }, "Contest stats for the Pokémon."); + SetToolTipsForControls(new Control[] { pidNumericUpDown, pidLabel }, "The PID of the Pokémon.\nDetermines ability and nature."); + SetToolTipsForControls(new Control[] { heldItemComboBox, heldItemLabel }, "The held item of the Pokémon."); + SetToolTipsForControls(new Control[] { otGenderComboBox, otGenderLabel }, "The gender of the Original Trainer (OT).\nThe OT name is determined by the text bank."); + SetToolTipsForControls(new Control[] { langComboBox, langLabel }, "The language of origin of the traded Pokémon."); + SetToolTipsForControls(new Control[] { requestedComboBox, requestedLabel }, "The species of the requested Pokémon.\nWhether the Pokémon selected by the player matches this species or not is checked via scripting."); + SetToolTipsForControls(new Control[] { unknownNumericUpDown, unknownLabel }, "An unknown value, present in HGSS only.\nAppears to be unused."); + SetToolTipsForControls(new Control[] { otNameTextBox, otNameLabel }, + $"The Original Trainer's name.\nStored in text bank {GetTextBankIndex()}.\nAt most {otNameTextBox.MaxLength} characters."); + SetToolTipsForControls(new Control[] { nicknameTextBox, nicknameLabel }, + $"The nickname of the Pokémon.\nStored in text bank {GetTextBankIndex()}.\nAt most {nicknameTextBox.MaxLength} characters."); } - private void tradeIDNumericUpDown_ValueChanged(object sender, EventArgs e) + private void SetToolTipsForControls(IEnumerable controls, string text) { - if (Helpers.HandlersDisabled) + foreach (var control in controls) { - return; + toolTip.SetToolTip(control, text); + } + } + + public void LoadFromFile(int tradeID) + { + Helpers.DisableHandlers(); + curTradeData = new TradeData(tradeID); + tradeIDNumericUpDown.Value = tradeID; + speciesComboBox.SelectedIndex = curTradeData.species; + hpIVNumericUpDown.Value = curTradeData.hpIV; + atkIVNumericUpDown.Value = curTradeData.atkIV; + defIVNumericUpDown.Value = curTradeData.defIV; + speIVNumericUpDown.Value = curTradeData.speedIV; + spaIVNumericUpDown.Value = curTradeData.spAtkIV; + spdIVNumericUpDown.Value = curTradeData.spDefIV; + abilityComboBox.SelectedIndex = curTradeData.ability; + otIDNumericUpDown.Value = curTradeData.otID; + coolNumericUpDown.Value = curTradeData.cool; + beautyNumericUpDown.Value = curTradeData.beauty; + cuteNumericUpDown.Value = curTradeData.cute; + smartNumericUpDown.Value = curTradeData.smart; + toughNumericUpDown.Value = curTradeData.tough; + pidNumericUpDown.Value = curTradeData.pid; + heldItemComboBox.SelectedIndex = curTradeData.heldItem; + otGenderComboBox.SelectedIndex = curTradeData.otGender; + sheenNumericUpDown.Value = curTradeData.sheen; + langComboBox.SelectedIndex = curTradeData.language; + requestedComboBox.SelectedIndex = curTradeData.requestedSpecies; + unknownNumericUpDown.Value = curTradeData.unknown; + + otNameTextBox.Text = GetOTName(tradeID); + nicknameTextBox.Text = GetMonNickname(tradeID); + tradeDataGroupBox.Text = "Trade Data"; + textDataGroupBox.Text = "Text Data"; + this.Text = "Trade Editor"; + + tradeDirty = false; + textDirty = false; + + Helpers.EnableHandlers(); + } + + private void SaveTradeToFile() + { + Helpers.DisableHandlers(); + curTradeData.species = speciesComboBox.SelectedIndex; + curTradeData.hpIV = (int)hpIVNumericUpDown.Value; + curTradeData.atkIV = (int)atkIVNumericUpDown.Value; + curTradeData.defIV = (int)defIVNumericUpDown.Value; + curTradeData.speedIV = (int)speIVNumericUpDown.Value; + curTradeData.spAtkIV = (int)spaIVNumericUpDown.Value; + curTradeData.spDefIV = (int)spdIVNumericUpDown.Value; + curTradeData.ability = abilityComboBox.SelectedIndex; + curTradeData.otID = (int)otIDNumericUpDown.Value; + curTradeData.cool = (int)coolNumericUpDown.Value; + curTradeData.beauty = (int)beautyNumericUpDown.Value; + curTradeData.cute = (int)cuteNumericUpDown.Value; + curTradeData.smart = (int)smartNumericUpDown.Value; + curTradeData.tough = (int)toughNumericUpDown.Value; + curTradeData.pid = (int)pidNumericUpDown.Value; + curTradeData.heldItem = heldItemComboBox.SelectedIndex; + curTradeData.otGender = otGenderComboBox.SelectedIndex; + curTradeData.sheen = (int)sheenNumericUpDown.Value; + curTradeData.language = langComboBox.SelectedIndex; + curTradeData.requestedSpecies = requestedComboBox.SelectedIndex; + + if (RomInfo.gameFamily == RomInfo.GameFamilies.HGSS) + { + curTradeData.unknown = (int)unknownNumericUpDown.Value; + } + else + { + curTradeData.unknown = 0; } + curTradeData.SaveToFileDefaultDir((int)tradeIDNumericUpDown.Value, false); + tradeDataGroupBox.Text = "Trade Data"; + tradeDirty = false; + if (!textDirty) + { + this.Text = "Trade Editor"; + } + Helpers.EnableHandlers(); + } + + private void SaveTextDataToFile() + { + Helpers.DisableHandlers(); int tradeID = (int)tradeIDNumericUpDown.Value; - if (tradeID < 0 || tradeID >= TradeData.GetTradeCount()) + + if (tradeID < 0 || tradeID + TradeData.GetTradeCount() > tradeArchive.messages.Count) { - MessageBox.Show("Invalid Trade ID selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Can't save to text bank. Index is out of range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error("TradeEditor: Can't save to text bank. Index is out of range."); + Helpers.EnableHandlers(); return; } - LoadFromFile(tradeID); + // Nickname + tradeArchive.messages[tradeID] = nicknameTextBox.Text; - } + // OT Name + tradeArchive.messages[tradeID + TradeData.GetTradeCount()] = otNameTextBox.Text; - private void saveTradeButton_Click(object sender, EventArgs e) - { - SaveToFile(); + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + + // Reset the text data group box and dirty flags + textDataGroupBox.Text = "Text Data"; + textDirty = false; + if (!tradeDirty) + { + this.Text = "Trade Editor"; + } + Helpers.EnableHandlers(); } private int GetTextBankIndex() @@ -270,7 +312,7 @@ namespace DSPRE.Editors MessageBox.Show("Invalid game family for text bank index retrieval.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return 0; } - + } private string GetMonNickname(int tradeID) { @@ -291,29 +333,149 @@ namespace DSPRE.Editors msg = msg.Substring(0, otNameTextBox.MaxLength); } return msg; - } + } - private void saveTextDataButton_Click(object sender, EventArgs e) + private void RegisterMarkDirtyHandlers() { - Helpers.DisableHandlers(); - int tradeID = (int)tradeIDNumericUpDown.Value; + // ComboBoxes + speciesComboBox.SelectedIndexChanged += MarkDirty; + abilityComboBox.SelectedIndexChanged += MarkDirty; + heldItemComboBox.SelectedIndexChanged += MarkDirty; + otGenderComboBox.SelectedIndexChanged += MarkDirty; + langComboBox.SelectedIndexChanged += MarkDirty; + requestedComboBox.SelectedIndexChanged += MarkDirty; - if (tradeID < 0 || tradeID + TradeData.GetTradeCount() > tradeArchive.messages.Count) + // NumericUpDowns + hpIVNumericUpDown.ValueChanged += MarkDirty; + atkIVNumericUpDown.ValueChanged += MarkDirty; + defIVNumericUpDown.ValueChanged += MarkDirty; + speIVNumericUpDown.ValueChanged += MarkDirty; + spaIVNumericUpDown.ValueChanged += MarkDirty; + spdIVNumericUpDown.ValueChanged += MarkDirty; + otIDNumericUpDown.ValueChanged += MarkDirty; + coolNumericUpDown.ValueChanged += MarkDirty; + beautyNumericUpDown.ValueChanged += MarkDirty; + cuteNumericUpDown.ValueChanged += MarkDirty; + smartNumericUpDown.ValueChanged += MarkDirty; + toughNumericUpDown.ValueChanged += MarkDirty; + pidNumericUpDown.ValueChanged += MarkDirty; + sheenNumericUpDown.ValueChanged += MarkDirty; + unknownNumericUpDown.ValueChanged += MarkDirty; + + // TextBoxes + otNameTextBox.TextChanged += MarkDirty; + nicknameTextBox.TextChanged += MarkDirty; + } + + #region Handlers + + private void MarkDirty(object sender, EventArgs e) + { + if (Helpers.HandlersDisabled) { - MessageBox.Show("Can't save to text bank. Index is out of range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - AppLogger.Error("TradeEditor: Can't save to text bank. Index is out of range."); - Helpers.EnableHandlers(); return; } - // Nickname - tradeArchive.messages[tradeID] = nicknameTextBox.Text; + Helpers.DisableHandlers(); - // OT Name - tradeArchive.messages[tradeID + TradeData.GetTradeCount()] = otNameTextBox.Text; + if (sender.Equals(otNameTextBox) || sender.Equals(nicknameTextBox)) + { + textDataGroupBox.Text = "Text Data*"; + this.Text = "Trade Editor*"; + textDirty = true; + } + else + { + tradeDataGroupBox.Text = "Trade Data*"; + this.Text = "Trade Editor*"; + tradeDirty = true; + } - tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); Helpers.EnableHandlers(); } + + private void tradeIDNumericUpDown_ValueChanged(object sender, EventArgs e) + { + if (Helpers.HandlersDisabled) + { + return; + } + + Helpers.DisableHandlers(); + + if (tradeDirty || textDirty) + { + DialogResult result = MessageBox.Show("You have unsaved changes. Do you want to save before changing the Trade ID?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + if (result == DialogResult.Yes) + { + SaveTradeToFile(); + SaveTextDataToFile(); + } + else if (result == DialogResult.Cancel) + { + // Revert the change + tradeIDNumericUpDown.Value = curTradeData.id; + Helpers.EnableHandlers(); + return; + } + } + + int tradeID = (int)tradeIDNumericUpDown.Value; + if (tradeID < 0 || tradeID >= TradeData.GetTradeCount()) + { + MessageBox.Show("Invalid Trade ID selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + LoadFromFile(tradeID); + + Helpers.EnableHandlers(); + + } + + private void saveTradeButton_Click(object sender, EventArgs e) + { + SaveTradeToFile(); + } + + private void saveTextDataButton_Click(object sender, EventArgs e) + { + SaveTextDataToFile(); + } + + private void saveAllButton_Click(object sender, EventArgs e) + { + SaveTradeToFile(); + SaveTextDataToFile(); + } + + private void TradeEditor_FormClosing(object sender, FormClosingEventArgs e) + { + if (tradeDirty || textDirty) + { + DialogResult result = MessageBox.Show("You have unsaved changes. Do you want to save before closing?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + if (result == DialogResult.Yes) + { + SaveTradeToFile(); + SaveTextDataToFile(); + } + else if (result == DialogResult.Cancel) + { + e.Cancel = true; // Cancel the closing + } + } + } + + #endregion + + private void addFileButton_Click(object sender, EventArgs e) + { + + } + + private void removeLastButton_Click(object sender, EventArgs e) + { + + } } } From 97377cfd244feaa9001b61aca655dcff78ba3501 Mon Sep 17 00:00:00 2001 From: Yako Date: Fri, 25 Jul 2025 16:50:22 +0200 Subject: [PATCH 05/11] add logic for adding / removing files and fix issues with plat USA using the wrong path to the narc --- DS_Map/Editors/TradeEditor.cs | 57 ++++++++++++++++++++++++++++++++--- DS_Map/ROMFiles/TradeData.cs | 24 +++++++++++++-- DS_Map/RomInfo.cs | 2 +- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 931c01b..13b0e98 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -58,9 +59,11 @@ namespace DSPRE.Editors unknownNumericUpDown.Enabled = false; } + // PLAT: Overlay 6, 0x8050-0x8053: dc f5 f0 fb -> 00 00 00 00 to dummy out ASSERT + // Disable buttons until trade expansion is implemented - addFileButton.Enabled = false; - removeLastButton.Enabled = false; + //addFileButton.Enabled = false; + //removeLastButton.Enabled = false; tradeArchive = new TextArchive(GetTextBankIndex()); LoadFromFile(0); @@ -170,6 +173,7 @@ namespace DSPRE.Editors { Helpers.DisableHandlers(); curTradeData = new TradeData(tradeID); + tradeArchive = new TextArchive(GetTextBankIndex()); tradeIDNumericUpDown.Value = tradeID; speciesComboBox.SelectedIndex = curTradeData.species; hpIVNumericUpDown.Value = curTradeData.hpIV; @@ -466,16 +470,61 @@ namespace DSPRE.Editors } } - #endregion - private void addFileButton_Click(object sender, EventArgs e) { + TradeData newTrade = new TradeData(TradeData.GetTradeCount()); + newTrade.SaveToFileDefaultDir(newTrade.id, false); + tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount() - 1; // Update the maximum value + // Adjust text archive to accommodate the new trade + int lastNicknameIndex = TradeData.GetTradeCount() - 1; + tradeArchive.messages.Insert(lastNicknameIndex, "Nickname"); + tradeArchive.messages.Add("OT Name"); + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + + MessageBox.Show($"Added new trade with id {newTrade.id}", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void removeLastButton_Click(object sender, EventArgs e) { + DialogResult result = MessageBox.Show("Are you sure you want to remove the last trade? This action cannot be undone.", "Confirm Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (result != DialogResult.Yes) + { + return; // User cancelled the removal + } + + if (TradeData.GetTradeCount() <= 1) + { + MessageBox.Show("Cannot remove the last trade.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + int lastTradeID = TradeData.GetTradeCount() - 1; + + try + { + File.Delete(RomInfo.gameDirs[RomInfo.DirNames.tradeData].unpackedDir + "\\" + lastTradeID.ToString("D4")); + } + catch (Exception ex) + { + MessageBox.Show($"Failed to delete trade file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error($"TradeEditor: Failed to delete trade file for ID {lastTradeID}: {ex.Message}"); + return; + } + + tradeIDNumericUpDown.Maximum = lastTradeID - 1; // Update the maximum value + // Adjust text archive to remove the last trade's text + + if (tradeArchive.messages.Count > lastTradeID) + { + tradeArchive.messages.RemoveAt(lastTradeID); // Remove Nickname + tradeArchive.messages.RemoveAt(tradeArchive.messages.Count - 1); // Remove OT Name + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + } } + + #endregion + } } diff --git a/DS_Map/ROMFiles/TradeData.cs b/DS_Map/ROMFiles/TradeData.cs index 4091eb9..d6ec594 100644 --- a/DS_Map/ROMFiles/TradeData.cs +++ b/DS_Map/ROMFiles/TradeData.cs @@ -36,7 +36,7 @@ namespace DSPRE.ROMFiles public int requestedSpecies; public int unknown; // unused? - public TradeData(Stream stream, int id) + public TradeData(int id, Stream stream) { this.id = id; using (BinaryReader br = new BinaryReader(stream)) @@ -70,7 +70,27 @@ namespace DSPRE.ROMFiles } } - public TradeData(int id) : this(new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Open), id) { } + public TradeData(int id) : this(id, GetStream(id)) { } + + private static Stream GetStream(int id) + { + + if (!File.Exists(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"))) + { + // If the file does not exist, create it with default values + FileStream fileStream = new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Create); + fileStream.Write(new byte[0x50], 0, 0x50); // create an empty file + if (RomInfo.gameFamily == GameFamilies.HGSS) + { + fileStream.Write(new byte[0x04], 0, 0x04); // HGSS only + } + fileStream.Seek(0, SeekOrigin.Begin); // Reset the position to the start of the file + return fileStream; + } + + return new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Open); + + } public override byte[] ToByteArray() { diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 02c653b..2457184 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -1539,7 +1539,7 @@ namespace DSPRE [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; - if (gameLanguage != GameLanguages.Japanese) + if (gameLanguage != GameLanguages.Japanese && gameLanguage != GameLanguages.English) { packedDirsDict[DirNames.tradeData] = $@"data\resource\{GetLangResFolderName()}\pokemon_trade\fld_trade.narc"; } From 52e632407119ca03b6305ce5f1423476928ddb32 Mon Sep 17 00:00:00 2001 From: Yako Date: Wed, 23 Jul 2025 23:42:10 +0200 Subject: [PATCH 06/11] create trade data --- DS_Map/DSPRE.csproj | 7 ++ DS_Map/Editors/TradeEditor.Designer.cs | 39 +++++++++ DS_Map/Editors/TradeEditor.cs | 20 +++++ DS_Map/ROMFiles/TradeData.cs | 115 +++++++++++++++++++++++++ DS_Map/RomInfo.cs | 13 ++- 5 files changed, 191 insertions(+), 3 deletions(-) create mode 100644 DS_Map/Editors/TradeEditor.Designer.cs create mode 100644 DS_Map/Editors/TradeEditor.cs create mode 100644 DS_Map/ROMFiles/TradeData.cs diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj index b6c1915..2ab79af 100644 --- a/DS_Map/DSPRE.csproj +++ b/DS_Map/DSPRE.csproj @@ -230,6 +230,12 @@ TextEditor.cs + + Form + + + TradeEditor.cs + UserControl @@ -346,6 +352,7 @@ + diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs new file mode 100644 index 0000000..59fbe5c --- /dev/null +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -0,0 +1,39 @@ +namespace DSPRE.Editors +{ + partial class TradeEditor + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Text = "TradeEditor"; + } + + #endregion + } +} \ No newline at end of file diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs new file mode 100644 index 0000000..79794b3 --- /dev/null +++ b/DS_Map/Editors/TradeEditor.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace DSPRE.Editors +{ + public partial class TradeEditor : Form + { + public TradeEditor() + { + InitializeComponent(); + } + } +} diff --git a/DS_Map/ROMFiles/TradeData.cs b/DS_Map/ROMFiles/TradeData.cs new file mode 100644 index 0000000..267d709 --- /dev/null +++ b/DS_Map/ROMFiles/TradeData.cs @@ -0,0 +1,115 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static DSPRE.RomInfo; + +namespace DSPRE.ROMFiles +{ + internal class TradeData : RomFile + { + + public int id; + + // TradeData structure in narc + public int species; + public int hpIV; + public int atkIV; + public int defIV; + public int speedIV; + public int spAtkIV; + public int spDefIV; + public int ability; // unused + public int otID; + public int cool; + public int beauty; + public int cute; + public int smart; + public int tough; + public int pid; + public int heldItem; + public int otGender; + public int sheen; + public int language; + public int requestedSpecies; + public int unknown; // unused? + + public TradeData(Stream stream, int id) + { + this.id = id; + using (BinaryReader br = new BinaryReader(stream)) + { + species = br.ReadInt32(); + hpIV = br.ReadInt32(); + atkIV = br.ReadInt32(); + defIV = br.ReadInt32(); + speedIV = br.ReadInt32(); + spAtkIV = br.ReadInt32(); + spDefIV = br.ReadInt32(); + ability = br.ReadInt32(); // unused + otID = br.ReadInt32(); + cool = br.ReadInt32(); + beauty = br.ReadInt32(); + cute = br.ReadInt32(); + smart = br.ReadInt32(); + tough = br.ReadInt32(); + pid = br.ReadInt32(); + heldItem = br.ReadInt32(); + otGender = br.ReadInt32(); + sheen = br.ReadInt32(); + language = br.ReadInt32(); + requestedSpecies = br.ReadInt32(); + unknown = br.ReadInt32(); // unused? + } + } + + public TradeData(int id) : this(new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Open), id) { } + + public override byte[] ToByteArray() + { + using (MemoryStream ms = new MemoryStream()) + using (BinaryWriter bw = new BinaryWriter(ms)) + { + bw.Write(species); + bw.Write(hpIV); + bw.Write(atkIV); + bw.Write(defIV); + bw.Write(speedIV); + bw.Write(spAtkIV); + bw.Write(spDefIV); + bw.Write(ability); // unused + bw.Write(otID); + bw.Write(cool); + bw.Write(beauty); + bw.Write(cute); + bw.Write(smart); + bw.Write(tough); + bw.Write(pid); + bw.Write(heldItem); + bw.Write(otGender); + bw.Write(sheen); + bw.Write(language); + bw.Write(requestedSpecies); + + if (RomInfo.gameFamily == GameFamilies.HGSS) + { + bw.Write(unknown); // HGSS only + } + + return ms.ToArray(); + } + } + + public void SaveToFileDefaultDir(int IDtoReplace, bool showSuccessMessage = true) + { + SaveToFileDefaultDir(DirNames.tradeData, IDtoReplace, showSuccessMessage); + } + public void SaveToFileExplorePath(string suggestedFileName, bool showSuccessMessage = true) + { + SaveToFileExplorePath("Gen IV Trade data", "bin", suggestedFileName, showSuccessMessage); + } + + } +} diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index bc104bd..55c3dc2 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -175,7 +175,9 @@ namespace DSPRE evolutions, itemData, - itemIcons + itemIcons, + + tradeData }; public static Dictionary gameDirs { get; private set; } @@ -1470,7 +1472,9 @@ namespace DSPRE [DirNames.otherPokemonBattleSprites] = @"data\poketool\pokegra\otherpoke.narc", [DirNames.itemData] = @"data\itemtool\itemdata\item_data.narc", - [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc" + [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc", + + [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; //Personal Data archive is different for Pearl @@ -1525,7 +1529,9 @@ namespace DSPRE [DirNames.evolutions] = @"data\poketool\personal\evo.narc", [DirNames.itemData] = @"data\itemtool\itemdata\pl_item_data.narc", - [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc" + [DirNames.itemIcons] = @"data\itemtool\itemdata\item_icon.narc", + + [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; break; @@ -1567,6 +1573,7 @@ namespace DSPRE [DirNames.evolutions] = @"data\a\0\3\4", [DirNames.itemData] = @"data\a\0\1\7", [DirNames.itemIcons] = @"data\a\0\1\8", + [DirNames.tradeData] = @"data\a\1\1\2", [DirNames.safariZone] = @"data\a\2\3\0", [DirNames.headbutt] = @"data\a\2\5\2", //both versions use the same folder with different data From cb4814bcdf074ce0e23a1ecc5dd6a3cde8dd062c Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 18:47:23 +0200 Subject: [PATCH 07/11] this should be fully functional now --- DS_Map/DSPRE.csproj | 3 + DS_Map/Editors/TextEditor.Designer.cs | 1 + DS_Map/Editors/TradeEditor.Designer.cs | 743 ++++++++++++++++++++++++- DS_Map/Editors/TradeEditor.cs | 301 +++++++++- DS_Map/Editors/TradeEditor.resx | 123 ++++ DS_Map/Main Window.Designer.cs | 12 +- DS_Map/Main Window.cs | 8 + DS_Map/ROMFiles/TradeData.cs | 14 +- DS_Map/RomInfo.cs | 30 + 9 files changed, 1230 insertions(+), 5 deletions(-) create mode 100644 DS_Map/Editors/TradeEditor.resx diff --git a/DS_Map/DSPRE.csproj b/DS_Map/DSPRE.csproj index 2ab79af..8765a2b 100644 --- a/DS_Map/DSPRE.csproj +++ b/DS_Map/DSPRE.csproj @@ -531,6 +531,9 @@ TextEditor.cs + + TradeEditor.cs + TrainerEditor.cs diff --git a/DS_Map/Editors/TextEditor.Designer.cs b/DS_Map/Editors/TextEditor.Designer.cs index 6f45fbb..a360188 100644 --- a/DS_Map/Editors/TextEditor.Designer.cs +++ b/DS_Map/Editors/TextEditor.Designer.cs @@ -331,6 +331,7 @@ this.textSearchResultsListBox.Size = new System.Drawing.Size(267, 244); this.textSearchResultsListBox.TabIndex = 38; this.textSearchResultsListBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textSearchResultsListBox_KeyDown); + this.textSearchResultsListBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.textSearchResultsListBox_GoToEntryResult); // // replaceTextLabel // diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs index 59fbe5c..645291b 100644 --- a/DS_Map/Editors/TradeEditor.Designer.cs +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -29,11 +29,752 @@ private void InitializeComponent() { this.components = new System.ComponentModel.Container(); + this.mainPanel = new System.Windows.Forms.Panel(); + this.saveTextDataButton = new System.Windows.Forms.Button(); + this.saveTradeButton = new System.Windows.Forms.Button(); + this.textDataGroupBox = new System.Windows.Forms.GroupBox(); + this.nicknameTextBox = new System.Windows.Forms.TextBox(); + this.otNameTextBox = new System.Windows.Forms.TextBox(); + this.nicknameLabel = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.tradeDataGroupBox = new System.Windows.Forms.GroupBox(); + this.requestedComboBox = new System.Windows.Forms.ComboBox(); + this.requestedLabel = new System.Windows.Forms.Label(); + this.otGenderComboBox = new System.Windows.Forms.ComboBox(); + this.otGenderLabel = new System.Windows.Forms.Label(); + this.otIDNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.otIDLabel = new System.Windows.Forms.Label(); + this.monDataGroupBox = new System.Windows.Forms.GroupBox(); + this.monDataPanel = new System.Windows.Forms.Panel(); + this.abilityComboBox = new System.Windows.Forms.ComboBox(); + this.abilityLabel = new System.Windows.Forms.Label(); + this.unknownNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.unknownLabel = new System.Windows.Forms.Label(); + this.pidNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.pidLabel = new System.Windows.Forms.Label(); + this.langComboBox = new System.Windows.Forms.ComboBox(); + this.langLabel = new System.Windows.Forms.Label(); + this.heldItemComboBox = new System.Windows.Forms.ComboBox(); + this.heldItemLabel = new System.Windows.Forms.Label(); + this.contestGroupBox = new System.Windows.Forms.GroupBox(); + this.toughNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.smartNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.cuteNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.beautyNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.coolNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.sheenNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.toughLabel = new System.Windows.Forms.Label(); + this.smartLabel = new System.Windows.Forms.Label(); + this.cuteLabel = new System.Windows.Forms.Label(); + this.beautyLabel = new System.Windows.Forms.Label(); + this.coolLabel = new System.Windows.Forms.Label(); + this.sheenLabel = new System.Windows.Forms.Label(); + this.IVGroupBox = new System.Windows.Forms.GroupBox(); + this.speIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.spdIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.spaIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.defIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.atkIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.hpIVNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.speIVLabel = new System.Windows.Forms.Label(); + this.spdIVLabel = new System.Windows.Forms.Label(); + this.spaIVLabel = new System.Windows.Forms.Label(); + this.defIVLabel = new System.Windows.Forms.Label(); + this.atkIVLabel = new System.Windows.Forms.Label(); + this.hpIVLabel = new System.Windows.Forms.Label(); + this.speciesComboBox = new System.Windows.Forms.ComboBox(); + this.speciesLabel = new System.Windows.Forms.Label(); + this.tradeIDNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.tradeIDLabel = new System.Windows.Forms.Label(); + this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.mainPanel.SuspendLayout(); + this.textDataGroupBox.SuspendLayout(); + this.tradeDataGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.otIDNumericUpDown)).BeginInit(); + this.monDataGroupBox.SuspendLayout(); + this.monDataPanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.unknownNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pidNumericUpDown)).BeginInit(); + this.contestGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.toughNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.smartNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.cuteNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.beautyNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.coolNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.sheenNumericUpDown)).BeginInit(); + this.IVGroupBox.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.speIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.spdIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.spaIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.defIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.atkIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.hpIVNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.tradeIDNumericUpDown)).BeginInit(); + this.SuspendLayout(); + // + // mainPanel + // + this.mainPanel.Controls.Add(this.saveTextDataButton); + this.mainPanel.Controls.Add(this.saveTradeButton); + this.mainPanel.Controls.Add(this.textDataGroupBox); + this.mainPanel.Controls.Add(this.tradeDataGroupBox); + this.mainPanel.Location = new System.Drawing.Point(12, 12); + this.mainPanel.Name = "mainPanel"; + this.mainPanel.Size = new System.Drawing.Size(624, 444); + this.mainPanel.TabIndex = 0; + // + // saveTextDataButton + // + this.saveTextDataButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveTextDataButton.Image = global::DSPRE.Properties.Resources.saveButton; + this.saveTextDataButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; + this.saveTextDataButton.Location = new System.Drawing.Point(479, 156); + this.saveTextDataButton.Name = "saveTextDataButton"; + this.saveTextDataButton.Size = new System.Drawing.Size(126, 44); + this.saveTextDataButton.TabIndex = 5; + this.saveTextDataButton.Text = "Save Text Data"; + this.saveTextDataButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.saveTextDataButton.UseVisualStyleBackColor = true; + this.saveTextDataButton.Click += new System.EventHandler(this.saveTextDataButton_Click); + // + // saveTradeButton + // + this.saveTradeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveTradeButton.Image = global::DSPRE.Properties.Resources.saveButton; + this.saveTradeButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.saveTradeButton.Location = new System.Drawing.Point(470, 383); + this.saveTradeButton.Name = "saveTradeButton"; + this.saveTradeButton.Size = new System.Drawing.Size(147, 47); + this.saveTradeButton.TabIndex = 4; + this.saveTradeButton.Text = "Save Trade Data"; + this.saveTradeButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.saveTradeButton.UseVisualStyleBackColor = true; + this.saveTradeButton.Click += new System.EventHandler(this.saveTradeButton_Click); + // + // textDataGroupBox + // + this.textDataGroupBox.Controls.Add(this.nicknameTextBox); + this.textDataGroupBox.Controls.Add(this.otNameTextBox); + this.textDataGroupBox.Controls.Add(this.nicknameLabel); + this.textDataGroupBox.Controls.Add(this.label1); + this.textDataGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.textDataGroupBox.Location = new System.Drawing.Point(470, 3); + this.textDataGroupBox.Name = "textDataGroupBox"; + this.textDataGroupBox.Size = new System.Drawing.Size(147, 147); + this.textDataGroupBox.TabIndex = 3; + this.textDataGroupBox.TabStop = false; + this.textDataGroupBox.Text = "Text Data"; + // + // nicknameTextBox + // + this.nicknameTextBox.Location = new System.Drawing.Point(9, 100); + this.nicknameTextBox.Name = "nicknameTextBox"; + this.nicknameTextBox.Size = new System.Drawing.Size(126, 22); + this.nicknameTextBox.TabIndex = 17; + // + // otNameTextBox + // + this.otNameTextBox.Location = new System.Drawing.Point(9, 46); + this.otNameTextBox.Name = "otNameTextBox"; + this.otNameTextBox.Size = new System.Drawing.Size(126, 22); + this.otNameTextBox.TabIndex = 16; + // + // nicknameLabel + // + this.nicknameLabel.AutoSize = true; + this.nicknameLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.nicknameLabel.Location = new System.Drawing.Point(6, 79); + this.nicknameLabel.Name = "nicknameLabel"; + this.nicknameLabel.Size = new System.Drawing.Size(129, 16); + this.nicknameLabel.TabIndex = 15; + this.nicknameLabel.Text = "Pokémon Nickname"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.label1.Location = new System.Drawing.Point(6, 25); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(66, 16); + this.label1.TabIndex = 13; + this.label1.Text = "OT Name"; + // + // tradeDataGroupBox + // + this.tradeDataGroupBox.Controls.Add(this.requestedComboBox); + this.tradeDataGroupBox.Controls.Add(this.requestedLabel); + this.tradeDataGroupBox.Controls.Add(this.otGenderComboBox); + this.tradeDataGroupBox.Controls.Add(this.otGenderLabel); + this.tradeDataGroupBox.Controls.Add(this.otIDNumericUpDown); + this.tradeDataGroupBox.Controls.Add(this.otIDLabel); + this.tradeDataGroupBox.Controls.Add(this.monDataGroupBox); + this.tradeDataGroupBox.Controls.Add(this.tradeIDNumericUpDown); + this.tradeDataGroupBox.Controls.Add(this.tradeIDLabel); + this.tradeDataGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tradeDataGroupBox.Location = new System.Drawing.Point(3, 3); + this.tradeDataGroupBox.Name = "tradeDataGroupBox"; + this.tradeDataGroupBox.Size = new System.Drawing.Size(461, 437); + this.tradeDataGroupBox.TabIndex = 2; + this.tradeDataGroupBox.TabStop = false; + this.tradeDataGroupBox.Text = "Trade Data"; + // + // requestedComboBox + // + this.requestedComboBox.FormattingEnabled = true; + this.requestedComboBox.Location = new System.Drawing.Point(165, 44); + this.requestedComboBox.Name = "requestedComboBox"; + this.requestedComboBox.Size = new System.Drawing.Size(150, 24); + this.requestedComboBox.TabIndex = 12; + // + // requestedLabel + // + this.requestedLabel.AutoSize = true; + this.requestedLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.requestedLabel.Location = new System.Drawing.Point(162, 25); + this.requestedLabel.Name = "requestedLabel"; + this.requestedLabel.Size = new System.Drawing.Size(135, 16); + this.requestedLabel.TabIndex = 11; + this.requestedLabel.Text = "Requested Pokémon"; + // + // otGenderComboBox + // + this.otGenderComboBox.FormattingEnabled = true; + this.otGenderComboBox.Location = new System.Drawing.Point(165, 98); + this.otGenderComboBox.Name = "otGenderComboBox"; + this.otGenderComboBox.Size = new System.Drawing.Size(150, 24); + this.otGenderComboBox.TabIndex = 10; + // + // otGenderLabel + // + this.otGenderLabel.AutoSize = true; + this.otGenderLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otGenderLabel.Location = new System.Drawing.Point(162, 79); + this.otGenderLabel.Name = "otGenderLabel"; + this.otGenderLabel.Size = new System.Drawing.Size(74, 16); + this.otGenderLabel.TabIndex = 9; + this.otGenderLabel.Text = "OT Gender"; + // + // otIDNumericUpDown + // + this.otIDNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otIDNumericUpDown.Location = new System.Drawing.Point(21, 98); + this.otIDNumericUpDown.Name = "otIDNumericUpDown"; + this.otIDNumericUpDown.Size = new System.Drawing.Size(120, 22); + this.otIDNumericUpDown.TabIndex = 6; + // + // otIDLabel + // + this.otIDLabel.AutoSize = true; + this.otIDLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otIDLabel.Location = new System.Drawing.Point(18, 79); + this.otIDLabel.Name = "otIDLabel"; + this.otIDLabel.Size = new System.Drawing.Size(42, 16); + this.otIDLabel.TabIndex = 7; + this.otIDLabel.Text = "OT ID"; + // + // monDataGroupBox + // + this.monDataGroupBox.Controls.Add(this.monDataPanel); + this.monDataGroupBox.Location = new System.Drawing.Point(9, 139); + this.monDataGroupBox.Name = "monDataGroupBox"; + this.monDataGroupBox.Size = new System.Drawing.Size(441, 288); + this.monDataGroupBox.TabIndex = 5; + this.monDataGroupBox.TabStop = false; + this.monDataGroupBox.Text = "Pokémon Data"; + // + // monDataPanel + // + this.monDataPanel.Controls.Add(this.abilityComboBox); + this.monDataPanel.Controls.Add(this.abilityLabel); + this.monDataPanel.Controls.Add(this.unknownNumericUpDown); + this.monDataPanel.Controls.Add(this.unknownLabel); + this.monDataPanel.Controls.Add(this.pidNumericUpDown); + this.monDataPanel.Controls.Add(this.pidLabel); + this.monDataPanel.Controls.Add(this.langComboBox); + this.monDataPanel.Controls.Add(this.langLabel); + this.monDataPanel.Controls.Add(this.heldItemComboBox); + this.monDataPanel.Controls.Add(this.heldItemLabel); + this.monDataPanel.Controls.Add(this.contestGroupBox); + this.monDataPanel.Controls.Add(this.IVGroupBox); + this.monDataPanel.Controls.Add(this.speciesComboBox); + this.monDataPanel.Controls.Add(this.speciesLabel); + this.monDataPanel.Location = new System.Drawing.Point(6, 21); + this.monDataPanel.Name = "monDataPanel"; + this.monDataPanel.Size = new System.Drawing.Size(418, 257); + this.monDataPanel.TabIndex = 4; + // + // abilityComboBox + // + this.abilityComboBox.FormattingEnabled = true; + this.abilityComboBox.Location = new System.Drawing.Point(6, 218); + this.abilityComboBox.Name = "abilityComboBox"; + this.abilityComboBox.Size = new System.Drawing.Size(147, 24); + this.abilityComboBox.TabIndex = 26; + // + // abilityLabel + // + this.abilityLabel.AutoSize = true; + this.abilityLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.abilityLabel.Location = new System.Drawing.Point(3, 198); + this.abilityLabel.Name = "abilityLabel"; + this.abilityLabel.Size = new System.Drawing.Size(43, 16); + this.abilityLabel.TabIndex = 27; + this.abilityLabel.Text = "Ability"; + // + // unknownNumericUpDown + // + this.unknownNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.unknownNumericUpDown.Location = new System.Drawing.Point(294, 220); + this.unknownNumericUpDown.Name = "unknownNumericUpDown"; + this.unknownNumericUpDown.Size = new System.Drawing.Size(111, 22); + this.unknownNumericUpDown.TabIndex = 24; + // + // unknownLabel + // + this.unknownLabel.AutoSize = true; + this.unknownLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.unknownLabel.Location = new System.Drawing.Point(291, 201); + this.unknownLabel.Name = "unknownLabel"; + this.unknownLabel.Size = new System.Drawing.Size(100, 16); + this.unknownLabel.TabIndex = 25; + this.unknownLabel.Text = "Unknown Value"; + // + // pidNumericUpDown + // + this.pidNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.pidNumericUpDown.Location = new System.Drawing.Point(169, 220); + this.pidNumericUpDown.Name = "pidNumericUpDown"; + this.pidNumericUpDown.Size = new System.Drawing.Size(111, 22); + this.pidNumericUpDown.TabIndex = 11; + // + // pidLabel + // + this.pidLabel.AutoSize = true; + this.pidLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.pidLabel.Location = new System.Drawing.Point(166, 201); + this.pidLabel.Name = "pidLabel"; + this.pidLabel.Size = new System.Drawing.Size(29, 16); + this.pidLabel.TabIndex = 23; + this.pidLabel.Text = "PID"; + // + // langComboBox + // + this.langComboBox.FormattingEnabled = true; + this.langComboBox.Location = new System.Drawing.Point(6, 166); + this.langComboBox.Name = "langComboBox"; + this.langComboBox.Size = new System.Drawing.Size(147, 24); + this.langComboBox.TabIndex = 20; + // + // langLabel + // + this.langLabel.AutoSize = true; + this.langLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.langLabel.Location = new System.Drawing.Point(3, 146); + this.langLabel.Name = "langLabel"; + this.langLabel.Size = new System.Drawing.Size(106, 16); + this.langLabel.TabIndex = 21; + this.langLabel.Text = "Origin Language"; + // + // heldItemComboBox + // + this.heldItemComboBox.FormattingEnabled = true; + this.heldItemComboBox.Location = new System.Drawing.Point(6, 98); + this.heldItemComboBox.Name = "heldItemComboBox"; + this.heldItemComboBox.Size = new System.Drawing.Size(147, 24); + this.heldItemComboBox.TabIndex = 18; + // + // heldItemLabel + // + this.heldItemLabel.AutoSize = true; + this.heldItemLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.heldItemLabel.Location = new System.Drawing.Point(3, 78); + this.heldItemLabel.Name = "heldItemLabel"; + this.heldItemLabel.Size = new System.Drawing.Size(64, 16); + this.heldItemLabel.TabIndex = 19; + this.heldItemLabel.Text = "Held Item"; + // + // contestGroupBox + // + this.contestGroupBox.Controls.Add(this.toughNumericUpDown); + this.contestGroupBox.Controls.Add(this.smartNumericUpDown); + this.contestGroupBox.Controls.Add(this.cuteNumericUpDown); + this.contestGroupBox.Controls.Add(this.beautyNumericUpDown); + this.contestGroupBox.Controls.Add(this.coolNumericUpDown); + this.contestGroupBox.Controls.Add(this.sheenNumericUpDown); + this.contestGroupBox.Controls.Add(this.toughLabel); + this.contestGroupBox.Controls.Add(this.smartLabel); + this.contestGroupBox.Controls.Add(this.cuteLabel); + this.contestGroupBox.Controls.Add(this.beautyLabel); + this.contestGroupBox.Controls.Add(this.coolLabel); + this.contestGroupBox.Controls.Add(this.sheenLabel); + this.contestGroupBox.Location = new System.Drawing.Point(285, 10); + this.contestGroupBox.Name = "contestGroupBox"; + this.contestGroupBox.Size = new System.Drawing.Size(120, 180); + this.contestGroupBox.TabIndex = 17; + this.contestGroupBox.TabStop = false; + this.contestGroupBox.Text = "Contest Stats"; + // + // toughNumericUpDown + // + this.toughNumericUpDown.Location = new System.Drawing.Point(64, 148); + this.toughNumericUpDown.Name = "toughNumericUpDown"; + this.toughNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.toughNumericUpDown.TabIndex = 16; + // + // smartNumericUpDown + // + this.smartNumericUpDown.Location = new System.Drawing.Point(64, 123); + this.smartNumericUpDown.Name = "smartNumericUpDown"; + this.smartNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.smartNumericUpDown.TabIndex = 15; + // + // cuteNumericUpDown + // + this.cuteNumericUpDown.Location = new System.Drawing.Point(64, 97); + this.cuteNumericUpDown.Name = "cuteNumericUpDown"; + this.cuteNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.cuteNumericUpDown.TabIndex = 14; + // + // beautyNumericUpDown + // + this.beautyNumericUpDown.Location = new System.Drawing.Point(64, 72); + this.beautyNumericUpDown.Name = "beautyNumericUpDown"; + this.beautyNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.beautyNumericUpDown.TabIndex = 13; + // + // coolNumericUpDown + // + this.coolNumericUpDown.Location = new System.Drawing.Point(64, 47); + this.coolNumericUpDown.Name = "coolNumericUpDown"; + this.coolNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.coolNumericUpDown.TabIndex = 12; + // + // sheenNumericUpDown + // + this.sheenNumericUpDown.Location = new System.Drawing.Point(64, 22); + this.sheenNumericUpDown.Name = "sheenNumericUpDown"; + this.sheenNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.sheenNumericUpDown.TabIndex = 11; + // + // toughLabel + // + this.toughLabel.AutoSize = true; + this.toughLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.toughLabel.Location = new System.Drawing.Point(6, 150); + this.toughLabel.Name = "toughLabel"; + this.toughLabel.Size = new System.Drawing.Size(46, 16); + this.toughLabel.TabIndex = 10; + this.toughLabel.Text = "Tough"; + // + // smartLabel + // + this.smartLabel.AutoSize = true; + this.smartLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.smartLabel.Location = new System.Drawing.Point(6, 125); + this.smartLabel.Name = "smartLabel"; + this.smartLabel.Size = new System.Drawing.Size(42, 16); + this.smartLabel.TabIndex = 9; + this.smartLabel.Text = "Smart"; + // + // cuteLabel + // + this.cuteLabel.AutoSize = true; + this.cuteLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.cuteLabel.Location = new System.Drawing.Point(6, 100); + this.cuteLabel.Name = "cuteLabel"; + this.cuteLabel.Size = new System.Drawing.Size(34, 16); + this.cuteLabel.TabIndex = 8; + this.cuteLabel.Text = "Cute"; + // + // beautyLabel + // + this.beautyLabel.AutoSize = true; + this.beautyLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.beautyLabel.Location = new System.Drawing.Point(6, 75); + this.beautyLabel.Name = "beautyLabel"; + this.beautyLabel.Size = new System.Drawing.Size(49, 16); + this.beautyLabel.TabIndex = 7; + this.beautyLabel.Text = "Beauty"; + // + // coolLabel + // + this.coolLabel.AutoSize = true; + this.coolLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.coolLabel.Location = new System.Drawing.Point(6, 50); + this.coolLabel.Name = "coolLabel"; + this.coolLabel.Size = new System.Drawing.Size(35, 16); + this.coolLabel.TabIndex = 6; + this.coolLabel.Text = "Cool"; + // + // sheenLabel + // + this.sheenLabel.AutoSize = true; + this.sheenLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.sheenLabel.Location = new System.Drawing.Point(6, 25); + this.sheenLabel.Name = "sheenLabel"; + this.sheenLabel.Size = new System.Drawing.Size(46, 16); + this.sheenLabel.TabIndex = 5; + this.sheenLabel.Text = "Sheen"; + // + // IVGroupBox + // + this.IVGroupBox.Controls.Add(this.speIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.spdIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.spaIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.defIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.atkIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.hpIVNumericUpDown); + this.IVGroupBox.Controls.Add(this.speIVLabel); + this.IVGroupBox.Controls.Add(this.spdIVLabel); + this.IVGroupBox.Controls.Add(this.spaIVLabel); + this.IVGroupBox.Controls.Add(this.defIVLabel); + this.IVGroupBox.Controls.Add(this.atkIVLabel); + this.IVGroupBox.Controls.Add(this.hpIVLabel); + this.IVGroupBox.Location = new System.Drawing.Point(160, 10); + this.IVGroupBox.Name = "IVGroupBox"; + this.IVGroupBox.Size = new System.Drawing.Size(120, 180); + this.IVGroupBox.TabIndex = 4; + this.IVGroupBox.TabStop = false; + this.IVGroupBox.Text = "IVs"; + // + // speIVNumericUpDown + // + this.speIVNumericUpDown.Location = new System.Drawing.Point(50, 148); + this.speIVNumericUpDown.Name = "speIVNumericUpDown"; + this.speIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.speIVNumericUpDown.TabIndex = 16; + // + // spdIVNumericUpDown + // + this.spdIVNumericUpDown.Location = new System.Drawing.Point(50, 123); + this.spdIVNumericUpDown.Name = "spdIVNumericUpDown"; + this.spdIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.spdIVNumericUpDown.TabIndex = 15; + // + // spaIVNumericUpDown + // + this.spaIVNumericUpDown.Location = new System.Drawing.Point(50, 97); + this.spaIVNumericUpDown.Name = "spaIVNumericUpDown"; + this.spaIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.spaIVNumericUpDown.TabIndex = 14; + // + // defIVNumericUpDown + // + this.defIVNumericUpDown.Location = new System.Drawing.Point(50, 72); + this.defIVNumericUpDown.Name = "defIVNumericUpDown"; + this.defIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.defIVNumericUpDown.TabIndex = 13; + // + // atkIVNumericUpDown + // + this.atkIVNumericUpDown.Location = new System.Drawing.Point(50, 47); + this.atkIVNumericUpDown.Name = "atkIVNumericUpDown"; + this.atkIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.atkIVNumericUpDown.TabIndex = 12; + // + // hpIVNumericUpDown + // + this.hpIVNumericUpDown.Location = new System.Drawing.Point(50, 22); + this.hpIVNumericUpDown.Name = "hpIVNumericUpDown"; + this.hpIVNumericUpDown.Size = new System.Drawing.Size(51, 22); + this.hpIVNumericUpDown.TabIndex = 11; + // + // speIVLabel + // + this.speIVLabel.AutoSize = true; + this.speIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.speIVLabel.Location = new System.Drawing.Point(6, 150); + this.speIVLabel.Name = "speIVLabel"; + this.speIVLabel.Size = new System.Drawing.Size(32, 16); + this.speIVLabel.TabIndex = 10; + this.speIVLabel.Text = "Spe"; + // + // spdIVLabel + // + this.spdIVLabel.AutoSize = true; + this.spdIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.spdIVLabel.Location = new System.Drawing.Point(6, 125); + this.spdIVLabel.Name = "spdIVLabel"; + this.spdIVLabel.Size = new System.Drawing.Size(34, 16); + this.spdIVLabel.TabIndex = 9; + this.spdIVLabel.Text = "SpD"; + // + // spaIVLabel + // + this.spaIVLabel.AutoSize = true; + this.spaIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.spaIVLabel.Location = new System.Drawing.Point(6, 100); + this.spaIVLabel.Name = "spaIVLabel"; + this.spaIVLabel.Size = new System.Drawing.Size(33, 16); + this.spaIVLabel.TabIndex = 8; + this.spaIVLabel.Text = "SpA"; + // + // defIVLabel + // + this.defIVLabel.AutoSize = true; + this.defIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.defIVLabel.Location = new System.Drawing.Point(6, 75); + this.defIVLabel.Name = "defIVLabel"; + this.defIVLabel.Size = new System.Drawing.Size(28, 16); + this.defIVLabel.TabIndex = 7; + this.defIVLabel.Text = "Def"; + // + // atkIVLabel + // + this.atkIVLabel.AutoSize = true; + this.atkIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.atkIVLabel.Location = new System.Drawing.Point(6, 50); + this.atkIVLabel.Name = "atkIVLabel"; + this.atkIVLabel.Size = new System.Drawing.Size(26, 16); + this.atkIVLabel.TabIndex = 6; + this.atkIVLabel.Text = "Atk"; + // + // hpIVLabel + // + this.hpIVLabel.AutoSize = true; + this.hpIVLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.hpIVLabel.Location = new System.Drawing.Point(6, 25); + this.hpIVLabel.Name = "hpIVLabel"; + this.hpIVLabel.Size = new System.Drawing.Size(26, 16); + this.hpIVLabel.TabIndex = 5; + this.hpIVLabel.Text = "HP"; + // + // speciesComboBox + // + this.speciesComboBox.FormattingEnabled = true; + this.speciesComboBox.Location = new System.Drawing.Point(6, 30); + this.speciesComboBox.Name = "speciesComboBox"; + this.speciesComboBox.Size = new System.Drawing.Size(147, 24); + this.speciesComboBox.TabIndex = 2; + // + // speciesLabel + // + this.speciesLabel.AutoSize = true; + this.speciesLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.speciesLabel.Location = new System.Drawing.Point(3, 10); + this.speciesLabel.Name = "speciesLabel"; + this.speciesLabel.Size = new System.Drawing.Size(57, 16); + this.speciesLabel.TabIndex = 3; + this.speciesLabel.Text = "Species"; + // + // tradeIDNumericUpDown + // + this.tradeIDNumericUpDown.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tradeIDNumericUpDown.Location = new System.Drawing.Point(21, 46); + this.tradeIDNumericUpDown.Name = "tradeIDNumericUpDown"; + this.tradeIDNumericUpDown.Size = new System.Drawing.Size(120, 22); + this.tradeIDNumericUpDown.TabIndex = 0; + this.tradeIDNumericUpDown.ValueChanged += new System.EventHandler(this.tradeIDNumericUpDown_ValueChanged); + // + // tradeIDLabel + // + this.tradeIDLabel.AutoSize = true; + this.tradeIDLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tradeIDLabel.Location = new System.Drawing.Point(18, 27); + this.tradeIDLabel.Name = "tradeIDLabel"; + this.tradeIDLabel.Size = new System.Drawing.Size(60, 16); + this.tradeIDLabel.TabIndex = 1; + this.tradeIDLabel.Text = "Trade ID"; + // + // TradeEditor + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(641, 460); + this.Controls.Add(this.mainPanel); + this.Name = "TradeEditor"; this.Text = "TradeEditor"; + this.mainPanel.ResumeLayout(false); + this.textDataGroupBox.ResumeLayout(false); + this.textDataGroupBox.PerformLayout(); + this.tradeDataGroupBox.ResumeLayout(false); + this.tradeDataGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.otIDNumericUpDown)).EndInit(); + this.monDataGroupBox.ResumeLayout(false); + this.monDataPanel.ResumeLayout(false); + this.monDataPanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.unknownNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pidNumericUpDown)).EndInit(); + this.contestGroupBox.ResumeLayout(false); + this.contestGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.toughNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.smartNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.cuteNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.beautyNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.coolNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.sheenNumericUpDown)).EndInit(); + this.IVGroupBox.ResumeLayout(false); + this.IVGroupBox.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.speIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.spdIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.spaIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.defIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.atkIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.hpIVNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.tradeIDNumericUpDown)).EndInit(); + this.ResumeLayout(false); + } #endregion + + private System.Windows.Forms.Panel mainPanel; + private System.Windows.Forms.NumericUpDown tradeIDNumericUpDown; + private System.Windows.Forms.Label tradeIDLabel; + private System.Windows.Forms.GroupBox tradeDataGroupBox; + private System.Windows.Forms.GroupBox textDataGroupBox; + private System.Windows.Forms.Label speciesLabel; + private System.Windows.Forms.ComboBox speciesComboBox; + private System.Windows.Forms.Panel monDataPanel; + private System.Windows.Forms.GroupBox IVGroupBox; + private System.Windows.Forms.Label speIVLabel; + private System.Windows.Forms.Label spdIVLabel; + private System.Windows.Forms.Label spaIVLabel; + private System.Windows.Forms.Label defIVLabel; + private System.Windows.Forms.Label atkIVLabel; + private System.Windows.Forms.Label hpIVLabel; + private System.Windows.Forms.NumericUpDown speIVNumericUpDown; + private System.Windows.Forms.NumericUpDown spdIVNumericUpDown; + private System.Windows.Forms.NumericUpDown spaIVNumericUpDown; + private System.Windows.Forms.NumericUpDown defIVNumericUpDown; + private System.Windows.Forms.NumericUpDown atkIVNumericUpDown; + private System.Windows.Forms.NumericUpDown hpIVNumericUpDown; + private System.Windows.Forms.GroupBox contestGroupBox; + private System.Windows.Forms.NumericUpDown toughNumericUpDown; + private System.Windows.Forms.NumericUpDown smartNumericUpDown; + private System.Windows.Forms.NumericUpDown cuteNumericUpDown; + private System.Windows.Forms.NumericUpDown beautyNumericUpDown; + private System.Windows.Forms.NumericUpDown coolNumericUpDown; + private System.Windows.Forms.NumericUpDown sheenNumericUpDown; + private System.Windows.Forms.Label toughLabel; + private System.Windows.Forms.Label smartLabel; + private System.Windows.Forms.Label cuteLabel; + private System.Windows.Forms.Label beautyLabel; + private System.Windows.Forms.Label coolLabel; + private System.Windows.Forms.Label sheenLabel; + private System.Windows.Forms.ComboBox heldItemComboBox; + private System.Windows.Forms.Label heldItemLabel; + private System.Windows.Forms.GroupBox monDataGroupBox; + private System.Windows.Forms.ComboBox langComboBox; + private System.Windows.Forms.Label langLabel; + private System.Windows.Forms.NumericUpDown otIDNumericUpDown; + private System.Windows.Forms.Label otIDLabel; + private System.Windows.Forms.Label otGenderLabel; + private System.Windows.Forms.ComboBox otGenderComboBox; + private System.Windows.Forms.NumericUpDown pidNumericUpDown; + private System.Windows.Forms.Label pidLabel; + private System.Windows.Forms.NumericUpDown unknownNumericUpDown; + private System.Windows.Forms.Label unknownLabel; + private System.Windows.Forms.ComboBox abilityComboBox; + private System.Windows.Forms.Label abilityLabel; + private System.Windows.Forms.ComboBox requestedComboBox; + private System.Windows.Forms.Label requestedLabel; + private System.Windows.Forms.ToolTip toolTip; + private System.Windows.Forms.Button saveTradeButton; + private System.Windows.Forms.TextBox nicknameTextBox; + private System.Windows.Forms.TextBox otNameTextBox; + private System.Windows.Forms.Label nicknameLabel; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.Button saveTextDataButton; } } \ No newline at end of file diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 79794b3..45ff993 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -1,4 +1,5 @@ -using System; +using DSPRE.ROMFiles; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -12,9 +13,307 @@ namespace DSPRE.Editors { public partial class TradeEditor : Form { + + private TradeData curTradeData; + private TextArchive tradeArchive; + + #region Enums + public enum OriginLang + { + NONE = 0, + JAPANESE = 1, + ENGLISH = 2, + FRENCH = 3, + ITALIAN = 4, + GERMAN = 5, + UNUSED = 6, + SPANISH = 7, + KOREAN = 8 + } + #endregion + public TradeEditor() { + Helpers.DisableHandlers(); + InitializeComponent(); + InitLimits(); + InitDataRanges(); + SetToolTips(); + + if (TradeData.GetTradeCount() == 0) + { + MessageBox.Show("No trades could be found! The narc may have failed to unpack.", "Loading Trades Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error("TradeEditor: Loading trades failed."); + return; + } + + if (RomInfo.gameFamily != RomInfo.GameFamilies.HGSS) + { + unknownNumericUpDown.Enabled = false; + } + + tradeArchive = new TextArchive(GetTextBankIndex()); + LoadFromFile(0); + } + + public void LoadFromFile(int tradeID) + { + Helpers.DisableHandlers(); + curTradeData = new TradeData(tradeID); + tradeIDNumericUpDown.Value = tradeID; + speciesComboBox.SelectedIndex = curTradeData.species; + hpIVNumericUpDown.Value = curTradeData.hpIV; + atkIVNumericUpDown.Value = curTradeData.atkIV; + defIVNumericUpDown.Value = curTradeData.defIV; + speIVNumericUpDown.Value = curTradeData.speedIV; + spaIVNumericUpDown.Value = curTradeData.spAtkIV; + spdIVNumericUpDown.Value = curTradeData.spDefIV; + abilityComboBox.SelectedIndex = curTradeData.ability; + otIDNumericUpDown.Value = curTradeData.otID; + coolNumericUpDown.Value = curTradeData.cool; + beautyNumericUpDown.Value = curTradeData.beauty; + cuteNumericUpDown.Value = curTradeData.cute; + smartNumericUpDown.Value = curTradeData.smart; + toughNumericUpDown.Value = curTradeData.tough; + pidNumericUpDown.Value = curTradeData.pid; + heldItemComboBox.SelectedIndex = curTradeData.heldItem; + otGenderComboBox.SelectedIndex = curTradeData.otGender; + sheenNumericUpDown.Value = curTradeData.sheen; + langComboBox.SelectedIndex = curTradeData.language; + requestedComboBox.SelectedIndex = curTradeData.requestedSpecies; + unknownNumericUpDown.Value = curTradeData.unknown; + + otNameTextBox.Text = GetOTName(tradeID); + nicknameTextBox.Text = GetMonNickname(tradeID); + + Helpers.EnableHandlers(); + } + + private void SaveToFile() + { + curTradeData.species = speciesComboBox.SelectedIndex; + curTradeData.hpIV = (int)hpIVNumericUpDown.Value; + curTradeData.atkIV = (int)atkIVNumericUpDown.Value; + curTradeData.defIV = (int)defIVNumericUpDown.Value; + curTradeData.speedIV = (int)speIVNumericUpDown.Value; + curTradeData.spAtkIV = (int)spaIVNumericUpDown.Value; + curTradeData.spDefIV = (int)spdIVNumericUpDown.Value; + curTradeData.ability = abilityComboBox.SelectedIndex; + curTradeData.otID = (int)otIDNumericUpDown.Value; + curTradeData.cool = (int)coolNumericUpDown.Value; + curTradeData.beauty = (int)beautyNumericUpDown.Value; + curTradeData.cute = (int)cuteNumericUpDown.Value; + curTradeData.smart = (int)smartNumericUpDown.Value; + curTradeData.tough = (int)toughNumericUpDown.Value; + curTradeData.pid = (int)pidNumericUpDown.Value; + curTradeData.heldItem = heldItemComboBox.SelectedIndex; + curTradeData.otGender = otGenderComboBox.SelectedIndex; + curTradeData.sheen = (int)sheenNumericUpDown.Value; + curTradeData.language = langComboBox.SelectedIndex; + curTradeData.requestedSpecies = requestedComboBox.SelectedIndex; + + if (RomInfo.gameFamily == RomInfo.GameFamilies.HGSS) + { + curTradeData.unknown = (int)unknownNumericUpDown.Value; + } + else + { + curTradeData.unknown = 0; + } + + curTradeData.SaveToFileDefaultDir((int)tradeIDNumericUpDown.Value, true); + } + + private void InitLimits() + { + // IVs: 0-31 + hpIVNumericUpDown.Minimum = 0; + hpIVNumericUpDown.Maximum = 31; + atkIVNumericUpDown.Minimum = 0; + atkIVNumericUpDown.Maximum = 31; + defIVNumericUpDown.Minimum = 0; + defIVNumericUpDown.Maximum = 31; + speIVNumericUpDown.Minimum = 0; + speIVNumericUpDown.Maximum = 31; + spaIVNumericUpDown.Minimum = 0; + spaIVNumericUpDown.Maximum = 31; + spdIVNumericUpDown.Minimum = 0; + spdIVNumericUpDown.Maximum = 31; + + // Contest stats: 0-255 + coolNumericUpDown.Minimum = 0; + coolNumericUpDown.Maximum = 255; + beautyNumericUpDown.Minimum = 0; + beautyNumericUpDown.Maximum = 255; + cuteNumericUpDown.Minimum = 0; + cuteNumericUpDown.Maximum = 255; + smartNumericUpDown.Minimum = 0; + smartNumericUpDown.Maximum = 255; + toughNumericUpDown.Minimum = 0; + toughNumericUpDown.Maximum = 255; + + // PID: (32-bit unsigned) + pidNumericUpDown.Minimum = 0; + pidNumericUpDown.Maximum = int.MaxValue; + + // Sheen: 0-255 + sheenNumericUpDown.Minimum = 0; + sheenNumericUpDown.Maximum = 255; + + // Unknown: (32-bit unsigned) + unknownNumericUpDown.Minimum = 0; + unknownNumericUpDown.Maximum = int.MaxValue; + + // Trade ID: (dynamic based on loaded data) + tradeIDNumericUpDown.Minimum = 0; + tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount()-1; + + // OT ID: (32-bit unsigned) + otIDNumericUpDown.Minimum = 0; + otIDNumericUpDown.Maximum = int.MaxValue; + + // Text fields + otNameTextBox.MaxLength = 7; + nicknameTextBox.MaxLength = 10; + } + + private void InitDataRanges() + { + // Species Names + speciesComboBox.DataSource = RomInfo.GetPokemonNames(); + requestedComboBox.DataSource = RomInfo.GetPokemonNames(); + + // Abilities + abilityComboBox.DataSource = RomInfo.GetAbilityNames(); + + // Held Items + heldItemComboBox.DataSource = RomInfo.GetItemNames(); + + // OT Gender + otGenderComboBox.DataSource = new string[] {"Male", "Female"}; + + // Languages + langComboBox.DataSource = Enum.GetNames(typeof(OriginLang)); + } + + private void SetToolTips() + { + toolTip.SetToolTip(tradeIDNumericUpDown, "The Trade ID to edit."); + toolTip.SetToolTip(speciesComboBox, "The species of the Pokémon being traded."); + toolTip.SetToolTip(IVGroupBox, "Individual Values (IVs)"); + toolTip.SetToolTip(abilityComboBox, "The ability of the Pokémon.\nThis value is unused!"); + toolTip.SetToolTip(otIDNumericUpDown, "The Original Trainer ID of the Pokémon."); + toolTip.SetToolTip(contestGroupBox, "Contest stats for the Pokémon."); + toolTip.SetToolTip(pidNumericUpDown, "The PID of the Pokémon."); + toolTip.SetToolTip(heldItemComboBox, "The held item of the Pokémon."); + toolTip.SetToolTip(otGenderComboBox, "The gender of the Original Trainer (OT).\nThe OT name is determined by the text bank."); + toolTip.SetToolTip(langComboBox, "The language of origin of the traded Pokémon."); + toolTip.SetToolTip(requestedComboBox, "The species of the requested Pokémon.\nWhether the Pokémon selected by the player matches this species or not is checked via scripting."); + toolTip.SetToolTip(unknownNumericUpDown, "An unknown value, present in HGSS only.\nAppears to be unused."); + + } + + private void tradeIDNumericUpDown_ValueChanged(object sender, EventArgs e) + { + if (Helpers.HandlersDisabled) + { + return; + } + + int tradeID = (int)tradeIDNumericUpDown.Value; + if (tradeID < 0 || tradeID >= TradeData.GetTradeCount()) + { + MessageBox.Show("Invalid Trade ID selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + LoadFromFile(tradeID); + + } + + private void saveTradeButton_Click(object sender, EventArgs e) + { + SaveToFile(); + } + + private int GetTextBankIndex() + { + switch (RomInfo.gameFamily) + { + case RomInfo.GameFamilies.DP: + switch (RomInfo.gameLanguage) + { + case RomInfo.GameLanguages.Japanese: + return 325; // not confirmed to be correct + default: + return 326; + } + case RomInfo.GameFamilies.Plat: + switch (RomInfo.gameLanguage) + { + case RomInfo.GameLanguages.Japanese: + return 369; + default: + return 370; + } + case RomInfo.GameFamilies.HGSS: + switch (RomInfo.gameLanguage) + { + case RomInfo.GameLanguages.Japanese: + return 198; + default: + return 200; + } + default: + AppLogger.Error("TradeEditor: Invalid game family for text bank index retrieval."); + MessageBox.Show("Invalid game family for text bank index retrieval.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return 0; + } + + } + private string GetMonNickname(int tradeID) + { + string msg = tradeArchive.messages[tradeID]; + if (msg.Length > nicknameTextBox.MaxLength) + { + msg = msg.Substring(0, nicknameTextBox.MaxLength); + } + return msg; + } + + private string GetOTName(int tradeID) + { + int index = tradeID + TradeData.GetTradeCount(); + string msg = tradeArchive.messages[index]; + if (msg.Length > otNameTextBox.MaxLength) + { + msg = msg.Substring(0, otNameTextBox.MaxLength); + } + return msg; + } + + private void saveTextDataButton_Click(object sender, EventArgs e) + { + Helpers.DisableHandlers(); + int tradeID = (int)tradeIDNumericUpDown.Value; + + if (tradeID < 0 || tradeID + TradeData.GetTradeCount() > tradeArchive.messages.Count) + { + MessageBox.Show("Can't save to text bank. Index is out of range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error("TradeEditor: Can't save to text bank. Index is out of range."); + Helpers.EnableHandlers(); + return; + } + + // Nickname + tradeArchive.messages[tradeID] = nicknameTextBox.Text; + + // OT Name + tradeArchive.messages[tradeID + TradeData.GetTradeCount()] = otNameTextBox.Text; + + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + Helpers.EnableHandlers(); } } } diff --git a/DS_Map/Editors/TradeEditor.resx b/DS_Map/Editors/TradeEditor.resx new file mode 100644 index 0000000..8766f29 --- /dev/null +++ b/DS_Map/Editors/TradeEditor.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/DS_Map/Main Window.Designer.cs b/DS_Map/Main Window.Designer.cs index fd8df7a..a756fdd 100644 --- a/DS_Map/Main Window.Designer.cs +++ b/DS_Map/Main Window.Designer.cs @@ -536,6 +536,7 @@ this.flyWarpEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.itemEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.overworldEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.tradeEditorToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.aboutToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.statusStrip1 = new System.Windows.Forms.StatusStrip(); this.statusLabel = new System.Windows.Forms.ToolStripStatusLabel(); @@ -6735,7 +6736,8 @@ this.moveDataEditorToolStripMenuItem, this.flyWarpEditorToolStripMenuItem, this.itemEditorToolStripMenuItem, - this.overworldEditorToolStripMenuItem}); + this.overworldEditorToolStripMenuItem, + this.tradeEditorToolStripMenuItem}); this.otherEditorsToolStripMenuItem.Enabled = false; this.otherEditorsToolStripMenuItem.Name = "otherEditorsToolStripMenuItem"; this.otherEditorsToolStripMenuItem.Size = new System.Drawing.Size(88, 20); @@ -6789,6 +6791,13 @@ this.overworldEditorToolStripMenuItem.Size = new System.Drawing.Size(174, 22); this.overworldEditorToolStripMenuItem.Text = "Overworld Editor"; this.overworldEditorToolStripMenuItem.Click += new System.EventHandler(this.overworldEditorToolStripMenuItem_Click); + // + // tradeEditorToolStripMenuItem + // + this.tradeEditorToolStripMenuItem.Name = "tradeEditorToolStripMenuItem"; + this.tradeEditorToolStripMenuItem.Size = new System.Drawing.Size(174, 22); + this.tradeEditorToolStripMenuItem.Text = "Trade Editor"; + this.tradeEditorToolStripMenuItem.Click += new System.EventHandler(this.tradeEditorToolStripMenuItem_Click); // // aboutToolStripMenuItem1 // @@ -7946,6 +7955,7 @@ private System.Windows.Forms.Panel panel1; private System.Windows.Forms.ToolStripMenuItem flyWarpEditorToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem itemEditorToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem tradeEditorToolStripMenuItem; private System.Windows.Forms.Button popoutTextEditorButton; private System.Windows.Forms.Label textEditorPoppedOutLabel; private System.Windows.Forms.Button popoutLevelScriptEditorButton; diff --git a/DS_Map/Main Window.cs b/DS_Map/Main Window.cs index 6d5e810..60b8560 100644 --- a/DS_Map/Main Window.cs +++ b/DS_Map/Main Window.cs @@ -7270,6 +7270,14 @@ namespace DSPRE { flyEditor.Show(); } + private void tradeEditorToolStripMenuItem_Click(object sender, EventArgs e) + { + DSUtils.TryUnpackNarcs(new List { DirNames.tradeData }); + + TradeEditor tradeEditor = new TradeEditor(); + tradeEditor.Show(); + } + private void itemEditorToolStripMenuItem_Click(object sender, EventArgs e) { Helpers.statusLabelMessage("Setting up Item Data Editor..."); diff --git a/DS_Map/ROMFiles/TradeData.cs b/DS_Map/ROMFiles/TradeData.cs index 267d709..4091eb9 100644 --- a/DS_Map/ROMFiles/TradeData.cs +++ b/DS_Map/ROMFiles/TradeData.cs @@ -48,7 +48,7 @@ namespace DSPRE.ROMFiles speedIV = br.ReadInt32(); spAtkIV = br.ReadInt32(); spDefIV = br.ReadInt32(); - ability = br.ReadInt32(); // unused + ability = br.ReadInt32(); // appears unused otID = br.ReadInt32(); cool = br.ReadInt32(); beauty = br.ReadInt32(); @@ -61,7 +61,12 @@ namespace DSPRE.ROMFiles sheen = br.ReadInt32(); language = br.ReadInt32(); requestedSpecies = br.ReadInt32(); - unknown = br.ReadInt32(); // unused? + + if (RomInfo.gameFamily == GameFamilies.HGSS) + { + unknown = br.ReadInt32(); // unused? + } + } } @@ -111,5 +116,10 @@ namespace DSPRE.ROMFiles SaveToFileExplorePath("Gen IV Trade data", "bin", suggestedFileName, showSuccessMessage); } + public static int GetTradeCount() + { + return Directory.GetFiles(RomInfo.gameDirs[DirNames.tradeData].unpackedDir, "*.*").Length; + } + } } diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 55c3dc2..e64f3cb 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -1486,6 +1486,11 @@ namespace DSPRE personal += @"\personal.narc"; packedDirsDict[DirNames.personalPokeData] = personal; + if (gameLanguage != GameLanguages.Japanese) + { + packedDirsDict[DirNames.tradeData] = $@"data\resource\{GetLangResFolderName()}\pokemon_trade\fld_trade.narc"; + } + break; case GameFamilies.Plat: @@ -1533,6 +1538,12 @@ namespace DSPRE [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; + + if (gameLanguage != GameLanguages.Japanese) + { + packedDirsDict[DirNames.tradeData] = $@"data\resource\{GetLangResFolderName()}\pokemon_trade\fld_trade.narc"; + } + break; case GameFamilies.HGSS: @@ -1591,6 +1602,25 @@ namespace DSPRE } } + public static string GetLangResFolderName() + { + switch (gameLanguage) + { + case GameLanguages.English: + return "eng"; + case GameLanguages.Italian: + return "ita"; + case GameLanguages.French: + return "fra"; + case GameLanguages.German: + return "ger"; + case GameLanguages.Spanish: + return "spa"; + default: + return ""; + } + } + public void ResetMapCellsColorDictionary() { switch (gameFamily) From 6d5673eb75bb3d6666823eebd9ade218fa08d4fb Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 19:44:22 +0200 Subject: [PATCH 08/11] fix JP DP trade text bank and revert text editor changes --- DS_Map/Editors/TextEditor.Designer.cs | 1 - DS_Map/Editors/TradeEditor.cs | 2 +- DS_Map/RomInfo.cs | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/DS_Map/Editors/TextEditor.Designer.cs b/DS_Map/Editors/TextEditor.Designer.cs index a360188..6f45fbb 100644 --- a/DS_Map/Editors/TextEditor.Designer.cs +++ b/DS_Map/Editors/TextEditor.Designer.cs @@ -331,7 +331,6 @@ this.textSearchResultsListBox.Size = new System.Drawing.Size(267, 244); this.textSearchResultsListBox.TabIndex = 38; this.textSearchResultsListBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textSearchResultsListBox_KeyDown); - this.textSearchResultsListBox.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.textSearchResultsListBox_GoToEntryResult); // // replaceTextLabel // diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 45ff993..d6daef4 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -245,7 +245,7 @@ namespace DSPRE.Editors switch (RomInfo.gameLanguage) { case RomInfo.GameLanguages.Japanese: - return 325; // not confirmed to be correct + return 324; default: return 326; } diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index e64f3cb..02c653b 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -1026,7 +1026,7 @@ namespace DSPRE switch (gameFamily) { case GameFamilies.DP: - itemNamesTextNumber = 344; + itemNamesTextNumber = gameLanguage == GameLanguages.Japanese ? 341 : 344; itemDescriptionsTextNumber = 0; break; From ee8e5c9db13129c8af676a0bc4d199e5caa23b44 Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 22:40:28 +0200 Subject: [PATCH 09/11] trade editor complete except for adding / removing trades --- DS_Map/Editors/TradeEditor.Designer.cs | 99 +++++-- DS_Map/Editors/TradeEditor.cs | 376 ++++++++++++++++++------- 2 files changed, 347 insertions(+), 128 deletions(-) diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs index 645291b..454e2b4 100644 --- a/DS_Map/Editors/TradeEditor.Designer.cs +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -30,13 +30,14 @@ { this.components = new System.ComponentModel.Container(); this.mainPanel = new System.Windows.Forms.Panel(); + this.saveAllButton = new System.Windows.Forms.Button(); this.saveTextDataButton = new System.Windows.Forms.Button(); this.saveTradeButton = new System.Windows.Forms.Button(); this.textDataGroupBox = new System.Windows.Forms.GroupBox(); this.nicknameTextBox = new System.Windows.Forms.TextBox(); this.otNameTextBox = new System.Windows.Forms.TextBox(); this.nicknameLabel = new System.Windows.Forms.Label(); - this.label1 = new System.Windows.Forms.Label(); + this.otNameLabel = new System.Windows.Forms.Label(); this.tradeDataGroupBox = new System.Windows.Forms.GroupBox(); this.requestedComboBox = new System.Windows.Forms.ComboBox(); this.requestedLabel = new System.Windows.Forms.Label(); @@ -87,6 +88,8 @@ this.tradeIDNumericUpDown = new System.Windows.Forms.NumericUpDown(); this.tradeIDLabel = new System.Windows.Forms.Label(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); + this.addFileButton = new System.Windows.Forms.Button(); + this.removeLastButton = new System.Windows.Forms.Button(); this.mainPanel.SuspendLayout(); this.textDataGroupBox.SuspendLayout(); this.tradeDataGroupBox.SuspendLayout(); @@ -114,6 +117,9 @@ // // mainPanel // + this.mainPanel.Controls.Add(this.removeLastButton); + this.mainPanel.Controls.Add(this.saveAllButton); + this.mainPanel.Controls.Add(this.addFileButton); this.mainPanel.Controls.Add(this.saveTextDataButton); this.mainPanel.Controls.Add(this.saveTradeButton); this.mainPanel.Controls.Add(this.textDataGroupBox); @@ -123,28 +129,42 @@ this.mainPanel.Size = new System.Drawing.Size(624, 444); this.mainPanel.TabIndex = 0; // + // saveAllButton + // + this.saveAllButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveAllButton.Image = global::DSPRE.Properties.Resources.saveButton; + this.saveAllButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.saveAllButton.Location = new System.Drawing.Point(470, 389); + this.saveAllButton.Name = "saveAllButton"; + this.saveAllButton.Size = new System.Drawing.Size(147, 47); + this.saveAllButton.TabIndex = 6; + this.saveAllButton.Text = "Save All"; + this.saveAllButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.saveAllButton.UseVisualStyleBackColor = true; + this.saveAllButton.Click += new System.EventHandler(this.saveAllButton_Click); + // // saveTextDataButton // this.saveTextDataButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.saveTextDataButton.Image = global::DSPRE.Properties.Resources.saveButton; - this.saveTextDataButton.ImageAlign = System.Drawing.ContentAlignment.MiddleRight; - this.saveTextDataButton.Location = new System.Drawing.Point(479, 156); + this.saveTextDataButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.saveTextDataButton.Location = new System.Drawing.Point(479, 142); this.saveTextDataButton.Name = "saveTextDataButton"; - this.saveTextDataButton.Size = new System.Drawing.Size(126, 44); + this.saveTextDataButton.Size = new System.Drawing.Size(126, 40); this.saveTextDataButton.TabIndex = 5; this.saveTextDataButton.Text = "Save Text Data"; - this.saveTextDataButton.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.saveTextDataButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; this.saveTextDataButton.UseVisualStyleBackColor = true; this.saveTextDataButton.Click += new System.EventHandler(this.saveTextDataButton_Click); // // saveTradeButton // - this.saveTradeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.saveTradeButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.saveTradeButton.Image = global::DSPRE.Properties.Resources.saveButton; this.saveTradeButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; - this.saveTradeButton.Location = new System.Drawing.Point(470, 383); + this.saveTradeButton.Location = new System.Drawing.Point(480, 342); this.saveTradeButton.Name = "saveTradeButton"; - this.saveTradeButton.Size = new System.Drawing.Size(147, 47); + this.saveTradeButton.Size = new System.Drawing.Size(126, 40); this.saveTradeButton.TabIndex = 4; this.saveTradeButton.Text = "Save Trade Data"; this.saveTradeButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; @@ -156,11 +176,11 @@ this.textDataGroupBox.Controls.Add(this.nicknameTextBox); this.textDataGroupBox.Controls.Add(this.otNameTextBox); this.textDataGroupBox.Controls.Add(this.nicknameLabel); - this.textDataGroupBox.Controls.Add(this.label1); + this.textDataGroupBox.Controls.Add(this.otNameLabel); this.textDataGroupBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.textDataGroupBox.Location = new System.Drawing.Point(470, 3); this.textDataGroupBox.Name = "textDataGroupBox"; - this.textDataGroupBox.Size = new System.Drawing.Size(147, 147); + this.textDataGroupBox.Size = new System.Drawing.Size(147, 133); this.textDataGroupBox.TabIndex = 3; this.textDataGroupBox.TabStop = false; this.textDataGroupBox.Text = "Text Data"; @@ -189,15 +209,15 @@ this.nicknameLabel.TabIndex = 15; this.nicknameLabel.Text = "Pokémon Nickname"; // - // label1 + // otNameLabel // - this.label1.AutoSize = true; - this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.label1.Location = new System.Drawing.Point(6, 25); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(66, 16); - this.label1.TabIndex = 13; - this.label1.Text = "OT Name"; + this.otNameLabel.AutoSize = true; + this.otNameLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.otNameLabel.Location = new System.Drawing.Point(6, 25); + this.otNameLabel.Name = "otNameLabel"; + this.otNameLabel.Size = new System.Drawing.Size(66, 16); + this.otNameLabel.TabIndex = 13; + this.otNameLabel.Text = "OT Name"; // // tradeDataGroupBox // @@ -220,6 +240,7 @@ // // requestedComboBox // + this.requestedComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.requestedComboBox.FormattingEnabled = true; this.requestedComboBox.Location = new System.Drawing.Point(165, 44); this.requestedComboBox.Name = "requestedComboBox"; @@ -305,6 +326,7 @@ // // abilityComboBox // + this.abilityComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.abilityComboBox.FormattingEnabled = true; this.abilityComboBox.Location = new System.Drawing.Point(6, 218); this.abilityComboBox.Name = "abilityComboBox"; @@ -317,9 +339,9 @@ this.abilityLabel.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.abilityLabel.Location = new System.Drawing.Point(3, 198); this.abilityLabel.Name = "abilityLabel"; - this.abilityLabel.Size = new System.Drawing.Size(43, 16); + this.abilityLabel.Size = new System.Drawing.Size(101, 16); this.abilityLabel.TabIndex = 27; - this.abilityLabel.Text = "Ability"; + this.abilityLabel.Text = "Ability (Unused)"; // // unknownNumericUpDown // @@ -359,6 +381,7 @@ // // langComboBox // + this.langComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.langComboBox.FormattingEnabled = true; this.langComboBox.Location = new System.Drawing.Point(6, 166); this.langComboBox.Name = "langComboBox"; @@ -377,6 +400,7 @@ // // heldItemComboBox // + this.heldItemComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.heldItemComboBox.FormattingEnabled = true; this.heldItemComboBox.Location = new System.Drawing.Point(6, 98); this.heldItemComboBox.Name = "heldItemComboBox"; @@ -641,6 +665,7 @@ // // speciesComboBox // + this.speciesComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; this.speciesComboBox.FormattingEnabled = true; this.speciesComboBox.Location = new System.Drawing.Point(6, 30); this.speciesComboBox.Name = "speciesComboBox"; @@ -676,6 +701,34 @@ this.tradeIDLabel.TabIndex = 1; this.tradeIDLabel.Text = "Trade ID"; // + // addFileButton + // + this.addFileButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.addFileButton.Image = global::DSPRE.Properties.Resources.addIcon; + this.addFileButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.addFileButton.Location = new System.Drawing.Point(480, 242); + this.addFileButton.Name = "addFileButton"; + this.addFileButton.Size = new System.Drawing.Size(126, 40); + this.addFileButton.TabIndex = 13; + this.addFileButton.Text = "Add File"; + this.addFileButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.addFileButton.UseVisualStyleBackColor = true; + this.addFileButton.Click += new System.EventHandler(this.addFileButton_Click); + // + // removeLastButton + // + this.removeLastButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.removeLastButton.Image = global::DSPRE.Properties.Resources.deleteIcon; + this.removeLastButton.ImageAlign = System.Drawing.ContentAlignment.TopCenter; + this.removeLastButton.Location = new System.Drawing.Point(480, 292); + this.removeLastButton.Name = "removeLastButton"; + this.removeLastButton.Size = new System.Drawing.Size(126, 40); + this.removeLastButton.TabIndex = 14; + this.removeLastButton.Text = "Remove Last"; + this.removeLastButton.TextAlign = System.Drawing.ContentAlignment.BottomCenter; + this.removeLastButton.UseVisualStyleBackColor = true; + this.removeLastButton.Click += new System.EventHandler(this.removeLastButton_Click); + // // TradeEditor // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -684,6 +737,7 @@ this.Controls.Add(this.mainPanel); this.Name = "TradeEditor"; this.Text = "TradeEditor"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.TradeEditor_FormClosing); this.mainPanel.ResumeLayout(false); this.textDataGroupBox.ResumeLayout(false); this.textDataGroupBox.PerformLayout(); @@ -774,7 +828,10 @@ private System.Windows.Forms.TextBox nicknameTextBox; private System.Windows.Forms.TextBox otNameTextBox; private System.Windows.Forms.Label nicknameLabel; - private System.Windows.Forms.Label label1; + private System.Windows.Forms.Label otNameLabel; private System.Windows.Forms.Button saveTextDataButton; + private System.Windows.Forms.Button saveAllButton; + private System.Windows.Forms.Button addFileButton; + private System.Windows.Forms.Button removeLastButton; } } \ No newline at end of file diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index d6daef4..931c01b 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -17,6 +17,10 @@ namespace DSPRE.Editors private TradeData curTradeData; private TextArchive tradeArchive; + // Track if any changes have been made + private bool tradeDirty = false; + private bool textDirty = false; + #region Enums public enum OriginLang { @@ -40,6 +44,7 @@ namespace DSPRE.Editors InitLimits(); InitDataRanges(); SetToolTips(); + RegisterMarkDirtyHandlers(); if (TradeData.GetTradeCount() == 0) { @@ -53,78 +58,14 @@ namespace DSPRE.Editors unknownNumericUpDown.Enabled = false; } + // Disable buttons until trade expansion is implemented + addFileButton.Enabled = false; + removeLastButton.Enabled = false; + tradeArchive = new TextArchive(GetTextBankIndex()); LoadFromFile(0); } - public void LoadFromFile(int tradeID) - { - Helpers.DisableHandlers(); - curTradeData = new TradeData(tradeID); - tradeIDNumericUpDown.Value = tradeID; - speciesComboBox.SelectedIndex = curTradeData.species; - hpIVNumericUpDown.Value = curTradeData.hpIV; - atkIVNumericUpDown.Value = curTradeData.atkIV; - defIVNumericUpDown.Value = curTradeData.defIV; - speIVNumericUpDown.Value = curTradeData.speedIV; - spaIVNumericUpDown.Value = curTradeData.spAtkIV; - spdIVNumericUpDown.Value = curTradeData.spDefIV; - abilityComboBox.SelectedIndex = curTradeData.ability; - otIDNumericUpDown.Value = curTradeData.otID; - coolNumericUpDown.Value = curTradeData.cool; - beautyNumericUpDown.Value = curTradeData.beauty; - cuteNumericUpDown.Value = curTradeData.cute; - smartNumericUpDown.Value = curTradeData.smart; - toughNumericUpDown.Value = curTradeData.tough; - pidNumericUpDown.Value = curTradeData.pid; - heldItemComboBox.SelectedIndex = curTradeData.heldItem; - otGenderComboBox.SelectedIndex = curTradeData.otGender; - sheenNumericUpDown.Value = curTradeData.sheen; - langComboBox.SelectedIndex = curTradeData.language; - requestedComboBox.SelectedIndex = curTradeData.requestedSpecies; - unknownNumericUpDown.Value = curTradeData.unknown; - - otNameTextBox.Text = GetOTName(tradeID); - nicknameTextBox.Text = GetMonNickname(tradeID); - - Helpers.EnableHandlers(); - } - - private void SaveToFile() - { - curTradeData.species = speciesComboBox.SelectedIndex; - curTradeData.hpIV = (int)hpIVNumericUpDown.Value; - curTradeData.atkIV = (int)atkIVNumericUpDown.Value; - curTradeData.defIV = (int)defIVNumericUpDown.Value; - curTradeData.speedIV = (int)speIVNumericUpDown.Value; - curTradeData.spAtkIV = (int)spaIVNumericUpDown.Value; - curTradeData.spDefIV = (int)spdIVNumericUpDown.Value; - curTradeData.ability = abilityComboBox.SelectedIndex; - curTradeData.otID = (int)otIDNumericUpDown.Value; - curTradeData.cool = (int)coolNumericUpDown.Value; - curTradeData.beauty = (int)beautyNumericUpDown.Value; - curTradeData.cute = (int)cuteNumericUpDown.Value; - curTradeData.smart = (int)smartNumericUpDown.Value; - curTradeData.tough = (int)toughNumericUpDown.Value; - curTradeData.pid = (int)pidNumericUpDown.Value; - curTradeData.heldItem = heldItemComboBox.SelectedIndex; - curTradeData.otGender = otGenderComboBox.SelectedIndex; - curTradeData.sheen = (int)sheenNumericUpDown.Value; - curTradeData.language = langComboBox.SelectedIndex; - curTradeData.requestedSpecies = requestedComboBox.SelectedIndex; - - if (RomInfo.gameFamily == RomInfo.GameFamilies.HGSS) - { - curTradeData.unknown = (int)unknownNumericUpDown.Value; - } - else - { - curTradeData.unknown = 0; - } - - curTradeData.SaveToFileDefaultDir((int)tradeIDNumericUpDown.Value, true); - } - private void InitLimits() { // IVs: 0-31 @@ -167,7 +108,7 @@ namespace DSPRE.Editors // Trade ID: (dynamic based on loaded data) tradeIDNumericUpDown.Minimum = 0; - tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount()-1; + tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount() - 1; // OT ID: (32-bit unsigned) otIDNumericUpDown.Minimum = 0; @@ -191,7 +132,7 @@ namespace DSPRE.Editors heldItemComboBox.DataSource = RomInfo.GetItemNames(); // OT Gender - otGenderComboBox.DataSource = new string[] {"Male", "Female"}; + otGenderComboBox.DataSource = new string[] { "Male", "Female" }; // Languages langComboBox.DataSource = Enum.GetNames(typeof(OriginLang)); @@ -199,42 +140,143 @@ namespace DSPRE.Editors private void SetToolTips() { - toolTip.SetToolTip(tradeIDNumericUpDown, "The Trade ID to edit."); - toolTip.SetToolTip(speciesComboBox, "The species of the Pokémon being traded."); - toolTip.SetToolTip(IVGroupBox, "Individual Values (IVs)"); - toolTip.SetToolTip(abilityComboBox, "The ability of the Pokémon.\nThis value is unused!"); - toolTip.SetToolTip(otIDNumericUpDown, "The Original Trainer ID of the Pokémon."); - toolTip.SetToolTip(contestGroupBox, "Contest stats for the Pokémon."); - toolTip.SetToolTip(pidNumericUpDown, "The PID of the Pokémon."); - toolTip.SetToolTip(heldItemComboBox, "The held item of the Pokémon."); - toolTip.SetToolTip(otGenderComboBox, "The gender of the Original Trainer (OT).\nThe OT name is determined by the text bank."); - toolTip.SetToolTip(langComboBox, "The language of origin of the traded Pokémon."); - toolTip.SetToolTip(requestedComboBox, "The species of the requested Pokémon.\nWhether the Pokémon selected by the player matches this species or not is checked via scripting."); - toolTip.SetToolTip(unknownNumericUpDown, "An unknown value, present in HGSS only.\nAppears to be unused."); - + SetToolTipsForControls(new Control[] { tradeIDNumericUpDown, tradeIDLabel }, "The Trade ID to edit."); + SetToolTipsForControls(new Control[] { speciesComboBox, speciesLabel }, "The species of the Pokémon being traded."); + SetToolTipsForControls(new Control[] { IVGroupBox }, "Individual Values (IVs)"); + SetToolTipsForControls(new Control[] { abilityComboBox, abilityLabel }, "The ability of the Pokémon.\nThis value is unused and will have no effect!"); + SetToolTipsForControls(new Control[] { otIDNumericUpDown, otIDLabel }, "The Original Trainer ID of the Pokémon."); + SetToolTipsForControls(new Control[] { contestGroupBox }, "Contest stats for the Pokémon."); + SetToolTipsForControls(new Control[] { pidNumericUpDown, pidLabel }, "The PID of the Pokémon.\nDetermines ability and nature."); + SetToolTipsForControls(new Control[] { heldItemComboBox, heldItemLabel }, "The held item of the Pokémon."); + SetToolTipsForControls(new Control[] { otGenderComboBox, otGenderLabel }, "The gender of the Original Trainer (OT).\nThe OT name is determined by the text bank."); + SetToolTipsForControls(new Control[] { langComboBox, langLabel }, "The language of origin of the traded Pokémon."); + SetToolTipsForControls(new Control[] { requestedComboBox, requestedLabel }, "The species of the requested Pokémon.\nWhether the Pokémon selected by the player matches this species or not is checked via scripting."); + SetToolTipsForControls(new Control[] { unknownNumericUpDown, unknownLabel }, "An unknown value, present in HGSS only.\nAppears to be unused."); + SetToolTipsForControls(new Control[] { otNameTextBox, otNameLabel }, + $"The Original Trainer's name.\nStored in text bank {GetTextBankIndex()}.\nAt most {otNameTextBox.MaxLength} characters."); + SetToolTipsForControls(new Control[] { nicknameTextBox, nicknameLabel }, + $"The nickname of the Pokémon.\nStored in text bank {GetTextBankIndex()}.\nAt most {nicknameTextBox.MaxLength} characters."); } - private void tradeIDNumericUpDown_ValueChanged(object sender, EventArgs e) + private void SetToolTipsForControls(IEnumerable controls, string text) { - if (Helpers.HandlersDisabled) + foreach (var control in controls) { - return; + toolTip.SetToolTip(control, text); + } + } + + public void LoadFromFile(int tradeID) + { + Helpers.DisableHandlers(); + curTradeData = new TradeData(tradeID); + tradeIDNumericUpDown.Value = tradeID; + speciesComboBox.SelectedIndex = curTradeData.species; + hpIVNumericUpDown.Value = curTradeData.hpIV; + atkIVNumericUpDown.Value = curTradeData.atkIV; + defIVNumericUpDown.Value = curTradeData.defIV; + speIVNumericUpDown.Value = curTradeData.speedIV; + spaIVNumericUpDown.Value = curTradeData.spAtkIV; + spdIVNumericUpDown.Value = curTradeData.spDefIV; + abilityComboBox.SelectedIndex = curTradeData.ability; + otIDNumericUpDown.Value = curTradeData.otID; + coolNumericUpDown.Value = curTradeData.cool; + beautyNumericUpDown.Value = curTradeData.beauty; + cuteNumericUpDown.Value = curTradeData.cute; + smartNumericUpDown.Value = curTradeData.smart; + toughNumericUpDown.Value = curTradeData.tough; + pidNumericUpDown.Value = curTradeData.pid; + heldItemComboBox.SelectedIndex = curTradeData.heldItem; + otGenderComboBox.SelectedIndex = curTradeData.otGender; + sheenNumericUpDown.Value = curTradeData.sheen; + langComboBox.SelectedIndex = curTradeData.language; + requestedComboBox.SelectedIndex = curTradeData.requestedSpecies; + unknownNumericUpDown.Value = curTradeData.unknown; + + otNameTextBox.Text = GetOTName(tradeID); + nicknameTextBox.Text = GetMonNickname(tradeID); + tradeDataGroupBox.Text = "Trade Data"; + textDataGroupBox.Text = "Text Data"; + this.Text = "Trade Editor"; + + tradeDirty = false; + textDirty = false; + + Helpers.EnableHandlers(); + } + + private void SaveTradeToFile() + { + Helpers.DisableHandlers(); + curTradeData.species = speciesComboBox.SelectedIndex; + curTradeData.hpIV = (int)hpIVNumericUpDown.Value; + curTradeData.atkIV = (int)atkIVNumericUpDown.Value; + curTradeData.defIV = (int)defIVNumericUpDown.Value; + curTradeData.speedIV = (int)speIVNumericUpDown.Value; + curTradeData.spAtkIV = (int)spaIVNumericUpDown.Value; + curTradeData.spDefIV = (int)spdIVNumericUpDown.Value; + curTradeData.ability = abilityComboBox.SelectedIndex; + curTradeData.otID = (int)otIDNumericUpDown.Value; + curTradeData.cool = (int)coolNumericUpDown.Value; + curTradeData.beauty = (int)beautyNumericUpDown.Value; + curTradeData.cute = (int)cuteNumericUpDown.Value; + curTradeData.smart = (int)smartNumericUpDown.Value; + curTradeData.tough = (int)toughNumericUpDown.Value; + curTradeData.pid = (int)pidNumericUpDown.Value; + curTradeData.heldItem = heldItemComboBox.SelectedIndex; + curTradeData.otGender = otGenderComboBox.SelectedIndex; + curTradeData.sheen = (int)sheenNumericUpDown.Value; + curTradeData.language = langComboBox.SelectedIndex; + curTradeData.requestedSpecies = requestedComboBox.SelectedIndex; + + if (RomInfo.gameFamily == RomInfo.GameFamilies.HGSS) + { + curTradeData.unknown = (int)unknownNumericUpDown.Value; + } + else + { + curTradeData.unknown = 0; } + curTradeData.SaveToFileDefaultDir((int)tradeIDNumericUpDown.Value, false); + tradeDataGroupBox.Text = "Trade Data"; + tradeDirty = false; + if (!textDirty) + { + this.Text = "Trade Editor"; + } + Helpers.EnableHandlers(); + } + + private void SaveTextDataToFile() + { + Helpers.DisableHandlers(); int tradeID = (int)tradeIDNumericUpDown.Value; - if (tradeID < 0 || tradeID >= TradeData.GetTradeCount()) + + if (tradeID < 0 || tradeID + TradeData.GetTradeCount() > tradeArchive.messages.Count) { - MessageBox.Show("Invalid Trade ID selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Can't save to text bank. Index is out of range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error("TradeEditor: Can't save to text bank. Index is out of range."); + Helpers.EnableHandlers(); return; } - LoadFromFile(tradeID); + // Nickname + tradeArchive.messages[tradeID] = nicknameTextBox.Text; - } + // OT Name + tradeArchive.messages[tradeID + TradeData.GetTradeCount()] = otNameTextBox.Text; - private void saveTradeButton_Click(object sender, EventArgs e) - { - SaveToFile(); + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + + // Reset the text data group box and dirty flags + textDataGroupBox.Text = "Text Data"; + textDirty = false; + if (!tradeDirty) + { + this.Text = "Trade Editor"; + } + Helpers.EnableHandlers(); } private int GetTextBankIndex() @@ -270,7 +312,7 @@ namespace DSPRE.Editors MessageBox.Show("Invalid game family for text bank index retrieval.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return 0; } - + } private string GetMonNickname(int tradeID) { @@ -291,29 +333,149 @@ namespace DSPRE.Editors msg = msg.Substring(0, otNameTextBox.MaxLength); } return msg; - } + } - private void saveTextDataButton_Click(object sender, EventArgs e) + private void RegisterMarkDirtyHandlers() { - Helpers.DisableHandlers(); - int tradeID = (int)tradeIDNumericUpDown.Value; + // ComboBoxes + speciesComboBox.SelectedIndexChanged += MarkDirty; + abilityComboBox.SelectedIndexChanged += MarkDirty; + heldItemComboBox.SelectedIndexChanged += MarkDirty; + otGenderComboBox.SelectedIndexChanged += MarkDirty; + langComboBox.SelectedIndexChanged += MarkDirty; + requestedComboBox.SelectedIndexChanged += MarkDirty; - if (tradeID < 0 || tradeID + TradeData.GetTradeCount() > tradeArchive.messages.Count) + // NumericUpDowns + hpIVNumericUpDown.ValueChanged += MarkDirty; + atkIVNumericUpDown.ValueChanged += MarkDirty; + defIVNumericUpDown.ValueChanged += MarkDirty; + speIVNumericUpDown.ValueChanged += MarkDirty; + spaIVNumericUpDown.ValueChanged += MarkDirty; + spdIVNumericUpDown.ValueChanged += MarkDirty; + otIDNumericUpDown.ValueChanged += MarkDirty; + coolNumericUpDown.ValueChanged += MarkDirty; + beautyNumericUpDown.ValueChanged += MarkDirty; + cuteNumericUpDown.ValueChanged += MarkDirty; + smartNumericUpDown.ValueChanged += MarkDirty; + toughNumericUpDown.ValueChanged += MarkDirty; + pidNumericUpDown.ValueChanged += MarkDirty; + sheenNumericUpDown.ValueChanged += MarkDirty; + unknownNumericUpDown.ValueChanged += MarkDirty; + + // TextBoxes + otNameTextBox.TextChanged += MarkDirty; + nicknameTextBox.TextChanged += MarkDirty; + } + + #region Handlers + + private void MarkDirty(object sender, EventArgs e) + { + if (Helpers.HandlersDisabled) { - MessageBox.Show("Can't save to text bank. Index is out of range.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - AppLogger.Error("TradeEditor: Can't save to text bank. Index is out of range."); - Helpers.EnableHandlers(); return; } - // Nickname - tradeArchive.messages[tradeID] = nicknameTextBox.Text; + Helpers.DisableHandlers(); - // OT Name - tradeArchive.messages[tradeID + TradeData.GetTradeCount()] = otNameTextBox.Text; + if (sender.Equals(otNameTextBox) || sender.Equals(nicknameTextBox)) + { + textDataGroupBox.Text = "Text Data*"; + this.Text = "Trade Editor*"; + textDirty = true; + } + else + { + tradeDataGroupBox.Text = "Trade Data*"; + this.Text = "Trade Editor*"; + tradeDirty = true; + } - tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); Helpers.EnableHandlers(); } + + private void tradeIDNumericUpDown_ValueChanged(object sender, EventArgs e) + { + if (Helpers.HandlersDisabled) + { + return; + } + + Helpers.DisableHandlers(); + + if (tradeDirty || textDirty) + { + DialogResult result = MessageBox.Show("You have unsaved changes. Do you want to save before changing the Trade ID?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + if (result == DialogResult.Yes) + { + SaveTradeToFile(); + SaveTextDataToFile(); + } + else if (result == DialogResult.Cancel) + { + // Revert the change + tradeIDNumericUpDown.Value = curTradeData.id; + Helpers.EnableHandlers(); + return; + } + } + + int tradeID = (int)tradeIDNumericUpDown.Value; + if (tradeID < 0 || tradeID >= TradeData.GetTradeCount()) + { + MessageBox.Show("Invalid Trade ID selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + LoadFromFile(tradeID); + + Helpers.EnableHandlers(); + + } + + private void saveTradeButton_Click(object sender, EventArgs e) + { + SaveTradeToFile(); + } + + private void saveTextDataButton_Click(object sender, EventArgs e) + { + SaveTextDataToFile(); + } + + private void saveAllButton_Click(object sender, EventArgs e) + { + SaveTradeToFile(); + SaveTextDataToFile(); + } + + private void TradeEditor_FormClosing(object sender, FormClosingEventArgs e) + { + if (tradeDirty || textDirty) + { + DialogResult result = MessageBox.Show("You have unsaved changes. Do you want to save before closing?", "Unsaved Changes", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); + if (result == DialogResult.Yes) + { + SaveTradeToFile(); + SaveTextDataToFile(); + } + else if (result == DialogResult.Cancel) + { + e.Cancel = true; // Cancel the closing + } + } + } + + #endregion + + private void addFileButton_Click(object sender, EventArgs e) + { + + } + + private void removeLastButton_Click(object sender, EventArgs e) + { + + } } } From 0ef89149a798132ff3e4c5221c568e2ab86d9be6 Mon Sep 17 00:00:00 2001 From: Yako Date: Fri, 25 Jul 2025 16:50:22 +0200 Subject: [PATCH 10/11] add logic for adding / removing files and fix issues with plat USA using the wrong path to the narc --- DS_Map/Editors/TradeEditor.cs | 57 ++++++++++++++++++++++++++++++++--- DS_Map/ROMFiles/TradeData.cs | 24 +++++++++++++-- DS_Map/RomInfo.cs | 2 +- 3 files changed, 76 insertions(+), 7 deletions(-) diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 931c01b..13b0e98 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -58,9 +59,11 @@ namespace DSPRE.Editors unknownNumericUpDown.Enabled = false; } + // PLAT: Overlay 6, 0x8050-0x8053: dc f5 f0 fb -> 00 00 00 00 to dummy out ASSERT + // Disable buttons until trade expansion is implemented - addFileButton.Enabled = false; - removeLastButton.Enabled = false; + //addFileButton.Enabled = false; + //removeLastButton.Enabled = false; tradeArchive = new TextArchive(GetTextBankIndex()); LoadFromFile(0); @@ -170,6 +173,7 @@ namespace DSPRE.Editors { Helpers.DisableHandlers(); curTradeData = new TradeData(tradeID); + tradeArchive = new TextArchive(GetTextBankIndex()); tradeIDNumericUpDown.Value = tradeID; speciesComboBox.SelectedIndex = curTradeData.species; hpIVNumericUpDown.Value = curTradeData.hpIV; @@ -466,16 +470,61 @@ namespace DSPRE.Editors } } - #endregion - private void addFileButton_Click(object sender, EventArgs e) { + TradeData newTrade = new TradeData(TradeData.GetTradeCount()); + newTrade.SaveToFileDefaultDir(newTrade.id, false); + tradeIDNumericUpDown.Maximum = TradeData.GetTradeCount() - 1; // Update the maximum value + // Adjust text archive to accommodate the new trade + int lastNicknameIndex = TradeData.GetTradeCount() - 1; + tradeArchive.messages.Insert(lastNicknameIndex, "Nickname"); + tradeArchive.messages.Add("OT Name"); + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + + MessageBox.Show($"Added new trade with id {newTrade.id}", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } private void removeLastButton_Click(object sender, EventArgs e) { + DialogResult result = MessageBox.Show("Are you sure you want to remove the last trade? This action cannot be undone.", "Confirm Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); + if (result != DialogResult.Yes) + { + return; // User cancelled the removal + } + + if (TradeData.GetTradeCount() <= 1) + { + MessageBox.Show("Cannot remove the last trade.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + + int lastTradeID = TradeData.GetTradeCount() - 1; + + try + { + File.Delete(RomInfo.gameDirs[RomInfo.DirNames.tradeData].unpackedDir + "\\" + lastTradeID.ToString("D4")); + } + catch (Exception ex) + { + MessageBox.Show($"Failed to delete trade file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + AppLogger.Error($"TradeEditor: Failed to delete trade file for ID {lastTradeID}: {ex.Message}"); + return; + } + + tradeIDNumericUpDown.Maximum = lastTradeID - 1; // Update the maximum value + // Adjust text archive to remove the last trade's text + + if (tradeArchive.messages.Count > lastTradeID) + { + tradeArchive.messages.RemoveAt(lastTradeID); // Remove Nickname + tradeArchive.messages.RemoveAt(tradeArchive.messages.Count - 1); // Remove OT Name + tradeArchive.SaveToFileDefaultDir(GetTextBankIndex(), false); + } } + + #endregion + } } diff --git a/DS_Map/ROMFiles/TradeData.cs b/DS_Map/ROMFiles/TradeData.cs index 4091eb9..d6ec594 100644 --- a/DS_Map/ROMFiles/TradeData.cs +++ b/DS_Map/ROMFiles/TradeData.cs @@ -36,7 +36,7 @@ namespace DSPRE.ROMFiles public int requestedSpecies; public int unknown; // unused? - public TradeData(Stream stream, int id) + public TradeData(int id, Stream stream) { this.id = id; using (BinaryReader br = new BinaryReader(stream)) @@ -70,7 +70,27 @@ namespace DSPRE.ROMFiles } } - public TradeData(int id) : this(new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Open), id) { } + public TradeData(int id) : this(id, GetStream(id)) { } + + private static Stream GetStream(int id) + { + + if (!File.Exists(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"))) + { + // If the file does not exist, create it with default values + FileStream fileStream = new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Create); + fileStream.Write(new byte[0x50], 0, 0x50); // create an empty file + if (RomInfo.gameFamily == GameFamilies.HGSS) + { + fileStream.Write(new byte[0x04], 0, 0x04); // HGSS only + } + fileStream.Seek(0, SeekOrigin.Begin); // Reset the position to the start of the file + return fileStream; + } + + return new FileStream(RomInfo.gameDirs[DirNames.tradeData].unpackedDir + "\\" + id.ToString("D4"), FileMode.Open); + + } public override byte[] ToByteArray() { diff --git a/DS_Map/RomInfo.cs b/DS_Map/RomInfo.cs index 02c653b..2457184 100644 --- a/DS_Map/RomInfo.cs +++ b/DS_Map/RomInfo.cs @@ -1539,7 +1539,7 @@ namespace DSPRE [DirNames.tradeData] = @"data\fielddata\pokemon_trade\fld_trade.narc" }; - if (gameLanguage != GameLanguages.Japanese) + if (gameLanguage != GameLanguages.Japanese && gameLanguage != GameLanguages.English) { packedDirsDict[DirNames.tradeData] = $@"data\resource\{GetLangResFolderName()}\pokemon_trade\fld_trade.narc"; } From 18febc480a4c0217b395f2d89e0d1a606c162c9c Mon Sep 17 00:00:00 2001 From: Yako Date: Mon, 28 Jul 2025 14:23:05 +0200 Subject: [PATCH 11/11] final touches for trade editor --- DS_Map/Editors/TradeEditor.Designer.cs | 10 +++++----- DS_Map/Editors/TradeEditor.cs | 20 ++++++++++++++++++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/DS_Map/Editors/TradeEditor.Designer.cs b/DS_Map/Editors/TradeEditor.Designer.cs index 454e2b4..e0f4735 100644 --- a/DS_Map/Editors/TradeEditor.Designer.cs +++ b/DS_Map/Editors/TradeEditor.Designer.cs @@ -240,7 +240,7 @@ // // requestedComboBox // - this.requestedComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.requestedComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.requestedComboBox.FormattingEnabled = true; this.requestedComboBox.Location = new System.Drawing.Point(165, 44); this.requestedComboBox.Name = "requestedComboBox"; @@ -326,7 +326,7 @@ // // abilityComboBox // - this.abilityComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.abilityComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.abilityComboBox.FormattingEnabled = true; this.abilityComboBox.Location = new System.Drawing.Point(6, 218); this.abilityComboBox.Name = "abilityComboBox"; @@ -381,7 +381,7 @@ // // langComboBox // - this.langComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.langComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.langComboBox.FormattingEnabled = true; this.langComboBox.Location = new System.Drawing.Point(6, 166); this.langComboBox.Name = "langComboBox"; @@ -400,7 +400,7 @@ // // heldItemComboBox // - this.heldItemComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.heldItemComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.heldItemComboBox.FormattingEnabled = true; this.heldItemComboBox.Location = new System.Drawing.Point(6, 98); this.heldItemComboBox.Name = "heldItemComboBox"; @@ -665,7 +665,7 @@ // // speciesComboBox // - this.speciesComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.Suggest; + this.speciesComboBox.AutoCompleteMode = System.Windows.Forms.AutoCompleteMode.SuggestAppend; this.speciesComboBox.FormattingEnabled = true; this.speciesComboBox.Location = new System.Drawing.Point(6, 30); this.speciesComboBox.Name = "speciesComboBox"; diff --git a/DS_Map/Editors/TradeEditor.cs b/DS_Map/Editors/TradeEditor.cs index 13b0e98..a7bad41 100644 --- a/DS_Map/Editors/TradeEditor.cs +++ b/DS_Map/Editors/TradeEditor.cs @@ -41,6 +41,8 @@ namespace DSPRE.Editors { Helpers.DisableHandlers(); + AppLogger.Debug("TradeEditor: Initializing Trade Editor."); + InitializeComponent(); InitLimits(); InitDataRanges(); @@ -62,8 +64,8 @@ namespace DSPRE.Editors // PLAT: Overlay 6, 0x8050-0x8053: dc f5 f0 fb -> 00 00 00 00 to dummy out ASSERT // Disable buttons until trade expansion is implemented - //addFileButton.Enabled = false; - //removeLastButton.Enabled = false; + addFileButton.Enabled = false; + removeLastButton.Enabled = false; tradeArchive = new TextArchive(GetTextBankIndex()); LoadFromFile(0); @@ -126,19 +128,24 @@ namespace DSPRE.Editors { // Species Names speciesComboBox.DataSource = RomInfo.GetPokemonNames(); + speciesComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; requestedComboBox.DataSource = RomInfo.GetPokemonNames(); + requestedComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; // Abilities abilityComboBox.DataSource = RomInfo.GetAbilityNames(); + abilityComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; // Held Items heldItemComboBox.DataSource = RomInfo.GetItemNames(); + heldItemComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; // OT Gender otGenderComboBox.DataSource = new string[] { "Male", "Female" }; // Languages langComboBox.DataSource = Enum.GetNames(typeof(OriginLang)); + langComboBox.AutoCompleteSource = AutoCompleteSource.ListItems; } private void SetToolTips() @@ -159,6 +166,13 @@ namespace DSPRE.Editors $"The Original Trainer's name.\nStored in text bank {GetTextBankIndex()}.\nAt most {otNameTextBox.MaxLength} characters."); SetToolTipsForControls(new Control[] { nicknameTextBox, nicknameLabel }, $"The nickname of the Pokémon.\nStored in text bank {GetTextBankIndex()}.\nAt most {nicknameTextBox.MaxLength} characters."); + + SetToolTipsForControls(new Control[] { saveTradeButton }, "Save the current trade data to file."); + SetToolTipsForControls(new Control[] { saveTextDataButton }, "Save the current text data to file."); + SetToolTipsForControls(new Control[] { saveAllButton }, "Save both trade data and text data to file."); + + // ToDo: Remove these tooltips when the features are implemented + SetToolTipsForControls(new Control[] { addFileButton, removeLastButton }, "Coming soon!\nThis feature is not yet implemented.\nIt will allow you to add or remove trades from the trade data file."); } private void SetToolTipsForControls(IEnumerable controls, string text) @@ -249,6 +263,7 @@ namespace DSPRE.Editors { this.Text = "Trade Editor"; } + AppLogger.Debug($"TradeEditor: Saved trade data for ID {curTradeData.id}."); Helpers.EnableHandlers(); } @@ -280,6 +295,7 @@ namespace DSPRE.Editors { this.Text = "Trade Editor"; } + AppLogger.Debug($"TradeEditor: Saved trade text data to message bank {GetTextBankIndex()}"); Helpers.EnableHandlers(); }