Skip to content

Commit

Permalink
Build with EA instead of a UPS patch
Browse files Browse the repository at this point in the history
  • Loading branch information
21aslade committed Aug 3, 2019
1 parent 98009e1 commit 8e4d45c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
25 changes: 14 additions & 11 deletions Randomizer/Shuffler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,20 @@ private void AddLocation(Location location)
}
}

public void ApplyPatch(string romLocation, string patchFile = null)
{
if (string.IsNullOrEmpty(patchFile))
{
// Get directory of MinishRandomizer
string assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
patchFile = assemblyPath + "/Patches/ROM buildfile.event";
}

string[] args = new[] { "A", "FE8", "-input:" + patchFile, "-output:" + romLocation };

ColorzCore.Program.Main(args);
}

/// <summary>
/// Loads and shuffles all locations
/// </summary>
Expand Down Expand Up @@ -199,17 +213,6 @@ public void RandomizeLocations(int seed)
// All locations should be filled at this point
throw new ShuffleException($"There are {unfilledLocations.Count} unfilled locations!");
}

using (MemoryStream ms = new MemoryStream(ROM.Instance.romData))
{
Writer writer = new Writer(ms);
foreach (Location location in Locations)
{
location.WriteLocation(writer);
}
}

File.WriteAllBytes(OutputDirectory + "/mcrando.gba", ROM.Instance.romData);
}

/// <summary>
Expand Down
12 changes: 11 additions & 1 deletion UI/MainWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ private void BrowsePatchButton_Click(object sender, EventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog
{
Filter = "UPS Patches|*.ups|All Files|*.*",
Filter = "Event Assembler Buildfiles|*.event|All Files|*.*",
Title = "Select Custom Patch"
};

Expand Down Expand Up @@ -193,6 +193,16 @@ private void SaveRomButton_Click(object sender, EventArgs e)
// Write output to ROM, then add patches
byte[] outputRom = shuffler.GetRandomizedRom();
File.WriteAllBytes(sfd.FileName, outputRom);

if (customPatchCheckBox.Checked)
{
shuffler.ApplyPatch(sfd.FileName, customPatchPath.Text);
}
else
{
// Use the default patch
shuffler.ApplyPatch(sfd.FileName);
}
}

private void SavePatchButton_Click(object sender, EventArgs e)
Expand Down

1 comment on commit 8e4d45c

@21aslade
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't build until language raws are available in the right folder

Please sign in to comment.