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

Commit

Permalink
Implemented all classes and structs for Script execution
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 28, 2019
1 parent 6a322a0 commit 5a68634
Show file tree
Hide file tree
Showing 2 changed files with 241 additions and 3 deletions.
6 changes: 6 additions & 0 deletions OMODFramework/Classes/CompressionHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ You should have received a copy of the GNU General Public License

namespace OMODFramework
{
/// <summary>
/// The Compression used for extraction and compression
/// </summary>
public enum CompressionType : byte { SevenZip, Zip }
/// <summary>
/// The level of compression used for extraction and compression
/// </summary>
public enum CompressionLevel : byte { VeryHigh, High, Medium, Low, VeryLow, None }

internal class SparseFileWriterStream : Stream
Expand Down
238 changes: 235 additions & 3 deletions OMODFramework/Classes/Misc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,24 @@ You should have received a copy of the GNU General Public License

namespace OMODFramework
{
/// <summary>
/// Describes the Conflict Level between two files/plugins/OMODs
/// </summary>
public enum ConflictLevel { Active, NoConflict, MinorConflict, MajorConflict, Unusable }

/// <summary>
/// Describes the status for OMOD/Plugin deactivation
/// </summary>
public enum DeactivationStatus { Allow, WarnAgainst, Disallow }

/// <summary>
/// Describes the programming language used in the OMOD script
/// </summary>
public enum ScriptType { OBMMScript, Python, Csharp, VB, Count }

/// <summary>
/// Struct containing conflict information for a file
/// </summary>
public struct ConflictData
{
public ConflictLevel Level;
Expand Down Expand Up @@ -61,25 +77,241 @@ public DataFileInfo(DataFileInfo original)
}
}

/// <summary>
/// Contains all information needed for the creation of an OMOD file
/// </summary>
public struct OMODCreationOptions
{
/// <summary>
/// Required
/// </summary>
public string Name;
/// <summary>
/// Required
/// </summary>
public string Author;
/// <summary>
/// Required
/// </summary>
public string Description;
/// <summary>
/// Optional
/// </summary>
public string Email;
/// <summary>
/// Optional
/// </summary>
public string Website;
public string Description;


/// <summary>
/// Optional, this needs to be the path to the image.
/// The image will be read during creation so make sure it's readable!
/// </summary>
public string Image;
/// <summary>
/// Optional, this is the entire readme as text. Best as UTF-8
/// </summary>
public string Readme;
/// <summary>
/// Optional, this is the entire script as text. Best as UTF-8
/// </summary>
public string Script;

/// <summary>
/// Required
/// </summary>
public int MajorVersion;
/// <summary>
/// Required
/// </summary>
public int MinorVersion;
/// <summary>
/// Optional
/// </summary>
public int BuildVersion;

/// <summary>
/// Required
/// </summary>
public CompressionType CompressionType;
/// <summary>
/// Required, this is the level of compression for all data files inside the .omod file
/// </summary>
public CompressionLevel DataFileCompressionLevel;
/// <summary>
/// Required, this is the overall level of compression for the .omod file
/// </summary>
public CompressionLevel OMODCompressionLevel;

/// <summary>
/// Optional if you have no ESPs
/// </summary>
public List<string> ESPs;
/// <summary>
/// Optional if you have no ESPs
/// </summary>
public List<string> ESPPaths;
/// <summary>
/// Required, this List contains all absolute paths of the files you want to include
/// </summary>
public List<string> DataFiles;
/// <summary>
/// Required, this List contains all relative paths of the files from DataFiles:
/// This is a List and not a HashSet since the framework will loop through the DataFiles list
/// using the indices and needs a corresponding path at the same index in this List.
/// EG:
/// <example>
/// <code>
/// DataFiles = {
/// "C:\\Modding\\MyOMOD\\readme.txt",
/// "C:\\Modding\\MyOMOD\\textures.bsa",
/// "C:\\Modding\\MyOMOD\\ui_stuff\\repair_menu_final.xml"
/// };
///
/// DataFilePaths = {
/// "docs\\readme.txt",
/// "textures.bsa",
/// "menus\\repair_menu.xml"
/// };
/// </code>
/// </example>
/// </summary>
public List<string> DataFilePaths;
public string Readme;
public string Script;
}

/// <summary>
/// If you want plugin A to load after plugin B you would
/// set <c>PluginLoadInfo.Plugin</c> to A, <c>PluginLoadInfo.Target</c> to B
/// and <c>PluginLoadInfo.LoadAfter</c> to true
/// </summary>
public struct PluginLoadInfo
{
public string Plugin;
public string Target;
public bool LoadAfter;

public PluginLoadInfo(string plugin, string target, bool loadAfter)
{
Plugin = plugin;
Target = target;
LoadAfter = loadAfter;
}
}

public struct ScriptESPEdit
{
public readonly bool IsGMST;
public readonly string Plugin;
public readonly string EDID;
public readonly string Value;

public ScriptESPEdit(bool gmst, string plugin, string edid, string value)
{
IsGMST = gmst;
Plugin = plugin;
EDID = edid;
Value = value;
}
}

/// <summary>
/// Contains information about the deactivation status of a plugin. Eg you might have
/// a plugin that should not be deactivated
/// </summary>
public struct ScriptESPWarnAgainst
{
public string Plugin;
public DeactivationStatus Status;

public ScriptESPWarnAgainst(string plugin, DeactivationStatus status)
{
Plugin = plugin;
Status = status;
}
}

/// <summary>
/// Information about what file goes where
/// </summary>
public struct ScriptCopyDataFile
{
public readonly string CopyFrom;
public readonly string CopyTo;

public ScriptCopyDataFile(string from, string to)
{
CopyFrom = from;
CopyTo = to;
}
}

/// <summary>
/// Contains all information about the script execution
/// </summary>
public class ScriptReturnData
{
public bool CancelInstall = false;

// Plugins
public bool InstallAllPlugins = true;
public readonly HashSet<string> IgnorePlugins = new HashSet<string>();
public readonly HashSet<string> InstallPlugins = new HashSet<string>();
public readonly HashSet<ScriptCopyDataFile> CopyPlugins = new HashSet<ScriptCopyDataFile>();

// Data files
public bool InstallAllData = true;
public readonly HashSet<string> IgnoreData = new HashSet<string>();
public readonly HashSet<string> InstallData = new HashSet<string>();
public readonly HashSet<ScriptCopyDataFile> CopyDataFiles = new HashSet<ScriptCopyDataFile>();

// Load order stuff
public readonly HashSet<string> UncheckedPlugins = new HashSet<string>();
public readonly HashSet<ScriptESPWarnAgainst> ESPDeactivation = new HashSet<ScriptESPWarnAgainst>();
public readonly HashSet<string> EarlyPlugins = new HashSet<string>();
public readonly HashSet<PluginLoadInfo> LoadOrderSet = new HashSet<PluginLoadInfo>();
public readonly HashSet<ConflictData> ConflictsWith = new HashSet<ConflictData>();
public readonly HashSet<ConflictData> DependsOn = new HashSet<ConflictData>();

// Edits
public readonly HashSet<string> RegisterBSASet = new HashSet<string>();
public readonly HashSet<INIEditInfo> INIEdits = new HashSet<INIEditInfo>();
public readonly HashSet<SDPEditInfo> SDPEdits = new HashSet<SDPEditInfo>();
public readonly HashSet<ScriptESPEdit> ESPEdits = new HashSet<ScriptESPEdit>();
}

public class INIEditInfo
{
public readonly string Section;
public readonly string Name;
public readonly string NewValue;
public string OldValue;
public OMOD Plugin;

public INIEditInfo(string section, string name, string newValue)
{
Section = section;
Name = name;
NewValue = newValue;
}

public static bool operator==(INIEditInfo a, INIEditInfo b) { return a?.Section==b?.Section && a?.Name==b?.Name; }
public static bool operator!=(INIEditInfo a, INIEditInfo b) { return a?.Section!=b?.Section || a?.Name!=b?.Name; }
public override bool Equals(object obj) { return this==obj as INIEditInfo; }
public override int GetHashCode() { return Section.GetHashCode() + Name.GetHashCode(); }
}

public class SDPEditInfo
{
public readonly byte Package;
public readonly string Shader;
public string BinaryObject;

public SDPEditInfo(byte package, string shader, string binaryObject)
{
Package = package;
Shader = shader.ToLower();
BinaryObject = binaryObject.ToLower();
}
}
}

0 comments on commit 5a68634

Please sign in to comment.