Add schemePanel.cs gui stuff

This commit is contained in:
Li 2023-01-16 20:07:32 -08:00
parent bf060a5df6
commit 6ecbff1e66
20 changed files with 3582 additions and 15 deletions

View File

@ -0,0 +1,385 @@
using LibXom.Data;
using LibXom.Streams;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibW4M.Data.Schemes
{
public class SchemeData : SaveDataEntry
{
public override string FriendlyName
{
get
{
return this.Name.Value;
}
}
public XomString Name;
public bool Permanant;
public XomString Lock;
public WeaponSettingsData Airstrike;
public WeaponSettingsData BananaBomb;
public WeaponSettingsData BaseballBat;
public WeaponSettingsData Bazooka;
public WeaponSettingsData ClusterGrenade;
public WeaponSettingsData ConcreteDonkey;
public WeaponSettingsData CrateShower;
public WeaponSettingsData CrateSpy;
public WeaponSettingsData DoubleDamage;
public WeaponSettingsData Dynamite;
public WeaponSettingsData FirePunch;
public WeaponSettingsData GasCanister;
public WeaponSettingsData Girder;
public WeaponSettingsData Grenade;
public WeaponSettingsData HolyHandGrenade;
public WeaponSettingsData HomingMissile;
public WeaponSettingsData Jetpack;
public WeaponSettingsData Landmine;
public WeaponSettingsData NinjaRope;
public WeaponSettingsData OldWoman;
public WeaponSettingsData Parachute;
public WeaponSettingsData Prod;
public WeaponSettingsData SelectWorm;
public WeaponSettingsData Sheep;
public WeaponSettingsData Shotgun;
public WeaponSettingsData SkipGo;
public WeaponSettingsData SuperSheep;
public WeaponSettingsData Redbull;
public WeaponSettingsData Flood;
public WeaponSettingsData Armour;
public WeaponSettingsData WeaponFactoryWeapon;
public WeaponSettingsData AlienAbduction;
public WeaponSettingsData Fatkins;
public WeaponSettingsData Scouser;
public WeaponSettingsData NoMoreNails;
public WeaponSettingsData PoisonArrow;
public WeaponSettingsData SentryGun;
public WeaponSettingsData SniperRifle;
public WeaponSettingsData SuperAirstrike;
public WeaponSettingsData BubbleTrouble;
public WeaponSettingsData Starburst;
public WeaponSettingsData Surrender;
public WeaponSettingsData MineLayerMystery;
public WeaponSettingsData MineTripletMystery;
public WeaponSettingsData BarrelTripletMystery;
public WeaponSettingsData FloodMystery;
public WeaponSettingsData DisarmMystery;
public WeaponSettingsData TeleportMystery;
public WeaponSettingsData QuickWalkMystery;
public WeaponSettingsData LowGravityMystery;
public WeaponSettingsData DoubleTurnTimeMystery;
public WeaponSettingsData HealthMystery;
public WeaponSettingsData DamageMystery;
public WeaponSettingsData SuperHealthMystery;
public WeaponSettingsData SpecialWeaponMystery;
public WeaponSettingsData BadPoisonMystery;
public WeaponSettingsData GoodPoisonMystery;
public int ArtileryMode;
public int TeleportIn;
public int Wins;
public int WormSelect;
public int WormHealth;
public int RoundTime;
public int TurnTime;
public int Objects; // TODO: make this an enum
public int RandomCrateChancePerTurn;
public int MysteryChance;
public int WeaponChance;
public int UtilityChance;
public int HealthChance;
public int HealthInCrates;
public int Stockpiling; // TODO: make this an enum too
public int SuddenDeath; // TODO: make this an enum too
public int WaterSpeed; // TODO: make this an enum too
public int DisplayTime;
public int LandTime;
public int RopeTime;
public int FallDamage;
public int HotSeat;
public int Special;
public int MineFuse;
public int HelpPanelDelay;
public bool MineFactoryOn;
public bool TelepadsOn;
public int WindMaxStrength;
public SchemeData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}
public override void Load()
{
using (XomStreamReader reader = new XomStreamReader(new MemoryStream(this.mainContainer.GetData())))
{
reader.Skip(3);
this.Name = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
this.Permanant = reader.ReadBool();
this.Lock = fileBelongs.LookupStringFromId(reader.ReadCompressedInt());
// Read WeaponSettingsData
this.Airstrike = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.BananaBomb = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.BaseballBat = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Bazooka = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.ClusterGrenade = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.ConcreteDonkey = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.CrateShower = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.CrateSpy = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.DoubleDamage = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Dynamite = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.FirePunch = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.GasCanister = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Girder = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Grenade = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.HolyHandGrenade = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.HomingMissile = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Jetpack = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Landmine = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.NinjaRope = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.OldWoman = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Parachute = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Prod = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SelectWorm = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Sheep = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Shotgun = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SkipGo = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SuperSheep = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Redbull = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Flood = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Armour = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.WeaponFactoryWeapon = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.AlienAbduction = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Fatkins = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Scouser = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.NoMoreNails = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.PoisonArrow = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SentryGun = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SniperRifle = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SuperAirstrike = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.BubbleTrouble = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Starburst = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.Surrender = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.MineLayerMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.MineTripletMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.BarrelTripletMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.FloodMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.DisarmMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.TeleportMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.QuickWalkMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.LowGravityMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.DoubleTurnTimeMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.HealthMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.DamageMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SuperHealthMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.SpecialWeaponMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.BadPoisonMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.GoodPoisonMystery = new WeaponSettingsData(fileBelongs, fileBelongs.xomFile.GetContainerById(reader.ReadCompressedInt()));
this.ArtileryMode = reader.ReadInt32();
this.TeleportIn = reader.ReadInt32();
this.Wins = reader.ReadInt32();
this.WormSelect = reader.ReadInt32();
this.WormHealth = reader.ReadInt32();
this.RoundTime = reader.ReadInt32();
this.TurnTime = reader.ReadInt32();
this.Objects = reader.ReadInt32();
this.RandomCrateChancePerTurn = reader.ReadInt32();
this.MysteryChance = reader.ReadInt32();
this.WeaponChance = reader.ReadInt32();
this.UtilityChance = reader.ReadInt32();
this.HealthChance = reader.ReadInt32();
this.HealthInCrates = reader.ReadInt32();
this.Stockpiling = reader.ReadInt32();
this.SuddenDeath = reader.ReadInt32();
this.WaterSpeed = reader.ReadInt32();
this.DisplayTime = reader.ReadInt32();
this.LandTime = reader.ReadInt32();
this.RopeTime = reader.ReadInt32();
this.FallDamage = reader.ReadInt32();
this.HotSeat = reader.ReadInt32();
this.Special = reader.ReadInt32();
this.MineFuse = reader.ReadInt32();
this.HelpPanelDelay = reader.ReadInt32();
this.MineFactoryOn = reader.ReadBool();
this.TelepadsOn = reader.ReadBool();
this.WindMaxStrength = reader.ReadInt32();
}
}
public override void Save()
{
// Save all WeaponSettingsData.
this.Airstrike.Save();
this.BananaBomb.Save();
this.BaseballBat.Save();
this.Bazooka.Save();
this.ClusterGrenade.Save();
this.ConcreteDonkey.Save();
this.CrateShower.Save();
this.CrateSpy.Save();
this.DoubleDamage.Save();
this.Dynamite.Save();
this.FirePunch.Save();
this.GasCanister.Save();
this.Girder.Save();
this.Grenade.Save();
this.HolyHandGrenade.Save();
this.HomingMissile.Save();
this.Jetpack.Save();
this.Landmine.Save();
this.NinjaRope.Save();
this.OldWoman.Save();
this.Parachute.Save();
this.Prod.Save();
this.SelectWorm.Save();
this.Sheep.Save();
this.Shotgun.Save();
this.SkipGo.Save();
this.SuperSheep.Save();
this.Redbull.Save();
this.Flood.Save();
this.Armour.Save();
this.WeaponFactoryWeapon.Save();
this.AlienAbduction.Save();
this.Fatkins.Save();
this.Scouser.Save();
this.NoMoreNails.Save();
this.PoisonArrow.Save();
this.SentryGun.Save();
this.SniperRifle.Save();
this.SuperAirstrike.Save();
this.BubbleTrouble.Save();
this.Starburst.Save();
this.Surrender.Save();
this.MineLayerMystery.Save();
this.MineTripletMystery.Save();
this.BarrelTripletMystery.Save();
this.FloodMystery.Save();
this.DisarmMystery.Save();
this.TeleportMystery.Save();
this.QuickWalkMystery.Save();
this.LowGravityMystery.Save();
this.DoubleTurnTimeMystery.Save();
this.HealthMystery.Save();
this.DamageMystery.Save();
this.SuperHealthMystery.Save();
this.SpecialWeaponMystery.Save();
this.BadPoisonMystery.Save();
this.GoodPoisonMystery.Save();
// Save scheme
using (MemoryStream ms = new MemoryStream())
{
using (XomStreamWriter writer = new XomStreamWriter(ms))
{
writer.Skip(3);
writer.WriteCompressedInt(this.Name.Id);
writer.WriteBool(this.Permanant);
writer.WriteCompressedInt(this.Lock.Id);
writer.WriteCompressedInt(this.Airstrike.mainContainer.Id);
writer.WriteCompressedInt(this.BananaBomb.mainContainer.Id);
writer.WriteCompressedInt(this.BaseballBat.mainContainer.Id);
writer.WriteCompressedInt(this.Bazooka.mainContainer.Id);
writer.WriteCompressedInt(this.ClusterGrenade.mainContainer.Id);
writer.WriteCompressedInt(this.ConcreteDonkey.mainContainer.Id);
writer.WriteCompressedInt(this.CrateShower.mainContainer.Id);
writer.WriteCompressedInt(this.CrateSpy.mainContainer.Id);
writer.WriteCompressedInt(this.DoubleDamage.mainContainer.Id);
writer.WriteCompressedInt(this.Dynamite.mainContainer.Id);
writer.WriteCompressedInt(this.FirePunch.mainContainer.Id);
writer.WriteCompressedInt(this.GasCanister.mainContainer.Id);
writer.WriteCompressedInt(this.Girder.mainContainer.Id);
writer.WriteCompressedInt(this.Grenade.mainContainer.Id);
writer.WriteCompressedInt(this.HolyHandGrenade.mainContainer.Id);
writer.WriteCompressedInt(this.HomingMissile.mainContainer.Id);
writer.WriteCompressedInt(this.Jetpack.mainContainer.Id);
writer.WriteCompressedInt(this.Landmine.mainContainer.Id);
writer.WriteCompressedInt(this.NinjaRope.mainContainer.Id);
writer.WriteCompressedInt(this.OldWoman.mainContainer.Id);
writer.WriteCompressedInt(this.Parachute.mainContainer.Id);
writer.WriteCompressedInt(this.Prod.mainContainer.Id);
writer.WriteCompressedInt(this.SelectWorm.mainContainer.Id);
writer.WriteCompressedInt(this.Sheep.mainContainer.Id);
writer.WriteCompressedInt(this.Shotgun.mainContainer.Id);
writer.WriteCompressedInt(this.SkipGo.mainContainer.Id);
writer.WriteCompressedInt(this.SuperSheep.mainContainer.Id);
writer.WriteCompressedInt(this.Redbull.mainContainer.Id);
writer.WriteCompressedInt(this.Flood.mainContainer.Id);
writer.WriteCompressedInt(this.Armour.mainContainer.Id);
writer.WriteCompressedInt(this.WeaponFactoryWeapon.mainContainer.Id);
writer.WriteCompressedInt(this.AlienAbduction.mainContainer.Id);
writer.WriteCompressedInt(this.Fatkins.mainContainer.Id);
writer.WriteCompressedInt(this.Scouser.mainContainer.Id);
writer.WriteCompressedInt(this.NoMoreNails.mainContainer.Id);
writer.WriteCompressedInt(this.PoisonArrow.mainContainer.Id);
writer.WriteCompressedInt(this.SentryGun.mainContainer.Id);
writer.WriteCompressedInt(this.SniperRifle.mainContainer.Id);
writer.WriteCompressedInt(this.SuperAirstrike.mainContainer.Id);
writer.WriteCompressedInt(this.BubbleTrouble.mainContainer.Id);
writer.WriteCompressedInt(this.Starburst.mainContainer.Id);
writer.WriteCompressedInt(this.Surrender.mainContainer.Id);
writer.WriteCompressedInt(this.MineLayerMystery.mainContainer.Id);
writer.WriteCompressedInt(this.MineTripletMystery.mainContainer.Id);
writer.WriteCompressedInt(this.BarrelTripletMystery.mainContainer.Id);
writer.WriteCompressedInt(this.FloodMystery.mainContainer.Id);
writer.WriteCompressedInt(this.DisarmMystery.mainContainer.Id);
writer.WriteCompressedInt(this.TeleportMystery.mainContainer.Id);
writer.WriteCompressedInt(this.QuickWalkMystery.mainContainer.Id);
writer.WriteCompressedInt(this.LowGravityMystery.mainContainer.Id);
writer.WriteCompressedInt(this.DoubleTurnTimeMystery.mainContainer.Id);
writer.WriteCompressedInt(this.HealthMystery.mainContainer.Id);
writer.WriteCompressedInt(this.DamageMystery.mainContainer.Id);
writer.WriteCompressedInt(this.SuperHealthMystery.mainContainer.Id);
writer.WriteCompressedInt(this.SpecialWeaponMystery.mainContainer.Id);
writer.WriteCompressedInt(this.BadPoisonMystery.mainContainer.Id);
writer.WriteCompressedInt(this.GoodPoisonMystery.mainContainer.Id);
writer.WriteInt32(this.ArtileryMode);
writer.WriteInt32(this.TeleportIn);
writer.WriteInt32(this.Wins);
writer.WriteInt32(this.WormSelect);
writer.WriteInt32(this.WormHealth);
writer.WriteInt32(this.RoundTime);
writer.WriteInt32(this.TurnTime);
writer.WriteInt32(this.Objects);
writer.WriteInt32(this.RandomCrateChancePerTurn);
writer.WriteInt32(this.MysteryChance);
writer.WriteInt32(this.WeaponChance);
writer.WriteInt32(this.UtilityChance);
writer.WriteInt32(this.HealthChance);
writer.WriteInt32(this.HealthInCrates);
writer.WriteInt32(this.Stockpiling);
writer.WriteInt32(this.SuddenDeath);
writer.WriteInt32(this.WaterSpeed);
writer.WriteInt32(this.DisplayTime);
writer.WriteInt32(this.LandTime);
writer.WriteInt32(this.RopeTime);
writer.WriteInt32(this.FallDamage);
writer.WriteInt32(this.HotSeat);
writer.WriteInt32(this.Special);
writer.WriteInt32(this.MineFuse);
writer.WriteInt32(this.HelpPanelDelay);
writer.WriteBool(this.MineFactoryOn);
writer.WriteBool(this.TelepadsOn);
writer.WriteInt32(this.WindMaxStrength);
ms.Seek(0x00, SeekOrigin.Begin);
mainContainer.SetData(ms.ToArray());
}
}
}
}
}

