Skip to content

Commit

Permalink
use inheritdoc on models pt4
Browse files Browse the repository at this point in the history
  • Loading branch information
Miepee committed May 12, 2022
1 parent 5d8bc34 commit 1bdfd99
Show file tree
Hide file tree
Showing 8 changed files with 149 additions and 56 deletions.
16 changes: 8 additions & 8 deletions UndertaleModLib/Models/UndertaleAnimationCurve.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UndertaleModLib.Models
namespace UndertaleModLib.Models
{
/// <summary>
/// An animation curve entry in a data file.
Expand All @@ -32,6 +25,7 @@ public enum GraphTypeEnum : uint

public UndertaleSimpleList<Channel> Channels { get; set; }

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
Serialize(writer, true);
Expand All @@ -50,6 +44,7 @@ public void Serialize(UndertaleWriter writer, bool includeName)
Channels.Serialize(writer);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Unserialize(reader, true);
Expand All @@ -68,6 +63,7 @@ public void Unserialize(UndertaleReader reader, bool includeName)
Channels = reader.ReadUndertaleObject<UndertaleSimpleList<Channel>>();
}

/// <inheritdoc />
public override string ToString()
{
return Name.Content;
Expand All @@ -87,6 +83,7 @@ public enum FunctionType : uint
public uint Iterations { get; set; }
public UndertaleSimpleList<Point> Points { get; set; }

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(Name);
Expand All @@ -95,6 +92,7 @@ public void Serialize(UndertaleWriter writer)
Points.Serialize(writer);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Name = reader.ReadUndertaleString();
Expand All @@ -113,6 +111,7 @@ public class Point : UndertaleObject
public float BezierX1;
public float BezierY1;

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.Write(X);
Expand All @@ -129,6 +128,7 @@ public void Serialize(UndertaleWriter writer)
writer.Write(0);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
X = reader.ReadSingle();
Expand Down
12 changes: 9 additions & 3 deletions UndertaleModLib/Models/UndertaleCode.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using UndertaleModLib.Compiler;
using UndertaleModLib.Decompiler;
using UndertaleModLib.Models;

namespace UndertaleModLib.Models
{
Expand Down Expand Up @@ -220,19 +217,22 @@ public Reference(int int32Value)
Type = (VariableType)(int32Value >> 24);
}

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
NextOccurrenceOffset = 0xdead;
writer.WriteUInt24(NextOccurrenceOffset);
writer.Write((byte)Type);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
NextOccurrenceOffset = reader.ReadUInt24();
Type = (VariableType)reader.ReadByte();
}

/// <inheritdoc />
public override string ToString()
{
if (typeof(T) == typeof(UndertaleVariable) && Type != VariableType.Normal)
Expand Down Expand Up @@ -333,6 +333,7 @@ public Reference<T> GetReference<T>(bool allowResolve = false) where T : class,
return res;
}

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
switch (GetInstructionType(Kind))
Expand Down Expand Up @@ -532,6 +533,7 @@ public void Serialize(UndertaleWriter writer)
}
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
uint instructionStartAddress = reader.Position;
Expand Down Expand Up @@ -801,6 +803,7 @@ public void Unserialize(UndertaleReader reader)
}
}

/// <inheritdoc />
public override string ToString()
{
return ToString(null);
Expand Down Expand Up @@ -1040,6 +1043,7 @@ public void SerializeBlobBefore(UndertaleWriter writer)
}
}

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(Name);
Expand Down Expand Up @@ -1074,6 +1078,7 @@ public void Serialize(UndertaleWriter writer)

}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Name = reader.ReadUndertaleString();
Expand Down Expand Up @@ -1271,6 +1276,7 @@ public void ReplaceGML(string gmlCode, UndertaleData data)
}
}

