Skip to content

Commit

Permalink
Release v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jianmingyong committed Aug 13, 2024
1 parent 9667bee commit 9fc543e
Show file tree
Hide file tree
Showing 16 changed files with 56 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
env:
PROJECT_PROPERTIES: TheDialgaTeam.FossilFighters.prop
PROJECT_PUBLISH_ROOT: bin
DOTNET_VERSION: 7.0.x
DOTNET_VERSION: 8.0.x
RELEASE_TEMPLATE: RELEASE_TEMPLATE.md

defaults:
Expand Down
1 change: 1 addition & 0 deletions RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Change Logs from v2.1.0:
- CLI: Changed the behavior of `convert dtx` command such that it uses a new json file format.
- CLI: Added `convert dmg` command to convert the generated json file to dmg file format.
- GUI: Fixed nds rom checksum so you can run in bootloader mode.
- CLI: Decompress will now not output extra stuff unless `--extra` argument is supplied.
- CORE: Fixed images/sprites that uses 16 bytes color palette.

Extra Files Supported:
Expand Down
2 changes: 1 addition & 1 deletion TheDialgaTeam.FossilFighters.Assets/Archive/MarArchive.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public IReadOnlyList<MarArchiveEntry> Entries
private readonly BinaryReader? _reader;
private readonly BinaryWriter? _writer;

private readonly List<MarArchiveEntry> _entries = new();
private readonly List<MarArchiveEntry> _entries = [];

private bool _hasEntriesRead;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System.Buffers;
using System.Diagnostics;
using System.Text;

