Skip to content

Commit

Permalink
Update for API11
Browse files Browse the repository at this point in the history
  • Loading branch information
MidoriKami committed Nov 15, 2024
1 parent 5ad86f9 commit dccc432
Show file tree
Hide file tree
Showing 13 changed files with 79 additions and 79 deletions.
2 changes: 1 addition & 1 deletion Classes/ImGuiTweaks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Dalamud.Plugin;
using ImGuiNET;
using KamiLib.Extensions;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Classes;

Expand Down
10 changes: 6 additions & 4 deletions Configuration/CharacterConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
using Dalamud.Interface.Utility;
using Dalamud.Interface.Utility.Raii;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game.UI;
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
using FFXIVClientStructs.FFXIV.Common.Math;
using ImGuiNET;

Expand All @@ -20,10 +22,10 @@ public class CharacterConfiguration : IPluginConfiguration {
[JsonIgnore] public bool PurgeProfilePicture { get; set; }
[JsonIgnore] public ISharedImmediateTexture? ProfilePicture { get; set; }

public void UpdateCharacterData(IClientState clientState) {
if (clientState is { LocalPlayer: { Name: var playerName, HomeWorld.GameData.Name: var homeWorld } }) {
CharacterName = playerName.ToString();
CharacterWorld = homeWorld.ToString();
public unsafe void UpdateCharacterData() {
if (AgentLobby.Instance()->IsLoggedIn) {
CharacterName = PlayerState.Instance()->CharacterNameString;
CharacterWorld = AgentLobby.Instance()->LobbyData.HomeWorldName.ToString();
}
}

Expand Down
68 changes: 33 additions & 35 deletions Extensions/DataManagerExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Dalamud.Game;
using Dalamud.Plugin.Services;
using FFXIVClientStructs.FFXIV.Client.Game;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Extensions;

Expand All @@ -19,73 +19,71 @@ public enum DutyType {

public static class DataManagerExtensions {
public static IEnumerable<ContentFinderCondition> GetSavageDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)?
.Where(cfc => cfc is { ContentType.Row: 5 })
.Where(cfc => cfc.Name.RawString.Contains("Savage")) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)
.Where(cfc => cfc is { ContentType.RowId: 5 })
.Where(cfc => cfc.Name.ExtractText().Contains("Savage"));

public static IEnumerable<ContentFinderCondition> GetUltimateDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>()?
.Where(cfc => cfc is { ContentType.Row: 28 }) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>()
.Where(cfc => cfc is { ContentType.RowId: 28 });

public static IEnumerable<ContentFinderCondition> GetExtremeDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)?
.Where(cfc => cfc is { ContentType.Row: 4, HighEndDuty: false })
.Where(cfc => cfc.Name.RawString.Contains("Extreme")) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)
.Where(cfc => cfc is { ContentType.RowId: 4, HighEndDuty: false })
.Where(cfc => cfc.Name.ExtractText().Contains("Extreme"));

public static IEnumerable<ContentFinderCondition> GetUnrealDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)?
.Where(cfc => cfc is { ContentType.Row: 4, HighEndDuty: true }) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)
.Where(cfc => cfc is { ContentType.RowId: 4, HighEndDuty: true });

public static IEnumerable<ContentFinderCondition> GetCriterionDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>()?
.Where(cfc => cfc is { ContentType.Row: 30, AllowUndersized: false }) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>()
.Where(cfc => cfc is { ContentType.RowId: 30, AllowUndersized: false });

public static IEnumerable<ContentFinderCondition> GetAllianceDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>()?
.Where(cfc => cfc is { ContentType.Row: 5, ContentMemberType.Row: 4 }) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>()
.Where(cfc => cfc is { ContentType.RowId: 5, ContentMemberType.RowId: 4 });

