diff --git a/CBT/CBT.csproj b/CBT/CBT.csproj index 54663c8..9a68938 100644 --- a/CBT/CBT.csproj +++ b/CBT/CBT.csproj @@ -3,7 +3,7 @@ cultbaus - - 0.0.3.10 + 0.0.3.11 This plugin manipulates flytext. - https://github.com/cultbaus/CBT diff --git a/CBT/Interface/Tabs/KindTab.cs b/CBT/Interface/Tabs/KindTab.cs index f6b3ed9..88b6a4b 100644 --- a/CBT/Interface/Tabs/KindTab.cs +++ b/CBT/Interface/Tabs/KindTab.cs @@ -48,6 +48,23 @@ public class KindTab : Tab } } + if (this.Current.InCategory(FlyTextCategory.AutoAttack)) + { + GuiArtist.DrawLabelPrefix("Configure for", sameLine: false); + ImGui.SameLine(); + var isTaken = this.UsePlayerAutoAttackTakenConfig; + if (ImGui.RadioButton("Player AutoAttack Dealt", !isTaken)) + { + this.UsePlayerAutoAttackTakenConfig = false; + } + + ImGui.SameLine(); + if (ImGui.RadioButton("Player AutoAttack Taken", isTaken)) + { + this.UsePlayerAutoAttackTakenConfig = true; + } + } + if (this.CurrentEnabled) { this.DrawFontConfigurations(); diff --git a/CBT/Interface/Tabs/Tab.cs b/CBT/Interface/Tabs/Tab.cs index 3527902..37da773 100644 --- a/CBT/Interface/Tabs/Tab.cs +++ b/CBT/Interface/Tabs/Tab.cs @@ -32,6 +32,11 @@ public abstract class Tab /// protected bool UsePlayerDamageTakenConfig { get; set; } + /// + /// When true and current kind is AutoAttack, configuration edits apply to Player AutoAttack Taken instead of Dealt. + /// + protected bool UsePlayerAutoAttackTakenConfig { get; set; } + /// /// Gets or sets a value indicating whether. /// @@ -241,7 +246,7 @@ public abstract class Tab public abstract void OnClose(); /// - /// Gets the config dictionary to use for the current kind (FlyTextKinds or FlyTextKindsPlayerDamageTaken for AbilityDamage when editing Taken). + /// Gets the config dictionary to use for the current kind (FlyTextKinds or the appropriate Player * Taken dict when editing Taken). /// protected Dictionary GetCurrentConfigDictionary() { @@ -251,6 +256,12 @@ public abstract class Tab return Service.Configuration.FlyTextKindsPlayerDamageTaken; } + if (this.Current.InCategory(FlyTextCategory.AutoAttack) && this.UsePlayerAutoAttackTakenConfig + && Service.Configuration.FlyTextKindsPlayerAutoAttackTaken != null) + { + return Service.Configuration.FlyTextKindsPlayerAutoAttackTaken; + } + return Service.Configuration.FlyTextKinds; } diff --git a/CBT/Plugin.cs b/CBT/Plugin.cs index d37773f..ae57d88 100644 --- a/CBT/Plugin.cs +++ b/CBT/Plugin.cs @@ -92,7 +92,7 @@ public sealed partial class Plugin : IDalamudPlugin => this.configWindow.IsOpen = true; /// - /// Migrates existing config: ensures FlyTextKindsPlayerDamageTaken is populated for AbilityDamage kinds (e.g. from older saves). + /// Migrates existing config: ensures FlyTextKindsPlayerDamageTaken and FlyTextKindsPlayerAutoAttackTaken are populated (e.g. from older saves). /// private static void MigratePlayerDamageTakenConfig() { @@ -112,6 +112,22 @@ public sealed partial class Plugin : IDalamudPlugin } } } + + if (config.FlyTextKindsPlayerAutoAttackTaken == null || config.FlyTextKindsPlayerAutoAttackTaken.Count == 0) + { + config.FlyTextKindsPlayerAutoAttackTaken = []; + foreach (var kind in FlyTextCategoryExtension.GetKindsFor(FlyTextCategory.AutoAttack)) + { + if (config.FlyTextKinds.TryGetValue(kind, out var existing)) + { + config.FlyTextKindsPlayerAutoAttackTaken[kind] = new FlyTextConfiguration(existing); + } + else + { + config.FlyTextKindsPlayerAutoAttackTaken[kind] = new FlyTextConfiguration(); + } + } + } } /// diff --git a/CBT/PluginConfiguration.cs b/CBT/PluginConfiguration.cs index 2e194d6..bac6eca 100644 --- a/CBT/PluginConfiguration.cs +++ b/CBT/PluginConfiguration.cs @@ -68,6 +68,12 @@ public class PluginConfiguration : IPluginConfiguration kind => kind, kind => new FlyTextConfiguration()); + this.FlyTextKindsPlayerAutoAttackTaken = FlyTextCategoryExtension + .GetKindsFor(FlyTextCategory.AutoAttack) + .ToDictionary( + kind => kind, + kind => new FlyTextConfiguration()); + FlyTextCategory.AbilityDamage .ForEachKind(kind => { @@ -90,6 +96,9 @@ public class PluginConfiguration : IPluginConfiguration { this.FlyTextKinds[kind].Font.Color = new Vector4(1, 1, 1, 1); this.FlyTextKinds[kind].Font.Size = 18f; + + this.FlyTextKindsPlayerAutoAttackTaken[kind].Font.Color = new Vector4(1, 1, 1, 1); + this.FlyTextKindsPlayerAutoAttackTaken[kind].Font.Size = 18f; }); FlyTextCategory.AbilityHealing @@ -179,6 +188,27 @@ public class PluginConfiguration : IPluginConfiguration this.FlyTextKindsPlayerDamageTaken[kind].Filter.Self = false; } }); + + FlyTextCategoryExtension + .GetKindsFor(FlyTextCategory.AutoAttack) + .ToList() + .ForEach(kind => + { + if (kind.ShouldFilter(FlyTextFilter.Party)) + { + this.FlyTextKindsPlayerAutoAttackTaken[kind].Filter.Party = false; + } + + if (kind.ShouldFilter(FlyTextFilter.Enemy)) + { + this.FlyTextKindsPlayerAutoAttackTaken[kind].Filter.Enemy = false; + } + + if (kind.ShouldFilter(FlyTextFilter.Self)) + { + this.FlyTextKindsPlayerAutoAttackTaken[kind].Filter.Self = false; + } + }); } /// @@ -197,6 +227,12 @@ public class PluginConfiguration : IPluginConfiguration /// public Dictionary FlyTextKindsPlayerDamageTaken { get; set; } = []; + /// + /// Gets or sets the configuration for auto attack when the player is the target (auto attack taken). + /// When the player deals auto attack, is used; when the player takes auto attack, this is used. + /// + public Dictionary FlyTextKindsPlayerAutoAttackTaken { get; set; } = []; + /// /// Gets or sets the FlyTextCategory Category Configuration options. /// diff --git a/CBT/PluginManager.cs b/CBT/PluginManager.cs index d6edd0d..e8e2506 100644 --- a/CBT/PluginManager.cs +++ b/CBT/PluginManager.cs @@ -104,7 +104,7 @@ public unsafe partial class PluginManager => Service.Configuration.FlyTextKinds.TryGetValue(kind, out var config) ? config : null; /// - /// Get the config for an event. For AbilityDamage kinds, returns Player Damage Taken config when the player is the target, otherwise the normal (Dealt) config. + /// Get the config for an event. For AbilityDamage kinds, returns Player Damage Taken config when the player is the target; for AutoAttack, returns Player AutoAttack Taken config when the player is the target; otherwise the normal (Dealt) config. /// /// Kind of the event. /// Source character. @@ -112,12 +112,19 @@ public unsafe partial class PluginManager /// The configuration to use for this event. public static FlyTextConfiguration? GetConfigForEvent(FlyTextKind kind, Character* source, Character* target) { - if (kind.InCategory(FlyTextCategory.AbilityDamage) - && target != null - && IsPlayerCharacter(target) - && Service.Configuration.FlyTextKindsPlayerDamageTaken?.TryGetValue(kind, out var takenConfig) == true) + if (target != null && IsPlayerCharacter(target)) { - return takenConfig; + if (kind.InCategory(FlyTextCategory.AbilityDamage) + && Service.Configuration.FlyTextKindsPlayerDamageTaken?.TryGetValue(kind, out var damageTakenConfig) == true) + { + return damageTakenConfig; + } + + if (kind.InCategory(FlyTextCategory.AutoAttack) + && Service.Configuration.FlyTextKindsPlayerAutoAttackTaken?.TryGetValue(kind, out var autoAttackTakenConfig) == true) + { + return autoAttackTakenConfig; + } } return GetConfigForKind(kind);