View File

@ -0,0 +1,41 @@
using LibW4M.Data.WeaponFactory;
using LibXom.Data;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibW4M.Data.Schemes
{
public class SchemesCollective : SaveDataCollective
{
public SchemesCollective(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}
public override void Load()
{
int[] collective = mainContainer.Decompress();
for (int i = 0; i < collective[0]; i++)
{
SchemeData scheme = new SchemeData(this.fileBelongs, this.fileBelongs.xomFile.GetContainerById(collective[i + 1]));
base.collectiveEntries.Add(scheme);
}
}
public override void Save()
{
int len = this.Length;
int[] collective = new int[len + 1];
collective[0] = len;
for (int i = 0; i < len; i++)
{
SchemeData scheme = collectiveEntries[i] as SchemeData;
scheme.Save();
collective[i + 1] = scheme.mainContainer.Id;
}
mainContainer.CompressAndUpdate(collective);
}
}
}

View File

@ -0,0 +1,49 @@
using LibXom.Data;
using LibXom.Streams;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LibW4M.Data.Schemes
{
public class WeaponSettingsData : SaveDataEntry
{
public int Ammo;
public int Crate;
public int Delay;
public WeaponSettingsData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}
public override void Load()
{
using (XomStreamReader reader = new XomStreamReader(new MemoryStream(this.mainContainer.GetData())))
{
reader.Skip(3);
this.Ammo = reader.ReadInt32();
this.Crate = reader.ReadInt32();
this.Delay = reader.ReadInt32();
}
}
public override void Save()
{
using (MemoryStream ms = new MemoryStream())
{
using (XomStreamWriter writer = new XomStreamWriter(ms))
{
writer.Skip(3);
writer.WriteInt32(this.Ammo);
writer.WriteInt32(this.Crate);
writer.WriteInt32(this.Delay);
ms.Seek(0x00, SeekOrigin.Begin);
mainContainer.SetData(ms.ToArray());
}
}
}
}
}

