Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First attempt at adding in-code documentation #806

Merged
merged 21 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions UndertaleModCli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
using System.Linq;
using System.Collections.Generic;
using UndertaleModLib.Decompiler;
using UndertaleModLib.Models;
using UndertaleModLib.Models;

/// <summary>
/// The supplied location of the data file did not exist
/// </summary>
Expand Down Expand Up @@ -528,7 +528,7 @@ public void EnsureDataLoaded()
throw new Exception("No data file is loaded.");
}

public async Task<bool> Make_New_File()
public async Task<bool> MakeNewDataFile()
{
await Task.Delay(1); //dummy await

Expand Down Expand Up @@ -676,12 +676,12 @@ public string GetDisassemblyText(UndertaleCode code)
throw new NotImplementedException();
}

public bool AreFilesIdentical(string File01, string File02)
public bool AreFilesIdentical(string file1, string file2)
{
try
{
using var fs1 = new FileStream(File01, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fs2 = new FileStream(File01, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fs1 = new FileStream(file1, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fs2 = new FileStream(file2, FileMode.Open, FileAccess.Read, FileShare.Read);
if (fs1.Length != fs2.Length) return false; // different size.

while (true)
Expand All @@ -702,7 +702,7 @@ public bool AreFilesIdentical(string File01, string File02)
}
}

public string ScriptInputDialog(string titleText, string labelText, string defaultInputBoxText, string cancelButtonText, string submitButtonText, bool isMultiline, bool preventClose)
public string ScriptInputDialog(string title, string label, string defaultInput, string cancelText, string submitText, bool isMultiline, bool preventClose)
{
throw new NotImplementedException();
}
Expand All @@ -711,7 +711,7 @@ public string SimpleTextInput(string title, string label, string defaultValue, b
{
throw new NotImplementedException();
}
public void SimpleTextOutput(string title, string label, string defaultText, bool allowMultiline)
public void SimpleTextOutput(string title, string label, string message, bool allowMultiline)
{
throw new NotImplementedException();
}
Expand Down Expand Up @@ -775,15 +775,15 @@ public void AddProgress(int amount)
{
progressValue += amount;
}
public void IncProgress()
public void IncrementProgress()
{
progressValue++;
}
public void AddProgressP(int amount) //P - Parallel (multithreaded)
public void AddProgressParallel(int amount) //P - Parallel (multithreaded)
{
Interlocked.Add(ref progressValue, amount); //thread-safe add operation (not the same as "lock ()")
}
public void IncProgressP()
public void IncrementProgressParallel()
{
Interlocked.Increment(ref progressValue); //thread-safe increment
}
Expand All @@ -805,7 +805,7 @@ public void SyncBinding(string resourceType, bool enable)
{
//there is no UI with any data binding
}
public void SyncBinding(bool enable = false)
public void DisableAllSyncBindings()
{
//there is no UI with any data binding
}
Expand Down Expand Up @@ -837,7 +837,7 @@ private void ProgressUpdater()
Thread.Sleep(100); //10 times per second
}
}
public void StartUpdater()
public void StartProgressBarUpdater()
{
if (cts is not null)
Console.WriteLine("Warning - there is another progress updater task running (hangs) in the background.");
Expand All @@ -847,7 +847,7 @@ public void StartUpdater()

updater = Task.Run(ProgressUpdater);
}
public async Task StopUpdater() //"async" because "Wait()" blocks UI thread
public async Task StopProgressBarUpdater() //"async" because "Wait()" blocks UI thread
{
if (cts is not null)
{
Expand All @@ -865,7 +865,7 @@ public void StartUpdater()
}
}

public async Task<bool> GenerateGMLCache(ThreadLocal<GlobalDecompileContext> decompileContext = null, object dialog = null, bool isSaving = false)
public async Task<bool> GenerateGMLCache(ThreadLocal<GlobalDecompileContext> decompileContext = null, object dialog = null, bool clearGMLEditedBefore = false)
{
await Task.Delay(1); //dummy await

Expand All @@ -875,12 +875,12 @@ public async Task<bool> GenerateGMLCache(ThreadLocal<GlobalDecompileContext> dec
}


public void ChangeSelection(object newsel)
public void ChangeSelection(object newSelection)
{
Selected = newsel;
Selected = newSelection;
}

public string PromptChooseDirectory(string prompt)
public string PromptChooseDirectory()
{
Console.WriteLine("Please type a path (or drag and drop) to a directory:");
Console.Write("Path: ");
Expand Down
40 changes: 40 additions & 0 deletions UndertaleModLib/AumiIPC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,39 @@ namespace UndertaleModLib
{
public struct IpcMessage_t
{
/// <summary>
/// A numerical value (1 to 4 for the latest AUMI implementation).
/// </summary>
/// <remarks>
/// The following table describes and explains the numerical values:
/// <list type="table">
/// <listheader>
/// <term>number</term>
/// <description>Explanation</description>
/// </listheader>
/// <item>
/// <term>1</term>
/// <description>Test Communication - Always returns a string that's 128 characters long.</description>
/// </item>
/// <item>
/// <term>2</term>
/// <description>Get Function By Index - Returns information about a function at a specified index in the runner.</description>
/// </item>
/// <item>
/// <term>3</term>
/// <description>Get Function By Name - Returns information about a function with a specified name.</description>
/// </item>
/// <item>
/// <term>4</term>
/// <description>Execute Code - Executes precompiled bytecode in the global context.</description>
/// </item>
/// </list>
/// </remarks>
public short FuncID;

/// <summary>
/// A 512 byte buffer containing information which accompanies <see cref="FuncID"/>.
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 512)]
public byte[] Buffer;

Expand All @@ -30,7 +62,15 @@ public byte[] RawBytes()

public struct IpcReply_t
{
/// <summary>
/// A numerical value from 0 to n, where 0 means success.
/// </summary>
/// <remarks>Anything other than 0 means failure, where the number specifies the actual reason.</remarks>
public int AUMIResult; // Always contains a value.

/// <summary>
/// A 128 byte buffer, might not always be filled in.
/// </summary>
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 128)]
public byte[] Buffer;

Expand Down
9 changes: 5 additions & 4 deletions UndertaleModLib/Compiler/BuiltinList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ public AccessorInfo(string lFunc, string lPreFunc, string lPostFunc, string rFun
}
}

// This is a really long list of known constants and variables, taken from code analysis
// This deserves to be in its own file for that reason...
// This will likely need to be updated with every new GameMaker version with new features
/// <summary>
/// A really long list of known Game Maker: Studio constants and variables, taken from code analysis. <br/>
/// Will likely need to be updated on every new Game Maker version with new features.
/// </summary>
public class BuiltinList
{
public Dictionary<string, double> Constants = null;
Expand All @@ -132,7 +133,7 @@ public BuiltinList(UndertaleData data)
{
Initialize(data);
}

public void Initialize(UndertaleData data)
{
// Functions
Expand Down
22 changes: 22 additions & 0 deletions UndertaleModLib/Models/UndertaleAnimationCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

namespace UndertaleModLib.Models
{
/// <summary>
/// An animation curve entry in a data file.
/// </summary>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleAnimationCurve : UndertaleNamedResource
{
Expand All @@ -16,15 +19,29 @@ public enum GraphTypeEnum : uint
Unknown1 = 1
}

/// <summary>
/// The name of this animation curve.
/// </summary>
public UndertaleString Name { get; set; }

/// <summary>
/// The graph type of this animation curve.
/// </summary>
public GraphTypeEnum GraphType { get; set; }


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

public void Serialize(UndertaleWriter writer)
{
Serialize(writer, true);
}

/// <summary>
/// Serializes the data file into a specified <see cref="UndertaleWriter"/>.
/// </summary>
/// <param name="writer">Where to serialize to.</param>
/// <param name="includeName">Whether to include <see cref="Name"/> in the serialization.</param>
public void Serialize(UndertaleWriter writer, bool includeName)
{
if (includeName)
Expand All @@ -38,6 +55,11 @@ public void Unserialize(UndertaleReader reader)
Unserialize(reader, true);
}

/// <summary>
/// Deserializes from a specified <see cref="UndertaleReader"/> to the current data file.
/// </summary>
/// <param name="reader">Where to deserialize from.</param>
/// <param name="includeName">Whether to include <see cref="Name"/> in the deserialization.</param>
public void Unserialize(UndertaleReader reader, bool includeName)
{
if (includeName)
Expand Down
77 changes: 76 additions & 1 deletion UndertaleModLib/Models/UndertaleBackground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,24 @@

namespace UndertaleModLib.Models
{
/// <summary>
/// A background or tileset entry in a data file.
/// </summary>
/// <remarks>For Game Maker Studio: 2, this will only ever be a tileset. For Game Maker Studio: 1, this is usually a background,
/// but is sometimes repurposed as use for a tileset as well.</remarks>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleBackground : UndertaleNamedResource
{
/// <summary>
/// A tile id, which can be used for referencing specific tiles in a tileset. Game Maker Studio 2 only.
/// </summary>
public class TileID : UndertaleObject, INotifyPropertyChanged
{
private uint _ID;

/// <summary>
/// The id of a specific tile.
/// </summary>
public uint ID { get => _ID; set { _ID = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(ID))); } }

public event PropertyChangedEventHandler PropertyChanged;
Expand All @@ -30,21 +41,85 @@ public void Unserialize(UndertaleReader reader)
}
}

/// <summary>
/// The name of the background.
/// </summary>
public UndertaleString Name { get; set; }

/// <summary>
/// Whether the background should be transparent.
/// </summary>
public bool Transparent { get; set; }

/// <summary>
/// Whether the background should get smoothed.
/// </summary>
public bool Smooth { get; set; }

/// <summary>
/// Whether to preload the background.
/// </summary>
public bool Preload { get; set; }

/// <summary>
/// The <see cref="UndertaleTexturePageItem"/> this background uses.
/// </summary>
public UndertaleTexturePageItem Texture { get; set; }


/// <summary>
/// TODO: Functionality currently unknown.
/// </summary>
public uint GMS2UnknownAlways2 { get; set; } = 2;

/// <summary>
/// The tile width of the tileset. Game Maker Studio 2 only.
/// </summary>
public uint GMS2TileWidth { get; set; } = 32;

/// <summary>
/// The tile height of the tileset. Game Maker Studio 2 only.
/// </summary>
public uint GMS2TileHeight { get; set; } = 32;

/// <summary>
/// The output border X of the tileset. Game Maker Studio 2 only.
/// </summary>
public uint GMS2OutputBorderX { get; set; } = 2;

/// <summary>
/// The output Border Y of the tileset. Game Maker Studio 2 only.
/// </summary>
public uint GMS2OutputBorderY { get; set; } = 2;

/// <summary>
/// The amount of columns this tileset has.
/// </summary>
public uint GMS2TileColumns { get; set; } = 32;

/// <summary>
/// The number of frames of the tileset animation.
/// </summary>
public uint GMS2ItemsPerTileCount { get; set; } = 1;

/// <summary>
/// The amount of tiles this tileset has.
/// </summary>
public uint GMS2TileCount { get; set; } = 1024;

/// <summary>
/// TODO: Functionality currently unknown.
/// </summary>
public uint GMS2UnknownAlwaysZero { get; set; } = 0;
public long GMS2FrameLength { get; set; } = 66666; // time for each frame (in microseconds seemingly)

/// <summary>
/// The time for each frame in microseconds.
/// </summary>
public long GMS2FrameLength { get; set; } = 66666;

/// <summary>
/// All tile ids of this tileset. Game Maker Studio 2 only.
/// </summary>
public List<TileID> GMS2TileIds { get; set; } = new List<TileID>();

public void Serialize(UndertaleWriter writer)
Expand Down
Loading