mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
87 files changed
+1076
-281
No files matched your search
@@ -13,7 +13,7 @@ namespace MiraAPI.Example.Buttons.Freezer;
|
||||
|
||||
public class FreezeButton : CustomActionButton<PlayerControl>
|
||||
{
|
||||
public override string Name => "Freeze";
|
||||
public override string Name => "button.freeze";
|
||||
|
||||
public override float Cooldown => OptionGroupSingleton<FreezerRoleSettings>.Instance.FreezeDuration;
|
||||
public override bool PauseTimerInVent => true;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class MeetingButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Call Meeting";
|
||||
public override string Name => "button.callMeeting";
|
||||
|
||||
public override float Cooldown => 15;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class NeutralKillerButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Win Game";
|
||||
public override string Name => "button.winGame";
|
||||
public override float Cooldown => 0f;
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
public override MiraKeybind Keybind => ExampleKeybinds.NeutralWinKeybind;
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace MiraAPI.Example.Buttons.Teleporter;
|
||||
|
||||
public class TeleportButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Teleport";
|
||||
public override string Name => "button.teleport";
|
||||
|
||||
public override float Cooldown => OptionGroupSingleton<TeleporterOptions>.Instance.TeleportCooldown.Value;
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -6,7 +7,7 @@ namespace MiraAPI.Example.Buttons;
|
||||
|
||||
public class ThinkButton : CustomActionButton
|
||||
{
|
||||
public override string Name => "Think";
|
||||
public override string Name => "button.think";
|
||||
public override float Cooldown => 15f;
|
||||
public override float EffectDuration => 10f;
|
||||
public override int MaxUses => 1;
|
||||
@@ -14,13 +15,12 @@ public class ThinkButton : CustomActionButton
|
||||
public override LoadableAsset<Sprite> Sprite => ExampleAssets.ExampleButton;
|
||||
protected override void OnClick()
|
||||
{
|
||||
// This button does absolutely nothing besides changing its text
|
||||
Button!.OverrideText("Thinking...");
|
||||
Button!.OverrideText("button.think.thinking".Translate());
|
||||
}
|
||||
|
||||
public override void OnEffectEnd()
|
||||
{
|
||||
Button!.OverrideText("Think");
|
||||
Button!.OverrideText("button.think".Translate());
|
||||
}
|
||||
|
||||
public override bool IsEffectCancellable()
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace MiraAPI.Example;
|
||||
[RegisterCustomColors]
|
||||
public static class ExampleColors
|
||||
{
|
||||
public static CustomColor Cerulean { get; } = new("Cerulean", new Color(0.0f, 0.48f, 0.65f))
|
||||
public static CustomColor Cerulean { get; } = new("color.cerulean", new Color(0.0f, 0.48f, 0.65f))
|
||||
{
|
||||
ColorBrightness = CustomColorBrightness.Lighter,
|
||||
};
|
||||
|
||||
public static CustomColor Rose { get; } = new("Rose", new Color(0.98f, 0.26f, 0.62f));
|
||||
public static CustomColor Rose { get; } = new("color.rose", new Color(0.98f, 0.26f, 0.62f));
|
||||
|
||||
public static CustomColor Gold { get; } = new("Gold", new Color(1.0f, 0.84f, 0.0f));
|
||||
public static CustomColor Gold { get; } = new("color.gold", new Color(1.0f, 0.84f, 0.0f));
|
||||
}
|
||||
@@ -8,7 +8,7 @@ namespace MiraAPI.Example;
|
||||
|
||||
public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
public override string TabName => "Mira Example";
|
||||
public override string TabName => "settings.miraExample";
|
||||
protected override bool ShouldCreateLabels => false;
|
||||
|
||||
public override LocalSettingTabAppearance TabAppearance => new()
|
||||
@@ -18,7 +18,7 @@ public class ExampleLocalSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
};
|
||||
|
||||
[LocalSettingsButton]
|
||||
public LocalSettingsButton ExampleButton { get; private set; } = new("Example Button", OnExampleButtonClick);
|
||||
public LocalSettingsButton ExampleButton { get; private set; } = new("settings.miraExample.button.exampleButton", OnExampleButtonClick);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ExampleToggle { get; private set; } = config.Bind("General", "Example Bool", true);
|
||||
|
||||
@@ -3,11 +3,10 @@ using BepInEx.Configuration;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Example;
|
||||
|
||||
@@ -18,6 +17,10 @@ namespace MiraAPI.Example;
|
||||
[ReactorModFlags(ModFlags.RequireOnAllClients)]
|
||||
public partial class ExamplePlugin : BasePlugin, IMiraPlugin
|
||||
{
|
||||
public ExamplePlugin()
|
||||
{
|
||||
MiraLocaleManager.Register("mira.example");
|
||||
}
|
||||
public Harmony Harmony { get; } = new(Id);
|
||||
public string OptionsTitleText => "Mira API\nExample Mod";
|
||||
public string CustomOptionMenuNameTwo => "angxl's Options";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.GameEnd;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class NeutralKillerGameOver : CustomGameOver
|
||||
|
||||
public override void AfterEndGameSetup(EndGameManager endGameManager)
|
||||
{
|
||||
endGameManager.WinText.text = "Outcast Killer Wins!";
|
||||
endGameManager.WinText.text = "gameover.outcastKiller.win".Translate();
|
||||
endGameManager.WinText.color = Color.magenta;
|
||||
endGameManager.BackgroundBar.material.SetColor(ShaderID.Color, Color.magenta);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using MiraAPI.Example.Modifiers;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.Hud;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.Example.Roles;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -29,6 +29,9 @@ public class ShootButton : TargetedMeetingButton
|
||||
{
|
||||
playerVoteArea.SetDisabled();
|
||||
var player = playerVoteArea.GetPlayer();
|
||||
PlayerControl.LocalPlayer.RpcCustomMurder(player);
|
||||
if (player != null)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcCustomMurder(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Utilities;
|
||||
@@ -28,6 +27,7 @@ public class ShotgunButton : MultiTargetMeetingButton
|
||||
|
||||
protected override void OnClick(PlayerVoteArea playerVoteArea)
|
||||
{
|
||||
// Emptu because it only triggers the actual kills once all meeting abilities have been used.
|
||||
}
|
||||
|
||||
public override LoadableAsset<Sprite> SpriteActive => ExampleAssets.CallMeetingButton;
|
||||
@@ -45,7 +45,10 @@ public class ShotgunButton : MultiTargetMeetingButton
|
||||
{
|
||||
playerVoteArea.SetDisabled();
|
||||
var player = playerVoteArea.GetPlayer();
|
||||
PlayerControl.LocalPlayer.RpcCustomMurder(player);
|
||||
if (player != null)
|
||||
{
|
||||
PlayerControl.LocalPlayer.RpcCustomMurder(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
<Version>1.0.0</Version>
|
||||
<Description>Example mod for Mira API</Description>
|
||||
<Authors>Angxl, XtraCube</Authors>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -9,7 +10,7 @@ namespace MiraAPI.Example.Modifiers;
|
||||
|
||||
public class CaptainModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "Captain";
|
||||
public override string ModifierName => "modifier.captain";
|
||||
public override LoadableAsset<Sprite>? ModifierIcon => ExampleAssets.CallMeetingButton;
|
||||
|
||||
public override void OnDeath(DeathReason reason)
|
||||
@@ -19,7 +20,7 @@ public class CaptainModifier : GameModifier
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return $"You can call a meeting from anywhere on the map.";
|
||||
return "modifier.captain.description";
|
||||
}
|
||||
|
||||
public override int GetAssignmentChance()
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace MiraAPI.Example.Modifiers.Freezer;
|
||||
|
||||
public class FreezeModifier : TimedModifier
|
||||
{
|
||||
public override string ModifierName => "Freezed";
|
||||
public override string ModifierName => "modifier.freezed";
|
||||
public override bool HideOnUi => false;
|
||||
public override float Duration => 15f;
|
||||
public override bool AutoStart => true;
|
||||
|
||||
@@ -4,11 +4,11 @@ namespace MiraAPI.Example.Modifiers;
|
||||
|
||||
public class HighPriorityModifier : GameModifier
|
||||
{
|
||||
public override string ModifierName => "High Priority";
|
||||
public override string ModifierName => "modifier.highPriority";
|
||||
|
||||
public override string GetDescription()
|
||||
{
|
||||
return "You are high priority! Idrk what this means either tbh...";
|
||||
return "modifier.highPriority.description";
|
||||
}
|
||||
|
||||
public override int GetAssignmentChance()
|
||||
|
||||
@@ -7,19 +7,19 @@ namespace MiraAPI.Example.Options;
|
||||
|
||||
public class ExampleOptions : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "Example Options 1";
|
||||
public override string GroupName => "options.exampleOptions1";
|
||||
public override Color GroupColor => Color.green;
|
||||
|
||||
[ModdedToggleOption("Toggle Opt 1")]
|
||||
[ModdedToggleOption("options.exampleOptions1.toggleOpt1")]
|
||||
public bool ToggleOpt { get; set; } = false;
|
||||
|
||||
[ModdedToggleOption("Toggle Opt 2")]
|
||||
[ModdedToggleOption("options.exampleOptions1.toggleOpt1")]
|
||||
public bool ToggleOpt2 { get; set; } = true;
|
||||
|
||||
[ModdedNumberOption("Number Opt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
|
||||
[ModdedNumberOption("options.exampleOptions1.numberOpt", min: 0, max: 10, increment: .25f, formatString: "0.00", suffixType: MiraNumberSuffixes.Percent)]
|
||||
public float NumberOpt { get; set; } = 4f;
|
||||
|
||||
[ModdedEnumOption("Best API", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
|
||||
[ModdedEnumOption("options.exampleOptions1.bestApi", typeof(BestApi), ["Mira API", "Mitochondria", "Reactor"])]
|
||||
public BestApi Opt { get; set; } = BestApi.MiraAPI;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,22 +6,22 @@ namespace MiraAPI.Example.Options;
|
||||
|
||||
public class ExampleOptions2 : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "Example Options 2";
|
||||
public override string GroupName => "options.exampleOptions2";
|
||||
|
||||
public override uint GroupPriority => 0; // This group will be displayed first. The default value is uint.MaxValue.
|
||||
|
||||
public override MenuCategory ParentMenu => MenuCategory.CustomTwo;
|
||||
|
||||
public ModdedPlayerOption PlayerOption2 { get; } = new("YOU MUST CHOSE A PLAYER", false);
|
||||
public ModdedPlayerOption PlayerOption { get; } = new("Eh whatever");
|
||||
public ModdedToggleOption ToggleOpt1 { get; } = new("Toggle Option 1", false);
|
||||
public ModdedPlayerOption PlayerOption2 { get; } = new("options.exampleOptions2.youMustChoseAPlayer", false);
|
||||
public ModdedPlayerOption PlayerOption { get; } = new("options.exampleOptions2.ehWhatever");
|
||||
public ModdedToggleOption ToggleOpt1 { get; } = new("options.exampleOptions2.toggleOption1", false);
|
||||
|
||||
public ModdedToggleOption ToggleOpt2 { get; } = new("Toggle Option 2", false)
|
||||
public ModdedToggleOption ToggleOpt2 { get; } = new("options.exampleOptions2.toggleOption2", false)
|
||||
{
|
||||
Visible = () => OptionGroupSingleton<ExampleOptions2>.Instance.ToggleOpt1, // implicit cast from ModdedToggleOption to bool
|
||||
};
|
||||
|
||||
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("Enum Opt", 0)
|
||||
public ModdedEnumOption<TestingData> EnumOpt { get; } = new("options.exampleOptions2.enumOpt", 0)
|
||||
{
|
||||
ChangedEvent = x => Logger<ExamplePlugin>.Info($"changed Enum Opt to {x}"),
|
||||
};
|
||||
|
||||
@@ -6,14 +6,14 @@ namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class CaptainModifierSettings : AbstractOptionGroup<CaptainModifier>
|
||||
{
|
||||
public override string GroupName => "Captain Settings";
|
||||
public override string GroupName => "options.captainSettings";
|
||||
|
||||
[ModdedNumberOption("Amount", 0, 5)]
|
||||
[ModdedNumberOption("options.captainSettings.amount", 0, 5)]
|
||||
public float Amount { get; set; } = 1;
|
||||
|
||||
[ModdedNumberOption("Chance", 0, 100, 10)]
|
||||
[ModdedNumberOption("options.captainSettings.chance", 0, 100, 10)]
|
||||
public float Chance { get; set; } = 50;
|
||||
|
||||
[ModdedNumberOption("Uses", 1, 5)]
|
||||
[ModdedNumberOption("options.captainSettings.uses", 1, 5)]
|
||||
public float NumUses { get; set; } = 3;
|
||||
}
|
||||
@@ -6,8 +6,8 @@ namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class FreezeModifierSettings : AbstractOptionGroup<FreezeModifier>
|
||||
{
|
||||
public override string GroupName => "Freeze";
|
||||
public override string GroupName => "options.freezeModifierSettings";
|
||||
|
||||
[ModdedToggleOption("Use Color")]
|
||||
[ModdedToggleOption("options.freezeModifierSettings.useColor")]
|
||||
public bool UseColor { get; set; } = true;
|
||||
}
|
||||
@@ -5,15 +5,15 @@ namespace MiraAPI.Example.Options.Modifiers;
|
||||
|
||||
public class GeneralModifierOptions : AbstractOptionGroup
|
||||
{
|
||||
public override string GroupName => "General";
|
||||
public override string GroupName => "options.generalModifier";
|
||||
|
||||
public override uint GroupPriority => 0;
|
||||
|
||||
public override MenuCategory ParentMenu => MenuCategory.Modifiers;
|
||||
|
||||
[ModdedToggleOption("Some Boolean Option")]
|
||||
[ModdedToggleOption("options.generalModifier.someBooleanOption")]
|
||||
public bool SomeBooleanOption { get; set; } = true;
|
||||
|
||||
[ModdedNumberOption("Number Option", 0, 10, 1)]
|
||||
[ModdedNumberOption("options.generalModifier.numberOption", 0, 10, 1)]
|
||||
public float NumberOption { get; set; } = 5;
|
||||
}
|
||||
@@ -13,11 +13,11 @@ public class FreezerRoleSettings : AbstractOptionGroup<FreezerRole>
|
||||
TmpSpriteUtils.CreateSpriteAsset(
|
||||
MiraAssets.ImpostorFile.LoadAsset(),
|
||||
"ApiExample.Role.Impostor.FreezerRole"));
|
||||
public override string GroupName => "Custom Role";
|
||||
public override string GroupName => "ApiExample.Role.Freezer";
|
||||
|
||||
[ModdedNumberOption("Freeze Duration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
|
||||
[ModdedNumberOption("ApiExample.Role.Freezer.Settings.FreezeDuration", 1, 15, 1, MiraNumberSuffixes.Seconds)]
|
||||
public float FreezeDuration { get; set; } = 5;
|
||||
|
||||
[ModdedNumberOption("Freeze Uses", 1, 5)]
|
||||
[ModdedNumberOption("ApiExample.Role.Freezer.Settings.FreezeUses", 1, 5)]
|
||||
public float FreezeUses { get; set; } = 1;
|
||||
}
|
||||
@@ -8,13 +8,13 @@ namespace MiraAPI.Example.Options.Roles;
|
||||
|
||||
public class TeleporterOptions : AbstractRoleOptionGroup<TeleporterRole>
|
||||
{
|
||||
public override string GroupName => "Teleporter";
|
||||
public override string GroupName => "ApiExample.Role.Teleporter";
|
||||
|
||||
public ModdedNumberOption TeleportCooldown { get; set; } = new("Teleport Cooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
|
||||
public ModdedNumberOption TeleportCooldown { get; set; } = new("ApiExample.Role.Teleporter.Settings.TeleportCooldown", 10, 5, 60, 2.5f, MiraNumberSuffixes.Seconds);
|
||||
|
||||
[ModdedNumberOption("Teleport Duration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
|
||||
[ModdedNumberOption("ApiExample.Role.Teleporter.Settings.TeleportDuration", 5, 25, 1, MiraNumberSuffixes.Seconds)]
|
||||
public float TeleportDuration { get; set; } = 10;
|
||||
|
||||
[ModdedNumberOption("Zoom Distance", 4, 15)]
|
||||
[ModdedNumberOption("ApiExample.Role.Teleporter.Settings.ZoomDistance", 4, 15)]
|
||||
public float ZoomDistance { get; set; } = 6;
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="ApiExample.Role.Teleporter">Teleporter</string>
|
||||
<string name="ApiExample.Role.Teleporter.IntroBlurb">Zoom out and teleport across the map!</string>
|
||||
<string name="ApiExample.Role.Teleporter.MedDescription">Zoom out and teleport across the map!</string>
|
||||
<string name="ApiExample.Role.Teleporter.TabDescription">Zoom out and teleport across the map!</string>
|
||||
<string name="ApiExample.Role.Teleporter.WikiDescription">The Teleporter is a Crewmate role that can move around the map using their dope-ass ability.</string>
|
||||
<string name="ApiExample.Role.Freezer">Freezer</string>
|
||||
<string name="ApiExample.Role.Freezer.IntroBlurb">Get iced, nerd.</string>
|
||||
<string name="ApiExample.Role.Freezer.MedDescription">Freeze others for a duration of time.</string>
|
||||
<string name="ApiExample.Role.Freezer.TabDescription">Freeze another player for a duration of time.</string>
|
||||
<string name="ApiExample.Role.Freezer.WikiDescription">The Freezer is an Impostor role that can freeze players. Or something along those lines.</string>
|
||||
<string name="ApiExample.Role.Mayor">Mayor</string>
|
||||
<string name="ApiExample.Role.Mayor.IntroBlurb">Democracy is the best policy.</string>
|
||||
<string name="ApiExample.Role.Mayor.MedDescription">Vote out the Impostors with more votes.
|
||||
Your votes have double the power.</string>
|
||||
<string name="ApiExample.Role.Mayor.TabDescription">You get one extra vote in the meeting!</string>
|
||||
<string name="ApiExample.Role.Mayor.WikiDescription">The Mayor is a Crewmate role that gets two votes in the meeting, instead of the singular vote other Crewmates get.</string>
|
||||
<string name="ApiExample.Role.Chamelon">Chamelon</string>
|
||||
<string name="ApiExample.Role.Chamelon.IntroBlurb">Become one with the environment.</string>
|
||||
<string name="ApiExample.Role.Chamelon.MedDescription">Fade out of everyone's vision by not moving.</string>
|
||||
<string name="ApiExample.Role.Chamelon.TabDescription">Stay invisible while not moving.</string>
|
||||
<string name="ApiExample.Role.Chamelon.WikiDescription">The Chamelon is a Crewmate role that slowly becomes invisible while standing still.</string>
|
||||
<string name="ApiExample.Role.OutcastKiller">Outcast Killer</string>
|
||||
<string name="ApiExample.Role.OutcastKiller.IntroBlurb">Kill everyone else.</string>
|
||||
<string name="ApiExample.Role.OutcastKiller.MedDescription">Be the last outcast standing.
|
||||
Eliminate every other faction.</string>
|
||||
<string name="ApiExample.Role.OutcastKiller.TabDescription">Outcast who can kill.</string>
|
||||
<string name="ApiExample.Role.OutcastKiller.WikiDescription">The Outcast Killer is an Outcast role that can kill, like some sort of neutral killer...</string>
|
||||
<string name="outcast">Outcast</string>
|
||||
<string name="outcast.roleTitle">OUTCAST</string>
|
||||
<string name="outcast.teamIntroDescription">You are an Outcast. You do not have a team.</string>
|
||||
<string name="button.think">Think</string>
|
||||
<string name="button.think.thinking">Thinking...</string>
|
||||
<string name="button.freeze">Freeze</string>
|
||||
<string name="button.teleport">Teleport</string>
|
||||
<string name="button.callMeeting">Call Meeting</string>
|
||||
<string name="button.winGame">Win Game</string>
|
||||
<string name="modifier.captain">Captain</string>
|
||||
<string name="modifier.captain.TabDescription">You can call a meeting from anywhere on the map.</string>
|
||||
<string name="modifier.freezed">Freezed</string>
|
||||
<string name="modifier.highPriority">High Priority</string>
|
||||
<string name="modifier.highPriority.TabDescription">You are high priority! Idrk what this means either tbh...</string>
|
||||
<string name="options.exampleOptions1">Example Options 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt1">Toggle Opt 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt2">Toggle Opt 2</string>
|
||||
<string name="options.exampleOptions1.numberOpt">Number Opt</string>
|
||||
<string name="options.exampleOptions1.bestApi">Best API</string>
|
||||
<string name="options.exampleOptions2">Example Options 2</string>
|
||||
<string name="options.exampleOptions2.youMustChoseAPlayer">YOU MUST CHOSE A PLAYER</string>
|
||||
<string name="options.exampleOptions2.ehWhatever">Eh whatever</string>
|
||||
<string name="options.exampleOptions2.toggleOption1">Toggle Option 1</string>
|
||||
<string name="options.exampleOptions2.toggleOption2">Toggle Option 2</string>
|
||||
<string name="options.exampleOptions2.enumOpt">Enum Opt</string>
|
||||
<string name="options.captainSettings">Captain Settings</string>
|
||||
<string name="options.captainSettings.amount">Amount</string>
|
||||
<string name="options.captainSettings.chance">Chance</string>
|
||||
<string name="options.captainSettings.uses">Uses</string>
|
||||
<string name="options.freezeModifierSettings">Freeze</string>
|
||||
<string name="options.freezeModifierSettings.useColor">Use Color</string>
|
||||
<string name="options.generalModifier">General</string>
|
||||
<string name="options.generalModifier.someBooleanOption">Some Boolean Option</string>
|
||||
<string name="options.generalModifier.numberOption">Number Option</string>
|
||||
<string name="options.freezerRoleSettings">Custom Role</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeDuration">Freeze Duration</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeUses">Freeze Uses</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportCooldown">Teleport Cooldown</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportDuration">Teleport Duration</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.ZoomDistance">Zoom Distance</string>
|
||||
<string name="settings.miraExample">Mira Example</string>
|
||||
<string name="settings.miraExample.exampleBool">Example Bool</string>
|
||||
<string name="settings.miraExample.exampleBool2">Example Bool 2</string>
|
||||
<string name="settings.miraExample.slider">Slider</string>
|
||||
<string name="settings.miraExample.exampleNumber">Example Number</string>
|
||||
<string name="settings.miraExample.exampleMultiplier">Example Multplier</string>
|
||||
<string name="settings.miraExample.exampleEnum">Example Enum</string>
|
||||
<string name="settings.miraExample.button.exampleButton">Example Button</string>
|
||||
<string name="gameover.outcastKiller.win">Outcast Killer Wins!</string>
|
||||
<string name="color.cerulean">Cerulean</string>
|
||||
<string name="color.rose">Rose</string>
|
||||
<string name="color.gold">Gold</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="ApiExample.Role.Teleporter">传送者</string>
|
||||
<string name="ApiExample.Role.Teleporter.IntroBlurb">缩小视野并在地图上传送!</string>
|
||||
<string name="ApiExample.Role.Teleporter.MedDescription">缩小视野并在地图上传送!</string>
|
||||
<string name="ApiExample.Role.Teleporter.TabDescription">缩小视野并在地图上传送!</string>
|
||||
<string name="ApiExample.Role.Freezer">冰冻者</string>
|
||||
<string name="ApiExample.Role.Freezer.TabDescription">将其他玩家冰冻一段时间。</string>
|
||||
<string name="mayorrole">市长</string>
|
||||
<string name="mayorrole.description">你拥有额外投票权!</string>
|
||||
<string name="chamelonrole">变色龙</string>
|
||||
<string name="chamelonrole.description">静止不动时保持隐身。</string>
|
||||
<string name="outcastKillerrole">流放杀手</string>
|
||||
<string name="outcastKillerrole.description">可以击杀的流放者。</string>
|
||||
<string name="outcast">流放者</string>
|
||||
<string name="outcast.roleTitle">流放者</string>
|
||||
<string name="outcast.teamIntroDescription">你是流放者,你没有队伍。</string>
|
||||
<string name="button.think">思考</string>
|
||||
<string name="button.think.thinking">思考中...</string>
|
||||
<string name="button.freeze">冰冻</string>
|
||||
<string name="button.teleport">传送</string>
|
||||
<string name="button.callMeeting">召集会议</string>
|
||||
<string name="button.winGame">赢得游戏</string>
|
||||
<string name="modifier.captain">队长</string>
|
||||
<string name="modifier.captain.description">你可以在地图上任意位置召集会议。</string>
|
||||
<string name="modifier.freezed">已被冰冻</string>
|
||||
<string name="modifier.highPriority">高优先级</string>
|
||||
<string name="modifier.highPriority.description">你是高优先级!老实说我也不太清楚这是什么意思……</string>
|
||||
<string name="options.exampleOptions1">示例选项组 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt1">开关选项 1</string>
|
||||
<string name="options.exampleOptions1.toggleOpt2">开关选项 2</string>
|
||||
<string name="options.exampleOptions1.numberOpt">数字选项</string>
|
||||
<string name="options.exampleOptions1.bestApi">谁是最好的API</string>
|
||||
<string name="options.exampleOptions2">示例选项组 2</string>
|
||||
<string name="options.exampleOptions2.youMustChoseAPlayer">你必须选择一个玩家</string>
|
||||
<string name="options.exampleOptions2.ehWhatever">咕咕嘎嘎</string>
|
||||
<string name="options.exampleOptions2.toggleOption1">开关选项 1</string>
|
||||
<string name="options.exampleOptions2.toggleOption2">开关选项 2</string>
|
||||
<string name="options.exampleOptions2.enumOpt">枚举选项</string>
|
||||
<string name="options.captainSettings">队长设置</string>
|
||||
<string name="options.captainSettings.amount">数量</string>
|
||||
<string name="options.captainSettings.chance">概率</string>
|
||||
<string name="options.captainSettings.uses">使用次数</string>
|
||||
<string name="options.freezeModifierSettings">冰冻</string>
|
||||
<string name="options.freezeModifierSettings.useColor">使用颜色</string>
|
||||
<string name="options.generalModifier">通用</string>
|
||||
<string name="options.generalModifier.someBooleanOption">某个布尔选项</string>
|
||||
<string name="options.generalModifier.numberOption">数字选项</string>
|
||||
<string name="options.freezerRoleSettings">自定义职业</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeDuration">冰冻时长</string>
|
||||
<string name="ApiExample.Role.Freezer.Settings.FreezeUses">冰冻次数</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings">传送者</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportCooldown">传送冷却</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.TeleportDuration">传送持续时间</string>
|
||||
<string name="ApiExample.Role.Teleporter.Settings.ZoomDistance">缩放距离</string>
|
||||
<string name="settings.miraExample">Mira 示例插件</string>
|
||||
<string name="settings.miraExample.exampleBool">示例布尔</string>
|
||||
<string name="settings.miraExample.exampleBool2">示例布尔 2</string>
|
||||
<string name="settings.miraExample.slider">滑块</string>
|
||||
<string name="settings.miraExample.exampleNumber">示例数字</string>
|
||||
<string name="settings.miraExample.exampleMultiplier">示例倍数</string>
|
||||
<string name="settings.miraExample.exampleEnum">示例枚举</string>
|
||||
<string name="settings.miraExample.button.exampleButton">示例按钮</string>
|
||||
<string name="gameover.outcastKiller.win">流放杀手获胜!</string>
|
||||
<string name="color.cerulean">天蓝</string>
|
||||
<string name="color.rose">玫瑰红</string>
|
||||
<string name="color.gold">金色</string>
|
||||
</resources>
|
||||
@@ -10,9 +10,7 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class ChameloenRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Chamelon";
|
||||
public string RoleLongDescription => "Stay invisible while not moving.";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "ApiExample.Role.Chamelon";
|
||||
public Color RoleColor => Palette.AcceptedGreen;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
|
||||
|
||||
@@ -6,9 +6,7 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class FreezerRole : ImpostorRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Freezer";
|
||||
public string RoleLongDescription => "Freeze another player for a duration of time.";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "ApiExample.Role.Freezer";
|
||||
public Color RoleColor => Palette.Blue;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Impostor;
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class MayorRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Mayor";
|
||||
public string RoleLongDescription => "You get extra votes!";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "ApiExample.Role.Mayor";
|
||||
public Color RoleColor => new Color32(221, 176, 152, 255);
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
public CustomRoleConfiguration Configuration => new(this);
|
||||
|
||||
@@ -8,9 +8,7 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class NeutralKillerRole : ImpostorRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Outcast Killer";
|
||||
public string RoleDescription => "Outcast who can kill.";
|
||||
public string RoleLongDescription => RoleDescription;
|
||||
public string IdPart => "ApiExample.Role.OutcastKiller";
|
||||
public Color RoleColor => Color.magenta;
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Custom;
|
||||
|
||||
@@ -21,13 +19,13 @@ public class NeutralKillerRole : ImpostorRole, ICustomRole
|
||||
CanUseVent = true,
|
||||
};
|
||||
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("Outcast", Color.gray);
|
||||
public RoleOptionsGroup RoleOptionsGroup { get; } = new("outcast", Color.gray);
|
||||
|
||||
[HideFromIl2Cpp]
|
||||
public TeamIntroConfiguration? IntroConfiguration { get; } = new(
|
||||
Color.gray,
|
||||
"OUTCAST",
|
||||
"You are an Outcast. You do not have a team.");
|
||||
"outcast.roleTitle",
|
||||
"outcast.teamIntroDescription");
|
||||
|
||||
public override void SpawnTaskHeader(PlayerControl playerControl)
|
||||
{
|
||||
|
||||
@@ -5,9 +5,7 @@ namespace MiraAPI.Example.Roles;
|
||||
|
||||
public class TeleporterRole : CrewmateRole, ICustomRole
|
||||
{
|
||||
public string RoleName => "Teleporter";
|
||||
public string RoleLongDescription => "Zoom out and teleport across the map!";
|
||||
public string RoleDescription => RoleLongDescription;
|
||||
public string IdPart => "ApiExample.Role.Teleporter";
|
||||
public Color RoleColor => new Color32(221, 176, 152, 255);
|
||||
public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Colors;
|
||||
@@ -43,7 +43,7 @@ public sealed class CustomColor(StringNames name, Color32 mainColor, Color32 sha
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(CustomStringName.CreateAndRegister(name), mainColor, shadowColor)
|
||||
public CustomColor(string name, Color32 mainColor, Color32 shadowColor) : this(MiraLocaleManager.GetOrCreateLocaleString(name), mainColor, shadowColor)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ public static class PaletteManager
|
||||
{
|
||||
var colors = CustomColors.Select(x => x.MainColor).ToArray();
|
||||
var shadowColors = CustomColors.Select(x => x.ShadowColor).ToArray();
|
||||
var stringNames = CustomColors.Select(x => x.Name).ToArray();
|
||||
var stringNames = CustomColors.Select(x =>
|
||||
x.Name).ToArray();
|
||||
|
||||
Palette.PlayerColors = Palette.PlayerColors.ToArray().AddRangeToArray(colors);
|
||||
Palette.ShadowColors = Palette.ShadowColors.ToArray().AddRangeToArray(shadowColors);
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -32,7 +33,7 @@ public abstract class AbstractGameMode : IOptionable
|
||||
public abstract string Description { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game mode description.
|
||||
/// Gets the game mode color to display on the lobby pane.
|
||||
/// </summary>
|
||||
public virtual Color Color { get; } = Color.white;
|
||||
|
||||
@@ -42,14 +43,14 @@ public abstract class AbstractGameMode : IOptionable
|
||||
public virtual LoadableAsset<Sprite>? Icon => null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the icon of the gamemode for use on the options pop-up.
|
||||
/// Gets or sets the icon of the gamemode for use on the options pop-up.
|
||||
/// </summary>
|
||||
public TMP_SpriteAsset TmpIcon { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the colored game mode name, using the color and name properties.
|
||||
/// </summary>
|
||||
public string ColoredName => $"<color=#{this.Color.ToHtmlStringRGBA()}>{this.Name}</color>";
|
||||
public string ColoredName => $"<color=#{Color.ToHtmlStringRGBA()}>{MiraLocaleManager.Get(Name)}</color>";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the game mode id.
|
||||
|
||||
@@ -11,10 +11,10 @@ namespace MiraAPI.GameModes;
|
||||
public class ClassicMode : AbstractGameMode
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string Name => "Classic";
|
||||
public override string Name => "MiraApi.Gamemode.Classic";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "The classic Among Us experience!\nFind the Impostors or deceive the Crew.";
|
||||
public override string Description => "MiraApi.Gamemode.Classic.Description";
|
||||
|
||||
public override LoadableAsset<Sprite>? Icon => MiraAssets.ClassicGamemodeIcon;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.PluginLoading;
|
||||
using Reactor.Utilities;
|
||||
|
||||
@@ -58,7 +59,7 @@ public static class CustomGameModeManager
|
||||
/// <summary>
|
||||
/// Checks to see if the current game mode is an instance of the HNS mode.
|
||||
/// </summary>
|
||||
/// <returns>True if the Hide & Seek mode is the current one.</returns>
|
||||
/// <returns>True if the Hide n Seek mode is the current one.</returns>
|
||||
public static bool IsHideNSeek() => ActiveMode != null && ActiveMode.GetType().IsAssignableTo(typeof(HideAndSeekMode));
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -6,6 +6,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Patches.GameModes;
|
||||
using MiraAPI.Patches.Options;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -48,17 +49,17 @@ public static class GameModeOption
|
||||
internal static StringOption OptionBehaviour { get; set; } = null!;
|
||||
|
||||
internal static int _lastValue;
|
||||
internal static readonly StringNames GamemodeName = CustomStringName.CreateAndRegister("Gamemode");
|
||||
internal static readonly StringNames CustomName = CustomStringName.CreateAndRegister("Custom");
|
||||
internal static readonly StringNames GamemodeName = MiraLocaleManager.GetOrCreateLocaleString("Gamemode");
|
||||
internal static readonly StringNames CustomName = MiraLocaleManager.GetOrCreateLocaleString("Custom");
|
||||
internal static readonly Dictionary<uint, StringNames> Values = new()
|
||||
{
|
||||
[0] = CustomStringName.CreateAndRegister("Classic"),
|
||||
[0] = MiraLocaleManager.GetOrCreateLocaleString("MiraApi.Gamemode.Classic"),
|
||||
};
|
||||
|
||||
internal static void AddOption(AbstractGameMode mode)
|
||||
{
|
||||
if (!Values.ContainsKey(mode.ID))
|
||||
Values.Add(mode.ID, CustomStringName.CreateAndRegister(mode.ColoredName));
|
||||
Values.Add(mode.ID, MiraLocaleManager.GetOrCreateLocaleString(mode.Name));
|
||||
}
|
||||
/*[HarmonyPatch(typeof(GameOptionsMenu), nameof(GameOptionsMenu.CreateSettings))]
|
||||
[HarmonyPostfix]
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace MiraAPI.GameModes;
|
||||
public class HideAndSeekMode : AbstractGameMode
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public override string Name => "Hide n Seek";
|
||||
public override string Name => "MiraApi.Gamemode.HideAndSeek";
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string Description => "You can run, but you can't hide!\nOutlive the timer or eliminate the crew.";
|
||||
public override string Description => "MiraApi.Gamemode.HideAndSeek.Description";
|
||||
|
||||
// TODO: Once the Hide n Seek port is ready for release, we will remove this.
|
||||
public override bool HideMode => !MiraApiPlugin.IsDevBuild;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Translation;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class ModdedEnumOptionAttribute(string title, Type enumType, string[]? va
|
||||
{
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
var opt = new ModdedEnumOption(Title, (int)(value ?? 0), enumType, values);
|
||||
var opt = new ModdedEnumOption(Title.Translate(), (int)(value ?? 0), enumType, values);
|
||||
return opt;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
@@ -22,7 +23,7 @@ public class ModdedNumberOptionAttribute(
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
return new ModdedNumberOption(
|
||||
Title,
|
||||
Title.Translate(),
|
||||
(float)(value ?? min + increment),
|
||||
min,
|
||||
max,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using MiraAPI.GameOptions.OptionTypes;
|
||||
using MiraAPI.Translation;
|
||||
|
||||
namespace MiraAPI.GameOptions.Attributes;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class ModdedToggleOptionAttribute(string title) : ModdedOptionAttribute(t
|
||||
{
|
||||
internal override IModdedOption CreateOption(object? value, PropertyInfo property)
|
||||
{
|
||||
var toggleOpt = new ModdedToggleOption(Title, (bool)(value ?? false));
|
||||
var toggleOpt = new ModdedToggleOption(Title.Translate(), (bool)(value ?? false));
|
||||
return toggleOpt;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Localization.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -37,8 +38,8 @@ public class ModdedEnumOption : ModdedOption<int>
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
data.Values = values is null ?
|
||||
Enum.GetNames(enumType).Select(CustomStringName.CreateAndRegister).ToArray()
|
||||
: [.. values.Select(CustomStringName.CreateAndRegister)];
|
||||
Enum.GetNames(enumType).Select(MiraLocaleManager.GetOrCreateLocaleString).ToArray()
|
||||
: [.. values.Select(MiraLocaleManager.GetOrCreateLocaleString)];
|
||||
|
||||
data.Index = Value;
|
||||
}
|
||||
@@ -136,8 +137,8 @@ public class ModdedEnumOption<T> : ModdedOption<T> where T : Enum
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
data.Values = values is null ?
|
||||
Enum.GetNames(typeof(T)).Select(CustomStringName.CreateAndRegister).ToArray()
|
||||
: [.. values.Select(CustomStringName.CreateAndRegister)];
|
||||
Enum.GetNames(typeof(T)).Select(MiraLocaleManager.GetOrCreateLocaleString).ToArray()
|
||||
: [.. values.Select(MiraLocaleManager.GetOrCreateLocaleString)];
|
||||
|
||||
data.Index = Convert.ToInt32(Value, NumberFormatInfo.InvariantInfo);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Localization.Utilities;
|
||||
using Reactor.Networking.Rpc;
|
||||
using UnityEngine;
|
||||
@@ -78,10 +79,10 @@ public abstract class ModdedOption<T> : IModdedOption
|
||||
protected ModdedOption(string title, T defaultValue, bool includeInPreset = true)
|
||||
{
|
||||
Id = ModdedOptionsManager.NextId;
|
||||
Title = title;
|
||||
Title = title.Translate();
|
||||
DefaultValue = defaultValue;
|
||||
Value = defaultValue;
|
||||
StringName = CustomStringName.CreateAndRegister(Title);
|
||||
StringName = MiraLocaleManager.GetOrCreateLocaleString(Title);
|
||||
Visible = () => true;
|
||||
IncludeInPreset = includeInPreset;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using Il2CppSystem.Collections.Generic;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -65,7 +66,7 @@ public class ModdedPlayerOption : ModdedOption<int>
|
||||
playerOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
|
||||
playerOption.Title = StringName;
|
||||
playerOption.TitleText.text = TranslationController.Instance.GetString(StringName);
|
||||
playerOption.TitleText.text = Title.Translate();
|
||||
playerOption.Values = Values;
|
||||
playerOption.Value = Value;
|
||||
playerOption.playerIndex = filteredList.FindIndex(p => p.PlayerId == Value);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Localization.Utilities;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
@@ -56,7 +57,7 @@ public class ModdedStringOption : ModdedOption<string>
|
||||
newVals.Insert(index, value);
|
||||
Values = newVals.ToArray();
|
||||
var newStrVals = StringNameValues.ToList();
|
||||
newStrVals.Insert(index, CustomStringName.CreateAndRegister(value));
|
||||
newStrVals.Insert(index, MiraLocaleManager.GetOrCreateLocaleString(value));
|
||||
StringNameValues = newStrVals.ToArray();
|
||||
}
|
||||
|
||||
@@ -108,7 +109,7 @@ public class ModdedStringOption : ModdedOption<string>
|
||||
|
||||
data.Title = StringName;
|
||||
data.Type = global::OptionTypes.String;
|
||||
StringNameValues = values.Select(CustomStringName.CreateAndRegister).ToArray();
|
||||
StringNameValues = values.Select(MiraLocaleManager.GetOrCreateLocaleString).ToArray();
|
||||
data.Values = StringNameValues;
|
||||
|
||||
data.Index = GetIndex(Value, 3);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Translation;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -35,7 +36,7 @@ public class ModdedToggleOption : ModdedOption<bool>
|
||||
toggleOption.SetUpFromData(Data, 20);
|
||||
|
||||
toggleOption.Title = StringName;
|
||||
toggleOption.TitleText.text = Title;
|
||||
toggleOption.TitleText.text = Title.Translate();
|
||||
toggleOption.CheckMark.enabled = Value;
|
||||
toggleOption.OnValueChanged = (Il2CppSystem.Action<OptionBehaviour>)ValueChanged;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using MiraAPI.Events.Mira;
|
||||
using MiraAPI.Keybinds;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Patches;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Rewired;
|
||||
@@ -150,7 +151,7 @@ public abstract class CustomActionButton
|
||||
|
||||
Button = Object.Instantiate(HudManager.Instance.AbilityButton, parent);
|
||||
Button.name = Name + "Button";
|
||||
Button.OverrideText(Name.ToUpperInvariant());
|
||||
Button.OverrideText(Name.Translate().ToUpperInvariant());
|
||||
|
||||
Button.graphic.sprite = Sprite.LoadAsset();
|
||||
|
||||
|
||||
@@ -39,4 +39,9 @@ public interface ILocalSetting
|
||||
/// <param name="last">Whether it's the last on the row.</param>
|
||||
/// <returns>The created setting's <see cref="GameObject"/>.</returns>
|
||||
GameObject? CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
|
||||
|
||||
/// <summary>
|
||||
/// Used to refresh the setting's information, usually for localization.
|
||||
/// </summary>
|
||||
void RefreshOption();
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -28,6 +29,8 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
/// </summary>
|
||||
public LocalSettingsTab? Tab { get; internal set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
|
||||
internal GameObject CreateButton(ToggleButtonBehaviour toggle, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
var button = Object.Instantiate(toggle, parent).GetComponent<PassiveButton>();
|
||||
@@ -51,7 +54,8 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
button.transform.localPosition = new Vector3(order == 1 ? -1.185f : 1.185f, 1.85f - offset, -7);
|
||||
}
|
||||
|
||||
tmp.text = Text;
|
||||
tmp.text = Text.Translate();
|
||||
_btnText = tmp;
|
||||
button.name = Text;
|
||||
button.OnClick = new UnityEngine.UI.Button.ButtonClickedEvent();
|
||||
rollover.OutColor = Tab!.TabAppearance.ButtonColor;
|
||||
@@ -74,4 +78,9 @@ public class LocalSettingsButton(string text, Action onClick)
|
||||
|
||||
return button.gameObject;
|
||||
}
|
||||
|
||||
public void RefreshButton()
|
||||
{
|
||||
_btnText.text = Text.Translate();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using BepInEx.Configuration;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.LocalSettings.SettingTypes;
|
||||
using MiraAPI.Patches.LocalSettings;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -47,11 +49,21 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
/// </summary>
|
||||
public TabGroup? TabButton { get; internal set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="TextMeshPro"/>s alongside the locale keys for them.
|
||||
/// </summary>
|
||||
public static Dictionary<TextMeshPro, string> TabGroups { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="ILocalSetting"/>s.
|
||||
/// </summary>
|
||||
public List<ILocalSetting> Settings { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets a collection of <see cref="TextMeshPro"/>s alongside the locale keys for them.
|
||||
/// </summary>
|
||||
public Dictionary<TextMeshPro, string> Labels { get; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of <see cref="LocalSettingsButton"/>s.
|
||||
/// </summary>
|
||||
@@ -73,12 +85,25 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to open the tab.
|
||||
/// Refreshes setting names upon opening the tab.
|
||||
/// Override for custom behavior.
|
||||
/// </summary>
|
||||
public virtual void Open()
|
||||
{
|
||||
OptionsMenuPatches.Instance?.OpenTabGroup(TabIndex);
|
||||
foreach (var setting in Settings)
|
||||
{
|
||||
setting.RefreshOption();
|
||||
}
|
||||
foreach (var button in Buttons)
|
||||
{
|
||||
button.RefreshButton();
|
||||
}
|
||||
|
||||
foreach (var label in Labels)
|
||||
{
|
||||
label.Key.text =
|
||||
$"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{label.Value.Translate()}</b></font>";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -216,7 +241,8 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
tabButtonText.transform.localPosition = new Vector3(0.078f, 0, 0);
|
||||
tabButtonText.transform.localScale = new Vector3(0.9f, 0.9f);
|
||||
tabButtonText.alignment = TextAlignmentOptions.Right;
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName)}</b>";
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName.Translate())}</b>";
|
||||
TabGroups.Add(tabButtonText, TabName);
|
||||
|
||||
var tabButton = tabButtonObject.GetComponent<PassiveButton>();
|
||||
var rollover = tabButtonObject.Rollover;
|
||||
@@ -244,7 +270,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
tabButtonText.gameObject.SetActive(true);
|
||||
tabButtonText.transform.localPosition = new Vector3(-0.024f, 0, 0);
|
||||
tabButtonText.maxVisibleCharacters = int.MaxValue;
|
||||
tabButtonText.text = TabName;
|
||||
tabButtonText.text = TabName.Translate();
|
||||
tabButtonText.alignment = TextAlignmentOptions.Left;
|
||||
tabButtonRend?.gameObject.SetActive(!TabAppearance.HideIconOnHover);
|
||||
}));
|
||||
@@ -266,13 +292,13 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
|
||||
tabButtonText.transform.localPosition = new Vector3(0.1f, 0, 0);
|
||||
tabButtonText.maxVisibleCharacters = 4;
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName)}</b>";
|
||||
tabButtonText.text = $"<b>{GetShortName(TabName.Translate())}</b>";
|
||||
}));
|
||||
|
||||
return tabButtonObject.gameObject;
|
||||
}
|
||||
|
||||
private static void CreateLabel(GameObject template, Transform parent, string text, ref float offset)
|
||||
private void CreateLabel(GameObject template, Transform parent, string text, ref float offset)
|
||||
{
|
||||
var label = Object.Instantiate(template, parent);
|
||||
label.transform.localPosition = new Vector3(0, 1.85f - offset);
|
||||
@@ -280,7 +306,8 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
label.name = text;
|
||||
|
||||
var tmp = label.GetComponent<TextMeshPro>();
|
||||
tmp.text = $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{text}</b></font>";
|
||||
Labels.Add(tmp, text);
|
||||
tmp.text = $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\"><b>{text.Translate()}</b></font>";
|
||||
tmp.alignment = TextAlignmentOptions.Center;
|
||||
|
||||
var meshRend = label.GetComponent<MeshRenderer>();
|
||||
@@ -290,7 +317,7 @@ public abstract class LocalSettingsTab(ConfigFile config)
|
||||
offset += 0.5f;
|
||||
}
|
||||
|
||||
private static string GetShortName(string name)
|
||||
internal static string GetShortName(string name)
|
||||
{
|
||||
var shortName = string.Empty;
|
||||
name.Split(' ').Do(x => shortName += x[0]);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -25,6 +26,10 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
/// </summary>
|
||||
public string[] Values { get; }
|
||||
|
||||
private SpriteRenderer _highlight { get; set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalEnumSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -53,6 +58,7 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
{
|
||||
var button = Object.Instantiate(toggle, parent).GetComponent<PassiveButton>();
|
||||
var tmp = button.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>();
|
||||
_btnText = tmp;
|
||||
var rollover = button.GetComponent<ButtonRolloverHandler>();
|
||||
tmp.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
button.gameObject.SetActive(true);
|
||||
@@ -62,6 +68,7 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
var highlight = button.transform.FindChild("ButtonHighlight")?.GetComponent<SpriteRenderer>();
|
||||
if (highlight != null)
|
||||
{
|
||||
_highlight = highlight;
|
||||
highlight.color = Tab!.TabAppearance.EnumHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -124,9 +131,19 @@ public class LocalEnumSetting : LocalSettingBase<int>
|
||||
return button.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_btnText.text = GetValueText();
|
||||
if (_highlight)
|
||||
{
|
||||
_highlight.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{Values[GetValue()]}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}: <b>{Values[GetValue()].Translate()}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -34,6 +35,10 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; }
|
||||
|
||||
private SpriteRenderer _highlight { get; set; }
|
||||
|
||||
private TextMeshPro _btnText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalNumberSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -64,6 +69,7 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
{
|
||||
var button = Object.Instantiate(toggle, parent).GetComponent<PassiveButton>();
|
||||
var tmp = button.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>();
|
||||
_btnText = tmp;
|
||||
var rollover = button.GetComponent<ButtonRolloverHandler>();
|
||||
tmp.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
button.gameObject.SetActive(true);
|
||||
@@ -73,6 +79,7 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
var highlight = button.transform.FindChild("ButtonHighlight")?.GetComponent<SpriteRenderer>();
|
||||
if (highlight != null)
|
||||
{
|
||||
_highlight = highlight;
|
||||
highlight.color = Tab!.TabAppearance.NumberHoverColor;
|
||||
highlight.gameObject.SetActive(false);
|
||||
}
|
||||
@@ -135,11 +142,21 @@ public class LocalNumberSetting : LocalSettingBase<float>
|
||||
return button.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_btnText.text = GetValueText();
|
||||
if (_highlight)
|
||||
{
|
||||
_highlight.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
var value = GetValue();
|
||||
var formated = Helpers.FormatValue(value, SuffixType, FormatString);
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{formated}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}: <b>{formated}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,9 @@ public abstract class LocalSettingBase<T> : ILocalSetting
|
||||
/// <returns>The created setting.</returns>
|
||||
public abstract GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last);
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract void RefreshOption();
|
||||
|
||||
/// <summary>
|
||||
/// Returns the formated string to use in the text of the setting.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -39,6 +40,8 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
/// </summary>
|
||||
public MiraNumberSuffixes SuffixType { get; }
|
||||
|
||||
private SlideBar _slider { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalSliderSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -70,6 +73,7 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
var newSlider = Object.Instantiate(slider, parent).GetComponent<SlideBar>();
|
||||
_slider = newSlider;
|
||||
var rollover = newSlider.GetComponent<ButtonRolloverHandler>();
|
||||
newSlider.Title = newSlider.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>(); // Why the hell slider has a title property that is not even assigned???
|
||||
newSlider.Title.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
@@ -104,6 +108,12 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
return newSlider.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_slider.Title.text = GetValueText();
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override string GetValueText()
|
||||
{
|
||||
@@ -112,9 +122,9 @@ public class LocalSliderSetting : LocalSettingBase<float>
|
||||
var value = GetValue();
|
||||
var formated = Helpers.FormatValue(value, SuffixType, FormatString);
|
||||
var maxFormated = Helpers.FormatValue(SliderRange.max, SuffixType, FormatString);
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}: <b>{formated} / {maxFormated}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}: <b>{formated} / {maxFormated}</font></b>";
|
||||
}
|
||||
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name}</font></b>";
|
||||
return $"<font=\"LiberationSans SDF\" material=\"LiberationSans SDF - Chat Message Masked\">{Name.Translate()}</font></b>";
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using TMPro;
|
||||
@@ -14,6 +15,8 @@ namespace MiraAPI.LocalSettings.SettingTypes;
|
||||
/// </summary>
|
||||
public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
{
|
||||
private ToggleButtonBehaviour _toggle { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LocalToggleSetting"/> class.
|
||||
/// </summary>
|
||||
@@ -31,6 +34,7 @@ public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
public override GameObject CreateOption(ToggleButtonBehaviour toggle, SlideBar slider, Transform parent, ref float offset, ref int order, bool last)
|
||||
{
|
||||
var toggleObject = Object.Instantiate(toggle, parent).GetComponent<ToggleButtonBehaviour>();
|
||||
_toggle = toggleObject;
|
||||
var tmp = toggleObject.transform.FindChild("Text_TMP").GetComponent<TextMeshPro>();
|
||||
var passiveButton = toggleObject.GetComponent<PassiveButton>();
|
||||
var rollover = toggleObject.GetComponent<ButtonRolloverHandler>();
|
||||
@@ -46,9 +50,9 @@ public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
toggleObject.transform.localPosition = new Vector3(order == 1 ? -1.185f : 1.185f, 1.85f - offset, -7);
|
||||
}
|
||||
|
||||
toggleObject.BaseText = CustomStringName.CreateAndRegister(Name);
|
||||
toggleObject.BaseText = MiraLocaleManager.GetOrCreateLocaleString(Name);
|
||||
toggleObject.UpdateText(GetValue());
|
||||
toggleObject.name = Name;
|
||||
toggleObject.name = Name.Translate();
|
||||
toggleObject.Background.color = GetValue() ? Tab!.TabAppearance.ToggleActiveColor : Tab!.TabAppearance.ToggleInactiveColor;
|
||||
passiveButton.OnClick = new UnityEngine.UI.Button.ButtonClickedEvent();
|
||||
rollover.OverColor = Tab!.TabAppearance.ToggleHoverColor;
|
||||
@@ -85,4 +89,11 @@ public class LocalToggleSetting : LocalSettingBase<bool>
|
||||
|
||||
return toggleObject.gameObject;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override void RefreshOption()
|
||||
{
|
||||
_toggle.UpdateText(GetValue());
|
||||
_toggle.Background.color = GetValue() ? Tab!.TabAppearance.ToggleActiveColor : Tab!.TabAppearance.ToggleInactiveColor;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
global using static Reactor.Utilities.Logger<MiraAPI.MiraApiPlugin>;
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using BepInEx;
|
||||
using BepInEx.Configuration;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using HarmonyLib;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.VanillaEvents;
|
||||
using Reactor;
|
||||
using Reactor.Localization;
|
||||
using Reactor.Networking;
|
||||
using Reactor.Networking.Attributes;
|
||||
using Reactor.Utilities;
|
||||
@@ -29,6 +32,11 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
return Config;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the specified Culture for string manipulations.
|
||||
/// </summary>
|
||||
public static CultureInfo Culture { get; internal set; } = new("en-US");
|
||||
|
||||
/// <inheritdoc />
|
||||
public string OptionsTitleText => "MiraAPI";
|
||||
|
||||
@@ -69,6 +77,9 @@ public partial class MiraApiPlugin : BasePlugin, IMiraPlugin
|
||||
PluginManager = new MiraPluginManager();
|
||||
PluginManager.Initialize(this, this);
|
||||
|
||||
MiraLocaleManager.Register("mira.api");
|
||||
LocalizationManager.Register(new MiraLocalizationProvider());
|
||||
|
||||
IL2CPPChainloader.Instance.Finished +=
|
||||
ModCompatibility
|
||||
.Initialize; // Initialise AFTER the mods are loaded to ensure maximum parity (no need for the soft dependency either then)
|
||||
|
||||
+20
-25
@@ -4,6 +4,7 @@ using MiraAPI.Hud;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.LocalSettings.Attributes;
|
||||
using MiraAPI.Patches;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
@@ -16,7 +17,7 @@ namespace MiraAPI;
|
||||
public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override string TabName => "Mira API";
|
||||
public override string TabName => "MiraApi";
|
||||
|
||||
/// <inheritdoc />
|
||||
public override LocalSettingTabAppearance TabAppearance => new()
|
||||
@@ -204,58 +205,52 @@ public class MiraApiSettings(ConfigFile config) : LocalSettingsTab(config)
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("Visuals/UI", "Show Modifiers HUD on Left Side", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show keybinds on buttons.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("Visuals/UI", "Show Keybinds on Buttons", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the ability buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.5f, max: 1.5f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> ButtonUIFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Button Scale Factor", 0.75f);
|
||||
config.Bind("MiraApi.VisualsUi", "MiraApi.ButtonScaleFactor", 0.75f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the scale of the UI buttons.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 0.3f, max: 2f, suffixType: MiraNumberSuffixes.Multiplier, formatString: "0.00", displayValue: true)]
|
||||
public ConfigEntry<float> TopRightButtonsFactorSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Top-Right UI Scale Factor", 1f);
|
||||
config.Bind("MiraApi.VisualsUi", "MiraApi.TopRightButtonScaleFactor", 1f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the fps specified by the player.
|
||||
/// </summary>
|
||||
[LocalSliderSetting(min: 60f, max: 240f, suffixType: MiraNumberSuffixes.None, formatString: "0", displayValue: true, roundValue: true)]
|
||||
public ConfigEntry<float> SetFpsSlider { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Max FPS", 120f);
|
||||
config.Bind("MiraApi.VisualsUi", "Max FPS", 120f);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether the modifiers hud should be on the left side of the screen (under roles/task tab). Recommended for streamers.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ModifiersHudLeftSide { get; private set; } = config.Bind("MiraApi.VisualsUi", "MiraApi.ShowModifiersHudOnLeftSide", false);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show keybinds on buttons.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> ShowKeybinds { get; private set; } = config.Bind("MiraApi.VisualsUi", "MiraApi.ShowKeybindsOnButtons", true);
|
||||
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> WikiOnBottomRow { get; private set; } =
|
||||
config.Bind("Visuals/UI", "Display Wiki on Bottom Row", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to apply cosmetic changes to the TaskAdder.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> PrettyTaskAdder { get; private set; } = config.Bind("Freeplay", "Pretty Task Laptop", true);
|
||||
config.Bind("MiraApi.VisualsUi", "MiraApi.WikiOnBottomRow", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to show the red flash from sabotages.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageFlashes { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Flashes", true);
|
||||
public ConfigEntry<bool> EnableSabotageFlashes { get; private set; } = config.Bind("MiraApi.Accessibility", "MiraApi.EnableSabotageFlashes", true);
|
||||
|
||||
/// <summary>
|
||||
/// Gets whether to enable the sabotage sound effects or not.
|
||||
/// </summary>
|
||||
[LocalToggleSetting]
|
||||
public ConfigEntry<bool> EnableSabotageBlares { get; private set; } = config.Bind("Accessibility", "Enable Sabotage Blare", true);
|
||||
public ConfigEntry<bool> EnableSabotageBlares { get; private set; } = config.Bind("MiraApi.Accessibility", "MiraApi.EnableSabotageBlare", true);
|
||||
}
|
||||
@@ -8,6 +8,8 @@ using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Modifiers.ModifierDisplay;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.Patches.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -76,7 +78,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while deactivating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Error($"Error while deactivating modifier {modifier.ModifierName.Translate()}: {e.ToString()}");
|
||||
}
|
||||
|
||||
Modifiers.Remove(modifier);
|
||||
@@ -94,7 +96,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while activating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Error($"Error while activating modifier {modifier.ModifierName.Translate()}: {e.ToString()}");
|
||||
}
|
||||
|
||||
if (modifier is TimedModifier { AutoStart: true } timer)
|
||||
@@ -121,7 +123,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Error($"Error while (fixed) updating modifier {modifier.ModifierName.Translate()}: {e.ToString()}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +154,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Error while updating modifier {modifier.ModifierName}: {e.ToString()}");
|
||||
Error($"Error while updating modifier {modifier.ModifierName.Translate()}: {e.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -351,7 +353,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
if (!ActiveModifiers.Contains(modifier))
|
||||
{
|
||||
Error($"Cannot remove modifier {modifier.ModifierName} because it is not active on this player.");
|
||||
Error($"Cannot remove modifier {modifier.ModifierName.Translate()} because it is not active on this player.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -153,7 +154,7 @@ public class ModifierDisplayComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
private ModifierUiComponent CreateForModifier(BaseModifier modifier)
|
||||
{
|
||||
var newMod = Instantiate(_modTemplate, _children.transform);
|
||||
newMod.transform.name = modifier.ModifierName;
|
||||
newMod.transform.name = modifier.ModifierName.Translate();
|
||||
var comp = newMod.AddComponent<ModifierUiComponent>();
|
||||
comp.Modifier = modifier;
|
||||
return comp;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Il2CppInterop.Runtime.Attributes;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Utilities.Attributes;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -50,8 +51,8 @@ public class ModifierUiComponent(nint cppPtr) : MonoBehaviour(cppPtr)
|
||||
return;
|
||||
}
|
||||
|
||||
nameText.text = Modifier.ModifierName;
|
||||
desc.text = Modifier.GetDescription();
|
||||
nameText.text = Modifier.ModifierName.Translate();
|
||||
desc.text = Modifier.GetDescription().Translate();
|
||||
modBg.gameObject.SetActive(true);
|
||||
|
||||
icon.gameObject.SetActive(Modifier.ModifierIcon != null);
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Linq;
|
||||
using System.Runtime.Serialization;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -138,7 +139,7 @@ public static class ModifierManager
|
||||
{
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
Warning($"No valid players for modifier {modifier.ModifierName}");
|
||||
Warning($"No valid players for modifier {modifier.ModifierName.Translate()}");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@@ -163,7 +164,7 @@ public static class ModifierManager
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
Warning(
|
||||
$"No available players for modifier {modifier.ModifierName} at assignment {i + 1}");
|
||||
$"No available players for modifier {modifier.ModifierName.Translate()} at assignment {i + 1}");
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -174,7 +175,7 @@ public static class ModifierManager
|
||||
{
|
||||
if (MiraApiPlugin.IsDevBuild)
|
||||
{
|
||||
Warning($"Valid player for modifier {modifier.ModifierName} disappeared");
|
||||
Warning($"Valid player for modifier {modifier.ModifierName.Translate()} disappeared");
|
||||
}
|
||||
|
||||
continue;
|
||||
|
||||
@@ -7,7 +7,7 @@ using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Patches;
|
||||
|
||||
[HarmonyPatch(typeof(DetectiveNotesMinigame), nameof(DetectiveNotesMinigame.SetImpostorPopup))]
|
||||
/*[HarmonyPatch(typeof(DetectiveNotesMinigame), nameof(DetectiveNotesMinigame.SetImpostorPopup))]
|
||||
public static class DetectiveNotesMinigamePatch
|
||||
{
|
||||
public static void Prefix(DetectiveNotesMinigame __instance, bool active)
|
||||
@@ -39,4 +39,4 @@ public static class DetectiveNotesMinigamePatch
|
||||
}
|
||||
ControllerManager.Instance.OpenOverlayMenu(__instance.ImpostorOverlay, __instance.impostorTypePopup, __instance.ImpostorIconControllerSelectables[0], __instance.ImpostorIconControllerSelectables, false);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
@@ -5,11 +5,11 @@ using System.Text;
|
||||
using AmongUs.GameOptions;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.LocalSettings;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Modifiers.Types;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -268,13 +268,9 @@ public static class TaskAdderPatches
|
||||
stringBuilder.Append('\\');
|
||||
}
|
||||
__instance.PathText.text = stringBuilder.ToString();
|
||||
var prettyEnabled = LocalSettingsTabSingleton<MiraApiSettings>.Instance.PrettyTaskAdder.Value;
|
||||
if (prettyEnabled)
|
||||
{
|
||||
__instance.PathText.fontSizeMin = 3;
|
||||
__instance.PathText.fontSizeMax = 3;
|
||||
__instance.transform.FindChild("TitleText_TMP")?.gameObject.DestroyImmediate();
|
||||
}
|
||||
__instance.PathText.fontSizeMin = 3;
|
||||
__instance.PathText.fontSizeMax = 3;
|
||||
__instance.transform.FindChild("TitleText_TMP")?.gameObject.DestroyImmediate();
|
||||
|
||||
__instance.ActiveItems.ToArray().Do(x => x.gameObject.DeepDestroy(false));
|
||||
__instance.ActiveItems.Clear();
|
||||
@@ -354,15 +350,12 @@ public static class TaskAdderPatches
|
||||
{
|
||||
TaskAddButton roleAddButton = Object.Instantiate(__instance.RoleButton);
|
||||
roleAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
roleAddButton.Text.text = prettyEnabled ? role.GetRoleName() : "Be_" + role.GetRoleName() + ".exe";
|
||||
roleAddButton.Text.text = role.GetRoleName();
|
||||
roleAddButton.Role = role;
|
||||
if (prettyEnabled)
|
||||
{
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = role.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
}
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = role.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
|
||||
__instance.AddFileAsChildCustom(roleAddButton, ref num, ref num2, ref num3);
|
||||
if (roleAddButton != null && roleAddButton.Button != null)
|
||||
@@ -409,19 +402,16 @@ public static class TaskAdderPatches
|
||||
var roleAddButton = Object.Instantiate(__instance.RoleButton);
|
||||
roleAddButton.MyTask = null;
|
||||
roleAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
roleAddButton.Text.text = prettyEnabled ? roleBehaviour.GetRoleName() : "Be_" + roleBehaviour.GetRoleName() + ".exe";
|
||||
roleAddButton.Text.text = roleBehaviour.GetRoleName();
|
||||
roleAddButton.Text.EnableMasking();
|
||||
roleAddButton.role = roleBehaviour;
|
||||
if (prettyEnabled)
|
||||
{
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = roleBehaviour.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
}
|
||||
roleAddButton.Text.fontSizeMin = 1;
|
||||
roleAddButton.FileImage.sprite = roleBehaviour.IsImpostor
|
||||
? MiraAssets.ImpostorFile.LoadAsset()
|
||||
: MiraAssets.CrewmateFile.LoadAsset();
|
||||
if (roleBehaviour is ICustomRole custom)
|
||||
{
|
||||
if (prettyEnabled && custom.Team == ModdedRoleTeams.Custom) roleAddButton.FileImage.sprite = MiraAssets.CustomTeamFile.LoadAsset();
|
||||
if (custom.Team == ModdedRoleTeams.Custom) roleAddButton.FileImage.sprite = MiraAssets.CustomTeamFile.LoadAsset();
|
||||
var customColor = custom.IntroConfiguration?.IntroTeamColor ?? Color.gray;
|
||||
if (custom.Team is ModdedRoleTeams.Crewmate)
|
||||
{
|
||||
@@ -458,7 +448,7 @@ public static class TaskAdderPatches
|
||||
taskAddButton.role = null;
|
||||
taskAddButton.MyTask = null;
|
||||
taskAddButton.SafePositionWorld = __instance.SafePositionWorld;
|
||||
taskAddButton.Text.text = modifier.ModifierName;
|
||||
taskAddButton.Text.text = modifier.ModifierName.Translate();
|
||||
taskAddButton.Text.fontSizeMin = 1;
|
||||
taskAddButton.Text.EnableMasking();
|
||||
taskAddButton.FileImage.color = modifier.FreeplayFileColor;
|
||||
|
||||
@@ -2,6 +2,7 @@ using System.Collections;
|
||||
using HarmonyLib;
|
||||
using Il2CppSystem;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.Translation;
|
||||
using Reactor.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
@@ -49,7 +50,7 @@ internal static class HudPatches
|
||||
gmText.SetActive(false);
|
||||
modelText.SetActive(false);
|
||||
_text = gmTextClone.GetComponent<TextMeshPro>();
|
||||
_text.text = CustomGameModeManager.ActiveMode != null ? $"<color=#{CustomGameModeManager.ActiveMode.Color.ToHtmlStringRGBA()}>{CustomGameModeManager.ActiveMode.Name}</color>" : "Classic";
|
||||
_text.text = CustomGameModeManager.ActiveMode != null ? CustomGameModeManager.ActiveMode.ColoredName : MiraLocaleManager.Get("MiraApi.Gamemode.Classic");
|
||||
CustomGameModeManager.ActiveMode?.HudStart(instance);
|
||||
}
|
||||
|
||||
|
||||
@@ -42,12 +42,16 @@ public static class HudManagerPatches
|
||||
ResizeUI(LocalSettingsTabSingleton<MiraApiSettings>.Instance.ButtonUIFactorSlider.Value);
|
||||
}
|
||||
|
||||
private static Transform _storedButtonsParent;
|
||||
public static void ResizeUI(float scaleFactor)
|
||||
{
|
||||
var baseButtons = HudManager.Instance.transform.FindChild("Buttons");
|
||||
if (baseButtons != null)
|
||||
if (!_storedButtonsParent)
|
||||
{
|
||||
foreach (var aspect in baseButtons.GetComponentsInChildren<AspectPosition>(true))
|
||||
_storedButtonsParent = HudManager.Instance.transform.FindChild("Buttons");
|
||||
}
|
||||
if (_storedButtonsParent)
|
||||
{
|
||||
foreach (var aspect in _storedButtonsParent.GetComponentsInChildren<AspectPosition>(true))
|
||||
{
|
||||
if (!aspect.gameObject)
|
||||
{
|
||||
@@ -82,9 +86,9 @@ public static class HudManagerPatches
|
||||
button.gameObject.SetActive(!button.isActiveAndEnabled);
|
||||
}
|
||||
|
||||
if (baseButtons != null)
|
||||
if (_storedButtonsParent)
|
||||
{
|
||||
foreach (var arrange in baseButtons.GetComponentsInChildren<GridArrange>(true))
|
||||
foreach (var arrange in _storedButtonsParent.GetComponentsInChildren<GridArrange>(true))
|
||||
{
|
||||
if (!arrange.gameObject || !arrange.transform)
|
||||
{
|
||||
@@ -281,6 +285,8 @@ public static class HudManagerPatches
|
||||
}
|
||||
MiraApiSettings.OldButtonScaleFactor =
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.ButtonUIFactorSlider.Value;
|
||||
MiraApiSettings.OldUiButtonScaleFactor =
|
||||
LocalSettingsTabSingleton<MiraApiSettings>.Instance.TopRightButtonsFactorSlider.Value;
|
||||
Coroutines.Start(CoResizeUI());
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using MiraAPI.Events.Vanilla.Gameplay;
|
||||
using MiraAPI.MeetingAbilities;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
|
||||
namespace MiraAPI.Patches;
|
||||
@@ -86,8 +87,8 @@ public static class IntroCutscenePatches
|
||||
{
|
||||
__instance.BackgroundBar.material.SetColor(ShaderID.Color, introConfig.IntroTeamColor);
|
||||
__instance.TeamTitle.color = introConfig.IntroTeamColor;
|
||||
__instance.TeamTitle.text = introConfig.IntroTeamTitle;
|
||||
__instance.ImpostorText.text = introConfig.IntroTeamDescription;
|
||||
__instance.TeamTitle.text = introConfig.IntroTeamTitle.Translate();
|
||||
__instance.ImpostorText.text = introConfig.IntroTeamDescription.Translate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,7 @@ public static class OptionsMenuPatches
|
||||
int i = 0;
|
||||
int tabIdx = 0;
|
||||
int page = 1;
|
||||
LocalSettingsTab.TabGroups.Clear();
|
||||
foreach (var settings in LocalSettingsManager.AvailableTabs)
|
||||
{
|
||||
var tab = settings.CreateTab(__instance);
|
||||
@@ -213,6 +214,8 @@ public static class OptionsMenuPatches
|
||||
|
||||
if (background != null)
|
||||
background.color = tab.TabAppearance.TabColor;
|
||||
|
||||
tab.Open();
|
||||
}
|
||||
private static void CustomClose(LocalSettingsTab tab)
|
||||
{
|
||||
|
||||
@@ -7,8 +7,6 @@ using Reactor.Utilities.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
@@ -9,6 +9,7 @@ using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -113,7 +114,7 @@ internal static class GameOptionsMenuPatch
|
||||
_modIcon.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
_gamemodeDescription.text = gameMode.Description;
|
||||
_gamemodeDescription.text = MiraLocaleManager.Get(gameMode.Description);
|
||||
if (gameMode.ShowNormalGameSettings)
|
||||
{
|
||||
foreach (var opt in _vanillaHeaders)
|
||||
@@ -456,7 +457,7 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
num -= 0.58f;
|
||||
|
||||
categoryHeaderMasked.SetHeader(CustomStringName.CreateAndRegister(group.GroupName), 20);
|
||||
categoryHeaderMasked.SetHeader(MiraLocaleManager.GetOrCreateLocaleString(group.GroupName), 20);
|
||||
categoryHeaderMasked.Background.color = group.GroupColor;
|
||||
categoryHeaderMasked.Divider.color = group.GroupColor;
|
||||
categoryHeaderMasked.Title.color = group.GroupColor.Equals(MiraApiPlugin.DefaultHeaderColor)
|
||||
@@ -538,7 +539,7 @@ internal static class GameOptionsMenuPatch
|
||||
|
||||
internal static void UpdateGroup(AbstractOptionGroup? group, ref float num)
|
||||
{
|
||||
if (group is null || !group.Ready || group.Options.Count == 0 || group.Header is null)
|
||||
if (group is null || !group.Ready || group.Options.Count == 0 || group.Header == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -696,7 +697,7 @@ internal static class GameOptionsMenuPatch
|
||||
Quaternion.identity,
|
||||
container);
|
||||
|
||||
categoryHeaderMasked.SetHeader(CustomStringName.CreateAndRegister(group.GroupName), 20);
|
||||
categoryHeaderMasked.SetHeader(MiraLocaleManager.GetOrCreateLocaleString(group.GroupName), 20);
|
||||
categoryHeaderMasked.Background.color = group.GroupColor;
|
||||
categoryHeaderMasked.Divider.color = group.GroupColor;
|
||||
categoryHeaderMasked.Title.color = group.GroupColor.Equals(MiraApiPlugin.DefaultHeaderColor)
|
||||
@@ -715,7 +716,7 @@ internal static class GameOptionsMenuPatch
|
||||
categoryHeaderMasked.gameObject.SetActive(false);
|
||||
|
||||
var newText = Object.Instantiate(categoryHeaderMasked.Title, categoryHeaderMasked.transform);
|
||||
newText.text = "<size=70%>(Click to close)</size>";
|
||||
newText.text = $"<size=70%>({"MiraApi.GameSetting.Global.ClickToClose".Translate()})</size>";
|
||||
newText.transform.localPosition = new Vector3(2.6249f, -0.165f, 0f);
|
||||
newText.gameObject.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
|
||||
@@ -732,8 +733,8 @@ internal static class GameOptionsMenuPatch
|
||||
{
|
||||
group.AllOptionsHidden = !group.AllOptionsHidden;
|
||||
newText.text = group.AllOptionsHidden
|
||||
? "<size=70%>(Click to open)</size>"
|
||||
: "<size=70%>(Click to close)</size>";
|
||||
? $"<size=70%>({"MiraApi.GameSetting.Global.ClickToOpen".Translate()})</size>"
|
||||
: $"<size=70%>({"MiraApi.GameSetting.Global.ClickToClose".Translate()})</size>";
|
||||
}));
|
||||
headerBtn.SetButtonEnableState(true);
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Extensions;
|
||||
@@ -45,7 +46,7 @@ internal static class GamePresetsTabPatches
|
||||
|
||||
if (MenuState.Instance.CurrentModIdx != 0)
|
||||
{
|
||||
__instance.PresetDescriptionText.text = "Select or create an options preset for this mod";
|
||||
__instance.PresetDescriptionText.text = "MiraApi.GameSetting.Preset.Hint".Translate();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -184,7 +185,7 @@ internal static class GamePresetsTabPatches
|
||||
|
||||
// set the button text and alignment
|
||||
var saveText = saveButton.buttonText;
|
||||
saveText.text = "Save";
|
||||
saveText.text = "MiraApi.GameSetting.Preset.Save".Translate();
|
||||
saveText.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
saveText.alignment = TextAlignmentOptions.Center;
|
||||
saveText.transform.parent.localPosition = new Vector3(
|
||||
|
||||
@@ -8,6 +8,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -31,8 +32,7 @@ public static class LobbyViewPanePatches
|
||||
: Plugins[SelectedModIdx - 1];
|
||||
|
||||
private static PassiveButton? ModifiersTabButton { get; set; }
|
||||
|
||||
private static StringNames ModifiersTabName { get; } = CustomStringName.CreateAndRegister("ModifiersTab");
|
||||
internal static StringNames ModifiersTabName { get; } = MiraLocaleManager.GetOrCreateLocaleString("ModifiersTab");
|
||||
|
||||
private static AbstractGameMode? GetCustomGamemode()
|
||||
{
|
||||
@@ -83,7 +83,7 @@ public static class LobbyViewPanePatches
|
||||
var pos = ModifiersTabButton.transform.localPosition;
|
||||
pos.x = 2.1f;
|
||||
ModifiersTabButton.transform.localPosition = pos;
|
||||
ModifiersTabButton.buttonText.text = "Modifiers";
|
||||
ModifiersTabButton.buttonText.text = "MiraApi.GameSetting.Modifiers".Translate();
|
||||
ModifiersTabButton.OnClick = new Button.ButtonClickedEvent();
|
||||
ModifiersTabButton.OnClick.AddListener(
|
||||
(UnityAction)(() =>
|
||||
@@ -151,7 +151,7 @@ public static class LobbyViewPanePatches
|
||||
var cgm = GetCustomGamemode();
|
||||
ModifiersTabButton?.gameObject.SetActive(false);
|
||||
menu.rolesTabButton.gameObject.SetActive(cgm is null or { ShowNormalRoleSettings: true });
|
||||
menu.gameModeText.text = cgm is null ? "Main" : cgm.ColoredName;
|
||||
menu.gameModeText.text = cgm is null ? MiraLocaleManager.Get("MiraApi.Gamemode.Classic") : cgm.ColoredName;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -362,7 +362,7 @@ public static class LobbyViewPanePatches
|
||||
true);
|
||||
|
||||
categoryHeaderMasked.SetHeader(StringNames.Name, 61);
|
||||
categoryHeaderMasked.Title.text = group.GroupName;
|
||||
categoryHeaderMasked.Title.text = group.GroupName.Translate();
|
||||
categoryHeaderMasked.transform.localScale = Vector3.one;
|
||||
categoryHeaderMasked.transform.localPosition = new Vector3(-9.77f, num, -2f);
|
||||
menu.settingsInfo.Add(categoryHeaderMasked.gameObject);
|
||||
@@ -454,7 +454,7 @@ public static class LobbyViewPanePatches
|
||||
// sort the groups by priority
|
||||
var sortedRoleGroups = roleGroups
|
||||
.OrderBy(x => x.Key.Priority)
|
||||
.ThenBy(x => x.Key.Name);
|
||||
.ThenBy(x => x.Key.Name.Translate());
|
||||
|
||||
foreach (var grouping in sortedRoleGroups)
|
||||
{
|
||||
@@ -465,12 +465,7 @@ public static class LobbyViewPanePatches
|
||||
|
||||
var group = grouping.Key;
|
||||
|
||||
var name = group.Name switch
|
||||
{
|
||||
"Crewmate" => StringNames.CrewmateRolesHeader,
|
||||
"Impostor" => StringNames.ImpostorRolesHeader,
|
||||
_ => CustomStringName.CreateAndRegister(group.Name),
|
||||
};
|
||||
var name = MiraLocaleManager.GetOrCreateLocaleString(group.Name);
|
||||
|
||||
var categoryHeaderRoleVariant = Object.Instantiate(instance.categoryHeaderRoleOrigin, instance.settingsContainer, true);
|
||||
categoryHeaderRoleVariant.SetHeader(name, 61);
|
||||
|
||||
@@ -7,6 +7,7 @@ using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Utilities.Attributes;
|
||||
@@ -149,7 +150,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
_largeButtons[MenuButton.Modifiers] = mBtn;
|
||||
mBtn.name = "ModifiersButton";
|
||||
mBtn.buttonText.gameObject.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
mBtn.buttonText.text = "Modifiers";
|
||||
mBtn.buttonText.text = "MiraApi.GameSetting.Modifiers".Translate();
|
||||
mBtn.OnClick = new Button.ButtonClickedEvent();
|
||||
mBtn.OnClick.AddListener(
|
||||
(UnityAction)(() =>
|
||||
@@ -218,7 +219,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}));
|
||||
|
||||
var roleText = smRolesBtn.buttonText;
|
||||
roleText.text = "Roles";
|
||||
roleText.text = "MiraApi.GameSetting.Roles".Translate();
|
||||
roleText.GetComponent<TextTranslatorTMP>().Destroy();
|
||||
roleText.alignment = TextAlignmentOptions.Center;
|
||||
roleText.transform.parent.localPosition = new Vector3(
|
||||
@@ -243,7 +244,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
var smModBtn = Instantiate(smRolesBtn, smRolesBtn.transform.parent);
|
||||
_smallButtons[MenuButton.Modifiers] = smModBtn;
|
||||
smModBtn.name = "SmallModifiersButton";
|
||||
smModBtn.buttonText.text = "Modifiers";
|
||||
smModBtn.buttonText.text = "MiraApi.GameSetting.Modifiers".Translate();
|
||||
smModBtn.OnClick = new Button.ButtonClickedEvent();
|
||||
smModBtn.OnClick.AddListener(
|
||||
(UnityAction)(() =>
|
||||
@@ -388,7 +389,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
}
|
||||
else
|
||||
{
|
||||
var modName = CurrentMod.MiraPlugin.OptionsTitleText;
|
||||
var modName = CurrentMod.MiraPlugin.OptionsTitleText.Translate();
|
||||
_text.text = $"<size=40%>(Page {CurrentModIdx + 1}/{ModCount + 1})</size>\n" +
|
||||
modName[..Math.Min(modName.Length, 25)];
|
||||
}
|
||||
@@ -492,12 +493,12 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
_smallButtons[MenuButton.CustomOne].gameObject.SetActive(true);
|
||||
_smallButtons[MenuButton.CustomOne].transform.localPosition =
|
||||
new Vector3(leftPos, position.y, position.z);
|
||||
_smallButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne;
|
||||
_smallButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne.Translate();
|
||||
|
||||
_smallButtons[MenuButton.CustomTwo].gameObject.SetActive(true);
|
||||
_smallButtons[MenuButton.CustomTwo].transform.localPosition =
|
||||
new Vector3(rightPos, position.y, position.z);
|
||||
_smallButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo;
|
||||
_smallButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo.Translate();
|
||||
position.y -= 0.637f;
|
||||
}
|
||||
|
||||
@@ -506,7 +507,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
_largeButtons[MenuButton.CustomOne].gameObject.SetActive(true);
|
||||
_largeButtons[MenuButton.CustomOne].transform.localPosition = position;
|
||||
_largeButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne;
|
||||
_largeButtons[MenuButton.CustomOne].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameOne.Translate();
|
||||
position.y -= 0.637f;
|
||||
}
|
||||
else
|
||||
@@ -519,7 +520,7 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
{
|
||||
_largeButtons[MenuButton.CustomTwo].gameObject.SetActive(true);
|
||||
_largeButtons[MenuButton.CustomTwo].transform.localPosition = position;
|
||||
_largeButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo;
|
||||
_largeButtons[MenuButton.CustomTwo].buttonText.text = CurrentMod.MiraPlugin.CustomOptionMenuNameTwo.Translate();
|
||||
position.y -= 0.637f;
|
||||
}
|
||||
else
|
||||
@@ -573,15 +574,15 @@ public class MenuState(IntPtr cppPtr) : MonoBehaviour(cppPtr)
|
||||
|
||||
case MenuCategory.Modifiers:
|
||||
menu.GameSettingsTab.gameObject.SetActive(true);
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.ModifierMenuDescription;
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.ModifierMenuDescription.Translate();
|
||||
break;
|
||||
case MenuCategory.CustomOne:
|
||||
menu.GameSettingsTab.gameObject.SetActive(true);
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuOneDescription;
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuOneDescription.Translate();
|
||||
break;
|
||||
case MenuCategory.CustomTwo:
|
||||
menu.GameSettingsTab.gameObject.SetActive(true);
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuTwoDescription;
|
||||
menu.MenuDescriptionText.text = CurrentMod.MiraPlugin.CustomOptionMenuTwoDescription.Translate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Il2CppSystem;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Utilities.Extensions;
|
||||
using UnityEngine;
|
||||
@@ -164,7 +165,7 @@ public static class OptionsPatches
|
||||
return true;
|
||||
}
|
||||
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>());
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>()).Translate();
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -201,8 +202,7 @@ public static class OptionsPatches
|
||||
{
|
||||
return true;
|
||||
}
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title);
|
||||
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title).Translate();
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -309,7 +309,7 @@ public static class OptionsPatches
|
||||
return true;
|
||||
}
|
||||
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>());
|
||||
__instance.TitleText.text = TranslationController.Instance.GetString(__instance.Title, Array.Empty<Object>()).Translate();
|
||||
__instance.ValueText.text = TranslationController.Instance.GetString(__instance.Values[__instance.Value], Array.Empty<Object>());
|
||||
|
||||
return false;
|
||||
|
||||
@@ -9,6 +9,7 @@ using MiraAPI.GameModes;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -195,7 +196,7 @@ public static class RoleSettingMenuPatches
|
||||
// sort the groups by priority
|
||||
var sortedRoleGroups = roleGroups
|
||||
.OrderBy(x => x.Key.Priority)
|
||||
.ThenBy(x => x.Key.Name);
|
||||
.ThenBy(x => x.Key.Name.Translate());
|
||||
|
||||
var quotaThing = roleMenu.categoryHeaderEditRoleOrigin.transform.FindChild("QuotaHeader");
|
||||
var usingNewQuota = false;
|
||||
@@ -214,12 +215,7 @@ public static class RoleSettingMenuPatches
|
||||
|
||||
RoleGroupHidden.TryAdd(group, false);
|
||||
|
||||
var name = group.Name switch
|
||||
{
|
||||
"Crewmate" => StringNames.CrewmateRolesHeader,
|
||||
"Impostor" => StringNames.ImpostorRolesHeader,
|
||||
_ => CustomStringName.CreateAndRegister(group.Name),
|
||||
};
|
||||
var name = MiraLocaleManager.GetOrCreateLocaleString(group.Name);
|
||||
|
||||
var categoryHeaderMasked = Object.Instantiate(
|
||||
template,
|
||||
@@ -293,8 +289,8 @@ public static class RoleSettingMenuPatches
|
||||
quotaInst.gameObject.SetActive(!RoleGroupHidden[group]);
|
||||
|
||||
var label = RoleGroupHidden[group]
|
||||
? "(Click to open)"
|
||||
: "(Click to close)";
|
||||
? $"({"MiraApi.GameSetting.Global.ClickToOpen".Translate()})"
|
||||
: $"({"MiraApi.GameSetting.Global.ClickToClose".Translate()})";
|
||||
var newText = Object.Instantiate(categoryHeaderMasked.Title, categoryHeaderMasked.transform);
|
||||
newText.text = $"<size=70%>{label}</size>";
|
||||
newText.transform.localPosition = new Vector3(2.6249f, -0.165f, 0f);
|
||||
@@ -579,7 +575,7 @@ public static class RoleSettingMenuPatches
|
||||
return;
|
||||
}
|
||||
|
||||
__instance.roleDescriptionText.text = customRole.RoleLongDescription;
|
||||
__instance.roleDescriptionText.text = customRole.RoleMedDescription;
|
||||
__instance.roleTitleText.text = role.GetRoleName();
|
||||
|
||||
var imgBg = __instance.AdvancedRolesSettings.transform.FindChild("Imagebackground");
|
||||
@@ -614,7 +610,7 @@ public static class RoleSettingMenuPatches
|
||||
comp.Destroy();
|
||||
}
|
||||
|
||||
categoryHeaderMasked.Title.text = "RETURN TO ROLE SETTINGS";
|
||||
categoryHeaderMasked.Title.text = "MiraApi.ReturnToRoleSettings".Translate();
|
||||
|
||||
if (!categoryHeaderMasked.gameObject.TryGetComponent<PassiveButton>(out _))
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Linq;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using BepInEx.Configuration;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.PluginLoading;
|
||||
|
||||
@@ -15,11 +14,16 @@ public interface IMiraPlugin
|
||||
/// </summary>
|
||||
public virtual bool DisplayOnOptionsMenu => true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value for the localization id to use for anything registered under this mod.
|
||||
/// </summary>
|
||||
public virtual string ParentLocaleId => GetType().Name.ToLower(CultureInfo.InvariantCulture);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name to display on the options menu.
|
||||
/// </summary>
|
||||
string OptionsTitleText { get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the abbreviated name to display for other mods to pick up.
|
||||
/// </summary>
|
||||
|
||||
@@ -23,6 +23,7 @@ using MiraAPI.Modifiers;
|
||||
using MiraAPI.Patches.Options;
|
||||
using MiraAPI.Presets;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using Reactor.Networking;
|
||||
@@ -150,7 +151,7 @@ public sealed class MiraPluginManager
|
||||
|
||||
IL2CPPChainloader.Instance.PluginLoad += (pluginInfo, assembly, plugin) =>
|
||||
{
|
||||
if (plugin is not IMiraPlugin miraPlugin)
|
||||
if (plugin is not IMiraPlugin miraPlugin || pluginInfo.Metadata.GUID == MiraApiPlugin.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -271,21 +272,6 @@ public sealed class MiraPluginManager
|
||||
PluginsWithOptionsOrGameModes = [..RegisteredPlugins.Where(m => m.MiraPlugin.DisplayOnOptionsMenu || m.GameModes.Count > 0)];
|
||||
|
||||
ModifierManager.Modifiers = new ReadOnlyCollection<BaseModifier>(ModifierManager.InternalModifiers);
|
||||
|
||||
var dict = new Dictionary<string, object>();
|
||||
foreach (var (key, value) in CustomGameModeManager.IdToModeMap)
|
||||
{
|
||||
if (value is ClassicMode)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
dict.Add(value.Name, key);
|
||||
if (((AmongUs.GameOptions.GameModes) key) == AmongUs.GameOptions.GameModes.Normal)
|
||||
return;
|
||||
// 'Default' was still being registered twice and idk why
|
||||
GameModesHelpers.ModeToName.Add((AmongUs.GameOptions.GameModes)key, CustomStringName.CreateAndRegister(value.Name));
|
||||
}
|
||||
EnumInjector.InjectEnumValues<AmongUs.GameOptions.GameModes>(dict);
|
||||
};
|
||||
|
||||
RegisterKeybinds(typeof(MiraGlobalKeybinds), PluginSingleton<MiraApiPlugin>.Instance);
|
||||
@@ -577,7 +563,7 @@ public sealed class MiraPluginManager
|
||||
KeybindManager.Keybinds.Add(keybind);
|
||||
if (source is IMiraPlugin miraPlugin)
|
||||
{
|
||||
keybind.SourcePluginName = miraPlugin.OptionsTitleText;
|
||||
keybind.SourcePluginName = miraPlugin.OptionsTitleText.Translate();
|
||||
}
|
||||
else if (source is MiraApiPlugin)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="MiraApi">Mira API</string>
|
||||
<string name="MiraApi.VisualsUi">Visuals/UI</string>
|
||||
<string name="MiraApi.Accessibility">Accessibility</string>
|
||||
<string name="MiraApi.MiraApiBrand">MiraAPI</string>
|
||||
<string name="MiraApi.ShowModifiersHudOnLeftSide">Show Modifiers HUD on Left Side</string>
|
||||
<string name="MiraApi.ShowKeybindsOnButtons">Show Keybinds on Buttons</string>
|
||||
<string name="MiraApi.ButtonScaleFactor">Button Scale Factor</string>
|
||||
<string name="MiraApi.TopRightButtonScaleFactor">Top-Right UI Scale Factor</string>
|
||||
<string name="MiraApi.MaxFps">Max FPS</string>
|
||||
<string name="MiraApi.WikiOnBottomRow">Display Wiki on Bottom Row</string>
|
||||
<string name="MiraApi.EnableSabotageFlashes">Enable Sabotage Flashes</string>
|
||||
<string name="MiraApi.EnableSabotageBlare">Enable Sabotage Blare</string>
|
||||
<string name="MiraApi.ReturnToRoleSettings">RETURN TO ROLE SETTINGS</string>
|
||||
<string name="MiraApi.CustomCategory1">Custom Category 1</string>
|
||||
<string name="MiraApi.CustomCategory2">Custom Category 2</string>
|
||||
<string name="MiraApi.ModifierMenuDescription">Configure modifiers and their settings here!</string>
|
||||
<string name="MiraApi.CustomOptionMenuDescription">Apply game settings for this mod!</string>
|
||||
<string name="MiraApi.Gamemode.Classic">Classic</string>
|
||||
<string name="MiraApi.Gamemode.Classic.Description">The classic Among Us experience!
|
||||
Find the Impostors or deceive the Crew.</string>
|
||||
<string name="MiraApi.Gamemode.HideAndSeek">Hide n Seek</string>
|
||||
<string name="MiraApi.Gamemode.HideAndSeek.Description">You can run, but you can't hide!
|
||||
Outlive the timer or eliminate the crew.</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToClose">Click to close</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToOpen">Click to open</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Hint">Select or create a options preset for this game</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Save">Save</string>
|
||||
<string name="MiraApi.GameSetting.Roles">Roles</string>
|
||||
<string name="MiraApi.GameSetting.Modifiers">Modifiers</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate">Crewmate</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Short">Crew</string>
|
||||
<string name="MiraApi.RoleTeam.Crewmate.Group">Crewmate Roles</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor">Impostor</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Short">Imp</string>
|
||||
<string name="MiraApi.RoleTeam.Impostor.Group">Impostor Roles</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral">Neutral</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Short">Neut</string>
|
||||
<string name="MiraApi.RoleTeam.Neutral.Group">Neutral Roles</string>
|
||||
<string name="MiraApi.RoleTeam.Other">Other</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<resources>
|
||||
<string name="MiraApi">Mira API</string>
|
||||
<string name="MiraApi.VisualsUi">界面/视觉</string>
|
||||
<string name="MiraApi.Accessibility">无障碍</string>
|
||||
<string name="MiraApi.MiraApiBrand">MiraAPI</string>
|
||||
<string name="MiraApi.ShowModifiersHudOnLeftSide">在左侧显示附加职业UI</string>
|
||||
<string name="MiraApi.ShowKeybindsOnButtons">在按钮上显示快捷键</string>
|
||||
<string name="MiraApi.ButtonScaleFactor">按钮缩放比例</string>
|
||||
<string name="MiraApi.MaxFps">最大帧数</string>
|
||||
<string name="MiraApi.EnableSabotageFlashes">启用破坏红色闪烁</string>
|
||||
<string name="MiraApi.EnableSabotageBlare">启用破坏音效</string>
|
||||
<string name="MiraApi.ReturnToRoleSettings">返回职业设置</string>
|
||||
<string name="MiraApi.CustomCategory1">自定义类别 1</string>
|
||||
<string name="MiraApi.CustomCategory2">自定义类别 2</string>
|
||||
<string name="MiraApi.ModifierMenuDescription">在此配置附加职业及其设置!</string>
|
||||
<string name="MiraApi.CustomOptionMenuDescription">为此模组应用游戏设置!</string>
|
||||
<string name="gamemode.default">默认</string>
|
||||
<string name="gamemode.default.description">默认原版游戏模式</string>
|
||||
<string name="MiraApi.GameSetting.Global.ClickToClose">点击关闭</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Hint">为本游戏选择或创建一个预设</string>
|
||||
<string name="MiraApi.GameSetting.Preset.Save">保存</string>
|
||||
<string name="MiraApi.GameSetting.Roles">职业</string>
|
||||
<string name="MiraApi.GameSetting.Modifiers">附加职业</string>
|
||||
</resources>
|
||||
@@ -7,6 +7,7 @@ using Il2CppInterop.Runtime.Injection;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.Networking;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Reactor.Localization.Utilities;
|
||||
@@ -131,9 +132,10 @@ public static class CustomRoleManager
|
||||
roleBehaviour.Role = (RoleTypes)roleId;
|
||||
roleBehaviour.TeamType = customRole.Team == ModdedRoleTeams.Custom ? RoleTeamTypes.Crewmate : (RoleTeamTypes)customRole.Team;
|
||||
roleBehaviour.NameColor = customRole.RoleColor;
|
||||
roleBehaviour.StringName = CustomStringName.CreateAndRegister(customRole.RoleName);
|
||||
roleBehaviour.BlurbName = CustomStringName.CreateAndRegister(customRole.RoleDescription);
|
||||
roleBehaviour.BlurbNameLong = CustomStringName.CreateAndRegister(customRole.RoleLongDescription);
|
||||
roleBehaviour.StringName = MiraLocaleManager.GetOrCreateLocaleString(customRole.RoleNameLocale);
|
||||
roleBehaviour.BlurbName = MiraLocaleManager.GetOrCreateLocaleString(customRole.RoleDescriptionLocale);
|
||||
roleBehaviour.BlurbNameMed = MiraLocaleManager.GetOrCreateLocaleString(customRole.RoleMedDescriptionLocale);
|
||||
roleBehaviour.BlurbNameLong = MiraLocaleManager.GetOrCreateLocaleString(customRole.RoleLongDescriptionLocale);
|
||||
roleBehaviour.AffectedByLightAffectors = customRole.Configuration.AffectedByLightOnAirship;
|
||||
roleBehaviour.CanBeKilled = customRole.Configuration.CanGetKilled;
|
||||
roleBehaviour.CanUseKillButton = customRole.Configuration.UseVanillaKillButton;
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using AmongUs.GameOptions;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.GameModes;
|
||||
using MiraAPI.Utilities;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
|
||||
@@ -4,6 +4,7 @@ using BepInEx.Configuration;
|
||||
using MiraAPI.GameOptions;
|
||||
using MiraAPI.Modifiers;
|
||||
using MiraAPI.PluginLoading;
|
||||
using MiraAPI.Translation;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Roles;
|
||||
@@ -13,35 +14,70 @@ namespace MiraAPI.Roles;
|
||||
/// </summary>
|
||||
public interface ICustomRole : IOptionable
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the id part used to build the role's translation keys.
|
||||
/// </summary>
|
||||
string IdPart => GetType().Name;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the role.
|
||||
/// </summary>
|
||||
string RoleName { get; }
|
||||
string RoleName => MiraLocaleManager.Get(RoleNameLocale);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role's name id for localization.
|
||||
/// </summary>
|
||||
string RoleNameLocale => IdPart;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the description of the role. Used in the Intro Cutscene.
|
||||
/// </summary>
|
||||
string RoleDescription { get; }
|
||||
string RoleDescription => MiraLocaleManager.Get(RoleDescriptionLocale);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the medium description of the role. Used in the role guide.
|
||||
/// Gets the role's intro blurb id for localization.
|
||||
/// </summary>
|
||||
string RoleMedDescription => RoleDescription;
|
||||
string RoleDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPart, "IntroBlurb");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the long description of the role. Used in the Role Tab and Role Options.
|
||||
/// Gets the medium description of the role. Used in the role guide and options menu.
|
||||
/// </summary>
|
||||
string RoleLongDescription { get; }
|
||||
string RoleMedDescription => MiraLocaleManager.Get(RoleMedDescriptionLocale);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role's medium description id for localization.
|
||||
/// </summary>
|
||||
string RoleMedDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPart, "MedDescription");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the long description of the role. Used in the Role Tab.
|
||||
/// </summary>
|
||||
string RoleLongDescription => MiraLocaleManager.Get(RoleLongDescriptionLocale);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role's long description id for localization.
|
||||
/// </summary>
|
||||
string RoleLongDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPart, "TabDescription");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the wiki description of the role. Used in the wiki, but not currently required.
|
||||
/// </summary>
|
||||
string RoleWikiDescription => MiraLocaleManager.Get(RoleLongDescriptionLocale);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the role's wiki description id for localization.
|
||||
/// </summary>
|
||||
string RoleWikiDescriptionLocale => MiraLocaleManager.BuildTranslationId(IdPart, "WikiDescription");
|
||||
|
||||
/// <summary>
|
||||
/// Gets the faction / alignment of the role. Used in the role guide.
|
||||
/// </summary>
|
||||
string RoleFactionTitle => Team switch
|
||||
{
|
||||
ModdedRoleTeams.Crewmate => TranslationController.Instance.GetString(StringNames.Crewmate),
|
||||
ModdedRoleTeams.Impostor => TranslationController.Instance.GetString(StringNames.Impostor),
|
||||
ModdedRoleTeams.Custom => "Neutral",
|
||||
_ => "Other",
|
||||
ModdedRoleTeams.Crewmate => MiraLocaleManager.Get("MiraApi.RoleTeam.Crewmate"),
|
||||
ModdedRoleTeams.Impostor => MiraLocaleManager.Get("MiraApi.RoleTeam.Impostor"),
|
||||
ModdedRoleTeams.Custom => MiraLocaleManager.Get("MiraApi.RoleTeam.Neutral"),
|
||||
_ => MiraLocaleManager.Get("MiraApi.RoleTeam.Other"),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -13,15 +13,15 @@ public record struct RoleOptionsGroup(string Name, Color Color, int Priority = 0
|
||||
/// <summary>
|
||||
/// Gets the default group for crewmates.
|
||||
/// </summary>
|
||||
public static RoleOptionsGroup Crewmate { get; } = new("Crewmate", Palette.CrewmateBlue, -2);
|
||||
public static RoleOptionsGroup Crewmate { get; } = new("MiraApi.RoleTeam.Crewmate.Group", Palette.CrewmateBlue, -2);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default group for impostors.
|
||||
/// </summary>
|
||||
public static RoleOptionsGroup Impostor { get; } = new("Impostor", Palette.ImpostorRed, -1);
|
||||
public static RoleOptionsGroup Impostor { get; } = new("MiraApi.RoleTeam.Impostor.Group", Palette.ImpostorRed, -1);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the default group for neutral roles.
|
||||
/// </summary>
|
||||
public static RoleOptionsGroup Neutral { get; } = new("Neutral Roles", Color.gray);
|
||||
public static RoleOptionsGroup Neutral { get; } = new("MiraApi.RoleTeam.Neutral.Group", Color.gray);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace MiraAPI.Translation;
|
||||
|
||||
/// <summary>
|
||||
/// Supported languages for Mira translation system.
|
||||
/// Maps to Among Us's SupportedLangs enum values.
|
||||
/// </summary>
|
||||
public enum MiraLanguage
|
||||
{
|
||||
English,
|
||||
Latam,
|
||||
Brazilian,
|
||||
Portuguese,
|
||||
Korean,
|
||||
Russian,
|
||||
Dutch,
|
||||
Filipino,
|
||||
French,
|
||||
German,
|
||||
Italian,
|
||||
Japanese,
|
||||
Spanish,
|
||||
SChinese,
|
||||
TChinese,
|
||||
Irish,
|
||||
Polish,
|
||||
Turkish,
|
||||
Swedish,
|
||||
Lithuanian,
|
||||
Czech,
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Xml;
|
||||
using MiraAPI.Utilities;
|
||||
using Reactor.Localization.Utilities;
|
||||
using UnityEngine;
|
||||
|
||||
namespace MiraAPI.Translation;
|
||||
|
||||
public static class MiraLocaleManager
|
||||
{
|
||||
private const string LangDirectory = "mira_languages";
|
||||
|
||||
public static readonly Dictionary<string, Dictionary<MiraLanguage, Dictionary<string, string>>> Locale = [];
|
||||
|
||||
public static readonly Dictionary<string, StringNames> RegisteredStringNames = [];
|
||||
internal static readonly Dictionary<StringNames, string> StringNamesLookup = [];
|
||||
|
||||
public static Dictionary<MiraLanguage, string> LangList { get; } = new()
|
||||
{
|
||||
{ MiraLanguage.English, "en_US" },
|
||||
{ MiraLanguage.Latam, "es_419" },
|
||||
{ MiraLanguage.Brazilian, "pt_BR" },
|
||||
{ MiraLanguage.Portuguese, "pt_PT" },
|
||||
{ MiraLanguage.Korean, "ko_KR" },
|
||||
{ MiraLanguage.Russian, "ru_RU" },
|
||||
{ MiraLanguage.Dutch, "nl_NL" },
|
||||
{ MiraLanguage.Filipino, "fil_PH" },
|
||||
{ MiraLanguage.French, "fr_FR" },
|
||||
{ MiraLanguage.German, "de_DE" },
|
||||
{ MiraLanguage.Italian, "it_IT" },
|
||||
{ MiraLanguage.Japanese, "ja_JP" },
|
||||
{ MiraLanguage.Spanish, "es_ES" },
|
||||
{ MiraLanguage.SChinese, "zh_CN" },
|
||||
{ MiraLanguage.TChinese, "zh_TW" },
|
||||
{ MiraLanguage.Irish, "ga_IE" },
|
||||
{ MiraLanguage.Polish, "pl_PL" }, // Custom
|
||||
{ MiraLanguage.Turkish, "tr_TR" }, // Custom
|
||||
{ MiraLanguage.Swedish, "sv_SE" }, // Custom
|
||||
{ MiraLanguage.Lithuanian, "lt_LT" }, // Custom
|
||||
{ MiraLanguage.Czech, "cs_CZ" }, // Custom
|
||||
};
|
||||
public static Dictionary<MiraLanguage, string> LangCultureList { get; } = new()
|
||||
{
|
||||
{ MiraLanguage.English, "en-US" },
|
||||
{ MiraLanguage.Latam, "es-419" },
|
||||
{ MiraLanguage.Brazilian, "pt-BR" },
|
||||
{ MiraLanguage.Portuguese, "pt-PT" },
|
||||
{ MiraLanguage.Korean, "ko-KR" },
|
||||
{ MiraLanguage.Russian, "ru-RU" },
|
||||
{ MiraLanguage.Dutch, "nl-NL" },
|
||||
{ MiraLanguage.Filipino, "fil-PH" },
|
||||
{ MiraLanguage.French, "fr-FR" },
|
||||
{ MiraLanguage.German, "de-DE" },
|
||||
{ MiraLanguage.Italian, "it-IT" },
|
||||
{ MiraLanguage.Japanese, "ja-JP" },
|
||||
{ MiraLanguage.Spanish, "es-ES" },
|
||||
{ MiraLanguage.SChinese, "zh-CN" },
|
||||
{ MiraLanguage.TChinese, "zh-TW" },
|
||||
{ MiraLanguage.Irish, "ga-IE" },
|
||||
{ MiraLanguage.Polish, "pl-PL" }, // Custom
|
||||
{ MiraLanguage.Turkish, "tr-TR" }, // Custom
|
||||
{ MiraLanguage.Swedish, "sv-SE" }, // Custom
|
||||
{ MiraLanguage.Lithuanian, "lt-LT" }, // Custom
|
||||
{ MiraLanguage.Czech, "cs-CZ" }, // Custom
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current language from Among Us settings.
|
||||
/// </summary>
|
||||
public static MiraLanguage CurrentLanguage
|
||||
{
|
||||
get
|
||||
{
|
||||
try
|
||||
{
|
||||
var langName = AmongUs.Data.DataManager.Settings.Language.CurrentLanguage;
|
||||
return (MiraLanguage)langName;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return MiraLanguage.English;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers translations for a mod. Copies embedded XML to mira_languages/{modGuid}/ on first run,
|
||||
/// then loads all XML files from that directory into memory.
|
||||
/// Call once per mod during plugin Load().
|
||||
/// </summary>
|
||||
/// <param name="modGuid">The mod GUID (e.g., "mira.example").</param>
|
||||
public static void Register(string modGuid)
|
||||
{
|
||||
var callingAssembly = Assembly.GetCallingAssembly();
|
||||
var dir = GetModLangDir(modGuid);
|
||||
|
||||
LoadInternalStrings(callingAssembly, callingAssembly.GetName().Name!, modGuid, dir);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers translations for a mod. Copies embedded XML to mira_languages/{modGuid}/ on first run,
|
||||
/// then loads all XML files from that directory into memory.
|
||||
/// Call once per mod during plugin Load().
|
||||
/// </summary>
|
||||
/// <param name="modGuid">The mod GUID (e.g., "mira.example").</param>
|
||||
/// <param name="internalName">The mod's root namespace (e.g., "mira.api").</param>
|
||||
public static void Register(string modGuid, string internalName)
|
||||
{
|
||||
var callingAssembly = Assembly.GetCallingAssembly();
|
||||
var dir = GetModLangDir(modGuid);
|
||||
|
||||
LoadInternalStrings(callingAssembly, internalName, modGuid, dir);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Translates a key into the current language.
|
||||
/// Searches all mods, with reverse lookup fallback.
|
||||
/// </summary>
|
||||
/// <param name="key">The string id to find.</param>
|
||||
/// <param name="fallback">Fallback string to use if no translation is found.</param>
|
||||
/// <returns>A <see cref="string"/> based on the key provided.</returns>
|
||||
public static string Get(string key, string fallback = "")
|
||||
{
|
||||
var currentLang = CurrentLanguage;
|
||||
|
||||
foreach (var (_, modLocale) in Locale)
|
||||
{
|
||||
if (modLocale.TryGetValue(currentLang, out var langDict) &&
|
||||
langDict.TryGetValue(key, out var translated))
|
||||
{
|
||||
return translated;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (_, modLocale) in Locale)
|
||||
{
|
||||
if (modLocale.TryGetValue(MiraLanguage.English, out var engDict) &&
|
||||
engDict.TryGetValue(key, out var english))
|
||||
{
|
||||
return english;
|
||||
}
|
||||
}
|
||||
|
||||
string? bestStructuredKey = null;
|
||||
foreach (var (_, modLocale) in Locale)
|
||||
{
|
||||
if (modLocale.TryGetValue(MiraLanguage.English, out var engDict))
|
||||
{
|
||||
foreach (var (structuredKey, englishValue) in engDict)
|
||||
{
|
||||
if (englishValue == key)
|
||||
{
|
||||
bestStructuredKey = structuredKey;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bestStructuredKey != null) break;
|
||||
}
|
||||
|
||||
if (bestStructuredKey != null)
|
||||
{
|
||||
foreach (var (_, modLocale) in Locale)
|
||||
{
|
||||
if (modLocale.TryGetValue(currentLang, out var langDict) &&
|
||||
langDict.TryGetValue(bestStructuredKey, out var revTranslated))
|
||||
{
|
||||
return revTranslated;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (_, modLocale) in Locale)
|
||||
{
|
||||
if (modLocale.TryGetValue(MiraLanguage.English, out var engDict) &&
|
||||
engDict.TryGetValue(bestStructuredKey, out var revEnglish))
|
||||
{
|
||||
return revEnglish;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fallback != string.Empty ? fallback : key;
|
||||
}
|
||||
|
||||
public static string BuildTranslationId(string idPart, string suffix)
|
||||
{
|
||||
return idPart.StartsWith('#') ? idPart[1..] : $"{idPart}.{suffix}";
|
||||
}
|
||||
|
||||
private static string GetModLangDir(string modGuid)
|
||||
{
|
||||
return Path.Combine(Application.persistentDataPath, LangDirectory, modGuid);
|
||||
}
|
||||
|
||||
public static StringNames GetOrCreateLocaleString(string name)
|
||||
{
|
||||
if (RegisteredStringNames.TryGetValue(name, out var stringName))
|
||||
{
|
||||
return stringName;
|
||||
}
|
||||
|
||||
var newString = CustomStringName.CreateAndRegister(name);
|
||||
RegisteredStringNames.Add(name, newString);
|
||||
StringNamesLookup.Add(newString, name);
|
||||
return newString;
|
||||
}
|
||||
|
||||
private static void LoadInternalStrings(Assembly assembly, string internalName, string modGuid, string dir)
|
||||
{
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
if (!Locale.ContainsKey(modGuid))
|
||||
{
|
||||
Locale[modGuid] = [];
|
||||
}
|
||||
|
||||
var resourcePrefix = $"{internalName}.Resources.Locale.";
|
||||
|
||||
var atLeastOneLoaded = false;
|
||||
foreach (var locale in LangList)
|
||||
{
|
||||
using var resourceStream =
|
||||
assembly.GetManifestResourceStream(resourcePrefix + locale.Value + ".xml");
|
||||
if (resourceStream == null)
|
||||
{
|
||||
// Silently skipped
|
||||
continue;
|
||||
}
|
||||
|
||||
using StreamReader reader = new(resourceStream);
|
||||
string xmlContent = reader.ReadToEnd();
|
||||
try
|
||||
{
|
||||
var dict = ParseXmlFile(xmlContent);
|
||||
Locale[modGuid][locale.Key] = dict;
|
||||
Info($"Loaded {locale.Key.ToDisplayString()} translation for mod {modGuid} ({dict.Count} keys)");
|
||||
atLeastOneLoaded = true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to load translation {resourcePrefix}{locale.Value}: {e.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (!atLeastOneLoaded)
|
||||
{
|
||||
Error($"No internal strings were found for {internalName}!");
|
||||
}
|
||||
|
||||
if (!Locale.TryGetValue(modGuid, out _))
|
||||
{
|
||||
Locale[modGuid] = [];
|
||||
}
|
||||
|
||||
foreach (var filePath in Directory.GetFiles(dir, "*"))
|
||||
{
|
||||
var fileName = Path.GetFileNameWithoutExtension(filePath);
|
||||
|
||||
var lang = LangList.ContainsValue(fileName)
|
||||
? LangList.First(x => x.Value == fileName).Key
|
||||
: (MiraLanguage)(-1);
|
||||
if ((int)lang == -1) continue;
|
||||
|
||||
try
|
||||
{
|
||||
var dict = ParseXmlFile(filePath);
|
||||
Locale[modGuid][lang] = dict;
|
||||
Info($"Loaded external {lang.ToDisplayString()} translation for mod {modGuid} ({dict.Count} keys)");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Error($"Failed to load external translation {filePath}: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> ParseXmlFile(string xmlContent)
|
||||
{
|
||||
var dict = new Dictionary<string, string>();
|
||||
XmlDocument xmlDoc = new();
|
||||
try
|
||||
{
|
||||
xmlDoc.LoadXml(xmlContent);
|
||||
XmlNodeList? stringNodes = xmlDoc.SelectNodes("/resources/string");
|
||||
|
||||
if (stringNodes != null)
|
||||
{
|
||||
foreach (XmlNode node in stringNodes)
|
||||
{
|
||||
if (node.Attributes?["name"] != null)
|
||||
{
|
||||
string name = node.Attributes["name"]!.Value;
|
||||
string value = node.InnerText;
|
||||
|
||||
if (string.IsNullOrEmpty(name)) continue;
|
||||
|
||||
if (value.Contains('['))
|
||||
{
|
||||
value = value.Replace("[", "<");
|
||||
}
|
||||
|
||||
if (value.Contains(']'))
|
||||
{
|
||||
value = value.Replace("]", ">");
|
||||
}
|
||||
|
||||
value = value.Replace("<nl>", "\n").Replace("<and>", "&");
|
||||
|
||||
dict[name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (XmlException ex)
|
||||
{
|
||||
Error($"XML parsing error: {ex.Message}");
|
||||
}
|
||||
|
||||
return dict;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System.Linq;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.LocalSettings;
|
||||
using Reactor.Localization;
|
||||
using Reactor.Localization.Providers;
|
||||
using Reactor.Utilities;
|
||||
|
||||
namespace MiraAPI.Translation;
|
||||
|
||||
public class MiraLocalizationProvider : LocalizationProvider
|
||||
{
|
||||
public override int Priority => ReactorPriority.Normal;
|
||||
private static LocalizationProvider? _reactorProvider;
|
||||
|
||||
public override bool TryGetText(StringNames stringName, out string? result)
|
||||
{
|
||||
if (MiraLocaleManager.StringNamesLookup.TryGetValue(stringName, out var key))
|
||||
{
|
||||
result = MiraLocaleManager.Get(key);
|
||||
return true;
|
||||
}
|
||||
result = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool TryGetTextFormatted(StringNames stringName, Il2CppReferenceArray<Il2CppSystem.Object> parts, out string? result)
|
||||
{
|
||||
if (!TryGetText(stringName, out result)) return false;
|
||||
|
||||
result = Il2CppSystem.String.Format(result, parts);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnLanguageChanged(SupportedLangs newLanguage)
|
||||
{
|
||||
_reactorProvider ??= LocalizationManager.Providers.First(x => x is HardCodedLocalizationProvider);
|
||||
|
||||
if (MiraLocaleManager.LangCultureList.TryGetValue((MiraLanguage)newLanguage, out var culture))
|
||||
{
|
||||
MiraApiPlugin.Culture = new(culture);
|
||||
}
|
||||
|
||||
foreach (var tab in LocalSettingsTab.TabGroups)
|
||||
{
|
||||
if (tab.Key == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
tab.Key.text = $"<b>{LocalSettingsTab.GetShortName(tab.Value.Translate())}</b>";
|
||||
}
|
||||
/*Warning($"<?xml version='1.0' encoding='UTF-8'?>");
|
||||
Warning($"<resources>");
|
||||
foreach (var stringName in TranslationController.Instance.currentLanguage.AllStrings)
|
||||
{
|
||||
var value = stringName.Value.Replace("\n", "\\%nl\\%");
|
||||
value = value.Replace("{", "[");
|
||||
value = value.Replace("}", "]");
|
||||
Warning($"<string name=\"{stringName.Key}\">{value}</string>");
|
||||
}
|
||||
Warning($"</resources>");*/
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace MiraAPI.Translation;
|
||||
|
||||
/// <summary>
|
||||
/// Extension method for translating strings.
|
||||
/// </summary>
|
||||
public static class TranslationExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Translates a key to the current language.
|
||||
/// </summary>
|
||||
public static string Translate(this string key)
|
||||
{
|
||||
return MiraLocaleManager.Get(key);
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,9 @@ namespace MiraAPI.Utilities.Components;
|
||||
/// <summary>
|
||||
/// Utility component for arranging objects in a centered layout, similar to <see cref="GridArrange"/>.
|
||||
/// </summary>
|
||||
/// <param name="ptr"></param>
|
||||
/// <param name="iPtr">The <see cref="IntPtr"/> for the component.</param>
|
||||
[RegisterInIl2Cpp]
|
||||
public class CenteredGridArrange(IntPtr ptr) : MonoBehaviour(ptr)
|
||||
public class CenteredGridArrange(IntPtr iPtr) : MonoBehaviour(iPtr)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the cell size, which is used for spacing.
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Linq;
|
||||
using HarmonyLib;
|
||||
using Il2CppInterop.Runtime.InteropTypes.Arrays;
|
||||
using MiraAPI.Roles;
|
||||
using MiraAPI.Translation;
|
||||
using MiraAPI.Utilities.Assets;
|
||||
using Rewired;
|
||||
using TMPro;
|
||||
|
||||
Reference in new issue
Block a user