diff --git a/Dalamud/Data/DataManager.cs b/Dalamud/Data/DataManager.cs
index db15a8ba7..220c5af78 100644
--- a/Dalamud/Data/DataManager.cs
+++ b/Dalamud/Data/DataManager.cs
@@ -3,17 +3,14 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
-using System.Net;
-using System.Net.Http;
using System.Threading;
-using System.Threading.Tasks;
-using Dalamud.Data.LuminaExtensions;
+
using Lumina.Data;
using Lumina.Data.Files;
using Lumina.Excel;
using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
using Serilog;
+
using LuminaOptions = Lumina.LuminaOptions;
using ParsedFilePath = Lumina.ParsedFilePath;
@@ -22,25 +19,9 @@ namespace Dalamud.Data
///
/// This class provides data for Dalamud-internal features, but can also be used by plugins if needed.
///
- public class DataManager : IDisposable {
- ///
- /// OpCodes sent by the server to the client.
- ///
- public ReadOnlyDictionary ServerOpCodes { get; private set; }
- ///
- /// OpCodes sent by the client to the server.
- ///
- public ReadOnlyDictionary ClientOpCodes { get; private set; }
-
- ///
- /// An object which gives access to any of the game's sheet data.
- ///
- public ExcelModule Excel => this.gameData?.Excel;
-
- ///
- /// Indicates whether Game Data is ready to be read.
- ///
- public bool IsDataReady { get; private set; }
+ public class DataManager : IDisposable
+ {
+ private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
///
/// A object which gives access to any excel/game data.
@@ -49,10 +30,12 @@ namespace Dalamud.Data
private ClientLanguage language;
- private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
-
private Thread luminaResourceThread;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The language to load data with by default.
public DataManager(ClientLanguage language)
{
// Set up default values so plugins do not null-reference when data is being loaded.
@@ -61,6 +44,30 @@ namespace Dalamud.Data
this.language = language;
}
+ ///
+ /// Gets the OpCodes sent by the server to the client.
+ ///
+ public ReadOnlyDictionary ServerOpCodes { get; private set; }
+
+ ///
+ /// Gets the OpCodes sent by the client to the server.
+ ///
+ public ReadOnlyDictionary ClientOpCodes { get; private set; }
+
+ ///
+ /// Gets an object which gives access to any of the game's sheet data.
+ ///
+ public ExcelModule Excel => this.gameData?.Excel;
+
+ ///
+ /// Gets a value indicating whether Game Data is ready to be read.
+ ///
+ public bool IsDataReady { get; private set; }
+
+ ///
+ /// Initialize this data manager.
+ ///
+ /// The directory to load data from.
public void Initialize(string baseDir)
{
try
@@ -69,18 +76,18 @@ namespace Dalamud.Data
var zoneOpCodeDict =
JsonConvert.DeserializeObject>(File.ReadAllText(Path.Combine(baseDir, "UIRes", "serveropcode.json")));
- ServerOpCodes = new ReadOnlyDictionary(zoneOpCodeDict);
+ this.ServerOpCodes = new ReadOnlyDictionary(zoneOpCodeDict);
Log.Verbose("Loaded {0} ServerOpCodes.", zoneOpCodeDict.Count);
var clientOpCodeDict =
JsonConvert.DeserializeObject>(File.ReadAllText(Path.Combine(baseDir, "UIRes", "clientopcode.json")));
- ClientOpCodes = new ReadOnlyDictionary(clientOpCodeDict);
+ this.ClientOpCodes = new ReadOnlyDictionary(clientOpCodeDict);
Log.Verbose("Loaded {0} ClientOpCodes.", clientOpCodeDict.Count);
-
- var luminaOptions = new LuminaOptions {
+ var luminaOptions = new LuminaOptions
+ {
CacheFileResources = true,
#if DEBUG
@@ -94,30 +101,32 @@ namespace Dalamud.Data
ClientLanguage.English => Language.English,
ClientLanguage.German => Language.German,
ClientLanguage.French => Language.French,
- _ => throw new ArgumentOutOfRangeException(nameof(this.language),
- "Unknown Language: " + this.language)
- }
+ _ => throw new ArgumentOutOfRangeException(
+ nameof(this.language),
+ "Unknown Language: " + this.language),
+ },
};
this.gameData = new Lumina.Lumina(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "sqpack"), luminaOptions);
- Log.Information("Lumina is ready: {0}", gameData.DataPath);
+ Log.Information("Lumina is ready: {0}", this.gameData.DataPath);
- IsDataReady = true;
-
- this.luminaResourceThread = new Thread( () =>
+ this.IsDataReady = true;
+
+ this.luminaResourceThread = new Thread(() =>
{
while (true)
{
- if (gameData.FileHandleManager.HasPendingFileLoads)
+ if (this.gameData.FileHandleManager.HasPendingFileLoads)
{
- gameData.ProcessFileHandleQueue();
+ this.gameData.ProcessFileHandleQueue();
}
else
{
Thread.Sleep(5);
}
}
+
// ReSharper disable once FunctionNeverReturns
});
this.luminaResourceThread.Start();
@@ -146,7 +155,8 @@ namespace Dalamud.Data
/// Language of the sheet to get.
/// The excel sheet type to get.
/// The , giving access to game rows.
- public ExcelSheet GetExcelSheet(ClientLanguage language) where T : class, IExcelRow {
+ public ExcelSheet GetExcelSheet(ClientLanguage language) where T : class, IExcelRow
+ {
var lang = language switch {
ClientLanguage.Japanese => Language.Japanese,
ClientLanguage.English => Language.English,
@@ -170,7 +180,7 @@ namespace Dalamud.Data
///
/// Get a with the given path, of the given type.
///
- /// The type of resource
+ /// The type of resource.
/// The path inside of the game files.
/// The of the file.
public T GetFile(string path) where T : FileResource
@@ -199,7 +209,7 @@ namespace Dalamud.Data
/// The containing the icon.
public TexFile GetIcon(int iconId)
{
- return GetIcon(this.language, iconId);
+ return this.GetIcon(this.language, iconId);
}
///
@@ -215,11 +225,10 @@ namespace Dalamud.Data
ClientLanguage.English => "en/",
ClientLanguage.German => "de/",
ClientLanguage.French => "fr/",
- _ => throw new ArgumentOutOfRangeException(nameof(this.language),
- "Unknown Language: " + this.language)
+ _ => throw new ArgumentOutOfRangeException(nameof(this.language), "Unknown Language: " + this.language)
};
- return GetIcon(type, iconId);
+ return this.GetIcon(type, iconId);
}
///
@@ -247,6 +256,9 @@ namespace Dalamud.Data
#endregion
+ ///
+ /// Dispose this DataManager.
+ ///
public void Dispose()
{
this.luminaResourceThread.Abort();