Skip to content

Commit

Permalink
Implement installation of the OpenSauce IDE to the HCE directory
Browse files Browse the repository at this point in the history
  • Loading branch information
MirisWisdom committed Nov 17, 2018
1 parent 21afaf4 commit 504601f
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
1 change: 1 addition & 0 deletions AmaiSosu/AmaiSosu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Backup.cs" />
<Compile Include="Copy.cs" />
<Compile Include="Main.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
Expand Down
3 changes: 2 additions & 1 deletion AmaiSosu/Backup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class Backup
"data",
"MaxScripts",
"shaders",
"tags"
"tags",
"OpenSauceIDE"
};

/// <summary>
Expand Down
34 changes: 34 additions & 0 deletions AmaiSosu/Copy.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.IO;

namespace AmaiSosu
{
/// <summary>
/// Copy a directory and its contents. Adapted from the MSDN CopyAll method.
/// <see cref="!:https://docs.microsoft.com/en-us/dotnet/api/system.io.directoryinfo" />
/// </summary>
public static class Copy
{
public static void All(DirectoryInfo source, DirectoryInfo target)
{
if (string.Equals(source.FullName, target.FullName, StringComparison.CurrentCultureIgnoreCase)) return;

// Check if the target directory exists, if not, create it.
if (Directory.Exists(target.FullName) == false) Directory.CreateDirectory(target.FullName);

// Copy each file into it's new directory.
foreach (var fi in source.GetFiles())
{
Console.WriteLine(@"Copying {0}\{1}", target.FullName, fi.Name);
fi.CopyTo(Path.Combine(target.ToString(), fi.Name), true);
}

// Copy each subdirectory using recursion.
foreach (var diSourceSubDir in source.GetDirectories())
{
var nextTargetSubDir = target.CreateSubdirectory(diSourceSubDir.Name);
All(diSourceSubDir, nextTargetSubDir);
}
}
}
}
19 changes: 19 additions & 0 deletions AmaiSosu/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void Install()
{
new Backup(Path).Commit();
OpenSauce.Install(Path);
MoveOpenSauceIde();
InstallText = "Installation has been successful!";
}
catch (Exception e)
Expand All @@ -106,6 +107,24 @@ public void Install()
}
}

/// <summary>
/// Moves the OpenSauce IDE directory to the HCE directory for convenience.
/// This method calls the static Copy.All(DirectoryInfo source, DirectoryInfo target) method.
/// </summary>
private void MoveOpenSauceIde()
{
const string dirName = "OpenSauceIDE";

var source =
System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
"Kornner Studios", "OpenSauce", dirName);

var target = System.IO.Path.Combine(Path, dirName);

Copy.All(new DirectoryInfo(source), new DirectoryInfo(target));
Directory.Delete(source, true);
}

/// <summary>
/// Updates the install text upon successful path provision.
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ there is no collision.

- installation of the OpenSauce libraries, in-game UI and user configurations;
- installation of OpenSauce development tools (`OS_Guerilla`, `OS_Sapien`, `OS_Tool`, etc.);
- installation of the OpenSauce IDE to the HCE directory, for self-containerisation & convenience;
- automatic back-up of existing OpenSauce data in the HCE directory (both files and folders);
- automatic back-up & deactivation of HAC2 if it exists, due to its incompatibility with OpenSauce;
- automatic detection attempt of a legally installed HCE directory for an even easier installation;
Expand Down

0 comments on commit 504601f

Please sign in to comment.