From cb4814bcdf074ce0e23a1ecc5dd6a3cde8dd062c Mon Sep 17 00:00:00 2001 From: Yako Date: Thu, 24 Jul 2025 18:47:23 +0200 Subject: [PATCH] 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)