From d8aa83259e891ccba6e91f842decb9df9b97d6e1 Mon Sep 17 00:00:00 2001 From: Mixone-FinallyHere Date: Thu, 19 Jun 2025 11:27:51 +0200 Subject: [PATCH 1/2] Parsing and BattlePockets need fix still --- DS_Map/Editors/ItemEditor.Designer.cs | 772 +++++++++++++++++++++++++- DS_Map/Editors/ItemEditor.cs | 254 ++++++++- DS_Map/Editors/ItemEditor.resx | 3 + DS_Map/ROMFiles/ItemData.cs | 118 ++-- 4 files changed, 1063 insertions(+), 84 deletions(-) diff --git a/DS_Map/Editors/ItemEditor.Designer.cs b/DS_Map/Editors/ItemEditor.Designer.cs index 78cf2f8..ba50788 100644 --- a/DS_Map/Editors/ItemEditor.Designer.cs +++ b/DS_Map/Editors/ItemEditor.Designer.cs @@ -28,6 +28,7 @@ /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); this.itemNumberNumericUpDown = new System.Windows.Forms.NumericUpDown(); this.holdEffectComboBox = new System.Windows.Forms.ComboBox(); this.fieldPocketComboBox = new System.Windows.Forms.ComboBox(); @@ -59,6 +60,7 @@ this.naturalGiftTypeComboBox = new System.Windows.Forms.ComboBox(); this.checksFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); this.checksGroupBox = new System.Windows.Forms.GroupBox(); + this.partyUseCheckBox = new System.Windows.Forms.CheckBox(); this.canSelectCheckBox = new System.Windows.Forms.CheckBox(); this.preventTossCheckBox = new System.Windows.Forms.CheckBox(); this.priceFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); @@ -70,7 +72,65 @@ this.fieldFunctionLabel = new System.Windows.Forms.Label(); this.fieldFunctionComboBox = new System.Windows.Forms.ComboBox(); this.battleFunctionLabel = new System.Windows.Forms.Label(); - this.partyUseCheckBox = new System.Windows.Forms.CheckBox(); + this.itemParamsTabControl = new System.Windows.Forms.TabControl(); + this.statusHealtTabPage = new System.Windows.Forms.TabPage(); + this.levelUpEvolveTabPage = new System.Windows.Forms.TabPage(); + this.statStagesTabPage = new System.Windows.Forms.TabPage(); + this.hpPpRestoreTabPage = new System.Windows.Forms.TabPage(); + this.evsTabPage = new System.Windows.Forms.TabPage(); + this.friendshipTabPage = new System.Windows.Forms.TabPage(); + this.slpHealCheckBox = new System.Windows.Forms.CheckBox(); + this.psnHealCheckBox = new System.Windows.Forms.CheckBox(); + this.brnHealCheckBox = new System.Windows.Forms.CheckBox(); + this.frzHealCheckBox = new System.Windows.Forms.CheckBox(); + this.przHealCheckBox = new System.Windows.Forms.CheckBox(); + this.cfsHealCheckBox = new System.Windows.Forms.CheckBox(); + this.infHealCheckBox = new System.Windows.Forms.CheckBox(); + this.guardSpecCheckBox = new System.Windows.Forms.CheckBox(); + this.reviveCheckBox = new System.Windows.Forms.CheckBox(); + this.reviveAllCheckBox = new System.Windows.Forms.CheckBox(); + this.levelUpCheckBox = new System.Windows.Forms.CheckBox(); + this.evolveCheckBox = new System.Windows.Forms.CheckBox(); + this.atkStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.defStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.label3 = new System.Windows.Forms.Label(); + this.spAtkStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.label4 = new System.Windows.Forms.Label(); + this.spDefStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.label5 = new System.Windows.Forms.Label(); + this.speedStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.label6 = new System.Windows.Forms.Label(); + this.accuracyStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.label7 = new System.Windows.Forms.Label(); + this.critRateStagesNumeric = new System.Windows.Forms.NumericUpDown(); + this.hpRestoreCheckBox = new System.Windows.Forms.CheckBox(); + this.ppRestoreCheckBox = new System.Windows.Forms.CheckBox(); + this.ppUpsCheckBox = new System.Windows.Forms.CheckBox(); + this.ppMaxCheckBox = new System.Windows.Forms.CheckBox(); + this.ppRestoreAllCheckBox = new System.Windows.Forms.CheckBox(); + this.hpRestoreParamNumeric = new System.Windows.Forms.NumericUpDown(); + this.ppRestoreParamNumeric = new System.Windows.Forms.NumericUpDown(); + this.evHpValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.evHpCheckBox = new System.Windows.Forms.CheckBox(); + this.evAtkValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.evAtkCheckBox = new System.Windows.Forms.CheckBox(); + this.evDefValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.evDefCheckBox = new System.Windows.Forms.CheckBox(); + this.evSpeedValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.evSpeedCheckBox = new System.Windows.Forms.CheckBox(); + this.evSpAtkValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.evSpAtkCheckBox = new System.Windows.Forms.CheckBox(); + this.evSpDefValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.evSpDefCheckBox = new System.Windows.Forms.CheckBox(); + this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); + this.friendshipLowValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.friendshipLowCheckBox = new System.Windows.Forms.CheckBox(); + this.friendshipMidValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.friendshipMidCheckBox = new System.Windows.Forms.CheckBox(); + this.friendshipHighValueNumeric = new System.Windows.Forms.NumericUpDown(); + this.friendshipHighCheckBox = new System.Windows.Forms.CheckBox(); ((System.ComponentModel.ISupportInitialize)(this.itemNumberNumericUpDown)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.priceNumericUpDown)).BeginInit(); this.tableLayoutPanel1.SuspendLayout(); @@ -91,6 +151,31 @@ this.priceGroupBox.SuspendLayout(); this.functionsFlowLayoutPanel.SuspendLayout(); this.functionsGroupBox.SuspendLayout(); + this.itemParamsTabControl.SuspendLayout(); + this.statusHealtTabPage.SuspendLayout(); + this.levelUpEvolveTabPage.SuspendLayout(); + this.statStagesTabPage.SuspendLayout(); + this.hpPpRestoreTabPage.SuspendLayout(); + this.evsTabPage.SuspendLayout(); + this.friendshipTabPage.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.atkStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.defStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.spAtkStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.spDefStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.speedStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.accuracyStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.critRateStagesNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.hpRestoreParamNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.ppRestoreParamNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.evHpValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.evAtkValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.evDefValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.evSpeedValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.evSpAtkValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.evSpDefValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.friendshipLowValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.friendshipMidValueNumeric)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.friendshipHighValueNumeric)).BeginInit(); this.SuspendLayout(); // // itemNumberNumericUpDown @@ -167,6 +252,7 @@ this.tableLayoutPanel1.Controls.Add(this.checksFlowLayoutPanel, 2, 1); this.tableLayoutPanel1.Controls.Add(this.priceFlowLayoutPanel, 3, 1); this.tableLayoutPanel1.Controls.Add(this.functionsFlowLayoutPanel, 0, 3); + this.tableLayoutPanel1.Controls.Add(this.itemParamsTabControl, 2, 2); this.tableLayoutPanel1.Location = new System.Drawing.Point(12, 12); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 4; @@ -432,6 +518,17 @@ this.checksGroupBox.TabStop = false; this.checksGroupBox.Text = "Checks"; // + // partyUseCheckBox + // + this.partyUseCheckBox.AutoSize = true; + this.partyUseCheckBox.Location = new System.Drawing.Point(136, 39); + this.partyUseCheckBox.Name = "partyUseCheckBox"; + this.partyUseCheckBox.Size = new System.Drawing.Size(72, 17); + this.partyUseCheckBox.TabIndex = 2; + this.partyUseCheckBox.Text = "Party Use"; + this.partyUseCheckBox.UseVisualStyleBackColor = true; + this.partyUseCheckBox.CheckedChanged += new System.EventHandler(this.partyUseCheckBox_CheckedChanged); + // // canSelectCheckBox // this.canSelectCheckBox.AutoSize = true; @@ -547,16 +644,581 @@ this.battleFunctionLabel.Text = "Battle Function"; this.battleFunctionLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // partyUseCheckBox + // itemParamsTabControl // - this.partyUseCheckBox.AutoSize = true; - this.partyUseCheckBox.Location = new System.Drawing.Point(136, 39); - this.partyUseCheckBox.Name = "partyUseCheckBox"; - this.partyUseCheckBox.Size = new System.Drawing.Size(72, 17); - this.partyUseCheckBox.TabIndex = 2; - this.partyUseCheckBox.Text = "Party Use"; - this.partyUseCheckBox.UseVisualStyleBackColor = true; - this.partyUseCheckBox.CheckedChanged += new System.EventHandler(this.partyUseCheckBox_CheckedChanged); + this.tableLayoutPanel1.SetColumnSpan(this.itemParamsTabControl, 2); + this.itemParamsTabControl.Controls.Add(this.statusHealtTabPage); + this.itemParamsTabControl.Controls.Add(this.levelUpEvolveTabPage); + this.itemParamsTabControl.Controls.Add(this.statStagesTabPage); + this.itemParamsTabControl.Controls.Add(this.hpPpRestoreTabPage); + this.itemParamsTabControl.Controls.Add(this.evsTabPage); + this.itemParamsTabControl.Controls.Add(this.friendshipTabPage); + this.itemParamsTabControl.Location = new System.Drawing.Point(535, 283); + this.itemParamsTabControl.Name = "itemParamsTabControl"; + this.tableLayoutPanel1.SetRowSpan(this.itemParamsTabControl, 2); + this.itemParamsTabControl.SelectedIndex = 0; + this.itemParamsTabControl.Size = new System.Drawing.Size(526, 277); + this.itemParamsTabControl.TabIndex = 17; + // + // statusHealtTabPage + // + this.statusHealtTabPage.BackColor = System.Drawing.SystemColors.Control; + this.statusHealtTabPage.Controls.Add(this.reviveAllCheckBox); + this.statusHealtTabPage.Controls.Add(this.reviveCheckBox); + this.statusHealtTabPage.Controls.Add(this.guardSpecCheckBox); + this.statusHealtTabPage.Controls.Add(this.infHealCheckBox); + this.statusHealtTabPage.Controls.Add(this.cfsHealCheckBox); + this.statusHealtTabPage.Controls.Add(this.przHealCheckBox); + this.statusHealtTabPage.Controls.Add(this.frzHealCheckBox); + this.statusHealtTabPage.Controls.Add(this.brnHealCheckBox); + this.statusHealtTabPage.Controls.Add(this.psnHealCheckBox); + this.statusHealtTabPage.Controls.Add(this.slpHealCheckBox); + this.statusHealtTabPage.Location = new System.Drawing.Point(4, 22); + this.statusHealtTabPage.Name = "statusHealtTabPage"; + this.statusHealtTabPage.Padding = new System.Windows.Forms.Padding(3); + this.statusHealtTabPage.Size = new System.Drawing.Size(518, 251); + this.statusHealtTabPage.TabIndex = 0; + this.statusHealtTabPage.Text = "Status Heals"; + // + // levelUpEvolveTabPage + // + this.levelUpEvolveTabPage.BackColor = System.Drawing.SystemColors.Control; + this.levelUpEvolveTabPage.Controls.Add(this.evolveCheckBox); + this.levelUpEvolveTabPage.Controls.Add(this.levelUpCheckBox); + this.levelUpEvolveTabPage.Location = new System.Drawing.Point(4, 22); + this.levelUpEvolveTabPage.Name = "levelUpEvolveTabPage"; + this.levelUpEvolveTabPage.Padding = new System.Windows.Forms.Padding(3); + this.levelUpEvolveTabPage.Size = new System.Drawing.Size(518, 251); + this.levelUpEvolveTabPage.TabIndex = 1; + this.levelUpEvolveTabPage.Text = "Level Up & Evolve"; + // + // statStagesTabPage + // + this.statStagesTabPage.BackColor = System.Drawing.SystemColors.Control; + this.statStagesTabPage.Controls.Add(this.label7); + this.statStagesTabPage.Controls.Add(this.critRateStagesNumeric); + this.statStagesTabPage.Controls.Add(this.label6); + this.statStagesTabPage.Controls.Add(this.accuracyStagesNumeric); + this.statStagesTabPage.Controls.Add(this.label5); + this.statStagesTabPage.Controls.Add(this.speedStagesNumeric); + this.statStagesTabPage.Controls.Add(this.label4); + this.statStagesTabPage.Controls.Add(this.spDefStagesNumeric); + this.statStagesTabPage.Controls.Add(this.label3); + this.statStagesTabPage.Controls.Add(this.spAtkStagesNumeric); + this.statStagesTabPage.Controls.Add(this.label2); + this.statStagesTabPage.Controls.Add(this.defStagesNumeric); + this.statStagesTabPage.Controls.Add(this.label1); + this.statStagesTabPage.Controls.Add(this.atkStagesNumeric); + this.statStagesTabPage.Location = new System.Drawing.Point(4, 22); + this.statStagesTabPage.Name = "statStagesTabPage"; + this.statStagesTabPage.Padding = new System.Windows.Forms.Padding(3); + this.statStagesTabPage.Size = new System.Drawing.Size(518, 251); + this.statStagesTabPage.TabIndex = 2; + this.statStagesTabPage.Text = "Stat Stages"; + // + // hpPpRestoreTabPage + // + this.hpPpRestoreTabPage.BackColor = System.Drawing.SystemColors.Control; + this.hpPpRestoreTabPage.Controls.Add(this.ppRestoreParamNumeric); + this.hpPpRestoreTabPage.Controls.Add(this.hpRestoreParamNumeric); + this.hpPpRestoreTabPage.Controls.Add(this.ppRestoreAllCheckBox); + this.hpPpRestoreTabPage.Controls.Add(this.ppMaxCheckBox); + this.hpPpRestoreTabPage.Controls.Add(this.ppUpsCheckBox); + this.hpPpRestoreTabPage.Controls.Add(this.ppRestoreCheckBox); + this.hpPpRestoreTabPage.Controls.Add(this.hpRestoreCheckBox); + this.hpPpRestoreTabPage.Location = new System.Drawing.Point(4, 22); + this.hpPpRestoreTabPage.Name = "hpPpRestoreTabPage"; + this.hpPpRestoreTabPage.Padding = new System.Windows.Forms.Padding(3); + this.hpPpRestoreTabPage.Size = new System.Drawing.Size(518, 251); + this.hpPpRestoreTabPage.TabIndex = 3; + this.hpPpRestoreTabPage.Text = "HP/PP Restore"; + // + // evsTabPage + // + this.evsTabPage.BackColor = System.Drawing.SystemColors.Control; + this.evsTabPage.Controls.Add(this.evSpDefValueNumeric); + this.evsTabPage.Controls.Add(this.evSpDefCheckBox); + this.evsTabPage.Controls.Add(this.evSpAtkValueNumeric); + this.evsTabPage.Controls.Add(this.evSpAtkCheckBox); + this.evsTabPage.Controls.Add(this.evSpeedValueNumeric); + this.evsTabPage.Controls.Add(this.evSpeedCheckBox); + this.evsTabPage.Controls.Add(this.evDefValueNumeric); + this.evsTabPage.Controls.Add(this.evDefCheckBox); + this.evsTabPage.Controls.Add(this.evAtkValueNumeric); + this.evsTabPage.Controls.Add(this.evAtkCheckBox); + this.evsTabPage.Controls.Add(this.evHpValueNumeric); + this.evsTabPage.Controls.Add(this.evHpCheckBox); + this.evsTabPage.Location = new System.Drawing.Point(4, 22); + this.evsTabPage.Name = "evsTabPage"; + this.evsTabPage.Padding = new System.Windows.Forms.Padding(3); + this.evsTabPage.Size = new System.Drawing.Size(518, 251); + this.evsTabPage.TabIndex = 4; + this.evsTabPage.Text = "EVs"; + // + // friendshipTabPage + // + this.friendshipTabPage.BackColor = System.Drawing.SystemColors.Control; + this.friendshipTabPage.Controls.Add(this.friendshipHighValueNumeric); + this.friendshipTabPage.Controls.Add(this.friendshipHighCheckBox); + this.friendshipTabPage.Controls.Add(this.friendshipMidValueNumeric); + this.friendshipTabPage.Controls.Add(this.friendshipMidCheckBox); + this.friendshipTabPage.Controls.Add(this.friendshipLowValueNumeric); + this.friendshipTabPage.Controls.Add(this.friendshipLowCheckBox); + this.friendshipTabPage.Location = new System.Drawing.Point(4, 22); + this.friendshipTabPage.Name = "friendshipTabPage"; + this.friendshipTabPage.Padding = new System.Windows.Forms.Padding(3); + this.friendshipTabPage.Size = new System.Drawing.Size(518, 251); + this.friendshipTabPage.TabIndex = 5; + this.friendshipTabPage.Text = "Friendship"; + // + // slpHealCheckBox + // + this.slpHealCheckBox.AutoSize = true; + this.slpHealCheckBox.Location = new System.Drawing.Point(16, 23); + this.slpHealCheckBox.Name = "slpHealCheckBox"; + this.slpHealCheckBox.Size = new System.Drawing.Size(83, 17); + this.slpHealCheckBox.TabIndex = 0; + this.slpHealCheckBox.Text = "Heals Sleep"; + this.slpHealCheckBox.UseVisualStyleBackColor = true; + // + // psnHealCheckBox + // + this.psnHealCheckBox.AutoSize = true; + this.psnHealCheckBox.Location = new System.Drawing.Point(16, 46); + this.psnHealCheckBox.Name = "psnHealCheckBox"; + this.psnHealCheckBox.Size = new System.Drawing.Size(88, 17); + this.psnHealCheckBox.TabIndex = 1; + this.psnHealCheckBox.Text = "Heals Poison"; + this.psnHealCheckBox.UseVisualStyleBackColor = true; + // + // brnHealCheckBox + // + this.brnHealCheckBox.AutoSize = true; + this.brnHealCheckBox.Location = new System.Drawing.Point(16, 69); + this.brnHealCheckBox.Name = "brnHealCheckBox"; + this.brnHealCheckBox.Size = new System.Drawing.Size(78, 17); + this.brnHealCheckBox.TabIndex = 2; + this.brnHealCheckBox.Text = "Heals Burn"; + this.brnHealCheckBox.UseVisualStyleBackColor = true; + // + // frzHealCheckBox + // + this.frzHealCheckBox.AutoSize = true; + this.frzHealCheckBox.Location = new System.Drawing.Point(16, 92); + this.frzHealCheckBox.Name = "frzHealCheckBox"; + this.frzHealCheckBox.Size = new System.Drawing.Size(88, 17); + this.frzHealCheckBox.TabIndex = 3; + this.frzHealCheckBox.Text = "Heals Freeze"; + this.frzHealCheckBox.UseVisualStyleBackColor = true; + // + // przHealCheckBox + // + this.przHealCheckBox.AutoSize = true; + this.przHealCheckBox.Location = new System.Drawing.Point(16, 115); + this.przHealCheckBox.Name = "przHealCheckBox"; + this.przHealCheckBox.Size = new System.Drawing.Size(97, 17); + this.przHealCheckBox.TabIndex = 4; + this.przHealCheckBox.Text = "Heals Paralysis"; + this.przHealCheckBox.UseVisualStyleBackColor = true; + // + // cfsHealCheckBox + // + this.cfsHealCheckBox.AutoSize = true; + this.cfsHealCheckBox.Location = new System.Drawing.Point(16, 138); + this.cfsHealCheckBox.Name = "cfsHealCheckBox"; + this.cfsHealCheckBox.Size = new System.Drawing.Size(103, 17); + this.cfsHealCheckBox.TabIndex = 5; + this.cfsHealCheckBox.Text = "Heals Confusion"; + this.cfsHealCheckBox.UseVisualStyleBackColor = true; + // + // infHealCheckBox + // + this.infHealCheckBox.AutoSize = true; + this.infHealCheckBox.Location = new System.Drawing.Point(135, 23); + this.infHealCheckBox.Name = "infHealCheckBox"; + this.infHealCheckBox.Size = new System.Drawing.Size(101, 17); + this.infHealCheckBox.TabIndex = 6; + this.infHealCheckBox.Text = "Heals All Health"; + this.infHealCheckBox.UseVisualStyleBackColor = true; + // + // guardSpecCheckBox + // + this.guardSpecCheckBox.AutoSize = true; + this.guardSpecCheckBox.Location = new System.Drawing.Point(135, 46); + this.guardSpecCheckBox.Name = "guardSpecCheckBox"; + this.guardSpecCheckBox.Size = new System.Drawing.Size(102, 17); + this.guardSpecCheckBox.TabIndex = 7; + this.guardSpecCheckBox.Text = "Set Guard Spec"; + this.guardSpecCheckBox.UseVisualStyleBackColor = true; + // + // reviveCheckBox + // + this.reviveCheckBox.AutoSize = true; + this.reviveCheckBox.Location = new System.Drawing.Point(262, 23); + this.reviveCheckBox.Name = "reviveCheckBox"; + this.reviveCheckBox.Size = new System.Drawing.Size(92, 17); + this.reviveCheckBox.TabIndex = 8; + this.reviveCheckBox.Text = "Revive Single"; + this.reviveCheckBox.UseVisualStyleBackColor = true; + // + // reviveAllCheckBox + // + this.reviveAllCheckBox.AutoSize = true; + this.reviveAllCheckBox.Location = new System.Drawing.Point(262, 46); + this.reviveAllCheckBox.Name = "reviveAllCheckBox"; + this.reviveAllCheckBox.Size = new System.Drawing.Size(79, 17); + this.reviveAllCheckBox.TabIndex = 9; + this.reviveAllCheckBox.Text = "Revives All"; + this.reviveAllCheckBox.UseVisualStyleBackColor = true; + // + // levelUpCheckBox + // + this.levelUpCheckBox.AutoSize = true; + this.levelUpCheckBox.Location = new System.Drawing.Point(26, 22); + this.levelUpCheckBox.Name = "levelUpCheckBox"; + this.levelUpCheckBox.Size = new System.Drawing.Size(69, 17); + this.levelUpCheckBox.TabIndex = 10; + this.levelUpCheckBox.Text = "Level Up"; + this.levelUpCheckBox.UseVisualStyleBackColor = true; + // + // evolveCheckBox + // + this.evolveCheckBox.AutoSize = true; + this.evolveCheckBox.Location = new System.Drawing.Point(135, 22); + this.evolveCheckBox.Name = "evolveCheckBox"; + this.evolveCheckBox.Size = new System.Drawing.Size(64, 17); + this.evolveCheckBox.TabIndex = 11; + this.evolveCheckBox.Text = "Evolves"; + this.evolveCheckBox.UseVisualStyleBackColor = true; + // + // atkStagesNumeric + // + this.atkStagesNumeric.Location = new System.Drawing.Point(96, 14); + this.atkStagesNumeric.Name = "atkStagesNumeric"; + this.atkStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.atkStagesNumeric.TabIndex = 0; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(16, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(23, 13); + this.label1.TabIndex = 1; + this.label1.Text = "Atk"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(16, 51); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(24, 13); + this.label2.TabIndex = 3; + this.label2.Text = "Def"; + // + // defStagesNumeric + // + this.defStagesNumeric.Location = new System.Drawing.Point(96, 49); + this.defStagesNumeric.Name = "defStagesNumeric"; + this.defStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.defStagesNumeric.TabIndex = 2; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(16, 86); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(39, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Sp Atk"; + // + // spAtkStagesNumeric + // + this.spAtkStagesNumeric.Location = new System.Drawing.Point(96, 84); + this.spAtkStagesNumeric.Name = "spAtkStagesNumeric"; + this.spAtkStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.spAtkStagesNumeric.TabIndex = 4; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(16, 118); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(40, 13); + this.label4.TabIndex = 7; + this.label4.Text = "Sp Def"; + // + // spDefStagesNumeric + // + this.spDefStagesNumeric.Location = new System.Drawing.Point(96, 116); + this.spDefStagesNumeric.Name = "spDefStagesNumeric"; + this.spDefStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.spDefStagesNumeric.TabIndex = 6; + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(16, 147); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(38, 13); + this.label5.TabIndex = 9; + this.label5.Text = "Speed"; + // + // speedStagesNumeric + // + this.speedStagesNumeric.Location = new System.Drawing.Point(96, 145); + this.speedStagesNumeric.Name = "speedStagesNumeric"; + this.speedStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.speedStagesNumeric.TabIndex = 8; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(16, 176); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(52, 13); + this.label6.TabIndex = 11; + this.label6.Text = "Accuracy"; + // + // accuracyStagesNumeric + // + this.accuracyStagesNumeric.Location = new System.Drawing.Point(96, 174); + this.accuracyStagesNumeric.Name = "accuracyStagesNumeric"; + this.accuracyStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.accuracyStagesNumeric.TabIndex = 10; + // + // label7 + // + this.label7.AutoSize = true; + this.label7.Location = new System.Drawing.Point(16, 207); + this.label7.Name = "label7"; + this.label7.Size = new System.Drawing.Size(48, 13); + this.label7.TabIndex = 13; + this.label7.Text = "Crit Rate"; + // + // critRateStagesNumeric + // + this.critRateStagesNumeric.Location = new System.Drawing.Point(96, 205); + this.critRateStagesNumeric.Name = "critRateStagesNumeric"; + this.critRateStagesNumeric.Size = new System.Drawing.Size(42, 20); + this.critRateStagesNumeric.TabIndex = 12; + // + // hpRestoreCheckBox + // + this.hpRestoreCheckBox.AutoSize = true; + this.hpRestoreCheckBox.Location = new System.Drawing.Point(16, 22); + this.hpRestoreCheckBox.Name = "hpRestoreCheckBox"; + this.hpRestoreCheckBox.Size = new System.Drawing.Size(81, 17); + this.hpRestoreCheckBox.TabIndex = 11; + this.hpRestoreCheckBox.Text = "HP Restore"; + this.hpRestoreCheckBox.UseVisualStyleBackColor = true; + // + // ppRestoreCheckBox + // + this.ppRestoreCheckBox.AutoSize = true; + this.ppRestoreCheckBox.Location = new System.Drawing.Point(16, 56); + this.ppRestoreCheckBox.Name = "ppRestoreCheckBox"; + this.ppRestoreCheckBox.Size = new System.Drawing.Size(80, 17); + this.ppRestoreCheckBox.TabIndex = 12; + this.ppRestoreCheckBox.Text = "PP Restore"; + this.ppRestoreCheckBox.UseVisualStyleBackColor = true; + // + // ppUpsCheckBox + // + this.ppUpsCheckBox.AutoSize = true; + this.ppUpsCheckBox.Location = new System.Drawing.Point(16, 155); + this.ppUpsCheckBox.Name = "ppUpsCheckBox"; + this.ppUpsCheckBox.Size = new System.Drawing.Size(57, 17); + this.ppUpsCheckBox.TabIndex = 13; + this.ppUpsCheckBox.Text = "PP Up"; + this.ppUpsCheckBox.UseVisualStyleBackColor = true; + // + // ppMaxCheckBox + // + this.ppMaxCheckBox.AutoSize = true; + this.ppMaxCheckBox.Location = new System.Drawing.Point(16, 184); + this.ppMaxCheckBox.Name = "ppMaxCheckBox"; + this.ppMaxCheckBox.Size = new System.Drawing.Size(63, 17); + this.ppMaxCheckBox.TabIndex = 14; + this.ppMaxCheckBox.Text = "PP Max"; + this.ppMaxCheckBox.UseVisualStyleBackColor = true; + // + // ppRestoreAllCheckBox + // + this.ppRestoreAllCheckBox.AutoSize = true; + this.ppRestoreAllCheckBox.Location = new System.Drawing.Point(16, 105); + this.ppRestoreAllCheckBox.Name = "ppRestoreAllCheckBox"; + this.ppRestoreAllCheckBox.Size = new System.Drawing.Size(94, 17); + this.ppRestoreAllCheckBox.TabIndex = 15; + this.ppRestoreAllCheckBox.Text = "PP Restore All"; + this.ppRestoreAllCheckBox.UseVisualStyleBackColor = true; + // + // hpRestoreParamNumeric + // + this.hpRestoreParamNumeric.Location = new System.Drawing.Point(103, 21); + this.hpRestoreParamNumeric.Name = "hpRestoreParamNumeric"; + this.hpRestoreParamNumeric.Size = new System.Drawing.Size(57, 20); + this.hpRestoreParamNumeric.TabIndex = 16; + // + // ppRestoreParamNumeric + // + this.ppRestoreParamNumeric.Location = new System.Drawing.Point(103, 55); + this.ppRestoreParamNumeric.Name = "ppRestoreParamNumeric"; + this.ppRestoreParamNumeric.Size = new System.Drawing.Size(57, 20); + this.ppRestoreParamNumeric.TabIndex = 17; + // + // evHpValueNumeric + // + this.evHpValueNumeric.Location = new System.Drawing.Point(252, 36); + this.evHpValueNumeric.Name = "evHpValueNumeric"; + this.evHpValueNumeric.Size = new System.Drawing.Size(53, 20); + this.evHpValueNumeric.TabIndex = 18; + // + // evHpCheckBox + // + this.evHpCheckBox.AutoSize = true; + this.evHpCheckBox.Location = new System.Drawing.Point(165, 37); + this.evHpCheckBox.Name = "evHpCheckBox"; + this.evHpCheckBox.Size = new System.Drawing.Size(41, 17); + this.evHpCheckBox.TabIndex = 17; + this.evHpCheckBox.Text = "HP"; + this.evHpCheckBox.UseVisualStyleBackColor = true; + // + // evAtkValueNumeric + // + this.evAtkValueNumeric.Location = new System.Drawing.Point(252, 59); + this.evAtkValueNumeric.Name = "evAtkValueNumeric"; + this.evAtkValueNumeric.Size = new System.Drawing.Size(53, 20); + this.evAtkValueNumeric.TabIndex = 20; + // + // evAtkCheckBox + // + this.evAtkCheckBox.AutoSize = true; + this.evAtkCheckBox.Location = new System.Drawing.Point(165, 60); + this.evAtkCheckBox.Name = "evAtkCheckBox"; + this.evAtkCheckBox.Size = new System.Drawing.Size(42, 17); + this.evAtkCheckBox.TabIndex = 19; + this.evAtkCheckBox.Text = "Atk"; + this.evAtkCheckBox.UseVisualStyleBackColor = true; + // + // evDefValueNumeric + // + this.evDefValueNumeric.Location = new System.Drawing.Point(252, 85); + this.evDefValueNumeric.Name = "evDefValueNumeric"; + this.evDefValueNumeric.Size = new System.Drawing.Size(53, 20); + this.evDefValueNumeric.TabIndex = 22; + // + // evDefCheckBox + // + this.evDefCheckBox.AutoSize = true; + this.evDefCheckBox.Location = new System.Drawing.Point(165, 86); + this.evDefCheckBox.Name = "evDefCheckBox"; + this.evDefCheckBox.Size = new System.Drawing.Size(43, 17); + this.evDefCheckBox.TabIndex = 21; + this.evDefCheckBox.Text = "Def"; + this.evDefCheckBox.UseVisualStyleBackColor = true; + // + // evSpeedValueNumeric + // + this.evSpeedValueNumeric.Location = new System.Drawing.Point(252, 125); + this.evSpeedValueNumeric.Name = "evSpeedValueNumeric"; + this.evSpeedValueNumeric.Size = new System.Drawing.Size(53, 20); + this.evSpeedValueNumeric.TabIndex = 24; + // + // evSpeedCheckBox + // + this.evSpeedCheckBox.AutoSize = true; + this.evSpeedCheckBox.Location = new System.Drawing.Point(165, 126); + this.evSpeedCheckBox.Name = "evSpeedCheckBox"; + this.evSpeedCheckBox.Size = new System.Drawing.Size(57, 17); + this.evSpeedCheckBox.TabIndex = 23; + this.evSpeedCheckBox.Text = "Speed"; + this.evSpeedCheckBox.UseVisualStyleBackColor = true; + // + // evSpAtkValueNumeric + // + this.evSpAtkValueNumeric.Location = new System.Drawing.Point(252, 158); + this.evSpAtkValueNumeric.Name = "evSpAtkValueNumeric"; + this.evSpAtkValueNumeric.Size = new System.Drawing.Size(53, 20); + this.evSpAtkValueNumeric.TabIndex = 26; + // + // evSpAtkCheckBox + // + this.evSpAtkCheckBox.AutoSize = true; + this.evSpAtkCheckBox.Location = new System.Drawing.Point(165, 159); + this.evSpAtkCheckBox.Name = "evSpAtkCheckBox"; + this.evSpAtkCheckBox.Size = new System.Drawing.Size(58, 17); + this.evSpAtkCheckBox.TabIndex = 25; + this.evSpAtkCheckBox.Text = "Sp Atk"; + this.evSpAtkCheckBox.UseVisualStyleBackColor = true; + // + // evSpDefValueNumeric + // + this.evSpDefValueNumeric.Location = new System.Drawing.Point(252, 192); + this.evSpDefValueNumeric.Name = "evSpDefValueNumeric"; + this.evSpDefValueNumeric.Size = new System.Drawing.Size(53, 20); + this.evSpDefValueNumeric.TabIndex = 28; + // + // evSpDefCheckBox + // + this.evSpDefCheckBox.AutoSize = true; + this.evSpDefCheckBox.Location = new System.Drawing.Point(165, 193); + this.evSpDefCheckBox.Name = "evSpDefCheckBox"; + this.evSpDefCheckBox.Size = new System.Drawing.Size(59, 17); + this.evSpDefCheckBox.TabIndex = 27; + this.evSpDefCheckBox.Text = "Sp Def"; + this.evSpDefCheckBox.UseVisualStyleBackColor = true; + // + // friendshipLowValueNumeric + // + this.friendshipLowValueNumeric.Location = new System.Drawing.Point(226, 37); + this.friendshipLowValueNumeric.Name = "friendshipLowValueNumeric"; + this.friendshipLowValueNumeric.Size = new System.Drawing.Size(53, 20); + this.friendshipLowValueNumeric.TabIndex = 20; + // + // friendshipLowCheckBox + // + this.friendshipLowCheckBox.AutoSize = true; + this.friendshipLowCheckBox.Location = new System.Drawing.Point(110, 38); + this.friendshipLowCheckBox.Name = "friendshipLowCheckBox"; + this.friendshipLowCheckBox.Size = new System.Drawing.Size(97, 17); + this.friendshipLowCheckBox.TabIndex = 19; + this.friendshipLowCheckBox.Text = "Low Friendship"; + this.friendshipLowCheckBox.UseVisualStyleBackColor = true; + // + // friendshipMidValueNumeric + // + this.friendshipMidValueNumeric.Location = new System.Drawing.Point(226, 94); + this.friendshipMidValueNumeric.Name = "friendshipMidValueNumeric"; + this.friendshipMidValueNumeric.Size = new System.Drawing.Size(53, 20); + this.friendshipMidValueNumeric.TabIndex = 22; + // + // friendshipMidCheckBox + // + this.friendshipMidCheckBox.AutoSize = true; + this.friendshipMidCheckBox.Location = new System.Drawing.Point(110, 94); + this.friendshipMidCheckBox.Name = "friendshipMidCheckBox"; + this.friendshipMidCheckBox.Size = new System.Drawing.Size(94, 17); + this.friendshipMidCheckBox.TabIndex = 21; + this.friendshipMidCheckBox.Text = "Mid Friendship"; + this.friendshipMidCheckBox.UseVisualStyleBackColor = true; + // + // friendshipHighValueNumeric + // + this.friendshipHighValueNumeric.Location = new System.Drawing.Point(226, 143); + this.friendshipHighValueNumeric.Name = "friendshipHighValueNumeric"; + this.friendshipHighValueNumeric.Size = new System.Drawing.Size(53, 20); + this.friendshipHighValueNumeric.TabIndex = 24; + // + // friendshipHighCheckBox + // + this.friendshipHighCheckBox.AutoSize = true; + this.friendshipHighCheckBox.Location = new System.Drawing.Point(110, 143); + this.friendshipHighCheckBox.Name = "friendshipHighCheckBox"; + this.friendshipHighCheckBox.Size = new System.Drawing.Size(99, 17); + this.friendshipHighCheckBox.TabIndex = 23; + this.friendshipHighCheckBox.Text = "High Friendship"; + this.friendshipHighCheckBox.UseVisualStyleBackColor = true; // // ItemEditor // @@ -592,6 +1254,37 @@ this.functionsFlowLayoutPanel.ResumeLayout(false); this.functionsGroupBox.ResumeLayout(false); this.functionsGroupBox.PerformLayout(); + this.itemParamsTabControl.ResumeLayout(false); + this.statusHealtTabPage.ResumeLayout(false); + this.statusHealtTabPage.PerformLayout(); + this.levelUpEvolveTabPage.ResumeLayout(false); + this.levelUpEvolveTabPage.PerformLayout(); + this.statStagesTabPage.ResumeLayout(false); + this.statStagesTabPage.PerformLayout(); + this.hpPpRestoreTabPage.ResumeLayout(false); + this.hpPpRestoreTabPage.PerformLayout(); + this.evsTabPage.ResumeLayout(false); + this.evsTabPage.PerformLayout(); + this.friendshipTabPage.ResumeLayout(false); + this.friendshipTabPage.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.atkStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.defStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.spAtkStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.spDefStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.speedStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.accuracyStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.critRateStagesNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.hpRestoreParamNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.ppRestoreParamNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.evHpValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.evAtkValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.evDefValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.evSpeedValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.evSpAtkValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.evSpDefValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.friendshipLowValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.friendshipMidValueNumeric)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.friendshipHighValueNumeric)).EndInit(); this.ResumeLayout(false); } @@ -641,5 +1334,64 @@ private System.Windows.Forms.ComboBox fieldFunctionComboBox; private System.Windows.Forms.Label battleFunctionLabel; private System.Windows.Forms.CheckBox partyUseCheckBox; + private System.Windows.Forms.TabControl itemParamsTabControl; + private System.Windows.Forms.TabPage statusHealtTabPage; + private System.Windows.Forms.TabPage levelUpEvolveTabPage; + private System.Windows.Forms.TabPage statStagesTabPage; + private System.Windows.Forms.TabPage hpPpRestoreTabPage; + private System.Windows.Forms.TabPage evsTabPage; + private System.Windows.Forms.TabPage friendshipTabPage; + private System.Windows.Forms.CheckBox slpHealCheckBox; + private System.Windows.Forms.CheckBox infHealCheckBox; + private System.Windows.Forms.CheckBox cfsHealCheckBox; + private System.Windows.Forms.CheckBox przHealCheckBox; + private System.Windows.Forms.CheckBox frzHealCheckBox; + private System.Windows.Forms.CheckBox brnHealCheckBox; + private System.Windows.Forms.CheckBox psnHealCheckBox; + private System.Windows.Forms.CheckBox reviveAllCheckBox; + private System.Windows.Forms.CheckBox reviveCheckBox; + private System.Windows.Forms.CheckBox guardSpecCheckBox; + private System.Windows.Forms.CheckBox evolveCheckBox; + private System.Windows.Forms.CheckBox levelUpCheckBox; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown atkStagesNumeric; + private System.Windows.Forms.Label label7; + private System.Windows.Forms.NumericUpDown critRateStagesNumeric; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.NumericUpDown accuracyStagesNumeric; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.NumericUpDown speedStagesNumeric; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.NumericUpDown spDefStagesNumeric; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.NumericUpDown spAtkStagesNumeric; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.NumericUpDown defStagesNumeric; + private System.Windows.Forms.CheckBox hpRestoreCheckBox; + private System.Windows.Forms.CheckBox ppRestoreAllCheckBox; + private System.Windows.Forms.CheckBox ppMaxCheckBox; + private System.Windows.Forms.CheckBox ppUpsCheckBox; + private System.Windows.Forms.CheckBox ppRestoreCheckBox; + private System.Windows.Forms.NumericUpDown ppRestoreParamNumeric; + private System.Windows.Forms.NumericUpDown hpRestoreParamNumeric; + private System.Windows.Forms.NumericUpDown evDefValueNumeric; + private System.Windows.Forms.CheckBox evDefCheckBox; + private System.Windows.Forms.NumericUpDown evAtkValueNumeric; + private System.Windows.Forms.CheckBox evAtkCheckBox; + private System.Windows.Forms.NumericUpDown evHpValueNumeric; + private System.Windows.Forms.CheckBox evHpCheckBox; + private System.Windows.Forms.NumericUpDown evSpDefValueNumeric; + private System.Windows.Forms.CheckBox evSpDefCheckBox; + private System.Windows.Forms.NumericUpDown evSpAtkValueNumeric; + private System.Windows.Forms.CheckBox evSpAtkCheckBox; + private System.Windows.Forms.NumericUpDown evSpeedValueNumeric; + private System.Windows.Forms.CheckBox evSpeedCheckBox; + private System.Windows.Forms.ToolTip toolTip1; + private System.Windows.Forms.NumericUpDown friendshipHighValueNumeric; + private System.Windows.Forms.CheckBox friendshipHighCheckBox; + private System.Windows.Forms.NumericUpDown friendshipMidValueNumeric; + private System.Windows.Forms.CheckBox friendshipMidCheckBox; + private System.Windows.Forms.NumericUpDown friendshipLowValueNumeric; + private System.Windows.Forms.CheckBox friendshipLowCheckBox; } } \ No newline at end of file diff --git a/DS_Map/Editors/ItemEditor.cs b/DS_Map/Editors/ItemEditor.cs index ffcc8eb..ffbba40 100644 --- a/DS_Map/Editors/ItemEditor.cs +++ b/DS_Map/Editors/ItemEditor.cs @@ -7,6 +7,7 @@ using System.Linq; using System.Net.Sockets; using System.Text; using System.Windows.Forms; +using static DSPRE.ROMFiles.ItemData; using MessageBox = System.Windows.Forms.MessageBox; namespace DSPRE.Editors @@ -67,11 +68,128 @@ namespace DSPRE.Editors fieldFunctionComboBox.Items.AddRange(Enum.GetNames(typeof(FieldUseFunc))); battleFunctionComboBox.Items.AddRange(Enum.GetNames(typeof(BattleUseFunc))); + // ItemParameters + BindItemParamsEvents(); + SetItemParamToolTips(); + SetItemParamRanges(); + Helpers.EnableHandlers(); itemNameInputComboBox.SelectedIndex = 1; } + private void BindItemParamsEvents() + { + foreach (var ctrl in new CheckBox[] { + slpHealCheckBox, psnHealCheckBox, brnHealCheckBox, frzHealCheckBox, + przHealCheckBox, cfsHealCheckBox, infHealCheckBox, guardSpecCheckBox, + reviveCheckBox, reviveAllCheckBox, levelUpCheckBox, evolveCheckBox, + hpRestoreCheckBox, ppRestoreCheckBox, ppUpsCheckBox, ppMaxCheckBox, ppRestoreAllCheckBox, + evHpCheckBox, evAtkCheckBox, evDefCheckBox, evSpeedCheckBox, evSpAtkCheckBox, evSpDefCheckBox, + friendshipLowCheckBox, friendshipMidCheckBox, friendshipHighCheckBox + }) ctrl.CheckedChanged += PartyParamsControlChanged; + + foreach (var num in new NumericUpDown[] { + atkStagesNumeric, defStagesNumeric, spAtkStagesNumeric, spDefStagesNumeric, + speedStagesNumeric, accuracyStagesNumeric, critRateStagesNumeric, + hpRestoreParamNumeric, ppRestoreParamNumeric, + evHpValueNumeric, evAtkValueNumeric, evDefValueNumeric, + evSpeedValueNumeric, evSpAtkValueNumeric, evSpDefValueNumeric, + friendshipLowValueNumeric, friendshipMidValueNumeric, friendshipHighValueNumeric + }) num.ValueChanged += PartyParamsControlChanged; + } + + private void SetItemParamRanges() + { + // Stat stage modifiers: range -6 to +6 in gameplay, stored as 0–15 in data (encoded with +6 offset) + foreach (var n in new NumericUpDown[] { + atkStagesNumeric, defStagesNumeric, spAtkStagesNumeric, + spDefStagesNumeric, speedStagesNumeric, accuracyStagesNumeric }) + { + n.Minimum = -6; + n.Maximum = 6; + } + + // HP and PP restore parameters: stored as byte (0–255) + foreach (var n in new NumericUpDown[] { + hpRestoreParamNumeric, ppRestoreParamNumeric }) + { + n.Minimum = 0; + n.Maximum = 255; + } + + // EV and friendship modifiers: stored as sbyte (-128 to +127) + foreach (var n in new NumericUpDown[] { + evHpValueNumeric, evAtkValueNumeric, evDefValueNumeric, + evSpeedValueNumeric, evSpAtkValueNumeric, evSpDefValueNumeric, + friendshipLowValueNumeric, friendshipMidValueNumeric, friendshipHighValueNumeric }) + { + n.Minimum = -128; + n.Maximum = 127; + } + + // Crit rate stages: 2-bit unsigned, range 0–3 + critRateStagesNumeric.Minimum = 0; + critRateStagesNumeric.Maximum = 3; + } + + + + private void SetItemParamToolTips() + { + toolTip1.SetToolTip(slpHealCheckBox, "Cures sleep status"); + toolTip1.SetToolTip(psnHealCheckBox, "Cures poison status"); + toolTip1.SetToolTip(brnHealCheckBox, "Cures burn status"); + toolTip1.SetToolTip(frzHealCheckBox, "Cures freeze status"); + toolTip1.SetToolTip(przHealCheckBox, "Cures paralysis status"); + toolTip1.SetToolTip(cfsHealCheckBox, "Cures confusion"); + toolTip1.SetToolTip(infHealCheckBox, "Cures infatuation"); + toolTip1.SetToolTip(guardSpecCheckBox, "Applies Mist effect to party (Guard Spec)"); + + toolTip1.SetToolTip(reviveCheckBox, "Revives a fainted Pokémon to 50% HP"); + toolTip1.SetToolTip(reviveAllCheckBox, "Revives all fainted Pokémon in party"); + toolTip1.SetToolTip(levelUpCheckBox, "Causes the Pokémon to level up"); + toolTip1.SetToolTip(evolveCheckBox, "Causes the Pokémon to evolve"); + + toolTip1.SetToolTip(atkStagesNumeric, "Boost to Attack stat (in stages)"); + toolTip1.SetToolTip(defStagesNumeric, "Boost to Defense stat"); + toolTip1.SetToolTip(spAtkStagesNumeric, "Boost to Special Attack stat"); + toolTip1.SetToolTip(spDefStagesNumeric, "Boost to Special Defense stat"); + toolTip1.SetToolTip(speedStagesNumeric, "Boost to Speed stat"); + toolTip1.SetToolTip(accuracyStagesNumeric, "Boost to Accuracy stat"); + toolTip1.SetToolTip(critRateStagesNumeric, "Boost to Critical Hit rate"); + + toolTip1.SetToolTip(hpRestoreCheckBox, "Restores HP by parameter value"); + toolTip1.SetToolTip(hpRestoreParamNumeric, "Amount of HP to restore (0 = use %)"); + toolTip1.SetToolTip(ppRestoreCheckBox, "Restores PP by parameter value"); + toolTip1.SetToolTip(ppRestoreParamNumeric, "Amount of PP to restore"); + toolTip1.SetToolTip(ppUpsCheckBox, "Applies PP Up"); + toolTip1.SetToolTip(ppMaxCheckBox, "Applies PP Max"); + toolTip1.SetToolTip(ppRestoreAllCheckBox, "Restores PP for all moves"); + + toolTip1.SetToolTip(evHpCheckBox, "Adds EVs to HP"); + toolTip1.SetToolTip(evAtkCheckBox, "Adds EVs to Attack"); + toolTip1.SetToolTip(evDefCheckBox, "Adds EVs to Defense"); + toolTip1.SetToolTip(evSpeedCheckBox, "Adds EVs to Speed"); + toolTip1.SetToolTip(evSpAtkCheckBox, "Adds EVs to Special Attack"); + toolTip1.SetToolTip(evSpDefCheckBox, "Adds EVs to Special Defense"); + + toolTip1.SetToolTip(evHpValueNumeric, "EV value to apply to HP"); + toolTip1.SetToolTip(evAtkValueNumeric, "EV value to apply to Attack"); + toolTip1.SetToolTip(evDefValueNumeric, "EV value to apply to Defense"); + toolTip1.SetToolTip(evSpeedValueNumeric, "EV value to apply to Speed"); + toolTip1.SetToolTip(evSpAtkValueNumeric, "EV value to apply to Special Attack"); + toolTip1.SetToolTip(evSpDefValueNumeric, "EV value to apply to Special Defense"); + + toolTip1.SetToolTip(friendshipLowCheckBox, "Affects low-level friendship modification"); + toolTip1.SetToolTip(friendshipMidCheckBox, "Affects mid-level friendship modification"); + toolTip1.SetToolTip(friendshipHighCheckBox, "Affects high-level friendship modification"); + + toolTip1.SetToolTip(friendshipLowValueNumeric, "Friendship change for low base friendship"); + toolTip1.SetToolTip(friendshipMidValueNumeric, "Friendship change for mid base friendship"); + toolTip1.SetToolTip(friendshipHighValueNumeric, "Friendship change for high base friendship"); + } + private void setDirty(bool status) { if (status) @@ -150,6 +268,66 @@ namespace DSPRE.Editors //descriptionTextBox.Text = itemDescriptions[currentLoadedId]; + + itemParamsTabControl.Enabled = partyUseCheckBox.Checked; + PopulateItemPartyParamsUI(); + } + + private void PopulateItemPartyParamsUI() + { + ItemPartyUseParam param = currentLoadedFile.PartyUseParam; + + slpHealCheckBox.Checked = param.SlpHeal; + psnHealCheckBox.Checked = param.PsnHeal; + brnHealCheckBox.Checked = param.BrnHeal; + frzHealCheckBox.Checked = param.FrzHeal; + przHealCheckBox.Checked = param.PrzHeal; + cfsHealCheckBox.Checked = param.CfsHeal; + infHealCheckBox.Checked = param.InfHeal; + guardSpecCheckBox.Checked = param.GuardSpec; + + reviveCheckBox.Checked = param.Revive; + reviveAllCheckBox.Checked = param.ReviveAll; + levelUpCheckBox.Checked = param.LevelUp; + evolveCheckBox.Checked = param.Evolve; + + atkStagesNumeric.Value = param.AtkStages; + defStagesNumeric.Value = param.DefStages; + spAtkStagesNumeric.Value = param.SpAtkStages; + spDefStagesNumeric.Value = param.SpDefStages; + speedStagesNumeric.Value = param.SpeedStages; + accuracyStagesNumeric.Value = param.AccuracyStages; + critRateStagesNumeric.Value = param.CritRateStages; + + hpRestoreCheckBox.Checked = param.HPRestore; + hpRestoreParamNumeric.Value = param.HPRestoreParam; + ppRestoreCheckBox.Checked = param.PPRestore; + ppRestoreParamNumeric.Value = param.PPRestoreParam; + ppUpsCheckBox.Checked = param.PPUps; + ppMaxCheckBox.Checked = param.PPMax; + ppRestoreAllCheckBox.Checked = param.PPRestoreAll; + + evHpCheckBox.Checked = param.EVUps[0]; + evAtkCheckBox.Checked = param.EVUps[1]; + evDefCheckBox.Checked = param.EVUps[2]; + evSpeedCheckBox.Checked = param.EVUps[3]; + evSpAtkCheckBox.Checked = param.EVUps[4]; + evSpDefCheckBox.Checked = param.EVUps[5]; + + evHpValueNumeric.Value = param.EVParams[0]; + evAtkValueNumeric.Value = param.EVParams[1]; + evDefValueNumeric.Value = param.EVParams[2]; + evSpeedValueNumeric.Value = param.EVParams[3]; + evSpAtkValueNumeric.Value = param.EVParams[4]; + evSpDefValueNumeric.Value = param.EVParams[5]; + + friendshipLowCheckBox.Checked = param.FriendshipMods[0]; + friendshipMidCheckBox.Checked = param.FriendshipMods[1]; + friendshipHighCheckBox.Checked = param.FriendshipMods[2]; + + friendshipLowValueNumeric.Value = param.FriendshipParams[0]; + friendshipMidValueNumeric.Value = param.FriendshipParams[1]; + friendshipHighValueNumeric.Value = param.FriendshipParams[2]; } private void saveDataButton_Click(object sender, EventArgs e) @@ -233,8 +411,9 @@ namespace DSPRE.Editors return; } - currentLoadedFile.battlePocket = (BattlePocket)battlePocketComboBox.SelectedValue; + currentLoadedFile.battlePocket = (BattlePocket)Enum.Parse(typeof(BattlePocket), (string)battlePocketComboBox.SelectedItem); setDirty(true); + } private void priceNumericUpDown_ValueChanged(object sender, EventArgs e) @@ -266,8 +445,9 @@ namespace DSPRE.Editors return; } - currentLoadedFile.naturalGiftType = (NaturalGiftType)naturalGiftTypeComboBox.SelectedIndex; + currentLoadedFile.naturalGiftType = (NaturalGiftType)Enum.Parse(typeof(NaturalGiftType), (string)naturalGiftTypeComboBox.SelectedItem); setDirty(true); + } private void naturalGiftPowerNumericUpDown_ValueChanged(object sender, EventArgs e) @@ -366,7 +546,77 @@ namespace DSPRE.Editors } currentLoadedFile.PartyUse = (byte)(partyUseCheckBox.Checked ? 1: 0); + itemParamsTabControl.Enabled = partyUseCheckBox.Checked; setDirty(true); } + + private void PartyParamsControlChanged(object sender, EventArgs e) + { + if (currentLoadedFile == null) return; + + ItemPartyUseParam param = currentLoadedFile.PartyUseParam; + + // Status heals + param.SlpHeal = slpHealCheckBox.Checked; + param.PsnHeal = psnHealCheckBox.Checked; + param.BrnHeal = brnHealCheckBox.Checked; + param.FrzHeal = frzHealCheckBox.Checked; + param.PrzHeal = przHealCheckBox.Checked; + param.CfsHeal = cfsHealCheckBox.Checked; + param.InfHeal = infHealCheckBox.Checked; + param.GuardSpec = guardSpecCheckBox.Checked; + + // Revive, evolve, level + param.Revive = reviveCheckBox.Checked; + param.ReviveAll = reviveAllCheckBox.Checked; + param.LevelUp = levelUpCheckBox.Checked; + param.Evolve = evolveCheckBox.Checked; + + // Stat stages + param.AtkStages = (sbyte)atkStagesNumeric.Value; + param.DefStages = (sbyte)defStagesNumeric.Value; + param.SpAtkStages = (sbyte)spAtkStagesNumeric.Value; + param.SpDefStages = (sbyte)spDefStagesNumeric.Value; + param.SpeedStages = (sbyte)speedStagesNumeric.Value; + param.AccuracyStages = (sbyte)accuracyStagesNumeric.Value; + param.CritRateStages = (sbyte)critRateStagesNumeric.Value; + + // Restore + param.HPRestore = hpRestoreCheckBox.Checked; + param.HPRestoreParam = (byte)hpRestoreParamNumeric.Value; + param.PPRestore = ppRestoreCheckBox.Checked; + param.PPRestoreParam = (byte)ppRestoreParamNumeric.Value; + param.PPUps = ppUpsCheckBox.Checked; + param.PPMax = ppMaxCheckBox.Checked; + param.PPRestoreAll = ppRestoreAllCheckBox.Checked; + + // EVs + param.EVUps[0] = evHpCheckBox.Checked; + param.EVUps[1] = evAtkCheckBox.Checked; + param.EVUps[2] = evDefCheckBox.Checked; + param.EVUps[3] = evSpeedCheckBox.Checked; + param.EVUps[4] = evSpAtkCheckBox.Checked; + param.EVUps[5] = evSpDefCheckBox.Checked; + + param.EVParams[0] = (sbyte)evHpValueNumeric.Value; + param.EVParams[1] = (sbyte)evAtkValueNumeric.Value; + param.EVParams[2] = (sbyte)evDefValueNumeric.Value; + param.EVParams[3] = (sbyte)evSpeedValueNumeric.Value; + param.EVParams[4] = (sbyte)evSpAtkValueNumeric.Value; + param.EVParams[5] = (sbyte)evSpDefValueNumeric.Value; + + // Friendship + param.FriendshipMods[0] = friendshipLowCheckBox.Checked; + param.FriendshipMods[1] = friendshipMidCheckBox.Checked; + param.FriendshipMods[2] = friendshipHighCheckBox.Checked; + + param.FriendshipParams[0] = (sbyte)friendshipLowValueNumeric.Value; + param.FriendshipParams[1] = (sbyte)friendshipMidValueNumeric.Value; + param.FriendshipParams[2] = (sbyte)friendshipHighValueNumeric.Value; + + setDirty(true); + } + + } } diff --git a/DS_Map/Editors/ItemEditor.resx b/DS_Map/Editors/ItemEditor.resx index 1af7de1..df8339b 100644 --- a/DS_Map/Editors/ItemEditor.resx +++ b/DS_Map/Editors/ItemEditor.resx @@ -117,4 +117,7 @@ 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/ROMFiles/ItemData.cs b/DS_Map/ROMFiles/ItemData.cs index ad04bca..6e896bf 100644 --- a/DS_Map/ROMFiles/ItemData.cs +++ b/DS_Map/ROMFiles/ItemData.cs @@ -361,7 +361,7 @@ namespace DSPRE.ROMFiles battleUseFunc = (BattleUseFunc)reader.ReadByte(); PartyUse = reader.ReadByte(); - //reader.ReadByte(); // skip 1 byte padding_0D + reader.ReadByte(); // skip 1 byte padding_0D PartyUseParam = new ItemPartyUseParam(reader); @@ -418,50 +418,28 @@ namespace DSPRE.ROMFiles public class ItemPartyUseParam { // Flags (bit-packed) - public bool SlpHeal; - public bool PsnHeal; - public bool BrnHeal; - public bool FrzHeal; - public bool PrzHeal; - public bool CfsHeal; - public bool InfHeal; - + public bool SlpHeal, PsnHeal, BrnHeal, FrzHeal, PrzHeal, CfsHeal, InfHeal; public bool GuardSpec; - public bool Revive; - public bool ReviveAll; + public bool Revive, ReviveAll, LevelUp, Evolve; - public bool LevelUp; + public sbyte AtkStages, DefStages, SpAtkStages, SpDefStages, SpeedStages, AccuracyStages, CritRateStages; - public bool Evolve; + public bool PPUps, PPMax, PPRestore, PPRestoreAll, HPRestore; - public sbyte AtkStages; - public sbyte DefStages; - public sbyte SpAtkStages; - public sbyte SpDefStages; - public sbyte SpeedStages; - public sbyte AccuracyStages; - public sbyte CritRateStages; + public bool[] EVUps = new bool[6]; // hp, atk, def, speed, spatk, spdef + public bool[] FriendshipMods = new bool[3]; // lo, med, hi - public bool PPUps; - public bool PPMax; - public bool PPRestore; - public bool PPRestoreAll; - public bool HPRestore; - - public bool[] EVUps = new bool[6]; // hp, atk, def, speed, spatk, spdef - public bool[] FriendshipMods = new bool[3]; // lo, med, hi - - public sbyte[] EVParams = new sbyte[6]; // hp, atk, def, speed, spatk, spdef + public sbyte[] EVParams = new sbyte[6]; // hp, atk, def, speed, spatk, spdef public byte HPRestoreParam; public byte PPRestoreParam; - public sbyte[] FriendshipParams = new sbyte[3]; // lo, med, hi + public sbyte[] FriendshipParams = new sbyte[3]; // lo, med, hi public ItemPartyUseParam(BinaryReader reader) { - byte[] data = reader.ReadBytes(19); // Total size of struct + byte[] data = reader.ReadBytes(19); - // Byte 0: HealStatus1 bits + // Byte 0: HealStatus1 byte healStatus1 = data[0]; SlpHeal = (healStatus1 & (1 << 0)) != 0; PsnHeal = (healStatus1 & (1 << 1)) != 0; @@ -472,71 +450,65 @@ namespace DSPRE.ROMFiles InfHeal = (healStatus1 & (1 << 6)) != 0; GuardSpec = (healStatus1 & (1 << 7)) != 0; - // Byte 1: revive, revive_all, level_up, evolve, + 4 bits padding + // Byte 1: revive, revive_all, level_up, evolve byte flags1 = data[1]; Revive = (flags1 & (1 << 0)) != 0; ReviveAll = (flags1 & (1 << 1)) != 0; LevelUp = (flags1 & (1 << 2)) != 0; Evolve = (flags1 & (1 << 3)) != 0; - // Byte 2: atk_stages (4 bits), def_stages (4 bits) - byte stages1 = data[2]; - AtkStages = (sbyte)(stages1 & 0x0F); - DefStages = (sbyte)((stages1 >> 4) & 0x0F); + // Byte 2: atk + def stages (stored 0–15, mapped to -6 to +6 if needed) + AtkStages = DecodeStage(data[2] & 0x0F); + DefStages = DecodeStage((data[2] >> 4) & 0x0F); - // Byte 3: spatk_stages (4 bits), spdef_stages (4 bits) - byte stages2 = data[3]; - SpAtkStages = (sbyte)(stages2 & 0x0F); - SpDefStages = (sbyte)((stages2 >> 4) & 0x0F); + // Byte 3: spatk + spdef + SpAtkStages = DecodeStage(data[3] & 0x0F); + SpDefStages = DecodeStage((data[3] >> 4) & 0x0F); - // Byte 4: speed_stages (4 bits), accuracy_stages (4 bits) - byte stages3 = data[4]; - SpeedStages = (sbyte)(stages3 & 0x0F); - AccuracyStages = (sbyte)((stages3 >> 4) & 0x0F); + // Byte 4: speed + accuracy + SpeedStages = DecodeStage(data[4] & 0x0F); + AccuracyStages = DecodeStage((data[4] >> 4) & 0x0F); - // Byte 5: critrate_stages (2 bits), pp_up, pp_max, pp_restore, pp_restore_all, hp_restore (5 bits) + // Byte 5: crit rate (2 bits), pp/hp restore flags byte flags2 = data[5]; - CritRateStages = (sbyte)(flags2 & 0x03); + CritRateStages = (sbyte)(flags2 & 0x03); // 0–3 PPUps = (flags2 & (1 << 2)) != 0; PPMax = (flags2 & (1 << 3)) != 0; PPRestore = (flags2 & (1 << 4)) != 0; PPRestoreAll = (flags2 & (1 << 5)) != 0; HPRestore = (flags2 & (1 << 6)) != 0; - // Byte 6: ev flags + // Byte 6: EV flags byte evFlags = data[6]; - EVUps = new bool[6]; for (int i = 0; i < 6; i++) EVUps[i] = (evFlags & (1 << i)) != 0; // Byte 7: friendship flags byte friendFlags = data[7]; - FriendshipMods = new bool[3]; for (int i = 0; i < 3; i++) FriendshipMods[i] = (friendFlags & (1 << i)) != 0; - // Bytes 8-13: EVParams - EVParams = new sbyte[6]; + // Bytes 8–13: EVParams (signed) for (int i = 0; i < 6; i++) EVParams[i] = (sbyte)data[8 + i]; - // Byte 14: HPRestoreParam + // Byte 14: HP restore param (0–255) HPRestoreParam = data[14]; - // Byte 15: PPRestoreParam + // Byte 15: PP restore param (0–255) PPRestoreParam = data[15]; - // Bytes 16–18: FriendshipParams - FriendshipParams = new sbyte[3]; + // Bytes 16–18: friendship params (signed) for (int i = 0; i < 3; i++) FriendshipParams[i] = (sbyte)data[16 + i]; - // Padding is ignored (2 bytes assumed to follow) + // Skip padding in binary reader (2 bytes expected) + reader.BaseStream.Seek(2, SeekOrigin.Current); } public void WriteTo(BinaryWriter writer) { - byte[] data = new byte[18]; + byte[] data = new byte[19]; // Byte 0: HealStatus1 data[0] = 0; @@ -557,15 +529,15 @@ namespace DSPRE.ROMFiles if (Evolve) data[1] |= (1 << 3); // Byte 2: atk + def stages - data[2] = (byte)((DefStages & 0x0F) << 4 | (AtkStages & 0x0F)); + data[2] = (byte)((EncodeStage(DefStages) << 4) | EncodeStage(AtkStages)); - // Byte 3: spatk + spdef stages - data[3] = (byte)((SpDefStages & 0x0F) << 4 | (SpAtkStages & 0x0F)); + // Byte 3: spatk + spdef + data[3] = (byte)((EncodeStage(SpDefStages) << 4) | EncodeStage(SpAtkStages)); - // Byte 4: speed + accuracy stages - data[4] = (byte)((AccuracyStages & 0x0F) << 4 | (SpeedStages & 0x0F)); + // Byte 4: speed + accuracy + data[4] = (byte)((EncodeStage(AccuracyStages) << 4) | EncodeStage(SpeedStages)); - // Byte 5: crit rate + pp/hp flags + // Byte 5: crit rate + flags data[5] = (byte)(CritRateStages & 0x03); if (PPUps) data[5] |= (1 << 2); if (PPMax) data[5] |= (1 << 3); @@ -574,16 +546,14 @@ namespace DSPRE.ROMFiles if (HPRestore) data[5] |= (1 << 6); // Byte 6: EV flags - data[6] = 0; for (int i = 0; i < 6; i++) if (EVUps[i]) data[6] |= (byte)(1 << i); - // Byte 7: Friendship flags - data[7] = 0; + // Byte 7: friendship flags for (int i = 0; i < 3; i++) if (FriendshipMods[i]) data[7] |= (byte)(1 << i); - // Bytes 8-13: EVParams + // Bytes 8–13: EVParams for (int i = 0; i < 6; i++) data[8 + i] = (byte)EVParams[i]; @@ -597,13 +567,17 @@ namespace DSPRE.ROMFiles for (int i = 0; i < 3; i++) data[16 + i] = (byte)FriendshipParams[i]; - // Write all bytes + // Write struct + padding writer.Write(data); - - // Write padding writer.Write(new byte[2]); } + // Replace the problematic line with the following implementation of Clamp: + private static byte EncodeStage(sbyte val) => (byte)((val + 6 < 0) ? 0 : (val + 6 > 15) ? 15 : val + 6); + + // Decodes 0 to 15 to -6 to +9 range (limited logic for now) + private static sbyte DecodeStage(int val) => (sbyte)(val - 6); } + } } From e228507374c89154dcef9fe200edbc4a2b5b5cd5 Mon Sep 17 00:00:00 2001 From: Mixone-FinallyHere Date: Thu, 19 Jun 2025 15:20:04 +0200 Subject: [PATCH 2/2] =?UTF-8?q?(=E2=95=AF=C2=B0=E2=96=A1=C2=B0)=E2=95=AF?= =?UTF-8?q?=EF=B8=B5=20=E2=94=BB=E2=94=81=E2=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DS_Map/Editors/ItemEditor.cs | 73 +++++----- DS_Map/ROMFiles/ItemData.cs | 273 ++++++++++++++++++----------------- 2 files changed, 177 insertions(+), 169 deletions(-) diff --git a/DS_Map/Editors/ItemEditor.cs b/DS_Map/Editors/ItemEditor.cs index ffbba40..112a4e5 100644 --- a/DS_Map/Editors/ItemEditor.cs +++ b/DS_Map/Editors/ItemEditor.cs @@ -298,7 +298,6 @@ namespace DSPRE.Editors speedStagesNumeric.Value = param.SpeedStages; accuracyStagesNumeric.Value = param.AccuracyStages; critRateStagesNumeric.Value = param.CritRateStages; - hpRestoreCheckBox.Checked = param.HPRestore; hpRestoreParamNumeric.Value = param.HPRestoreParam; ppRestoreCheckBox.Checked = param.PPRestore; @@ -307,27 +306,27 @@ namespace DSPRE.Editors ppMaxCheckBox.Checked = param.PPMax; ppRestoreAllCheckBox.Checked = param.PPRestoreAll; - evHpCheckBox.Checked = param.EVUps[0]; - evAtkCheckBox.Checked = param.EVUps[1]; - evDefCheckBox.Checked = param.EVUps[2]; - evSpeedCheckBox.Checked = param.EVUps[3]; - evSpAtkCheckBox.Checked = param.EVUps[4]; - evSpDefCheckBox.Checked = param.EVUps[5]; + evHpCheckBox.Checked = param.EVHp; + evAtkCheckBox.Checked = param.EVAtk; + evDefCheckBox.Checked = param.EVDef; + evSpeedCheckBox.Checked = param.EVSpeed; + evSpAtkCheckBox.Checked = param.EVSpAtk; + evSpDefCheckBox.Checked = param.EVSpDef; - evHpValueNumeric.Value = param.EVParams[0]; - evAtkValueNumeric.Value = param.EVParams[1]; - evDefValueNumeric.Value = param.EVParams[2]; - evSpeedValueNumeric.Value = param.EVParams[3]; - evSpAtkValueNumeric.Value = param.EVParams[4]; - evSpDefValueNumeric.Value = param.EVParams[5]; + evHpValueNumeric.Value = param.EVHpValue; + evAtkValueNumeric.Value = param.EVAtkValue; + evDefValueNumeric.Value = param.EVDefValue; + evSpeedValueNumeric.Value = param.EVSpeedValue; + evSpAtkValueNumeric.Value = param.EVSpAtkValue; + evSpDefValueNumeric.Value = param.EVSpDefValue; - friendshipLowCheckBox.Checked = param.FriendshipMods[0]; - friendshipMidCheckBox.Checked = param.FriendshipMods[1]; - friendshipHighCheckBox.Checked = param.FriendshipMods[2]; + friendshipLowCheckBox.Checked = param.FriendshipLow; + friendshipMidCheckBox.Checked = param.FriendshipMid; + friendshipHighCheckBox.Checked = param.FriendshipHigh; - friendshipLowValueNumeric.Value = param.FriendshipParams[0]; - friendshipMidValueNumeric.Value = param.FriendshipParams[1]; - friendshipHighValueNumeric.Value = param.FriendshipParams[2]; + friendshipLowValueNumeric.Value = param.FriendshipLowValue; + friendshipMidValueNumeric.Value = param.FriendshipMidValue; + friendshipHighValueNumeric.Value = param.FriendshipHighValue; } private void saveDataButton_Click(object sender, EventArgs e) @@ -591,28 +590,28 @@ namespace DSPRE.Editors param.PPRestoreAll = ppRestoreAllCheckBox.Checked; // EVs - param.EVUps[0] = evHpCheckBox.Checked; - param.EVUps[1] = evAtkCheckBox.Checked; - param.EVUps[2] = evDefCheckBox.Checked; - param.EVUps[3] = evSpeedCheckBox.Checked; - param.EVUps[4] = evSpAtkCheckBox.Checked; - param.EVUps[5] = evSpDefCheckBox.Checked; + param.EVHp = evHpCheckBox.Checked; + param.EVAtk = evAtkCheckBox.Checked; + param.EVDef = evDefCheckBox.Checked; + param.EVSpeed = evSpeedCheckBox.Checked; + param.EVSpAtk = evSpAtkCheckBox.Checked; + param.EVSpDef = evSpDefCheckBox.Checked; - param.EVParams[0] = (sbyte)evHpValueNumeric.Value; - param.EVParams[1] = (sbyte)evAtkValueNumeric.Value; - param.EVParams[2] = (sbyte)evDefValueNumeric.Value; - param.EVParams[3] = (sbyte)evSpeedValueNumeric.Value; - param.EVParams[4] = (sbyte)evSpAtkValueNumeric.Value; - param.EVParams[5] = (sbyte)evSpDefValueNumeric.Value; + param.EVHpValue = (sbyte)evHpValueNumeric.Value; + param.EVAtkValue = (sbyte)evAtkValueNumeric.Value; + param.EVDefValue = (sbyte)evDefValueNumeric.Value; + param.EVSpeedValue = (sbyte)evSpeedValueNumeric.Value; + param.EVSpAtkValue = (sbyte)evSpAtkValueNumeric.Value; + param.EVSpDefValue = (sbyte)evSpDefValueNumeric.Value; // Friendship - param.FriendshipMods[0] = friendshipLowCheckBox.Checked; - param.FriendshipMods[1] = friendshipMidCheckBox.Checked; - param.FriendshipMods[2] = friendshipHighCheckBox.Checked; + param.FriendshipLow = friendshipLowCheckBox.Checked; + param.FriendshipMid = friendshipMidCheckBox.Checked; + param.FriendshipHigh = friendshipHighCheckBox.Checked; - param.FriendshipParams[0] = (sbyte)friendshipLowValueNumeric.Value; - param.FriendshipParams[1] = (sbyte)friendshipMidValueNumeric.Value; - param.FriendshipParams[2] = (sbyte)friendshipHighValueNumeric.Value; + param.FriendshipLowValue = (sbyte)friendshipLowValueNumeric.Value; + param.FriendshipMidValue = (sbyte)friendshipMidValueNumeric.Value; + param.FriendshipHighValue = (sbyte)friendshipHighValueNumeric.Value; setDirty(true); } diff --git a/DS_Map/ROMFiles/ItemData.cs b/DS_Map/ROMFiles/ItemData.cs index 6e896bf..7d16496 100644 --- a/DS_Map/ROMFiles/ItemData.cs +++ b/DS_Map/ROMFiles/ItemData.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using System.Windows.Controls.Primitives; using static DSPRE.RomInfo; using static Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System; @@ -417,166 +418,174 @@ namespace DSPRE.ROMFiles public class ItemPartyUseParam { - // Flags (bit-packed) - public bool SlpHeal, PsnHeal, BrnHeal, FrzHeal, PrzHeal, CfsHeal, InfHeal; - public bool GuardSpec; - + public bool SlpHeal, PsnHeal, BrnHeal, FrzHeal, PrzHeal, CfsHeal, InfHeal, GuardSpec; public bool Revive, ReviveAll, LevelUp, Evolve; - - public sbyte AtkStages, DefStages, SpAtkStages, SpDefStages, SpeedStages, AccuracyStages, CritRateStages; - + public int AtkStages, DefStages, SpAtkStages, SpDefStages, SpeedStages, AccuracyStages, CritRateStages; public bool PPUps, PPMax, PPRestore, PPRestoreAll, HPRestore; - - public bool[] EVUps = new bool[6]; // hp, atk, def, speed, spatk, spdef - public bool[] FriendshipMods = new bool[3]; // lo, med, hi - - public sbyte[] EVParams = new sbyte[6]; // hp, atk, def, speed, spatk, spdef - public byte HPRestoreParam; - public byte PPRestoreParam; - public sbyte[] FriendshipParams = new sbyte[3]; // lo, med, hi + public bool EVHp, EVAtk, EVDef, EVSpeed, EVSpAtk, EVSpDef; + public bool FriendshipLow, FriendshipMid, FriendshipHigh; + public sbyte EVHpValue, EVAtkValue, EVDefValue, EVSpeedValue, EVSpAtkValue, EVSpDefValue; + public byte HPRestoreParam, PPRestoreParam; + public sbyte FriendshipLowValue, FriendshipMidValue, FriendshipHighValue; public ItemPartyUseParam(BinaryReader reader) { - byte[] data = reader.ReadBytes(19); + byte b0 = reader.ReadByte(); // byte 0 + SlpHeal = (b0 & (1 << 0)) != 0; + PsnHeal = (b0 & (1 << 1)) != 0; + BrnHeal = (b0 & (1 << 2)) != 0; + FrzHeal = (b0 & (1 << 3)) != 0; + PrzHeal = (b0 & (1 << 4)) != 0; + CfsHeal = (b0 & (1 << 5)) != 0; + InfHeal = (b0 & (1 << 6)) != 0; + GuardSpec = (b0 & (1 << 7)) != 0; - // Byte 0: HealStatus1 - byte healStatus1 = data[0]; - SlpHeal = (healStatus1 & (1 << 0)) != 0; - PsnHeal = (healStatus1 & (1 << 1)) != 0; - BrnHeal = (healStatus1 & (1 << 2)) != 0; - FrzHeal = (healStatus1 & (1 << 3)) != 0; - PrzHeal = (healStatus1 & (1 << 4)) != 0; - CfsHeal = (healStatus1 & (1 << 5)) != 0; - InfHeal = (healStatus1 & (1 << 6)) != 0; - GuardSpec = (healStatus1 & (1 << 7)) != 0; + byte b1 = reader.ReadByte(); // byte 1 + Revive = (b1 & (1 << 0)) != 0; + ReviveAll = (b1 & (1 << 1)) != 0; + LevelUp = (b1 & (1 << 2)) != 0; + Evolve = (b1 & (1 << 3)) != 0; + AtkStages = (sbyte)((b1 >> 4) & 0xF); // signed 4-bit from high nibble - // Byte 1: revive, revive_all, level_up, evolve - byte flags1 = data[1]; - Revive = (flags1 & (1 << 0)) != 0; - ReviveAll = (flags1 & (1 << 1)) != 0; - LevelUp = (flags1 & (1 << 2)) != 0; - Evolve = (flags1 & (1 << 3)) != 0; + byte b2 = reader.ReadByte(); // byte 2 + DefStages = (sbyte)(b2 & 0xF); + SpAtkStages = (sbyte)((b2 >> 4) & 0xF); - // Byte 2: atk + def stages (stored 0–15, mapped to -6 to +6 if needed) - AtkStages = DecodeStage(data[2] & 0x0F); - DefStages = DecodeStage((data[2] >> 4) & 0x0F); + byte b3 = reader.ReadByte(); // byte 3 + SpDefStages = (sbyte)(b3 & 0xF); + SpeedStages = (sbyte)((b3 >> 4) & 0xF); - // Byte 3: spatk + spdef - SpAtkStages = DecodeStage(data[3] & 0x0F); - SpDefStages = DecodeStage((data[3] >> 4) & 0x0F); + byte b4 = reader.ReadByte(); // byte 4 + AccuracyStages = (sbyte)(b4 & 0xF); + CritRateStages = (sbyte)((b4 >> 4) & 0x3); + PPUps = (b4 & (1 << 6)) != 0; + PPMax = (b4 & (1 << 7)) != 0; - // Byte 4: speed + accuracy - SpeedStages = DecodeStage(data[4] & 0x0F); - AccuracyStages = DecodeStage((data[4] >> 4) & 0x0F); + byte b5 = reader.ReadByte(); // byte 5 + PPRestore = (b5 & (1 << 0)) != 0; + PPRestoreAll = (b5 & (1 << 1)) != 0; + HPRestore = (b5 & (1 << 2)) != 0; + EVHp = (b5 & (1 << 3)) != 0; + EVAtk = (b5 & (1 << 4)) != 0; + EVDef = (b5 & (1 << 5)) != 0; + EVSpeed = (b5 & (1 << 6)) != 0; + EVSpAtk = (b5 & (1 << 7)) != 0; - // Byte 5: crit rate (2 bits), pp/hp restore flags - byte flags2 = data[5]; - CritRateStages = (sbyte)(flags2 & 0x03); // 0–3 - PPUps = (flags2 & (1 << 2)) != 0; - PPMax = (flags2 & (1 << 3)) != 0; - PPRestore = (flags2 & (1 << 4)) != 0; - PPRestoreAll = (flags2 & (1 << 5)) != 0; - HPRestore = (flags2 & (1 << 6)) != 0; + byte b6 = reader.ReadByte(); // byte 6 + EVSpDef = (b6 & (1 << 0)) != 0; + FriendshipLow = (b6 & (1 << 1)) != 0; + FriendshipMid = (b6 & (1 << 2)) != 0; + FriendshipHigh = (b6 & (1 << 3)) != 0; + // bits 4-7 unused - // Byte 6: EV flags - byte evFlags = data[6]; - for (int i = 0; i < 6; i++) - EVUps[i] = (evFlags & (1 << i)) != 0; + // Remaining bytes (7–18): values + EVHpValue = reader.ReadSByte(); + EVAtkValue = reader.ReadSByte(); + EVDefValue = reader.ReadSByte(); + EVSpeedValue = reader.ReadSByte(); + EVSpAtkValue = reader.ReadSByte(); + EVSpDefValue = reader.ReadSByte(); + HPRestoreParam = reader.ReadByte(); + PPRestoreParam = reader.ReadByte(); + FriendshipLowValue = reader.ReadSByte(); + FriendshipMidValue = reader.ReadSByte(); + FriendshipHighValue = reader.ReadSByte(); - // Byte 7: friendship flags - byte friendFlags = data[7]; - for (int i = 0; i < 3; i++) - FriendshipMods[i] = (friendFlags & (1 << i)) != 0; - - // Bytes 8–13: EVParams (signed) - for (int i = 0; i < 6; i++) - EVParams[i] = (sbyte)data[8 + i]; - - // Byte 14: HP restore param (0–255) - HPRestoreParam = data[14]; - - // Byte 15: PP restore param (0–255) - PPRestoreParam = data[15]; - - // Bytes 16–18: friendship params (signed) - for (int i = 0; i < 3; i++) - FriendshipParams[i] = (sbyte)data[16 + i]; - - // Skip padding in binary reader (2 bytes expected) - reader.BaseStream.Seek(2, SeekOrigin.Current); + reader.BaseStream.Seek(2, SeekOrigin.Current); // skip padding } + public void WriteTo(BinaryWriter writer) { - byte[] data = new byte[19]; + // Byte 0 + byte b0 = 0; + b0 |= (byte)(SlpHeal ? 1 << 0 : 0); + b0 |= (byte)(PsnHeal ? 1 << 1 : 0); + b0 |= (byte)(BrnHeal ? 1 << 2 : 0); + b0 |= (byte)(FrzHeal ? 1 << 3 : 0); + b0 |= (byte)(PrzHeal ? 1 << 4 : 0); + b0 |= (byte)(CfsHeal ? 1 << 5 : 0); + b0 |= (byte)(InfHeal ? 1 << 6 : 0); + b0 |= (byte)(GuardSpec ? 1 << 7 : 0); + writer.Write(b0); - // Byte 0: HealStatus1 - data[0] = 0; - if (SlpHeal) data[0] |= (1 << 0); - if (PsnHeal) data[0] |= (1 << 1); - if (BrnHeal) data[0] |= (1 << 2); - if (FrzHeal) data[0] |= (1 << 3); - if (PrzHeal) data[0] |= (1 << 4); - if (CfsHeal) data[0] |= (1 << 5); - if (InfHeal) data[0] |= (1 << 6); - if (GuardSpec) data[0] |= (1 << 7); + // Byte 1 + byte b1 = 0; + b1 |= (byte)(Revive ? 1 << 0 : 0); + b1 |= (byte)(ReviveAll ? 1 << 1 : 0); + b1 |= (byte)(LevelUp ? 1 << 2 : 0); + b1 |= (byte)(Evolve ? 1 << 3 : 0); + b1 |= (byte)((AtkStages & 0x0F) << 4); // signed 4-bit + writer.Write(b1); - // Byte 1: revive, revive_all, level_up, evolve - data[1] = 0; - if (Revive) data[1] |= (1 << 0); - if (ReviveAll) data[1] |= (1 << 1); - if (LevelUp) data[1] |= (1 << 2); - if (Evolve) data[1] |= (1 << 3); + // Byte 2 + byte b2 = 0; + b2 |= (byte)((DefStages & 0x0F)); + b2 |= (byte)((SpAtkStages & 0x0F) << 4); + writer.Write(b2); - // Byte 2: atk + def stages - data[2] = (byte)((EncodeStage(DefStages) << 4) | EncodeStage(AtkStages)); + // Byte 3 + byte b3 = 0; + b3 |= (byte)((SpDefStages & 0x0F)); + b3 |= (byte)((SpeedStages & 0x0F) << 4); + writer.Write(b3); - // Byte 3: spatk + spdef - data[3] = (byte)((EncodeStage(SpDefStages) << 4) | EncodeStage(SpAtkStages)); + // Byte 4 + byte b4 = 0; + b4 |= (byte)((AccuracyStages & 0x0F)); + b4 |= (byte)((CritRateStages & 0x03) << 4); + b4 |= (byte)(PPUps ? 1 << 6 : 0); + b4 |= (byte)(PPMax ? 1 << 7 : 0); + writer.Write(b4); - // Byte 4: speed + accuracy - data[4] = (byte)((EncodeStage(AccuracyStages) << 4) | EncodeStage(SpeedStages)); + // Byte 5 + byte b5 = 0; + b5 |= (byte)(PPRestore ? 1 << 0 : 0); + b5 |= (byte)(PPRestoreAll ? 1 << 1 : 0); + b5 |= (byte)(HPRestore ? 1 << 2 : 0); + b5 |= (byte)(EVHp ? 1 << 3 : 0); + b5 |= (byte)(EVAtk ? 1 << 4 : 0); + b5 |= (byte)(EVDef ? 1 << 5 : 0); + b5 |= (byte)(EVSpeed ? 1 << 6 : 0); + b5 |= (byte)(EVSpAtk ? 1 << 7 : 0); + writer.Write(b5); - // Byte 5: crit rate + flags - data[5] = (byte)(CritRateStages & 0x03); - if (PPUps) data[5] |= (1 << 2); - if (PPMax) data[5] |= (1 << 3); - if (PPRestore) data[5] |= (1 << 4); - if (PPRestoreAll) data[5] |= (1 << 5); - if (HPRestore) data[5] |= (1 << 6); + // Byte 6 + byte b6 = 0; + b6 |= (byte)(EVSpDef ? 1 << 0 : 0); + b6 |= (byte)(FriendshipLow ? 1 << 1 : 0); + b6 |= (byte)(FriendshipMid ? 1 << 2 : 0); + b6 |= (byte)(FriendshipHigh ? 1 << 3 : 0); + // bits 4-7 unused + writer.Write(b6); - // Byte 6: EV flags - for (int i = 0; i < 6; i++) - if (EVUps[i]) data[6] |= (byte)(1 << i); + // Bytes 7–18: raw values + writer.Write(EVHpValue); + writer.Write(EVAtkValue); + writer.Write(EVDefValue); + writer.Write(EVSpeedValue); + writer.Write(EVSpAtkValue); + writer.Write(EVSpDefValue); + writer.Write(HPRestoreParam); + writer.Write(PPRestoreParam); + writer.Write(FriendshipLowValue); + writer.Write(FriendshipMidValue); + writer.Write(FriendshipHighValue); - // Byte 7: friendship flags - for (int i = 0; i < 3; i++) - if (FriendshipMods[i]) data[7] |= (byte)(1 << i); - - // Bytes 8–13: EVParams - for (int i = 0; i < 6; i++) - data[8 + i] = (byte)EVParams[i]; - - // Byte 14: HPRestoreParam - data[14] = HPRestoreParam; - - // Byte 15: PPRestoreParam - data[15] = PPRestoreParam; - - // Bytes 16–18: FriendshipParams - for (int i = 0; i < 3; i++) - data[16 + i] = (byte)FriendshipParams[i]; - - // Write struct + padding - writer.Write(data); - writer.Write(new byte[2]); + // Bytes 19–20: padding + writer.Write((byte)0); + writer.Write((byte)0); } - // Replace the problematic line with the following implementation of Clamp: - private static byte EncodeStage(sbyte val) => (byte)((val + 6 < 0) ? 0 : (val + 6 > 15) ? 15 : val + 6); + private static bool GetBit(ulong val, int bit) => ((val >> bit) & 1) != 0; + private static void SetBit(ref ulong val, int bit, bool on) + { + if (on) val |= 1UL << bit; + else val &= ~(1UL << bit); + } - // Decodes 0 to 15 to -6 to +9 range (limited logic for now) - private static sbyte DecodeStage(int val) => (sbyte)(val - 6); + private static byte EncodeStage(sbyte val) => (byte)((val + 6 < 0) ? 0 : (val + 6 > 15) ? 15 : val + 6); + private static sbyte DecodeStage(byte val) => (sbyte)(val - 6); } }