Skip to content

Commit

Permalink
Merge pull request #167 from poveden/jpc/musictrack-refactor
Browse files Browse the repository at this point in the history
Jpc/musictrack refactor
  • Loading branch information
poveden authored Mar 23, 2024
2 parents bb28c11 + 7097449 commit 5a5ea1f
Show file tree
Hide file tree
Showing 34 changed files with 241 additions and 305 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"dotnet-reportgenerator-globaltool": {
"version": "5.1.24",
"version": "5.2.4",
"commands": [
"reportgenerator"
]
Expand Down
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ csharp_style_implicit_object_creation_when_type_is_apparent = false
# Test code
[test/**/*.cs]

# CA2007: Consider calling ConfigureAwait on the awaited task
dotnet_diagnostic.CA2007.severity = none

# IDE0008: Use explicit type
csharp_style_var_elsewhere = true:warning

Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [1.18.2](https://github.com/poveden/EliteChroma/compare/v1.18.1...v1.18.2) — 2024-03-22

### Fixed

- Fix crash when a music track unknown to EliteChroma plays

## [1.18.1](https://github.com/poveden/EliteChroma/compare/v1.18.0...v1.18.1) — 2023-10-01

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions Common.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.7.0.75501">
<PackageReference Include="SonarAnalyzer.CSharp" Version="9.22.0.87781">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.406">
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.556">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions src/EliteChroma.Core/Chroma/ColorExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ public static ChromaColor Transform(this ChromaColor color, double multiply, dou
double g = color.G / 255.0;
double b = color.B / 255.0;

if (multiply != 1.0)
if (multiply is < 1.0 or > 1.0)
{
r *= multiply;
g *= multiply;
b *= multiply;
}

if (gamma != 1.0)
if (gamma is < 1.0 or > 1.0)
{
r = Math.Pow(r, gamma);
g = Math.Pow(g, gamma);
Expand Down
6 changes: 3 additions & 3 deletions src/EliteChroma.Core/Elite/GameState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ internal set

public GameColors Colors { get; private set; }

public Music.Track MusicTrack { get; internal set; }
public string? MusicTrack { get; internal set; }

public StartJump.FsdJumpType FsdJumpType { get; internal set; }

Expand Down Expand Up @@ -92,7 +92,7 @@ GuiFocus.ExternalPanel or
GuiFocus.CommsPanel or
GuiFocus.RolePanel or
GuiFocus.StationServices
=> MusicTrack is not Music.Track.GalacticPowers and not Music.Track.Squadrons,
=> MusicTrack is not Music.GalacticPowers and not Music.Squadrons,

GuiFocus.GalaxyMap or
GuiFocus.SystemMap or
Expand Down Expand Up @@ -121,7 +121,7 @@ public bool IsWalking
return false;
}

if (MusicTrack is Music.Track.GalacticPowers or Music.Track.Squadrons or Music.Track.FleetCarrierManagment)
if (MusicTrack is Music.GalacticPowers or Music.Squadrons or Music.FleetCarrierManagment)
{
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EliteChroma.Core/Elite/GameStateWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ private void JournalWatcher_EntryAdded(object? sender, JournalEntry e)
case Music music:
_gameState.MusicTrack = music.MusicTrack;

if (_gameState.MusicTrack == Music.Track.MainMenu)
if (_gameState.MusicTrack == Music.MainMenu)
{
_gameState.GameMode = LoadGame.PlayMode.None;
}
Expand Down
2 changes: 1 addition & 1 deletion src/EliteChroma.Core/Layers/BackgroundLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private AmbientColors GetAmbientColors(bool hardpointsDeployed, VehicleMode mode
{
Keyboard = c.Transform(Colors.KeyboardDimBrightness),
Device = hardpointsDeployed ? c : c.Transform(Colors.DeviceDimBrightness),
Logo = Game.MusicTrack == Music.Track.MainMenu ? GameColors.EliteOrange : c,
Logo = Game.MusicTrack == Music.MainMenu ? GameColors.EliteOrange : c,
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/EliteChroma/EliteChroma.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageProjectUrl>https://github.com/poveden/EliteChroma</PackageProjectUrl>
<RepositoryUrl>https://github.com/poveden/EliteChroma</RepositoryUrl>
<Description>A tool to make Razer Chroma devices react to Elite:Dangerous in-game events.</Description>
<Version>1.18.1</Version>
<Version>1.18.2</Version>
<RepositoryType></RepositoryType>
<Authors>Jorge Poveda Coma</Authors>
<PackageTags>Elite, Dangerous, Razer, Chroma</PackageTags>
Expand Down
4 changes: 3 additions & 1 deletion src/EliteFiles/Bindings/BindingPreset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ public static IReadOnlyDictionary<BindingCategory, string> FindActivePresetFiles
using var sr = new StreamReader(fs);

string? bindsName;
for (int i = 0; (bindsName = sr.ReadLine()) != null; i++)
int i = 0;
while ((bindsName = sr.ReadLine()) != null)
{
string? bindsFile =
TryGetBindingsFilePath(gameOptionsFolder.Bindings, bindsName)
Expand All @@ -175,6 +176,7 @@ public static IReadOnlyDictionary<BindingCategory, string> FindActivePresetFiles
}

bindsFiles.Add((BindingCategory)i, bindsFile);
i++;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/EliteFiles/EliteFiles.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="8.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
</ItemGroup>

Expand Down
13 changes: 0 additions & 13 deletions src/EliteFiles/Internal/JsonStringEnumNameAttribute.cs

This file was deleted.

33 changes: 0 additions & 33 deletions src/EliteFiles/Internal/JsonStringEnumNameConverter.cs

This file was deleted.

152 changes: 65 additions & 87 deletions src/EliteFiles/Journal/Events/Music.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Text.Json.Serialization;
using EliteFiles.Internal;

namespace EliteFiles.Journal.Events
{
Expand All @@ -9,127 +8,106 @@ namespace EliteFiles.Journal.Events
[JournalEntry("Music")]
public sealed class Music : JournalEntry
{
/// <summary>
/// Specifies the music track.
/// </summary>
public enum Track
{
/// <summary>No music track is being played.</summary>
NoTrack = 0,
/// <summary>No music track is being played.</summary>
public const string NoTrack = "NoTrack";

/// <summary>Plays while on the game's main menu.</summary>
MainMenu,
/// <summary>Plays while on the game's main menu.</summary>
public const string MainMenu = "MainMenu";

/// <summary>Plays while on the game's CQC menu.</summary>
[JsonStringEnumName("CQCMenu")]
CqcMenu,
/// <summary>Plays while on the game's CQC menu.</summary>
public const string CqcMenu = "CQCMenu";

/// <summary>Plays while on the system map.</summary>
SystemMap,
/// <summary>Plays while on the system map.</summary>
public const string SystemMap = "SystemMap";

/// <summary>Plays while on the galaxy map.</summary>
GalaxyMap,
/// <summary>Plays while on the galaxy map.</summary>
public const string GalaxyMap = "GalaxyMap";

/// <summary>Plays while on the galaxy powers screen.</summary>
GalacticPowers,
/// <summary>Plays while on the galaxy powers screen.</summary>
public const string GalacticPowers = "GalacticPowers";

/// <summary>Plays while playing a CQC session.</summary>
[JsonStringEnumName("CQC")]
Cqc,
/// <summary>Plays while playing a CQC session.</summary>
public const string Cqc = "CQC";

/// <summary>Plays when entering from hyperspace into supercruise upon reaching the final route destination.</summary>
DestinationFromHyperspace,
/// <summary>Plays when entering from hyperspace into supercruise upon reaching the final route destination.</summary>
public const string DestinationFromHyperspace = "DestinationFromHyperspace";

/// <summary>Plays when entering from supercruise into realspace upon reaching the final route destination.</summary>
DestinationFromSupercruise,
/// <summary>Plays when entering from supercruise into realspace upon reaching the final route destination.</summary>
public const string DestinationFromSupercruise = "DestinationFromSupercruise";

/// <summary>Plays while the ship is on supercruise.</summary>
Supercruise,
/// <summary>Plays while the ship is on supercruise.</summary>
public const string Supercruise = "Supercruise";

/// <summary>Plays while fighting thargoids.</summary>
[JsonStringEnumName("Combat_Unknown")]
CombatUnknown,
/// <summary>Plays while fighting thargoids.</summary>
public const string CombatUnknown = "Combat_Unknown";

/// <summary>Plays while encountering thargoids in a USS.</summary>
[JsonStringEnumName("Unknown_Encounter")]
UnknownEncounter,
/// <summary>Plays while encountering thargoids in a USS.</summary>
public const string UnknownEncounter = "Unknown_Encounter";

/// <summary>Plays while dogfighting.</summary>
[JsonStringEnumName("Combat_Dogfight")]
CombatDogfight,
/// <summary>Plays while dogfighting.</summary>
public const string CombatDogfight = "Combat_Dogfight";

/// <summary>Plays while doing combat in a SRV.</summary>
[JsonStringEnumName("Combat_SRV")]
CombatSrv,
/// <summary>Plays while doing combat in a SRV.</summary>
public const string CombatSrv = "Combat_SRV";

/// <summary>Plays while exploring a thargoid settlement.</summary>
[JsonStringEnumName("Unknown_Settlement")]
UnknownSettlement,
/// <summary>Plays while exploring a thargoid settlement.</summary>
public const string UnknownSettlement = "Unknown_Settlement";

/// <summary>Plays while the docking computer is on.</summary>
DockingComputer,
/// <summary>Plays while the docking computer is on.</summary>
public const string DockingComputer = "DockingComputer";

/// <summary>Plays while docked on a starport.</summary>
Starport,
/// <summary>Plays while docked on a starport.</summary>
public const string Starport = "Starport";

/// <summary>Plays while encountering thargoids in a USS.</summary>
[JsonStringEnumName("Unknown_Exploration")]
UnknownExploration,
/// <summary>Plays while encountering thargoids in a USS.</summary>
public const string UnknownExploration = "Unknown_Exploration";

/// <summary>Plays while exploring in realspace.</summary>
Exploration,
/// <summary>Plays while exploring in realspace.</summary>
public const string Exploration = "Exploration";

/// <summary>Plays while on the FSS screen.</summary>
SystemAndSurfaceScanner,
/// <summary>Plays while on the FSS screen.</summary>
public const string SystemAndSurfaceScanner = "SystemAndSurfaceScanner";

/// <summary>Plays while on foot.</summary>
OnFoot,
/// <summary>Plays while on foot.</summary>
public const string OnFoot = "OnFoot";

/// <summary>Plays while on the fleet carrier management screen.</summary>
[JsonStringEnumName("FleetCarrier_Managment")]
FleetCarrierManagment,
/// <summary>Plays while on the fleet carrier management screen.</summary>
public const string FleetCarrierManagment = "FleetCarrier_Managment";

/// <summary>Plays while on the codex screen.</summary>
Codex,
/// <summary>Plays while on the codex screen.</summary>
public const string Codex = "Codex";

/// <summary>Plays when entering realspace after being interdicted.</summary>
Interdiction,
/// <summary>Plays when entering realspace after being interdicted.</summary>
public const string Interdiction = "Interdiction";

/// <summary>Plays while dogfighting.</summary>
[JsonStringEnumName("Combat_LargeDogFight")]
CombatLargeDogFight,
/// <summary>Plays while dogfighting.</summary>
public const string CombatLargeDogFight = "Combat_LargeDogFight";

/// <summary>Plays while exploring a guardian site.</summary>
GuardianSites,
/// <summary>Plays while exploring a guardian site.</summary>
public const string GuardianSites = "GuardianSites";

/// <summary>Plays while on the squadrons screen.</summary>
Squadrons,
/// <summary>Plays while on the squadrons screen.</summary>
public const string Squadrons = "Squadrons";

/// <summary>Plays while near of, or docked on, a fleet carrier.</summary>
NoInGameMusic,
/// <summary>Plays while near of, or docked on, a fleet carrier.</summary>
public const string NoInGameMusic = "NoInGameMusic";

/// <summary>Plays while exploring a Lagrange cloud.</summary>
[JsonStringEnumName("Lifeform_FogCloud")]
LifeformFogCloud,
/// <summary>Plays while exploring a Lagrange cloud.</summary>
public const string LifeformFogCloud = "Lifeform_FogCloud";

/// <summary>Plays while near of, or docked on, a damaged starport.</summary>
[JsonStringEnumName("Damaged_Starport")]
DamagedStarport,
/// <summary>Plays while near of, or docked on, a damaged starport.</summary>
public const string DamagedStarport = "Damaged_Starport";

/// <summary>Plays when a capital ship enters a combat zone.</summary>
[JsonStringEnumName("Combat_CapitalShip")]
CombatCapitalShip,
/// <summary>Plays when a capital ship enters a combat zone.</summary>
public const string CombatCapitalShip = "Combat_CapitalShip";

/// <summary>Plays while encountering a thargoid titan.</summary>
[JsonStringEnumName("Titan_Encounter")]
TitanEncounter,
}
/// <summary>Plays while encountering a thargoid titan.</summary>
public const string TitanEncounter = "Titan_Encounter";

/// <summary>
/// Gets or sets the name of the music track.
/// </summary>
[JsonPropertyName("MusicTrack")]
[JsonConverter(typeof(JsonStringEnumNameConverter<Track>))]
public Track MusicTrack { get; set; }
public string? MusicTrack { get; set; }
}
}
Loading

0 comments on commit 5a5ea1f

Please sign in to comment.