diff --git a/LibW4M/Data/Teams/Team.cs b/LibW4M/Data/Teams/Team.cs index 6723f14..6b54e5e 100644 --- a/LibW4M/Data/Teams/Team.cs +++ b/LibW4M/Data/Teams/Team.cs @@ -6,7 +6,6 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -using static System.Runtime.InteropServices.JavaScript.JSType; namespace LibW4M.Data.Teams { @@ -116,6 +115,9 @@ namespace LibW4M.Data.Teams writer.WriteInt32Array(this.StoryMissionsCompleted); writer.WriteInt32(this.StoryChapter); + + ms.Seek(0x00, SeekOrigin.Begin); + mainContainer.SetData(ms.ToArray()); } } } diff --git a/LibW4M/W4SaveFile.cs b/LibW4M/W4SaveFile.cs index 8c97a48..c42ecc9 100644 --- a/LibW4M/W4SaveFile.cs +++ b/LibW4M/W4SaveFile.cs @@ -66,6 +66,21 @@ namespace LibW4M } } } + + public XomString[] StringArrayToXomStringArray(string[] strings) + { + XomString[] xstrings = new XomString[strings.Length]; + for (int i = 0; i < xstrings.Length; i++) xstrings[i] = LookupString(strings[i]); + return xstrings; + } + + public string[] XomStringArrayToStringArray(XomString[] xstrings) + { + string[] strings = new string[xstrings.Length]; + for (int i = 0; i < strings.Length; i++) strings[i] = xstrings[i].Value; + return strings; + } + public int[] XomStringArrayToIntArray(XomString[] strs) { int[] ids = new int[strs.Length]; diff --git a/W4Gui/Components/IntList.Designer.cs b/W4Gui/Components/IntList.Designer.cs index 4bd6696..2c37d20 100644 --- a/W4Gui/Components/IntList.Designer.cs +++ b/W4Gui/Components/IntList.Designer.cs @@ -64,7 +64,7 @@ this.numberList.FormattingEnabled = true; this.numberList.Location = new System.Drawing.Point(3, 3); this.numberList.Name = "numberList"; - this.numberList.Size = new System.Drawing.Size(159, 23); + this.numberList.Size = new System.Drawing.Size(200, 23); this.numberList.TabIndex = 0; this.numberList.SelectedIndexChanged += new System.EventHandler(this.numberList_SelectedIndexChanged); // @@ -73,7 +73,7 @@ this.valueBox.Dock = System.Windows.Forms.DockStyle.Top; this.valueBox.Location = new System.Drawing.Point(168, 3); this.valueBox.Name = "valueBox"; - this.valueBox.Size = new System.Drawing.Size(325, 23); + this.valueBox.Size = new System.Drawing.Size(100, 23); this.valueBox.TabIndex = 1; this.valueBox.Text = "0"; this.valueBox.Value = 0; diff --git a/W4Gui/Components/IntList.cs b/W4Gui/Components/IntList.cs index 63188ec..3f2c656 100644 --- a/W4Gui/Components/IntList.cs +++ b/W4Gui/Components/IntList.cs @@ -42,9 +42,29 @@ namespace W4Gui.Components } public void DelInt(int idx) { + this.lastIndex = -1; this.valuesList.RemoveAt(idx); this.numberList.Items.RemoveAt(idx); createNumbersList(); + this.numberList.SelectedIndex = idx - 1; + } + + private void selectFirst() + { + if (this.numberList.SelectedIndex < 0) + if (this.numberList.Items.Count > 0) + this.numberList.SelectedIndex = 0; + } + public void LoadItems(int[] values) + { + this.valuesList.Clear(); + this.numberList.Items.Clear(); + + foreach(int itm in values) + { + this.AddInt(itm); + } + selectFirst(); } public void AddInt(int value) @@ -61,7 +81,7 @@ namespace W4Gui.Components this.numberList.Items.Add(formatStr(i)); lastIndex = -1; - + selectFirst(); } public IntList() diff --git a/W4Gui/Components/ListAddUpdateDel.cs b/W4Gui/Components/ListAddUpdateDel.cs index 248c639..deb7d09 100644 --- a/W4Gui/Components/ListAddUpdateDel.cs +++ b/W4Gui/Components/ListAddUpdateDel.cs @@ -39,6 +39,12 @@ namespace W4Gui.Components lst.Items.Add(item); } + public void LoadData(string[] items) + { + lst.Items.Clear(); + lst.Items.AddRange(items); + } + private void addBtn_Click(object sender, EventArgs e) { string val = newEntry.Text.Trim(); diff --git a/W4Gui/Components/TeamsPanel.Designer.cs b/W4Gui/Components/TeamsPanel.Designer.cs index 67f7099..e31c29b 100644 --- a/W4Gui/Components/TeamsPanel.Designer.cs +++ b/W4Gui/Components/TeamsPanel.Designer.cs @@ -39,10 +39,7 @@ this.selWorms = new W4Gui.Components.ListAddUpdateDel(); this.apperanceTab = new System.Windows.Forms.TabPage(); this.tblApperance = new System.Windows.Forms.TableLayoutPanel(); - this.selPlayer = new System.Windows.Forms.TextBox(); - this.lblPlayer = new System.Windows.Forms.Label(); this.lblGlasses = new System.Windows.Forms.Label(); - this.lblFace = new System.Windows.Forms.Label(); this.lblGloves = new System.Windows.Forms.Label(); this.lblHat = new System.Windows.Forms.Label(); this.lblSpeech = new System.Windows.Forms.Label(); @@ -54,7 +51,6 @@ this.selHat = new System.Windows.Forms.TextBox(); this.selGloves = new System.Windows.Forms.TextBox(); this.selGlasses = new System.Windows.Forms.TextBox(); - this.selFace = new System.Windows.Forms.TextBox(); this.storyTab = new System.Windows.Forms.TabPage(); this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.tblStoryFlags = new System.Windows.Forms.TableLayoutPanel(); @@ -84,6 +80,10 @@ this.tblWeapButtonSep = new System.Windows.Forms.TableLayoutPanel(); this.btnEditWeapon = new System.Windows.Forms.Button(); this.btnChangeWeapon = new System.Windows.Forms.Button(); + this.lblPlayer = new System.Windows.Forms.Label(); + this.selPlayerUsername = new System.Windows.Forms.TextBox(); + this.selFace = new System.Windows.Forms.TextBox(); + this.lblFace = new System.Windows.Forms.Label(); this.teamTabControl.SuspendLayout(); this.generalTab.SuspendLayout(); this.tblGeneral.SuspendLayout(); @@ -132,29 +132,31 @@ this.tblGeneral.ColumnCount = 2; this.tblGeneral.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tblGeneral.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tblGeneral.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblGeneral.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tblGeneral.Controls.Add(this.lblWormName, 0, 2); - this.tblGeneral.Controls.Add(this.lblSkillLevel, 0, 1); + this.tblGeneral.Controls.Add(this.selPlayerUsername, 1, 1); + this.tblGeneral.Controls.Add(this.lblPlayer, 0, 1); + this.tblGeneral.Controls.Add(this.lblWormName, 0, 3); + this.tblGeneral.Controls.Add(this.lblSkillLevel, 0, 2); this.tblGeneral.Controls.Add(this.lblTeamName, 0, 0); this.tblGeneral.Controls.Add(this.selName, 1, 0); - this.tblGeneral.Controls.Add(this.selSkill, 1, 1); - this.tblGeneral.Controls.Add(this.selWorms, 1, 2); + this.tblGeneral.Controls.Add(this.selSkill, 1, 2); + this.tblGeneral.Controls.Add(this.selWorms, 1, 3); this.tblGeneral.Dock = System.Windows.Forms.DockStyle.Top; this.tblGeneral.Location = new System.Drawing.Point(3, 3); this.tblGeneral.Name = "tblGeneral"; - this.tblGeneral.RowCount = 3; + this.tblGeneral.RowCount = 4; + this.tblGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle()); + this.tblGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.tblGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tblGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tblGeneral.Size = new System.Drawing.Size(689, 348); + this.tblGeneral.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tblGeneral.Size = new System.Drawing.Size(689, 379); this.tblGeneral.TabIndex = 0; // // lblWormName // this.lblWormName.AutoSize = true; this.lblWormName.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblWormName.Location = new System.Drawing.Point(5, 64); + this.lblWormName.Location = new System.Drawing.Point(5, 95); this.lblWormName.Name = "lblWormName"; this.lblWormName.Size = new System.Drawing.Size(83, 282); this.lblWormName.TabIndex = 4; @@ -165,7 +167,7 @@ // this.lblSkillLevel.AutoSize = true; this.lblSkillLevel.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblSkillLevel.Location = new System.Drawing.Point(5, 33); + this.lblSkillLevel.Location = new System.Drawing.Point(5, 64); this.lblSkillLevel.Name = "lblSkillLevel"; this.lblSkillLevel.Size = new System.Drawing.Size(83, 29); this.lblSkillLevel.TabIndex = 2; @@ -204,7 +206,7 @@ "CPU Level 3", "CPU Level 4", "CPU Level 5"}); - this.selSkill.Location = new System.Drawing.Point(96, 36); + this.selSkill.Location = new System.Drawing.Point(96, 67); this.selSkill.Name = "selSkill"; this.selSkill.Size = new System.Drawing.Size(588, 23); this.selSkill.TabIndex = 3; @@ -212,7 +214,7 @@ // selWorms // this.selWorms.Dock = System.Windows.Forms.DockStyle.Top; - this.selWorms.Location = new System.Drawing.Point(96, 67); + this.selWorms.Location = new System.Drawing.Point(96, 98); this.selWorms.Name = "selWorms"; this.selWorms.Size = new System.Drawing.Size(588, 276); this.selWorms.TabIndex = 5; @@ -236,8 +238,6 @@ this.tblApperance.ColumnCount = 2; this.tblApperance.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tblApperance.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tblApperance.Controls.Add(this.selPlayer, 1, 7); - this.tblApperance.Controls.Add(this.lblPlayer, 0, 7); this.tblApperance.Controls.Add(this.lblGlasses, 0, 5); this.tblApperance.Controls.Add(this.lblFace, 0, 6); this.tblApperance.Controls.Add(this.lblGloves, 0, 4); @@ -255,7 +255,7 @@ this.tblApperance.Dock = System.Windows.Forms.DockStyle.Top; this.tblApperance.Location = new System.Drawing.Point(3, 3); this.tblApperance.Name = "tblApperance"; - this.tblApperance.RowCount = 8; + this.tblApperance.RowCount = 7; this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle()); @@ -263,29 +263,10 @@ this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.tblApperance.Size = new System.Drawing.Size(689, 250); + this.tblApperance.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.tblApperance.Size = new System.Drawing.Size(689, 219); this.tblApperance.TabIndex = 1; // - // selPlayer - // - this.selPlayer.Dock = System.Windows.Forms.DockStyle.Top; - this.selPlayer.Location = new System.Drawing.Point(96, 222); - this.selPlayer.Name = "selPlayer"; - this.selPlayer.Size = new System.Drawing.Size(588, 23); - this.selPlayer.TabIndex = 17; - // - // lblPlayer - // - this.lblPlayer.AutoSize = true; - this.lblPlayer.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblPlayer.Location = new System.Drawing.Point(5, 219); - this.lblPlayer.Name = "lblPlayer"; - this.lblPlayer.Size = new System.Drawing.Size(83, 29); - this.lblPlayer.TabIndex = 16; - this.lblPlayer.Text = "Player:"; - this.lblPlayer.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // // lblGlasses // this.lblGlasses.AutoSize = true; @@ -297,17 +278,6 @@ this.lblGlasses.Text = "Glasses:"; this.lblGlasses.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; // - // lblFace - // - this.lblFace.AutoSize = true; - this.lblFace.Dock = System.Windows.Forms.DockStyle.Fill; - this.lblFace.Location = new System.Drawing.Point(5, 188); - this.lblFace.Name = "lblFace"; - this.lblFace.Size = new System.Drawing.Size(83, 29); - this.lblFace.TabIndex = 10; - this.lblFace.Text = "Face:"; - this.lblFace.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // // lblGloves // this.lblGloves.AutoSize = true; @@ -413,14 +383,6 @@ this.selGlasses.Size = new System.Drawing.Size(588, 23); this.selGlasses.TabIndex = 14; // - // selFace - // - this.selFace.Dock = System.Windows.Forms.DockStyle.Top; - this.selFace.Location = new System.Drawing.Point(96, 191); - this.selFace.Name = "selFace"; - this.selFace.Size = new System.Drawing.Size(588, 23); - this.selFace.TabIndex = 15; - // // storyTab // this.storyTab.BackColor = System.Drawing.Color.Transparent; @@ -462,6 +424,7 @@ this.tblStoryFlags.Controls.Add(this.selNewTeam, 1, 1); this.tblStoryFlags.Controls.Add(this.selStoryChapter, 1, 3); this.tblStoryFlags.Controls.Add(this.selStoryMissionsCompleted, 1, 2); + this.tblStoryFlags.Dock = System.Windows.Forms.DockStyle.Top; this.tblStoryFlags.Location = new System.Drawing.Point(3, 3); this.tblStoryFlags.Name = "tblStoryFlags"; this.tblStoryFlags.RowCount = 4; @@ -665,7 +628,7 @@ this.brnEditCluster.Dock = System.Windows.Forms.DockStyle.Fill; this.brnEditCluster.Location = new System.Drawing.Point(3, 3); this.brnEditCluster.Name = "brnEditCluster"; - this.brnEditCluster.Size = new System.Drawing.Size(288, 25); + this.brnEditCluster.Size = new System.Drawing.Size(150, 25); this.brnEditCluster.TabIndex = 0; this.brnEditCluster.Text = "Edit Weapon Cluster"; this.brnEditCluster.UseVisualStyleBackColor = true; @@ -675,9 +638,9 @@ // this.btnChangeCluster.AutoSize = true; this.btnChangeCluster.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnChangeCluster.Location = new System.Drawing.Point(297, 3); + this.btnChangeCluster.Location = new System.Drawing.Point(159, 3); this.btnChangeCluster.Name = "btnChangeCluster"; - this.btnChangeCluster.Size = new System.Drawing.Size(244, 25); + this.btnChangeCluster.Size = new System.Drawing.Size(382, 25); this.btnChangeCluster.TabIndex = 1; this.btnChangeCluster.Text = "Change Weapon Cluster"; this.btnChangeCluster.UseVisualStyleBackColor = true; @@ -768,7 +731,7 @@ this.btnEditWeapon.Dock = System.Windows.Forms.DockStyle.Fill; this.btnEditWeapon.Location = new System.Drawing.Point(3, 3); this.btnEditWeapon.Name = "btnEditWeapon"; - this.btnEditWeapon.Size = new System.Drawing.Size(288, 25); + this.btnEditWeapon.Size = new System.Drawing.Size(150, 25); this.btnEditWeapon.TabIndex = 0; this.btnEditWeapon.Text = "Edit Weapon"; this.btnEditWeapon.UseVisualStyleBackColor = true; @@ -778,14 +741,53 @@ // this.btnChangeWeapon.AutoSize = true; this.btnChangeWeapon.Dock = System.Windows.Forms.DockStyle.Fill; - this.btnChangeWeapon.Location = new System.Drawing.Point(297, 3); + this.btnChangeWeapon.Location = new System.Drawing.Point(159, 3); this.btnChangeWeapon.Name = "btnChangeWeapon"; - this.btnChangeWeapon.Size = new System.Drawing.Size(244, 25); + this.btnChangeWeapon.Size = new System.Drawing.Size(382, 25); this.btnChangeWeapon.TabIndex = 1; this.btnChangeWeapon.Text = "Change Weapon"; this.btnChangeWeapon.UseVisualStyleBackColor = true; this.btnChangeWeapon.Click += new System.EventHandler(this.btnChangeWeapon_Click); // + // lblPlayer + // + this.lblPlayer.AutoSize = true; + this.lblPlayer.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblPlayer.Location = new System.Drawing.Point(5, 33); + this.lblPlayer.Name = "lblPlayer"; + this.lblPlayer.Size = new System.Drawing.Size(83, 29); + this.lblPlayer.TabIndex = 17; + this.lblPlayer.Text = "Username:"; + this.lblPlayer.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // selPlayerUsername + // + this.selPlayerUsername.Dock = System.Windows.Forms.DockStyle.Top; + this.selPlayerUsername.Location = new System.Drawing.Point(96, 36); + this.selPlayerUsername.Name = "selPlayerUsername"; + this.selPlayerUsername.PlaceholderText = "Computer Name"; + this.selPlayerUsername.Size = new System.Drawing.Size(588, 23); + this.selPlayerUsername.TabIndex = 18; + // + // selFace + // + this.selFace.Dock = System.Windows.Forms.DockStyle.Top; + this.selFace.Location = new System.Drawing.Point(96, 191); + this.selFace.Name = "selFace"; + this.selFace.Size = new System.Drawing.Size(588, 23); + this.selFace.TabIndex = 15; + // + // lblFace + // + this.lblFace.AutoSize = true; + this.lblFace.Dock = System.Windows.Forms.DockStyle.Fill; + this.lblFace.Location = new System.Drawing.Point(5, 188); + this.lblFace.Name = "lblFace"; + this.lblFace.Size = new System.Drawing.Size(83, 29); + this.lblFace.TabIndex = 10; + this.lblFace.Text = "Face:"; + this.lblFace.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // // TeamsPanel // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -843,13 +845,11 @@ private TextBox selFlag; private IntUpDown selGrave; private TextBox selSpeech; - private Label lblFace; private Label lblGloves; private Label lblGlasses; private TextBox selHat; private TextBox selGloves; private TextBox selGlasses; - private TextBox selFace; private TableLayoutPanel tblStoryFlags; private Label lblStoryChapter; private Label lblNewTeam; @@ -858,8 +858,6 @@ private IntUpDown selNewTeam; private IntUpDown selStoryChapter; private Label lblStoryMissionsComplete; - private TextBox selPlayer; - private Label lblPlayer; private TableLayoutPanel tableLayoutPanel1; private IntList selStoryMissionsCompleted; private TableLayoutPanel tblStoryToggles; @@ -880,5 +878,9 @@ private TableLayoutPanel tblClusterSep; private Button brnEditCluster; private Button btnChangeCluster; + private TextBox selPlayerUsername; + private Label lblPlayer; + private Label lblFace; + private TextBox selFace; } } diff --git a/W4Gui/Components/TeamsPanel.cs b/W4Gui/Components/TeamsPanel.cs index 47cbd27..36fac19 100644 --- a/W4Gui/Components/TeamsPanel.cs +++ b/W4Gui/Components/TeamsPanel.cs @@ -1,4 +1,5 @@ -using LibW4M.Data.WeaponFactory; +using LibW4M.Data.Teams; +using LibW4M.Data.WeaponFactory; using System; using System.Collections.Generic; using System.ComponentModel; @@ -22,6 +23,74 @@ namespace W4Gui.Components } + public void SaveTeamData(ref Team team) + { + // Load general + team.Name = DataManager.SaveFile.LookupString(this.selName.Text); + team.Skill = (SkillLevel)this.selSkill.SelectedIndex; + team.Player = DataManager.SaveFile.LookupString(this.selPlayerUsername.Text); + team.Worms = DataManager.SaveFile.StringArrayToXomStringArray(selWorms.Items); + + // Load apperance + team.Tash = DataManager.SaveFile.LookupString(this.selFace.Text); + team.Flag = DataManager.SaveFile.LookupString(this.selFlag.Text); + team.Glasses = DataManager.SaveFile.LookupString(this.selGlasses.Text); + team.Gloves = DataManager.SaveFile.LookupString(this.selGloves.Text); + team.Hat = DataManager.SaveFile.LookupString(this.selHat.Text); + team.Grave = this.selGrave.Value; + team.Speech = DataManager.SaveFile.LookupString(this.selSpeech.Text); + + // Load story flags + team.AllMissionsDone = this.selAllMissionsDone.Checked; + team.AllTutorialsDone = this.selAllTutorialsDone.Checked; + team.NewTeam = this.selNewTeam.Value; + team.InGame = this.selInGame.Checked; + team.StoryChapter = this.selStoryChapter.Value; + team.TutorialsDone = this.selTutorialsDone.Value; + team.StoryMissionsCompleted = this.selStoryMissionsCompleted.Values; + + // Load weapon data + team.SWeapon = this.selSWeapon.Value; + team.SecretWeapon = this.weapon; + team.SecretWeaponCluster = this.weaponCluster; + team.CustomWeapon = DataManager.SaveFile.LookupString(this.selTeamWeapName.Text); + } + + public void LoadTeamData(Team team) + { + // Load general + this.selName.Text = team.Name.Value; + this.selSkill.SelectedIndex = (int)team.Skill; + this.selPlayerUsername.Text = team.Player.Value; + this.selWorms.LoadData(DataManager.SaveFile.XomStringArrayToStringArray(team.Worms)); + + // Load apperance + this.selFace.Text = team.Tash.Value; + this.selFlag.Text = team.Flag.Value; + this.selGlasses.Text = team.Glasses.Value; + this.selGloves.Text = team.Gloves.Value; + this.selHat.Text = team.Hat.Value; + this.selGrave.Value = team.Grave; + this.selSpeech.Text = team.Speech.Value; + + // Load story flags + this.selAllMissionsDone.Checked = team.AllMissionsDone; + this.selAllTutorialsDone.Checked = team.AllTutorialsDone; + this.selNewTeam.Value = team.NewTeam; + this.selInGame.Checked = team.InGame; + this.selStoryChapter.Value = team.StoryChapter; + this.selTutorialsDone.Value = team.TutorialsDone; + this.selStoryMissionsCompleted.LoadItems(team.StoryMissionsCompleted); + + // Load weapon data + this.selSWeapon.Value = team.SWeapon; + this.weapon = team.SecretWeapon; + this.weaponCluster = team.SecretWeaponCluster; + this.selTeamWeapName.Text = team.CustomWeapon.Value; + + + } + private void btnChangeWeapon_Click(object sender, EventArgs e) { CollectiveSelectionDialog csd = new CollectiveSelectionDialog(DataManager.SaveFile.WeaponFactoryCollective); diff --git a/W4Gui/Components/WeaponsPanel.Designer.cs b/W4Gui/Components/WeaponsPanel.Designer.cs index f5ccdc3..2d923eb 100644 --- a/W4Gui/Components/WeaponsPanel.Designer.cs +++ b/W4Gui/Components/WeaponsPanel.Designer.cs @@ -324,9 +324,8 @@ this.powerTable.Controls.Add(this.selBlastDmgRad, 1, 3); this.powerTable.Controls.Add(this.selMaxThrowStr, 1, 4); this.powerTable.Dock = System.Windows.Forms.DockStyle.Top; - this.powerTable.Location = new System.Drawing.Point(0, 0); + this.powerTable.Location = new System.Drawing.Point(3, 3); this.powerTable.Name = "powerTable"; - this.powerTable.Padding = new System.Windows.Forms.Padding(3); this.powerTable.RightToLeft = System.Windows.Forms.RightToLeft.No; this.powerTable.RowCount = 6; this.powerTable.RowStyles.Add(new System.Windows.Forms.RowStyle()); diff --git a/W4Gui/Components/WeaponsPanel.cs b/W4Gui/Components/WeaponsPanel.cs index 5fc2106..2357cf1 100644 --- a/W4Gui/Components/WeaponsPanel.cs +++ b/W4Gui/Components/WeaponsPanel.cs @@ -73,17 +73,8 @@ namespace W4Gui.Components weapon.DetonationFX = DataManager.SaveFile.LookupString(this.selDetonationFx.Text); // Save graphical resources - string[] graphicalResources = this.selGraphicalResoures.Items; - string[] graphicalLocators = this.selGraphicalLocators.Items; - - weapon.GraphicalResources = new XomString[graphicalResources.Length]; - for (int i = 0; i < graphicalResources.Length; i++) - weapon.GraphicalResources[i] = DataManager.SaveFile.LookupString(graphicalResources[i]); - - weapon.GraphicalLocators = new XomString[graphicalLocators.Length]; - for (int i = 0; i < graphicalLocators.Length; i++) - weapon.GraphicalLocators[i] = DataManager.SaveFile.LookupString(graphicalLocators[i]); - + weapon.GraphicalResources = DataManager.SaveFile.StringArrayToXomStringArray(this.selGraphicalResoures.Items); + weapon.GraphicalLocators = DataManager.SaveFile.StringArrayToXomStringArray(this.selGraphicalLocators.Items); // Save toggles @@ -125,14 +116,8 @@ namespace W4Gui.Components this.selArielFx.Text = weapon.ArielFX.Value; this.selDetonationFx.Text = weapon.DetonationFX.Value; - selGraphicalLocators.Clear(); - selGraphicalResoures.Clear(); - - foreach(XomString graphicalRes in weapon.GraphicalResources) - this.selGraphicalResoures.AddItem(graphicalRes.Value); - - foreach (XomString graphicalLoc in weapon.GraphicalLocators) - this.selGraphicalLocators.AddItem(graphicalLoc.Value); + this.selGraphicalResoures.LoadData(DataManager.SaveFile.XomStringArrayToStringArray(weapon.GraphicalResources)); + this.selGraphicalLocators.LoadData(DataManager.SaveFile.XomStringArrayToStringArray(weapon.GraphicalLocators)); // Read toggles diff --git a/W4Gui/Dialogs/CollectiveSelectionDialog.cs b/W4Gui/Dialogs/CollectiveSelectionDialog.cs index 55ce636..eda3da8 100644 --- a/W4Gui/Dialogs/CollectiveSelectionDialog.cs +++ b/W4Gui/Dialogs/CollectiveSelectionDialog.cs @@ -13,6 +13,7 @@ namespace W4Gui.Dialogs { public partial class CollectiveSelectionDialog : Form { + private bool saving = false; private SaveDataCollective collective; private SaveDataEntry selectedEntry; public SaveDataEntry SelectedEntry @@ -33,13 +34,18 @@ namespace W4Gui.Dialogs private void CollectiveSelectionDialog_FormClosing(object sender, FormClosingEventArgs e) { - this.DialogResult = DialogResult.Cancel; - this.Close(); + if (!saving) + { + this.DialogResult = DialogResult.Cancel; + this.Close(); + this.saving = true; + } } private void selectButton_Click(object sender, EventArgs e) { this.selectedEntry = collective[this.collectiveList.CurrentlySelected]; + this.saving = true; this.DialogResult = DialogResult.OK; this.Close(); } diff --git a/W4Gui/Dialogs/EditWeaponDialog.cs b/W4Gui/Dialogs/EditWeaponDialog.cs index 4820780..7ab23f2 100644 --- a/W4Gui/Dialogs/EditWeaponDialog.cs +++ b/W4Gui/Dialogs/EditWeaponDialog.cs @@ -13,6 +13,7 @@ namespace W4Gui.Dialogs { public partial class EditWeaponDialog : Form { + private bool saved = false; WeaponData weapon; public EditWeaponDialog(ref WeaponData weapon) { @@ -23,20 +24,25 @@ namespace W4Gui.Dialogs private void EditWeaponDialog_FormClosing(object sender, FormClosingEventArgs e) { - if(MessageBox.Show("Are you sure you want to exit?\nyou'll loose any changes you've made to the weapon.", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + if (!saved) { - this.DialogResult = DialogResult.None; - this.Close(); - } - else - { - e.Cancel = true; + if (MessageBox.Show("Are you sure you want to exit?\nyou'll loose any changes you've made to the weapon.", "Are you sure?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + this.saved = true; + this.DialogResult = DialogResult.Cancel; + this.Close(); + } + else + { + e.Cancel = true; + } } } private void btnSave_Click(object sender, EventArgs e) { weaponsPanel.SaveWeaponData(ref weapon); + this.saved = true; this.DialogResult = DialogResult.OK; this.Close(); } diff --git a/W4Gui/Main.Designer.cs b/W4Gui/Main.Designer.cs index 559c567..05ef773 100644 --- a/W4Gui/Main.Designer.cs +++ b/W4Gui/Main.Designer.cs @@ -43,19 +43,10 @@ namespace W4Gui this.weaponPage = new W4Gui.Tabs.WeaponsTab(); this.teamTab = new System.Windows.Forms.TabPage(); this.teamsPage = new W4Gui.Tabs.TeamsTab(); - this.groupBox1 = new System.Windows.Forms.GroupBox(); - this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); - this.label1 = new System.Windows.Forms.Label(); - this.comboBox1 = new System.Windows.Forms.ComboBox(); - this.tableLayoutPanel11 = new System.Windows.Forms.TableLayoutPanel(); - this.label21 = new System.Windows.Forms.Label(); - this.label22 = new System.Windows.Forms.Label(); this.mainMenuStrip.SuspendLayout(); this.mainTabControl.SuspendLayout(); this.weaponTab.SuspendLayout(); this.teamTab.SuspendLayout(); - this.tableLayoutPanel1.SuspendLayout(); - this.tableLayoutPanel11.SuspendLayout(); this.SuspendLayout(); // // mainMenuStrip @@ -160,10 +151,12 @@ namespace W4Gui // // teamTab // + this.teamTab.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.teamTab.Controls.Add(this.teamsPage); this.teamTab.Location = new System.Drawing.Point(4, 24); this.teamTab.Name = "teamTab"; - this.teamTab.Size = new System.Drawing.Size(192, 72); + this.teamTab.Padding = new System.Windows.Forms.Padding(3); + this.teamTab.Size = new System.Drawing.Size(868, 509); this.teamTab.TabIndex = 1; this.teamTab.Text = "Teams"; this.teamTab.UseVisualStyleBackColor = true; @@ -171,101 +164,11 @@ namespace W4Gui // teamsPage // this.teamsPage.Dock = System.Windows.Forms.DockStyle.Fill; - this.teamsPage.Location = new System.Drawing.Point(0, 0); + this.teamsPage.Location = new System.Drawing.Point(3, 3); this.teamsPage.Name = "teamsPage"; - this.teamsPage.Size = new System.Drawing.Size(192, 72); + this.teamsPage.Size = new System.Drawing.Size(858, 499); this.teamsPage.TabIndex = 0; // - // groupBox1 - // - this.groupBox1.Location = new System.Drawing.Point(0, 0); - this.groupBox1.Name = "groupBox1"; - this.groupBox1.Size = new System.Drawing.Size(200, 100); - this.groupBox1.TabIndex = 0; - this.groupBox1.TabStop = false; - // - // tableLayoutPanel1 - // - this.tableLayoutPanel1.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Inset; - this.tableLayoutPanel1.ColumnCount = 2; - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel1.Controls.Add(this.label1, 0, 1); - this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel1.Name = "tableLayoutPanel1"; - this.tableLayoutPanel1.RowCount = 2; - this.tableLayoutPanel1.Size = new System.Drawing.Size(200, 100); - this.tableLayoutPanel1.TabIndex = 0; - // - // label1 - // - this.label1.AutoSize = true; - this.label1.Dock = System.Windows.Forms.DockStyle.Fill; - this.label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.label1.Location = new System.Drawing.Point(5, 4); - this.label1.Name = "label1"; - this.label1.Size = new System.Drawing.Size(83, 94); - this.label1.TabIndex = 7; - this.label1.Text = "Weapon Type:"; - this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // comboBox1 - // - this.comboBox1.DisplayMember = "0"; - this.comboBox1.Dock = System.Windows.Forms.DockStyle.Top; - this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboBox1.FormattingEnabled = true; - this.comboBox1.Items.AddRange(new object[] { - "Air Strike", - "Launched", - "Thrown"}); - this.comboBox1.Location = new System.Drawing.Point(96, 7); - this.comboBox1.Name = "comboBox1"; - this.comboBox1.Size = new System.Drawing.Size(651, 23); - this.comboBox1.TabIndex = 6; - // - // tableLayoutPanel11 - // - this.tableLayoutPanel11.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Inset; - this.tableLayoutPanel11.ColumnCount = 2; - this.tableLayoutPanel11.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel11.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); - this.tableLayoutPanel11.Controls.Add(this.label21, 0, 4); - this.tableLayoutPanel11.Location = new System.Drawing.Point(0, 0); - this.tableLayoutPanel11.Name = "tableLayoutPanel11"; - this.tableLayoutPanel11.RowCount = 5; - this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel11.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); - this.tableLayoutPanel11.Size = new System.Drawing.Size(200, 100); - this.tableLayoutPanel11.TabIndex = 0; - // - // label21 - // - this.label21.AutoSize = true; - this.label21.Dock = System.Windows.Forms.DockStyle.Fill; - this.label21.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.label21.Location = new System.Drawing.Point(5, 90); - this.label21.Name = "label21"; - this.label21.Size = new System.Drawing.Size(117, 20); - this.label21.TabIndex = 14; - this.label21.Text = "Max Throw Strength:"; - this.label21.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // - // label22 - // - this.label22.AutoSize = true; - this.label22.Dock = System.Windows.Forms.DockStyle.Fill; - this.label22.FlatStyle = System.Windows.Forms.FlatStyle.Flat; - this.label22.Location = new System.Drawing.Point(5, 8); - this.label22.Name = "label22"; - this.label22.Size = new System.Drawing.Size(117, 15); - this.label22.TabIndex = 13; - this.label22.Text = "Blast DMG Radius:"; - this.label22.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; - // // Main // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -284,10 +187,6 @@ namespace W4Gui this.mainTabControl.ResumeLayout(false); this.weaponTab.ResumeLayout(false); this.teamTab.ResumeLayout(false); - this.tableLayoutPanel1.ResumeLayout(false); - this.tableLayoutPanel1.PerformLayout(); - this.tableLayoutPanel11.ResumeLayout(false); - this.tableLayoutPanel11.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); @@ -301,13 +200,6 @@ namespace W4Gui private ToolStripMenuItem saveToolStripMenuItem; private TabControl mainTabControl; private TabPage weaponTab; - private GroupBox groupBox1; - private TableLayoutPanel tableLayoutPanel1; - private Label label1; - private ComboBox comboBox1; - private TableLayoutPanel tableLayoutPanel11; - private Label label21; - private Label label22; private WeaponsTab weaponPage; private ToolStripMenuItem convertToolStripMenuItem; private ToolStripMenuItem convertToPS2ToolStripMenuItem; diff --git a/W4Gui/Properties/PublishProfiles/FolderProfile.pubxml.user b/W4Gui/Properties/PublishProfiles/FolderProfile.pubxml.user index a881485..3374ef0 100644 --- a/W4Gui/Properties/PublishProfiles/FolderProfile.pubxml.user +++ b/W4Gui/Properties/PublishProfiles/FolderProfile.pubxml.user @@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. --> - True|2023-01-11T09:22:28.8737310Z;True|2023-01-11T01:16:55.3469226-08:00; + True|2023-01-14T00:57:56.0824690Z;True|2023-01-11T01:22:28.8737310-08:00;True|2023-01-11T01:16:55.3469226-08:00; \ No newline at end of file diff --git a/W4Gui/Tabs/TeamsTab.Designer.cs b/W4Gui/Tabs/TeamsTab.Designer.cs index 46d0154..b876c16 100644 --- a/W4Gui/Tabs/TeamsTab.Designer.cs +++ b/W4Gui/Tabs/TeamsTab.Designer.cs @@ -51,8 +51,8 @@ // teamsSplitContainer.Panel2 // this.teamsSplitContainer.Panel2.Controls.Add(this.teamsPanel); - this.teamsSplitContainer.Size = new System.Drawing.Size(721, 352); - this.teamsSplitContainer.SplitterDistance = 241; + this.teamsSplitContainer.Size = new System.Drawing.Size(797, 464); + this.teamsSplitContainer.SplitterDistance = 265; this.teamsSplitContainer.TabIndex = 0; // // teamsList @@ -60,16 +60,19 @@ this.teamsList.Dock = System.Windows.Forms.DockStyle.Fill; this.teamsList.Location = new System.Drawing.Point(0, 0); this.teamsList.Name = "teamsList"; - this.teamsList.Size = new System.Drawing.Size(237, 348); + this.teamsList.Size = new System.Drawing.Size(261, 460); this.teamsList.TabIndex = 0; + this.teamsList.NewButton += new System.EventHandler(this.teamsList_NewButton); + this.teamsList.DeleteButton += new System.EventHandler(this.teamsList_DeleteButton); // // teamsPanel // this.teamsPanel.BackColor = System.Drawing.Color.LightGray; this.teamsPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.teamsPanel.Enabled = false; this.teamsPanel.Location = new System.Drawing.Point(0, 0); this.teamsPanel.Name = "teamsPanel"; - this.teamsPanel.Size = new System.Drawing.Size(472, 348); + this.teamsPanel.Size = new System.Drawing.Size(524, 460); this.teamsPanel.TabIndex = 0; // // TeamsTab @@ -78,7 +81,7 @@ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.Controls.Add(this.teamsSplitContainer); this.Name = "TeamsTab"; - this.Size = new System.Drawing.Size(721, 352); + this.Size = new System.Drawing.Size(797, 464); this.teamsSplitContainer.Panel1.ResumeLayout(false); this.teamsSplitContainer.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.teamsSplitContainer)).EndInit(); diff --git a/W4Gui/Tabs/TeamsTab.cs b/W4Gui/Tabs/TeamsTab.cs index c175278..079d9b8 100644 --- a/W4Gui/Tabs/TeamsTab.cs +++ b/W4Gui/Tabs/TeamsTab.cs @@ -1,4 +1,5 @@ -using System; +using LibW4M.Data.Teams; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; @@ -10,11 +11,51 @@ using System.Windows.Forms; namespace W4Gui.Tabs { - public partial class TeamsTab : UserControl + public partial class TeamsTab : TabEntry { public TeamsTab() { InitializeComponent(); + this.teamsList.List.Selected += teamsList_Selected; + this.teamsList.List.Unselected += teamsList_Unselected; + } + + public override void SaveFromControl() + { + if (teamsList.List.IsItemSelected) + teamsList_Unselected(null, null); + } + + public override void LoadIntoControl() + { + this.teamsList.List.LoadCollective(DataManager.SaveFile.TeamDataColective); + teamsPanel.Enabled = false; + } + + private void teamsList_Unselected(object? sender, EventArgs e) + { + Team team = DataManager.SaveFile.TeamDataColective[teamsList.List.LastSelected] as Team; + teamsPanel.SaveTeamData(ref team); + teamsList.List.UpdateName(teamsList.List.LastSelected, team.Name.Value); + } + + private void teamsList_Selected(object? sender, EventArgs e) + { + Team team = DataManager.SaveFile.TeamDataColective[teamsList.List.CurrentlySelected] as Team; + teamsPanel.LoadTeamData(team); + teamsPanel.Enabled = true; + } + + private void teamsList_NewButton(object sender, EventArgs e) + { + throw new NotImplementedException("Adding new teams from here not implemented yet ;)"); + } + + private void teamsList_DeleteButton(object sender, EventArgs e) + { + throw new NotImplementedException("Removing weapons from here not implemented yet ;)"); + } + } } diff --git a/W4Gui/Tabs/WeaponsTab.Designer.cs b/W4Gui/Tabs/WeaponsTab.Designer.cs index 056ae62..d0a5e65 100644 --- a/W4Gui/Tabs/WeaponsTab.Designer.cs +++ b/W4Gui/Tabs/WeaponsTab.Designer.cs @@ -60,7 +60,7 @@ namespace W4Gui.Tabs // this.weaponSplitContainer.Panel2.Controls.Add(this.weaponClusterTabControl); this.weaponSplitContainer.Size = new System.Drawing.Size(797, 464); - this.weaponSplitContainer.SplitterDistance = 264; + this.weaponSplitContainer.SplitterDistance = 265; this.weaponSplitContainer.TabIndex = 1; // // weaponList @@ -68,10 +68,8 @@ namespace W4Gui.Tabs this.weaponList.Dock = System.Windows.Forms.DockStyle.Fill; this.weaponList.Location = new System.Drawing.Point(0, 0); this.weaponList.Name = "weaponList"; - this.weaponList.Size = new System.Drawing.Size(260, 460); + this.weaponList.Size = new System.Drawing.Size(261, 460); this.weaponList.TabIndex = 0; - this.weaponList.List.Unselected += new System.EventHandler(this.weaponList_Unselected); - this.weaponList.List.Selected += new System.EventHandler(this.weaponList_Selected); this.weaponList.NewButton += new System.EventHandler(this.weaponList_NewButton); this.weaponList.DeleteButton += new System.EventHandler(this.weaponList_DeleteButton); // @@ -84,7 +82,7 @@ namespace W4Gui.Tabs this.weaponClusterTabControl.Location = new System.Drawing.Point(0, 0); this.weaponClusterTabControl.Name = "weaponClusterTabControl"; this.weaponClusterTabControl.SelectedIndex = 0; - this.weaponClusterTabControl.Size = new System.Drawing.Size(525, 460); + this.weaponClusterTabControl.Size = new System.Drawing.Size(524, 460); this.weaponClusterTabControl.TabIndex = 0; // // mainWeaponPage @@ -95,7 +93,7 @@ namespace W4Gui.Tabs this.mainWeaponPage.Location = new System.Drawing.Point(4, 24); this.mainWeaponPage.Name = "mainWeaponPage"; this.mainWeaponPage.Padding = new System.Windows.Forms.Padding(3); - this.mainWeaponPage.Size = new System.Drawing.Size(517, 432); + this.mainWeaponPage.Size = new System.Drawing.Size(516, 432); this.mainWeaponPage.TabIndex = 0; this.mainWeaponPage.Text = "Main Weapon"; // @@ -104,7 +102,7 @@ namespace W4Gui.Tabs this.weaponPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.weaponPanel.Location = new System.Drawing.Point(3, 3); this.weaponPanel.Name = "weaponPanel"; - this.weaponPanel.Size = new System.Drawing.Size(507, 422); + this.weaponPanel.Size = new System.Drawing.Size(506, 422); this.weaponPanel.TabIndex = 0; // // clustersPage @@ -115,7 +113,7 @@ namespace W4Gui.Tabs this.clustersPage.Location = new System.Drawing.Point(4, 24); this.clustersPage.Name = "clustersPage"; this.clustersPage.Padding = new System.Windows.Forms.Padding(3); - this.clustersPage.Size = new System.Drawing.Size(192, 72); + this.clustersPage.Size = new System.Drawing.Size(517, 432); this.clustersPage.TabIndex = 1; this.clustersPage.Text = "Clusters"; // @@ -124,7 +122,7 @@ namespace W4Gui.Tabs this.clusterPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.clusterPanel.Location = new System.Drawing.Point(3, 3); this.clusterPanel.Name = "clusterPanel"; - this.clusterPanel.Size = new System.Drawing.Size(182, 62); + this.clusterPanel.Size = new System.Drawing.Size(507, 422); this.clusterPanel.TabIndex = 0; // // WeaponsTab diff --git a/W4Gui/Tabs/WeaponsTab.cs b/W4Gui/Tabs/WeaponsTab.cs index d7542c1..37b89e3 100644 --- a/W4Gui/Tabs/WeaponsTab.cs +++ b/W4Gui/Tabs/WeaponsTab.cs @@ -24,10 +24,14 @@ namespace W4Gui.Tabs { weaponList.List.LoadCollective(DataManager.SaveFile.WeaponFactoryCollective); weaponClusterTabControl.Enabled = false; - } + } + + public WeaponsTab() { InitializeComponent(); + this.weaponList.List.Selected += weaponList_Selected; + this.weaponList.List.Unselected += weaponList_Unselected; } private void weaponList_Unselected(object sender, EventArgs e)