Skip to content
This repository has been archived by the owner on Aug 7, 2022. It is now read-only.

Commit

Permalink
Framework.cs cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 30, 2019
1 parent b8dd98f commit b25bf59
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions OMODFramework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,84 +30,93 @@ public class Framework
public static byte CurrentOmodVersion = 4;

/// <summary>
/// Whether the internal omod version check should be ignored
/// Whether the internal omod version check should be ignored
/// </summary>
public static bool IgnoreVersion { get; set; } = false;

/// <summary>
/// Whether to enable warnings during script executing. HIGHLY recommended to have this set to true
/// Whether to enable warnings during script executing. HIGHLY recommended to have this set to true
/// </summary>
public static bool EnableWarnings { get; set; } = true;

/// <summary>
/// DO NOT TOUCH UNLESS TOLD TO
/// DO NOT TOUCH UNLESS TOLD TO
/// </summary>
public static int MaxMemoryStreamSize => 67108864;

/// <summary>
/// Temp folder used for extraction. Default is %temp%\\OMODFramework\\
/// Temp folder used for extraction. Default is %temp%\\OMODFramework\\
/// </summary>
public static string TempDir { get; set; } = Path.Combine(Path.GetTempPath(), "OMODFramework");

/// <summary>
/// Absolute path to the Oblivion Game folder where <c>oblivion.exe</c> is located
/// Absolute path to the Oblivion Game folder where <c>oblivion.exe</c> is located
/// </summary>
public static string OblivionGameFolder { get; set; } = "";

internal static string OblivionDataFolder => Path.Combine(OblivionGameFolder, "data");

/// <summary>
/// Absolute path to the oblivion.ini file
/// Absolute path to the oblivion.ini file
/// </summary>
public static string OblivionINIFile { get; set; } = "";

/// <summary>
/// Absolute path to the RendererInfo.txt file
/// Absolute path to the RendererInfo.txt file
/// </summary>
public static string OblivionRenderInfoFile { get; set; } = "";

/// <summary>
/// Methods for patching files.
/// <para><c>OverwriteGameFolder</c> - will overwrite the file from the oblivion data folder if found</para>
/// <para><c>CreatePatchGameFolder</c> - will create a patch folder in the oblivion data folder containing the patched files</para>
/// <para><c>CreatePatchInMod</c> - will populate the <c>ScriptReturnData.PatchFiles</c> HashSet and not write to disk</para>
/// <para><c>PathWithInterface</c> - will call <c>IScriptFunctions.Patch</c> and let you decide how to patch something</para>
/// Methods for patching files.
/// <para><c>OverwriteGameFolder</c> - will overwrite the file from the oblivion data folder if found</para>
/// <para>
/// <c>CreatePatchGameFolder</c> - will create a patch folder in the oblivion data folder containing the patched
/// files
/// </para>
/// <para><c>CreatePatchInMod</c> - will populate the <c>ScriptReturnData.PatchFiles</c> HashSet and not write to disk</para>
/// <para><c>PathWithInterface</c> - will call <c>IScriptFunctions.Patch</c> and let you decide how to patch something</para>
/// </summary>
public enum PatchMethod { OverwriteGameFolder, CreatePatchGameFolder, CreatePatchInMod, PatchWithInterface }

/// <summary>
/// Method used for patching files, see <see cref="PatchMethod"/> for all available options
/// Method used for patching files, see <see cref="PatchMethod" /> for all available options
/// </summary>
public static PatchMethod CurrentPatchMethod { get; set; } = PatchMethod.CreatePatchInMod;

/// <summary>
/// Methods for reading the oblivion.ini file
/// <para><c>ReadOriginalINI</c> - reads the oblivion.ini specified at <see cref="OblivionINIFile"/></para>
/// <para><c>ReadWithInterface</c> - will call <c>IScriptFunctions.ReadOblivionINI</c></para>
/// Methods for reading the oblivion.ini file
/// <para><c>ReadOriginalINI</c> - reads the oblivion.ini specified at <see cref="OblivionINIFile" /></para>
/// <para><c>ReadWithInterface</c> - will call <c>IScriptFunctions.ReadOblivionINI</c></para>
/// </summary>
public enum ReadINIMethod { ReadOriginalINI, ReadWithInterface }

/// <summary>
/// Method used for reading the oblivion.ini file, see <see cref="ReadINIMethod"/> for all available options
/// Method used for reading the oblivion.ini file, see <see cref="ReadINIMethod" /> for all available options
/// </summary>
public static ReadINIMethod CurrentReadINIMethod { get; set; } = ReadINIMethod.ReadOriginalINI;

/// <summary>
/// Methods for reading the RendererInfo.txt file
/// <para><c>ReadOriginalRenderer</c> - reads the RendererInfo.txt specified at <see cref="OblivionRenderInfoFile"/></para>
/// <para><c>ReadWithInterface</c> - will call <c>IScriptFunctions.ReadRendererInfo</c></para>
/// Methods for reading the RendererInfo.txt file
/// <para>
/// <c>ReadOriginalRenderer</c> - reads the RendererInfo.txt specified at <see cref="OblivionRenderInfoFile" />
/// </para>
/// <para><c>ReadWithInterface</c> - will call <c>IScriptFunctions.ReadRendererInfo</c></para>
/// </summary>
public enum ReadRendererMethod { ReadOriginalRenderer, ReadWithInterface }

/// <summary>
/// Method used for reading the RendererInfo.txt file, see <see cref="ReadRendererMethod"/> for all available options
/// Method used for reading the RendererInfo.txt file, see <see cref="ReadRendererMethod" /> for all available options
/// </summary>
public static ReadRendererMethod CurrentReadRendererMethod { get; set; } =
ReadRendererMethod.ReadOriginalRenderer;

/// <summary>
/// Convenience function that will clean the entire temp folder for you
/// Convenience function that will clean the entire temp folder for you
/// </summary>
/// <param name="deleteRoot">Whether to delete the folder itself</param>
public static void CleanTempDir(bool deleteRoot = false)
{
if(!Directory.Exists(TempDir))
if (!Directory.Exists(TempDir))
return;

var dInfo = new DirectoryInfo(TempDir);
Expand All @@ -124,11 +133,13 @@ public static void CleanTempDir(bool deleteRoot = false)
{
// ignored
}

});
dInfo.GetDirectories().Do(d => {if(d.Exists && !d.Attributes.HasFlag(FileAttributes.ReadOnly)) d.Delete(true);});
dInfo.GetDirectories().Do(d =>
{
if (d.Exists && !d.Attributes.HasFlag(FileAttributes.ReadOnly)) d.Delete(true);
});

if(deleteRoot)
if (deleteRoot)
Directory.Delete(TempDir);
}
}
Expand Down

0 comments on commit b25bf59

Please sign in to comment.