From c2bf910bf8dea2ed6da834e1454fe639287a6820 Mon Sep 17 00:00:00 2001 From: Danielle Thompson Date: Sun, 4 Aug 2024 20:04:56 +1000 Subject: [PATCH] Added some extra checks for raid effects and AZERTY layouts --- Chromatics/Chromatics.csproj | 2 +- Chromatics/Chromatics.sln | 19 ++++++++ Chromatics/Forms/Uc_Mappings.cs | 13 +++++- .../Forms/vDevices/Uc_VirtualKeyboard.cs | 1 - Chromatics/Helpers/LedKeyHelper.cs | 16 +++++-- .../Layers/BaseLayers/ReactiveWeather.cs | 46 ++++++++++++------- .../DynamicLayers/ReactiveWeatherHighlight.cs | 38 ++++++++------- Chromatics/Layers/LayerProcessor.cs | 25 +++++++++- .../obj/Chromatics.csproj.nuget.dgspec.json | 2 +- Chromatics/obj/project.assets.json | 2 +- 10 files changed, 121 insertions(+), 43 deletions(-) create mode 100644 Chromatics/Chromatics.sln diff --git a/Chromatics/Chromatics.csproj b/Chromatics/Chromatics.csproj index 19db6f1..bbdf10c 100644 --- a/Chromatics/Chromatics.csproj +++ b/Chromatics/Chromatics.csproj @@ -5,7 +5,7 @@ net8.0-windows7.0 true Chromatics.Program - 3.1.3.0 + 3.1.3.1 Danielle Thompson app.manifest Danielle Thompson 2024 diff --git a/Chromatics/Chromatics.sln b/Chromatics/Chromatics.sln new file mode 100644 index 0000000..1aad2d3 --- /dev/null +++ b/Chromatics/Chromatics.sln @@ -0,0 +1,19 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 25.0.1704.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Chromatics", "Chromatics.csproj", "{24D17385-5866-4EF5-8595-5276EE0D088A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {63572831-4136-4B51-BE30-34824AAFAC05} + EndGlobalSection +EndGlobal diff --git a/Chromatics/Forms/Uc_Mappings.cs b/Chromatics/Forms/Uc_Mappings.cs index b43434e..670d923 100644 --- a/Chromatics/Forms/Uc_Mappings.cs +++ b/Chromatics/Forms/Uc_Mappings.cs @@ -333,8 +333,19 @@ private void CreateDefaults(KeyValuePair devicePair) // Add dynamic layer for keyboards if (deviceType == RGBDeviceType.Keyboard) { + var settings = AppSettings.GetSettings(); var x = i; - AddLayer(LayerType.DynamicLayer, deviceGuid, deviceType, 0, x, true, false, true, LedKeyHelper.DefaultKeys_ReactiveWeather, (int)DynamicLayerType.ReactiveWeatherHighlight, true, LayerModes.Interpolate); + + if (settings.keyboardLayout == KeyboardLocalization.azerty) + { + AddLayer(LayerType.DynamicLayer, deviceGuid, deviceType, 0, x, true, false, true, LedKeyHelper.DefaultKeys_ReactiveWeather_AZERTY, (int)DynamicLayerType.ReactiveWeatherHighlight, true, LayerModes.Interpolate); + } + else + { + AddLayer(LayerType.DynamicLayer, deviceGuid, deviceType, 0, x, true, false, true, LedKeyHelper.DefaultKeys_ReactiveWeather_QWERTY, (int)DynamicLayerType.ReactiveWeatherHighlight, true, LayerModes.Interpolate); + } + + AddLayer(LayerType.DynamicLayer, deviceGuid, deviceType, 0, (x + 1), true, false, true, LedKeyHelper.DefaultKeys_Keybinds, (int)DynamicLayerType.Keybinds, true, LayerModes.Interpolate); AddLayer(LayerType.DynamicLayer, deviceGuid, deviceType, 0, (x + 2), true, false, true, LedKeyHelper.DefaultKeys_HP, (int)DynamicLayerType.HPTracker, true, LayerModes.Interpolate); AddLayer(LayerType.DynamicLayer, deviceGuid, deviceType, 0, (x + 3), true, false, true, LedKeyHelper.DefaultKeys_MP, (int)DynamicLayerType.MPTracker, true, LayerModes.Interpolate); diff --git a/Chromatics/Forms/vDevices/Uc_VirtualKeyboard.cs b/Chromatics/Forms/vDevices/Uc_VirtualKeyboard.cs index aed61dc..cd057cb 100644 --- a/Chromatics/Forms/vDevices/Uc_VirtualKeyboard.cs +++ b/Chromatics/Forms/vDevices/Uc_VirtualKeyboard.cs @@ -57,7 +57,6 @@ public override void InitializeDevice() foreach (var led in keycapsLocalized) { - Debug.WriteLine(led.LedType); keycaps.Add(new KeyValuePair(base_i, led)); base_i++; } diff --git a/Chromatics/Helpers/LedKeyHelper.cs b/Chromatics/Helpers/LedKeyHelper.cs index 5e8b7d7..91de1e2 100644 --- a/Chromatics/Helpers/LedKeyHelper.cs +++ b/Chromatics/Helpers/LedKeyHelper.cs @@ -2118,7 +2118,7 @@ public static Dictionary GetAllKeysForDevice(RGBDeviceType device) LedId.Unknown128 }; - public static Dictionary DefaultKeys_ReactiveWeather = new Dictionary() + public static Dictionary DefaultKeys_ReactiveWeather_QWERTY = new Dictionary() { { 1, LedId.Keyboard_W }, { 2, LedId.Keyboard_A }, @@ -2127,9 +2127,19 @@ public static Dictionary GetAllKeysForDevice(RGBDeviceType device) { 5, LedId.Keyboard_LeftShift }, { 6, LedId.Keyboard_LeftCtrl }, { 7, LedId.Keyboard_LeftAlt } - - }; + + public static Dictionary DefaultKeys_ReactiveWeather_AZERTY = new Dictionary() + { + { 1, LedId.Keyboard_Z }, + { 2, LedId.Keyboard_Q }, + { 3, LedId.Keyboard_S }, + { 4, LedId.Keyboard_D }, + { 5, LedId.Keyboard_LeftShift }, + { 6, LedId.Keyboard_LeftCtrl }, + { 7, LedId.Keyboard_LeftAlt } + }; + public static Dictionary DefaultKeys_Keybinds = new Dictionary() { { 1, LedId.Keyboard_GraveAccentAndTilde }, diff --git a/Chromatics/Layers/BaseLayers/ReactiveWeather.cs b/Chromatics/Layers/BaseLayers/ReactiveWeather.cs index 0790fea..b2af1af 100644 --- a/Chromatics/Layers/BaseLayers/ReactiveWeather.cs +++ b/Chromatics/Layers/BaseLayers/ReactiveWeather.cs @@ -38,6 +38,7 @@ public class ReactiveWeatherProcessor : LayerProcessor internal static int _previousOffset = 0; internal static bool dutyComplete = false; internal static bool raidEffectsRunning = false; + internal static string[] bossNames = null; public override void Process(IMappingLayer layer) { @@ -147,29 +148,38 @@ public override void Process(IMappingLayer layer) if (chatLogEntries.Count > 0) { - //Debug.WriteLine($"{chatLogEntries.First().Code}: {chatLogEntries.First().Message}"); - - if (chatLogEntries.First().Code == "0840" && Regex.IsMatch(chatLogEntries.First().Message, @"completion time: (\d+:\d+)")) + + if (chatLogEntries.First().Code == "0840" && Regex.IsMatch(chatLogEntries.First().Message, @"completion time: (\d+:\d+)", RegexOptions.IgnoreCase)) { dutyComplete = true; raidEffectsRunning = false; + bossNames = null; } - else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has begun\.")) + else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has begun\.", RegexOptions.IgnoreCase)) { dutyComplete = false; } - else if (chatLogEntries.First().Code == "083E" && Regex.IsMatch(chatLogEntries.First().Message, @"You obtain \d+ Allagan tomestones of \w+\.")) + else if (chatLogEntries.First().Code == "083E" && Regex.IsMatch(chatLogEntries.First().Message, @"You obtain \d+ Allagan tomestones of \w+\.", RegexOptions.IgnoreCase)) + { + dutyComplete = true; + raidEffectsRunning = false; + bossNames = null; + } + + else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has ended\.", RegexOptions.IgnoreCase)) { dutyComplete = true; raidEffectsRunning = false; + bossNames = null; } - else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has ended\.")) + else if (bossNames != null && (chatLogEntries.First().Code == "133A" || chatLogEntries.First().Code == "0B3A") && Regex.IsMatch(chatLogEntries.First().Message, @"(.* defeats|You defeat|You defeat the) (" + string.Join("|", bossNames.Select(Regex.Escape)) + @")\.", RegexOptions.IgnoreCase)) { dutyComplete = true; raidEffectsRunning = false; + bossNames = null; } } @@ -193,14 +203,6 @@ public override void Process(IMappingLayer layer) currentWeather = weatherService.GetCurrentWeather(currentZone).Item1.ToString(); } - /* - if (raidEffectsRunning) - { - model._currentWeather = currentWeather; - - } - */ - //var currentWeather = weatherService.GetCurrentWeather(currentZone).Item1.ToString(); @@ -209,10 +211,10 @@ public override void Process(IMappingLayer layer) //layergroup.Brush = weather_brush; - effectApplied = SetReactiveWeather(layergroup, currentZone, currentWeather, weather_brush, _colorPalette, surface, ledArray, model._gradientEffects, DutyFinderBellExtension.InInstance()); + effectApplied = SetReactiveWeather(layergroup, currentZone, currentWeather, weather_brush, _colorPalette, surface, ledArray, model._gradientEffects, DutyFinderBellExtension.InInstance(), layer.deviceGuid); #if DEBUG - Debug.WriteLine($"{layer.deviceType} Zone Lookup: {currentZone}. Weather: {currentWeather}"); + //Debug.WriteLine($"{layer.deviceGuid} Zone Lookup: {currentZone}. Weather: {currentWeather}"); #endif model._currentWeather = currentWeather; @@ -317,7 +319,7 @@ private static void StopEffects(ListLedGroup layer, HashSet _gra layer.RemoveAllDecorators(); } - private static bool SetReactiveWeather(ListLedGroup layer, string zone, string weather, SolidColorBrush weather_brush, PaletteColorModel _colorPalette, RGBSurface surface, Led[] ledArray, HashSet _gradientEffects, bool inInstance) + private static bool SetReactiveWeather(ListLedGroup layer, string zone, string weather, SolidColorBrush weather_brush, PaletteColorModel _colorPalette, RGBSurface surface, Led[] ledArray, HashSet _gradientEffects, bool inInstance, Guid deviceGuid) { var effectSettings = RGBController.GetEffectsSettings(); var runningEffects = RGBController.GetRunningEffects(); @@ -344,6 +346,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w SetEffect(starfield, layer, runningEffects); raidEffectsRunning = true; + bossNames = ["Zoraal Ja"]; return true; } @@ -373,6 +376,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w runningEffects.Add(layer); raidEffectsRunning = true; + bossNames = ["Queen Eternal"]; return true; } @@ -402,6 +406,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w runningEffects.Add(layer); raidEffectsRunning = true; + bossNames = ["Black Cat"]; return true; } @@ -417,6 +422,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w layer.Brush = new SolidColorBrush(baseCol); SetEffect(arenaLightShow, layer, runningEffects); raidEffectsRunning = true; + bossNames = ["Honey B. Lovely"]; return true; } @@ -445,11 +451,13 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w runningEffects.Add(layer); raidEffectsRunning = true; + bossNames = ["Brute Bomber"]; return true; } break; case "The Thundering": + case "Dalamud's Shadow": //Raid Zone Effect if (effectSettings.effect_raideffects && !raidEffectsRunning) { @@ -460,6 +468,9 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w layer.Brush = new SolidColorBrush(baseCol); SetEffect(bpmArenaLightShow, layer, runningEffects); raidEffectsRunning = true; + bossNames = ["Wicked Thunder", "Rafflesia"]; + + //Logger.WriteConsole(Enums.LoggerTypes.FFXIV, $"Catch X4: Effect Run ({deviceGuid})"); return true; } @@ -469,6 +480,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w } raidEffectsRunning = false; + bossNames = null; switch (zone) { diff --git a/Chromatics/Layers/DynamicLayers/ReactiveWeatherHighlight.cs b/Chromatics/Layers/DynamicLayers/ReactiveWeatherHighlight.cs index 86e5e4e..3fa05d7 100644 --- a/Chromatics/Layers/DynamicLayers/ReactiveWeatherHighlight.cs +++ b/Chromatics/Layers/DynamicLayers/ReactiveWeatherHighlight.cs @@ -27,6 +27,7 @@ public class ReactiveWeatherHighlightProcessor : LayerProcessor internal static int _previousOffset = 0; internal static bool dutyComplete = false; internal static bool raidEffectsRunning = false; + internal static string[] bossNames = null; public override void Process(IMappingLayer layer) { @@ -121,29 +122,40 @@ public override void Process(IMappingLayer layer) { if (chatLogEntries.Count > 0) { - if (chatLogEntries.First().Code == "0840" && Regex.IsMatch(chatLogEntries.First().Message, @"completion time: (\d+:\d+)")) + if (chatLogEntries.First().Code == "0840" && Regex.IsMatch(chatLogEntries.First().Message, @"completion time: (\d+:\d+)", RegexOptions.IgnoreCase)) { dutyComplete = true; raidEffectsRunning = false; + bossNames = null; } - else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has begun\.")) + else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has begun\.", RegexOptions.IgnoreCase)) { dutyComplete = false; } - else if (chatLogEntries.First().Code == "083E" && Regex.IsMatch(chatLogEntries.First().Message, @"You obtain \d+ Allagan tomestones of \w+\.")) + else if (chatLogEntries.First().Code == "083E" && Regex.IsMatch(chatLogEntries.First().Message, @"You obtain \d+ Allagan tomestones of \w+\.", RegexOptions.IgnoreCase)) { dutyComplete = true; raidEffectsRunning = false; + bossNames = null; } - else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has ended\.")) + else if (chatLogEntries.First().Code == "0839" && Regex.IsMatch(chatLogEntries.First().Message, @"has ended\.", RegexOptions.IgnoreCase)) { dutyComplete = true; raidEffectsRunning = false; + bossNames = null; } + else if (bossNames != null && (chatLogEntries.First().Code == "133A" || chatLogEntries.First().Code == "0B3A") && Regex.IsMatch(chatLogEntries.First().Message, @"(.* defeats|You defeat|You defeat the) (" + string.Join("|", bossNames.Select(Regex.Escape)) + @")\.", RegexOptions.IgnoreCase)) + { + dutyComplete = true; + raidEffectsRunning = false; + bossNames = null; + } + + } _previousArrayIndex = readResult.PreviousArrayIndex; @@ -162,13 +174,6 @@ public override void Process(IMappingLayer layer) currentWeather = weatherService.GetCurrentWeather(currentZone).Item1.ToString(); } - /* - if (raidEffectsRunning) - { - model._currentWeather = currentWeather; - - } - */ if ((model._currentWeather != currentWeather || model._currentZone != currentZone || model._reactiveWeatherEffects != reactiveWeatherEffects || model._raidEffects != raidEffects || layer.requestUpdate || model._inInstance != DutyFinderBellExtension.InInstance() || model._dutyComplete != dutyComplete) && currentWeather != "CutScene") { @@ -176,8 +181,6 @@ public override void Process(IMappingLayer layer) SetReactiveWeather(layergroup, currentZone, currentWeather, weather_brush, _colorPalette, DutyFinderBellExtension.InInstance()); - - model._currentWeather = currentWeather; model._currentZone = currentZone; model._inInstance = DutyFinderBellExtension.InInstance(); @@ -224,8 +227,7 @@ private static void SetReactiveWeather(ListLedGroup layer, string zone, string w { color = ColorHelper.ColorToRGBColor(_colorPalette.RaidEffectEverkeepKeyHighlight.Color); raidEffectsRunning = true; - - Logger.WriteConsole(Enums.LoggerTypes.FFXIV, $"Z1"); + bossNames = ["Zoraal Ja"]; } break; case "Interphos": @@ -235,6 +237,7 @@ private static void SetReactiveWeather(ListLedGroup layer, string zone, string w { color = ColorHelper.ColorToRGBColor(_colorPalette.RaidEffectInterphosKeyHighlight.Color); raidEffectsRunning = true; + bossNames = ["Queen Eternal"]; } break; case "Scratching Ring": @@ -243,6 +246,7 @@ private static void SetReactiveWeather(ListLedGroup layer, string zone, string w { color = ColorHelper.ColorToRGBColor(_colorPalette.RaidEffectM1KeyHighlight.Color); raidEffectsRunning = true; + bossNames = ["Black Cat"]; } break; case "Lovely Lovering": @@ -251,6 +255,7 @@ private static void SetReactiveWeather(ListLedGroup layer, string zone, string w { color = ColorHelper.ColorToRGBColor(_colorPalette.RaidEffectM2KeyHighlight.Color); raidEffectsRunning = true; + bossNames = ["Honey B. Lovely"]; } break; case "Blasting Ring": @@ -259,6 +264,7 @@ private static void SetReactiveWeather(ListLedGroup layer, string zone, string w { color = ColorHelper.ColorToRGBColor(_colorPalette.RaidEffectM3KeyHighlight.Color); raidEffectsRunning = true; + bossNames = ["Brute Bomber"]; } break; case "The Thundering": @@ -268,12 +274,12 @@ private static void SetReactiveWeather(ListLedGroup layer, string zone, string w { color = ColorHelper.ColorToRGBColor(_colorPalette.RaidEffectM4KeyHighlight.Color); raidEffectsRunning = true; + bossNames = ["Wicked Thunder"]; } break; } } - switch (zone) { diff --git a/Chromatics/Layers/LayerProcessor.cs b/Chromatics/Layers/LayerProcessor.cs index e4788b7..3184357 100644 --- a/Chromatics/Layers/LayerProcessor.cs +++ b/Chromatics/Layers/LayerProcessor.cs @@ -21,6 +21,12 @@ public abstract class LayerProcessor internal Led[] GetLedArray(IMappingLayer layer) { var device = RGBController.GetLiveDevices().FirstOrDefault(d => d.Key == layer.deviceGuid).Value; + + if (device == null) + { + return Array.Empty(); + } + var ledArray = device.Where(led => layer.deviceLeds.Any(v => v.Value.Equals(led.Id))).ToArray(); if (ledArray != null && ledArray.Length > 0) @@ -34,6 +40,12 @@ internal Led[] GetLedArray(IMappingLayer layer) internal Led[] GetLedSortedArray(IMappingLayer layer) { var device = RGBController.GetLiveDevices().FirstOrDefault(d => d.Key == layer.deviceGuid).Value; + + if (device == null) + { + return Array.Empty(); + } + var ledArray = (from led in device.Select((led, index) => new { Index = index, Led = led }) join id in layer.deviceLeds.Values.Select((id, index) => new { Index = index, Id = id }) on led.Led.Id equals id.Id orderby id.Index select led.Led).ToArray(); @@ -48,6 +60,12 @@ internal Led[] GetLedSortedArray(IMappingLayer layer) internal Led[] GetLedBaseArray(IMappingLayer layer, Layer baseLayer) { var device = RGBController.GetLiveDevices().FirstOrDefault(d => d.Key == layer.deviceGuid).Value; + + if (device == null) + { + return Array.Empty(); + } + var ledArray = device.Where(led => baseLayer.deviceLeds.Any(v => v.Value.Equals(led.Id))).ToArray(); @@ -63,6 +81,11 @@ internal IRGBDevice GetDevice(IMappingLayer layer) { var device = RGBController.GetLiveDevices().FirstOrDefault(d => d.Key == layer.deviceGuid).Value; + if (device == null) + { + return null; + } + return device; } @@ -83,8 +106,6 @@ public override void Process(IMappingLayer layer) //loop through all LED's and assign to device layer - - ListLedGroup layergroup; var ledArray = GetLedArray(layer); diff --git a/Chromatics/obj/Chromatics.csproj.nuget.dgspec.json b/Chromatics/obj/Chromatics.csproj.nuget.dgspec.json index 5907aa8..5604d99 100644 --- a/Chromatics/obj/Chromatics.csproj.nuget.dgspec.json +++ b/Chromatics/obj/Chromatics.csproj.nuget.dgspec.json @@ -5,7 +5,7 @@ }, "projects": { "D:\\Git Projects\\roxaskeyheart\\Chromatics Workbench\\Chromatics-3.x\\Chromatics\\Chromatics.csproj": { - "version": "3.1.3", + "version": "3.1.3.1", "restore": { "projectUniqueName": "D:\\Git Projects\\roxaskeyheart\\Chromatics Workbench\\Chromatics-3.x\\Chromatics\\Chromatics.csproj", "projectName": "Chromatics", diff --git a/Chromatics/obj/project.assets.json b/Chromatics/obj/project.assets.json index 515cd7f..4bd106a 100644 --- a/Chromatics/obj/project.assets.json +++ b/Chromatics/obj/project.assets.json @@ -4593,7 +4593,7 @@ "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages": {} }, "project": { - "version": "3.1.3", + "version": "3.1.3.1", "restore": { "projectUniqueName": "D:\\Git Projects\\roxaskeyheart\\Chromatics Workbench\\Chromatics-3.x\\Chromatics\\Chromatics.csproj", "projectName": "Chromatics",