// Warning, expensive operation, as this has to cross-reference multiple data sets.
public static IEnumerable<ContentFinderCondition> GetLimitedAllianceRaidDuties(this IDataManager dataManager)
=> dataManager.GetLimitedDuties()
.Where(cfc => cfc is { ContentType.Row: 5, ContentMemberType.Row: 4 });
.Where(cfc => cfc is { ContentType.RowId: 5, ContentMemberType.RowId: 4 });

// Warning, expensive operation, as this has to cross-reference multiple data sets.
public static IEnumerable<ContentFinderCondition> GetLimitedSavageRaidDuties(this IDataManager dataManager)
=> dataManager.GetLimitedDuties()
.Where(cfc => cfc is { ContentType.Row: 5 })
.Where(cfc => cfc.Name.RawString.Contains("Savage"));
.Where(cfc => cfc is { ContentType.RowId: 5 })
.Where(cfc => cfc.Name.ExtractText().Contains("Savage"));

// Warning, expensive operation, as this has to cross-reference multiple data sets.
public static IEnumerable<ContentFinderCondition> GetLimitedNormalRaidDuties(this IDataManager dataManager)
=> dataManager.GetLimitedDuties()
.Where(cfc => cfc is { ContentType.Row: 5 })
.Where(cfc => !cfc.Name.RawString.Contains("Savage"));
.Where(cfc => cfc is { ContentType.RowId: 5 })
.Where(cfc => !cfc.Name.ExtractText().Contains("Savage"));

private static IEnumerable<ContentFinderCondition> GetLimitedDuties(this IDataManager dataManager)
=> dataManager.GetExcelSheet<ContentFinderCondition>()?
.Where(cfc => dataManager.GetExcelSheet<InstanceContent>()?
.Where(instanceContent => instanceContent is { WeekRestriction: 1 })
.Select(instanceContent => instanceContent.RowId)
.Contains(cfc.Content) ?? false) ?? [];
=> dataManager.GetExcelSheet<ContentFinderCondition>()
.Where(cfc => dataManager.GetExcelSheet<InstanceContent>()
.Where(instanceContent => instanceContent is { WeekRestriction: 1 })
.Select(instanceContent => instanceContent.RowId)
.Contains(cfc.Content.RowId));

public static DutyType GetDutyType(this IDataManager dataManager, ContentFinderCondition cfc) {
var englishCfc = dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English)!.GetRow(cfc.RowId);
var englishCfc = dataManager.GetExcelSheet<ContentFinderCondition>(ClientLanguage.English).GetRow(cfc.RowId);

return englishCfc switch {
{ ContentType.Row: 5 } when englishCfc.Name.ToString().Contains("Savage") => DutyType.Savage,
{ ContentType.Row: 28 } => DutyType.Ultimate,
{ ContentType.Row: 4, HighEndDuty: false } when englishCfc.Name.ToString().Contains("Extreme") => DutyType.Extreme,
{ ContentType.Row: 4, HighEndDuty: true } => DutyType.Unreal,
{ ContentType.Row: 30, AllowUndersized: false } => DutyType.Criterion,
{ ContentType.Row: 5, ContentMemberType.Row: 4 } => DutyType.Alliance,
{ ContentType.RowId: 5 } when englishCfc.Name.ToString().Contains("Savage") => DutyType.Savage,
{ ContentType.RowId: 28 } => DutyType.Ultimate,
{ ContentType.RowId: 4, HighEndDuty: false } when englishCfc.Name.ToString().Contains("Extreme") => DutyType.Extreme,
{ ContentType.RowId: 4, HighEndDuty: true } => DutyType.Unreal,
{ ContentType.RowId: 30, AllowUndersized: false } => DutyType.Criterion,
{ ContentType.RowId: 5, ContentMemberType.RowId: 4 } => DutyType.Alliance,
_ => DutyType.Unknown,
};
}

public static unsafe DutyType GetCurrentDutyType(this IDataManager dataManager) {
var cfc = dataManager.GetExcelSheet<ContentFinderCondition>()!.GetRow(GameMain.Instance()->CurrentContentFinderConditionId);
if (cfc is null) return DutyType.Unknown;

var cfc = dataManager.GetExcelSheet<ContentFinderCondition>().GetRow(GameMain.Instance()->CurrentContentFinderConditionId);
return dataManager.GetDutyType(cfc);
}
}
24 changes: 12 additions & 12 deletions Extensions/TerritoryTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
using Dalamud.Utility;
using ImGuiNET;
using KamiLib.Classes;
using Lumina.Excel.GeneratedSheets2;
using TerritoryType = Lumina.Excel.GeneratedSheets.TerritoryType;
using Lumina.Excel.Sheets;
using TerritoryType = Lumina.Excel.Sheets.TerritoryType;

namespace KamiLib.Extensions;

Expand All @@ -32,7 +32,7 @@ private static void DrawTerritoryImage(TerritoryType option, IDataManager dataMa
using var imageFrame = ImRaii.Child($"image_frame{option}", ImGuiHelpers.ScaledVector2(Width * ImGuiHelpers.GlobalScale, Height), false, ImGuiWindowFlags.NoInputs);
if (!imageFrame) return;

if (dataManager.GetExcelSheet<LoadingImage>()!.GetRow(option.LoadingImage) is { } loadingImageInfo) {
if (dataManager.GetExcelSheet<LoadingImage>().GetRow(option.LoadingImage.RowId) is var loadingImageInfo) {
if (textureProvider.GetFromGame($"ui/loadingimage/{loadingImageInfo.Unknown0}_hr1.tex").GetWrapOrDefault() is { } texture) {
ImGui.Image(texture.ImGuiHandle, ImGuiHelpers.ScaledVector2(Width, Height), new Vector2(0.15f, 0.15f), new Vector2(0.85f, 0.85f));
}
Expand All @@ -54,9 +54,9 @@ private static void DrawTerritoryInfo(TerritoryType option, IDataManager dataMan
ImGui.TableSetupColumn("##column1", ImGuiTableColumnFlags.None, 1.0f);
ImGui.TableSetupColumn("##column2", ImGuiTableColumnFlags.None, 1.0f);

var placeName = option.PlaceName.Value?.Name ?? "Unknown PlaceName";
var zoneName = option.PlaceNameZone.Value?.Name;
var regionName = option.PlaceNameRegion.Value?.Name;
var placeName = option.PlaceName.Value.Name.ExtractText();
var zoneName = option.PlaceNameZone.Value.Name.ExtractText();
var regionName = option.PlaceNameRegion.Value.Name.ExtractText();

ImGui.TableNextColumn();
ImGui.TextUnformatted(placeName);
Expand All @@ -68,25 +68,25 @@ private static void DrawTerritoryInfo(TerritoryType option, IDataManager dataMan
ImGui.TableNextColumn();

using var grayColor = ImRaii.PushColor(ImGuiCol.Text, KnownColor.DarkGray.Vector());
if (zoneName is not null && !zoneName.ToString().IsNullOrEmpty() && regionName is not null && !regionName.ToString().IsNullOrEmpty()) {
if (!zoneName.IsNullOrEmpty() && !regionName.IsNullOrEmpty()) {
ImGui.TextUnformatted($"{regionName}, {zoneName}");
}
else if (zoneName is not null && !zoneName.ToString().IsNullOrEmpty()) {
else if (!zoneName.IsNullOrEmpty()) {
ImGui.TextUnformatted($"{zoneName}");
}
else if (regionName is not null && !regionName.ToString().IsNullOrEmpty()) {
else if (!regionName.IsNullOrEmpty()) {
ImGui.TextUnformatted($"{regionName}");
}

ImGui.TableNextColumn();
ImGui.TextUnformatted($"{((TerritoryIntendedUseEnum)option.TerritoryIntendedUse).GetDescription()}");
ImGui.TextUnformatted($"{((TerritoryIntendedUseEnum)option.TerritoryIntendedUse.RowId).GetDescription()}");

ImGui.TableNextColumn();
if (ContentFinderConditionMap.ContainsKey(option.RowId) && ContentFinderConditionMap.TryGetValue(option.RowId, out var cfc) && cfc is not null) {
ImGui.TextUnformatted($"{CultureInfo.CurrentCulture.TextInfo.ToTitleCase(cfc.Name)}");
ImGui.TextUnformatted($"{CultureInfo.CurrentCulture.TextInfo.ToTitleCase(cfc.Value.Name.ExtractText())}");
}
else if (!ContentFinderConditionMap.ContainsKey(option.RowId)) {
ContentFinderConditionMap.TryAdd(option.RowId, dataManager.GetExcelSheet<ContentFinderCondition>()!.FirstOrDefault(contentFinderCondition => contentFinderCondition.TerritoryType.Row == option.RowId));
ContentFinderConditionMap.TryAdd(option.RowId, dataManager.GetExcelSheet<ContentFinderCondition>().FirstOrDefault(contentFinderCondition => contentFinderCondition.TerritoryType.RowId == option.RowId));
}
}
}
2 changes: 1 addition & 1 deletion Extensions/UiColorExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Numerics;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Extensions;

Expand Down
2 changes: 1 addition & 1 deletion KamiLib.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Dalamud.NET.Sdk/10.0.0">
<Project Sdk="Dalamud.NET.Sdk/11.0.0">
<ItemGroup>
<PackageReference Include="NetStone" Version="1.1.1" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions Window/SelectionWindows/CollectableItemSelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Window.SelectionWindows;

Expand All @@ -20,7 +20,7 @@ public CollectableItemSelectionWindow(IDalamudPluginInterface pluginInterface) :
pluginInterface.Inject(this);

SelectionOptions = DataManager
.GetExcelSheet<Item>()!
.GetExcelSheet<Item>()
.Where(item => !item.Name.ToString().IsNullOrEmpty())
.Where(item => item.IsCollectable)
.OrderBy(item => item.Name.ToString())
Expand All @@ -39,10 +39,10 @@ protected override void DrawSelection(Item option) {
ImGui.Image(texture.GetWrapOrEmpty().ImGuiHandle, ImGuiHelpers.ScaledVector2(30.0f, 30.0f));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPos().Y + 5.0f * ImGuiHelpers.GlobalScale);
ImGui.Text(option.Name);
ImGui.Text(option.Name.ExtractText());
}
}

protected override IEnumerable<string> GetFilterStrings(Item option)
=> [option.Name];
=> [option.Name.ExtractText()];
}
8 changes: 4 additions & 4 deletions Window/SelectionWindows/HighQualityItemSelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Window.SelectionWindows;

Expand All @@ -20,7 +20,7 @@ public HighQualityItemSelectionWindow(IDalamudPluginInterface pluginInterface) :
pluginInterface.Inject(this);

SelectionOptions = DataManager
.GetExcelSheet<Item>()!
.GetExcelSheet<Item>()
.Where(item => !item.Name.ToString().IsNullOrEmpty())
.Where(item => item.CanBeHq)
.OrderBy(item => item.Name.ToString())
Expand All @@ -39,10 +39,10 @@ protected override void DrawSelection(Item option) {
ImGui.Image(texture.GetWrapOrEmpty().ImGuiHandle, ImGuiHelpers.ScaledVector2(30.0f, 30.0f));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPos().Y + 5.0f * ImGuiHelpers.GlobalScale);
ImGui.Text(option.Name);
ImGui.Text(option.Name.ExtractText());
}
}

protected override IEnumerable<string> GetFilterStrings(Item option)
=> [option.Name];
=> [option.Name.ExtractText()];
}
8 changes: 4 additions & 4 deletions Window/SelectionWindows/ItemSelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Window.SelectionWindows;

Expand All @@ -20,7 +20,7 @@ public ItemSelectionWindow(IDalamudPluginInterface pluginInterface) : base(new V
pluginInterface.Inject(this);

SelectionOptions = DataManager
.GetExcelSheet<Item>()!
.GetExcelSheet<Item>()
.Where(item => !item.Name.ToString().IsNullOrEmpty())
.OrderBy(item => item.Name.ToString())
.ToList();
Expand All @@ -38,10 +38,10 @@ protected override void DrawSelection(Item option) {
ImGui.Image(texture.GetWrapOrEmpty().ImGuiHandle, ImGuiHelpers.ScaledVector2(30.0f, 30.0f));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPos().Y + 5.0f * ImGuiHelpers.GlobalScale);
ImGui.Text(option.Name);
ImGui.Text(option.Name.ExtractText());
}
}

protected override IEnumerable<string> GetFilterStrings(Item option)
=> [option.Name];
=> [option.Name.ExtractText()];
}
8 changes: 4 additions & 4 deletions Window/SelectionWindows/ItemUICategorySelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using Dalamud.Plugin.Services;
using Dalamud.Utility;
using ImGuiNET;
using Lumina.Excel.GeneratedSheets;
using Lumina.Excel.Sheets;

namespace KamiLib.Window.SelectionWindows;

Expand All @@ -19,7 +19,7 @@ public ItemUiCategorySelectionWindow(IDalamudPluginInterface pluginInterface) :
pluginInterface.Inject(this);

SelectionOptions = DataManager
.GetExcelSheet<ItemUICategory>()!
.GetExcelSheet<ItemUICategory>()
.Where(item => !item.Name.ToString().IsNullOrEmpty())
.OrderBy(item => item.OrderMajor)
.ThenBy(item => item.OrderMinor)
Expand All @@ -34,10 +34,10 @@ protected override void DrawSelection(ItemUICategory option) {
ImGui.Image(texture.GetWrapOrEmpty().ImGuiHandle, ImGuiHelpers.ScaledVector2(30.0f, 30.0f));
ImGui.SameLine();
ImGui.SetCursorPosY(ImGui.GetCursorPos().Y + 5.0f * ImGuiHelpers.GlobalScale);
ImGui.Text(option.Name);
ImGui.Text(option.Name.ExtractText());
}
}

protected override IEnumerable<string> GetFilterStrings(ItemUICategory option)
=> [option.Name];
=> [option.Name.ExtractText()];
}
8 changes: 4 additions & 4 deletions Window/SelectionWindows/TerritorySelectionWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Dalamud.Plugin;
using Dalamud.Plugin.Services;
using KamiLib.Extensions;
using TerritoryType = Lumina.Excel.GeneratedSheets.TerritoryType;
using Lumina.Excel.Sheets;

namespace KamiLib.Window.SelectionWindows;

Expand All @@ -17,8 +17,8 @@ public class TerritorySelectionWindow : SelectionWindowBase<TerritoryType> {
public TerritorySelectionWindow(IDalamudPluginInterface pluginInterface) :base(new Vector2(600.0f, 600.0f)) {
pluginInterface.Inject(this);

SelectionOptions = DataManager.GetExcelSheet<TerritoryType>()!
.Where(territory => territory is { PlaceName.Row: not 0, LoadingImage: not 0 })
SelectionOptions = DataManager.GetExcelSheet<TerritoryType>()
.Where(territory => territory is { PlaceName.RowId: not 0, LoadingImage.RowId: not 0 })
.ToList();
}

Expand All @@ -29,5 +29,5 @@ protected override void DrawSelection(TerritoryType option)
=> option.Draw(DataManager, TextureProvider);

protected override IEnumerable<string> GetFilterStrings(TerritoryType option)
=> [option.PlaceName?.Value?.Name.ToString() ?? string.Empty];
=> [option.PlaceName.Value.Name.ExtractText()];
}
Loading

0 comments on commit dccc432

Please sign in to comment.