diff --git a/MiraAPI/GameModes/AbstractGameMode.cs b/MiraAPI/GameModes/AbstractGameMode.cs
index 466c282..0f820c8 100644
--- a/MiraAPI/GameModes/AbstractGameMode.cs
+++ b/MiraAPI/GameModes/AbstractGameMode.cs
@@ -157,4 +157,7 @@ public abstract class AbstractGameMode
/// Player attempting to vent.
/// True if venting is enabled in this mode.
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
+
+ ///
+ public override string ToString() => Name;
}
diff --git a/MiraAPI/GameModes/CustomGameModeManager.cs b/MiraAPI/GameModes/CustomGameModeManager.cs
index 62d27e2..99bff39 100644
--- a/MiraAPI/GameModes/CustomGameModeManager.cs
+++ b/MiraAPI/GameModes/CustomGameModeManager.cs
@@ -4,6 +4,7 @@ using Il2CppSystem.Threading.Tasks;
using MiraAPI.GameOptions;
using MiraAPI.PluginLoading;
using Reactor.Utilities;
+using Reactor.Utilities.Extensions;
namespace MiraAPI.GameModes;
@@ -72,11 +73,18 @@ public static class CustomGameModeManager
if (IdToModeMap.TryGetValue(id, out var mode))
{
ActiveMode = mode;
- return;
+ }
+ else if (id != 0)
+ {
+ ActiveMode = IdToModeMap[0];
+ OptionGroupSingleton.Instance.CurrentMode.SetValue(0);
+ Logger.Warning($"Unable to find game mode of id {id}!");
}
- ActiveMode = IdToModeMap[0];
- Logger.Warning($"Unable to find game mode of id {id}!");
+ if (OptionGroupSingleton.Instance.CurrentMode.OptionBehaviour != null && ActiveMode != null)
+ {
+ ((NumberOption)OptionGroupSingleton.Instance.CurrentMode.OptionBehaviour).TitleText.SetText($"Game Mode: <#{ActiveMode.Color.ToHtmlStringRGBA()}>{ActiveMode}");
+ }
}
internal static void GetAndSetGameMode()
diff --git a/MiraAPI/GameModes/GameModeOption.cs b/MiraAPI/GameModes/GameModeOption.cs
index 729cdc3..9c02dc6 100644
--- a/MiraAPI/GameModes/GameModeOption.cs
+++ b/MiraAPI/GameModes/GameModeOption.cs
@@ -11,7 +11,10 @@ public class GameModeOption : AbstractOptionGroup
///
public override string GroupName => "Game Mode";
- public ModdedNumberOption CurrentMode { get; set; } = new("Current Game Mode", 0, 0, CustomGameModeManager.LastId, 1, Utilities.MiraNumberSuffixes.None)
+ ///
+ /// Gets or sets the game mode option.
+ ///
+ public ModdedNumberOption CurrentMode { get; set; } = new("Game Mode: {0}", 0, 0, CustomGameModeManager.LastId, 1, Utilities.MiraNumberSuffixes.None)
{
ChangedEvent = x => CustomGameModeManager.SetGameMode((uint)x),
};
diff --git a/MiraAPI/Patches/GameModes/ConsolePatches.cs b/MiraAPI/Patches/GameModes/ConsolePatches.cs
index 09fbe17..d8a6dd8 100644
--- a/MiraAPI/Patches/GameModes/ConsolePatches.cs
+++ b/MiraAPI/Patches/GameModes/ConsolePatches.cs
@@ -2,8 +2,10 @@
using InnerNet;
using MiraAPI.GameModes;
+namespace MiraAPI.Patches.GameModes;
+
[HarmonyPatch]
-public static class ConsolePatches
+internal static class ConsolePatches
{
[HarmonyPrefix, HarmonyPatch(typeof(Console), nameof(Console.CanUse))]
public static bool CanUsePatch(Console __instance, [HarmonyArgument(0)] NetworkedPlayerInfo pc, [HarmonyArgument(1)] out bool canUse, [HarmonyArgument(2)] out bool couldUse)
diff --git a/MiraAPI/Patches/GameModes/DeadBodyPatch.cs b/MiraAPI/Patches/GameModes/DeadBodyPatch.cs
index 1070336..fff7e40 100644
--- a/MiraAPI/Patches/GameModes/DeadBodyPatch.cs
+++ b/MiraAPI/Patches/GameModes/DeadBodyPatch.cs
@@ -1,8 +1,10 @@
using HarmonyLib;
using MiraAPI.GameModes;
+namespace MiraAPI.Patches.GameModes;
+
[HarmonyPatch(typeof(DeadBody))]
-public static class DeadBodyPatch
+internal static class DeadBodyPatch
{
[HarmonyPrefix, HarmonyPatch(nameof(DeadBody.OnClick))]
public static bool OnClickPatch(DeadBody __instance)
diff --git a/MiraAPI/Patches/GameModes/GameLogicPatches.cs b/MiraAPI/Patches/GameModes/GameLogicPatches.cs
index 75d4ed9..46dea2a 100644
--- a/MiraAPI/Patches/GameModes/GameLogicPatches.cs
+++ b/MiraAPI/Patches/GameModes/GameLogicPatches.cs
@@ -1,8 +1,10 @@
using HarmonyLib;
using MiraAPI.GameModes;
+namespace MiraAPI.Patches.GameModes;
+
[HarmonyPatch]
-public static class GameLogicPatches
+internal static class GameLogicPatches
{
[HarmonyPrefix, HarmonyPatch(typeof(LogicGameFlowNormal), nameof(LogicGameFlowNormal.CheckEndCriteria))]
public static bool EndCritPatch(LogicGameFlowNormal __instance)
diff --git a/MiraAPI/Patches/GameModes/HudPatches.cs b/MiraAPI/Patches/GameModes/HudPatches.cs
index 50871b9..e232920 100644
--- a/MiraAPI/Patches/GameModes/HudPatches.cs
+++ b/MiraAPI/Patches/GameModes/HudPatches.cs
@@ -1,12 +1,14 @@
using HarmonyLib;
using MiraAPI.GameModes;
-[HarmonyPatch]
-public static class HudPatches
+namespace MiraAPI.Patches.GameModes;
+
+[HarmonyPatch(typeof(HudManager))]
+internal static class HudPatches
{
- [HarmonyPostfix, HarmonyPatch(typeof(HudManager), nameof(HudManager.Start))]
+ [HarmonyPostfix, HarmonyPatch(nameof(HudManager.Start))]
public static void HudStartPatch(HudManager __instance) => CustomGameModeManager.ActiveMode?.HudStart(__instance);
- [HarmonyPostfix, HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))]
+ [HarmonyPostfix, HarmonyPatch(nameof(HudManager.Update))]
public static void HudUpdatePatch(HudManager __instance) => CustomGameModeManager.ActiveMode?.HudUpdate(__instance);
}
diff --git a/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs b/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs
index 08e39f9..de9bbf1 100644
--- a/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs
+++ b/MiraAPI/Patches/GameModes/ImpostorTargetPatch.cs
@@ -1,11 +1,13 @@
using HarmonyLib;
using MiraAPI.GameModes;
+namespace MiraAPI.Patches.GameModes;
+
///
-/// Allow Impostors to kill each other if can kill is enabled in gamemode or friendly fire is toggled on
+/// Allow Impostors to kill each other if can kill is enabled in gamemode or friendly fire is toggled on.
///
[HarmonyPatch(typeof(ImpostorRole), "IsValidTarget")]
-public static class ImpostorTargetPatch
+internal static class ImpostorTargetPatch
{
public static bool Prefix(ImpostorRole __instance, [HarmonyArgument(0)] NetworkedPlayerInfo target, ref bool __result)
{
diff --git a/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs b/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs
index b6c48fc..06ea282 100644
--- a/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs
+++ b/MiraAPI/Patches/GameModes/MapBehaviourPatch.cs
@@ -1,8 +1,10 @@
using HarmonyLib;
using MiraAPI.GameModes;
+namespace MiraAPI.Patches.GameModes;
+
[HarmonyPatch(typeof(MapBehaviour))]
-public static class MapBehaviourPatch
+internal static class MapBehaviourPatch
{
[HarmonyPrefix, HarmonyPatch(nameof(MapBehaviour.ShowSabotageMap))]
public static bool ShowSabotagePatch(MapBehaviour __instance)
diff --git a/MiraAPI/Patches/GameModes/OnDeathPatch.cs b/MiraAPI/Patches/GameModes/OnDeathPatch.cs
index dcedbab..ba96c6c 100644
--- a/MiraAPI/Patches/GameModes/OnDeathPatch.cs
+++ b/MiraAPI/Patches/GameModes/OnDeathPatch.cs
@@ -1,8 +1,10 @@
using HarmonyLib;
using MiraAPI.GameModes;
+namespace MiraAPI.Patches.GameModes;
+
[HarmonyPatch(typeof(KillAnimation))]
-public static class OnDeathPatch
+internal static class OnDeathPatch
{
[HarmonyPostfix, HarmonyPatch(nameof(KillAnimation.CoPerformKill))]
public static void OnDeathPostfix([HarmonyArgument(0)] PlayerControl source, [HarmonyArgument(1)] PlayerControl target)
diff --git a/MiraAPI/Patches/Options/LobbyViewPanePatches.cs b/MiraAPI/Patches/Options/LobbyViewPanePatches.cs
index ee26822..66db435 100644
--- a/MiraAPI/Patches/Options/LobbyViewPanePatches.cs
+++ b/MiraAPI/Patches/Options/LobbyViewPanePatches.cs
@@ -1,8 +1,11 @@
using HarmonyLib;
+using MiraAPI.GameModes;
+using MiraAPI.GameOptions;
using MiraAPI.PluginLoading;
using MiraAPI.Roles;
using MiraAPI.Utilities;
using MiraAPI.Utilities.Assets;
+using Reactor.Utilities.Extensions;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -181,6 +184,14 @@ public static class LobbyViewPanePatches
else
{
viewSettingsInfoPanel.SetInfo(data.Title, data.GetValueString(option.GetFloatData()), 61);
+
+ if (viewSettingsInfoPanel.titleText.text.Contains("Game Mode"))
+ {
+ viewSettingsInfoPanel.titleText.text = TranslationController.Instance.GetString(
+ OptionGroupSingleton.Instance.CurrentMode.StringName,
+ $"<#{CustomGameModeManager.ActiveMode?.Color.ToHtmlStringRGBA()}>{CustomGameModeManager.ActiveMode}"
+ );
+ }
}
instance.settingsInfo.Add(viewSettingsInfoPanel.gameObject);
diff --git a/MiraAPI/Patches/Options/OptionsPatches.cs b/MiraAPI/Patches/Options/OptionsPatches.cs
index dae6905..bb520c0 100644
--- a/MiraAPI/Patches/Options/OptionsPatches.cs
+++ b/MiraAPI/Patches/Options/OptionsPatches.cs
@@ -1,6 +1,9 @@
using HarmonyLib;
using Il2CppSystem;
+using MiraAPI.GameModes;
+using MiraAPI.GameOptions;
using MiraAPI.Utilities;
+using Reactor.Utilities.Extensions;
namespace MiraAPI.Patches.Options;
@@ -38,8 +41,16 @@ public static class OptionsPatches
return true;
}
- __instance.TitleText.text =
- TranslationController.Instance.GetString(__instance.Title, Array.Empty