namespace TheDialgaTeam.FossilFighters.Assets.Archive;
Expand All @@ -34,7 +35,8 @@ public MarArchiveEntry(BinaryReader reader, int fileOffset, int fileLength)
{
if (memoryStream.TryGetBuffer(out var arraySegment))
{
MemoryStream = new MemoryStream(arraySegment.Array!, arraySegment.Offset + fileOffset, fileLength);
Debug.Assert(arraySegment.Array != null, "arraySegment.Array != null");
MemoryStream = new MemoryStream(arraySegment.Array, arraySegment.Offset + fileOffset, fileLength);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion TheDialgaTeam.FossilFighters.Assets/GameData/DmgFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public sealed class DmgFile
{
public const uint FileHeader = 0x00474D44;

public DmgMessage[] Messages { get; set; } = Array.Empty<DmgMessage>();
public DmgMessage[] Messages { get; set; } = [];

public static DmgFile ReadFromRawStream(Stream stream)
{
Expand Down
1 change: 0 additions & 1 deletion TheDialgaTeam.FossilFighters.Assets/Rom/NdsFilesystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public sealed class NdsFilesystem : IDisposable
internal Dictionary<ushort, NitroRomDirectory> NitroRomDirectories { get; } = new();

internal Dictionary<ushort, NitroRomFile> NitroRomFilesById { get; } = new();

internal Dictionary<string, NitroRomFile> NitroRomFilesByPath { get; } = new();

internal Dictionary<ushort, NitroRomFile> OverlayFilesById { get; } = new();
Expand Down
4 changes: 2 additions & 2 deletions TheDialgaTeam.FossilFighters.Assets/Rom/NitroRomDirectory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ public string FullPath

public NitroRomType FileType => NitroRomType.FileFolder;

public List<NitroRomDirectory> SubDirectories { get; } = new();
public List<NitroRomDirectory> SubDirectories { get; } = [];

public List<NitroRomFile> Files { get; } = new();
public List<NitroRomFile> Files { get; } = [];
private readonly NitroRomDirectory? _parentDirectory;

private string? _fullPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.4" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.1.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ public CompressCommand() : base("compress", Localization.CompressCommandDescript
var inputArgument = new Argument<string>("input", "Target folder to compress.") { Arity = ArgumentArity.ExactlyOne };
inputArgument.LegalFilePathsOnly();

var outputOption = new Option<string>(new[] { "--output", "-o" }, "Output file after compression.") { Arity = ArgumentArity.ExactlyOne, IsRequired = true, ArgumentHelpName = "file" };
var outputOption = new Option<string>(["--output", "-o"], "Output file after compression.") { Arity = ArgumentArity.ExactlyOne, IsRequired = true, ArgumentHelpName = "file" };

var includeOption = new Option<string[]>(new[] { "--include", "-i" }, static () => new[] { "*.bin" }, "Include files to be compressed. You can use wildcard (*) to specify one or more files. E.g \"-i *.bin -i *.hex\"") { Arity = ArgumentArity.OneOrMore, IsRequired = false, ArgumentHelpName = "fileTypes" };
var includeOption = new Option<string[]>(["--include", "-i"], static () => ["*.bin"], "Include files to be compressed. You can use wildcard (*) to specify one or more files. E.g \"-i *.bin -i *.hex\"") { Arity = ArgumentArity.OneOrMore, IsRequired = false, ArgumentHelpName = "fileTypes" };

var compressionTypeOption = new Option<McmFileCompressionType[]>(new[] { "--compress-type", "-c" }, static () => Array.Empty<McmFileCompressionType>(), "Type of compression to be used. (Maximum 2) E.g \"-c Huffman -c Lzss\" Compression is done in reverse order. Make sure to put huffman first for better compression ratio.") { Arity = new ArgumentArity(1, 2), IsRequired = false };
var compressionTypeOption = new Option<McmFileCompressionType[]>(["--compress-type", "-c"], static () => [], "Type of compression to be used. (Maximum 2) E.g \"-c Huffman -c Lzss\" Compression is done in reverse order. Make sure to put huffman first for better compression ratio.") { Arity = new ArgumentArity(1, 2), IsRequired = false };
compressionTypeOption.AddCompletions(Enum.GetNames<McmFileCompressionType>());

var maxSizePerChunkOption = new Option<uint>(new[] { "--max-size-per-chunk", "-m" }, static () => 0x2000, "Split each file into chunks of <size> bytes when compressing.") { Arity = ArgumentArity.ExactlyOne, IsRequired = false, ArgumentHelpName = "size" };
var maxSizePerChunkOption = new Option<uint>(["--max-size-per-chunk", "-m"], static () => 0x2000, "Split each file into chunks of <size> bytes when compressing.") { Arity = ArgumentArity.ExactlyOne, IsRequired = false, ArgumentHelpName = "size" };

var metaFileOption = new Option<string>(new[] { "--meta-file", "-mf" }, static () => "meta.json", "Meta definition file to define the compression type and the chunk size.") { Arity = ArgumentArity.ExactlyOne, IsRequired = false, ArgumentHelpName = "file" };
var metaFileOption = new Option<string>(["--meta-file", "-mf"], static () => "meta.json", "Meta definition file to define the compression type and the chunk size.") { Arity = ArgumentArity.ExactlyOne, IsRequired = false, ArgumentHelpName = "file" };

AddArgument(inputArgument);
AddOption(outputOption);
Expand Down
36 changes: 23 additions & 13 deletions TheDialgaTeam.FossilFighters.Tool.Cli/Commands/DecompressCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,19 @@ internal sealed class DecompressCommand : Command
public DecompressCommand() : base("decompress", Localization.DecompressCommandDescription)
{
var inputArgument = new Argument<string[]>("input", "List of folders or files to extract.") { Arity = ArgumentArity.OneOrMore };
var outputOption = new Option<string>(new[] { "--output", "-o" }, () => string.Empty, "Output folder to place the extracted contents.") { Arity = ArgumentArity.ExactlyOne, IsRequired = false };
var excludeOption = new Option<string[]>(new[] { "--exclude", "-e" }, () => new[] { "**/bin/**/*" }, "Exclude files to be decompressed. You can use wildcard (*) to specify one or more folders.") { Arity = ArgumentArity.OneOrMore, IsRequired = false };
var outputOption = new Option<string>(["--output", "-o"], () => string.Empty, "Output folder to place the extracted contents.") { Arity = ArgumentArity.ExactlyOne, IsRequired = false };
var excludeOption = new Option<string[]>(["--exclude", "-e"], () => ["**/bin/**/*"], "Exclude files to be decompressed. You can use wildcard (*) to specify one or more folders.") { Arity = ArgumentArity.OneOrMore, IsRequired = false };
var outputExtra = new Option<bool>(["--extra", "-ex"], () => false, "Include extra files when extracting contents.") { Arity = ArgumentArity.ZeroOrOne, IsRequired = false };

AddArgument(inputArgument);
AddOption(outputOption);
AddOption(excludeOption);
AddOption(outputExtra);

this.SetHandler(Invoke, inputArgument, outputOption, excludeOption);
this.SetHandler(Invoke, inputArgument, outputOption, excludeOption, outputExtra);
}

private static void Invoke(string[] inputs, string output, string[] excludes)
private static void Invoke(string[] inputs, string output, string[] excludes, bool outputExtra)
{
foreach (var input in inputs)
{
Expand All @@ -73,7 +75,7 @@ private static void Invoke(string[] inputs, string output, string[] excludes)

foreach (var file in matcher.GetResultsInFullPath(outputPath))
{
Decompress(file, output);
Decompress(file, output, outputExtra);
}

continue;
Expand Down Expand Up @@ -103,7 +105,7 @@ void ExportFile(NitroRomDirectory targetDirectory, string targetLocation)
}
}

Decompress(input, output);
Decompress(input, output, outputExtra);
}
else if (Directory.Exists(input))
{
Expand All @@ -114,7 +116,7 @@ void ExportFile(NitroRomDirectory targetDirectory, string targetLocation)

foreach (var file in matcher.GetResultsInFullPath(input))
{
Decompress(file, output);
Decompress(file, output, outputExtra);
}
}
else
Expand All @@ -124,7 +126,7 @@ void ExportFile(NitroRomDirectory targetDirectory, string targetLocation)
}
}

private static void Decompress(string input, string output)
private static void Decompress(string input, string output, bool outputExtra)
{
Console.WriteLine(Localization.FileExtracting, input);

Expand Down Expand Up @@ -176,6 +178,8 @@ private static void Decompress(string input, string output)
{
case AclHeader.FileHeader:
{
if (!outputExtra) break;

fileStream.Seek(0, SeekOrigin.Begin);

var header = AclHeader.GetHeaderFromStream(fileStream);
Expand All @@ -188,6 +192,8 @@ private static void Decompress(string input, string output)

case DmsHeader.FileHeader:
{
if (!outputExtra) break;

fileStream.Seek(0, SeekOrigin.Begin);

var header = DmsHeader.GetHeaderFromStream(fileStream);
Expand All @@ -210,7 +216,7 @@ private static void Decompress(string input, string output)

if (!File.Exists(colorPaletteFile))
{
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mmsHeader.ColorPaletteFileName), Path.Combine(output, ".."));
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mmsHeader.ColorPaletteFileName), Path.Combine(output, ".."), outputExtra);
}

using var colorPaletteFileStream = new FileStream(colorPaletteFile, FileMode.Open, FileAccess.Read);
Expand All @@ -229,7 +235,7 @@ private static void Decompress(string input, string output)

if (!File.Exists(bitmapFile))
{
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mmsHeader.BitmapFileName), Path.Combine(output, ".."));
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mmsHeader.BitmapFileName), Path.Combine(output, ".."), outputExtra);
}

