Skip to content

Commit 0ce105c

Browse files
chore: add Resource prefix to the RIFF resource types
1 parent 668cdaf commit 0ce105c

38 files changed

+125
-125
lines changed

Shockky.Sandbox/Program.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ static void HandleExtractCommand(IEnumerable<System.IO.FileInfo> input, Director
102102
var shockwaveFile = ShockwaveFile.Read(file.FullName);
103103

104104
if (shockwaveFile.Resources.Values
105-
.FirstOrDefault(c => c.Kind == OsType.KEYPtr) is not KeyMap associationTable)
105+
.FirstOrDefault(c => c.Kind == OsType.KEYPtr) is not KeyMapResource associationTable)
106106
{
107-
Console.WriteLine(nameof(KeyMap) + " was not found!");
107+
Console.WriteLine(nameof(KeyMapResource) + " was not found!");
108108
continue;
109109
}
110110
if (shockwaveFile.Resources.Values
111-
.FirstOrDefault(c => c.Kind == OsType.CASPtr) is not CastMap castAssociationTable)
111+
.FirstOrDefault(c => c.Kind == OsType.CASPtr) is not CastMapResource castAssociationTable)
112112
{
113-
Console.WriteLine(nameof(CastMap) + " was not found!");
113+
Console.WriteLine(nameof(CastMapResource) + " was not found!");
114114
continue;
115115
}
116116
Console.Write("Extracting bitmaps..");
@@ -120,8 +120,8 @@ static void HandleExtractCommand(IEnumerable<System.IO.FileInfo> input, Director
120120
{
121121
if (resourceId.Kind != OsType.BITD) continue;
122122

123-
var member = shockwaveFile.Resources[resourceId.Id] as CastMemberProperties;
124-
var bitmapData = shockwaveFile.Resources[index] as BitmapData;
123+
var member = shockwaveFile.Resources[resourceId.Id] as CastMemberPropertiesResource;
124+
var bitmapData = shockwaveFile.Resources[index] as BitmapDataResource;
125125

126126
if (member?.Properties is not BitmapCastProperties bitmapProperties)
127127
continue;
@@ -169,7 +169,7 @@ static void HandleExtractCommand(IEnumerable<System.IO.FileInfo> input, Director
169169

170170
static bool TryExtractBitmapResource(string outputFilePath,
171171
BitmapCastProperties properties,
172-
BitmapData bitmapData,
172+
BitmapDataResource bitmapData,
173173
System.Drawing.Color[] palette)
174174
{
175175
static int CalcStride(int width, int bitdepth)

Shockky.SourceGeneration/Helpers/HashCode.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ private void Add(int value)
134134
/// Gets the resulting hashcode from the current instance.
135135
/// </summary>
136136
/// <returns>The resulting hashcode from the current instance.</returns>
137-
public int ToHashCode()
137+
public readonly int ToHashCode()
138138
{
139139
uint length = _length;
140140
uint position = length % 4;
@@ -165,12 +165,12 @@ public int ToHashCode()
165165
/// <inheritdoc/>
166166
[Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes. Use ToHashCode to retrieve the computed hash code.", error: true)]
167167
[EditorBrowsable(EditorBrowsableState.Never)]
168-
public override int GetHashCode() => throw new NotSupportedException();
168+
public override readonly int GetHashCode() => throw new NotSupportedException();
169169

170170
/// <inheritdoc/>
171171
[Obsolete("HashCode is a mutable struct and should not be compared with other HashCodes.", error: true)]
172172
[EditorBrowsable(EditorBrowsableState.Never)]
173-
public override bool Equals(object? obj) => throw new NotSupportedException();
173+
public override readonly bool Equals(object? obj) => throw new NotSupportedException();
174174

175175
/// <summary>
176176
/// Rotates the specified value left by the specified number of bits.

Shockky.SourceGeneration/Helpers/IndentedTextWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,13 @@ private void WriteRawText(ReadOnlySpan<char> content)
355355
/// <summary>
356356
/// Represents an indented block that needs to be closed.
357357
/// </summary>
358-
/// <param name="_writer">The input <see cref="IndentedTextWriter"/> instance to wrap.</param>
359-
public readonly struct Block(IndentedTextWriter _writer, bool isExpression = false) : IDisposable
358+
/// <param name="writer">The input <see cref="IndentedTextWriter"/> instance to wrap.</param>
359+
public readonly struct Block(IndentedTextWriter writer, bool isExpression = false) : IDisposable
360360
{
361361
/// <summary>
362362
/// The <see cref="IndentedTextWriter"/> instance to write to.
363363
/// </summary>
364-
private readonly IndentedTextWriter? _writer = _writer;
364+
private readonly IndentedTextWriter? _writer = writer;
365365

366366
/// <summary>
367367
/// Indicates whether the indented block is an expression and requires a semicolon to close the block.

Shockky/IRiff.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ namespace Shockky;
55

66
public interface IRiff
77
{
8-
MemoryMap MemoryMap { get; }
8+
MemoryMapResource MemoryMap { get; }
99
IDictionary<ResourceId, int> ResourceMap { get; }
1010
}

Shockky/Lingo/LingoLiteral.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ public void WriteTo(ShockwaveWriter output, WriterOptions options)
3737
throw new NotImplementedException();
3838
}
3939

40-
public bool Equals(LingoLiteral literal)
41-
=> literal.Kind == Kind && literal.Value == Value;
40+
public bool Equals(LingoLiteral? literal)
41+
=> literal is not null && literal.Kind == Kind && literal.Value == Value;
4242

43-
public override bool Equals(object obj) => Equals(obj as LingoLiteral);
43+
public override bool Equals(object? obj) => Equals(obj as LingoLiteral);
4444

4545
public static LingoLiteral Read(ref ShockwaveReader input, VariantKind entryKind, int entryOffset)
4646
{

Shockky/Resources/AfterBurner/AfterburnerMapEntry.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public sealed class AfterburnerMapEntry : IShockwaveItem
1414
public int DecompressedLength { get; set; }
1515

1616
/// <summary>
17-
/// Represents an index in <see cref="FileCompressionTypes.CompressionTypes"/> array.
17+
/// Represents an index in <see cref="FileCompressionTypesResource.CompressionTypes"/> array.
1818
/// </summary>
1919
public int CompressionTypeIndex { get; set; }
2020

Shockky/Resources/AfterBurner/AfterburnerMap.cs renamed to Shockky/Resources/AfterBurner/AfterburnerMapResource.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Shockky.Resources;
44

5-
public sealed class AfterburnerMap : IShockwaveItem, IResource
5+
public sealed class AfterburnerMapResource : IShockwaveItem, IResource
66
{
77
public OsType Kind => OsType.ABMP;
88

@@ -11,7 +11,7 @@ public sealed class AfterburnerMap : IShockwaveItem, IResource
1111
public int LastIndex { get; set; }
1212
public Dictionary<int, AfterburnerMapEntry> Entries { get; set; }
1313

14-
public AfterburnerMap(ref ShockwaveReader input, ReaderContext context)
14+
public AfterburnerMapResource(ref ShockwaveReader input, ReaderContext context)
1515
{
1616
input.ReadByte();
1717
Unknown = input.Read7BitEncodedInt();

Shockky/Resources/AfterBurner/FileCompressionTypes.cs renamed to Shockky/Resources/AfterBurner/FileCompressionTypesResource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
namespace Shockky.Resources;
44

5-
public sealed class FileCompressionTypes : IShockwaveItem, IResource
5+
public sealed class FileCompressionTypesResource : IShockwaveItem, IResource
66
{
77
public OsType Kind => OsType.Fcdr;
88

99
public (Guid Id, string Description)[] CompressionTypes { get; set; }
1010

11-
public FileCompressionTypes()
11+
public FileCompressionTypesResource()
1212
{ }
13-
public FileCompressionTypes(ref ShockwaveReader input, ReaderContext context)
13+
public FileCompressionTypesResource(ref ShockwaveReader input, ReaderContext context)
1414
{
1515
using ZLibShockwaveReader decompressedInput = ZLib.CreateDeflateReaderUnsafe(ref input);
1616

Shockky/Resources/AfterBurner/FileGzipEmbeddedImage.cs renamed to Shockky/Resources/AfterBurner/FileGzipEmbeddedImageResource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
namespace Shockky.Resources;
44

55
// Contains logic to read embedded Zlib compressed resources from the FGEI resource
6-
public static class FileGzipEmbeddedImage
6+
public static class FileGzipEmbeddedImageResource
77
{
88
// TODO: Tidy up more.
99
public static IDictionary<int, IResource> ReadResources(
1010
ref ShockwaveReader input, ReaderContext context,
11-
AfterburnerMap afterburnerMap, FileCompressionTypes compressionTypes)
11+
AfterburnerMapResource afterburnerMap, FileCompressionTypesResource compressionTypes)
1212
{
1313
int chunkStart = input.Position;
1414
var resources = new Dictionary<int, IResource>(afterburnerMap.Entries.Count);
@@ -33,7 +33,7 @@ public static IDictionary<int, IResource> ReadResources(
3333

3434
private static bool TryReadInitialLoadSegment(
3535
ref ShockwaveReader input, ReaderContext context,
36-
AfterburnerMap afterburnerMap, Dictionary<int, IResource> resources)
36+
AfterburnerMapResource afterburnerMap, Dictionary<int, IResource> resources)
3737
{
3838
// First entry in the AfterburnerMap must be ILS.
3939
AfterburnerMapEntry ilsEntry = afterburnerMap.Entries.First().Value;

Shockky/Resources/AfterBurner/FileVersion.cs renamed to Shockky/Resources/AfterBurner/FileVersionResource.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
namespace Shockky.Resources;
44

5-
public sealed class FileVersion : IResource, IShockwaveItem
5+
public sealed class FileVersionResource : IResource, IShockwaveItem
66
{
77
public OsType Kind => OsType.Fver;
88

99
public DirectorVersion Version { get; set; }
1010
public string VersionString { get; set; }
1111

12-
public FileVersion(scoped ref ShockwaveReader input, ReaderContext context)
12+
public FileVersionResource(scoped ref ShockwaveReader input, ReaderContext context)
1313
{
1414
int versionMaybeTooForgot = input.Read7BitEncodedInt();
1515
if (versionMaybeTooForgot < 0x401) return;
@@ -29,5 +29,5 @@ public void WriteTo(ShockwaveWriter output, WriterOptions options)
2929
throw new NotImplementedException();
3030
}
3131

32-
public static FileVersion Read(ref ShockwaveReader input, ReaderContext context) => new FileVersion(ref input, context);
32+
public static FileVersionResource Read(ref ShockwaveReader input, ReaderContext context) => new FileVersionResource(ref input, context);
3333
}

0 commit comments

Comments
 (0)