mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
set option title
This commit is contained in:
1 parent
dbacd044eb
commit
f9f7898277
12 files changed
+67
-17
No files matched your search
@@ -157,4 +157,7 @@ public abstract class AbstractGameMode
|
||||
/// <param name="playerInfo">Player attempting to vent.</param>
|
||||
/// <returns>True if venting is enabled in this mode.</returns>
|
||||
public virtual bool CanVent(Vent vent, NetworkedPlayerInfo playerInfo) => true;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
@@ -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<GameModeOption>.Instance.CurrentMode.SetValue(0);
|
||||
Logger<MiraApiPlugin>.Warning($"Unable to find game mode of id {id}!");
|
||||
}
|
||||
|
||||
ActiveMode = IdToModeMap[0];
|
||||
Logger<MiraApiPlugin>.Warning($"Unable to find game mode of id {id}!");
|
||||
if (OptionGroupSingleton<GameModeOption>.Instance.CurrentMode.OptionBehaviour != null && ActiveMode != null)
|
||||
{
|
||||
((NumberOption)OptionGroupSingleton<GameModeOption>.Instance.CurrentMode.OptionBehaviour).TitleText.SetText($"Game Mode: <#{ActiveMode.Color.ToHtmlStringRGBA()}>{ActiveMode}</color>");
|
||||
}
|
||||
}
|
||||
|
||||
internal static void GetAndSetGameMode()
|
||||
|
||||
@@ -11,7 +11,10 @@ public class GameModeOption : AbstractOptionGroup
|
||||
/// <inheritdoc/>
|
||||
public override string GroupName => "Game Mode";
|
||||
|
||||
public ModdedNumberOption CurrentMode { get; set; } = new("Current Game Mode", 0, 0, CustomGameModeManager.LastId, 1, Utilities.MiraNumberSuffixes.None)
|
||||
/// <summary>
|
||||
/// Gets or sets the game mode option.
|
||||
/// </summary>
|
||||
public ModdedNumberOption CurrentMode { get; set; } = new("Game Mode: {0}", 0, 0, CustomGameModeManager.LastId, 1, Utilities.MiraNumberSuffixes.None)
|
||||
{
|
||||
ChangedEvent = x => CustomGameModeManager.SetGameMode((uint)x),
|
||||
};
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1,11 +1,13 @@
|
||||
using HarmonyLib;
|
||||
using MiraAPI.GameModes;
|
||||
|
||||
namespace MiraAPI.Patches.GameModes;
|
||||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
[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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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<GameModeOption>.Instance.CurrentMode.StringName,
|
||||
$"<#{CustomGameModeManager.ActiveMode?.Color.ToHtmlStringRGBA()}>{CustomGameModeManager.ActiveMode}</color>"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
instance.settingsInfo.Add(viewSettingsInfoPanel.gameObject);
|
||||
|
||||
@@ -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<Object>());
|
||||
if (__instance == OptionGroupSingleton<GameModeOption>.Instance.CurrentMode.OptionBehaviour)
|
||||
{
|
||||
__instance.TitleText.text =
|
||||
TranslationController.Instance.GetString(__instance.Title, $"<#{CustomGameModeManager.ActiveMode?.Color.ToHtmlStringRGBA()}>{CustomGameModeManager.ActiveMode}</color>");
|
||||
}
|
||||
else
|
||||
{
|
||||
__instance.TitleText.text =
|
||||
TranslationController.Instance.GetString(__instance.Title);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user