View File

@ -9,7 +9,7 @@ using System.Threading.Tasks;
namespace LibW4M.Data.Teams
{
public class Team : SaveDataEntry
public class TeamData : SaveDataEntry
{
public override string FriendlyName
@ -42,7 +42,7 @@ namespace LibW4M.Data.Teams
public XomString Tash;
public int[] StoryMissionsCompleted;
public int StoryChapter;
public Team(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
public TeamData(W4SaveFile fileBelongs, XomContainer mainContainer) : base(fileBelongs, mainContainer)
{
}

View File

@ -20,7 +20,7 @@ namespace LibW4M.Data.Teams
int numTeams = decompressedCollective[0];
for (int i = 0; i < numTeams; i++)
{
Team team = new Team(this.fileBelongs, this.fileBelongs.xomFile.GetContainerById(decompressedCollective[i + 1]));
TeamData team = new TeamData(this.fileBelongs, this.fileBelongs.xomFile.GetContainerById(decompressedCollective[i + 1]));
this.collectiveEntries.Add(team);
}
}
@ -44,7 +44,7 @@ namespace LibW4M.Data.Teams
collective[0] = sz;
for (int i = 0; i < sz; i++)
{
Team team = collectiveEntries[i] as Team;
TeamData team = collectiveEntries[i] as TeamData;
team.Save();
collective[i + 1] = team.mainContainer.Id;
}

View File

@ -1,10 +1,12 @@
using LibW4M.Data;
using LibW4M.Data.Highscores;
using LibW4M.Data.Schemes;
using LibW4M.Data.Teams;
using LibW4M.Data.WeaponFactory;
using LibXom;
using LibXom.Blocks;
using LibXom.Data;
using System.Runtime.InteropServices;
namespace LibW4M
{
@ -13,6 +15,7 @@ namespace LibW4M
internal List<SaveDataEntry> collectives = new List<SaveDataEntry>();
private WeaponsCollective weaponFactoryCollective;
private TeamsCollective teamDataColective;
private SchemesCollective schemesCollective;
private HighscoreCollective highscoreCollective;
public WeaponsCollective WeaponFactoryCollective
{
@ -36,6 +39,14 @@ namespace LibW4M
}
}
public SchemesCollective SchemeCollective
{
get
{
return schemesCollective;
}
}
internal XomFile xomFile;
internal WeaponData findWeaponWithContainerId(int containerId)
@ -70,7 +81,19 @@ namespace LibW4M
foreach(XomContainer container in type.Containers)
{
File.WriteAllBytes(Path.ChangeExtension(Path.Combine(outfolder, container.Id.ToString("X2")), ".bin"), container.GetData());
while (true)
{
try
{
File.WriteAllBytes(Path.ChangeExtension(Path.Combine(outfolder, container.Id.ToString("X2")), ".bin"), container.GetData());
break;
}
catch
{
continue;
}
}
}
}
}
@ -112,9 +135,15 @@ namespace LibW4M
public W4SaveFile(XomFile w4Save)
{
this.xomFile = w4Save;
// Read Weapon Factory
weaponFactoryCollective = new WeaponsCollective(this, this.xomFile.GetTypeByName("WeaponFactoryCollective").Containers.First());
// Abtract away teamdata storing both highscores and teams.
teamDataColective = new TeamsCollective(this, this.xomFile.GetTypeByName("TeamDataColective").Containers.First());
highscoreCollective = new HighscoreCollective(this, this.xomFile.GetTypeByName("TeamDataColective").Containers.First());
// Read Schemes / Game Styles
schemesCollective = new SchemesCollective(this, this.xomFile.GetTypeByName("SchemeColective").Containers.First());
}
}
}

