Skip to content

Commit

Permalink
Merge pull request #165 from logicallysynced/chromatics-3.x
Browse files Browse the repository at this point in the history
Added some extra checks for raid effects and AZERTY layouts
  • Loading branch information
logicallysynced authored Aug 4, 2024
2 parents e3ad6c5 + c2bf910 commit 0c6e538
Show file tree
Hide file tree
Showing 10 changed files with 121 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Chromatics/Chromatics.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>net8.0-windows7.0</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<StartupObject>Chromatics.Program</StartupObject>
<Version>3.1.3.0</Version>
<Version>3.1.3.1</Version>
<Authors>Danielle Thompson</Authors>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Copyright>Danielle Thompson 2024</Copyright>
Expand Down
19 changes: 19 additions & 0 deletions Chromatics/Chromatics.sln
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion Chromatics/Forms/Uc_Mappings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,19 @@ private void CreateDefaults(KeyValuePair<Guid, IRGBDevice> 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);
Expand Down
1 change: 0 additions & 1 deletion Chromatics/Forms/vDevices/Uc_VirtualKeyboard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public override void InitializeDevice()

foreach (var led in keycapsLocalized)
{
Debug.WriteLine(led.LedType);
keycaps.Add(new KeyValuePair<int, KeyboardKey>(base_i, led));
base_i++;
}
Expand Down
16 changes: 13 additions & 3 deletions Chromatics/Helpers/LedKeyHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,7 @@ public static Dictionary<int, LedId> GetAllKeysForDevice(RGBDeviceType device)
LedId.Unknown128
};

public static Dictionary<int, LedId> DefaultKeys_ReactiveWeather = new Dictionary<int, LedId>()
public static Dictionary<int, LedId> DefaultKeys_ReactiveWeather_QWERTY = new Dictionary<int, LedId>()
{
{ 1, LedId.Keyboard_W },
{ 2, LedId.Keyboard_A },
Expand All @@ -2127,9 +2127,19 @@ public static Dictionary<int, LedId> GetAllKeysForDevice(RGBDeviceType device)
{ 5, LedId.Keyboard_LeftShift },
{ 6, LedId.Keyboard_LeftCtrl },
{ 7, LedId.Keyboard_LeftAlt }


};

public static Dictionary<int, LedId> DefaultKeys_ReactiveWeather_AZERTY = new Dictionary<int, LedId>()
{
{ 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<int, LedId> DefaultKeys_Keybinds = new Dictionary<int, LedId>()
{
{ 1, LedId.Keyboard_GraveAccentAndTilde },
Expand Down
46 changes: 29 additions & 17 deletions Chromatics/Layers/BaseLayers/ReactiveWeather.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
}

}
Expand All @@ -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();

Expand All @@ -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;
Expand Down Expand Up @@ -317,7 +319,7 @@ private static void StopEffects(ListLedGroup layer, HashSet<LinearGradient> _gra
layer.RemoveAllDecorators();
}

private static bool SetReactiveWeather(ListLedGroup layer, string zone, string weather, SolidColorBrush weather_brush, PaletteColorModel _colorPalette, RGBSurface surface, Led[] ledArray, HashSet<LinearGradient> _gradientEffects, bool inInstance)
private static bool SetReactiveWeather(ListLedGroup layer, string zone, string weather, SolidColorBrush weather_brush, PaletteColorModel _colorPalette, RGBSurface surface, Led[] ledArray, HashSet<LinearGradient> _gradientEffects, bool inInstance, Guid deviceGuid)
{
var effectSettings = RGBController.GetEffectsSettings();
var runningEffects = RGBController.GetRunningEffects();
Expand All @@ -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;
}
Expand Down Expand Up @@ -373,6 +376,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w

runningEffects.Add(layer);
raidEffectsRunning = true;
bossNames = ["Queen Eternal"];

return true;
}
Expand Down Expand Up @@ -402,6 +406,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w

runningEffects.Add(layer);
raidEffectsRunning = true;
bossNames = ["Black Cat"];

return true;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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)
{
Expand All @@ -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;
}
Expand All @@ -469,6 +480,7 @@ private static bool SetReactiveWeather(ListLedGroup layer, string zone, string w
}

raidEffectsRunning = false;
bossNames = null;

switch (zone)
{
Expand Down
Loading

0 comments on commit 0c6e538

Please sign in to comment.