Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into underanalyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
colinator27 committed Jul 19, 2024
2 parents 57cba9b + e5e0d5a commit a46f44f
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 29 deletions.
2 changes: 1 addition & 1 deletion UndertaleModLib/Compiler/AssemblyWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1070,7 +1070,7 @@ private static void AssembleStatement(CodeWriter cw, Parser.Statement s)
{
// Put the return value into a local variable (GM does this as well)
// so that it doesn't get cleared out of the stack??
// See here: https://github.com/krzys-h/UndertaleModTool/issues/164
// See here: https://github.com/UnderminersTeam/UndertaleModTool/issues/164
cw.varPatches.Add(new VariablePatch()
{
Target = cw.EmitRef(Opcode.Pop, DataType.Variable, DataType.Variable),
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModLib/Models/UndertaleEmbeddedImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace UndertaleModLib.Models;
/// 32-bit string pointer, some kind of texture page identifier?
/// 32-bit pointer to something relating to a texture page entry?
/// </code>
/// <see href="https://github.com/krzys-h/UndertaleModTool/issues/4#issuecomment-421844420"/>.</remarks>
/// <see href="https://github.com/UnderminersTeam/UndertaleModTool/issues/4#issuecomment-421844420"/>.</remarks>
public class UndertaleEmbeddedImage : UndertaleNamedResource, IStaticChildObjectsSize, IDisposable
{
/// <inheritdoc cref="IStaticChildObjectsSize.ChildObjectsSize" />
Expand Down
32 changes: 24 additions & 8 deletions UndertaleModLib/Models/UndertaleEmbeddedTexture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@ namespace UndertaleModLib.Models;
/// An embedded texture entry in the data file.
/// </summary>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleEmbeddedTexture : UndertaleNamedResource, IDisposable,
IStaticChildObjCount, IStaticChildObjectsSize
public class UndertaleEmbeddedTexture : UndertaleNamedResource, IDisposable
{
/// <inheritdoc cref="IStaticChildObjCount.ChildObjectCount" />
public static readonly uint ChildObjectCount = 1;

/// <inheritdoc cref="IStaticChildObjectsSize.ChildObjectsSize" />
public static readonly uint ChildObjectsSize = 4; // minimal size

/// <summary>
/// The name of the embedded texture entry.
/// </summary>
Expand Down Expand Up @@ -196,6 +189,29 @@ public void UnserializeBlob(UndertaleReader reader)
TextureLoaded = true;
}

/// <inheritdoc cref="UndertaleObject.UnserializeChildObjectCount(UndertaleReader)"/>
public static uint UnserializeChildObjectCount(UndertaleReader reader)
{
uint count = 0;

reader.Position += 4; // "Scaled"
if (reader.undertaleData.IsVersionAtLeast(2, 0, 6))
reader.Position += 4; // "GeneratedMips"
if (reader.undertaleData.IsVersionAtLeast(2022, 3))
reader.Position += 4; // "_textureBlockSize"
if (reader.undertaleData.IsVersionAtLeast(2022, 9))
reader.Position += 12; // "TextureWidth", "TextureHeight", "IndexInGroup"

if (reader.ReadUInt32() != 0)
{
// If the texture data pointer isn't null, then this is an internal texture,
// which will create another object in the pool when reading the blob.
count++;
}

return count;
}

/// <summary>
/// Assigns texture group info to every embedded texture in the supplied data file.
/// </summary>
Expand Down
2 changes: 1 addition & 1 deletion UndertaleModLib/Models/UndertaleFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void Unserialize(UndertaleReader reader)
SourceWidth = reader.ReadUInt16();
SourceHeight = reader.ReadUInt16();
Shift = reader.ReadInt16();
Offset = reader.ReadInt16(); // potential assumption, see the conversation at https://github.com/krzys-h/UndertaleModTool/issues/40#issuecomment-440208912
Offset = reader.ReadInt16(); // Potential assumption, see the conversation at https://github.com/UnderminersTeam/UndertaleModTool/issues/40#issuecomment-440208912
Kerning = reader.ReadUndertaleObject<UndertaleSimpleListShort<GlyphKerning>>();
}

Expand Down
2 changes: 1 addition & 1 deletion UndertaleModLib/Models/UndertaleTextureGroupInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace UndertaleModLib.Models;
/// #5 leads here:
/// SimpleList&lt;int&gt; of tileset IDs the group has
/// </code>
/// <see href="https://github.com/krzys-h/UndertaleModTool/wiki/Bytecode-17#tgin-new-chunk"/>.</remarks>
/// <see href="https://github.com/UnderminersTeam/UndertaleModTool/wiki/Bytecode-17#tgin-new-chunk"/>.</remarks>
[PropertyChanged.AddINotifyPropertyChangedInterface]
public class UndertaleTextureGroupInfo : UndertaleNamedResource, IDisposable
{
Expand Down
13 changes: 1 addition & 12 deletions UndertaleModLib/UndertaleChunks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1651,17 +1651,6 @@ internal override uint UnserializeObjectCount(UndertaleReader reader)

CheckFor2022_3And5(reader);

uint txtrSize = UndertaleEmbeddedTexture.ChildObjectsSize;
if (reader.undertaleData.IsVersionAtLeast(2, 0, 6))
txtrSize += 4; // "GeneratedMips"
if (reader.undertaleData.IsVersionAtLeast(2022, 3))
txtrSize += 4; // "TextureBlockSize"
if (reader.undertaleData.IsVersionAtLeast(2022, 9))
txtrSize += 12;

if (txtrSize != UndertaleEmbeddedTexture.ChildObjectsSize)
reader.SetStaticChildObjectsSize(typeof(UndertaleEmbeddedTexture), txtrSize);

// Texture blobs are already included in the count
return base.UnserializeObjectCount(reader);
}
Expand Down Expand Up @@ -1703,7 +1692,7 @@ internal override void SerializeChunk(UndertaleWriter writer)
{
if (!writer.undertaleData.IsGameMaker2())
throw new InvalidOperationException();
writer.Write((uint)1); // apparently hardcoded 1, see https://github.com/krzys-h/UndertaleModTool/issues/4#issuecomment-421844420
writer.Write((uint)1); // Apparently hardcoded 1, see https://github.com/UnderminersTeam/UndertaleModTool/issues/4#issuecomment-421844420
base.SerializeChunk(writer);
}

Expand Down
6 changes: 3 additions & 3 deletions UndertaleModTool/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2786,12 +2786,12 @@ public string ScriptInputDialog(string title, string label, string defaultInput,

private void MenuItem_GitHub_Click(object sender, RoutedEventArgs e)
{
OpenBrowser("https://github.com/krzys-h/UndertaleModTool");
OpenBrowser("https://github.com/UnderminersTeam/UndertaleModTool");
}

private void MenuItem_About_Click(object sender, RoutedEventArgs e)
{
this.ShowMessage("UndertaleModTool by krzys_h\nVersion " + Version, "About");
this.ShowMessage("UndertaleModTool by krzys_h and the Underminers team\nVersion " + Version, "About");
}

/// From https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Dialogs/AboutAvaloniaDialog.xaml.cs
Expand Down Expand Up @@ -2906,7 +2906,7 @@ public async void UpdateApp(SettingsWindow window)
bool isBundled = !Regex.Match(assemblyLocation, @"C:\\Program Files( \(x86\))*\\dotnet\\shared\\").Success;
string patchName = $"GUI-windows-latest-{configStr}-isBundled-{isBundled.ToString().ToLower()}-isSingleFile-{isSingleFile.ToString().ToLower()}";

string baseUrl = "https://api.github.com/repos/krzys-h/UndertaleModTool/actions/";
string baseUrl = "https://api.github.com/repos/UnderminersTeam/UndertaleModTool/actions/";
string detectedActionName = "Publish continuous release of UndertaleModTool";

// Fetch the latest workflow run
Expand Down
4 changes: 2 additions & 2 deletions UndertaleModTool/Scripts/Builtin Scripts/MixMod_README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Looking for an excuse to play Undertale again but don't have a Switch? I might have something for you!

The (probably) first mod that is not just another string/texture swap. Made with my [UndertaleModTool](https://github.com/krzys-h/UndertaleModTool).
The (probably) first mod that is not just another string/texture swap. Made with my [UndertaleModTool](https://github.com/UnderminersTeam/UndertaleModTool).

It's **Undertale, But Every Time A Song Plays Its A Random Remix From YouTube Instead!** (or MixMod for short)

And it does exactly that. Every time a song plays, it searches YouTube for "[song name] undertale remix" and plays a random result from the top N (where N depends on my estimation of songs popularity). Don't like the remix it selected? Just hit the spacebar to choose another random one!

**Installation instructions**:
1. Make sure you are on Undertale version >= 1.08 (older ones are not supported by UndertaleModTool because of bytecode changes) on Windows (because I didn't manage to figure out how to access GMS surfaces from extensions so I have to pass the whole DirectX context and draw manually - seriously, there is like no documentation on extensions at all)
2. Download [UndertaleModTool](https://github.com/krzys-h/UndertaleModTool/releases) (the mod script is bundled with the download because I'm too lazy to create a github repo for one file) and [GMWebExtension](https://github.com/krzys-h/GMWebExtension/releases) (the libs only zip file)
2. Download [UndertaleModTool](https://github.com/UnderminersTeam/UndertaleModTool/releases) (the mod script is bundled with the download because I'm too lazy to create a github repo for one file) and [GMWebExtension](https://github.com/krzys-h/GMWebExtension/releases) (the libs only zip file)
3. Make sure you backed up your Undertale installation
4. Open UndertaleModTool, load the data.win file from the Undertale directory
5. Select Scripts > Run builtin script > MixMod
Expand Down

0 comments on commit a46f44f

Please sign in to comment.