View File

@ -89,7 +89,7 @@ namespace LibXom.Streams
}
public void WriteInt32(int value)
{
byte[] buffer = BitConverter.GetBytes(value);
byte[] buffer = BitConverter.GetBytes((int)value);
WriteBytes(buffer);
}
public void WriteInt32BE(int value)

View File

@ -0,0 +1,153 @@
namespace W4Gui.Components
{
partial class InputWeaponSettingsData
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.tblWeapSettingData = new System.Windows.Forms.TableLayoutPanel();
this.lblAmmo = new System.Windows.Forms.Label();
this.lblCrateChance = new System.Windows.Forms.Label();
this.lblTurnDelay = new System.Windows.Forms.Label();
this.selAmmo = new W4Gui.Components.IntUpDown();
this.selCrate = new W4Gui.Components.IntUpDown();
this.selTurnDelay = new W4Gui.Components.IntUpDown();
this.tblWeapSettingData.SuspendLayout();
this.SuspendLayout();
//
// tblWeapSettingData
//
this.tblWeapSettingData.AutoSize = true;
this.tblWeapSettingData.CellBorderStyle = System.Windows.Forms.TableLayoutPanelCellBorderStyle.Inset;
this.tblWeapSettingData.ColumnCount = 2;
this.tblWeapSettingData.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.tblWeapSettingData.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tblWeapSettingData.Controls.Add(this.lblAmmo, 0, 0);
this.tblWeapSettingData.Controls.Add(this.lblCrateChance, 0, 1);
this.tblWeapSettingData.Controls.Add(this.lblTurnDelay, 0, 2);
this.tblWeapSettingData.Controls.Add(this.selAmmo, 1, 0);
this.tblWeapSettingData.Controls.Add(this.selCrate, 1, 1);
this.tblWeapSettingData.Controls.Add(this.selTurnDelay, 1, 2);
this.tblWeapSettingData.Dock = System.Windows.Forms.DockStyle.Top;
this.tblWeapSettingData.Location = new System.Drawing.Point(0, 0);
this.tblWeapSettingData.Name = "tblWeapSettingData";
this.tblWeapSettingData.RowCount = 3;
this.tblWeapSettingData.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tblWeapSettingData.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tblWeapSettingData.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.tblWeapSettingData.Size = new System.Drawing.Size(351, 95);
this.tblWeapSettingData.TabIndex = 0;
//
// lblAmmo
//
this.lblAmmo.AutoSize = true;
this.lblAmmo.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblAmmo.ForeColor = System.Drawing.SystemColors.ControlText;
this.lblAmmo.Location = new System.Drawing.Point(5, 2);
this.lblAmmo.Name = "lblAmmo";
this.lblAmmo.Size = new System.Drawing.Size(81, 29);
this.lblAmmo.TabIndex = 0;
this.lblAmmo.Text = "Ammo:";
this.lblAmmo.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblCrateChance
//
this.lblCrateChance.AutoSize = true;
this.lblCrateChance.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblCrateChance.Location = new System.Drawing.Point(5, 33);
this.lblCrateChance.Name = "lblCrateChance";
this.lblCrateChance.Size = new System.Drawing.Size(81, 29);
this.lblCrateChance.TabIndex = 1;
this.lblCrateChance.Text = "Crate Chance:";
this.lblCrateChance.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// lblTurnDelay
//
this.lblTurnDelay.AutoSize = true;
this.lblTurnDelay.Dock = System.Windows.Forms.DockStyle.Fill;
this.lblTurnDelay.Location = new System.Drawing.Point(5, 64);
this.lblTurnDelay.Name = "lblTurnDelay";
this.lblTurnDelay.Size = new System.Drawing.Size(81, 29);
this.lblTurnDelay.TabIndex = 2;
this.lblTurnDelay.Text = "Turn Delay:";
this.lblTurnDelay.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// selAmmo
//
this.selAmmo.Dock = System.Windows.Forms.DockStyle.Top;
this.selAmmo.Location = new System.Drawing.Point(94, 5);
this.selAmmo.Name = "selAmmo";
this.selAmmo.Size = new System.Drawing.Size(252, 23);
this.selAmmo.TabIndex = 3;
this.selAmmo.Text = "0";
this.selAmmo.Value = 0;
//
// selCrate
//
this.selCrate.Dock = System.Windows.Forms.DockStyle.Top;
this.selCrate.Location = new System.Drawing.Point(94, 36);
this.selCrate.Name = "selCrate";
this.selCrate.Size = new System.Drawing.Size(252, 23);
this.selCrate.TabIndex = 4;
this.selCrate.Text = "0";
this.selCrate.Value = 0;
//
// selTurnDelay
//
this.selTurnDelay.Dock = System.Windows.Forms.DockStyle.Top;
this.selTurnDelay.Location = new System.Drawing.Point(94, 67);
this.selTurnDelay.Name = "selTurnDelay";
this.selTurnDelay.Size = new System.Drawing.Size(252, 23);
this.selTurnDelay.TabIndex = 5;
this.selTurnDelay.Text = "0";
this.selTurnDelay.Value = 0;
//
// InputWeaponSettingsData
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSize = true;
this.Controls.Add(this.tblWeapSettingData);
this.Name = "InputWeaponSettingsData";
this.Size = new System.Drawing.Size(351, 95);
this.tblWeapSettingData.ResumeLayout(false);
this.tblWeapSettingData.PerformLayout();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private TableLayoutPanel tblWeapSettingData;
private Label lblAmmo;
private Label lblCrateChance;
private Label lblTurnDelay;
private IntUpDown selAmmo;
private IntUpDown selCrate;
private IntUpDown selTurnDelay;
}
}

