From 144616456392d727501a2057a7fc3916418ffddb Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Mon, 2 Sep 2024 00:53:22 -0700 Subject: implement basic postmatch toast and chat message reports --- Malmstone/Plugin.cs | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Malmstone/Plugin.cs') diff --git a/Malmstone/Plugin.cs b/Malmstone/Plugin.cs index 6f5e50c..20c3ad7 100644 --- a/Malmstone/Plugin.cs +++ b/Malmstone/Plugin.cs @@ -11,6 +11,7 @@ using Dalamud.Game.Text.SeStringHandling.Payloads; using System.Collections.Generic; using System.Linq; using Malmstone.Utils; +using Malmstone.Addons; namespace Malmstone; @@ -20,6 +21,8 @@ public sealed class Plugin : IDalamudPlugin [PluginService] internal static ITextureProvider TextureProvider { get; private set; } = null!; [PluginService] internal static ICommandManager CommandManager { get; private set; } = null!; [PluginService] internal static IChatGui Chat { get; private set; } = null!; + [PluginService] internal static IAddonLifecycle AddonLifeCycle { get; private set; } = null!; + [PluginService] internal static IToastGui ToastGui { get; private set; } = null!; private const string CommandName = "/pmalm"; @@ -28,7 +31,9 @@ public sealed class Plugin : IDalamudPlugin public readonly WindowSystem WindowSystem = new("Malmstone"); private ConfigWindow ConfigWindow { get; init; } private MainWindow MainWindow { get; init; } + internal readonly PvPService PvPService; + internal PvPMatchAddon PvPAddon; public Plugin() { @@ -37,6 +42,9 @@ public sealed class Plugin : IDalamudPlugin ConfigWindow = new ConfigWindow(this); MainWindow = new MainWindow(this); PvPService = new PvPService(); + PvPAddon = new PvPMatchAddon(this); + PvPAddon.EnableCrystallineConflictPostMatch(); + PvPAddon.EnableRivalWingsPostMatch(); WindowSystem.AddWindow(ConfigWindow); WindowSystem.AddWindow(MainWindow); -- cgit v1.2.3 From fcecdca25688aca015d352602b7daf2610522d97 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Mon, 2 Sep 2024 20:34:32 -0700 Subject: add configuration options for showing different toast types --- Malmstone/Addons/PvPMatchAddon.cs | 24 ++++++++++++++++++++---- Malmstone/Configuration.cs | 1 + Malmstone/Plugin.cs | 14 +++++++++++--- Malmstone/Windows/ConfigWindow.cs | 24 +++++++++++++++++++++++- 4 files changed, 55 insertions(+), 8 deletions(-) (limited to 'Malmstone/Plugin.cs') diff --git a/Malmstone/Addons/PvPMatchAddon.cs b/Malmstone/Addons/PvPMatchAddon.cs index 69c16e0..94d35b0 100644 --- a/Malmstone/Addons/PvPMatchAddon.cs +++ b/Malmstone/Addons/PvPMatchAddon.cs @@ -89,14 +89,30 @@ namespace Malmstone.Addons private void ShowSeriesProgressionToast(PvPSeriesInfo seriesInfo) { - Plugin.ToastGui.ShowNormal("Series Level " + seriesInfo.CurrentSeriesRank + - " " + seriesInfo.SeriesExperience + "/" + MalmstoneXPCalculator.GetXPTargetForCurrentLevel(seriesInfo.CurrentSeriesRank) + " EXP"); + switch (Plugin.Configuration.PostmatchProgressionToastType) + { + case 0: + Plugin.ToastGui.ShowNormal("Series Level " + seriesInfo.CurrentSeriesRank + + " " + seriesInfo.SeriesExperience + "/" + MalmstoneXPCalculator.GetXPTargetForCurrentLevel(seriesInfo.CurrentSeriesRank) + " EXP"); + break; + case 1: + Plugin.ToastGui.ShowQuest("Series Level " + seriesInfo.CurrentSeriesRank + + " " + seriesInfo.SeriesExperience + "/" + MalmstoneXPCalculator.GetXPTargetForCurrentLevel(seriesInfo.CurrentSeriesRank) + " EXP"); + break; + case 2: + Plugin.ToastGui.ShowError("Series Level " + seriesInfo.CurrentSeriesRank + + " " + seriesInfo.SeriesExperience + "/" + MalmstoneXPCalculator.GetXPTargetForCurrentLevel(seriesInfo.CurrentSeriesRank) + " EXP"); + break; + default: + Plugin.ToastGui.ShowNormal("Series Level " + seriesInfo.CurrentSeriesRank + + " " + seriesInfo.SeriesExperience + "/" + MalmstoneXPCalculator.GetXPTargetForCurrentLevel(seriesInfo.CurrentSeriesRank) + " EXP"); + break; + } + } private void ShowSeriesProgressionMessage(PvPSeriesInfo seriesInfo, PvPContentType contentType) { - Plugin.Chat.Print("Series Level " + seriesInfo.CurrentSeriesRank + - " - " + seriesInfo.SeriesExperience + "/" + MalmstoneXPCalculator.GetXPTargetForCurrentLevel(seriesInfo.CurrentSeriesRank) + " EXP"); var seString = new SeString(new List()); switch (contentType) { diff --git a/Malmstone/Configuration.cs b/Malmstone/Configuration.cs index a353e88..ce87dfd 100644 --- a/Malmstone/Configuration.cs +++ b/Malmstone/Configuration.cs @@ -10,6 +10,7 @@ public class Configuration : IPluginConfiguration public int Version { get; set; } = 0; public int DefaultTargetRankProperty { get; set; } = 1; + public int PostmatchProgressionToastType { get; set; } = 0; // 0 = normal, 1=quest, 2=error public bool ShowProgressionToastPostMatch { get; set; } = true; public bool ShowProgressionChatPostRW { get; set; } = true; public bool ShowProgressionChatPostCC { get; set; } = true; diff --git a/Malmstone/Plugin.cs b/Malmstone/Plugin.cs index 20c3ad7..4a387ec 100644 --- a/Malmstone/Plugin.cs +++ b/Malmstone/Plugin.cs @@ -43,10 +43,18 @@ public sealed class Plugin : IDalamudPlugin MainWindow = new MainWindow(this); PvPService = new PvPService(); PvPAddon = new PvPMatchAddon(this); - PvPAddon.EnableCrystallineConflictPostMatch(); - PvPAddon.EnableRivalWingsPostMatch(); + if (Configuration.ShowProgressionChatPostCC) + PvPAddon.EnableCrystallineConflictPostMatch(); + if (Configuration.ShowProgressionChatPostRW) + PvPAddon.EnableRivalWingsPostMatch(); + if (Configuration.ShowProgressionChatPostFL) + PvPAddon.EnableFrontlinePostMatch(); + if (Configuration.PostmatchProgressionToastType < 0 || Configuration.PostmatchProgressionToastType > 2) + { + Configuration.PostmatchProgressionToastType = 0; + } - WindowSystem.AddWindow(ConfigWindow); + WindowSystem.AddWindow(ConfigWindow); WindowSystem.AddWindow(MainWindow); CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand) diff --git a/Malmstone/Windows/ConfigWindow.cs b/Malmstone/Windows/ConfigWindow.cs index 494c7cc..37b9490 100644 --- a/Malmstone/Windows/ConfigWindow.cs +++ b/Malmstone/Windows/ConfigWindow.cs @@ -9,6 +9,7 @@ public class ConfigWindow : Window, IDisposable { private Configuration Configuration; private Plugin Plugin; + private string[] ToastOptions = {"Normal", "Quest", "Error"}; public ConfigWindow(Plugin Plugin) : base("Malmstone Config") { @@ -40,6 +41,7 @@ public class ConfigWindow : Window, IDisposable ImGui.Separator(); ImGui.Text("Show XP to next level after PVP matches"); + ImGui.SameLine(); var showProgressionToastPostMatch = Configuration.ShowProgressionToastPostMatch; if (ImGui.Checkbox("##ShowProgressionToastPostMatch", ref showProgressionToastPostMatch)) { @@ -47,8 +49,28 @@ public class ConfigWindow : Window, IDisposable Configuration.Save(); } + ImGui.Text("Notification Type"); + int selectedPostMatchToastType = Configuration.PostmatchProgressionToastType; + if (ImGui.Combo("##MatchOptions", ref selectedPostMatchToastType, ToastOptions, ToastOptions.Length)) + { + switch (selectedPostMatchToastType) + { + case 0: + Plugin.ToastGui.ShowNormal("[Malmstone Calculator] Normal Toast Selected"); + break; + case 1: + Plugin.ToastGui.ShowQuest("[Malmstone Calculator] Quest Toast Selected"); + break; + case 2: + Plugin.ToastGui.ShowError("[Malmstone Calculator] Error Toast Selected"); + break; + } + Configuration.PostmatchProgressionToastType = selectedPostMatchToastType; + Configuration.Save(); + } + ImGui.Separator(); - ImGui.Text("Show matches to next rank in chat postmatch"); + ImGui.Text("Show matches until next rank in chat after"); var showCCMatchesRemainingPostGame = Configuration.ShowProgressionChatPostCC; -- cgit v1.2.3 From 04b359033329d4bcd21b574e601601ffff135ff5 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 3 Sep 2024 16:36:53 -0700 Subject: move post match toast notification to record presetup - fixes and simplifies issue with managing different config combinations --- Malmstone/Addons/PvPMatchAddon.cs | 31 ++++++++++++++++++++----------- Malmstone/Plugin.cs | 2 ++ Malmstone/Windows/ConfigWindow.cs | 6 +++++- 3 files changed, 27 insertions(+), 12 deletions(-) (limited to 'Malmstone/Plugin.cs') diff --git a/Malmstone/Addons/PvPMatchAddon.cs b/Malmstone/Addons/PvPMatchAddon.cs index 7912665..0acb617 100644 --- a/Malmstone/Addons/PvPMatchAddon.cs +++ b/Malmstone/Addons/PvPMatchAddon.cs @@ -22,6 +22,20 @@ namespace Malmstone.Addons this.Plugin = Plugin; } + public void EnablePostMatchProgressionToast() + { + Plugin.AddonLifeCycle.RegisterListener(AddonEvent.PreSetup, "MKSRecord", ShowSeriesProgressionToast); + Plugin.AddonLifeCycle.RegisterListener(AddonEvent.PreSetup, "FrontlineRecord", ShowSeriesProgressionToast); + Plugin.AddonLifeCycle.RegisterListener(AddonEvent.PreSetup, "ManeuversRecord", ShowSeriesProgressionToast); + } + + public void DisablePostMatchProgressionToast() + { + Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PreSetup, "MKSRecord", ShowSeriesProgressionToast); + Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PreSetup, "FrontlineRecord", ShowSeriesProgressionToast); + Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PreSetup, "ManeuversRecord", ShowSeriesProgressionToast); + } + public void EnableCrystallineConflictPostMatch() { Plugin.AddonLifeCycle.RegisterListener(AddonEvent.PostSetup, "MKSRecord", OnCrystallineConflictRecordTrigger); @@ -29,7 +43,7 @@ namespace Malmstone.Addons public void DisableCrystallineConflictPostMatch() { - Plugin.AddonLifeCycle.UnregisterListener(OnCrystallineConflictRecordTrigger); + Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PostSetup, "MKSRecord", OnCrystallineConflictRecordTrigger); } public void EnableFrontlinePostMatch() @@ -39,7 +53,7 @@ namespace Malmstone.Addons public void DisableFrontlinePostMatch() { - Plugin.AddonLifeCycle.UnregisterListener(OnFrontlineRecordTrigger); + Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PostSetup, "FrontlineRecord", OnFrontlineRecordTrigger); } public void EnableRivalWingsPostMatch() @@ -48,7 +62,7 @@ namespace Malmstone.Addons } public void DisableRivalWingsPostMatch() { - Plugin.AddonLifeCycle.UnregisterListener(OnRivalWingsRecordTrigger); + Plugin.AddonLifeCycle.UnregisterListener(AddonEvent.PostSetup, "ManeuversRecord", OnRivalWingsRecordTrigger); } @@ -57,8 +71,6 @@ namespace Malmstone.Addons { PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo(); if (seriesInfo == null) return; - if (Plugin.Configuration.ShowProgressionToastPostMatch) - ShowSeriesProgressionToast(seriesInfo); if (Plugin.Configuration.ShowProgressionChatPostCC) ShowSeriesProgressionMessage(seriesInfo, PvPContentType.CrystallineConflict); } @@ -67,8 +79,6 @@ namespace Malmstone.Addons { PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo(); if (seriesInfo == null) return; - if (Plugin.Configuration.ShowProgressionToastPostMatch) - ShowSeriesProgressionToast(seriesInfo); if (Plugin.Configuration.ShowProgressionChatPostFL) ShowSeriesProgressionMessage(seriesInfo, PvPContentType.RivalWings); } @@ -77,15 +87,14 @@ namespace Malmstone.Addons { PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo(); if (seriesInfo == null) return; - if (Plugin.Configuration.ShowProgressionToastPostMatch) - ShowSeriesProgressionToast(seriesInfo); if (Plugin.Configuration.ShowProgressionChatPostRW) ShowSeriesProgressionMessage(seriesInfo, PvPContentType.RivalWings); } - - private void ShowSeriesProgressionToast(PvPSeriesInfo seriesInfo) + private void ShowSeriesProgressionToast(AddonEvent eventType, AddonArgs addonInfo) { + PvPSeriesInfo? seriesInfo = Plugin.PvPService.GetPvPSeriesInfo(); + if (seriesInfo == null) return; switch (Plugin.Configuration.PostmatchProgressionToastType) { case 0: diff --git a/Malmstone/Plugin.cs b/Malmstone/Plugin.cs index 4a387ec..b2cfde7 100644 --- a/Malmstone/Plugin.cs +++ b/Malmstone/Plugin.cs @@ -49,6 +49,8 @@ public sealed class Plugin : IDalamudPlugin PvPAddon.EnableRivalWingsPostMatch(); if (Configuration.ShowProgressionChatPostFL) PvPAddon.EnableFrontlinePostMatch(); + if (Configuration.ShowProgressionToastPostMatch) + PvPAddon.EnablePostMatchProgressionToast(); if (Configuration.PostmatchProgressionToastType < 0 || Configuration.PostmatchProgressionToastType > 2) { Configuration.PostmatchProgressionToastType = 0; diff --git a/Malmstone/Windows/ConfigWindow.cs b/Malmstone/Windows/ConfigWindow.cs index 9858b7e..e6376b3 100644 --- a/Malmstone/Windows/ConfigWindow.cs +++ b/Malmstone/Windows/ConfigWindow.cs @@ -43,12 +43,16 @@ public class ConfigWindow : Window, IDisposable ImGui.Separator(); - ImGui.Text("Show XP to next level after PVP matches"); + ImGui.Text("Show EXP progression after PVP matches"); ImGui.SameLine(); var showProgressionToastPostMatch = Configuration.ShowProgressionToastPostMatch; if (ImGui.Checkbox("##ShowProgressionToastPostMatch", ref showProgressionToastPostMatch)) { Configuration.ShowProgressionToastPostMatch = showProgressionToastPostMatch; + if (showProgressionToastPostMatch) + Plugin.PvPAddon.EnablePostMatchProgressionToast(); + else + Plugin.PvPAddon.DisablePostMatchProgressionToast(); Configuration.Save(); } -- cgit v1.2.3