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

Commit

Permalink
Added Load functions and Framework settings
Browse files Browse the repository at this point in the history
  • Loading branch information
erri120 committed Nov 30, 2019
1 parent b25bf59 commit a643c8b
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
11 changes: 9 additions & 2 deletions OMODFramework/Classes/BSA.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You should have received a copy of the GNU General Public License
*/

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using BSAList = System.Collections.Generic.List<OMODFramework.Classes.BSAArchive>;
Expand Down Expand Up @@ -226,17 +227,23 @@ internal static byte[] GetMesh(string path) {
}
*/

internal static void Load(HashSet<string> list)
{
list.Do(f => new BSAArchive(f, true));
Loaded = true;
}

internal static byte[] GetFileFromBSA(string path)
{
//if(!Loaded) Load(true);
if(!Loaded) throw new OMODFrameworkException("BSAs need to be loaded before getting files from them!");

var hash = GenHash(path);
return !All.ContainsKey(hash) ? null : All[hash].GetRawData();
}

internal static byte[] GetFileFromBSA(string bsa, string path)
{
//if(!Loaded) Load(true);
if(!Loaded) throw new OMODFrameworkException("BSAs need to be loaded before getting files from them!");

var hash = GenHash(path);
if (!All.ContainsKey(hash)) return null;
Expand Down
34 changes: 34 additions & 0 deletions OMODFramework/Framework.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ You should have received a copy of the GNU General Public License
*/

using System;
using System.Collections.Generic;
using System.IO;
using OMODFramework.Classes;
using Path = Alphaleonis.Win32.Filesystem.Path;

namespace OMODFramework
Expand Down Expand Up @@ -110,6 +112,38 @@ public enum ReadRendererMethod { ReadOriginalRenderer, ReadWithInterface }
public static ReadRendererMethod CurrentReadRendererMethod { get; set; } =
ReadRendererMethod.ReadOriginalRenderer;

/// <summary>
/// Methods for handling BSA related functions like getting a file or extracting
/// <para>
/// <c>OriginalOBMM</c> - will use the original methods used by OBMM, requires <see cref="Framework.LoadBSAs"/>
/// </para>
/// <para>
/// <c>WithInterface</c> - will redirect all requests to the interface functions
/// </para>
/// </summary>
public enum BSAHandling { OriginalOBMM, WithInterface }

/// <summary>
/// Method used for handling BSA related functions, see <see cref="BSAHandling"/> for all available options
/// </summary>
public static BSAHandling CurrentBSAHandling { get; set; } = BSAHandling.WithInterface;

/// <summary>
/// This function will load all BSAs inside the provided HashSet. Do note that
/// this function is required when you
/// </summary>
/// <param name="fileList"></param>
public static void LoadBSAs(HashSet<string> fileList)
{
BSAArchive.Load(fileList);
}

/// <summary>
/// This function should be called after you are finished with everything and have set <see cref="CurrentBSAHandling"/>
/// to <c>OriginalOBMM</c>
/// </summary>
public static void ClearBSAs(){BSAArchive.Clear();}

/// <summary>
/// Convenience function that will clean the entire temp folder for you
/// </summary>
Expand Down

0 comments on commit a643c8b

Please sign in to comment.