View File

@ -0,0 +1,34 @@
using LibW4M.Data.Schemes;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace W4Gui.Components
{
public partial class InputWeaponSettingsData : UserControl
{
public InputWeaponSettingsData()
{
InitializeComponent();
}
public void LoadWeaponSettingsData(WeaponSettingsData wsd)
{
this.selAmmo.Value = wsd.Ammo;
this.selCrate.Value = wsd.Crate;
this.selTurnDelay.Value = wsd.Delay;
}
public void SaveWeaponSettingsData(ref WeaponSettingsData wsd)
{
wsd.Ammo = this.selAmmo.Value;
wsd.Crate = this.selCrate.Value;
wsd.Delay = this.selTurnDelay.Value;
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

2700
W4Gui/Components/SchemePanel.Designer.cs generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,50 @@
using LibW4M.Data.Highscores;
using LibW4M.Data.Teams;
using LibW4M.Data.WeaponFactory;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using W4Gui.Dialogs;
namespace W4Gui.Components
{
public partial class SchemePanel : UserControl
{
public SchemePanel()
{
InitializeComponent();
}
private void generalTab_Click(object sender, EventArgs e)
{
}
private void weaponTab_Click(object sender, EventArgs e)
{
}
/*public void SaveHighscoreData(ref HighscoreData highscore)
{
// Load general
highscore.WinnerName = DataManager.SaveFile.LookupString(selWinnerName.Text);
highscore.WinnerTime = selWinnerTime.Value;
}
public void LoadHighscoreData(HighscoreData highscore)
{
// Load general
this.selWinnerName.Text = highscore.WinnerName.Value;
this.selWinnerTime.Value = highscore.WinnerTime;
}*/
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -23,7 +23,7 @@ namespace W4Gui.Components
}
public void SaveTeamData(ref Team team)
public void SaveTeamData(ref TeamData team)
{
// Load general
team.Name = DataManager.SaveFile.LookupString(this.selName.Text);
@ -56,7 +56,7 @@ namespace W4Gui.Components
team.CustomWeapon = DataManager.SaveFile.LookupString(this.selTeamWeapName.Text);
}
public void LoadTeamData(Team team)
public void LoadTeamData(TeamData team)
{
// Load general
this.selName.Text = team.Name.Value;

View File

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>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;</History>
<History>True|2023-01-15T04:06:35.5919106Z;True|2023-01-13T16:57:56.0824690-08:00;True|2023-01-11T01:22:28.8737310-08:00;True|2023-01-11T01:16:55.3469226-08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>

View File

@ -62,8 +62,8 @@
this.highscoresList.Name = "highscoresList";
this.highscoresList.Size = new System.Drawing.Size(261, 460);
this.highscoresList.TabIndex = 0;
this.highscoresList.NewButton += new System.EventHandler<System.EventArgs>(this.teamsList_NewButton);
this.highscoresList.DeleteButton += new System.EventHandler<System.EventArgs>(this.teamsList_DeleteButton);
this.highscoresList.NewButton += new System.EventHandler<System.EventArgs>(this.highscoresList_NewButton);
this.highscoresList.DeleteButton += new System.EventHandler<System.EventArgs>(this.highscoresList_DelButton);
//
// highscorePanel
//

View File

@ -48,12 +48,12 @@ namespace W4Gui.Tabs
highscoresPanel.Enabled = true;
}
private void teamsList_NewButton(object sender, EventArgs e)
private void highscoresList_NewButton(object sender, EventArgs e)
{
throw new NotImplementedException("Adding new highscores from here not implemented yet ;)");
}
private void teamsList_DeleteButton(object sender, EventArgs e)
private void highscoresList_DelButton(object sender, EventArgs e)
{
throw new NotImplementedException("Removing highscores from here not implemented yet ;)");
}

View File

@ -35,14 +35,14 @@ namespace W4Gui.Tabs
private void teamsList_Unselected(object? sender, EventArgs e)
{
Team team = DataManager.SaveFile.TeamDataColective[teamsList.List.LastSelected] as Team;
TeamData team = DataManager.SaveFile.TeamDataColective[teamsList.List.LastSelected] as TeamData;
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;
TeamData team = DataManager.SaveFile.TeamDataColective[teamsList.List.CurrentlySelected] as TeamData;
teamsPanel.LoadTeamData(team);
teamsPanel.Enabled = true;
}

View File

@ -9,6 +9,9 @@
</PropertyGroup>
<ItemGroup>
<Compile Update="Components\SchemePanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="Components\IntUpDown.cs" />
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>

View File

@ -16,6 +16,9 @@
<Compile Update="Components\HighscoresPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="Components\InputWeaponSettingsData.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Update="Components\IntList.cs">
<SubType>UserControl</SubType>
</Compile>