using var bitmapFileStream = new FileStream(bitmapFile, FileMode.Open, FileAccess.Read);
Expand Down Expand Up @@ -257,7 +263,7 @@ private static void Decompress(string input, string output)

if (!File.Exists(colorPaletteFile))
{
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mpmHeader.ColorPaletteFileName), Path.Combine(output, ".."));
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mpmHeader.ColorPaletteFileName), Path.Combine(output, ".."), outputExtra);
}

using var colorPaletteFileStream = new FileStream(colorPaletteFile, FileMode.Open, FileAccess.Read);
Expand All @@ -267,7 +273,7 @@ private static void Decompress(string input, string output)

if (!File.Exists(bitmapFile))
{
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mpmHeader.BitmapFileName), Path.Combine(output, ".."));
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mpmHeader.BitmapFileName), Path.Combine(output, ".."), outputExtra);
}

if (mpmHeader.BgMapFileIndex == 0)
Expand All @@ -287,7 +293,7 @@ private static void Decompress(string input, string output)

if (!File.Exists(bitmapFile))
{
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mpmHeader.BgMapFileName), Path.Combine(output, ".."));
Decompress(Path.Combine(Path.GetDirectoryName(input)!, mpmHeader.BgMapFileName), Path.Combine(output, ".."), outputExtra);
}

using var bitmapFileStream = new FileStream(bitmapFile, FileMode.Open, FileAccess.Read);
Expand All @@ -313,6 +319,8 @@ private static void Decompress(string input, string output)

