Add delete feature

This commit is contained in:
Li 2023-03-07 20:49:53 +13:00
parent a441f36e92
commit 609c8fc4dd
34 changed files with 491 additions and 118 deletions

View File

@ -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()
{

View File

@ -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;
}
}

View File

@ -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();
}

View File

@ -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.

View File

@ -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);

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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();

View File

@ -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<IntResourceDetail> intResourceDetails = new List<IntResourceDetail>();
private List<UIntResourceDetail> uintResourceDetails = new List<UIntResourceDetail>();
private List<StringResourceDetail> stringResourceDetails = new List<StringResourceDetail>();
private List<FloatResourceDetail> floatResourceDetails = new List<FloatResourceDetail>();
private List<VectorResourceDetail> vectorResourceDetails = new List<VectorResourceDetail>();
private List<ContainerResourceDetail> containerResourceDetails = new List<ContainerResourceDetail>();
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])));
}
}

View File

@ -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);

View File

@ -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()

View File

@ -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.");
}

View File

@ -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);
}
}
}

View File

@ -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)

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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)

View File

@ -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
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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<System.EventArgs>(this.unlockableItemsList_NewButton);
this.unlockableItemsList.DeleteButton += new System.EventHandler<System.EventArgs>(this.unlockableItemsList_DeleteButton);
//
// UnlockableItemsTab
//
@ -93,6 +93,6 @@
private SplitContainer unlockableItemsSplitContainer;
private Components.UnlockableItemsPanel unlockableItemsPanel;
private Components.CollectiveListAddDelete unlockableItemsList;
private Components.CollectiveListBox unlockableItemsList;
}
}

View File

@ -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 ;)");
}
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}