mirror of
https://gitlab.com/Syroot/Worms.git
synced 2025-03-04 17:35:22 +03:00
Add parameterless constructors for new instance creation and unit test project.
This commit is contained in:
parent
d842d17abb
commit
a2a368baed
@ -1,7 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Syroot.Worms.Gen2.Armageddon;
|
using Syroot.Worms.Gen2;
|
||||||
|
|
||||||
namespace Syroot.Worms.Test
|
namespace Syroot.Worms.Test
|
||||||
{
|
{
|
||||||
@ -12,30 +12,13 @@ namespace Syroot.Worms.Test
|
|||||||
{
|
{
|
||||||
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
|
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private static readonly string[] _testPaths = { @"C:\Games\Worms Armageddon 3.7.2.1", @"E:\" };
|
private static readonly string[] _testPaths = { @"C:\Games\Worms Armageddon 3.7.2.1" };
|
||||||
|
|
||||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
//foreach (string dirFile in GetFiles("*.dir"))
|
Palette palette = new Palette("C:\\Games\\Worms World Party\\graphics\\palettes\\wwp.pal");
|
||||||
//{
|
|
||||||
// Console.WriteLine($"Loading {dirFile}...");
|
|
||||||
// Archive archive = new Archive(dirFile);
|
|
||||||
// foreach (string entry in archive.Keys)
|
|
||||||
// {
|
|
||||||
// Console.WriteLine($"\t{entry}");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//foreach (string imgFile in GetFiles("*.img"))
|
|
||||||
//{
|
|
||||||
// Console.WriteLine("Loading {imgFile}...");
|
|
||||||
// Image image = new Image(imgFile);
|
|
||||||
//}
|
|
||||||
Scheme scheme = new Scheme(@"D:\Archive\Games\Worms\Worms Armageddon\Common\User\Schemes\{{13}} The Full Wormage.wsc");
|
|
||||||
scheme.Save(@"D:\Pictures\Test2.wsc");
|
|
||||||
scheme.Load(@"D:\Pictures\Test2.wsc");
|
|
||||||
|
|
||||||
Console.WriteLine("Done.");
|
Console.WriteLine("Done.");
|
||||||
Console.ReadLine();
|
Console.ReadLine();
|
||||||
|
67
src/Syroot.Worms.UnitTest/Common/TestHelpers.cs
Normal file
67
src/Syroot.Worms.UnitTest/Common/TestHelpers.cs
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Syroot.Worms.Core;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of methods helping in executing tests.
|
||||||
|
/// </summary>
|
||||||
|
internal static class TestHelpers
|
||||||
|
{
|
||||||
|
// ---- MEMBERS ------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
private static readonly string[] _gamePaths =
|
||||||
|
{
|
||||||
|
@"C:\Games\Worms2",
|
||||||
|
@"C:\Games\Worms Armageddon 3.7.2.1",
|
||||||
|
@"C:\Games\Worms World Party"
|
||||||
|
};
|
||||||
|
|
||||||
|
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the files found with the given <paramref name="wildcard"/>. Excludes file names specified in the
|
||||||
|
/// optional array <paramref name="excludedFiles"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T">The type of the files to load.</typeparam>
|
||||||
|
/// <param name="wildcard">The wildcard to match.</param>
|
||||||
|
/// <param name="excludedFiles">Optionally, the files to exclude.</param>
|
||||||
|
internal static void LoadFiles<T>(string wildcard, string[] excludedFiles = null) where T : ILoadableFile, new()
|
||||||
|
{
|
||||||
|
foreach (string fileName in FindFiles(wildcard))
|
||||||
|
{
|
||||||
|
if (excludedFiles?.Contains(Path.GetFileName(fileName), StringComparer.OrdinalIgnoreCase) == true)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Skipping {fileName}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Debug.Write($"Loading {fileName}...");
|
||||||
|
T instance = new T();
|
||||||
|
instance.Load(fileName);
|
||||||
|
Debug.WriteLine($" ok");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a list of files found in any of the paths provided in the _gamePaths variable which match the
|
||||||
|
/// specified <paramref name="wildcard"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="wildcard">The wildcard which files have to match.</param>
|
||||||
|
/// <returns>A list of files matching the search.</returns>
|
||||||
|
private static List<string> FindFiles(string wildcard)
|
||||||
|
{
|
||||||
|
List<string> files = new List<string>();
|
||||||
|
foreach (string testPath in _gamePaths)
|
||||||
|
{
|
||||||
|
files.AddRange(Directory.GetFiles(testPath, wildcard, SearchOption.AllDirectories));
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/Syroot.Worms.UnitTest/Gen2/ArchiveTests.cs
Normal file
25
src/Syroot.Worms.UnitTest/Gen2/ArchiveTests.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Syroot.Worms.Gen2;
|
||||||
|
using Syroot.Worms.UnitTest.Common;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Gen2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of tests for the <see cref="Archive"/> class.
|
||||||
|
/// </summary>
|
||||||
|
[TestCategory("Archive")]
|
||||||
|
[TestClass]
|
||||||
|
public class ArchiveTests
|
||||||
|
{
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all files found in any game directories.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void LoadArchives()
|
||||||
|
{
|
||||||
|
TestHelpers.LoadFiles<Archive>("*.dir");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/Syroot.Worms.UnitTest/Gen2/Armageddon/SchemeTests.cs
Normal file
25
src/Syroot.Worms.UnitTest/Gen2/Armageddon/SchemeTests.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Syroot.Worms.Gen2.Armageddon;
|
||||||
|
using Syroot.Worms.UnitTest.Common;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Gen2.Armageddon
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of tests for the <see cref="Scheme"/> class.
|
||||||
|
/// </summary>
|
||||||
|
[TestCategory("Scheme")]
|
||||||
|
[TestClass]
|
||||||
|
public class SchemeTests
|
||||||
|
{
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all files found in any game directories.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void LoadSchemes()
|
||||||
|
{
|
||||||
|
TestHelpers.LoadFiles<Scheme>("*.wsc");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/Syroot.Worms.UnitTest/Gen2/ImageTests.cs
Normal file
25
src/Syroot.Worms.UnitTest/Gen2/ImageTests.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Syroot.Worms.Gen2;
|
||||||
|
using Syroot.Worms.UnitTest.Common;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Gen2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of tests for the <see cref="Image"/> class.
|
||||||
|
/// </summary>
|
||||||
|
[TestCategory("Image")]
|
||||||
|
[TestClass]
|
||||||
|
public class ImageTests
|
||||||
|
{
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all files found in any game directories.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void LoadImages()
|
||||||
|
{
|
||||||
|
TestHelpers.LoadFiles<Image>("*.img");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
29
src/Syroot.Worms.UnitTest/Gen2/PaletteTests.cs
Normal file
29
src/Syroot.Worms.UnitTest/Gen2/PaletteTests.cs
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Syroot.Worms.Gen2;
|
||||||
|
using Syroot.Worms.UnitTest.Common;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Gen2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of tests for the <see cref="Palette"/> class.
|
||||||
|
/// </summary>
|
||||||
|
[TestCategory("Palette")]
|
||||||
|
[TestClass]
|
||||||
|
public class PaletteTests
|
||||||
|
{
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all files found in any game directories.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void LoadPalettes()
|
||||||
|
{
|
||||||
|
TestHelpers.LoadFiles<Palette>("*.pal", new string[]
|
||||||
|
{
|
||||||
|
"wwp.pal", // Contains 4 bytes of trash after the data chunk.
|
||||||
|
"wwpmaped.pal" // Contains 4 bytes of trash after the data chunk.
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeOptionsTests.cs
Normal file
25
src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeOptionsTests.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Syroot.Worms.Gen2.Worms2;
|
||||||
|
using Syroot.Worms.UnitTest.Common;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Gen2.Worms2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of tests for the <see cref="SchemeOptions"/> class.
|
||||||
|
/// </summary>
|
||||||
|
[TestCategory("SchemeOptions")]
|
||||||
|
[TestClass]
|
||||||
|
public class SchemeOptionsTests
|
||||||
|
{
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all files found in any game directories.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void LoadSchemeOptions()
|
||||||
|
{
|
||||||
|
TestHelpers.LoadFiles<SchemeOptions>("*.opt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeWeaponsTests.cs
Normal file
25
src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeWeaponsTests.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||||
|
using Syroot.Worms.Gen2.Worms2;
|
||||||
|
using Syroot.Worms.UnitTest.Common;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.UnitTest.Gen2.Worms2
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a collection of tests for the <see cref="SchemeWeapons"/> class.
|
||||||
|
/// </summary>
|
||||||
|
[TestCategory("SchemeWeapons")]
|
||||||
|
[TestClass]
|
||||||
|
public class SchemeWeaponsTests
|
||||||
|
{
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads all files found in any game directories.
|
||||||
|
/// </summary>
|
||||||
|
[TestMethod]
|
||||||
|
public void LoadSchemeWeapons()
|
||||||
|
{
|
||||||
|
TestHelpers.LoadFiles<SchemeWeapons>("*.wep");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
21
src/Syroot.Worms.UnitTest/Syroot.Worms.UnitTest.csproj
Normal file
21
src/Syroot.Worms.UnitTest/Syroot.Worms.UnitTest.csproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netcoreapp1.1</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
|
||||||
|
<PackageReference Include="MSTest.TestAdapter" Version="1.1.11" />
|
||||||
|
<PackageReference Include="MSTest.TestFramework" Version="1.1.11" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -5,7 +5,9 @@ VisualStudioVersion = 15.0.26403.7
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syroot.Worms", "Syroot.Worms\Syroot.Worms.csproj", "{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syroot.Worms", "Syroot.Worms\Syroot.Worms.csproj", "{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syroot.Worms.Test", "Syroot.Worms.Test\Syroot.Worms.Test.csproj", "{9F7486C2-C30E-4457-B528-F4467486E6D8}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syroot.Worms.UnitTest", "Syroot.Worms.UnitTest\Syroot.Worms.UnitTest.csproj", "{493816DB-A1A1-4981-9F5F-8044499937B6}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Test", "Syroot.Worms.Test\Syroot.Worms.Test.csproj", "{2D796945-A523-4A22-BDEE-702D6BA36F69}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@ -17,10 +19,14 @@ Global
|
|||||||
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{9F7486C2-C30E-4457-B528-F4467486E6D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{493816DB-A1A1-4981-9F5F-8044499937B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{9F7486C2-C30E-4457-B528-F4467486E6D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{493816DB-A1A1-4981-9F5F-8044499937B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9F7486C2-C30E-4457-B528-F4467486E6D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{493816DB-A1A1-4981-9F5F-8044499937B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9F7486C2-C30E-4457-B528-F4467486E6D8}.Release|Any CPU.Build.0 = Release|Any CPU
|
{493816DB-A1A1-4981-9F5F-8044499937B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2D796945-A523-4A22-BDEE-702D6BA36F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2D796945-A523-4A22-BDEE-702D6BA36F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2D796945-A523-4A22-BDEE-702D6BA36F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2D796945-A523-4A22-BDEE-702D6BA36F69}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
@ -25,6 +25,13 @@ namespace Syroot.Worms.Gen2
|
|||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Archive"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public Archive()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Archive"/> class, loading the data from the given
|
/// Initializes a new instance of the <see cref="Archive"/> class, loading the data from the given
|
||||||
/// <see cref="Stream"/>.
|
/// <see cref="Stream"/>.
|
||||||
|
140
src/Syroot.Worms/Gen2/Armageddon/LandData.cs
Normal file
140
src/Syroot.Worms/Gen2/Armageddon/LandData.cs
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using Syroot.IO;
|
||||||
|
using Syroot.Maths;
|
||||||
|
using Syroot.Worms.Core;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.Gen2.Armageddon
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents scheme options stored in an OPT file which contains game settings.
|
||||||
|
/// S. https://worms2d.info/Options_file.
|
||||||
|
/// </summary>
|
||||||
|
public class LandData : ILoadableFile
|
||||||
|
{
|
||||||
|
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
private const int _signature = 0x1A444E4C; // "LND", 0x1A
|
||||||
|
|
||||||
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="LandData"/> class, loading the data from the given
|
||||||
|
/// <see cref="Stream"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||||
|
public LandData(Stream stream)
|
||||||
|
{
|
||||||
|
Load(stream);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="LandData"/> class, loading the data from the given file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||||
|
public LandData(string fileName)
|
||||||
|
{
|
||||||
|
Load(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the size of the landscape in pixels.
|
||||||
|
/// </summary>
|
||||||
|
public Vector2 Size { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether an indestructible top border will be enabled.
|
||||||
|
/// </summary>
|
||||||
|
public bool TopBorder { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the height of the water in pixels.
|
||||||
|
/// </summary>
|
||||||
|
public int WaterHeight { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets an array of coordinates at which objects can be placed.
|
||||||
|
/// </summary>
|
||||||
|
public Vector2[] ObjectLocations { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the visual foreground image.
|
||||||
|
/// </summary>
|
||||||
|
public Image Foreground { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the collision mask of the landscape.
|
||||||
|
/// </summary>
|
||||||
|
public Image CollisionMask { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the visual background image.
|
||||||
|
/// </summary>
|
||||||
|
public Image Background { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the path to the land image file.
|
||||||
|
/// </summary>
|
||||||
|
public string LandTexturePath { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the path to the Water.dir file.
|
||||||
|
/// </summary>
|
||||||
|
public string WaterDirPath { get; set; }
|
||||||
|
|
||||||
|
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the data from the given <see cref="Stream"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||||
|
public void Load(Stream stream)
|
||||||
|
{
|
||||||
|
using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII))
|
||||||
|
{
|
||||||
|
// Read the header.
|
||||||
|
if (reader.ReadInt32() != _signature)
|
||||||
|
{
|
||||||
|
throw new InvalidDataException("Invalid LND file signature.");
|
||||||
|
}
|
||||||
|
int fileLength = reader.ReadInt32();
|
||||||
|
|
||||||
|
// Read the data.
|
||||||
|
Size = reader.ReadStruct<Vector2>();
|
||||||
|
TopBorder = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
|
||||||
|
WaterHeight = reader.ReadInt32();
|
||||||
|
|
||||||
|
// Read the possible object coordinate array.
|
||||||
|
ObjectLocations = new Vector2[reader.ReadInt32()];
|
||||||
|
int objectLocationCountAgain = reader.ReadInt32(); // TODO: Repetitive or useful?
|
||||||
|
for (int i = 0; i < ObjectLocations.Length; i++)
|
||||||
|
{
|
||||||
|
ObjectLocations[i] = reader.ReadStruct<Vector2>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the image data.
|
||||||
|
Foreground = new Image(stream);
|
||||||
|
CollisionMask = new Image(stream);
|
||||||
|
Background = new Image(stream);
|
||||||
|
|
||||||
|
// Read the file paths.
|
||||||
|
LandTexturePath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
|
||||||
|
WaterDirPath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the data from the given file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||||
|
public void Load(string fileName)
|
||||||
|
{
|
||||||
|
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
|
{
|
||||||
|
Load(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -43,6 +43,15 @@ namespace Syroot.Worms.Gen2.Armageddon
|
|||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Scheme"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public Scheme()
|
||||||
|
{
|
||||||
|
Version = SchemeVersion.Extended;
|
||||||
|
Weapons = new SchemeWeaponSetting[GetWeaponCount()];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given
|
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given
|
||||||
/// <see cref="Stream"/>.
|
/// <see cref="Stream"/>.
|
||||||
|
@ -745,7 +745,12 @@ namespace Syroot.Worms.Gen2.Armageddon
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The worms health is reduced to 1.
|
/// The worms health is reduced to 1.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
HealthDrop = 2
|
HealthDrop = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// No special event is triggered and the water only rises in the rate specified in the scheme.
|
||||||
|
/// </summary>
|
||||||
|
WaterRise = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -19,6 +19,13 @@ namespace Syroot.Worms.Gen2
|
|||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Image"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public Image()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Image"/> class, loading the data from the given
|
/// Initializes a new instance of the <see cref="Image"/> class, loading the data from the given
|
||||||
/// <see cref="Stream"/>.
|
/// <see cref="Stream"/>.
|
||||||
@ -56,14 +63,9 @@ namespace Syroot.Worms.Gen2
|
|||||||
public Color[] Palette { get; private set; }
|
public Color[] Palette { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the width of the image in pixels.
|
/// Gets the size of the image in pixels.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int Width { get; private set; }
|
public Vector2 Size { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the height of the image in pixels.
|
|
||||||
/// </summary>
|
|
||||||
public int Height { get; private set; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the data of the image pixels.
|
/// Gets the data of the image pixels.
|
||||||
@ -115,11 +117,10 @@ namespace Syroot.Worms.Gen2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Width = reader.ReadInt16();
|
Size = reader.ReadStruct<Vector2>();
|
||||||
Height = reader.ReadInt16();
|
|
||||||
|
|
||||||
// Read the image data, which might be compressed.
|
// Read the image data, which might be compressed.
|
||||||
byte[] data = new byte[Width * Height * (BitsPerPixel / 8)];
|
byte[] data = new byte[Size.X * Size.Y * (BitsPerPixel / 8)];
|
||||||
if (flags.HasFlag(Flags.Compressed))
|
if (flags.HasFlag(Flags.Compressed))
|
||||||
{
|
{
|
||||||
Team17Compression.Decompress(reader.BaseStream, ref data);
|
Team17Compression.Decompress(reader.BaseStream, ref data);
|
||||||
|
@ -18,6 +18,14 @@ namespace Syroot.Worms.Gen2
|
|||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Palette"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public Palette()
|
||||||
|
{
|
||||||
|
Version = _version;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="Palette"/> class, loading the data from the given
|
/// Initializes a new instance of the <see cref="Palette"/> class, loading the data from the given
|
||||||
/// <see cref="Stream"/>.
|
/// <see cref="Stream"/>.
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Syroot.IO;
|
using Syroot.IO;
|
||||||
@ -19,6 +17,13 @@ namespace Syroot.Worms.Gen2.Worms2
|
|||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializs a new instance of the <see cref="SchemeOptions"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public SchemeOptions()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SchemeOptions"/> class, loading the data from the given
|
/// Initializes a new instance of the <see cref="SchemeOptions"/> class, loading the data from the given
|
||||||
/// <see cref="Stream"/>.
|
/// <see cref="Stream"/>.
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Syroot.IO;
|
using Syroot.IO;
|
||||||
using Syroot.Worms.Core;
|
using Syroot.Worms.Core;
|
||||||
@ -22,6 +19,14 @@ namespace Syroot.Worms.Gen2.Worms2
|
|||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class.
|
||||||
|
/// </summary>
|
||||||
|
public SchemeWeapons()
|
||||||
|
{
|
||||||
|
Weapons = new SchemeWeaponSetting[_weaponCount];
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class, loading the data from the given
|
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class, loading the data from the given
|
||||||
/// <see cref="Stream"/>.
|
/// <see cref="Stream"/>.
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Syroot.IO.BinaryData" Version="1.2.0" />
|
<PackageReference Include="Syroot.IO.BinaryData" Version="1.2.2" />
|
||||||
<PackageReference Include="Syroot.Maths" Version="1.3.0" />
|
<PackageReference Include="Syroot.Maths" Version="1.3.1" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user