Skip to content

Commit

Permalink
Update for Dalamud.NET.sdk/9.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MidoriKami committed Jun 30, 2024
1 parent f63bd9e commit 4409caa
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Classes/ImGuiTweaks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static bool Checkbox(string label, ref bool value, string? hintText) {
return result;
}

public static bool PriorityInt(DalamudPluginInterface pluginInterface, string label, ref int value) {
public static bool PriorityInt(IDalamudPluginInterface pluginInterface, string label, ref int value) {
ImGui.SetNextItemWidth(22.0f * ImGuiHelpers.GlobalScale);
var valueChanged = ImGui.InputInt($"##{label}_input_int", ref value, 0, 0);

Expand Down
4 changes: 2 additions & 2 deletions CommandManager/CommandManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ public class CommandManager : IDisposable {
[PluginService] private IPluginLog Log { get; set; } = null!;
[PluginService] private IChatGui ChatGui { get; set; } = null!;

private readonly DalamudPluginInterface pluginInterface;
private readonly IDalamudPluginInterface pluginInterface;

private readonly List<CommandHandler> registeredCommands = [];
private readonly List<string> registeredBaseCommands = [];

public CommandManager(DalamudPluginInterface pluginInterface, params string[] baseCommands) {
public CommandManager(IDalamudPluginInterface pluginInterface, params string[] baseCommands) {
this.pluginInterface = pluginInterface;
this.pluginInterface.Inject(this);

Expand Down
22 changes: 11 additions & 11 deletions Configuration/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static class Configuration {
/// <param name="createFunc">A function to create that file if loading fails.</param>
/// <typeparam name="T">Type of file to load, needed for serialization.</typeparam>
/// <returns>Either a loaded config file, or a new'd file of type T.</returns>
public static T LoadCharacterFile<T>(this DalamudPluginInterface pluginInterface, ulong contentId, string fileName, Func<T> createFunc) where T : new()
public static T LoadCharacterFile<T>(this IDalamudPluginInterface pluginInterface, ulong contentId, string fileName, Func<T> createFunc) where T : new()
=> LoadFile(pluginInterface, pluginInterface.GetCharacterFileInfo(contentId, fileName).FullName, createFunc);

/// <summary>
Expand All @@ -34,7 +34,7 @@ public static class Configuration {
/// <param name="createFunc">A function to create the file if loading fails.</param>
/// <typeparam name="T">Type of file to load, needed for serialization.</typeparam>
/// <returns>Either a loaded config file, or a new'd file of type T.</returns>
public static T LoadConfigFile<T>(this DalamudPluginInterface pluginInterface, string fileName, Func<T> createFunc) where T : new()
public static T LoadConfigFile<T>(this IDalamudPluginInterface pluginInterface, string fileName, Func<T> createFunc) where T : new()
=> LoadFile(pluginInterface, Path.Combine(pluginInterface.ConfigDirectory.FullName, fileName), createFunc);

/// <summary>
Expand All @@ -45,7 +45,7 @@ public static class Configuration {
/// <param name="fileName">Specific name of the file you wish to save.</param>
/// <param name="file">The object to write to a file.</param>
/// <typeparam name="T">Type of file to load, needed for serialization.</typeparam>
public static void SaveCharacterFile<T>(this DalamudPluginInterface pluginInterface, ulong contentId, string fileName, T file)
public static void SaveCharacterFile<T>(this IDalamudPluginInterface pluginInterface, ulong contentId, string fileName, T file)
=> SaveFile(pluginInterface, pluginInterface.GetCharacterFileInfo(contentId, fileName).FullName, file);

/// <summary>
Expand All @@ -55,10 +55,10 @@ public static void SaveCharacterFile<T>(this DalamudPluginInterface pluginInterf
/// <param name="fileName">Specific name of the file you wish to save.</param>
/// <param name="file">The object to write to a file.</param>
/// <typeparam name="T">Type of file to load, needed for serialization.</typeparam>
public static void SaveConfigFile<T>(this DalamudPluginInterface pluginInterface, string fileName, T file)
public static void SaveConfigFile<T>(this IDalamudPluginInterface pluginInterface, string fileName, T file)
=> SaveFile(pluginInterface, Path.Combine(pluginInterface.GetPluginConfigDirectory(), fileName), file);

private static T LoadFile<T>(DalamudPluginInterface pluginInterface, string filePath, Func<T> createFunc) where T : new() {
private static T LoadFile<T>(IDalamudPluginInterface pluginInterface, string filePath, Func<T> createFunc) where T : new() {
var fileInfo = new FileInfo(filePath);
if (fileInfo is { Exists: true }) {
try {
Expand Down Expand Up @@ -88,7 +88,7 @@ public static void SaveConfigFile<T>(this DalamudPluginInterface pluginInterface
return newFile;
}

private static void SaveFile<T>(DalamudPluginInterface pluginInterface, string filePath, T file) {
private static void SaveFile<T>(IDalamudPluginInterface pluginInterface, string filePath, T file) {
try {
var fileText = JsonSerializer.Serialize(file, file!.GetType(), SerializerOptions);
Dalamud.Utility.Util.WriteAllTextSafe(filePath, fileText);
Expand All @@ -99,7 +99,7 @@ private static void SaveFile<T>(DalamudPluginInterface pluginInterface, string f
}
}

internal static DirectoryInfo GetCharacterDirectoryInfo(this DalamudPluginInterface pluginInterface, ulong contentId) {
internal static DirectoryInfo GetCharacterDirectoryInfo(this IDalamudPluginInterface pluginInterface, ulong contentId) {
var directoryInfo = new DirectoryInfo(Path.Combine(pluginInterface.ConfigDirectory.FullName, contentId.ToString()));

if (directoryInfo is { Exists: false }) {
Expand All @@ -111,13 +111,13 @@ internal static DirectoryInfo GetCharacterDirectoryInfo(this DalamudPluginInterf
return directoryInfo;
}

internal static FileInfo GetCharacterFileInfo(this DalamudPluginInterface pluginInterface, ulong contentId, string fileName)
internal static FileInfo GetCharacterFileInfo(this IDalamudPluginInterface pluginInterface, ulong contentId, string fileName)
=> new(Path.Combine(pluginInterface.GetCharacterDirectoryInfo(contentId).FullName, fileName));

internal static IEnumerable<CharacterConfiguration> GetAllCharacterConfigurations(this DalamudPluginInterface pluginInterface)
internal static IEnumerable<CharacterConfiguration> GetAllCharacterConfigurations(this IDalamudPluginInterface pluginInterface)
=> pluginInterface.GetAllCharacterContentIds().Select(pluginInterface.LoadCharacterConfiguration);

private static CharacterConfiguration LoadCharacterConfiguration(this DalamudPluginInterface pluginInterface, ulong contentId) {
private static CharacterConfiguration LoadCharacterConfiguration(this IDalamudPluginInterface pluginInterface, ulong contentId) {
var loadedConfiguration = pluginInterface.LoadCharacterFile(contentId, "System.config.json", () => CreateNewCharacterConfig(contentId));
if (loadedConfiguration is { Version: not 2, ContentId: 0 }) {
loadedConfiguration.Version = 2;
Expand All @@ -128,7 +128,7 @@ private static CharacterConfiguration LoadCharacterConfiguration(this DalamudPlu
return loadedConfiguration;
}

private static IEnumerable<ulong> GetAllCharacterContentIds(this DalamudPluginInterface pluginInterface) {
private static IEnumerable<ulong> GetAllCharacterContentIds(this IDalamudPluginInterface pluginInterface) {
if (pluginInterface.ConfigDirectory is { Exists: true } directoryInfo) {
foreach (var directory in directoryInfo.EnumerateDirectories()) {
if (ulong.TryParse(directory.Name, out var contentId)) {
Expand Down
2 changes: 1 addition & 1 deletion Extensions/LodestoneClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace KamiLib.Extensions;

public static class LodestoneClientExtensions {
internal static async Task<LodestoneCharacter?> TryGetLodestoneCharacter(this LodestoneClient client, DalamudPluginInterface pluginInterface, IPluginLog log, CharacterConfiguration character) {
internal static async Task<LodestoneCharacter?> TryGetLodestoneCharacter(this LodestoneClient client, IDalamudPluginInterface pluginInterface, IPluginLog log, CharacterConfiguration character) {
try {
// If lodestone id is null, try and fetch it by searching for name and world.
if (character.LodestoneId is null) {
Expand Down
2 changes: 1 addition & 1 deletion Extensions/NetStoneExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace KamiLib.Extensions;

public static class NetStoneExtensions {
internal static async Task<ISharedImmediateTexture?> TryGetProfilePicture(HttpClient httpClient, LodestoneClient lodestoneClient, DalamudPluginInterface pluginInterface, ITextureProvider textureProvider, IPluginLog log, CharacterConfiguration characterConfiguration) {
internal static async Task<ISharedImmediateTexture?> TryGetProfilePicture(HttpClient httpClient, LodestoneClient lodestoneClient, IDalamudPluginInterface pluginInterface, ITextureProvider textureProvider, IPluginLog log, CharacterConfiguration characterConfiguration) {
try {
// We had some error while loading character configuration and don't know what character this is.
if (characterConfiguration.ContentId is 0) return null;
Expand Down
2 changes: 1 addition & 1 deletion Extensions/PluginInterfaceExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
namespace KamiLib.Extensions;

public static class PluginInterfaceExtensions {
internal static FileInfo GetProfilePictureFileInfo(this DalamudPluginInterface pluginInterface, CharacterConfiguration characterConfiguration)
internal static FileInfo GetProfilePictureFileInfo(this IDalamudPluginInterface pluginInterface, CharacterConfiguration characterConfiguration)
=> new(Path.Combine(pluginInterface.GetCharacterDirectoryInfo(characterConfiguration.ContentId).FullName, "profile.png"));
}
3 changes: 2 additions & 1 deletion KamiLib.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Dalamud.NET.Sdk/9.0.1">
<Project Sdk="Dalamud.NET.Sdk/9.0.2">

<ItemGroup>
<None Remove="LICENSE"/>
Expand All @@ -7,5 +7,6 @@

<ItemGroup>
<PackageReference Include="NetStone" Version="1.1.1" />
<PackageReference Update="DalamudPackager" Version="2.1.13" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Window/SelectionWindows/CollectableItemSelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class CollectableItemSelectionWindow : SelectionWindowBase<Item> {
[PluginService] private ITextureProvider TextureProvider { get; set; } = null!;
[PluginService] private IDataManager DataManager { get; set; } = null!;

public CollectableItemSelectionWindow(DalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
public CollectableItemSelectionWindow(IDalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
pluginInterface.Inject(this);

SelectionOptions = DataManager
Expand Down
2 changes: 1 addition & 1 deletion Window/SelectionWindows/HighQualityItemSelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class HighQualityItemSelectionWindow : SelectionWindowBase<Item> {
[PluginService] private ITextureProvider TextureProvider { get; set; } = null!;
[PluginService] private IDataManager DataManager { get; set; } = null!;

public HighQualityItemSelectionWindow(DalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
public HighQualityItemSelectionWindow(IDalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
pluginInterface.Inject(this);

SelectionOptions = DataManager
Expand Down
2 changes: 1 addition & 1 deletion Window/SelectionWindows/ItemSelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ItemSelectionWindow : SelectionWindowBase<Item> {
[PluginService] private ITextureProvider TextureProvider { get; set; } = null!;
[PluginService] private IDataManager DataManager { get; set; } = null!;

public ItemSelectionWindow(DalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
public ItemSelectionWindow(IDalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
pluginInterface.Inject(this);

SelectionOptions = DataManager
Expand Down
2 changes: 1 addition & 1 deletion Window/SelectionWindows/ItemUICategorySelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ItemUiCategorySelectionWindow : SelectionWindowBase<ItemUICategory>
[PluginService] private ITextureProvider TextureProvider { get; set; } = null!;
[PluginService] private IDataManager DataManager { get; set; } = null!;

public ItemUiCategorySelectionWindow(DalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
public ItemUiCategorySelectionWindow(IDalamudPluginInterface pluginInterface) : base(new Vector2(300.0f, 600.0f), false) {
pluginInterface.Inject(this);

SelectionOptions = DataManager
Expand Down
2 changes: 1 addition & 1 deletion Window/SelectionWindows/TerritorySelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class TerritorySelectionWindow : SelectionWindowBase<TerritoryType> {
[PluginService] private IDataManager DataManager { get; set; } = null!;
[PluginService] private ITextureProvider TextureProvider { get; set; } = null!;

public TerritorySelectionWindow(DalamudPluginInterface pluginInterface) :base(new Vector2(600.0f, 600.0f)) {
public TerritorySelectionWindow(IDalamudPluginInterface pluginInterface) :base(new Vector2(600.0f, 600.0f)) {
pluginInterface.Inject(this);

SelectionOptions = DataManager.GetExcelSheet<TerritoryType>()!
Expand Down
2 changes: 1 addition & 1 deletion Window/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public enum WindowFlags {

public abstract class Window : Dalamud.Interface.Windowing.Window {
private bool isCollapsed;
public DalamudPluginInterface PluginInterface { get; set; } = null!;
public IDalamudPluginInterface PluginInterface { get; set; } = null!;
public WindowManager ParentWindowManager { get; set; } = null!;

public string? AdditionalInfoTooltip { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions Window/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace KamiLib.Window;

public class WindowManager : IDisposable {
private readonly WindowSystem windowSystem;
private readonly DalamudPluginInterface pluginInterface;
private readonly IDalamudPluginInterface pluginInterface;

[PluginService] private IClientState ClientState { get; set; } = null!;

Expand All @@ -23,7 +23,7 @@ public class WindowManager : IDisposable {

private List<Window> Windows { get; } = [];

public WindowManager(DalamudPluginInterface pluginInterface) {
public WindowManager(IDalamudPluginInterface pluginInterface) {
windowSystem = new WindowSystem(pluginInterface.Manifest.InternalName);

this.pluginInterface = pluginInterface;
Expand Down
6 changes: 3 additions & 3 deletions packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net8.0-windows7.0": {
"DalamudPackager": {
"type": "Direct",
"requested": "[2.1.12, )",
"resolved": "2.1.12",
"contentHash": "Sc0PVxvgg4NQjcI8n10/VfUQBAS4O+Fw2pZrAqBdRMbthYGeogzu5+xmIGCGmsEZ/ukMOBuAqiNiB5qA3MRalg=="
"requested": "[2.1.13, )",
"resolved": "2.1.13",
"contentHash": "rMN1omGe8536f4xLMvx9NwfvpAc9YFFfeXJ1t4P4PE6Gu8WCIoFliR1sh07hM+bfODmesk/dvMbji7vNI+B/pQ=="
},
"DotNet.ReproducibleBuilds": {
"type": "Direct",
Expand Down

0 comments on commit 4409caa

Please sign in to comment.