Skip to content

Commit

Permalink
Merge pull request #1511 from Miepee/doc
Browse files Browse the repository at this point in the history
Add more documentation params
  • Loading branch information
colinator27 authored Nov 11, 2023
2 parents acdc440 + ed2e6c0 commit 9922aea
Show file tree
Hide file tree
Showing 12 changed files with 205 additions and 57 deletions.
84 changes: 73 additions & 11 deletions UndertaleModLib/Models/UndertaleAnimationCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,23 @@
namespace UndertaleModLib.Models;

/// <summary>
/// An animation curve entry in a data file.
/// An animation curve entry in a data file. These were introduced in GameMaker 2.3.0
/// </summary>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleAnimationCurve : UndertaleNamedResource, IDisposable
{
/// <summary>
/// TODO: unknown
/// </summary>
public enum GraphTypeEnum : uint
{
/// <summary>
/// Unknown
/// </summary>
Unknown0 = 0,
/// <summary>
/// Unknown
/// </summary>
Unknown1 = 1
}

Expand All @@ -23,8 +32,10 @@ public enum GraphTypeEnum : uint
/// The graph type of this animation curve.
/// </summary>
public GraphTypeEnum GraphType { get; set; }



/// <summary>
/// The channels this animation curve has.
/// </summary>
public UndertaleSimpleList<Channel> Channels { get; set; }

/// <inheritdoc />
Expand Down Expand Up @@ -99,30 +110,56 @@ public void Dispose()
{
foreach (Channel channel in Channels)
channel?.Dispose();
}
}
Name = null;
Channels = null;
}


/// <summary>
/// A channel in an animation curve.
/// </summary>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class Channel : UndertaleObject, IDisposable
public class Channel : UndertaleNamedResource, IDisposable
{
public enum FunctionType : uint
/// <summary>
/// The curve type determines how points flow to each other in a channel.
/// </summary>
public enum CurveType : uint
{
/// <summary>
/// Creates a linear progression between points.
/// </summary>
Linear = 0,
/// <summary>
/// Creates a smooth progression between points using catmull-rom interpolation.
/// </summary>
Smooth = 1
// TODO: What about bezier?
}

/// <inheritdoc />
public UndertaleString Name { get; set; }
public FunctionType Function { get; set; }

/// <summary>
/// The curve type this channel uses.
/// </summary>
public CurveType Curve { get; set; }

/// <summary>
/// TODO: document this
/// </summary>
public uint Iterations { get; set; }

/// <summary>
/// The points
/// </summary>
public UndertaleSimpleList<Point> Points { get; set; }

/// <inheritdoc />
public void Serialize(UndertaleWriter writer)
{
writer.WriteUndertaleString(Name);
writer.Write((uint)Function);
writer.Write((uint)Curve);
writer.Write(Iterations);
Points.Serialize(writer);
}
Expand All @@ -131,7 +168,7 @@ public void Serialize(UndertaleWriter writer)
public void Unserialize(UndertaleReader reader)
{
Name = reader.ReadUndertaleString();
Function = (FunctionType)reader.ReadUInt32();
Curve = (CurveType)reader.ReadUInt32();
Iterations = reader.ReadUInt32();
Points = reader.ReadUndertaleObject<UndertaleSimpleList<Point>>();
}
Expand Down Expand Up @@ -160,14 +197,39 @@ public void Dispose()
Points = null;
}

/// <summary>
/// A point which can exist on a <see cref="Channel"/>.
/// </summary>
public class Point : UndertaleObject
{
/// <summary>
/// The X coordinate of this point. GameMaker abbreviates this to "h".
/// </summary>
public float X;

/// <summary>
/// The Y coordinate of this point. GameMaker abbreviates this to "v".
/// </summary>
public float Value;

public float BezierX0; // Bezier only
/// <summary>
/// The Y position for the first bezier handle. Only used if the Channel is set to Bezier.
/// </summary>
public float BezierX0;

/// <summary>
/// The Y position for the first bezier handle. Only used if the Channel is set to Bezier.
/// </summary>
public float BezierY0;

/// <summary>
/// The X position for the second bezier handle. Only used if the Channel is set to Bezier.
/// </summary>
public float BezierX1;

/// <summary>
/// The Y position for the second bezier handle. Only used if the Channel is set to Bezier.
/// </summary>
public float BezierY1;

/// <inheritdoc />
Expand Down
4 changes: 4 additions & 0 deletions UndertaleModLib/Models/UndertaleEmbeddedTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,10 @@ public int Height

/// <inheritdoc />
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// Invoked whenever the effective value of any dependency property has been updated.
/// </summary>
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
Expand Down
74 changes: 71 additions & 3 deletions UndertaleModLib/Models/UndertaleExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,20 @@ public class UndertaleExtensionFunction : UndertaleObject, IDisposable
/// An identification number of the function.
/// </summary>
public uint ID { get; set; }

/// <summary>
/// TODO: is this kind the same as extension kind?
/// </summary>
public uint Kind { get; set; }

/// <summary>
/// The return type of the function.
/// </summary>
public UndertaleExtensionVarType RetType { get; set; }

/// <summary>
/// TODO: The extension of the filename this function belongs to?
/// </summary>
public UndertaleString ExtName { get; set; }

/// <summary>
Expand Down Expand Up @@ -168,13 +176,35 @@ public void Dispose()
}
}

/// <summary>
/// A file that's used in an <see cref="UndertaleExtension"/>.
/// </summary>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleExtensionFile : UndertaleObject, IDisposable
{
/// <summary>
/// The filename of this extension file.
/// </summary>
public UndertaleString Filename { get; set; }

/// <summary>
/// The script name that gets called when the game ends.
/// </summary>
public UndertaleString CleanupScript { get; set; }

/// <summary>
/// The script name that gets called when the game starts.
/// </summary>
public UndertaleString InitScript { get; set; }

/// <summary>
/// The type of extension this belongs to.
/// </summary>
public UndertaleExtensionKind Kind { get; set; }

/// <summary>
/// The functions this file has defined.
/// </summary>
public UndertalePointerList<UndertaleExtensionFunction> Functions { get; set; } = new UndertalePointerList<UndertaleExtensionFunction>();

/// <inheritdoc />
Expand Down Expand Up @@ -231,30 +261,53 @@ public void Dispose()
{
foreach (UndertaleExtensionFunction func in Functions)
func?.Dispose();
}
}
Filename = null;
CleanupScript = null;
InitScript = null;
Functions = new();
}
}


/// <summary>
/// An option that's used in an <see cref="UndertaleExtension"/>.
/// </summary>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleExtensionOption : UndertaleObject, IStaticChildObjectsSize, IDisposable
public class UndertaleExtensionOption : UndertaleNamedResource, IStaticChildObjectsSize, IDisposable
{
/// <inheritdoc cref="IStaticChildObjectsSize.ChildObjectsSize" />
public static readonly uint ChildObjectsSize = 12;

/// <summary>
/// The type of what the option value is.
/// </summary>
public enum OptionKind : uint
{
/// <summary>
/// The option value is a boolean-
/// </summary>
Boolean = 0,
/// <summary>
/// The option value is a number.
/// </summary>
Number = 1,
/// <summary>
/// The option value is a string.
/// </summary>
String = 2
}

/// <inheritdoc />
public UndertaleString Name { get; set; }

/// <summary>
/// The value of this option.
/// </summary>
public UndertaleString Value { get; set; }

/// <summary>
/// The type of this option.
/// </summary>
public OptionKind Kind { get; set; } = OptionKind.String;

/// <inheritdoc />
Expand Down Expand Up @@ -306,10 +359,25 @@ public class UndertaleExtension : UndertaleNamedResource, IDisposable
/// The name of the extension.
/// </summary>
public UndertaleString Name { get; set; }

/// <summary>
/// TODO: unknown?
/// </summary>
public UndertaleString ClassName { get; set; }

/// <summary>
/// The version of the extension.
/// </summary>
public UndertaleString Version { get; set; }

/// <summary>
/// The files that this extension contains.
/// </summary>
public UndertalePointerList<UndertaleExtensionFile> Files { get; set; } = new UndertalePointerList<UndertaleExtensionFile>();

/// <summary>
/// The options that this extension contains.
/// </summary>
public UndertalePointerList<UndertaleExtensionOption> Options { get; set; } = new UndertalePointerList<UndertaleExtensionOption>();

/// <inheritdoc />
Expand Down
5 changes: 3 additions & 2 deletions UndertaleModLib/Models/UndertaleFeatureFlags.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;

namespace UndertaleModLib.Models;

Expand All @@ -10,6 +8,9 @@ namespace UndertaleModLib.Models;
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleFeatureFlags : UndertaleObject, IDisposable
{
/// <summary>
/// The list of feature flags.
/// </summary>
public UndertaleSimpleListString List { get; set; }


Expand Down
5 changes: 5 additions & 0 deletions UndertaleModLib/Models/UndertaleGameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ public class UndertaleGameObject : UndertaleNamedResource, INotifyPropertyChange

/// <inheritdoc />
public event PropertyChangedEventHandler PropertyChanged;

/// <summary>
/// Invoked whenever the effective value of any dependency property has been updated.
/// </summary>
protected void OnPropertyChanged([CallerMemberName] string name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
Expand Down Expand Up @@ -537,6 +541,7 @@ public class EventAction : UndertaleObject, INotifyPropertyChanged, IDisposable,
public bool IsNot { get; set; } // always 0
public uint UnknownAlwaysZero { get; set; } // always 0

/// <inheritdoc />
public event PropertyChangedEventHandler PropertyChanged;

/// <inheritdoc />
Expand Down
Loading

0 comments on commit 9922aea

Please sign in to comment.