mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
refactor: new code style in Data
This commit is contained in:
parent
f5054f5274
commit
8b4635ee5f
2 changed files with 26 additions and 14 deletions
|
|
@ -47,6 +47,9 @@
|
||||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EFormat_002ESettingsUpgrade_002EAlignmentTabFillStyleMigration/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002EFormat_002ESettingsUpgrade_002EAlignmentTabFillStyleMigration/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=clientopcode/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dalamud/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Dalamud/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gpose/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Gpose/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=lumina/@EntryIndexedValue">True</s:Boolean>
|
||||||
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=serveropcode/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=unsanitized/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=unsanitized/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Lumina;
|
using Lumina;
|
||||||
using Lumina.Data;
|
using Lumina.Data;
|
||||||
using Lumina.Data.Files;
|
using Lumina.Data.Files;
|
||||||
|
|
@ -19,17 +20,12 @@ namespace Dalamud.Data
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DataManager : IDisposable
|
public class DataManager : IDisposable
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// The current game client language.
|
|
||||||
/// </summary>
|
|
||||||
internal ClientLanguage Language;
|
|
||||||
|
|
||||||
private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
|
private const string IconFileFormat = "ui/icon/{0:D3}000/{1}{2:D6}.tex";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A <see cref="Lumina"/> object which gives access to any excel/game data.
|
/// A <see cref="Lumina"/> object which gives access to any excel/game data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Lumina.GameData gameData;
|
private GameData gameData;
|
||||||
|
|
||||||
private Thread luminaResourceThread;
|
private Thread luminaResourceThread;
|
||||||
|
|
||||||
|
|
@ -45,6 +41,11 @@ namespace Dalamud.Data
|
||||||
this.Language = language;
|
this.Language = language;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current game client language.
|
||||||
|
/// </summary>
|
||||||
|
public ClientLanguage Language { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the OpCodes sent by the server to the client.
|
/// Gets the OpCodes sent by the server to the client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -53,6 +54,7 @@ namespace Dalamud.Data
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the OpCodes sent by the client to the server.
|
/// Gets the OpCodes sent by the client to the server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[UsedImplicitly]
|
||||||
public ReadOnlyDictionary<string, ushort> ClientOpCodes { get; private set; }
|
public ReadOnlyDictionary<string, ushort> ClientOpCodes { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -104,11 +106,19 @@ namespace Dalamud.Data
|
||||||
ClientLanguage.French => Lumina.Data.Language.French,
|
ClientLanguage.French => Lumina.Data.Language.French,
|
||||||
_ => throw new ArgumentOutOfRangeException(
|
_ => throw new ArgumentOutOfRangeException(
|
||||||
nameof(this.Language),
|
nameof(this.Language),
|
||||||
"Unknown Language: " + this.Language),
|
@"Unknown Language: " + this.Language),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
this.gameData = new GameData(Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "sqpack"), luminaOptions);
|
var processModule = Process.GetCurrentProcess().MainModule;
|
||||||
|
if (processModule != null)
|
||||||
|
{
|
||||||
|
this.gameData =
|
||||||
|
new GameData(
|
||||||
|
Path.Combine(
|
||||||
|
Path.GetDirectoryName(processModule.FileName) !,
|
||||||
|
"sqpack"), luminaOptions);
|
||||||
|
}
|
||||||
|
|
||||||
Log.Information("Lumina is ready: {0}", this.gameData.DataPath);
|
Log.Information("Lumina is ready: {0}", this.gameData.DataPath);
|
||||||
|
|
||||||
|
|
@ -163,7 +173,7 @@ namespace Dalamud.Data
|
||||||
ClientLanguage.English => Lumina.Data.Language.English,
|
ClientLanguage.English => Lumina.Data.Language.English,
|
||||||
ClientLanguage.German => Lumina.Data.Language.German,
|
ClientLanguage.German => Lumina.Data.Language.German,
|
||||||
ClientLanguage.French => Lumina.Data.Language.French,
|
ClientLanguage.French => Lumina.Data.Language.French,
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(this.Language), "Unknown Language: " + this.Language)
|
_ => throw new ArgumentOutOfRangeException(nameof(this.Language), @"Unknown Language: " + this.Language)
|
||||||
};
|
};
|
||||||
return this.Excel.GetSheet<T>(lang);
|
return this.Excel.GetSheet<T>(lang);
|
||||||
}
|
}
|
||||||
|
|
@ -186,11 +196,10 @@ namespace Dalamud.Data
|
||||||
/// <returns>The <see cref="FileResource"/> of the file.</returns>
|
/// <returns>The <see cref="FileResource"/> of the file.</returns>
|
||||||
public T GetFile<T>(string path) where T : FileResource
|
public T GetFile<T>(string path) where T : FileResource
|
||||||
{
|
{
|
||||||
ParsedFilePath filePath = GameData.ParseFilePath(path);
|
var filePath = GameData.ParseFilePath(path);
|
||||||
if (filePath == null)
|
if (filePath == null)
|
||||||
return default(T);
|
return default;
|
||||||
Repository repository;
|
return this.gameData.Repositories.TryGetValue(filePath.Repository, out var repository) ? repository.GetFile<T>(filePath.Category, filePath) : default(T);
|
||||||
return this.gameData.Repositories.TryGetValue(filePath.Repository, out repository) ? repository.GetFile<T>(filePath.Category, filePath) : default(T);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -226,7 +235,7 @@ namespace Dalamud.Data
|
||||||
ClientLanguage.English => "en/",
|
ClientLanguage.English => "en/",
|
||||||
ClientLanguage.German => "de/",
|
ClientLanguage.German => "de/",
|
||||||
ClientLanguage.French => "fr/",
|
ClientLanguage.French => "fr/",
|
||||||
_ => throw new ArgumentOutOfRangeException(nameof(this.Language), "Unknown Language: " + this.Language)
|
_ => throw new ArgumentOutOfRangeException(nameof(this.Language), @"Unknown Language: " + this.Language)
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.GetIcon(type, iconId);
|
return this.GetIcon(type, iconId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue