Skip to content

Commit

Permalink
API10 updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
awgil committed Jun 30, 2024
1 parent fa74094 commit b0568e8
Show file tree
Hide file tree
Showing 15 changed files with 489 additions and 497 deletions.
2 changes: 1 addition & 1 deletion BossMod/AI/AIBehaviour.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private NavigationDecision BuildNavigationDecision(Actor player, Actor master, r

private void FocusMaster(Actor master)
{
bool masterChanged = Service.TargetManager.FocusTarget?.ObjectId != master.InstanceID;
bool masterChanged = Service.TargetManager.FocusTarget?.EntityId != master.InstanceID;
if (masterChanged)
{
ctrl.SetFocusTarget(master);
Expand Down
2 changes: 1 addition & 1 deletion BossMod/AI/AIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void Clear()

public void SetFocusTarget(Actor? actor)
{
if (Service.TargetManager.FocusTarget?.ObjectId != actor?.InstanceID)
if (Service.TargetManager.FocusTarget?.EntityId != actor?.InstanceID)
Service.TargetManager.FocusTarget = actor != null ? Service.ObjectTable.SearchById((uint)actor.InstanceID) : null;
}

Expand Down
2 changes: 1 addition & 1 deletion BossMod/AI/AIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private int FindPartyMemberSlotFromSender(SeString sender)
return pm != null ? WorldState.Party.ContentIDs.IndexOf((ulong)pm.ContentId) : -1;
}

private void OnChatMessage(XivChatType type, uint senderId, ref SeString sender, ref SeString message, ref bool isHandled)
private void OnChatMessage(XivChatType type, int timestamp, ref SeString sender, ref SeString message, ref bool isHandled)
{
if (!_config.Enabled || type != XivChatType.Party)
return;
Expand Down
2 changes: 1 addition & 1 deletion BossMod/BossMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="DalamudPackager" Version="2.1.12" />
<PackageReference Include="DalamudPackager" Version="2.1.13" />
<PackageReference Include="SharpDX.Mathematics" Version="4.2.0" />
<ProjectReference Include="..\CodeAnalysis\CodeAnalysis.csproj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
Expand Down
38 changes: 15 additions & 23 deletions BossMod/Config/ModuleViewer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ namespace BossMod;
public sealed class ModuleViewer : IDisposable
{
private record struct ModuleInfo(ModuleRegistry.Info Info, string Name, int SortOrder);
private record struct ModuleGroupInfo(string Name, uint Id, uint SortOrder, IDalamudTextureWrap? Icon = null);
private record struct ModuleGroupInfo(string Name, uint Id, uint SortOrder, uint Icon = 0);
private record struct ModuleGroup(ModuleGroupInfo Info, List<ModuleInfo> Modules);

private readonly PlanDatabase? _planDB;

private BitMask _filterExpansions;
private BitMask _filterCategories;

private readonly (string name, IDalamudTextureWrap? icon)[] _expansions;
private readonly (string name, IDalamudTextureWrap? icon)[] _categories;
private readonly IDalamudTextureWrap? _iconFATE;
private readonly IDalamudTextureWrap? _iconHunt;
private readonly (string name, uint icon)[] _expansions;
private readonly (string name, uint icon)[] _categories;
private readonly uint _iconFATE;
private readonly uint _iconHunt;
private readonly List<ModuleGroup>[,] _groups;
private readonly Vector2 _iconSize = new(30, 30);

public ModuleViewer(PlanDatabase? planDB)
{
_planDB = planDB;

var defaultIcon = GetIcon(61762);
uint defaultIcon = 61762;
_expansions = Enum.GetNames<BossModuleInfo.Expansion>().Take((int)BossModuleInfo.Expansion.Count).Select(n => (n, defaultIcon)).ToArray();
_categories = Enum.GetNames<BossModuleInfo.Category>().Take((int)BossModuleInfo.Category.Count).Select(n => (n, defaultIcon)).ToArray();

Expand Down Expand Up @@ -68,8 +68,8 @@ public ModuleViewer(PlanDatabase? planDB)
_categories[(int)BossModuleInfo.Category.Alliance].icon = _categories[(int)BossModuleInfo.Category.Raid].icon;
//_categories[(int)BossModuleInfo.Category.Event].icon = GetIcon(61757);

_iconFATE = GetIcon(contentType?.GetRow(8)?.Icon ?? 0);
_iconHunt = GetIcon((uint)(playStyle?.GetRow(10)?.Icon ?? 0));
_iconFATE = contentType?.GetRow(8)?.Icon ?? 0;
_iconHunt = (uint)(playStyle?.GetRow(10)?.Icon ?? 0);

_groups = new List<ModuleGroup>[(int)BossModuleInfo.Expansion.Count, (int)BossModuleInfo.Category.Count];
for (int i = 0; i < (int)BossModuleInfo.Expansion.Count; ++i)
Expand Down Expand Up @@ -112,12 +112,6 @@ public ModuleViewer(PlanDatabase? planDB)

public void Dispose()
{
foreach (var e in _expansions)
e.icon?.Dispose();
foreach (var c in _categories)
c.icon?.Dispose();
_iconFATE?.Dispose();
_iconHunt?.Dispose();
}

public void Draw(UITree tree, WorldState ws)
Expand Down Expand Up @@ -155,7 +149,7 @@ private void DrawExpansionFilters()
for (var e = BossModuleInfo.Expansion.RealmReborn; e < BossModuleInfo.Expansion.Count; ++e)
{
ref var expansion = ref _expansions[(int)e];
UIMisc.ImageToggleButton(expansion.icon, _iconSize, !_filterExpansions[(int)e], expansion.name);
UIMisc.ImageToggleButton(Service.Texture.GetFromGameIcon(expansion.icon), _iconSize, !_filterExpansions[(int)e], expansion.name);
if (ImGui.IsItemClicked())
{
_filterExpansions.Toggle((int)e);
Expand All @@ -173,7 +167,7 @@ private void DrawContentTypeFilters()
for (var c = BossModuleInfo.Category.Uncategorized; c < BossModuleInfo.Category.Count; ++c)
{
ref var category = ref _categories[(int)c];
UIMisc.ImageToggleButton(category.icon, _iconSize, !_filterCategories[(int)c], category.name);
UIMisc.ImageToggleButton(Service.Texture.GetFromGameIcon(category.icon), _iconSize, !_filterCategories[(int)c], category.name);
if (ImGui.IsItemClicked())
{
_filterCategories.Toggle((int)c);
Expand Down Expand Up @@ -205,9 +199,9 @@ private void DrawModules(UITree tree, WorldState ws)
{
ImGui.TableNextRow();
ImGui.TableNextColumn();
UIMisc.Image(_expansions[i].icon, new(36));
UIMisc.Image(Service.Texture.GetFromGameIcon(_expansions[i].icon), new(36));
ImGui.SameLine();
UIMisc.Image(group.Info.Icon ?? _categories[j].icon, new(36));
UIMisc.Image(Service.Texture.GetFromGameIcon(group.Info.Icon != 0 ? group.Info.Icon : _categories[j].icon), new(36));
ImGui.TableNextColumn();

foreach (var ng in tree.Node($"{group.Info.Name}###{i}/{j}/{group.Info.Id}"))
Expand Down Expand Up @@ -243,11 +237,9 @@ private void DrawModules(UITree tree, WorldState ws)
}
}

private void Customize((string name, IDalamudTextureWrap? icon)[] array, int element, uint iconId, SeString? name)
private void Customize((string name, uint icon)[] array, int element, uint iconId, SeString? name)
{
var icon = GetIcon(iconId);
if (icon != null)
array[element].icon = icon;
array[element].icon = iconId;
if (name != null)
array[element].name = name;
}
Expand All @@ -256,7 +248,7 @@ private void Customize((string name, IDalamudTextureWrap? icon)[] array, int ele
private void Customize(BossModuleInfo.Category category, ContentType? ct) => Customize(category, ct?.Icon ?? 0, ct?.Name);
private void Customize(BossModuleInfo.Category category, CharaCardPlayStyle? ps) => Customize(category, (uint)(ps?.Icon ?? 0), ps?.Name);

private static IDalamudTextureWrap? GetIcon(uint iconId) => iconId != 0 ? Service.Texture?.GetIcon(iconId, Dalamud.Plugin.Services.ITextureProvider.IconFlags.HiRes) : null;
//private static IDalamudTextureWrap? GetIcon(uint iconId) => iconId != 0 ? Service.Texture?.GetIcon(iconId, Dalamud.Plugin.Services.ITextureProvider.IconFlags.HiRes) : null;
private static string FixCase(SeString? str) => CultureInfo.InvariantCulture.TextInfo.ToTitleCase(str ?? "");
private static string BNpcName(uint id) => FixCase(Service.LuminaRow<BNpcName>(id)?.Singular);

Expand Down
Loading

0 comments on commit b0568e8

Please sign in to comment.