Skip to content

Commit

Permalink
Move default color values to constant
Browse files Browse the repository at this point in the history
  • Loading branch information
legoandmars committed Feb 15, 2024
1 parent 9c4e23e commit 9fd01c8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
21 changes: 18 additions & 3 deletions LobbyCompatibility/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,21 @@ namespace LobbyCompatibility.Configuration;
/// </summary>
public class Config
{
/// <summary>
/// Default <see cref="Color"/> used to represent compatible plugins.
/// </summary>
public static readonly Color DefaultCompatibleColor = Color.green;

/// <summary>
/// Default <see cref="Color"/> used to represent incompatible plugins.
/// </summary>
public static readonly Color DefaultIncompatibleColor = Color.red;

/// <summary>
/// Default <see cref="Color"/> used to represent unknown plugins.
/// </summary>
public static readonly Color DefaultUnknownColor = Color.gray;

/// <summary>
/// Default <see cref="ModdedLobbyFilter"/> value for public lobby sorting.
/// </summary>
Expand Down Expand Up @@ -46,15 +61,15 @@ public Config(ConfigFile configFile)
"The default tab to use when viewing a lobby's mod list");
CompatibleColor = configFile.Bind("Visual",
"Compatible Plugin Color",
Color.green,
DefaultCompatibleColor,
"The color used to respresent compatible plugins");
IncompatibleColor = configFile.Bind("Visual",
"Incompatible Plugin Color",
Color.red,
DefaultIncompatibleColor,
"The color used to respresent incompatible plugins");
UnknownColor = configFile.Bind("Visual",
"Unknown Plugin Color",
Color.gray,
DefaultUnknownColor,
"The color used to respresent unknown plugins");
}
}
7 changes: 4 additions & 3 deletions LobbyCompatibility/Models/PluginDiff.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using LobbyCompatibility.Configuration;
using LobbyCompatibility.Enums;
using UnityEngine;

Expand Down Expand Up @@ -42,10 +43,10 @@ public Color GetTextColor()
{
return PluginDiffResult switch
{
PluginDiffResult.Compatible => LobbyCompatibilityPlugin.Config?.CompatibleColor.Value ?? Color.green,
PluginDiffResult.Compatible => LobbyCompatibilityPlugin.Config?.CompatibleColor.Value ?? Config.DefaultCompatibleColor,
PluginDiffResult.ClientMissingMod or PluginDiffResult.ServerMissingMod or PluginDiffResult.ModVersionMismatch
=> LobbyCompatibilityPlugin.Config?.IncompatibleColor.Value ?? Color.red,
_ => LobbyCompatibilityPlugin.Config?.UnknownColor.Value ?? Color.gray
=> LobbyCompatibilityPlugin.Config?.IncompatibleColor.Value ?? Config.DefaultIncompatibleColor,
_ => LobbyCompatibilityPlugin.Config?.UnknownColor.Value ?? Config.DefaultUnknownColor
};
}
}

0 comments on commit 9fd01c8

Please sign in to comment.