Skip to content

Commit

Permalink
[IO] Added checks for xenon and ps3
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperbx committed Dec 22, 2020
1 parent 4b5152a commit e6c68e0
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 5 deletions.
15 changes: 15 additions & 0 deletions Sonic-06-Character-Swapper/Forms/Main.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 24 additions & 3 deletions Sonic-06-Character-Swapper/Forms/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ public Main()
{
InitializeComponent();

// Set version string.
Label_Version.Text = $"Version {Program.Version}";

// Restore last checked states.
CheckBoxDark_CreateMod.Checked = Properties.Settings.Default.CreateMod;
CheckBoxDark_OverwriteArchive.Checked = Properties.Settings.Default.OverwriteArchive;
Expand Down Expand Up @@ -471,6 +474,9 @@ private void ButtonDark_RandomiseSeed_Click(object sender, EventArgs e)
/// </summary>
private void ButtonDark_Swap_Click(object sender, EventArgs e)
{
// Used for storage.
ArchiveDirectory player = null;

if (!File.Exists(ArchivePath))
{
MarathonMessageBox.Show
Expand Down Expand Up @@ -508,10 +514,25 @@ private void ButtonDark_Swap_Click(object sender, EventArgs e)
return;
}
#endif
ArchiveDirectory player = LoadedArchive.JumpToDirectory(@"xenon\player\");
int currentTotal = player.TotalContentsCount;
// Check if 'xenon\player\' returns null.
if ((player = LoadedArchive.JumpToDirectory(@"xenon\player\")) == null)
{
// If so, then check if 'ps3\player\' returns null.
if ((player = LoadedArchive.JumpToDirectory(@"ps3\player\")) == null)
{
MarathonMessageBox.Show
(
"Failed to locate the scripts directory...",
"Archive Error",
MessageBoxButtons.OK,
MessageBoxIcon.Error
);

Close();
}
}

for (int i = 0; i < currentTotal; i++)
for (int i = 0; i < player.TotalContentsCount; i++)
{
ArchiveFile script = (ArchiveFile)player.Data[i];

Expand Down
7 changes: 5 additions & 2 deletions Sonic-06-Character-Swapper/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,17 @@

using System;
using System.IO;
using System.Reflection;
using System.Diagnostics;
using System.Windows.Forms;

namespace S2006CharSwapMarathon
{
static class Program
{
public static string Location = Application.ExecutablePath, /* More convenient to store these here, rather than constantly requiring... */
WorkingDirectory = Path.GetDirectoryName(Location); /* ...System.Windows.Forms every time I need to use these. */
public static readonly string Version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion,
Location = Application.ExecutablePath, /* More convenient to store these here, rather than constantly requiring... */
WorkingDirectory = Path.GetDirectoryName(Location); /* ...System.Windows.Forms every time I need to use these. */

/// <summary>
/// The main entry point for the application.
Expand Down

0 comments on commit e6c68e0

Please sign in to comment.