Skip to content

Commit

Permalink
Rename ObjectPlacement to SetData
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperbx committed Aug 11, 2024
1 parent cf4006b commit f74b0e6
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 63 deletions.
6 changes: 3 additions & 3 deletions Marathon.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using Marathon.Formats.Audio;
using Marathon.Formats.Event;
using Marathon.Formats.Mesh;
using Marathon.Formats.Object;
using Marathon.Formats.Package;
using Marathon.Formats.Particle;
using Marathon.Formats.Placement;
using Marathon.Formats.Save;
using Marathon.Formats.Script;
using Marathon.Formats.Script.Lua;
Expand Down Expand Up @@ -210,12 +210,12 @@ static void Main(string[] args)

case ".set":
case ".set.json":
ObjectPlacement set = new(arg, true, !args.Contains("--no-index"));
SetData set = new(arg, true, !args.Contains("--no-index"));
break;

case ".prop":
case ".prop.json":
ObjectPropertyDatabase prop = new(arg, true);
PropertyDatabase prop = new(arg, true);
break;

case string mstEx when mstEx.EndsWith(".mst"):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
namespace Marathon.Formats.Placement
namespace Marathon.Formats.Object
{
/// <summary>
/// File base for the *.prop format.
/// <para>Used in SONIC THE HEDGEHOG for defining object properties.</para>
/// </summary>
public class ObjectPropertyDatabase : FileBase
public class PropertyDatabase : FileBase
{
public ObjectPropertyDatabase() { }
public PropertyDatabase() { }

public ObjectPropertyDatabase(string file, bool serialise = false)
public PropertyDatabase(string file, bool serialise = false)
{
switch (Path.GetExtension(file))
{
Expand Down Expand Up @@ -84,7 +84,7 @@ public override void Load(Stream stream)
ObjectParameter parameter = new()
{
Name = new string(reader.ReadChars(0x10)).Trim('\0'),
Type = (ObjectDataType)reader.ReadUInt32()
Type = (SetDataType)reader.ReadUInt32()
};

entry.Parameters.Add(parameter);
Expand Down Expand Up @@ -163,11 +163,11 @@ public class ObjectParameter
{
public string Name { get; set; }

public ObjectDataType Type { get; set; }
public SetDataType Type { get; set; }

public ObjectParameter() { }

public ObjectParameter(string in_name, ObjectDataType in_type)
public ObjectParameter(string in_name, SetDataType in_type)
{
Name = in_name;
Type = in_type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
using Marathon.Exceptions;
using Marathon.Helpers;
using Newtonsoft.Json;

namespace Marathon.Formats.Placement
namespace Marathon.Formats.Object
{
/// <summary>
/// File base for the *.set format.
/// <para>Used in SONIC THE HEDGEHOG for object layouts.</para>
/// </summary>
public class ObjectPlacement : FileBase
public class SetData : FileBase
{
public ObjectPlacement() { }
public SetData() { }

public ObjectPlacement(string file, bool serialise = false, bool displayIndex = true)
public SetData(string file, bool serialise = false, bool displayIndex = true)
{
switch (Path.GetExtension(file))
{
Expand Down Expand Up @@ -118,7 +117,7 @@ public override void Load(Stream stream)
for (int p = 0; p < parameterCount; p++)
{
// Read object data type.
ObjectDataType type = (ObjectDataType)reader.ReadUInt32();
SetDataType type = (SetDataType)reader.ReadUInt32();

// Initialise new parameter with the read type.
SetParameter setParameter = new()
Expand All @@ -128,22 +127,22 @@ public override void Load(Stream stream)

switch (type)
{
case ObjectDataType.Boolean:
case SetDataType.Boolean:
setParameter.Data = reader.ReadBoolean(4);
reader.JumpAhead(0x0C);
break;

case ObjectDataType.Int32:
case SetDataType.Int32:
setParameter.Data = reader.ReadInt32();
reader.JumpAhead(0x0C);
break;

case ObjectDataType.Single:
case SetDataType.Single:
setParameter.Data = reader.ReadSingle();
reader.JumpAhead(0x0C);
break;

case ObjectDataType.String:
case SetDataType.String:
{
uint stringOffset = reader.ReadUInt32();

Expand All @@ -165,12 +164,12 @@ public override void Load(Stream stream)
break;
}

case ObjectDataType.Vector3:
case SetDataType.Vector3:
setParameter.Data = reader.ReadVector3();
reader.JumpAhead(0x04);
break;

case ObjectDataType.UInt32:
case SetDataType.UInt32:
setParameter.Data = reader.ReadUInt32();
reader.JumpAhead(0x0C);
break;
Expand Down Expand Up @@ -276,29 +275,29 @@ public override void Save(Stream stream)

for (int p = 0; p < Data.Objects[o].Parameters.Count; p++)
{
ObjectDataType type = Data.Objects[o].Parameters[p].Type;
SetDataType type = Data.Objects[o].Parameters[p].Type;

// Write object data type.
writer.Write((uint)type);

switch (type)
{
case ObjectDataType.Boolean:
case SetDataType.Boolean:
writer.WriteBoolean32((bool)Data.Objects[o].Parameters[p].Data);
writer.WriteNulls(0x0C);
break;

case ObjectDataType.Int32:
case SetDataType.Int32:
writer.Write(Convert.ToInt32(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x0C);
break;

case ObjectDataType.Single:
case SetDataType.Single:
writer.Write(Convert.ToSingle(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x0C);
break;

case ObjectDataType.String:
case SetDataType.String:
{
// If the parameter's string is empty, add an offset to a null entry.
if (string.IsNullOrEmpty(Data.Objects[o].Parameters[p].Data.ToString()))
Expand All @@ -317,12 +316,12 @@ public override void Save(Stream stream)
break;
}

case ObjectDataType.Vector3:
case SetDataType.Vector3:
writer.Write(VectorHelper.ParseVector3(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x04);
break;

case ObjectDataType.UInt32:
case SetDataType.UInt32:
writer.Write(Convert.ToUInt32(Data.Objects[o].Parameters[p].Data));
writer.WriteNulls(0x0C);
break;
Expand Down Expand Up @@ -378,7 +377,7 @@ associated with it (because that can happen apparently) */

for (int p = 0; p < Data.Objects[o].Parameters.Count; p++)
{
if (Data.Objects[o].Parameters[p].Type == ObjectDataType.String)
if (Data.Objects[o].Parameters[p].Type == SetDataType.String)
{
if (string.IsNullOrEmpty(Data.Objects[o].Parameters[p].Data.ToString()))
{
Expand Down Expand Up @@ -469,11 +468,11 @@ public class SetParameter
/// <summary>
/// The data type for <see cref="Data"/>.
/// </summary>
public ObjectDataType Type { get; set; }
public SetDataType Type { get; set; }

public SetParameter() { }

public SetParameter(object in_data, ObjectDataType in_type)
public SetParameter(object in_data, SetDataType in_type)
{
Data = in_data;
Type = in_type;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
namespace Marathon.Formats.Placement
namespace Marathon.Formats.Object
{
[JsonConverter(typeof(StringEnumConverter))]
public enum ObjectDataType
public enum SetDataType
{
Boolean,
Int32,
Expand Down
58 changes: 29 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<br>

<p align="center">
<img src="https://raw.githubusercontent.com/Big-Endian-32/Marathon/master/Marathon.Shared/Resources/Images/Logos/Marathon.png" width="238" height="178"/>
<img src="https://raw.githubusercontent.com/hyperbx/Marathon/master/Marathon.Shared/Resources/Images/Logos/Marathon.png" width="238" height="178"/>
</p>

<h1 align="center">Marathon</h1>
Expand All @@ -13,50 +13,50 @@
# Releases

### GitHub Releases
This is where [stable builds](https://github.com/Big-Endian-32/Marathon/releases) of Marathon are published; if you're looking for the most reliable experience.
This is where [stable builds](https://github.com/hyperbx/Marathon/releases) of Marathon are published; if you're looking for the most reliable experience.

### GitHub Actions
While it can be fun to live on the bleeding edge, [GitHub Actions](https://github.com/Big-Endian-32/Marathon/actions) publishes new builds for each new commit, so changes can be unstable.
While it can be fun to live on the bleeding edge, [GitHub Actions](https://github.com/hyperbx/Marathon/actions) publishes new builds for each new commit, so changes can be unstable.

# Building
See the [Building](https://github.com/Big-Endian-32/Marathon/wiki/Building) page on the wiki.
See the [Building](https://github.com/hyperbx/Marathon/wiki/Building) page on the wiki.

# Capabilities

- Archive
- [U8 Archive (`*.arc`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Archive/U8Archive.cs) reading and writing
- [U8 Archive (`*.arc`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Archive/U8Archive.cs) reading and writing
- Audio
- [Sound Bank (`*.sbk`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Audio/SoundBank.cs) reading and writing
- [Sound Bank (`*.sbk`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Audio/SoundBank.cs) reading and writing
- Event
- [Event Playbook (`*.epb`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Event/EventPlaybook.cs) reading and writing
- [Time Event (`*.tev`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Event/TimeEvent.cs) reading and writing
- [Event Playbook (`*.epb`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Event/EventPlaybook.cs) reading and writing
- [Time Event (`*.tev`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Event/TimeEvent.cs) reading and writing
- Mesh
- [Collision (`collision.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Mesh/Collision.cs) reading and writing
- [Ninja (`*.xna; *.xnd; *.xne; *.xnf; *.xng; *.xni; *.xnm; *.xno; *.xnv`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Mesh/Ninja/NinjaNext.cs) reading and writing
- [Path Spline (`*.path`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Mesh/PathSpline.cs) reading and writing
- [Reflection Zone (`*.rab`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Mesh/ReflectionZone.cs) reading and writing
- [Collision (`collision.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Mesh/Collision.cs) reading and writing
- [Ninja (`*.xna; *.xnd; *.xne; *.xnf; *.xng; *.xni; *.xnm; *.xno; *.xnv`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Mesh/Ninja/NinjaNext.cs) reading and writing
- [Path Spline (`*.path`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Mesh/PathSpline.cs) reading and writing
- [Reflection Zone (`*.rab`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Mesh/ReflectionZone.cs) reading and writing
- Object
- [Set Data (`*.set`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Object/SetData.cs) reading and writing
- [Property Database (`*.prop`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Object/PropertyDatabase.cs) reading and writing
- Package
- [Asset Package (`*.pkg`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Package/AssetPackage.cs) reading and writing
- [Common Package (`Common.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Package/CommonPackage.cs) reading and writing
- [Explosion Package (`Explosion.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Package/ExplosionPackage.cs) reading and writing
- [Path Package (`PathObj.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Package/PathPackage.cs) reading and writing
- [Script Package (`ScriptParameter.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Package/ScriptPackage.cs) reading and writing
- [Shot Package (`ShotParameter.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Package/ShotPackage.cs) reading and writing
- [Asset Package (`*.pkg`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Package/AssetPackage.cs) reading and writing
- [Common Package (`Common.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Package/CommonPackage.cs) reading and writing
- [Explosion Package (`Explosion.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Package/ExplosionPackage.cs) reading and writing
- [Path Package (`PathObj.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Package/PathPackage.cs) reading and writing
- [Script Package (`ScriptParameter.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Package/ScriptPackage.cs) reading and writing
- [Shot Package (`ShotParameter.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Package/ShotPackage.cs) reading and writing
- Particle
- [Particle Container (`*.plc`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Particle/ParticleContainer.cs) reading and writing
- [Particle Effect Bank (`*.peb`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Particle/ParticleEffectBank.cs) reading and writing
- [Particle Generation System (`*.pgs`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Particle/ParticleGenerationSystem.cs) reading and writing
- [Particle Texture Bank (`*.ptb`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Particle/ParticleTextureBank.cs) reading and writing
- Placement
- [Object Placement (`*.set`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Placement/ObjectPlacement.cs) reading and writing
- [Object Property Database (`*.prop`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Placement/ObjectPropertyDatabase.cs) reading and writing
- [Particle Container (`*.plc`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Particle/ParticleContainer.cs) reading and writing
- [Particle Effect Bank (`*.peb`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Particle/ParticleEffectBank.cs) reading and writing
- [Particle Generation System (`*.pgs`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Particle/ParticleGenerationSystem.cs) reading and writing
- [Particle Texture Bank (`*.ptb`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Particle/ParticleTextureBank.cs) reading and writing
- Save
- [Save Data (`SonicNextSaveData.bin`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Save/SonicNextSaveData.cs) reading and writing
- [Save Data (`SonicNextSaveData.bin`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Save/SonicNextSaveData.cs) reading and writing
- Script
- [Lua Binary (`*.lub`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Script/Lua/LuaBinary.cs) reading and writing
- [Lua Binary (`*.lub`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Script/Lua/LuaBinary.cs) reading and writing
- Text
- [Message Table (`*.mst`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Text/MessageTable.cs) reading and writing
- [Picture Font (`*.pft`)](https://github.com/Big-Endian-32/Marathon/blob/master/Marathon/Formats/Text/PictureFont.cs) reading and writing
- [Message Table (`*.mst`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Text/MessageTable.cs) reading and writing
- [Picture Font (`*.pft`)](https://github.com/hyperbx/Marathon/blob/master/Marathon/Formats/Text/PictureFont.cs) reading and writing

# Unsupported

Expand Down

0 comments on commit f74b0e6

Please sign in to comment.