case DtxFile.FileHeader:
{
if (!outputExtra) break;

fileStream.Seek(0, SeekOrigin.Begin);

var dtxFile = DtxFile.ReadFromRawStream(fileStream);
Expand All @@ -328,6 +336,8 @@ private static void Decompress(string input, string output)

case DmgFile.FileHeader:
{
if (!outputExtra) break;

fileStream.Seek(0, SeekOrigin.Begin);

var dmgFile = DmgFile.ReadFromRawStream(fileStream);
Expand Down
7 changes: 1 addition & 6 deletions TheDialgaTeam.FossilFighters.Tool.Gui/Models/NitroRomNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Avalonia.Platform.Storage;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;
Expand All @@ -32,7 +27,7 @@ namespace TheDialgaTeam.FossilFighters.Tool.Gui.Models;

public sealed class NitroRomNode : ReactiveObject
{
public ObservableCollection<NitroRomNode> ChildNodes { get; } = new();
public ObservableCollection<NitroRomNode> ChildNodes { get; } = [];

public string Name => _nitroRom.Name;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.11" />
<PackageReference Include="Avalonia" Version="11.1.3" />
<PackageReference Include="Avalonia.Controls.TreeDataGrid" Version="11.0.10" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.11" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.11" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.11" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.11" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.11" />
<PackageReference Include="Avalonia.Desktop" Version="11.1.3" />
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.1.3" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.1.3" />
<PackageReference Include="Avalonia.ReactiveUI" Version="11.1.3" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.1.3" />
<PackageReference Include="ReactiveMarbles.ObservableEvents.SourceGenerator" Version="1.3.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Fossil Fighters Tool is used to decompress and compress MAR archives used in Fossil Fighters game.
// Copyright (C) 2023 Yong Jian Ming
// Copyright (C) 2024 Yong Jian Ming
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand All @@ -14,15 +14,11 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Reactive;
using System.Reactive.Linq;
using System.Text.Json;
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Controls.Models.TreeDataGrid;
using Avalonia.Controls.Selection;
Expand Down Expand Up @@ -72,7 +68,10 @@ public sealed class MainWindowViewModel : ViewModel

public HierarchicalTreeDataGridSource<NitroRomNode> NitroRomNodeSource { get; }

private readonly ObservableCollection<NitroRomNode> _nitroRomNodes = new();
private static readonly string[] s_nintendoRomPatterns = ["*.nds"];
private static readonly string[] s_nintendoRomMimeTypes = ["application/x-nintendo-ds-rom"];

private readonly ObservableCollection<NitroRomNode> _nitroRomNodes = [];

[Reactive]
private NdsFilesystem? LoadedRom { get; set; }
Expand Down Expand Up @@ -132,8 +131,8 @@ private async Task OpenFileImplementation()
{
new FilePickerFileType("Nintendo DS ROM")
{
Patterns = new[] { "*.nds" },
MimeTypes = new[] { "application/x-nintendo-ds-rom" }
Patterns = s_nintendoRomPatterns,
MimeTypes = s_nintendoRomMimeTypes
}
}
});
Expand Down Expand Up @@ -177,8 +176,8 @@ private async Task SaveFileImplementation()
{
new FilePickerFileType("Nintendo DS ROM")
{
Patterns = new[] { "*.nds" },
MimeTypes = new[] { "application/x-nintendo-ds-rom" }
Patterns = s_nintendoRomPatterns,
MimeTypes = s_nintendoRomMimeTypes
}
},
ShowOverwritePrompt = true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

using System;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Threading;
using ReactiveUI;
using ReactiveUI.Fody.Helpers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@

namespace TheDialgaTeam.FossilFighters.Tool.Gui.ViewModels;

public abstract class ViewModel : ReactiveObject
{
}
public abstract class ViewModel : ReactiveObject;

public abstract class ActivatableViewModel : ViewModel, IActivatableViewModel
{
Expand Down
2 changes: 1 addition & 1 deletion TheDialgaTeam.FossilFighters.prop
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

<Version>2.3.0</Version>
<Version>2.2.0</Version>
<Authors>Yong Jian Ming</Authors>
<PackageProjectUrl>https://github.com/jianmingyong/Fossil-Fighters-Tool</PackageProjectUrl>
<RepositoryUrl>https://github.com/jianmingyong/Fossil-Fighters-Tool</RepositoryUrl>
Expand Down

0 comments on commit 9fc543e

Please sign in to comment.