From 609c8fc4ddbf1433a934fc03a4524cec3602925a Mon Sep 17 00:00:00 2001
From: Li
Date: Tue, 7 Mar 2023 20:49:53 +1300
Subject: [PATCH] Add delete feature
---
.../InputMapping/InputEventMappingData.cs | 6 +
LibW4M/Data/SaveDataCollective.cs | 6 +-
LibW4M/Data/SaveDataEntry.cs | 16 +-
LibW4M/Data/Schemes/SchemeData.cs | 62 ++++++++
LibW4M/Data/Stats/StatsContainerData.cs | 2 +-
LibW4M/Data/Stats/TeamStatsCollective.cs | 16 ++
LibW4M/Data/Teams/TeamData.cs | 78 ++++++++-
LibW4M/Data/WeaponFactory/WeaponStore.cs | 23 ++-
.../Data/WeaponFactory/WeaponsCollective.cs | 11 ++
LibW4M/Data/X/DataBank.cs | 148 +++++++++++++++---
LibW4M/W4SaveFile.cs | 20 +--
LibXom/Data/XomContainer.cs | 2 +-
LibXom/Data/XomFile.cs | 20 ++-
LibXom/Data/XomFileComponent.cs | 14 +-
LibXom/Data/XomString.cs | 14 +-
LibXom/Data/XomType.cs | 4 +-
W4Gui/Components/CollectiveListAddDelete.cs | 28 +++-
W4Gui/Components/CollectiveListBox.cs | 20 +++
W4Gui/Main.cs | 6 +-
W4Gui/Tabs/HighscoresTab.cs | 5 +-
W4Gui/Tabs/InputEventMappingsTab.cs | 15 +-
W4Gui/Tabs/OtherTabs/InputMappingsTab.cs | 7 +-
W4Gui/Tabs/SchemeTab.cs | 5 +-
W4Gui/Tabs/StatsTab/StatisticsTab.cs | 5 +-
W4Gui/Tabs/StatsTab/TeamStatisticsTab.cs | 5 +-
W4Gui/Tabs/TeamsTab.cs | 6 +-
W4Gui/Tabs/UnlockableItemsTab.Designer.cs | 10 +-
W4Gui/Tabs/UnlockableItemsTab.cs | 24 +--
W4Gui/Tabs/VariablesTab/FloatVariablesTab.cs | 6 +-
W4Gui/Tabs/VariablesTab/IntVariablesTab.cs | 5 +-
W4Gui/Tabs/VariablesTab/StringVariablesTab.cs | 5 +-
W4Gui/Tabs/VariablesTab/UIntVariablesTab.cs | 5 +-
W4Gui/Tabs/VariablesTab/VectorVariablesTab.cs | 5 +-
W4Gui/Tabs/WeaponsTab.cs | 5 +-
34 files changed, 491 insertions(+), 118 deletions(-)
diff --git a/LibW4M/Data/InputMapping/InputEventMappingData.cs b/LibW4M/Data/InputMapping/InputEventMappingData.cs
index 2913249..6335c38 100644
--- a/LibW4M/Data/InputMapping/InputEventMappingData.cs
+++ b/LibW4M/Data/InputMapping/InputEventMappingData.cs
@@ -32,6 +32,12 @@ namespace LibW4M.Data.InputMapping
public InputEventMappingData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}
+ public override void DeleteEntries()
+ {
+ foreach (InputMappingData mappingData in InputMappings)
+ mappingData.DeleteEntries();
+ base.DeleteEntries();
+ }
public override void Load()
{
diff --git a/LibW4M/Data/SaveDataCollective.cs b/LibW4M/Data/SaveDataCollective.cs
index 3502e48..cdd370a 100644
--- a/LibW4M/Data/SaveDataCollective.cs
+++ b/LibW4M/Data/SaveDataCollective.cs
@@ -35,15 +35,15 @@ namespace LibW4M.Data
{
}
- public virtual void Delete(SaveDataEntry store)
+ public virtual void Delete(SaveDataEntry entry)
{
for (int i = 0; i < this.Length; i++)
{
SaveDataEntry saveDataEntry = this[i];
- if (saveDataEntry.uuid.Equals(store.uuid, StringComparison.InvariantCultureIgnoreCase))
+ if (saveDataEntry.Equals(entry))
{
+ saveDataEntry.DeleteEntries();
collectiveEntries.RemoveAt(i);
- saveDataEntry.delete();
break;
}
}
diff --git a/LibW4M/Data/SaveDataEntry.cs b/LibW4M/Data/SaveDataEntry.cs
index cb8d319..0904cee 100644
--- a/LibW4M/Data/SaveDataEntry.cs
+++ b/LibW4M/Data/SaveDataEntry.cs
@@ -9,7 +9,7 @@ namespace LibW4M.Data
{
public abstract class SaveDataEntry
{
- internal Guid guid = Guid.NewGuid();
+ private Guid guid = Guid.NewGuid();
internal W4SaveFile fileBelongs;
internal XomContainer mainContainer;
internal int containerId
@@ -19,7 +19,7 @@ namespace LibW4M.Data
return mainContainer.Id;
}
}
- internal string uuid
+ public string Uuid
{
get
{
@@ -32,9 +32,19 @@ namespace LibW4M.Data
return mainContainer.Type.Name;
}
}
+ public override int GetHashCode()
+ {
+ return this.Uuid.GetHashCode();
+ }
+ public override bool Equals(object? obj)
+ {
+ if (obj is not SaveDataEntry) return false;
+ return this.Uuid.Equals((obj as SaveDataEntry).Uuid, StringComparison.InvariantCultureIgnoreCase);
+ }
+
public abstract void Load();
public abstract void Save();
- internal virtual void delete()
+ public virtual void DeleteEntries()
{
this.mainContainer.Delete();
}
diff --git a/LibW4M/Data/Schemes/SchemeData.cs b/LibW4M/Data/Schemes/SchemeData.cs
index b2c43d9..98bd5b1 100644
--- a/LibW4M/Data/Schemes/SchemeData.cs
+++ b/LibW4M/Data/Schemes/SchemeData.cs
@@ -216,6 +216,68 @@ namespace LibW4M.Data.Schemes
}
}
+ public override void DeleteEntries()
+ {
+ this.Airstrike.DeleteEntries();
+ this.BananaBomb.DeleteEntries();
+ this.BaseballBat.DeleteEntries();
+ this.Bazooka.DeleteEntries();
+ this.ClusterGrenade.DeleteEntries();
+ this.ConcreteDonkey.DeleteEntries();
+ this.CrateShower.DeleteEntries();
+ this.CrateSpy.DeleteEntries();
+ this.DoubleDamage.DeleteEntries();
+ this.Dynamite.DeleteEntries();
+ this.FirePunch.DeleteEntries();
+ this.GasCanister.DeleteEntries();
+ this.Girder.DeleteEntries();
+ this.Grenade.DeleteEntries();
+ this.HolyHandGrenade.DeleteEntries();
+ this.HomingMissile.DeleteEntries();
+ this.Jetpack.DeleteEntries();
+ this.Landmine.DeleteEntries();
+ this.NinjaRope.DeleteEntries();
+ this.OldWoman.DeleteEntries();
+ this.Parachute.DeleteEntries();
+ this.Prod.DeleteEntries();
+ this.SelectWorm.DeleteEntries();
+ this.Sheep.DeleteEntries();
+ this.Shotgun.DeleteEntries();
+ this.SkipGo.DeleteEntries();
+ this.SuperSheep.DeleteEntries();
+ this.Redbull.DeleteEntries();
+ this.Flood.DeleteEntries();
+ this.Armour.DeleteEntries();
+ this.WeaponFactoryWeapon.DeleteEntries();
+ this.AlienAbduction.DeleteEntries();
+ this.Fatkins.DeleteEntries();
+ this.Scouser.DeleteEntries();
+ this.NoMoreNails.DeleteEntries();
+ this.PoisonArrow.DeleteEntries();
+ this.SentryGun.DeleteEntries();
+ this.SniperRifle.DeleteEntries();
+ this.SuperAirstrike.DeleteEntries();
+ this.BubbleTrouble.DeleteEntries();
+ this.Starburst.DeleteEntries();
+ this.Surrender.DeleteEntries();
+ this.MineLayerMystery.DeleteEntries();
+ this.MineTripletMystery.DeleteEntries();
+ this.BarrelTripletMystery.DeleteEntries();
+ this.FloodMystery.DeleteEntries();
+ this.DisarmMystery.DeleteEntries();
+ this.TeleportMystery.DeleteEntries();
+ this.QuickWalkMystery.DeleteEntries();
+ this.LowGravityMystery.DeleteEntries();
+ this.DoubleTurnTimeMystery.DeleteEntries();
+ this.HealthMystery.DeleteEntries();
+ this.DamageMystery.DeleteEntries();
+ this.SuperHealthMystery.DeleteEntries();
+ this.SpecialWeaponMystery.DeleteEntries();
+ this.BadPoisonMystery.DeleteEntries();
+ this.GoodPoisonMystery.DeleteEntries();
+ base.DeleteEntries();
+ }
+
public override void Save()
{
// Save all WeaponSettingsData.
diff --git a/LibW4M/Data/Stats/StatsContainerData.cs b/LibW4M/Data/Stats/StatsContainerData.cs
index 3dd04c4..9b63525 100644
--- a/LibW4M/Data/Stats/StatsContainerData.cs
+++ b/LibW4M/Data/Stats/StatsContainerData.cs
@@ -34,7 +34,7 @@ namespace LibW4M.Data.Stats
StatsContainerData? stat = this.fileBelongs.TeamStatsCollective[i] as StatsContainerData;
if (stat is null) continue;
- if (stat.uuid.Equals(this.uuid))
+ if (stat.Uuid.Equals(this.Uuid))
{
if (i > this.fileBelongs.TeamStatsCollective.TeamNames.Count) break;
XomString xStr = this.fileBelongs.LookupString(newName);
diff --git a/LibW4M/Data/Stats/TeamStatsCollective.cs b/LibW4M/Data/Stats/TeamStatsCollective.cs
index 98f0343..83c1711 100644
--- a/LibW4M/Data/Stats/TeamStatsCollective.cs
+++ b/LibW4M/Data/Stats/TeamStatsCollective.cs
@@ -45,6 +45,22 @@ namespace LibW4M.Data.Stats
}
}
+ public override void Delete(SaveDataEntry entry)
+ {
+ for (int i = 0; i < this.Length; i++)
+ {
+ SaveDataEntry saveDataEntry = this[i];
+ if (saveDataEntry.Equals(entry))
+ {
+ collectiveEntries.RemoveAt(i);
+ if(i > 0 && i < TeamNames.Count)
+ TeamNames.RemoveAt(i);
+ saveDataEntry.DeleteEntries();
+ break;
+ }
+ }
+ }
+
public override void Save()
{
// Decompress the collective
diff --git a/LibW4M/Data/Teams/TeamData.cs b/LibW4M/Data/Teams/TeamData.cs
index b9e4dc4..fde22a4 100644
--- a/LibW4M/Data/Teams/TeamData.cs
+++ b/LibW4M/Data/Teams/TeamData.cs
@@ -20,11 +20,36 @@ namespace LibW4M.Data.Teams
}
}
+ private string secretWeaponUuid;
+ private string secretWeaponClusterUuid;
+ public WeaponData SecretWeapon
+ {
+ get
+ {
+ WeaponData? data = fileBelongs.WeaponFactoryCollective.findWeaponWithContainerUuid(secretWeaponUuid);
+ if (data is null) return new WeaponData(fileBelongs, fileBelongs.LookupContainerByUuid(secretWeaponUuid));
+ return data;
+ }
+ set
+ {
+ this.secretWeaponUuid = value.mainContainer.Uuid;
+ }
+ }
+ public WeaponData SecretWeaponCluster
+ {
+ get
+ {
+ WeaponData? data = fileBelongs.WeaponFactoryCollective.findWeaponWithContainerUuid(secretWeaponClusterUuid);
+ if(data is null) return new WeaponData(fileBelongs, fileBelongs.LookupContainerByUuid(secretWeaponClusterUuid));
+ return data;
+ }
+ set
+ {
+ this.secretWeaponClusterUuid = value.mainContainer.Uuid;
+ }
+ }
-
- public WeaponData SecretWeapon;
- public WeaponData SecretWeaponCluster;
public XomString Name;
public XomString[] Worms;
public int TutorialsDone;
@@ -49,6 +74,46 @@ namespace LibW4M.Data.Teams
{
}
+ public override void DeleteEntries()
+ {
+ // delete weapon if its not in weapon collective, and this is the last reference to it.
+
+ if(fileBelongs.WeaponFactoryCollective.findWeaponWithContainerUuid(secretWeaponUuid) is null)
+ {
+ bool delete = true;
+
+ foreach (TeamData team in fileBelongs.TeamDataColective)
+ {
+ if (team.Equals(this)) continue;
+ if (team.secretWeaponUuid.Equals(this.secretWeaponUuid, StringComparison.InvariantCultureIgnoreCase)) delete = false;
+ }
+
+ if (delete)
+ {
+ this.SecretWeapon.DeleteEntries();
+ }
+ }
+
+ // delete cluster if its not in weapon collective, and this is the last reference to it.
+ if (fileBelongs.WeaponFactoryCollective.findWeaponWithContainerUuid(secretWeaponClusterUuid) is null)
+ {
+ bool delete = true;
+
+ foreach (TeamData team in fileBelongs.TeamDataColective)
+ {
+ if (team.Equals(this)) continue;
+ if (team.secretWeaponClusterUuid.Equals(this.secretWeaponClusterUuid, StringComparison.InvariantCultureIgnoreCase)) delete = false;
+ }
+
+ if (delete)
+ {
+ this.SecretWeaponCluster.DeleteEntries();
+ }
+ }
+
+ base.DeleteEntries();
+ }
+
public override void Load()
{
using (XomStreamReader reader = new XomStreamReader(new MemoryStream(this.mainContainer.GetData())))
@@ -69,8 +134,8 @@ namespace LibW4M.Data.Teams
this.AllMissionsDone = reader.ReadBool();
this.Player = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
- this.SecretWeapon = fileBelongs.findWeaponWithContainerId(reader.ReadCompressedInt());
- this.SecretWeaponCluster = fileBelongs.findWeaponWithContainerId(reader.ReadCompressedInt());
+ this.secretWeaponUuid = fileBelongs.LookupContainerById(reader.ReadCompressedInt()).Uuid;
+ this.secretWeaponClusterUuid = fileBelongs.LookupContainerById(reader.ReadCompressedInt()).Uuid;
this.CustomWeapon = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
@@ -86,9 +151,6 @@ namespace LibW4M.Data.Teams
public override void Save()
{
- this.SecretWeapon.Save();
- this.SecretWeaponCluster.Save();
-
using (MemoryStream ms = new MemoryStream())
{
using (XomStreamWriter writer = new XomStreamWriter(ms))
diff --git a/LibW4M/Data/WeaponFactory/WeaponStore.cs b/LibW4M/Data/WeaponFactory/WeaponStore.cs
index f0ca76d..16faf47 100644
--- a/LibW4M/Data/WeaponFactory/WeaponStore.cs
+++ b/LibW4M/Data/WeaponFactory/WeaponStore.cs
@@ -1,4 +1,5 @@
-using LibXom.Data;
+using LibW4M.Data.Teams;
+using LibXom.Data;
using LibXom.Streams;
using System;
using System.Collections.Generic;
@@ -47,11 +48,23 @@ namespace LibW4M.Data.WeaponFactory
this.mainContainer.CompressAndUpdate(weaponStore);
}
- internal override void delete()
+
+
+ public override void DeleteEntries()
{
- this.weaponContainer.Delete();
- this.clusterContainer.Delete();
- this.mainContainer.Delete();
+ bool clusterUsed = false;
+ bool weaponUsed = false;
+
+ foreach (TeamData team in fileBelongs.TeamDataColective)
+ {
+ if (team.SecretWeapon.Equals(this.Weapon)) weaponUsed = true;
+ if (team.SecretWeaponCluster.Equals(this.Cluster)) clusterUsed = true;
+ }
+
+ if (!clusterUsed) { this.Cluster.DeleteEntries(); }
+ if (!weaponUsed) { this.Weapon.DeleteEntries(); }
+
+ base.DeleteEntries();
}
public override string FriendlyName
diff --git a/LibW4M/Data/WeaponFactory/WeaponsCollective.cs b/LibW4M/Data/WeaponFactory/WeaponsCollective.cs
index 5c66002..3a587df 100644
--- a/LibW4M/Data/WeaponFactory/WeaponsCollective.cs
+++ b/LibW4M/Data/WeaponFactory/WeaponsCollective.cs
@@ -13,7 +13,18 @@ namespace LibW4M.Data.WeaponFactory
public WeaponsCollective(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}
+ internal WeaponData? findWeaponWithContainerUuid(string uuid)
+ {
+ for (int i = 0; i < this.Length; i++)
+ {
+ WeaponStore weaponStore = this[i] as WeaponStore;
+ if (weaponStore is null) continue;
+ if (weaponStore.Weapon.mainContainer.Uuid.Equals(uuid, StringComparison.InvariantCultureIgnoreCase)) return weaponStore.Weapon;
+ else if (weaponStore.Cluster.mainContainer.Uuid.Equals(uuid, StringComparison.InvariantCultureIgnoreCase)) return weaponStore.Cluster;
+ }
+ return null;
+ }
public override void Load()
{
int[] collective = mainContainer.Decompress();
diff --git a/LibW4M/Data/X/DataBank.cs b/LibW4M/Data/X/DataBank.cs
index 5fbcd0f..a519ba2 100644
--- a/LibW4M/Data/X/DataBank.cs
+++ b/LibW4M/Data/X/DataBank.cs
@@ -16,12 +16,118 @@ namespace LibW4M.Data.X
public class DataBank : SaveDataEntry
{
public int Section;
- public IntResourceDetail[] IntResourceDetails;
- public UIntResourceDetail[] UIntResourceDetails;
- public StringResourceDetail[] StringResourceDetails;
- public FloatResourceDetail[] FloatResourceDetails;
- public VectorResourceDetail[] VectorResourceDetails;
- public ContainerResourceDetail[] ContainerResourceDetails;
+
+ private List intResourceDetails = new List();
+ private List uintResourceDetails = new List();
+ private List stringResourceDetails = new List();
+ private List floatResourceDetails = new List();
+ private List vectorResourceDetails = new List();
+ private List containerResourceDetails = new List();
+
+ public IntResourceDetail[] IntResourceDetails
+ {
+ get
+ {
+ return intResourceDetails.ToArray();
+ }
+ }
+ public UIntResourceDetail[] UIntResourceDetails
+ {
+ get
+ {
+ return uintResourceDetails.ToArray();
+ }
+ }
+ public StringResourceDetail[] StringResourceDetails
+ {
+ get
+ {
+ return stringResourceDetails.ToArray();
+ }
+ }
+ public FloatResourceDetail[] FloatResourceDetails
+ {
+ get
+ {
+ return floatResourceDetails.ToArray();
+ }
+ }
+ public VectorResourceDetail[] VectorResourceDetails
+ {
+ get
+ {
+ return vectorResourceDetails.ToArray();
+ }
+ }
+ public ContainerResourceDetail[] ContainerResourceDetails
+ {
+ get
+ {
+ return containerResourceDetails.ToArray();
+ }
+ }
+
+
+ public void Delete(IntResourceDetail detail)
+ {
+ for (int i = 0; i < IntResourceDetails.Length; i++)
+ {
+ if (IntResourceDetails[i].Equals(detail))
+ {
+ IntResourceDetails[i].DeleteEntries();
+ intResourceDetails.RemoveAt(i);
+ break;
+ }
+ }
+ }
+ public void Delete(UIntResourceDetail detail)
+ {
+ for (int i = 0; i < UIntResourceDetails.Length; i++)
+ {
+ if (UIntResourceDetails[i].Equals(detail))
+ {
+ UIntResourceDetails[i].DeleteEntries();
+ uintResourceDetails.RemoveAt(i);
+ break;
+ }
+ }
+ }
+ public void Delete(StringResourceDetail detail)
+ {
+ for (int i = 0; i < StringResourceDetails.Length; i++)
+ {
+ if (StringResourceDetails[i].Equals(detail))
+ {
+ StringResourceDetails[i].DeleteEntries();
+ stringResourceDetails.RemoveAt(i);
+ break;
+ }
+ }
+ }
+ public void Delete(FloatResourceDetail detail)
+ {
+ for (int i = 0; i < FloatResourceDetails.Length; i++)
+ {
+ if (FloatResourceDetails[i].Equals(detail))
+ {
+ FloatResourceDetails[i].DeleteEntries();
+ floatResourceDetails.RemoveAt(i);
+ break;
+ }
+ }
+ }
+ public void Delete(VectorResourceDetail detail)
+ {
+ for (int i = 0; i < VectorResourceDetails.Length; i++)
+ {
+ if (VectorResourceDetails[i].Equals(detail))
+ {
+ VectorResourceDetails[i].DeleteEntries();
+ vectorResourceDetails.RemoveAt(i);
+ break;
+ }
+ }
+ }
public DataBank(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
@@ -35,40 +141,34 @@ namespace LibW4M.Data.X
this.Section = reader.ReadCompressedInt();
int[] intResourceCtnrs = reader.ReadCompressedIntArray();
- IntResourceDetails = new IntResourceDetail[intResourceCtnrs.Length];
- for (int i = 0; i < IntResourceDetails.Length; i++)
- IntResourceDetails[i] = new IntResourceDetail(fileBelongs, fileBelongs.LookupContainerById(intResourceCtnrs[i]));
+ for (int i = 0; i < intResourceCtnrs.Length; i++)
+ intResourceDetails.Add(new IntResourceDetail(fileBelongs, fileBelongs.LookupContainerById(intResourceCtnrs[i])));
int[] uintResourceCtnrs = reader.ReadCompressedIntArray();
- UIntResourceDetails = new UIntResourceDetail[uintResourceCtnrs.Length];
- for (int i = 0; i < UIntResourceDetails.Length; i++)
- UIntResourceDetails[i] = new UIntResourceDetail(fileBelongs, fileBelongs.LookupContainerById(uintResourceCtnrs[i]));
+ for (int i = 0; i < uintResourceCtnrs.Length; i++)
+ uintResourceDetails.Add(new UIntResourceDetail(fileBelongs, fileBelongs.LookupContainerById(uintResourceCtnrs[i])));
int[] stringResourceCtnrs = reader.ReadCompressedIntArray();
- StringResourceDetails = new StringResourceDetail[stringResourceCtnrs.Length];
- for (int i = 0; i < StringResourceDetails.Length; i++)
- StringResourceDetails[i] = new StringResourceDetail(fileBelongs, fileBelongs.LookupContainerById(stringResourceCtnrs[i]));
+ for (int i = 0; i < stringResourceCtnrs.Length; i++)
+ stringResourceDetails.Add(new StringResourceDetail(fileBelongs, fileBelongs.LookupContainerById(stringResourceCtnrs[i])));
int[] floatResourceCtnrs = reader.ReadCompressedIntArray();
- FloatResourceDetails = new FloatResourceDetail[floatResourceCtnrs.Length];
- for (int i = 0; i < FloatResourceDetails.Length; i++)
- FloatResourceDetails[i] = new FloatResourceDetail(fileBelongs, fileBelongs.LookupContainerById(floatResourceCtnrs[i]));
+ for (int i = 0; i < floatResourceCtnrs.Length; i++)
+ floatResourceDetails.Add(new FloatResourceDetail(fileBelongs, fileBelongs.LookupContainerById(floatResourceCtnrs[i])));
int[] vectorResourceCtnrs = reader.ReadCompressedIntArray();
- VectorResourceDetails = new VectorResourceDetail[vectorResourceCtnrs.Length];
- for (int i = 0; i < VectorResourceDetails.Length; i++)
- VectorResourceDetails[i] = new VectorResourceDetail(fileBelongs, fileBelongs.LookupContainerById(vectorResourceCtnrs[i]));
+ for (int i = 0; i < vectorResourceCtnrs.Length; i++)
+ vectorResourceDetails.Add(new VectorResourceDetail(fileBelongs, fileBelongs.LookupContainerById(vectorResourceCtnrs[i])));
int[] containerResourceCtnrs = reader.ReadCompressedIntArray();
- ContainerResourceDetails = new ContainerResourceDetail[containerResourceCtnrs.Length];
- for (int i = 0; i < ContainerResourceDetails.Length; i++)
- ContainerResourceDetails[i] = new ContainerResourceDetail(fileBelongs, fileBelongs.LookupContainerById(containerResourceCtnrs[i]));
+ for (int i = 0; i < containerResourceCtnrs.Length; i++)
+ containerResourceDetails.Add(new ContainerResourceDetail(fileBelongs, fileBelongs.LookupContainerById(containerResourceCtnrs[i])));
}
}
diff --git a/LibW4M/W4SaveFile.cs b/LibW4M/W4SaveFile.cs
index 50b9bad..b4ae952 100644
--- a/LibW4M/W4SaveFile.cs
+++ b/LibW4M/W4SaveFile.cs
@@ -58,20 +58,7 @@ namespace LibW4M
}
- internal WeaponData findWeaponWithContainerId(int containerId)
- {
- if(WeaponFactoryCollective is not null)
- {
- for (int i = 0; i < WeaponFactoryCollective.Length; i++)
- {
- WeaponStore weaponStore = (WeaponStore)WeaponFactoryCollective[i];
- if (weaponStore.Weapon.containerId == containerId) return weaponStore.Weapon;
- if (weaponStore.Cluster.containerId == containerId) return weaponStore.Cluster;
- }
- }
-
- return new WeaponData(this, LookupContainerById(containerId));
- }
+
public void Load()
{
@@ -232,7 +219,10 @@ namespace LibW4M
{
return xomFile.GetContainerById(id);
}
-
+ public XomContainer LookupContainerByUuid(string uuid)
+ {
+ return xomFile.GetContainerByUuid(uuid);
+ }
public XomString LookupStringFromId(int id)
{
return xomFile.GetStringById(id);
diff --git a/LibXom/Data/XomContainer.cs b/LibXom/Data/XomContainer.cs
index b9d0314..3cf4026 100644
--- a/LibXom/Data/XomContainer.cs
+++ b/LibXom/Data/XomContainer.cs
@@ -30,7 +30,7 @@ namespace LibXom.Data
{
get
{
- return this.fileBelongs.calculateIdForXomFileComponent(this.uuid, fileBelongs.XomContainers);
+ return this.fileBelongs.calculateIdForXomFileComponent(this.Uuid, fileBelongs.XomContainers);
}
}
public byte[] GetData()
diff --git a/LibXom/Data/XomFile.cs b/LibXom/Data/XomFile.cs
index 4a05e1a..816f943 100644
--- a/LibXom/Data/XomFile.cs
+++ b/LibXom/Data/XomFile.cs
@@ -61,7 +61,7 @@ namespace LibXom.Data
public XomString AddOrGetString(string value)
{
- XomString[] strings = XomStrings;
+ XomString[] strings = this.XomStrings;
for (int i = 0; i < strings.Length; i++)
if (strings[i].Equals(value)) return strings[i];
@@ -91,8 +91,22 @@ namespace LibXom.Data
throw new XomTypeNotFoundException("Type \"" + typeName + "\" was not found in XOM.");
}
- internal int calculateIdForXomStrings(XomString searchString, XomString[] stringsList)
+ public XomContainer GetContainerByUuid(string uuid)
{
+ foreach(XomContainer container in XomContainers)
+ {
+ if(container.Uuid.Equals(uuid, StringComparison.InvariantCultureIgnoreCase))
+ {
+ return container;
+ }
+ }
+
+ throw new XomContainerNotFoundException("No container was found with the uuid: " + uuid);
+ }
+
+ internal int calculateIdForXomStrings(XomString searchString)
+ {
+ XomString[] stringsList = this.XomStrings;
for (int i = 0; i < stringsList.Length; i++)
if (stringsList[i].Equals(searchString)) return i;
@@ -102,7 +116,7 @@ namespace LibXom.Data
internal int calculateIdForXomFileComponent(string searchUuid, XomFileComponent[] components)
{
for (int i = 0; i < components.Length; i++)
- if (components[i].uuid.Equals(searchUuid, StringComparison.CurrentCultureIgnoreCase)) return i + 1;
+ if (components[i].Uuid.Equals(searchUuid, StringComparison.CurrentCultureIgnoreCase)) return i + 1;
throw new XomFileComponentNotFoundException("A XOM Components ID could not be found in the Component List.");
}
diff --git a/LibXom/Data/XomFileComponent.cs b/LibXom/Data/XomFileComponent.cs
index 4e8c041..0d809b1 100644
--- a/LibXom/Data/XomFileComponent.cs
+++ b/LibXom/Data/XomFileComponent.cs
@@ -8,16 +8,24 @@ namespace LibXom.Data
{
public class XomFileComponent
{
- internal Guid guid = Guid.NewGuid();
+ private Guid guid = Guid.NewGuid();
internal XomFile fileBelongs;
public virtual int Id { get; }
- internal string uuid
+ public string Uuid
{
get
{
return guid.ToString();
}
}
-
+ public override int GetHashCode()
+ {
+ return this.Uuid.GetHashCode();
+ }
+ public override bool Equals(object? obj)
+ {
+ if (obj is not XomFileComponent) return false;
+ return this.Uuid.Equals((obj as XomFileComponent).Uuid, StringComparison.InvariantCultureIgnoreCase);
+ }
}
}
diff --git a/LibXom/Data/XomString.cs b/LibXom/Data/XomString.cs
index 9e6c66c..61f62de 100644
--- a/LibXom/Data/XomString.cs
+++ b/LibXom/Data/XomString.cs
@@ -15,7 +15,7 @@ namespace LibXom.Data
{
get
{
- return this.fileBelongs.calculateIdForXomStrings(this, fileBelongs.XomStrings);
+ return this.fileBelongs.calculateIdForXomStrings(this);
}
}
public string Value
@@ -36,13 +36,19 @@ namespace LibXom.Data
public override bool Equals(object? obj)
{
- XomString? xStr = obj as XomString;
- if (xStr is XomString)
- return this.Value.Equals(xStr.Value, StringComparison.InvariantCulture);
+ if (obj is XomString)
+ return this.Value.Equals((obj as XomString).Value, StringComparison.InvariantCulture);
+ else if(obj is string)
+ return this.Value.Equals((obj as string), StringComparison.InvariantCulture);
else
return false;
}
+ public override int GetHashCode()
+ {
+ return this.Value.GetHashCode();
+ }
+
/*
public void OverwriteXomString(string newValue)
diff --git a/LibXom/Data/XomType.cs b/LibXom/Data/XomType.cs
index 2cf983b..44f29e7 100644
--- a/LibXom/Data/XomType.cs
+++ b/LibXom/Data/XomType.cs
@@ -16,7 +16,7 @@ namespace LibXom.Data
{
get
{
- return this.fileBelongs.calculateIdForXomFileComponent(this.uuid, fileBelongs.XomTypes);
+ return this.fileBelongs.calculateIdForXomFileComponent(this.Uuid, fileBelongs.XomTypes);
}
}
@@ -45,7 +45,7 @@ namespace LibXom.Data
{
for (int i = 0; i < xomContainers.Count; i++)
{
- if (xomContainers[i].uuid.Equals(container.uuid, StringComparison.InvariantCulture))
+ if (xomContainers[i].Uuid.Equals(container.Uuid, StringComparison.InvariantCulture))
{
return i;
}
diff --git a/W4Gui/Components/CollectiveListAddDelete.cs b/W4Gui/Components/CollectiveListAddDelete.cs
index 7992ea5..43e40a7 100644
--- a/W4Gui/Components/CollectiveListAddDelete.cs
+++ b/W4Gui/Components/CollectiveListAddDelete.cs
@@ -18,6 +18,18 @@ namespace W4Gui.Components
public CollectiveListAddDelete()
{
InitializeComponent();
+ this.List.Unselected += List_Unselected; ;
+ this.List.Selected += List_Selected; ;
+ }
+
+ protected virtual void OnUnselected(EventArgs e)
+ {
+ btnDel.Enabled = false;
+ }
+
+ protected virtual void OnSelected(EventArgs e)
+ {
+ btnDel.Enabled = true;
}
protected virtual void OnNewButton(EventArgs e)
{
@@ -34,16 +46,26 @@ namespace W4Gui.Components
{
handler(this, e);
}
+
}
- private void btnAdd_Click(object sender, EventArgs e)
+ private void List_Selected(object? sender, EventArgs e)
+ {
+ OnSelected(e);
+ }
+
+ private void List_Unselected(object? sender, EventArgs e)
+ {
+ OnUnselected(e);
+ }
+ private void btnAdd_Click(object? sender, EventArgs e)
{
OnNewButton(e);
}
- private void btnDel_Click(object sender, EventArgs e)
+ private void btnDel_Click(object? sender, EventArgs e)
{
- // if (lstCollective.SelectedIndex >= 0)
+ if (this.List.SelectedIndex >= 0)
OnDeleteButton(e);
}
diff --git a/W4Gui/Components/CollectiveListBox.cs b/W4Gui/Components/CollectiveListBox.cs
index 24a2c81..fe27763 100644
--- a/W4Gui/Components/CollectiveListBox.cs
+++ b/W4Gui/Components/CollectiveListBox.cs
@@ -86,8 +86,28 @@ namespace W4Gui.Components
public void Delete(int idx)
{
+ int selIndx = this.SelectedIndex;
+
unselectWithoutSaveTrigger();
this.Items.RemoveAt(idx);
+
+ if (selIndx == idx)
+ {
+ if((selIndx - 1) < 0 && this.Items.Count > 0)
+ {
+ this.SelectedIndex = 0;
+ }
+ else if(selIndx > (this.Items.Count - 1))
+ {
+ this.SelectedIndex = this.Items.Count - 1;
+ }
+ else
+ {
+ this.SelectedIndex = selIndx;
+ }
+ }
+
+
}
private string processName(string name)
diff --git a/W4Gui/Main.cs b/W4Gui/Main.cs
index 2c0b44d..a64d9fd 100644
--- a/W4Gui/Main.cs
+++ b/W4Gui/Main.cs
@@ -82,6 +82,7 @@ namespace W4Gui
}
catch (Exception ex)
{
+ this.mainTabControl.Enabled = true;
MessageBox.Show("Failed to save: " + ex.Message, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
#endif
@@ -143,6 +144,8 @@ namespace W4Gui
this.Text = defaultTitle + " (" + DataManager.LoadedSaveType.ToString() + ") " + "[" + fd.FileName + "]";
+ this.mainTabControl.Enabled = true;
+
MessageBox.Show("File saved to: " + fd.FileName, "Save Complete!", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
@@ -150,7 +153,8 @@ namespace W4Gui
}
catch (Exception ex)
{
- MessageBox.Show("Failed to save: " + ex.Message, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ MessageBox.Show("Failed to save: " + ex.Message, "Save failed!", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ this.mainTabControl.Enabled = true;
}
#endif
}
diff --git a/W4Gui/Tabs/HighscoresTab.cs b/W4Gui/Tabs/HighscoresTab.cs
index 2086bc2..e003600 100644
--- a/W4Gui/Tabs/HighscoresTab.cs
+++ b/W4Gui/Tabs/HighscoresTab.cs
@@ -55,7 +55,10 @@ namespace W4Gui.Tabs
private void highscoresList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing highscores from here not implemented yet ;)");
+ int sel = highscoresList.List.CurrentlySelected;
+ HighscoreData highscoreData = DataManager.SaveFile.HighscoreCollective[sel] as HighscoreData;
+ DataManager.SaveFile.HighscoreCollective.Delete(highscoreData);
+ highscoresList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/InputEventMappingsTab.cs b/W4Gui/Tabs/InputEventMappingsTab.cs
index 0665303..4924718 100644
--- a/W4Gui/Tabs/InputEventMappingsTab.cs
+++ b/W4Gui/Tabs/InputEventMappingsTab.cs
@@ -36,15 +36,15 @@ namespace W4Gui.Tabs
private void inputEventMappingList_Unselected(object? sender, EventArgs e)
{
- InputEventMappingData InputEventMappingData = DataManager.SaveFile.InputMappingCollective[inputEventMappingList.List.LastSelected] as InputEventMappingData;
- inputEventMappingPanel.SaveInputEventMappingsData(ref InputEventMappingData);
- inputEventMappingList.List.UpdateName(inputEventMappingList.List.LastSelected, InputEventMappingData.FriendlyName);
+ InputEventMappingData inputEventMappingData = DataManager.SaveFile.InputMappingCollective[inputEventMappingList.List.LastSelected] as InputEventMappingData;
+ inputEventMappingPanel.SaveInputEventMappingsData(ref inputEventMappingData);
+ inputEventMappingList.List.UpdateName(inputEventMappingList.List.LastSelected, inputEventMappingData.FriendlyName);
}
private void inputEventMappingList_Selected(object? sender, EventArgs e)
{
- InputEventMappingData InputEventMappingData = DataManager.SaveFile.InputMappingCollective[inputEventMappingList.List.CurrentlySelected] as InputEventMappingData;
- inputEventMappingPanel.LoadInputEventMappingsData(InputEventMappingData);
+ InputEventMappingData inputEventMappingData = DataManager.SaveFile.InputMappingCollective[inputEventMappingList.List.CurrentlySelected] as InputEventMappingData;
+ inputEventMappingPanel.LoadInputEventMappingsData(inputEventMappingData);
inputEventMappingPanel.Enabled = true;
}
@@ -55,7 +55,10 @@ namespace W4Gui.Tabs
private void inputEventMappingList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing inputEventMapping from here not implemented yet ;)");
+ int sel = inputEventMappingList.List.CurrentlySelected;
+ InputEventMappingData inputEventMappingData = DataManager.SaveFile.InputMappingCollective[sel] as InputEventMappingData;
+ DataManager.SaveFile.InputMappingCollective.Delete(inputEventMappingData);
+ inputEventMappingList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/OtherTabs/InputMappingsTab.cs b/W4Gui/Tabs/OtherTabs/InputMappingsTab.cs
index bb11a94..757c164 100644
--- a/W4Gui/Tabs/OtherTabs/InputMappingsTab.cs
+++ b/W4Gui/Tabs/OtherTabs/InputMappingsTab.cs
@@ -1,5 +1,6 @@
using LibW4M.Data.Highscores;
using LibW4M.Data.InputMapping;
+using LibW4M.Data.Stats;
using LibW4M.Data.Teams;
using System;
using System.Collections.Generic;
@@ -66,7 +67,11 @@ namespace W4Gui.Tabs.OtherTabs
private void inputMappingsList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing inputMappings from here not implemented yet ;)");
+ int sel = inputMappingsList.List.CurrentlySelected;
+ InputMappingData inputMappingsData = mappingData[inputMappingsList.List.CurrentlySelected] as InputMappingData;
+ inputMappingsData.DeleteEntries();
+ mappingData.RemoveAt(inputMappingsList.List.CurrentlySelected);
+ inputMappingsList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/SchemeTab.cs b/W4Gui/Tabs/SchemeTab.cs
index c6bdbe7..0e8c36a 100644
--- a/W4Gui/Tabs/SchemeTab.cs
+++ b/W4Gui/Tabs/SchemeTab.cs
@@ -55,7 +55,10 @@ namespace W4Gui.Tabs
private void schemesList_DeleteButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing schemes from here not implemented yet ;)");
+ int sel = schemesList.List.CurrentlySelected;
+ SchemeData scheme = DataManager.SaveFile.SchemesCollective[sel] as SchemeData;
+ DataManager.SaveFile.SchemesCollective.Delete(scheme);
+ schemesList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/StatsTab/StatisticsTab.cs b/W4Gui/Tabs/StatsTab/StatisticsTab.cs
index d2a0660..91256ec 100644
--- a/W4Gui/Tabs/StatsTab/StatisticsTab.cs
+++ b/W4Gui/Tabs/StatsTab/StatisticsTab.cs
@@ -55,7 +55,10 @@ namespace W4Gui.Tabs.StatsTab
private void statisticsList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing statistics from here not implemented yet ;)");
+ int sel = statisticsList.List.CurrentlySelected;
+ StatsContainerData statsData = DataManager.SaveFile.StatsCollective[sel] as StatsContainerData;
+ DataManager.SaveFile.StatsCollective.Delete(statsData);
+ statisticsList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/StatsTab/TeamStatisticsTab.cs b/W4Gui/Tabs/StatsTab/TeamStatisticsTab.cs
index 7eb70b4..ee85a07 100644
--- a/W4Gui/Tabs/StatsTab/TeamStatisticsTab.cs
+++ b/W4Gui/Tabs/StatsTab/TeamStatisticsTab.cs
@@ -55,7 +55,10 @@ namespace W4Gui.Tabs.StatsTab
private void teamStatisticsList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing team statistics from here not implemented yet ;)");
+ int sel = teamStatisticsList.List.CurrentlySelected;
+ StatsContainerData statsData = DataManager.SaveFile.TeamStatsCollective[sel] as StatsContainerData;
+ DataManager.SaveFile.TeamStatsCollective.Delete(statsData);
+ teamStatisticsList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/TeamsTab.cs b/W4Gui/Tabs/TeamsTab.cs
index 5a5f6db..245cba0 100644
--- a/W4Gui/Tabs/TeamsTab.cs
+++ b/W4Gui/Tabs/TeamsTab.cs
@@ -1,4 +1,5 @@
using LibW4M.Data.Teams;
+using LibW4M.Data.WeaponFactory;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@@ -54,7 +55,10 @@ namespace W4Gui.Tabs
private void teamsList_DeleteButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing weapons from here not implemented yet ;)");
+ int sel = teamsList.List.CurrentlySelected;
+ TeamData team = DataManager.SaveFile.TeamDataColective[sel] as TeamData;
+ DataManager.SaveFile.TeamDataColective.Delete(team);
+ teamsList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/UnlockableItemsTab.Designer.cs b/W4Gui/Tabs/UnlockableItemsTab.Designer.cs
index 6830d2e..82b607b 100644
--- a/W4Gui/Tabs/UnlockableItemsTab.Designer.cs
+++ b/W4Gui/Tabs/UnlockableItemsTab.Designer.cs
@@ -30,7 +30,7 @@
{
this.unlockableItemsSplitContainer = new System.Windows.Forms.SplitContainer();
this.unlockableItemsPanel = new W4Gui.Components.UnlockableItemsPanel();
- this.unlockableItemsList = new W4Gui.Components.CollectiveListAddDelete();
+ this.unlockableItemsList = new W4Gui.Components.CollectiveListBox();
((System.ComponentModel.ISupportInitialize)(this.unlockableItemsSplitContainer)).BeginInit();
this.unlockableItemsSplitContainer.Panel1.SuspendLayout();
this.unlockableItemsSplitContainer.Panel2.SuspendLayout();
@@ -47,6 +47,7 @@
// unlockableItemsSplitContainer.Panel1
//
this.unlockableItemsSplitContainer.Panel1.Controls.Add(this.unlockableItemsList);
+ this.unlockableItemsSplitContainer.Panel1.Padding = new System.Windows.Forms.Padding(3);
//
// unlockableItemsSplitContainer.Panel2
//
@@ -68,11 +69,10 @@
//
this.unlockableItemsList.Dock = System.Windows.Forms.DockStyle.Fill;
this.unlockableItemsList.Location = new System.Drawing.Point(3, 3);
- this.unlockableItemsList.Name = "teamsList";
+ this.unlockableItemsList.Name = "unlockableItemsList";
this.unlockableItemsList.Size = new System.Drawing.Size(261, 460);
this.unlockableItemsList.TabIndex = 0;
- this.unlockableItemsList.NewButton += new System.EventHandler(this.unlockableItemsList_NewButton);
- this.unlockableItemsList.DeleteButton += new System.EventHandler(this.unlockableItemsList_DeleteButton);
+
//
// UnlockableItemsTab
//
@@ -93,6 +93,6 @@
private SplitContainer unlockableItemsSplitContainer;
private Components.UnlockableItemsPanel unlockableItemsPanel;
- private Components.CollectiveListAddDelete unlockableItemsList;
+ private Components.CollectiveListBox unlockableItemsList;
}
}
diff --git a/W4Gui/Tabs/UnlockableItemsTab.cs b/W4Gui/Tabs/UnlockableItemsTab.cs
index 791d9c2..5f67dd1 100644
--- a/W4Gui/Tabs/UnlockableItemsTab.cs
+++ b/W4Gui/Tabs/UnlockableItemsTab.cs
@@ -18,46 +18,36 @@ namespace W4Gui.Tabs
public UnlockableItemsTab()
{
InitializeComponent();
- this.unlockableItemsList.List.Selected += unlockableItemsList_Selected;
- this.unlockableItemsList.List.Unselected += unlockableItemsList_Unselected;
+ this.unlockableItemsList.Selected += unlockableItemsList_Selected;
+ this.unlockableItemsList.Unselected += unlockableItemsList_Unselected;
}
public override void SaveFromControl()
{
- if (this.unlockableItemsList.List.IsItemSelected)
+ if (this.unlockableItemsList.IsItemSelected)
unlockableItemsList_Unselected(null, null);
}
public override void LoadIntoControl()
{
- this.unlockableItemsList.List.LoadArray(DataManager.SaveFile.UnlockableItems);
+ this.unlockableItemsList.LoadArray(DataManager.SaveFile.UnlockableItems);
unlockableItemsPanel.Enabled = false;
}
private void unlockableItemsList_Unselected(object? sender, EventArgs? e)
{
- UnlockableItemData itemData = DataManager.SaveFile.UnlockableItems[unlockableItemsList.List.LastSelected] as UnlockableItemData;
+ UnlockableItemData itemData = DataManager.SaveFile.UnlockableItems[unlockableItemsList.LastSelected] as UnlockableItemData;
unlockableItemsPanel.SaveUnlockableItem(ref itemData);
- unlockableItemsList.List.UpdateName(unlockableItemsList.List.LastSelected, itemData.FriendlyName);
+ unlockableItemsList.UpdateName(unlockableItemsList.LastSelected, itemData.FriendlyName);
}
private void unlockableItemsList_Selected(object? sender, EventArgs? e)
{
- UnlockableItemData itemData = DataManager.SaveFile.UnlockableItems[unlockableItemsList.List.CurrentlySelected] as UnlockableItemData;
+ UnlockableItemData itemData = DataManager.SaveFile.UnlockableItems[unlockableItemsList.CurrentlySelected] as UnlockableItemData;
unlockableItemsPanel.LoadUnlockableItem(itemData);
unlockableItemsPanel.Enabled = true;
}
- private void unlockableItemsList_NewButton(object sender, EventArgs e)
- {
- throw new NotImplementedException("Adding new unlockableItems from here not implemented yet ;)");
- }
-
- private void unlockableItemsList_DeleteButton(object sender, EventArgs e)
- {
- throw new NotImplementedException("Removing unlockableItems from here not implemented yet ;)");
- }
-
}
}
diff --git a/W4Gui/Tabs/VariablesTab/FloatVariablesTab.cs b/W4Gui/Tabs/VariablesTab/FloatVariablesTab.cs
index 84cca55..148a1f8 100644
--- a/W4Gui/Tabs/VariablesTab/FloatVariablesTab.cs
+++ b/W4Gui/Tabs/VariablesTab/FloatVariablesTab.cs
@@ -1,4 +1,5 @@
using LibW4M.Data.Highscores;
+using LibW4M.Data.InputMapping;
using LibW4M.Data.Teams;
using LibW4M.Data.X;
using System;
@@ -57,7 +58,10 @@ namespace W4Gui.Tabs.VariablesTab
private void variablesList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing variables from here not implemented yet ;)");
+ int sel = variablesList.List.CurrentlySelected;
+ FloatResourceDetail variableData = DataManager.SaveFile.XDataBank.FloatResourceDetails[sel] as FloatResourceDetail;
+ DataManager.SaveFile.XDataBank.Delete(variableData);
+ variablesList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/VariablesTab/IntVariablesTab.cs b/W4Gui/Tabs/VariablesTab/IntVariablesTab.cs
index 008b5fe..27e3e2f 100644
--- a/W4Gui/Tabs/VariablesTab/IntVariablesTab.cs
+++ b/W4Gui/Tabs/VariablesTab/IntVariablesTab.cs
@@ -56,7 +56,10 @@ namespace W4Gui.Tabs.VariablesTab
private void variablesList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing variables from here not implemented yet ;)");
+ int sel = variablesList.List.CurrentlySelected;
+ IntResourceDetail variableData = DataManager.SaveFile.XDataBank.IntResourceDetails[sel] as IntResourceDetail;
+ DataManager.SaveFile.XDataBank.Delete(variableData);
+ variablesList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/VariablesTab/StringVariablesTab.cs b/W4Gui/Tabs/VariablesTab/StringVariablesTab.cs
index aef95a3..9a883ad 100644
--- a/W4Gui/Tabs/VariablesTab/StringVariablesTab.cs
+++ b/W4Gui/Tabs/VariablesTab/StringVariablesTab.cs
@@ -57,7 +57,10 @@ namespace W4Gui.Tabs.VariablesTab
private void variablesList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing variables from here not implemented yet ;)");
+ int sel = variablesList.List.CurrentlySelected;
+ StringResourceDetail variableData = DataManager.SaveFile.XDataBank.StringResourceDetails[sel] as StringResourceDetail;
+ DataManager.SaveFile.XDataBank.Delete(variableData);
+ variablesList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/VariablesTab/UIntVariablesTab.cs b/W4Gui/Tabs/VariablesTab/UIntVariablesTab.cs
index cc6839d..0ff1f2c 100644
--- a/W4Gui/Tabs/VariablesTab/UIntVariablesTab.cs
+++ b/W4Gui/Tabs/VariablesTab/UIntVariablesTab.cs
@@ -57,7 +57,10 @@ namespace W4Gui.Tabs.VariablesTab
private void variablesList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing variables from here not implemented yet ;)");
+ int sel = variablesList.List.CurrentlySelected;
+ UIntResourceDetail variableData = DataManager.SaveFile.XDataBank.UIntResourceDetails[sel] as UIntResourceDetail;
+ DataManager.SaveFile.XDataBank.Delete(variableData);
+ variablesList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/VariablesTab/VectorVariablesTab.cs b/W4Gui/Tabs/VariablesTab/VectorVariablesTab.cs
index 0f2d5fd..6afa3f1 100644
--- a/W4Gui/Tabs/VariablesTab/VectorVariablesTab.cs
+++ b/W4Gui/Tabs/VariablesTab/VectorVariablesTab.cs
@@ -57,7 +57,10 @@ namespace W4Gui.Tabs.VariablesTab
private void variablesList_DelButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing variables from here not implemented yet ;)");
+ int sel = variablesList.List.CurrentlySelected;
+ VectorResourceDetail variableData = DataManager.SaveFile.XDataBank.VectorResourceDetails[sel] as VectorResourceDetail;
+ DataManager.SaveFile.XDataBank.Delete(variableData);
+ variablesList.List.Delete(sel);
}
}
diff --git a/W4Gui/Tabs/WeaponsTab.cs b/W4Gui/Tabs/WeaponsTab.cs
index f4fc92e..86fa7f4 100644
--- a/W4Gui/Tabs/WeaponsTab.cs
+++ b/W4Gui/Tabs/WeaponsTab.cs
@@ -48,7 +48,8 @@ namespace W4Gui.Tabs
WeaponStore store = DataManager.SaveFile.WeaponFactoryCollective[weaponList.List.CurrentlySelected] as WeaponStore;
weaponPanel.LoadWeaponData(store.Weapon);
clusterPanel.LoadWeaponData(store.Cluster);
- selStockWeapon.Checked = store.StockWeapon; weaponClusterTabControl.Enabled = true;
+ selStockWeapon.Checked = store.StockWeapon;
+ weaponClusterTabControl.Enabled = true;
}
private void weaponList_NewButton(object sender, EventArgs e)
@@ -58,11 +59,9 @@ namespace W4Gui.Tabs
private void weaponList_DeleteButton(object sender, EventArgs e)
{
- throw new NotImplementedException("Removing weapons from here not implemented yet ;)");
int sel = weaponList.List.CurrentlySelected;
WeaponStore store = DataManager.SaveFile.WeaponFactoryCollective[sel] as WeaponStore;
DataManager.SaveFile.WeaponFactoryCollective.Delete(store);
-
weaponList.List.Delete(sel);
}
}