From d38b61089d8abcd9433cee230bbcc3884573e397 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20=C5=9Awierkot?= Date: Wed, 4 Aug 2021 23:51:59 +0200 Subject: [PATCH] Added Expedition league alerts --- PreloadAlert.cs | 90 ++++++++++++++++++++++++++++------------- PreloadAlertSettings.cs | 10 +++++ 2 files changed, 72 insertions(+), 28 deletions(-) diff --git a/PreloadAlert.cs b/PreloadAlert.cs index bf6fec6..0ffb9e6 100644 --- a/PreloadAlert.cs +++ b/PreloadAlert.cs @@ -26,6 +26,7 @@ public class PreloadAlert : BaseSettingsPlugin public static Dictionary Strongboxes; public static Dictionary Preload; public static Dictionary Bestiary; + public static Dictionary ExpeditionLeague; public static Color AreaNameColor; private readonly object _locker = new object(); private Dictionary alertStrings; @@ -103,7 +104,7 @@ public override void DrawSettings() $"{GameController.Area.CurrentArea.Name}.txt"); DebugWindow.LogMsg(path); - + File.WriteAllLines(path, PreloadDebug); } @@ -183,7 +184,7 @@ public override void DrawSettings() } } ImGui.Text($"Area Change Count: {GameController.Game.AreaChangeCount}"); - + if (ImGui.Button("Close")) PreloadDebugAction = null; }; } @@ -273,8 +274,8 @@ public override void AreaChange(AreaInstance area) Core.ParallelRunner.Run(new Coroutine(Parse(), this, "Preload parse")); isLoading = false; - } - + } + private IEnumerator Parse() { if (!working) @@ -287,30 +288,30 @@ private IEnumerator Parse() debugInformation.TickAction(() => { try - { - var memory = GameController.Memory; - FilesFromMemory filesFromMemory = new FilesFromMemory(memory); - var AllFiles = filesFromMemory.GetAllFilesSync(); - int areaChangeCount = GameController.Game.AreaChangeCount; - foreach (var file in AllFiles) - { - if (file.Value.ChangeCount == areaChangeCount) - { - var text = file.Key; - if (text.Contains('@')) text = text.Split('@')[0]; - - lock (_locker) - { - PreloadDebug.Add(text); - } - - CheckForPreload(text); - } - } - } - catch (Exception e) - { - DebugWindow.LogError($"{nameof(PreloadAlert)} -> {e}"); + { + var memory = GameController.Memory; + FilesFromMemory filesFromMemory = new FilesFromMemory(memory); + var AllFiles = filesFromMemory.GetAllFilesSync(); + int areaChangeCount = GameController.Game.AreaChangeCount; + foreach (var file in AllFiles) + { + if (file.Value.ChangeCount == areaChangeCount) + { + var text = file.Key; + if (text.Contains('@')) text = text.Split('@')[0]; + + lock (_locker) + { + PreloadDebug.Add(text); + } + + CheckForPreload(text); + } + } + } + catch (Exception e) + { + DebugWindow.LogError($"{nameof(PreloadAlert)} -> {e}"); } lock (_locker) @@ -660,6 +661,26 @@ private void SetupPredefinedConfigs() new PreloadConfigLine {Text = "Malachai Strongbox", FastColor = () => Settings.MalachaiStrongbox} } }; + + ExpeditionLeague = new Dictionary + { + { + "Metadata/Monsters/LeagueExpedition/NPC/ExpeditionTujen", + new PreloadConfigLine {Text = "Tujen, The Haggler", FastColor = () => Settings.ExpeditionTujen} + }, + { + "Metadata/Monsters/LeagueExpedition/NPC/ExpeditionDannig", + new PreloadConfigLine {Text = "Dannig, Warrior Skald", FastColor = () => Settings.ExpeditionDannig} + }, + { + "Metadata/Monsters/LeagueExpedition/NPC/ExpeditionRog; ", + new PreloadConfigLine {Text = "Rog, The Dealer", FastColor = () => Settings.ExpeditionRog} + }, + { + "Metadata/Monsters/LeagueExpedition/NPC/ExpeditionGwennen_", + new PreloadConfigLine {Text = "Gwennen, The Gambler", FastColor = () => Settings.ExpeditionGwennen} + } + }; Preload = new Dictionary { @@ -897,6 +918,19 @@ private void CheckForPreload(string text) alerts[alert.Text] = alert; } } + + if (Settings.Expedition) + { + var expedition_alert = ExpeditionLeague.Where(kv => text.StartsWith(kv.Key, StringComparison.OrdinalIgnoreCase)).Select(kv => kv.Value) + .FirstOrDefault(); + + if (expedition_alert == null) return; + + lock (_locker) + { + alerts[expedition_alert.Text] = expedition_alert; + } + } } } } diff --git a/PreloadAlertSettings.cs b/PreloadAlertSettings.cs index 15992b8..7deee17 100644 --- a/PreloadAlertSettings.cs +++ b/PreloadAlertSettings.cs @@ -18,6 +18,11 @@ public PreloadAlertSettings() CorruptedArea = new ToggleNode(true); CorruptedTitle = new ToggleNode(true); Bestiary = new ToggleNode(true); + Expedition = new ToggleNode(true); + ExpeditionTujen = new ColorBGRA(255, 242, 255, 255); + ExpeditionDannig = new ColorBGRA(255, 222, 13, 255); + ExpeditionRog = new ColorBGRA(255, 237, 12, 255); + ExpeditionGwennen = new ColorBGRA(255, 32, 219, 255); TextSize = new RangeNode(16, 10, 50); BackgroundColor = new ColorBGRA(0, 0, 0, 255); DefaultTextColor = new ColorBGRA(210, 210, 210, 255); @@ -237,5 +242,10 @@ public PreloadAlertSettings() public ColorNode UlyssesMorvant { get; set; } public ColorNode AurelioVoidsinger { get; set; } public ToggleNode Bestiary { get; set; } + public ToggleNode Expedition { get; set; } + public ColorNode ExpeditionTujen { get; set; } + public ColorNode ExpeditionDannig { get; set; } + public ColorNode ExpeditionRog { get; set; } + public ColorNode ExpeditionGwennen { get; set; } } }