/// <inheritdoc />
public override string ToString()
{
return Name.Content + " (" + GetType().Name + ")";
Expand Down
21 changes: 13 additions & 8 deletions UndertaleModLib/Models/UndertaleExtension.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace UndertaleModLib.Models
{
Expand Down Expand Up @@ -40,11 +34,13 @@ public UndertaleExtensionFunctionArg(UndertaleExtensionVarType type)
Type = type;
}

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.Write((uint)Type);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Type = (UndertaleExtensionVarType)reader.ReadUInt32();
Expand All @@ -55,12 +51,13 @@ public void Unserialize(UndertaleReader reader)
public class UndertaleExtensionFunction : UndertaleObject
{
public UndertaleString Name { get; set; }
public uint ID { get; set; }
public uint ID { get; set; }
public uint Kind { get; set; }
public UndertaleExtensionVarType RetType { get; set; }
public UndertaleString ExtName { get; set; }
public UndertaleSimpleList<UndertaleExtensionFunctionArg> Arguments { get; set; } = new UndertaleSimpleList<UndertaleExtensionFunctionArg>();

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(Name);
Expand All @@ -71,6 +68,7 @@ public void Serialize(UndertaleWriter writer)
writer.WriteUndertaleObject(Arguments);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Name = reader.ReadUndertaleString();
Expand All @@ -81,6 +79,7 @@ public void Unserialize(UndertaleReader reader)
Arguments = reader.ReadUndertaleObject<UndertaleSimpleList<UndertaleExtensionFunctionArg>>();
}

/// <inheritdoc />
public override string ToString()
{
return Name.Content + " (" + ExtName.Content + ")";
Expand All @@ -96,6 +95,7 @@ public class UndertaleExtensionFile : UndertaleObject
public UndertaleExtensionKind Kind { get; set; }
public UndertalePointerList<UndertaleExtensionFunction> Functions { get; set; } = new UndertalePointerList<UndertaleExtensionFunction>();

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(Filename);
Expand All @@ -105,6 +105,7 @@ public void Serialize(UndertaleWriter writer)
writer.WriteUndertaleObject(Functions);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Filename = reader.ReadUndertaleString();
Expand All @@ -114,6 +115,7 @@ public void Unserialize(UndertaleReader reader)
Functions = reader.ReadUndertaleObject<UndertalePointerList<UndertaleExtensionFunction>>();
}

/// <inheritdoc />
public override string ToString()
{
try
Expand All @@ -132,18 +134,20 @@ public class UndertaleExtension : UndertaleNamedResource
{
// Folder Name thing is a remnant from the legacy GM7-8.1 extension editor(aka ExtMaker).
// The runner reads the name but ignores it.
// Though you probably shouldn't change it anyways.
// Though you probably shouldn't change it anyways.
public UndertaleString FolderName { get; set; }
public UndertaleString Name { get; set; }
public UndertaleString ClassName { get; set; }

public UndertalePointerList<UndertaleExtensionFile> Files { get; set; } = new UndertalePointerList<UndertaleExtensionFile>();

/// <inheritdoc />
public override string ToString()
{
return Name.Content + " (" + GetType().Name + ")";
}

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(FolderName);
Expand All @@ -152,6 +156,7 @@ public void Serialize(UndertaleWriter writer)
writer.WriteUndertaleObject(Files);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
FolderName = reader.ReadUndertaleString();
Expand Down
16 changes: 9 additions & 7 deletions UndertaleModLib/Models/UndertaleFunction.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static UndertaleModLib.Models.UndertaleGeneralInfo;

namespace UndertaleModLib.Models
Expand All @@ -26,6 +20,7 @@ public class UndertaleFunction : UndertaleNamedResource, UndertaleInstruction.Re
[Obsolete("This variable has been renamed to NameStringID.")]
public int UnknownChainEndingValue { get => NameStringID; set => NameStringID = value; }

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(Name);
Expand All @@ -42,6 +37,7 @@ public void Serialize(UndertaleWriter writer)
writer.Write((int)-1);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Name = reader.ReadUndertaleString();
Expand All @@ -62,6 +58,7 @@ public void Unserialize(UndertaleReader reader)
}
}

/// <inheritdoc />
public override string ToString()
{
return Name.Content;
Expand All @@ -76,6 +73,7 @@ public class UndertaleCodeLocals : UndertaleNamedResource
public UndertaleString Name { get; set; }
public ObservableCollection<LocalVar> Locals { get; } = new ObservableCollection<LocalVar>();

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.Write((uint)Locals.Count);
Expand All @@ -86,6 +84,7 @@ public void Serialize(UndertaleWriter writer)
}
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
uint count = reader.ReadUInt32();
Expand All @@ -102,26 +101,29 @@ public bool HasLocal(string varName)
{
return Locals.Any(local=>local.Name.Content == varName);
}

// TODO: INotifyPropertyChanged
public class LocalVar : UndertaleObject
{
public uint Index { get; set; }
public UndertaleString Name { get; set; }

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.Write(Index);
writer.WriteUndertaleString(Name);
}

/// <inheritdoc />
public void Unserialize(UndertaleReader reader)
{
Index = reader.ReadUInt32();
Name = reader.ReadUndertaleString();
}
}

/// <inheritdoc />
public override string ToString()
{
return Name.Content + " (" + GetType().Name + ")";
Expand Down
Loading

0 comments on commit 1bdfd99

Please sign in to comment.