From 4757a17e6a3f4a307867e0c7140cbb711de75602 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 15 Aug 2025 18:56:40 +0800 Subject: [PATCH 01/19] bug fix --- FinalSuspect/Modules/Resources/VersionChecker.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FinalSuspect/Modules/Resources/VersionChecker.cs b/FinalSuspect/Modules/Resources/VersionChecker.cs index 6b0809c..46edc13 100644 --- a/FinalSuspect/Modules/Resources/VersionChecker.cs +++ b/FinalSuspect/Modules/Resources/VersionChecker.cs @@ -156,7 +156,8 @@ private static async Task GetVersionInfo(string url) foreach (var langid in EnumHelper.GetAllValues()) ModUpdater.announcement[langid] = announcement[langid.ToString()]?.ToString(); DownloadUrl_Gitee = DownloadUrl_Gitee.Replace("{showVer}", ShowVer); - HasUpdate = Main.version < _latestVersion && _creation > Main.PluginCreation; + HasUpdate = Main.version < _latestVersion && _creation > Main.PluginCreation || + Main.version == _latestVersion && _creation > Main.PluginCreation && !IsBroken; ForceUpdate = Main.version < _minimumVersion || _creation > Main.PluginCreation; return true; From 237115486adfe39307eda4a4f07d3081e69ea9c8 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 12 Sep 2025 22:40:32 +0800 Subject: [PATCH 02/19] BugFix --- Assets/Languages/Brazilian.yaml | 2 +- Assets/Languages/Dutch.yaml | 2 +- Assets/Languages/English.yaml | 2 +- Assets/Languages/Filipino.yaml | 2 +- Assets/Languages/French.yaml | 2 +- Assets/Languages/German.yaml | 2 +- Assets/Languages/Irish.yaml | 2 +- Assets/Languages/Italian.yaml | 2 +- Assets/Languages/Japanese.yaml | 2 +- Assets/Languages/Korean.yaml | 2 +- Assets/Languages/Latam.yaml | 2 +- Assets/Languages/Portuguese.yaml | 2 +- Assets/Languages/Russian.yaml | 2 +- Assets/Languages/SChinese.yaml | 4 +- Assets/Languages/Spanish.yaml | 2 +- Assets/Languages/TChinese.yaml | 2 +- .../Core/Game/PlayerControlExtension/_Role.cs | 7 +-- FinalSuspect/Modules/Core/Game/Utils.cs | 22 +++----- FinalSuspect/Modules/Resources/ModUpdater.cs | 2 +- FinalSuspect/Modules/Resources/PathManager.cs | 11 ++-- FinalSuspect/Patches/Game_Vanilla/HudPatch.cs | 10 +++- .../Patches/System/AccountManagerPatch.cs | 4 +- .../Patches/System/GameOptionPatch.cs | 16 +++--- .../Patches/System/GameStartManagerPatch.cs | 55 +------------------ .../Patches/System/LobbyPanelPatch.cs | 8 +-- FinalSuspect/main.cs | 8 +-- 26 files changed, 61 insertions(+), 116 deletions(-) diff --git a/Assets/Languages/Brazilian.yaml b/Assets/Languages/Brazilian.yaml index 96c4513..5a00b2b 100644 --- a/Assets/Languages/Brazilian.yaml +++ b/Assets/Languages/Brazilian.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Dutch.yaml b/Assets/Languages/Dutch.yaml index b1dcbda..446adf6 100644 --- a/Assets/Languages/Dutch.yaml +++ b/Assets/Languages/Dutch.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/English.yaml b/Assets/Languages/English.yaml index a9cd6d7..bed9b64 100644 --- a/Assets/Languages/English.yaml +++ b/Assets/Languages/English.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Filipino.yaml b/Assets/Languages/Filipino.yaml index 97a74df..c3d40cd 100644 --- a/Assets/Languages/Filipino.yaml +++ b/Assets/Languages/Filipino.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/French.yaml b/Assets/Languages/French.yaml index 2736560..ce6b63c 100644 --- a/Assets/Languages/French.yaml +++ b/Assets/Languages/French.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/German.yaml b/Assets/Languages/German.yaml index cbe8162..53dea2a 100644 --- a/Assets/Languages/German.yaml +++ b/Assets/Languages/German.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Irish.yaml b/Assets/Languages/Irish.yaml index 761ac89..e846e30 100644 --- a/Assets/Languages/Irish.yaml +++ b/Assets/Languages/Irish.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Italian.yaml b/Assets/Languages/Italian.yaml index 228007e..3598455 100644 --- a/Assets/Languages/Italian.yaml +++ b/Assets/Languages/Italian.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Japanese.yaml b/Assets/Languages/Japanese.yaml index 7ed95e9..b27859e 100644 --- a/Assets/Languages/Japanese.yaml +++ b/Assets/Languages/Japanese.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Korean.yaml b/Assets/Languages/Korean.yaml index 29ca457..eb9ad4a 100644 --- a/Assets/Languages/Korean.yaml +++ b/Assets/Languages/Korean.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Latam.yaml b/Assets/Languages/Latam.yaml index 4a86d07..5e26237 100644 --- a/Assets/Languages/Latam.yaml +++ b/Assets/Languages/Latam.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Portuguese.yaml b/Assets/Languages/Portuguese.yaml index bf7b241..839db20 100644 --- a/Assets/Languages/Portuguese.yaml +++ b/Assets/Languages/Portuguese.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/Russian.yaml b/Assets/Languages/Russian.yaml index f1d44f0..5946f35 100644 --- a/Assets/Languages/Russian.yaml +++ b/Assets/Languages/Russian.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/SChinese.yaml b/Assets/Languages/SChinese.yaml index a359f92..0908f38 100644 --- a/Assets/Languages/SChinese.yaml +++ b/Assets/Languages/SChinese.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type @@ -29,12 +29,12 @@ Role.Engineer: "工程师" Role.Scientist: "科学家" Role.Tracker: "侦查员" Role.Noisemaker: "大嗓门" +Role.Detective: "侦探" Role.GuardianAngel: "守护天使" Role.Impostor: "伪装者" Role.Shapeshifter: "变形者" Role.Phantom: "幻象师" Role.Viper: "毒蛇" -Role.Detective: "侦探" Role.CrewmateGhost: "船员灵魂" Role.ImpostorGhost: "伪装者灵魂" diff --git a/Assets/Languages/Spanish.yaml b/Assets/Languages/Spanish.yaml index 1e9cee7..e03e661 100644 --- a/Assets/Languages/Spanish.yaml +++ b/Assets/Languages/Spanish.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/Assets/Languages/TChinese.yaml b/Assets/Languages/TChinese.yaml index 9c22e23..978ce42 100644 --- a/Assets/Languages/TChinese.yaml +++ b/Assets/Languages/TChinese.yaml @@ -1,7 +1,7 @@ # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) -# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.XtremeWave.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" +# 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" TextBelowVersionText: "" # 职业类型 / Role Type diff --git a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs index 69dc886..1a72540 100644 --- a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs +++ b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs @@ -13,12 +13,7 @@ public static RoleTypes GetRoleType(this PlayerControl player) public static bool IsImpostor(this PlayerControl pc) { - if (IsLobby) return false; - return pc.GetRoleType() switch - { - RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom or RoleTypes.ImpostorGhost or RoleTypes.Viper => true, - _ => false - }; + return !IsLobby && pc.GetRoleType().IsImpostor(); } public static string GetNameWithRole(this PlayerControl player, bool forUser = false) diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index 1c23ead..8b60aac 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -472,7 +472,8 @@ public static bool IsImpostor(this RoleTypes role) { return role switch { - RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom or RoleTypes.ImpostorGhost or RoleTypes.Viper => true, + RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom or RoleTypes.ImpostorGhost + or RoleTypes.Viper => true, _ => false }; } @@ -539,21 +540,14 @@ public static string GetRoleInfoForVanilla(this RoleTypes role, bool InfoLong = var Info = "Blurb" + (InfoLong ? "Long" : ""); if (IsNormalGame) { - // 只针对毒蛇和侦探没有BlurbLong进行本地化 - if (role is RoleTypes.Viper or RoleTypes.Detective) + if (InfoLong) { - if (InfoLong) - { - return $"{GetString($"RolesHelp_{text}_01")}{Environment.NewLine}" + - $"{GetString($"RolesHelp_{text}_02")}"; - } - else - { - return GetString($"{text}Blurb"); - } + return role is not RoleTypes.Crewmate and not RoleTypes.Impostor + ? $"{GetString($"RolesHelp_{text}_01")}\n{GetString($"RolesHelp_{text}_02")}" + : $"{GetString($"RolesHelp_{text}Role")}"; } - // 保留原有格式 - return GetString($"{text}{(InfoLong ? "BlurbLong" : "Blurb")}"); + + return GetString($"{text}Blurb"); } if (InfoLong) diff --git a/FinalSuspect/Modules/Resources/ModUpdater.cs b/FinalSuspect/Modules/Resources/ModUpdater.cs index 76286b0..14bc8b6 100644 --- a/FinalSuspect/Modules/Resources/ModUpdater.cs +++ b/FinalSuspect/Modules/Resources/ModUpdater.cs @@ -38,7 +38,7 @@ public static void StartUpdate(string url = "waitToSelect") if (IsChineseLanguageUser) { btns.Add((GetString("UpdateSource.GithubMirror"), () => StartUpdate(DownloadUrl_GithubMirror))); - //btns.Add((GetString("UpdateSource.FangKuaiRemote"), () => StartUpdate(DownloadUrl_FangKuaiRemote))); + btns.Add((GetString("UpdateSource.FangKuaiRemote"), () => StartUpdate(DownloadUrl_FangKuaiRemote))); } btns.Add((GetString(StringNames.Cancel), SetUpdateButtonStatus)); diff --git a/FinalSuspect/Modules/Resources/PathManager.cs b/FinalSuspect/Modules/Resources/PathManager.cs index 151a536..f96d2ef 100644 --- a/FinalSuspect/Modules/Resources/PathManager.cs +++ b/FinalSuspect/Modules/Resources/PathManager.cs @@ -20,8 +20,9 @@ public static class PathManager public const string DownloadUrl_GithubMirror = "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect/releases/latest/download/FinalSuspect.dll"; - //public const string DownloadUrl_FangKuaiRemote = - // "https://dlhk.fangkuai.fun/FinalSuspect/FinalSuspect.dll"; + public const string DownloadUrl_FangKuaiRemote = + "https://dlhk.fangkuai.fun/FinalSuspect/FinalSuspect.dll"; + public static readonly string BANEDWORDS_FILE_PATH = GetBanFilesPath("BanWords.json"); public static readonly string DENY_NAME_LIST_PATH = GetBanFilesPath("DenyName.json"); @@ -35,7 +36,7 @@ public static class PathManager "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect/raw/FinalSus/", "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect_Assets/raw/FinalAsset/", "https://gitee.com/LezaiYa/FinalSuspectAssets/raw/main/", - //"https://dlhk.fangkuai.fun/FinalSuspect/", + "https://dlhk.fangkuai.fun/FinalSuspect/", #if DEBUG $"file:///{Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))}/", #endif @@ -63,7 +64,7 @@ private static string GetRemoteBase(RemoteType remoteType) RemoteType.GithubMirror => "hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect/raw/FinalSus/", RemoteType.GithubMirror_Assets => "hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect_Assets/raw/FinalAsset/", - //RemoteType.FangKuaiRemote => "dlhk.fangkuai.fun/FinalSuspect/", + RemoteType.FangKuaiRemote => "dlhk.fangkuai.fun/FinalSuspect/", RemoteType.Gitee => "gitee.com/LezaiYa/FinalSuspectAssets/raw/main/", RemoteType.Github => "github.com/Slok7565/FinalSuspect/raw/FinalSus/", RemoteType.Github_Assets => "github.com/Slok7565/FinalSuspect_Assets/raw/FinalAsset/", @@ -178,7 +179,7 @@ public enum FileType public enum RemoteType { - //FangKuaiRemote, + FangKuaiRemote, GithubMirror, GithubMirror_Assets, Gitee, diff --git a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs index 59fb03b..123b4c2 100644 --- a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs @@ -176,13 +176,19 @@ private static void SetAbilityButtonColor(HudManager __instance) var color = GetRoleColor(PlayerControl.LocalPlayer.GetRoleType()); __instance.AbilityButton.buttonLabelText.SetOutlineColor(color); __instance.AbilityButton.cooldownTimerText.color = color; + __instance.SecondaryAbilityButton.buttonLabelText.SetOutlineColor(color); + __instance.SecondaryAbilityButton.cooldownTimerText.color = color; __instance.KillButton.cooldownTimerText.color = ColorHelper.ImpostorRedPale; // 刷新按钮状态 - if (!__instance.AbilityButton.gameObject.active || Refresh) return; + if (Refresh) return; Refresh = true; + var active1 = __instance.AbilityButton.gameObject.active; __instance.AbilityButton.gameObject.SetActive(false); - __instance.AbilityButton.gameObject.SetActive(true); + __instance.AbilityButton.gameObject.SetActive(active1); + var active2 = __instance.SecondaryAbilityButton.gameObject.active; + __instance.SecondaryAbilityButton.gameObject.SetActive(false); + __instance.SecondaryAbilityButton.gameObject.SetActive(active2); } private static void SetShowInfoPanel() diff --git a/FinalSuspect/Patches/System/AccountManagerPatch.cs b/FinalSuspect/Patches/System/AccountManagerPatch.cs index f06a5cf..0574886 100644 --- a/FinalSuspect/Patches/System/AccountManagerPatch.cs +++ b/FinalSuspect/Patches/System/AccountManagerPatch.cs @@ -37,14 +37,14 @@ public static class AwakeAccountManager LoadSprite("CI_Scientist.png", 450f), LoadSprite("CI_Tracker.png", 450f), LoadSprite("CI_Noisemaker.png", 450f), + LoadSprite("CI_Detective.png", 450f), LoadSprite("CI_CrewmateGhost.png", 450f), LoadSprite("CI_Impostor.png", 450f), LoadSprite("CI_HnSImpostor.png", 450f), LoadSprite("CI_Shapeshifter.png", 450f), LoadSprite("CI_Phantom.png", 450f), - LoadSprite("CI_ImpostorGhost.png", 450f), LoadSprite("CI_Viper.png", 450f), - LoadSprite("CI_Detective.png", 450f) + LoadSprite("CI_ImpostorGhost.png", 450f), ]; private static int _currentIndex; diff --git a/FinalSuspect/Patches/System/GameOptionPatch.cs b/FinalSuspect/Patches/System/GameOptionPatch.cs index 8d05cd1..fc8d13d 100644 --- a/FinalSuspect/Patches/System/GameOptionPatch.cs +++ b/FinalSuspect/Patches/System/GameOptionPatch.cs @@ -21,11 +21,12 @@ internal class RolesSettingsMenuPatch { private static readonly List rolecolors = [ - GetRoleColor(RoleTypes.Engineer), - GetRoleColor(RoleTypes.GuardianAngel), GetRoleColor(RoleTypes.Scientist), - GetRoleColor(RoleTypes.Tracker), + GetRoleColor(RoleTypes.GuardianAngel), + GetRoleColor(RoleTypes.Engineer), + GetRoleColor(RoleTypes.Noisemaker), + GetRoleColor(RoleTypes.Tracker), GetRoleColor(RoleTypes.Detective), GetRoleColor(RoleTypes.Shapeshifter), GetRoleColor(RoleTypes.Phantom), @@ -48,15 +49,15 @@ public static void Postfix() private static void ConfigureHeaderButtons() { - var header = GameObject.Find("HeaderButtons"); + var header = GameObject.Find("HeaderButtons").transform.FindChild("ButtonsParentScroller"); var headerbuttons = new List(); - for (var i = 4; i <= 10; i++) headerbuttons.Add(header.transform.GetChild(i).gameObject); + for (var i = 1; i <= header.childCount - 1; i++) headerbuttons.Add(header.transform.GetChild(i).gameObject); var index = 0; foreach (var button in headerbuttons) { - var roleColor = index <= 4 ? GetRoleColor(RoleTypes.Crewmate) : GetRoleColor(RoleTypes.Impostor); + var roleColor = index <= 5 ? GetRoleColor(RoleTypes.Crewmate) : GetRoleColor(RoleTypes.Impostor); SetColor(button, rolecolors[index], roleColor); index++; } @@ -66,7 +67,8 @@ private static void ConfigureHeaderButtons() private static void ConfigureAllButtonColors() { - var allButton = GameObject.Find("HeaderButtons").transform.FindChild("AllButton").gameObject; + var allButton = GameObject.Find("HeaderButtons").transform.FindChild("ButtonsParentScroller") + .FindChild("AllButton").gameObject; allButton.transform.FindChild("Highlight").gameObject.GetComponent().color = allButton.transform.FindChild("Inactive").gameObject.GetComponent().color = allButton.transform.FindChild("Selected").gameObject.GetComponent().color = diff --git a/FinalSuspect/Patches/System/GameStartManagerPatch.cs b/FinalSuspect/Patches/System/GameStartManagerPatch.cs index 05a6257..8c74cc4 100644 --- a/FinalSuspect/Patches/System/GameStartManagerPatch.cs +++ b/FinalSuspect/Patches/System/GameStartManagerPatch.cs @@ -141,8 +141,7 @@ public static bool Prefix(GameStartManager __instance) if (!Main.AutoStartGame.Value || !AmongUsClient.Instance.AmHost - || GameStartManager.Instance.startState == GameStartManager.StartingStates.Starting - || IsInGame) return true; + || GameStartManager.Instance.startState == GameStartManager.StartingStates.Starting) return true; _updateTimer++; if (_updateTimer < 50) return true; _updateTimer = 0; @@ -158,54 +157,10 @@ public static void Postfix(GameStartManager __instance) if (!AmongUsClient.Instance) return; if (AmongUsClient.Instance.AmHost) { - /*bool canStartGame = true; - List mismatchedPlayerNameList = new(); - foreach (var client in AmongUsClient.Instance.allClients.ToArray()) - { - if (client.Character == null) continue; - var dummyComponent = client.Character.GetComponent(); - if (dummyComponent != null && dummyComponent.enabled) - continue; - if (!MatchVersions(client.Character.PlayerId, true)) - { - canStartGame = false; - mismatchedPlayerNameList.Add(StringHelper.ColorString(Palette.PlayerColors[client.ColorId], client.Character.Data.PlayerName)); - } - } - if (!canStartGame) - { - __instance.StartButton.gameObject.SetActive(false); - warningMessage = StringHelper.ColorString(Color.red, string.Format(GetString("Warning.MismatchedVersion"), string.Join(" ", mismatchedPlayerNameList), $"{Main.ModName}")); - }*/ _cancelButton.gameObject.SetActive(__instance.startState == GameStartManager.StartingStates.Countdown); __instance.StartButton.gameObject.SetActive(!_cancelButton.gameObject.active); } - /*if (MatchVersions(0, true) || Main.VersionCheat.Value) - exitTimer = 0; - else - { - exitTimer += Time.deltaTime; - if (exitTimer >= 5) - { - exitTimer = 0; - AmongUsClient.Instance.ExitGame(DisconnectReasons.ExitGame); - SceneChanger.ChangeScene("MainMenu"); - } - if (exitTimer != 0) - warningMessage = StringHelper.ColorString(Color.red, string.Format(GetString("Warning.AutoExitAtMismatchedVersion"), $"{Main.ModName}", Math.Round(5 - exitTimer).ToString())); - }*/ - var warningMessage = ""; - if (warningMessage == "") - { - _warningText.gameObject.SetActive(false); - } - else - { - _warningText.text = warningMessage; - _warningText.gameObject.SetActive(true); - } - if (AmongUsClient.Instance.AmHost) __instance.GameStartText.transform.localPosition = new Vector3( __instance.GameStartText.transform.localPosition.x, 2f, @@ -225,14 +180,6 @@ public static void Postfix(GameStartManager __instance) if (_timer <= 60) countDown = StringHelper.ColorString(Color.red, countDown); _timerText.text = countDown; } - - /*private static bool MatchVersions(byte playerId, bool acceptVanilla = false) - { - if (!FinalGameData.PlayerVersion.playerVersion.TryGetValue(playerId, out var version)) return acceptVanilla; - return Main.ForkId == version.forkId - && Main.version.CompareTo(version.version) == 0 - && version.tag == $"{Main.GitCommit}({Main.GitBranch})"; - }*/ } } diff --git a/FinalSuspect/Patches/System/LobbyPanelPatch.cs b/FinalSuspect/Patches/System/LobbyPanelPatch.cs index c56e74a..65df358 100644 --- a/FinalSuspect/Patches/System/LobbyPanelPatch.cs +++ b/FinalSuspect/Patches/System/LobbyPanelPatch.cs @@ -87,7 +87,7 @@ private static void Awake() [HarmonyPatch(typeof(LobbyViewSettingsPane), nameof(LobbyViewSettingsPane.Update))] [HarmonyPostfix] - private static void Update() + private static void Update(LobbyViewSettingsPane __instance) { try { @@ -99,7 +99,7 @@ private static void Update() { #region 游戏设置 - if (area.childCount == 21) + if (__instance.currentTab is StringNames.OverviewCategory) { var catIndex = 0; var bannerIndex = 0; @@ -147,7 +147,7 @@ private static void Update() break; case "ViewSettingsInfoPanel_Role Variant(Clone)": { - var roleColor = bannerIndex <= 4 + var roleColor = bannerIndex <= 5 ? GetRoleColor(RoleTypes.Crewmate) : GetRoleColor(RoleTypes.Impostor); SetColorForRolesBanner(banner.gameObject, rolecolors[bannerIndex], roleColor); @@ -165,7 +165,7 @@ private static void Update() if (banner.name == "AdvancedRoleViewPanel(Clone)") { var iconIndex = enableRoleIndex.First(); - var roleColor = iconIndex <= 4 + var roleColor = iconIndex <= 5 ? GetRoleColor(RoleTypes.Crewmate) : GetRoleColor(RoleTypes.Impostor); SetColorForIcon(banner.gameObject, rolecolors[iconIndex], roleColor); diff --git a/FinalSuspect/main.cs b/FinalSuspect/main.cs index b3150d8..04bfca3 100644 --- a/FinalSuspect/main.cs +++ b/FinalSuspect/main.cs @@ -31,7 +31,7 @@ public class Main : BasePlugin // == 程序基本设定 / Program Config == public const string ModName = "Final Suspect"; public const string ForkId = "Final Suspect"; - public const string PluginVersion = "1.2.1"; + public const string PluginVersion = "1.2.99"; public const string PluginGuid = "cn.slok.finalsuspect"; public const int PluginCreation = 1; public const string DebugKeyHash = "c0fd562955ba56af3ae20d7ec9e64c664f0facecef4b3e366e109306adeae29d"; @@ -40,7 +40,7 @@ public class Main : BasePlugin // == 版本相关设定 / Version Config == public const string LowestSupportedVersion = "2025.9.9"; // 17.0.0 - private const string DisplayedVersion_Head = "1.2"; + private const string DisplayedVersion_Head = "1.3"; private const string DisplayedVersion_Date = BuildTime.Date; @@ -82,8 +82,8 @@ public class Main : BasePlugin { RoleTypes.Impostor, "#FF1919" }, { RoleTypes.Shapeshifter, "#FF819E" }, { RoleTypes.Phantom, "#CA8AFF" }, - { RoleTypes.Detective, "#6490c3"}, - { RoleTypes.Viper, "#e8524d"} + { RoleTypes.Detective, "#70A1DA" }, + { RoleTypes.Viper, "#F06762" } }; public static string HostNickName = ""; From 270e91611ce0baa5207d53ad65c929210e3cd235 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 12 Sep 2025 22:51:24 +0800 Subject: [PATCH 03/19] Update TODO.txt --- Assets/TODO.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 Assets/TODO.txt diff --git a/Assets/TODO.txt b/Assets/TODO.txt new file mode 100644 index 0000000..63997e5 --- /dev/null +++ b/Assets/TODO.txt @@ -0,0 +1,2 @@ +1.将算法修正按钮修改为Aspect +2.全面优化设置着色代码 From 8efc041165e9d8cf53318b4c5376d0783c3542b5 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 12 Sep 2025 22:56:32 +0800 Subject: [PATCH 04/19] update --- FinalSuspect/Modules/Core/Game/Utils.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index 8b60aac..7c94c6b 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -537,7 +537,7 @@ public static string GetRoleInfoForVanilla(this RoleTypes role, bool InfoLong = InfoLong = false; var text = role.ToString(); - var Info = "Blurb" + (InfoLong ? "Long" : ""); + if (IsNormalGame) { if (InfoLong) @@ -563,6 +563,7 @@ public static string GetRoleInfoForVanilla(this RoleTypes role, bool InfoLong = $"\n{GetString(StringNames.RuleThreeImpostor)}"; } + var Info = "Blurb" + (InfoLong ? "Long" : ""); text = "HnS" + text; return GetString($"{text}{Info}"); } From 7932060078e5e51a55ad73cc3d96d02a8106ff42 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Sat, 13 Sep 2025 22:03:11 +0800 Subject: [PATCH 05/19] bugs fix --- .../ClientActions/ClientActionsPatch.cs | 2 +- .../DataHandling/FinalGameData/GameStates.cs | 31 ++++++++++++++----- FinalSuspect/Modules/Core/Game/Utils.cs | 5 ++- FinalSuspect/Patches/Game_Vanilla/HudPatch.cs | 4 ++- .../Patches/Game_Vanilla/IntroPatch.cs | 3 +- .../Game_Vanilla/PlayerJoinAndLeftPatch.cs | 4 +-- .../Patches/System/GameStartManagerPatch.cs | 3 +- FinalSuspect/Patches/System/PhasePatch.cs | 12 +++++-- SECURITY.md | 2 +- 9 files changed, 48 insertions(+), 18 deletions(-) diff --git a/FinalSuspect/ClientActions/ClientActionsPatch.cs b/FinalSuspect/ClientActions/ClientActionsPatch.cs index 18bbc11..f072d34 100644 --- a/FinalSuspect/ClientActions/ClientActionsPatch.cs +++ b/FinalSuspect/ClientActions/ClientActionsPatch.cs @@ -270,7 +270,7 @@ private static void SwitchMode() private static void AutoStartButtonToggle() { - if (Main.AutoStartGame.Value == false && IsCountDown) GameStartManager.Instance.ResetStartState(); + if (!Main.AutoStartGame.Value && IsCountDown) GameStartManager.Instance.ResetStartState(); } public static void SetCursor() diff --git a/FinalSuspect/DataHandling/FinalGameData/GameStates.cs b/FinalSuspect/DataHandling/FinalGameData/GameStates.cs index acccbbf..052ab85 100644 --- a/FinalSuspect/DataHandling/FinalGameData/GameStates.cs +++ b/FinalSuspect/DataHandling/FinalGameData/GameStates.cs @@ -11,6 +11,7 @@ public static class GameStates { private static bool InGame { get; set; } private static bool InMeeting { get; set; } + private static bool InitGame { get; set; } public static bool OtherModHost { @@ -42,6 +43,7 @@ public static bool OtherModHost public static bool IsFreePlay => AmongUsClient.Instance.NetworkMode == NetworkModes.FreePlay; public static bool IsInTask => IsInGame && !MeetingHud.Instance; public static bool IsInMeeting => IsInGame && MeetingHud.Instance && InMeeting; + public static bool IsInitGame => InitGame; public static bool IsVoting => IsInMeeting && MeetingHud.Instance.state is MeetingHud.VoteStates.Voted @@ -74,14 +76,22 @@ public static bool IsVanillaServer } } - public static void UpdateGameState_IsInGame(bool inGame) + public static void UpdateGameState(bool state, StateTypes type) { - InGame = inGame; - } - - public static void UpdateGameState_IsInMeeting(bool inMeeting) - { - InMeeting = inMeeting; + switch (type) + { + case StateTypes.InGame: + InGame = state; + break; + case StateTypes.InMeeting: + InMeeting = state; + break; + case StateTypes.InitGame: + InitGame = state; + break; + default: + throw new ArgumentOutOfRangeException(nameof(type), type, null); + } } public static bool MapIsActive(MapNames name) @@ -89,4 +99,11 @@ public static bool MapIsActive(MapNames name) return (MapNames)GameOptionsManager.Instance.CurrentGameOptions.MapId == name; } } +} + +public enum StateTypes +{ + InGame, + InMeeting, + InitGame } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index 7c94c6b..92ffbb5 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -472,7 +472,10 @@ public static bool IsImpostor(this RoleTypes role) { return role switch { - RoleTypes.Impostor or RoleTypes.Shapeshifter or RoleTypes.Phantom or RoleTypes.ImpostorGhost + RoleTypes.Impostor + or RoleTypes.Shapeshifter + or RoleTypes.Phantom + or RoleTypes.ImpostorGhost or RoleTypes.Viper => true, _ => false }; diff --git a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs index 123b4c2..a6bb950 100644 --- a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs @@ -173,11 +173,13 @@ private static void SetAbilityButtonColor(HudManager __instance) { if (!IsInGame) return; - var color = GetRoleColor(PlayerControl.LocalPlayer.GetRoleType()); + var role = PlayerControl.LocalPlayer.GetRoleType(); + var color = GetRoleColor(role); __instance.AbilityButton.buttonLabelText.SetOutlineColor(color); __instance.AbilityButton.cooldownTimerText.color = color; __instance.SecondaryAbilityButton.buttonLabelText.SetOutlineColor(color); __instance.SecondaryAbilityButton.cooldownTimerText.color = color; + __instance.KillButton.cooldownTimerText.color = ColorHelper.ImpostorRedPale; // 刷新按钮状态 diff --git a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs index a3b8aef..03a47f2 100644 --- a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using FinalSuspect.DataHandling.FinalGameData; using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using TMPro; @@ -13,7 +14,7 @@ internal class IntroCutscenePatch [HarmonyPrefix] public static void CoBegin_Prefix() { - UpdateGameState_IsInGame(true); + UpdateGameState(true, StateTypes.InGame); Info("Game Start", "IntroCutscene"); } diff --git a/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs b/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs index c65abc8..3bd6d15 100644 --- a/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs @@ -17,8 +17,8 @@ public static void Postfix(AmongUsClient __instance) Info($"{__instance.GameId} 加入房间", "OnGameJoined"); FinalGameData.PlayerVersion.PlayerVersions = new Dictionary(); FinalPlayerData.InitializeAll(); - UpdateGameState_IsInGame(false); - UpdateGameState_IsInMeeting(false); + UpdateGameState(false, StateTypes.InGame); + UpdateGameState(false, StateTypes.InMeeting); ErrorText.Instance.Clear(); ServerAddManager.SetServerName(); FinalGameData.JoinedCompleted = false; diff --git a/FinalSuspect/Patches/System/GameStartManagerPatch.cs b/FinalSuspect/Patches/System/GameStartManagerPatch.cs index 8c74cc4..7a44db4 100644 --- a/FinalSuspect/Patches/System/GameStartManagerPatch.cs +++ b/FinalSuspect/Patches/System/GameStartManagerPatch.cs @@ -141,7 +141,8 @@ public static bool Prefix(GameStartManager __instance) if (!Main.AutoStartGame.Value || !AmongUsClient.Instance.AmHost - || GameStartManager.Instance.startState == GameStartManager.StartingStates.Starting) return true; + || GameStartManager.Instance.startState == GameStartManager.StartingStates.Starting + || IsInitGame) return true; _updateTimer++; if (_updateTimer < 50) return true; _updateTimer = 0; diff --git a/FinalSuspect/Patches/System/PhasePatch.cs b/FinalSuspect/Patches/System/PhasePatch.cs index 4695388..0782275 100644 --- a/FinalSuspect/Patches/System/PhasePatch.cs +++ b/FinalSuspect/Patches/System/PhasePatch.cs @@ -17,7 +17,8 @@ public class AmongUsClientOnGameEndPatch { public static void Postfix() { - UpdateGameState_IsInGame(false); + UpdateGameState(false, StateTypes.InGame); + UpdateGameState(false, StateTypes.InitGame); Info("-----------游戏结束-----------", "Phase"); } } @@ -28,7 +29,7 @@ public class MeetingHudStartPatch { public static void Prefix() { - _ = new LateTask(() => UpdateGameState_IsInMeeting(true), 1f, "UpdateGameState_IsInMeeting"); + _ = new LateTask(() => UpdateGameState(true, StateTypes.InMeeting), 1f, "Update game state"); Info("------------会议开始------------", "Phase"); } } @@ -38,7 +39,7 @@ internal class MeetingHudOnDestroyPatch { public static void Postfix() { - UpdateGameState_IsInMeeting(false); + UpdateGameState(false, StateTypes.InMeeting); Info("------------会议结束------------", "Phase"); } } @@ -46,6 +47,11 @@ public static void Postfix() [HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.CoStartGame))] internal class CoStartGamePatch { + public static void Prefix() + { + UpdateGameState(true, StateTypes.InitGame); + } + public static void Postfix() { GameModuleInitializerAttribute.InitializeAll(); diff --git a/SECURITY.md b/SECURITY.md index 4d0b64b..e544b1a 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -19,7 +19,7 @@ 您可以通过联系Slok反馈安全问题。 > 在我们修复此安全问题之前,请**不要公开讨论或宣扬此安全问题**。 - (建议)Slok7565 - - 微信号: \_Slok7565-S0kA1\_ + - 微信号: The\_S1ok - (建议)QQ号: 639083778 你也可以通过在[安全](https://github.com/Slok7565/FinalSuspect/security)页面点击`Report a vulnerability`以通过GitHub向我们报告一个安全问题。 From 779a65a9bfb8f43497032a6856296a620e8f77a5 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Thu, 2 Oct 2025 23:44:34 +0800 Subject: [PATCH 06/19] Android(Starlight) Support --- Assets/ModNews/SChinese/FS.v1.3.txt | 48 +++++++ FinalSuspect.sln | 28 ++-- .../FeatureItems/NameTag/NameTagEditMenu.cs | 47 +++---- .../FeatureItems/NameTag/NameTagNewWindow.cs | 11 +- .../FeatureItems/NameTag/UiHelper.cs | 17 +-- .../FinalAntiCheat/Core/DllChecker.cs | 4 +- .../DataHandling/FinalAntiCheat/Core/Git.cs | 1 + FinalSuspect/FinalSuspect.csproj | 25 ++-- FinalSuspect/Helpers/RemoteHelper.cs | 114 ++++++++++++---- FinalSuspect/Helpers/ResourcesHelper.cs | 2 + .../Modules/Core/Game/ServerAddManager.cs | 85 ++++++------ .../Modules/Core/Plugin/RegistryManager.cs | 54 -------- .../RegistryManager/AndroidPreferenceStore.cs | 79 +++++++++++ .../RegistryManager/IPreferenceStore.cs | 10 ++ .../Plugin/RegistryManager/RegistryManager.cs | 73 ++++++++++ .../RegistryManager/WindowsPreferenceStore.cs | 94 +++++++++++++ FinalSuspect/Modules/Resources/Downloader.cs | 128 ++++++++++++++---- FinalSuspect/Modules/Resources/PathManager.cs | 128 ++++++++++++++---- .../Modules/Resources/ResourcesDownloader.cs | 6 + .../Patches/Game_Vanilla/IntroPatch.cs | 9 +- .../Patches/System/CredentialsPatch.cs | 25 ++-- FinalSuspect/Patches/System/LoadPatch.cs | 15 +- .../Patches/System/MainMenuManagerPatch.cs | 67 ++++++++- .../Patches/System/Others/UnityEnginePatch.cs | 7 +- FinalSuspect/Patches/System/PhasePatch.cs | 2 + FinalSuspect/main.cs | 2 + 26 files changed, 819 insertions(+), 262 deletions(-) create mode 100644 Assets/ModNews/SChinese/FS.v1.3.txt delete mode 100644 FinalSuspect/Modules/Core/Plugin/RegistryManager.cs create mode 100644 FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs create mode 100644 FinalSuspect/Modules/Core/Plugin/RegistryManager/IPreferenceStore.cs create mode 100644 FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs create mode 100644 FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt new file mode 100644 index 0000000..cd7880a --- /dev/null +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -0,0 +1,48 @@ +#Number:100009 +#Title:终极嫌疑 v1.3 +#SubTitle:★★★★安卓闪亮登场!★★★★ +#ShortTitle:★版本更新v1.3 +#Date:2025-08-15T00:00:00Z +#----------------------------- +# 简体中文 +自Starlight问世,安卓玩家也有了享受模组的权利 +因此,我们在适配了最新版本的同时,也对Starlight进行了适配 +享受使用手机游玩Final Suspect的时光吧! + +## 对应官方版本 +- 基于 Among Us v17.0.0 +- 使用 BepInEx 框架 v6.0.0-be.738 + +## 模组版本信息 +- 程序集版本号: v1.2.99 +- 版本类型: Canary(测试) +- 构建号: 3 + +## 更新内容 +- 修正: 23 +- 优化: 10 +- 更改: 17 +- 新增: 37 +- 重制: 1 +- 删除: 1 + +## 贡献者 +- [小黄117]("https://space.bilibili.com/403301761?spm_id_from=333.337.0.0") + +## 修正 +- 修复了部分分辨率下出现UI错误的问题 +修复: Slok + +## 优化 + +## 更改 +- 修改职业介绍格式 +- 将[LezaiYa]("https://github.com/NewLezaiYa")列入**开发者** + +## 新增 +- 适配**Among Us v17.0.0** +- 适配**Starlight**安装模组启动器 + +## 重制 + +## 删除 \ No newline at end of file diff --git a/FinalSuspect.sln b/FinalSuspect.sln index d0f63c1..b15e2a7 100644 --- a/FinalSuspect.sln +++ b/FinalSuspect.sln @@ -7,17 +7,27 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FinalSuspect", "FinalSuspec EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - OpenBeta|Any CPU = OpenBeta|Any CPU + Debug|Windows = Debug|Windows + OpenBeta|Windows = OpenBeta|Windows + Release|Windows = Release|Windows + Debug|Android = Debug|Android + OpenBeta|Android = OpenBeta|Android + Release|Android = Release|Android + EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BB32D6D5-7915-496C-933A-A2632C78918F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BB32D6D5-7915-496C-933A-A2632C78918F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BB32D6D5-7915-496C-933A-A2632C78918F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BB32D6D5-7915-496C-933A-A2632C78918F}.Release|Any CPU.Build.0 = Release|Any CPU - {BB32D6D5-7915-496C-933A-A2632C78918F}.OpenBeta|Any CPU.ActiveCfg = OpenBeta|Any CPU - {BB32D6D5-7915-496C-933A-A2632C78918F}.OpenBeta|Any CPU.Build.0 = OpenBeta|Any CPU + {BB32D6D5-7915-496C-933A-A2632C78918F}.OpenBeta|Windows.ActiveCfg = OpenBeta|Windows + {BB32D6D5-7915-496C-933A-A2632C78918F}.OpenBeta|Windows.Build.0 = OpenBeta|Windows + {BB32D6D5-7915-496C-933A-A2632C78918F}.Release|Windows.ActiveCfg = Release|Windows + {BB32D6D5-7915-496C-933A-A2632C78918F}.Release|Windows.Build.0 = Release|Windows + {BB32D6D5-7915-496C-933A-A2632C78918F}.Release|Android.ActiveCfg = Release|Android + {BB32D6D5-7915-496C-933A-A2632C78918F}.Release|Android.Build.0 = Release|Android + {BB32D6D5-7915-496C-933A-A2632C78918F}.Debug|Android.ActiveCfg = Debug|Android + {BB32D6D5-7915-496C-933A-A2632C78918F}.Debug|Android.Build.0 = Debug|Android + {BB32D6D5-7915-496C-933A-A2632C78918F}.Debug|Windows.ActiveCfg = Debug|Windows + {BB32D6D5-7915-496C-933A-A2632C78918F}.Debug|Windows.Build.0 = Debug|Windows + {BB32D6D5-7915-496C-933A-A2632C78918F}.OpenBeta|Android.ActiveCfg = OpenBeta|Android + {BB32D6D5-7915-496C-933A-A2632C78918F}.OpenBeta|Android.Build.0 = OpenBeta|Android EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs b/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs index c004632..b541e52 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs +++ b/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs @@ -38,7 +38,7 @@ public enum ComponentType private static ComponentType _currentComponent; // UI 元素 - public static GameObject Menu { get; private set; } + public static GameObject Menu { get; set; } private static Dictionary ComponentButtons { get; } = new(); public static GameObject Preview { get; private set; } public static GameObject TextEnter { get; private set; } @@ -238,7 +238,7 @@ public static void Init() ); var closeButton = UiHelper.CreateCloseButton(Menu.transform, () => Toggle(null, false)); - closeButton.transform.localPosition = new Vector3(4.9f, 2.5f, -1f) * GetResolutionOffset(); + closeButton.transform.localPosition = new Vector3(4.9f, 2.5f, -1f); CreateComponentButtons(); CreateActionButtons(); CreatePreviewSection(); @@ -263,14 +263,12 @@ private static void CreateComponentButton(ComponentType type, int col, int row) { var x = ButtonStartX + col * ButtonSpacing; var y = ButtonStartY - row * ButtonRowHeight; - var offset = GetResolutionOffset(); var button = UiHelper.CreateButton( Menu.transform.Find("Button Prefab").gameObject, Menu.transform, - new Vector3(x, y, 0) * offset, - type.ToString(), - offset + new Vector3(x, y, 0), + type.ToString() ); button.name = $"Edit{type}Button"; @@ -289,14 +287,11 @@ private static void CreateComponentButton(ComponentType type, int col, int row) private static void CreateActionButtons() { - var offset = GetResolutionOffset(); - var previewButton = UiHelper.CreateButton( Menu.transform.Find("Button Prefab").gameObject, Menu.transform, - new Vector3(1.2f * offset, -2.5f * offset, 0f), - "RefreshPreview", - offset + new Vector3(1.2f, -2.5f, 0f), + "RefreshPreview" ); previewButton.name = "RefreshPreviewButton"; @@ -315,9 +310,8 @@ private static void CreateActionButtons() var saveButton = UiHelper.CreateButton( Menu.transform.Find("Button Prefab").gameObject, Menu.transform, - new Vector3(3.5f * offset, -2.5f * offset, 0f), - "SaveAndClose", - offset + new Vector3(3.5f, -2.5f, 0f), + "SaveAndClose" ); saveButton.name = "SaveAndExitButton"; @@ -342,9 +336,8 @@ private static void CreateActionButtons() var deleteButton = UiHelper.CreateButton( Menu.transform.Find("Button Prefab").gameObject, Menu.transform, - new Vector3(-3.5f * offset, -2.5f * offset, 0f), + new Vector3(-3.5f, -2.5f, 0f), GetString("Delete"), - offset, false ); deleteButton.name = "DeleteButton"; @@ -380,12 +373,10 @@ private static void CreateActionButtons() private static void CreatePreviewSection() { - var offset = GetResolutionOffset(); - Preview = UiHelper.CreateText( Menu.transform.Find("Title Prefab").gameObject, Menu.transform, - new Vector3(0f, 1.2f * offset, 0f), + new Vector3(0f, 1.2f, 0f), DataManager.player.Customization.Name, 0.6f ); @@ -394,12 +385,10 @@ private static void CreatePreviewSection() private static void CreateInputFields() { - var offset = GetResolutionOffset(); - // 文本输入区域 TextEnter = UiHelper.CreateInputField( Menu.transform, - new Vector3(-2.9f * offset, 0f * offset, 0f), + new Vector3(-2.9f, 0f, 0f), true ); TextEnter.name = "Edit Text Enter Box"; @@ -407,7 +396,7 @@ private static void CreateInputFields() // 尺寸输入区域 SizeEnter = UiHelper.CreateInputField( Menu.transform, - new Vector3(-2.9f * offset, -1.2f * offset, 0f), + new Vector3(-2.9f, -1.2f, 0f), false ); SizeEnter.name = "Edit Size Enter Box"; @@ -415,29 +404,29 @@ private static void CreateInputFields() // 颜色输入区域 Color1Enter = UiHelper.CreateInputField( Menu.transform, - new Vector3(1.95f * offset, -0f * offset, 0f), + new Vector3(1.95f, -0f, 0f), true ); Color1Enter.name = "Edit Color 1 Enter Box"; Color2Enter = UiHelper.CreateInputField( Menu.transform, - new Vector3(1.95f * offset, -0.6f * offset, 0f), + new Vector3(1.95f, -0.6f, 0f), true ); Color2Enter.name = "Edit Color 2 Enter Box"; Color3Enter = UiHelper.CreateInputField( Menu.transform, - new Vector3(1.95f * offset, -1.2f * offset, 0f), + new Vector3(1.95f, -1.2f, 0f), true ); Color3Enter.name = "Edit Color 3 Enter Box"; // 创建标签文本 - CreateLabel(GetString("Tip.TextContent"), new Vector3(-2.95f * offset, 0f, 0f)); - CreateLabel(GetString("Tip.TextSizeDescription"), new Vector3(-2.95f * offset, -1.2f * offset, 0f)); - CreateLabel(GetString("Tip.TextColorDescription"), new Vector3(1.95f * offset, 0.2f, 0f)); + CreateLabel(GetString("Tip.TextContent"), new Vector3(-2.95f, 0f, 0f)); + CreateLabel(GetString("Tip.TextSizeDescription"), new Vector3(-2.95f, -1.2f, 0f)); + CreateLabel(GetString("Tip.TextColorDescription"), new Vector3(1.95f, 0.2f, 0f)); } private static void CreateLabel(string text, Vector3 position) diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs b/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs index 0b11dd2..51dbdee 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs +++ b/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs @@ -9,7 +9,7 @@ public static class NameTagNewWindow { private static readonly Regex FriendCodeRegex = new("^[a-z]+#[0-9]{4}$", RegexOptions.Compiled); - public static GameObject Window { get; private set; } + public static GameObject Window { get; set; } public static GameObject Info { get; private set; } public static GameObject EnterBox { get; private set; } public static GameObject ConfirmButton { get; private set; } @@ -50,7 +50,7 @@ public static void Init() private static void CreateCloseButton() { var closeButton = UiHelper.CreateCloseButton(Window.transform, () => Window.SetActive(false)); - closeButton.transform.localPosition = new Vector3(2.4f, 1.2f, -1f) * GetResolutionOffset(); + closeButton.transform.localPosition = new Vector3(2.4f, 1.2f, -1f); } private static void CreateInfoText() @@ -58,7 +58,7 @@ private static void CreateInfoText() Info = UiHelper.CreateText( Window.transform.Find("Info Prefab").gameObject, Window.transform, - new Vector3(0f, 0.1f, 0f) * GetResolutionOffset(), + new Vector3(0f, 0.1f, 0f), GetString("Tip.PleaseEnterFriendCode"), 1f ); @@ -69,7 +69,7 @@ private static void CreateInputField() { EnterBox = UiHelper.CreateInputField( Window.transform, - new Vector3(0f, -0.04f, 0f) * GetResolutionOffset(), + new Vector3(0f, -0.04f, 0f), true ); EnterBox.name = "Enter Friend Code Box"; @@ -85,9 +85,8 @@ private static void CreateConfirmButton() ConfirmButton = UiHelper.CreateButton( Window.transform.Find("Button Prefab").gameObject, Window.transform, - new Vector3(0, -0.8f, 0f) * GetResolutionOffset(), + new Vector3(0, -0.8f, 0f), GetString(StringNames.Confirm), - GetResolutionOffset(), false ); ConfirmButton.name = "Confirm Button"; diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs b/FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs index 6614c54..a8197f1 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs +++ b/FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs @@ -18,10 +18,9 @@ public static GameObject CreateBaseWindow(string name, Transform parent, float z window.name = name; window.transform.localPosition += Vector3.forward * zOffset; - var offset = GetResolutionOffset(); var background = window.transform.Find("Background"); if (background != null) - background.localScale = background.localScale * scale * offset; + background.localScale = Vector3.one * scale; // 移除不需要的按钮 var button2 = window.transform.Find("Button2"); @@ -61,13 +60,13 @@ public static GameObject CreateCloseButton(Transform parent, Action onClick) } public static GameObject CreateButton(GameObject template, Transform parent, Vector3 position, string text, - float scale, bool getString = true) + bool getString = true) { var button = Object.Instantiate(template, parent); button.name = $"Button_{text}"; button.transform.localPosition = position; - button.transform.localScale = new Vector3(scale, scale, 1f); + button.transform.localScale = new Vector3(1f, 1f, 1f); var passiveButton = button.GetComponent(); if (passiveButton != null) @@ -92,16 +91,14 @@ public static GameObject CreateText(GameObject template, Transform parent, Vecto float fontSize) { var textObj = Object.Instantiate(template, parent); - textObj.name = $"Text_{text.Substring(0, Mathf.Min(10, text.Length))}"; + textObj.name = $"Text_{text[..Mathf.Min(10, text.Length)]}"; textObj.transform.localPosition = position; var textComp = textObj.GetComponent(); - if (textComp != null) - { - textComp.text = text; - textComp.fontSize = fontSize; - } + if (textComp == null) return textObj; + textComp.text = text; + textComp.fontSize = fontSize; return textObj; } diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs index a6f2df4..f47fa00 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs @@ -10,6 +10,7 @@ internal static class DllChecker { internal static void Init() { + return; // SM的文件名是写死的 string[] suspiciousFiles = ["SickoMenu.dll", "version.dll"]; // 获取当前Dll启动目录 @@ -33,7 +34,7 @@ internal static void Init() var fullPath = Path.Combine(amongUsPath, fileName); if (!File.Exists(fullPath)) continue; - Error($"检测到非法文件: {fileName}!游戏将被强制终止。", "FAC"); + Error($"G检测到非法文件: {fileName}!游戏将被强制终止。", "FAC"); Application.Quit(1); } } @@ -44,6 +45,7 @@ public static class DisableOtherPlugins { public static bool Prefix([HarmonyArgument(0)] PluginInfo pluginInfo, [HarmonyArgument(1)] Assembly pluginAssembly) { + return true; return pluginInfo.Metadata.GUID is "com.sinai.unityexplorer" or "cn.slok.polarnight"; diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs index 3fa4d80..9b4472b 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs @@ -7,6 +7,7 @@ internal static class Git { public static void Prefix(MainMenuManager __instance) { + return; // 获取当前Dll启动目录 var directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // 针对基于BepInEx注入检测 diff --git a/FinalSuspect/FinalSuspect.csproj b/FinalSuspect/FinalSuspect.csproj index d2dc36b..0cc1cdc 100644 --- a/FinalSuspect/FinalSuspect.csproj +++ b/FinalSuspect/FinalSuspect.csproj @@ -18,17 +18,15 @@ $([System.DateTime]::Now.ToString("yyyyMMdd")) disable + + Windows;Android - - MSB3246, CA2211, IDE0044, IDE0028, IDE0300 - - - MSB3246, CA2211, IDE0044, IDE0028, IDE0300 + + Windows - - MSB3246, CA2211, IDE0044, IDE0028, IDE0300 + + Android - @@ -42,7 +40,8 @@ - + + @@ -55,11 +54,11 @@ - + - + ..\Assets\Mod\BaseBepInEx @@ -93,7 +92,7 @@ - - + + \ No newline at end of file diff --git a/FinalSuspect/Helpers/RemoteHelper.cs b/FinalSuspect/Helpers/RemoteHelper.cs index c0bc1ca..a5db1b9 100644 --- a/FinalSuspect/Helpers/RemoteHelper.cs +++ b/FinalSuspect/Helpers/RemoteHelper.cs @@ -21,39 +21,51 @@ public static class RemoteHelper } else { - ServicePointManager.SecurityProtocol = - SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 +#if Windows + | SecurityProtocolType.Tls13 +#endif + ; - var handler = new HttpClientHandler - { - AllowAutoRedirect = true, - UseDefaultCredentials = true, - Proxy = null, - AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate - }; + var handler = CreateOptimizedHttpClientHandler(); using HttpClient client = new(handler); - client.DefaultRequestHeaders.UserAgent.ParseAdd( - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + - "AppleWebKit/537.36 (KHTML, like Gecko) " + - "Chrome/127.0 Safari/537.36"); + client.Timeout = TimeSpan.FromSeconds(45); - client.DefaultRequestHeaders.Add("Accept", - "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); - client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.9"); - client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br"); - client.DefaultRequestHeaders.Add("Cache-Control", "no-cache"); - client.DefaultRequestHeaders.Add("Referer", "https://gitee.com"); + ConfigureHttpClientHeaders(client); - using var response = await client.GetAsync(new Uri(url), HttpCompletionOption.ResponseContentRead); - if (!response.IsSuccessStatusCode) + try { - Error($"Failed [{url}]: {response.StatusCode}", "Get Json Failed"); - return ("", false); + using var response = await client.GetAsync(new Uri(url), HttpCompletionOption.ResponseContentRead); + if (!response.IsSuccessStatusCode) + { + Error($"Failed [{url}]: {response.StatusCode}", "Get Json Failed"); + return ("", false); + } + + result = await response.Content.ReadAsStringAsync(); } + catch (HttpRequestException ex) + { + Error($"HTTP请求失败: {ex.Message}", "Get Remote"); + if (ex.InnerException != null) + { + Error($"内部异常: {ex.InnerException.Message}", "Get Remote"); + } - result = await response.Content.ReadAsStringAsync(); + return ("", false); + } + catch (TaskCanceledException ex) when (ex.InnerException is TimeoutException) + { + Error($"请求超时: {url}", "Get Remote"); + return ("", false); + } + catch (Exception ex) + { + Error($"请求异常: {ex.Message}", "Get Remote"); + return ("", false); + } if (removeLineBreaks) result = result.Replace("\r", string.Empty).Replace("\n", string.Empty).Trim(); @@ -74,6 +86,60 @@ public static class RemoteHelper return (result, isValid); } + private static HttpClientHandler CreateOptimizedHttpClientHandler() + { + var handler = new HttpClientHandler + { + AllowAutoRedirect = true, + AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, + UseCookies = false, + CheckCertificateRevocationList = false // Android 上关闭证书吊销检查 + }; + + // Android SSL 配置 + ConfigureAndroidSSL(handler); + + return handler; + } + + private static void ConfigureAndroidSSL(HttpClientHandler handler) + { + handler.ServerCertificateCustomValidationCallback = (_, cert, _, sslPolicyErrors) => + { + Info($"SSL 验证结果: {sslPolicyErrors}", "Get Remote"); + + if (cert == null) return true; + Info($"证书主题: {cert.Subject}", "Get Remote"); + Info($"证书颁发者: {cert.Issuer}", "Get Remote"); + return true; + }; + } + + private static void ConfigureHttpClientHeaders(HttpClient client) + { + // 清除默认头 + client.DefaultRequestHeaders.Clear(); + + // 设置 User-Agent - 使用移动设备标识 + client.DefaultRequestHeaders.UserAgent.ParseAdd( + "Mozilla/5.0 (Linux; Android 15; Mobile) " + + "AppleWebKit/537.36 (KHTML, like Gecko) " + + "Chrome/120.0.0.0 Mobile Safari/537.36"); + + // 添加请求头 + client.DefaultRequestHeaders.Add("Accept", + "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); + client.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.9"); + client.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br"); + client.DefaultRequestHeaders.Add("Cache-Control", "no-cache"); + client.DefaultRequestHeaders.Add("Referer", "https://gitee.com"); + + // 添加更多现代浏览器头以提高兼容性 + client.DefaultRequestHeaders.Add("sec-ch-ua", "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\""); + client.DefaultRequestHeaders.Add("sec-ch-ua-mobile", "?1"); + client.DefaultRequestHeaders.Add("sec-ch-ua-platform", "\"Android\""); + } + private static bool HasInvalidControlCharacters(string input) { var allowedWhitespace = new[] { ' ', '\t', '\n', '\r' }; diff --git a/FinalSuspect/Helpers/ResourcesHelper.cs b/FinalSuspect/Helpers/ResourcesHelper.cs index a939ea4..4b6eda1 100644 --- a/FinalSuspect/Helpers/ResourcesHelper.cs +++ b/FinalSuspect/Helpers/ResourcesHelper.cs @@ -57,12 +57,14 @@ public static class ResourcesHelper public static List RemoteDependList = [ +#if Windows "NAudio.dll", "NAudio.Asio.dll", "NAudio.Core.dll", "NAudio.Flac.dll", "NAudio.Wasapi.dll", "NAudio.WinMM.dll", +#endif "YamlDotNet.dll", "YamlDotNet.xml" ]; diff --git a/FinalSuspect/Modules/Core/Game/ServerAddManager.cs b/FinalSuspect/Modules/Core/Game/ServerAddManager.cs index 89ae2e3..a7cd58e 100644 --- a/FinalSuspect/Modules/Core/Game/ServerAddManager.cs +++ b/FinalSuspect/Modules/Core/Game/ServerAddManager.cs @@ -1,4 +1,6 @@ -using FinalSuspect.Attributes; +#if Windows +using FinalSuspect.Attributes; +#endif using FinalSuspect.Helpers; using FinalSuspect.Patches.System; using UnityEngine; @@ -7,40 +9,6 @@ namespace FinalSuspect.Modules.Core.Game; public static class ServerAddManager { - private static readonly ServerManager serverManager = DestroyableSingleton.Instance; - - [PluginModuleInitializer] - public static void Init() - { - List regionInfos = - [ - CreateHttp("au-us.niko233.me", "Niko233(NA)", 443, true), - CreateHttp("au-as.niko233.me", "Niko233(AS)", 443, true), - CreateHttp("au-eu.niko233.me", "Niko233(EU)", 443, true) - ]; - - if (IsChineseUser) - { - regionInfos.Add(CreateHttp("au-cn.niko233.me", "Niko233(CN)", 443, - true)); - regionInfos.Add(CreateHttp("player.fangkuai.fun", "方块宿迁私服", - 443, - true)); - regionInfos.Add(CreateHttp("auhk.fangkuai.fun", "方块香港私服", 443, - true)); - } - - regionInfos.Add(CreateHttp("au-as.duikbo.at", "Modded Asia (MAS)", 443, true)); - regionInfos.Add(CreateHttp("www.aumods.org", "Modded NA (MNA)", 443, true)); - regionInfos.Add(CreateHttp("au-eu.duikbo.at", "Modded EU (MEU)", 443, true)); - - var defaultRegion = serverManager.CurrentRegion; - regionInfos.Where(x => !serverManager.AvailableRegions.Contains(x)).Do(serverManager.AddOrUpdateRegion); - serverManager.SetRegion(defaultRegion); - - SetServerName(defaultRegion.Name); - } - public static void SetServerName(string serverName = "") { if (serverName == "") serverName = ServerManager.Instance.CurrentRegion.Name; @@ -81,24 +49,50 @@ private static Color GetServerColor(string serverName) { var color = serverName switch { - "Asia" => new Color32(58, 166, 117, 255), - "Europe" => new Color32(58, 166, 117, 255), - "North America" => new Color32(58, 166, 117, 255), - "Modded Asia (MAS)" => new Color32(255, 132, 0, 255), - "Modded NA (MNA)" => new Color32(255, 132, 0, 255), - "Modded EU (MEU)" => new Color32(255, 132, 0, 255), + "Asia" or "Europe" or "North America" => new Color32(58, 166, 117, 255), + "Modded Asia (MAS)" or "Modded NA (MNA)" or "Modded EU (MEU)" => new Color32(255, 132, 0, 255), "方块宿迁私服" => new Color32(0, 255, 255, 255), "方块香港私服" => new Color32(0, 255, 255, 255), - "Niko233(NA)" => new Color32(255, 224, 0, 255), - "Niko233(AS)" => new Color32(255, 224, 0, 255), - "Niko233(EU)" => new Color32(255, 224, 0, 255), - "Niko233(CN)" => new Color32(255, 224, 0, 255), + "Niko233(NA)" or "Niko233(AS)" or "Niko233(EU)" or "Niko233(CN)" => new Color32(255, 224, 0, 255), _ => new Color32(255, 255, 255, 255) }; return color; } +#if Windows + private static readonly ServerManager serverManager = DestroyableSingleton.Instance; + + [PluginModuleInitializer] + public static void Init() + { + List regionInfos = + [ + CreateHttp("au-us.niko233.me", "Niko233(NA)", 443, true), + CreateHttp("au-as.niko233.me", "Niko233(AS)", 443, true), + CreateHttp("au-eu.niko233.me", "Niko233(EU)", 443, true) + ]; + + if (IsChineseUser) + { + regionInfos.Add(CreateHttp("au-cn.niko233.me", "Niko233(CN)", 443, + true)); + regionInfos.Add(CreateHttp("player.fangkuai.fun", "方块宿迁私服", + 443, + true)); + regionInfos.Add(CreateHttp("auhk.fangkuai.fun", "方块香港私服", 443, + true)); + } + + regionInfos.Add(CreateHttp("au-as.duikbo.at", "Modded Asia (MAS)", 443, true)); + regionInfos.Add(CreateHttp("www.aumods.org", "Modded NA (MNA)", 443, true)); + regionInfos.Add(CreateHttp("au-eu.duikbo.at", "Modded EU (MEU)", 443, true)); + + var defaultRegion = serverManager.CurrentRegion; + regionInfos.Where(x => !serverManager.AvailableRegions.Contains(x)).Do(serverManager.AddOrUpdateRegion); + serverManager.SetRegion(defaultRegion); + SetServerName(defaultRegion.Name); + } private static IRegionInfo CreateHttp(string ip, string name, ushort port, bool ishttps) { @@ -109,4 +103,5 @@ private static IRegionInfo CreateHttp(string ip, string name, ushort port, bool name = StringHelper.ColorString(color, name); return new StaticHttpRegionInfo(name, (StringNames)1003, ip, ServerInfo).Cast(); } +#endif } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager.cs deleted file mode 100644 index b883e90..0000000 --- a/FinalSuspect/Modules/Core/Plugin/RegistryManager.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System.IO; -using Microsoft.Win32; - -namespace FinalSuspect.Modules.Core.Plugin; - -# pragma warning disable CA1416 -public static class RegistryManager -{ - private static RegistryKey Keys - { - get - { - var getKey = SoftwareKeys.OpenSubKey("AU-FinalSuspect", true); - if (getKey != null) return getKey; - Info("Create FinalSuspect Registry Key", "Registry Manager"); - return SoftwareKeys.CreateSubKey("AU-FinalSuspect", true); - } - } - - public static string LastStartVersion - { - get => Keys.GetValue("Last launched version")?.ToString() ?? ""; - set => Keys.SetValue("Last launched version", value); - } - - private static RegistryKey SoftwareKeys => Registry.CurrentUser.OpenSubKey("Software", true); - - public static void Init() - { - if (Keys == null) - { - Error("Create Registry Failed", "Registry Manager"); - return; - } - - Keys.SetValue("Path", Path.GetFullPath("./")); - - List FoldersNFileToDel = []; - - Info("上次启动的FinalSuspect版本:" + LastStartVersion, "Registry Manager"); - FoldersNFileToDel.Add("./Final Suspect_Data/Sounds"); - FoldersNFileToDel.Add("./Final Suspect_Data/ModNews"); - FoldersNFileToDel.DoIf(Directory.Exists, p => - { - Warn("Delete Useless Directory:" + p, "Registry Manager"); - Directory.Delete(p, true); - }); - FoldersNFileToDel.DoIf(File.Exists, p => - { - Warn("Delete Useless File:" + p, "Registry Manager"); - File.Delete(p); - }); - } -} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs new file mode 100644 index 0000000..d85181e --- /dev/null +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs @@ -0,0 +1,79 @@ +#if Android +using System; +using UnityEngine; + +namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; + +public class AndroidPreferenceStore : IPreferenceStore +{ + private const string Prefix = "FS_"; + + + public string GetString(string key, string defaultValue = "") + { + try + { + var playerPrefsKey = Prefix + key; + return PlayerPrefs.HasKey(playerPrefsKey) ? PlayerPrefs.GetString(playerPrefsKey, defaultValue) : ""; + } + catch (Exception e) + { + Error($"[AndroidPreferenceStore] 读取偏好设置失败 {key}: {e.Message}", "Registry Manager"); + return defaultValue; + } + } + + public void SetString(string key, string value) + { + try + { + var playerPrefsKey = Prefix + key; + PlayerPrefs.SetString(playerPrefsKey, value); + PlayerPrefs.Save(); + } + catch (Exception e) + { + Error($"[AndroidPreferenceStore] 设置偏好设置失败 {key}: {e.Message}", "Registry Manager"); + } + } + + public void Init() + { + try + { + Info("[AndroidPreferenceStore] Android偏好存储初始化完成", "Registry Manager"); + } + catch (Exception e) + { + Error($"[AndroidPreferenceStore] 初始化失败: {e.Message}", "Registry Manager"); + } + } + + public bool ContainsKey(string key) + { + try + { + return PlayerPrefs.HasKey(Prefix + key); + } + catch (Exception e) + { + Error($"[AndroidPreferenceStore] 检查键存在失败 {key}: {e.Message}", "Registry Manager"); + return false; + } + } + + public void DeleteKey(string key) + { + try + { + PlayerPrefs.DeleteKey(Prefix + key); + PlayerPrefs.Save(); + } + catch (Exception e) + { + Error($"[AndroidPreferenceStore] 删除键失败 {key}: {e.Message}", "Registry Manager"); + } + } +} + +#endif \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/IPreferenceStore.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/IPreferenceStore.cs new file mode 100644 index 0000000..d244d5d --- /dev/null +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/IPreferenceStore.cs @@ -0,0 +1,10 @@ +namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; + +public interface IPreferenceStore +{ + string GetString(string key, string defaultValue = ""); + void SetString(string key, string value); + void Init(); + bool ContainsKey(string key); + void DeleteKey(string key); +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs new file mode 100644 index 0000000..135ffed --- /dev/null +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs @@ -0,0 +1,73 @@ +using System; +using System.IO; + +namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; + +public static class RegistryManager +{ + private static IPreferenceStore PreferenceStore + { + get + { +#if Windows + return new WindowsPreferenceStore(); +#elif Android + return new AndroidPreferenceStore(); +#endif + } + } + + public static string LastStartVersion + { + get => PreferenceStore.GetString("Last launched version"); + set => PreferenceStore.SetString("Last launched version", value); + } + + public static void Init() + { + try + { + PreferenceStore.Init(); + + Info("上次启动的FinalSuspect版本:" + LastStartVersion, "Registry Manager"); + + PerformCleanup(); + + Info("RegistryManager 初始化完成", "Registry Manager"); + } + catch (Exception e) + { + Error($"RegistryManager 初始化失败: {e.Message}", "Registry Manager"); + } + } + + private static void PerformCleanup() + { + var itemsToDelete = new List + { + "./Final Suspect_Data/Sounds", + "./Final Suspect_Data/ModNews" + }; + + foreach (var item in itemsToDelete) + { + try + { + if (Directory.Exists(item)) + { + Directory.Delete(item, true); + Warn("删除无用目录: " + item, "Registry Manager"); + } + else if (File.Exists(item)) + { + File.Delete(item); + Warn("删除无用文件: " + item, "Registry Manager"); + } + } + catch (Exception e) + { + Warn($"删除失败 {item}: {e.Message}", "Registry Manager"); + } + } + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs new file mode 100644 index 0000000..2b3a9ba --- /dev/null +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs @@ -0,0 +1,94 @@ +#if Windows +#pragma warning disable CA1416 +using System; +using Microsoft.Win32; + +namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; + +public class WindowsPreferenceStore : IPreferenceStore +{ + public string GetString(string key, string defaultValue = "") + { + try + { + using var registryKey = GetRegistryKey(false); + return registryKey?.GetValue(key)?.ToString() ?? defaultValue; + } + catch (Exception e) + { + Error($"[WindowsPreferenceStore] 读取注册表值失败 {key}: {e.Message}", "Registry Manager"); + return defaultValue; + } + } + + public void SetString(string key, string value) + { + try + { + using var registryKey = GetRegistryKey(); + registryKey?.SetValue(key, value); + } + catch (Exception e) + { + Error($"[WindowsPreferenceStore] 设置注册表值失败 {key}: {e.Message}", "Registry Manager"); + } + } + + public void Init() + { + try + { + SetString("Path", System.IO.Path.GetFullPath("./")); + Info("[WindowsPreferenceStore] 注册表初始化完成", "Registry Manager"); + } + catch (Exception e) + { + Error($"[WindowsPreferenceStore] 初始化失败: {e.Message}", "Registry Manager"); + } + } + + public bool ContainsKey(string key) + { + try + { + using var registryKey = GetRegistryKey(false); + return registryKey?.GetValue(key) != null; + } + catch (Exception e) + { + Error($"[WindowsPreferenceStore] 检查键存在失败 {key}: {e.Message}", "Registry Manager"); + return false; + } + } + + public void DeleteKey(string key) + { + try + { + using var registryKey = GetRegistryKey(); + registryKey?.DeleteValue(key, false); + } + catch (Exception e) + { + Error($"[WindowsPreferenceStore] 删除键失败 {key}: {e.Message}", "Registry Manager"); + } + } + + private static RegistryKey GetRegistryKey(bool writable = true) + { + try + { + var softwareKey = Registry.CurrentUser.OpenSubKey("Software", writable); + + var key = softwareKey?.OpenSubKey("AU-FinalSuspect", writable); + return key ?? softwareKey?.CreateSubKey("AU-FinalSuspect", writable); + } + catch (Exception e) + { + Error($"[WindowsPreferenceStore] 获取注册表键失败: {e.Message}", "Registry Manager"); + return null; + } + } +} +#pragma warning restore CA1416 +#endif \ No newline at end of file diff --git a/FinalSuspect/Modules/Resources/Downloader.cs b/FinalSuspect/Modules/Resources/Downloader.cs index 7b70263..e1232dc 100644 --- a/FinalSuspect/Modules/Resources/Downloader.cs +++ b/FinalSuspect/Modules/Resources/Downloader.cs @@ -6,7 +6,6 @@ namespace FinalSuspect.Modules.Resources; -// 来源:Town Of Next public class HttpClientDownloadWithProgress(string downloadUrl, string destinationFilePath) : IDisposable { public delegate void ProgressChangedHandler(long? totalFileSize, long totalBytesDownloaded, @@ -17,43 +16,105 @@ public delegate void ProgressChangedHandler(long? totalFileSize, long totalBytes public void Dispose() { _httpClient?.Dispose(); + GC.SuppressFinalize(this); } public event ProgressChangedHandler ProgressChanged; public async Task StartDownload() { - ServicePointManager.SecurityProtocol = - SecurityProtocolType.Tls12 | SecurityProtocolType.Tls13; + try + { + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 +#if Windows + | SecurityProtocolType.Tls13 +#endif + ; + + var handler = CreateHttpClientHandler(); + + _httpClient = new HttpClient(handler) + { + Timeout = TimeSpan.FromSeconds(45) + }; + + ConfigureRequestHeaders(); + + Info($"开始下载: {downloadUrl}", "Downloader"); + + using var response = await _httpClient.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead); + await DownloadFileFromHttpResponseMessage(response); + } + catch (Exception ex) + { + Error($"下载启动失败: {ex.Message}", "Downloader"); + if (ex.InnerException != null) + { + Error($"内部异常: {ex.InnerException.Message}", "Downloader"); + } + throw; + } + } + + private static HttpClientHandler CreateHttpClientHandler() + { var handler = new HttpClientHandler { AllowAutoRedirect = true, - UseDefaultCredentials = true, - Proxy = null, - AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate + AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate, + UseCookies = false, + CheckCertificateRevocationList = false }; - _httpClient = new HttpClient(handler) + // Android 特定的 SSL 配置 + ConfigureAndroidSSL(handler); + + return handler; + } + + private static void ConfigureAndroidSSL(HttpClientHandler handler) + { + handler.ServerCertificateCustomValidationCallback = (_, cert, _, sslPolicyErrors) => { - Timeout = TimeSpan.FromSeconds(30) + Info($"SSL 验证: {sslPolicyErrors}", "Downloader"); + if (cert == null) return true; + Info($"证书主题: {cert.Subject}", "Downloader"); + Info($"证书颁发者: {cert.Issuer}", "Downloader"); + Info($"证书有效期: {cert.GetEffectiveDateString()} - {cert.GetExpirationDateString()}", "Downloader"); + return true; }; + } - // 浏览器级请求头, 完全防止403 + private void ConfigureRequestHeaders() + { + // 清除可能存在的默认头 + _httpClient.DefaultRequestHeaders.Clear(); + + // 设置移动设备 User-Agent _httpClient.DefaultRequestHeaders.UserAgent.ParseAdd( - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + + "Mozilla/5.0 (Linux; Android 15; Mobile) " + "AppleWebKit/537.36 (KHTML, like Gecko) " + - "Chrome/127.0.0.0 Safari/537.36"); + "Chrome/120.0.0.0 Mobile Safari/537.36"); + // 添加常用请求头 _httpClient.DefaultRequestHeaders.Add("Accept", - "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"); + "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8"); _httpClient.DefaultRequestHeaders.Add("Accept-Language", "en-US,en;q=0.9"); _httpClient.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br"); _httpClient.DefaultRequestHeaders.Add("Cache-Control", "no-cache"); _httpClient.DefaultRequestHeaders.Add("Pragma", "no-cache"); - using var response = await _httpClient.GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead); - await DownloadFileFromHttpResponseMessage(response); + // 添加更多兼容性头 + _httpClient.DefaultRequestHeaders.Add("sec-ch-ua", + "\"Not_A Brand\";v=\"8\", \"Chromium\";v=\"120\", \"Google Chrome\";v=\"120\""); + _httpClient.DefaultRequestHeaders.Add("sec-ch-ua-mobile", "?1"); + _httpClient.DefaultRequestHeaders.Add("sec-ch-ua-platform", "\"Android\""); + _httpClient.DefaultRequestHeaders.Add("sec-fetch-site", "none"); + _httpClient.DefaultRequestHeaders.Add("sec-fetch-mode", "navigate"); + _httpClient.DefaultRequestHeaders.Add("sec-fetch-user", "?1"); + _httpClient.DefaultRequestHeaders.Add("sec-fetch-dest", "document"); + _httpClient.DefaultRequestHeaders.Add("upgrade-insecure-requests", "1"); } private async Task DownloadFileFromHttpResponseMessage(HttpResponseMessage response) @@ -61,6 +122,7 @@ private async Task DownloadFileFromHttpResponseMessage(HttpResponseMessage respo response.EnsureSuccessStatusCode(); var totalBytes = response.Content.Headers.ContentLength; + Info($"文件大小: {totalBytes} 字节", "Downloader"); await using var contentStream = await response.Content.ReadAsStreamAsync(); await ProcessContentStream(totalBytes, contentStream); @@ -73,9 +135,18 @@ private async Task ProcessContentStream(long? totalDownloadSize, Stream contentS var buffer = new byte[8192]; var isMoreToRead = true; - await using var fileStream = new FileStream(destinationFilePath, FileMode.Create, FileAccess.Write, - FileShare.None, - 8192, true); + // 确保目标目录存在 + var directory = Path.GetDirectoryName(destinationFilePath); + if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory)) + { + Directory.CreateDirectory(directory); + } + + await using var fileStream = new FileStream(destinationFilePath, + FileMode.Create, FileAccess.Write, FileShare.None, 8192, true); + + var lastProgressUpdate = DateTime.Now; + do { var bytesRead = await contentStream.ReadAsync(buffer); @@ -91,20 +162,27 @@ private async Task ProcessContentStream(long? totalDownloadSize, Stream contentS totalBytesRead += bytesRead; readCount += 1; - if (readCount % 100 == 0) - TriggerProgressChanged(totalDownloadSize, totalBytesRead); + var now = DateTime.Now; + if (readCount % 50 != 0 && !((now - lastProgressUpdate).TotalMilliseconds > 200)) continue; + TriggerProgressChanged(totalDownloadSize, totalBytesRead); + lastProgressUpdate = now; } while (isMoreToRead); + + TriggerProgressChanged(totalDownloadSize, totalBytesRead); + Info($"下载完成: {totalBytesRead} 字节", "Downloader"); } private void TriggerProgressChanged(long? totalDownloadSize, long totalBytesRead) { - if (ProgressChanged == null) - return; + ProgressChanged?.Invoke(totalDownloadSize, totalBytesRead, + CalculateProgressPercentage(totalDownloadSize, totalBytesRead)); + } - double? progressPercentage = null; - if (totalDownloadSize.HasValue) - progressPercentage = Math.Round((double)totalBytesRead / totalDownloadSize.Value * 100, 2); + private static double? CalculateProgressPercentage(long? totalDownloadSize, long totalBytesRead) + { + if (totalDownloadSize is not > 0) + return null; - ProgressChanged(totalDownloadSize, totalBytesRead, progressPercentage); + return Math.Round((double)totalBytesRead / totalDownloadSize.Value * 100, 2); } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Resources/PathManager.cs b/FinalSuspect/Modules/Resources/PathManager.cs index f96d2ef..18ee009 100644 --- a/FinalSuspect/Modules/Resources/PathManager.cs +++ b/FinalSuspect/Modules/Resources/PathManager.cs @@ -1,19 +1,35 @@ -#if DEBUG using System; -#endif using System.IO; using FinalSuspect.Attributes; +using UnityEngine; +#if Windows +using System.Linq; +#endif namespace FinalSuspect.Modules.Resources; public static class PathManager { +#if Android + private static readonly string LocalPath_Data = Application.persistentDataPath + "/FinalSuspect_Data/"; + public static readonly string LANGUAGE_FOLDER_NAME = LocalPath_Data + "Language"; + private static readonly string DependsSavePath = LocalPath_Data + "Depend"; + public static readonly string BAN_LIST_PATH = LocalPath_Data + "BanList.txt"; +#else private const string LocalPath_Data = "Final Suspect_Data/"; public const string LANGUAGE_FOLDER_NAME = LocalPath_Data + "Language"; private const string DependsSavePath = "BepInEx/core/"; public const string BAN_LIST_PATH = LocalPath_Data + "BanList.txt"; +#endif + + +#if Android + public const string DownloadFileTempPath = "BepInEx/plugins/FinalSuspect.dll.temp"; +#else public const string DownloadFileTempPath = "BepInEx/plugins/FinalSuspect.dll.temp"; +#endif + // 下载URL保持不变 public const string DownloadUrl_Github = "https://github.com/Slok7565/FinalSuspect/releases/latest/download/FinalSuspect.dll"; @@ -29,18 +45,27 @@ public static class PathManager public static string DownloadUrl_Gitee = "https://gitee.com/LezaiYa/FinalSuspectAssets/releases/download/v{showVer}/FinalSuspect.dll"; - private static IReadOnlyList URLs => new List + private static IReadOnlyList URLs { - "https://raw.githubusercontent.com/Slok7565/FinalSuspect_Assets/FinalAsset/", - "https://raw.githubusercontent.com/Slok7565/FinalSuspect/FinalSus/", - "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect/raw/FinalSus/", - "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect_Assets/raw/FinalAsset/", - "https://gitee.com/LezaiYa/FinalSuspectAssets/raw/main/", - "https://dlhk.fangkuai.fun/FinalSuspect/", -#if DEBUG - $"file:///{Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))}/", + get + { + var urls = new List + { + "https://raw.githubusercontent.com/Slok7565/FinalSuspect_Assets/FinalAsset/", + "https://raw.githubusercontent.com/Slok7565/FinalSuspect/FinalSus/", + "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect/raw/FinalSus/", + "https://hub.gitmirror.com/https://github.com/Slok7565/FinalSuspect_Assets/raw/FinalAsset/", + "https://gitee.com/LezaiYa/FinalSuspectAssets/raw/main/", + "https://dlhk.fangkuai.fun/FinalSuspect/", + }; + +#if DEBUG && Windows + // 只有在 Windows 调试模式下才添加桌面路径 + urls.Add($"file:///{Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop))}/"); #endif - }; + return urls.AsReadOnly(); + } + } public static string GetFile(FileType fileType, RemoteType remoteType, string file) { @@ -121,24 +146,53 @@ public static void InitializePaths() CheckAndDeleteSLK(DependsSavePath); } - private static void CheckAndCreate(string path, bool hidden = true, bool isFile = false) + private static void CheckAndCreate( + string path, + bool hidden = true, + bool isFile = false) { if (path == null) return; switch (isFile) { case true when !File.Exists(path): - File.Create(path); + try + { + File.Create(path).Close(); + } + catch (Exception e) + { + Error($"创建文件失败: {path}, 错误: {e.Message}", "PathManager"); + } + break; case false when !Directory.Exists(path): - Directory.CreateDirectory(path); + try + { + Directory.CreateDirectory(path); + } + catch (Exception e) + { + Error($"创建目录失败: {path}, 错误: {e.Message}", "PathManager"); + } + break; } - var attributes = File.GetAttributes(path); - File.SetAttributes(path, hidden - ? attributes | FileAttributes.Hidden - : attributes & ~FileAttributes.Hidden); +#if Windows + // 只在 Windows 上设置隐藏属性 + try + { + var attributes = File.GetAttributes(path); + File.SetAttributes(path, hidden + ? attributes | FileAttributes.Hidden + : attributes & ~FileAttributes.Hidden); + } + catch (Exception e) + { + Warn($"设置文件属性失败: {path}, 错误: {e.Message}", "PathManager"); + } +#endif } private static void CheckAndDeleteSLK(string targetFolder) @@ -148,21 +202,41 @@ private static void CheckAndDeleteSLK(string targetFolder) { var filesToDelete = Directory.GetFiles(targetFolder, "*.slk", SearchOption.AllDirectories); - foreach (var file in filesToDelete) File.Delete(file); + foreach (var file in filesToDelete) + { + try + { + File.Delete(file); + } + catch (Exception e) + { + Warn($"删除文件失败: {file}, 错误: {e.Message}", "PathManager"); + } + } } - catch + catch (Exception e) { - /* ignored */ + Warn($"删除SLK文件时出错: {e.Message}", "PathManager"); } } public static IReadOnlyList GetInfoFileUrlList(bool allowDesktop = false) { - var list = URLs.ToList(); - if (!allowDesktop && DebugModeManager.IsDebugMode) - list.RemoveAt(6); - if (IsChineseUser) list.Reverse(); - return list; + var list = new List(URLs); + +#if Android + allowDesktop = false; +#endif + + if (!allowDesktop) + { + list.RemoveAll(url => url.StartsWith("file://")); + } + + if (IsChineseUser) + list.Reverse(); + + return list.AsReadOnly(); } } diff --git a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs index a6cb297..51ad109 100644 --- a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs +++ b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs @@ -107,6 +107,12 @@ private static async Task DownloadInternal( continue; } } +#if Android + if (fileType is FileType.Depends) + { + File.Copy(filePath, "/data/data/dev.allofus.starlight/files/BepInEx/core/"+ currentFile); + } +#endif Warn($"Succeed in {url}", "Download Resources"); success = true; diff --git a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs index 03a47f2..4035512 100644 --- a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs @@ -18,9 +18,14 @@ public static void CoBegin_Prefix() Info("Game Start", "IntroCutscene"); } - [HarmonyPatch(typeof(IntroCutscene._ShowRole_d__41), nameof(IntroCutscene._ShowRole_d__41.MoveNext))] - [HarmonyPostfix] +#if Windows + [HarmonyPatch(typeof(IntroCutscene._ShowRole_d__41), nameof(IntroCutscene._ShowRole_d__41.MoveNext)), + HarmonyPostfix] public static void Postfix(IntroCutscene._ShowRole_d__41 __instance, ref bool __result) +#elif Android + [HarmonyPatch(typeof(IntroCutscene._ShowRole_d__40), nameof(IntroCutscene._ShowRole_d__40.MoveNext)), HarmonyPostfix] + public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __result) +#endif { if (!Main.EnableFinalSuspect.Value) return; var intro = __instance.__4__this; diff --git a/FinalSuspect/Patches/System/CredentialsPatch.cs b/FinalSuspect/Patches/System/CredentialsPatch.cs index 4a1ec25..dad0c63 100644 --- a/FinalSuspect/Patches/System/CredentialsPatch.cs +++ b/FinalSuspect/Patches/System/CredentialsPatch.cs @@ -2,6 +2,7 @@ using FinalSuspect.ClientActions; using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientActions.FeatureItems.NameTag; using FinalSuspect.Helpers; using FinalSuspect.Modules.Resources; using FinalSuspect.Patches.Game_Vanilla; @@ -208,7 +209,7 @@ public static void CreateVisitText(VersionShower __instance) else _instance = __instance; - VisitText = Object.Instantiate(__instance.text); + VisitText = Object.Instantiate(__instance.text, OVersionShower.transform.parent); VisitText.name = "FinalSuspect VisitText"; VisitText.alignment = TextAlignmentOptions.Left; VisitText.text = VersionChecker.IsChecked @@ -220,12 +221,13 @@ public static void CreateVisitText(VersionShower __instance) __instance.text.alignment = TextAlignmentOptions.Left; var ap1 = OVersionShower.GetComponent(); ap1.Alignment = AspectPosition.EdgeAlignments.LeftBottom; - ap1.DistanceFromEdge = new Vector3(0.4f, -0.3f); + ap1.DistanceFromEdge = new Vector3(0.5f, -0.3f); ap1.updateAlways = true; + VisitText.alignment = TextAlignmentOptions.Left; var ap2 = VisitText.gameObject.AddComponent(); ap2.Alignment = AspectPosition.EdgeAlignments.LeftBottom; - ap2.DistanceFromEdge = new Vector3(1.4f, 0.1f); + ap2.DistanceFromEdge = new Vector3(0.5f, -0.45f); ap2.updateAlways = true; } } @@ -288,14 +290,14 @@ public static void Postfix(MainMenuManager __instance) { transform = { - position = new Vector3(0, 0, 520f) + position = new Vector3(0, 0, 520f), + localScale = new Vector3(Mathf.Max(GetResolutionOffset(), 1), Mathf.Max(GetResolutionOffset(), 1), 1) } }; var bgRenderer = FinalSuspect_Background.AddComponent(); bgRenderer.sprite = style.Sprite; - if (!(Ambience = GameObject.Find("Ambience"))) return; if (!(Starfield = Ambience.transform.FindChild("starfield").gameObject)) return; Starfield.SetActive(style.StarFieldActive); @@ -314,7 +316,7 @@ public static void Postfix(MainMenuManager __instance) if (!(RightPanel = GameObject.Find("RightPanel"))) return; var rightPanelAP = RightPanel.GetComponent(); if (rightPanelAP) Object.Destroy(rightPanelAP); - RightPanel.transform.localPosition = RightPanelOp + new Vector3(10f, 0f, 0f); + RightPanel.transform.localPosition = RightPanelOp + new Vector3(20f, 0f, 0f); RightPanel.GetComponent().color = new Color(1f, 0.78f, 0.9f, 1f); CloseRightButton = new GameObject("CloseRightPanelButton"); @@ -396,8 +398,6 @@ public static void Prefix(ModManager __instance) { var last = _lastScene; _lastScene = SceneManager.GetActiveScene().name; - Test(_lastScene); - Test(SceneManager.GetActiveScene().name); if (last is "SplashIntro") return; OnSceneChange(_lastScene); } @@ -457,6 +457,8 @@ public static void Postfix(int width, int height) Tint.transform.localPosition = new Vector3(-0.0824f * offset, 0.0513f, Tint.transform.localPosition.z); Sizer.transform.localPosition = new Vector3(-4.0f * offset, 1.4f, -1.0f); + FinalSuspect_Background.transform.localScale = new Vector3(Mathf.Max(GetResolutionOffset(), 1), + Mathf.Max(GetResolutionOffset(), 1), 1); var mainButtons = GameObject.Find("Main Buttons"); mainButtons.transform.position = new Vector3(-3.4f * offset, mainButtons.transform.position.y, mainButtons.transform.position.z); @@ -480,6 +482,13 @@ public static void Postfix(int width, int height) CloseRightButton.transform.localPosition = new Vector3(-4.78f * GetResolutionOffset(), 1.3f, 1f); + Object.Destroy(NameTagEditMenu.Menu); + NameTagEditMenu.Menu = null; + NameTagEditMenu.Init(); + + Object.Destroy(NameTagNewWindow.Window); + NameTagNewWindow.Window = null; + NameTagNewWindow.Init(); }, 0.01f, "RefreshMenu"); } } \ No newline at end of file diff --git a/FinalSuspect/Patches/System/LoadPatch.cs b/FinalSuspect/Patches/System/LoadPatch.cs index f77948a..9caa952 100644 --- a/FinalSuspect/Patches/System/LoadPatch.cs +++ b/FinalSuspect/Patches/System/LoadPatch.cs @@ -5,6 +5,7 @@ using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; using FinalSuspect.ClientActions.FeatureItems.MyMusic; using FinalSuspect.Helpers; +using FinalSuspect.Modules.Core.Plugin.RegistryManager; using FinalSuspect.Modules.Resources; using TMPro; using UnityEngine; @@ -104,7 +105,6 @@ private static IEnumerator HandleFirstLaunch() { var logoAnimator = GameObject.Find("LogoAnimator"); logoAnimator.SetActive(false); - CheckForListResources(ref ResourcesHelper.PreReadyRemoteImageList, FileType.Images); CheckForListResources(ref ResourcesHelper.PreReadyRemoteMusicList, FileType.Musics); yield return DownloadResources(ResourcesHelper.PreReadyRemoteImageList, FileType.Images, @@ -129,6 +129,7 @@ private static IEnumerator HandleCoreLoadingProcess(SplashManager instance) if (!fastLaunchMode) Main.OfflineMode.Value = false; + yield return fastLaunchMode ? HandleFastLaunchMode() : HandleNormalBoot(); yield return LoadEssentialResources(instance); @@ -157,7 +158,9 @@ private static bool CheckFastLaunchModeCondition() break; } - return Main.FastLaunchMode.Value && !_reloadLanguage; + CheckForListResources(ref ResourcesHelper.RemoteDependList, FileType.Depends); + + return Main.FastLaunchMode.Value && !_reloadLanguage && ResourcesHelper.RemoteDependList.Count == 0; } #endregion @@ -409,7 +412,15 @@ private static void CheckForListResources(ref List targetList, FileType if (fileType is FileType.Musics) AudioManager.ConvertExtension(ref path); if (File.Exists(path)) + { targetList.Remove(resource); +#if Android + if (fileType is FileType.Depends) + { + File.Copy(path, "/data/data/dev.allofus.starlight/files/BepInEx/core/"+ resource); + } +#endif + } else Warn($"File does not exist: {GetLocalFilePath(fileType, resource)}", "Check"); } diff --git a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs index f17a2e4..446cfa2 100644 --- a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs +++ b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs @@ -64,20 +64,23 @@ public static void MainMenuManager_LateUpdate(MainMenuManager __instance) { CustomPopup.Update(); + var text = VersionShowerStartPatch.OVersionShower.transform.FindChild("Text_TMP").gameObject + .GetComponent().sizeDelta = new Vector2(3.9f, 0.2359f); if (!GameObject.Find("MainUI")) ShowingPanel = false; VersionShowerStartPatch.CreditTextCredential.gameObject.SetActive(!ShowingPanel && Active); - + __instance.quitButton.gameObject.SetActive(true); + GithubButton.SetActive(true); if (RightPanel) { var pos1 = RightPanel.transform.localPosition; var pos3 = new Vector3( RightPanelOp.x * GetResolutionOffset(), RightPanelOp.y, RightPanelOp.z); - var lerp1 = Vector3.Lerp(pos1, ShowingPanel ? pos3 : RightPanelOp + new Vector3(10f, 0f, 0f), + var lerp1 = Vector3.Lerp(pos1, ShowingPanel ? pos3 : RightPanelOp + new Vector3(20f, 0f, 0f), Time.deltaTime * (ShowingPanel ? 3f : 2f)); if (ShowingPanel ? RightPanel.transform.localPosition.x > pos3.x + 0.03f - : RightPanel.transform.localPosition.x < RightPanelOp.x + 9f + : RightPanel.transform.localPosition.x < RightPanelOp.x + 29f ) RightPanel.transform.localPosition = lerp1; } @@ -103,7 +106,7 @@ public static void Start_Postfix(MainMenuManager __instance) var inviteLinkName = IsChineseUser ? "QQ群" : "Discord"; var inviteLinkUrl = IsChineseUser ? Main.QQInviteUrl : Main.DiscordInviteUrl; - if (!InviteButton) InviteButton = CreatButton(inviteLinkName, () => { Application.OpenURL(inviteLinkUrl); }); + if (!InviteButton) InviteButton = CreatButton(inviteLinkName, () => { OpenUrl(inviteLinkUrl); }); InviteButton.gameObject.SetActive(true); InviteButton.name = "FinalSuspect Extra Link Button"; @@ -111,13 +114,13 @@ public static void Start_Postfix(MainMenuManager __instance) //WebsiteButton.gameObject.SetActive(true); //WebsiteButton.name = "FinalSuspect Website Button"; - if (!GithubButton) GithubButton = CreatButton("Github", () => Application.OpenURL(Main.GithubRepoUrl)); + if (!GithubButton) GithubButton = CreatButton("Github", () => OpenUrl(Main.GithubRepoUrl)); GithubButton.gameObject.SetActive(true); GithubButton.name = "FinalSuspect Github Button"; var bugLinkName = IsChineseUser ? "Bug 反馈" : "Bug Report"; var bugLinkUrl = IsChineseUser ? Main.BugReportUrl_Gitee : Main.BugReportUrl_Github; - if (!BugReportButton) BugReportButton = CreatButton(bugLinkName, () => { Application.OpenURL(bugLinkUrl); }); + if (!BugReportButton) BugReportButton = CreatButton(bugLinkName, () => { OpenUrl(bugLinkUrl); }); BugReportButton.gameObject.SetActive(true); BugReportButton.name = "FinalSuspect Bug Report Button"; PlayButton = __instance.playButton.gameObject; @@ -148,6 +151,15 @@ public static void Start_Postfix(MainMenuManager __instance) Application.targetFrameRate = Main.UnlockFPS.Value ? 165 : 60; return; + void OpenUrl(string url) + { +#if Android + OpenURLAndroid(url); +#elif Windows + Application.OpenURL(url); +#endif + } + GameObject CreatButton(string text, Action action) { col++; @@ -173,4 +185,47 @@ GameObject CreatButton(string text, Action action) return button; } } +#if Android + private static void OpenURLAndroid(string url) + { + try + { + AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); + AndroidJavaObject currentActivity = unityPlayer.GetStatic("currentActivity"); + + // 创建 Intent + AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); + AndroidJavaObject intentObject = + new AndroidJavaObject("android.content.Intent", "android.intent.action.VIEW"); + + // 创建 URI + AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); + AndroidJavaObject uriObject = uriClass.CallStatic("parse", url); + + // 设置 Intent 的数据 + intentObject.Call("setData", uriObject); + + // 设置标志确保在新任务中打开 + int FLAG_ACTIVITY_NEW_TASK = 0x10000000; + intentObject.Call("setFlags", FLAG_ACTIVITY_NEW_TASK); + + // 启动 Activity + currentActivity.Call("startActivity", intentObject); + + // 释放资源(虽然不是必须的,但推荐) + unityPlayer.Dispose(); + currentActivity.Dispose(); + intentClass.Dispose(); + intentObject.Dispose(); + uriClass.Dispose(); + uriObject.Dispose(); + } + catch + { + // 降级到Application.OpenURL + Application.OpenURL(url); + } + } + +#endif } \ No newline at end of file diff --git a/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs b/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs index 3c46fe6..f1a4e80 100644 --- a/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs +++ b/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs @@ -7,13 +7,18 @@ public class UnityEnginePatch { public static bool Prefix([HarmonyArgument(0)] Object obj) { + bool Return; try { - return obj.name is not "LobbyInfoPane" and not "GameStartManager" || IsFreePlay || IsNotJoined; + Return = obj.name is not "LobbyInfoPane" and not "GameStartManager" || IsFreePlay || IsNotJoined; + if (obj.name is "IntroCutscene") + IntroCutsceneOnDestroyPatch.Postfix(); } catch { return true; } + + return Return; } } \ No newline at end of file diff --git a/FinalSuspect/Patches/System/PhasePatch.cs b/FinalSuspect/Patches/System/PhasePatch.cs index 0782275..8a0f463 100644 --- a/FinalSuspect/Patches/System/PhasePatch.cs +++ b/FinalSuspect/Patches/System/PhasePatch.cs @@ -79,7 +79,9 @@ public static void Postfix() } }*/ +#if Windows [HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.OnDestroy))] +#endif public static class IntroCutsceneOnDestroyPatch { public static void Postfix() diff --git a/FinalSuspect/main.cs b/FinalSuspect/main.cs index 04bfca3..8be9a1e 100644 --- a/FinalSuspect/main.cs +++ b/FinalSuspect/main.cs @@ -11,6 +11,7 @@ using FinalSuspect.Helpers; using FinalSuspect.Internal; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; +using FinalSuspect.Modules.Core.Plugin.RegistryManager; using FinalSuspect.Modules.Random; using FinalSuspect.Modules.Resources; using Il2CppInterop.Runtime.Injection; @@ -223,6 +224,7 @@ public override void Load() Harmony.PatchAll(); + if (DebugModeManager.IsDebugMode) ConsoleManager.CreateConsole(); else ConsoleManager.DetachConsole(); From 5574fb0ceb4a502dd23f35c3caf17fa150bdb367 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 3 Oct 2025 00:01:02 +0800 Subject: [PATCH 07/19] update news --- Assets/ModNews/SChinese/FS.v1.3.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index cd7880a..dfcb57b 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -31,17 +31,21 @@ ## 修正 - 修复了部分分辨率下出现UI错误的问题 +- 修复了「人满自动开始游戏」错误多次开始游戏导致游戏崩溃的问题 修复: Slok ## 优化 ## 更改 - 修改职业介绍格式 +制作: Slok, LezaiYa - 将[LezaiYa]("https://github.com/NewLezaiYa")列入**开发者** ## 新增 - 适配**Among Us v17.0.0** +制作: LezaiYa - 适配**Starlight**安装模组启动器 +制作: Slok ## 重制 From fbc3c2465fbf95c40534ae47d2e78f19f8786f8f Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 3 Oct 2025 11:00:16 +0800 Subject: [PATCH 08/19] bug fix --- .../FinalAntiCheat/Core/DllChecker.cs | 13 +++++++---- .../DataHandling/FinalAntiCheat/Core/Git.cs | 3 ++- FinalSuspect/Modules/Core/Game/Utils.cs | 14 +++++------ .../Modules/Core/Plugin/ModMainMenuManager.cs | 1 + FinalSuspect/Modules/Resources/PathManager.cs | 23 +++++++++++++++---- .../Modules/Resources/ResourcesDownloader.cs | 2 +- .../Modules/Resources/VersionChecker.cs | 8 ++++++- FinalSuspect/Patches/System/LoadPatch.cs | 2 +- .../Patches/System/MainMenuManagerPatch.cs | 19 +++++++-------- FinalSuspect/main.cs | 12 ---------- 10 files changed, 54 insertions(+), 43 deletions(-) diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs index f47fa00..6966928 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs @@ -10,7 +10,7 @@ internal static class DllChecker { internal static void Init() { - return; +#if Windows // SM的文件名是写死的 string[] suspiciousFiles = ["SickoMenu.dll", "version.dll"]; // 获取当前Dll启动目录 @@ -37,6 +37,7 @@ internal static void Init() Error($"G检测到非法文件: {fileName}!游戏将被强制终止。", "FAC"); Application.Quit(1); } +#endif } } @@ -45,9 +46,11 @@ public static class DisableOtherPlugins { public static bool Prefix([HarmonyArgument(0)] PluginInfo pluginInfo, [HarmonyArgument(1)] Assembly pluginAssembly) { - return true; - return pluginInfo.Metadata.GUID - is "com.sinai.unityexplorer" - or "cn.slok.polarnight"; + return +#if Windows + pluginInfo.Metadata.GUID is "com.sinai.unityexplorer"; +#elif Android + true; +#endif } } \ No newline at end of file diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs index 9b4472b..40721fa 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs @@ -7,7 +7,7 @@ internal static class Git { public static void Prefix(MainMenuManager __instance) { - return; +#if Windows // 获取当前Dll启动目录 var directoryPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // 针对基于BepInEx注入检测 @@ -18,5 +18,6 @@ public static void Prefix(MainMenuManager __instance) if (fileName is not "FinalSuspect.dll" and not "PolarNight.dll") Application.Quit(1); } +#endif } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index 92ffbb5..c90c5ce 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -160,10 +160,10 @@ public static long GetCurrentTimestamp() public static DirectoryInfo GetLogFolder(bool auto = false) { - var folder = Directory.CreateDirectory($"{Application.persistentDataPath}/FinalSuspect/Logs"); + var folder = Directory.CreateDirectory(FSLogOutPutPath); if (auto) { - folder = Directory.CreateDirectory($"{folder.FullName}/AutoLogs"); + folder = Directory.CreateDirectory(AutoLogOutPutPath); } return folder; @@ -178,15 +178,15 @@ public static void DumpLog(bool popup = false) OpenDirectory(filename); if (!PlayerControl.LocalPlayer) return; var t = DateTime.Now.ToString("yyyy-MM-dd_HH.mm.ss"); + var msg = string.Format(GetString("Message.DumpfileSaved"), + $"FinalSuspect - v{Main.DisplayedVersion}-{t}.log"); if (popup) { - HudManager.Instance.ShowPopUp(string.Format(GetString("Message.DumpfileSaved"), - $"FinalSuspect - v{Main.DisplayedVersion}-{t}.log")); + HudManager.Instance.ShowPopUp(msg); } else { - AddChatMessage(string.Format(GetString("Message.DumpfileSaved"), - $"FinalSuspect - v{Main.DisplayedVersion}-{t}.log")); + AddChatMessage(msg); } } catch (Exception ex) @@ -244,7 +244,7 @@ public static string CopyLog(string path) Directory.CreateDirectory(Path.GetDirectoryName(f) ?? string.Empty); } - FileInfo file = new($"{Environment.CurrentDirectory}/BepInEx/LogOutput.log"); + FileInfo file = new(BepInLogOutPutPath); if (!file.Exists) { return null; diff --git a/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs b/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs index f25bc09..effd894 100644 --- a/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs @@ -7,6 +7,7 @@ public static class ModMainMenuManager public static MainMenuManager Instance; public static GameObject InviteButton; + public static GameObject WebsiteButton; public static GameObject GithubButton; public static GameObject BugReportButton; public static GameObject UpdateButton; diff --git a/FinalSuspect/Modules/Resources/PathManager.cs b/FinalSuspect/Modules/Resources/PathManager.cs index 18ee009..ada49da 100644 --- a/FinalSuspect/Modules/Resources/PathManager.cs +++ b/FinalSuspect/Modules/Resources/PathManager.cs @@ -2,9 +2,6 @@ using System.IO; using FinalSuspect.Attributes; using UnityEngine; -#if Windows -using System.Linq; -#endif namespace FinalSuspect.Modules.Resources; @@ -15,6 +12,7 @@ public static class PathManager public static readonly string LANGUAGE_FOLDER_NAME = LocalPath_Data + "Language"; private static readonly string DependsSavePath = LocalPath_Data + "Depend"; public static readonly string BAN_LIST_PATH = LocalPath_Data + "BanList.txt"; + public const string BepInExPath = "/data/data/dev.allofus.starlight/files/BepInEx/" #else private const string LocalPath_Data = "Final Suspect_Data/"; public const string LANGUAGE_FOLDER_NAME = LocalPath_Data + "Language"; @@ -24,11 +22,17 @@ public static class PathManager #if Android - public const string DownloadFileTempPath = "BepInEx/plugins/FinalSuspect.dll.temp"; + public static readonly string BepInLogOutPutPath = BepInExPath + "LogOutput.log"; + public static readonly string BepInCorePath = BepInExPath + "core"; + public static readonly string BepInLogOutPutPath = BepInExPath + "/BepInEx/LogOutput.log"; #else public const string DownloadFileTempPath = "BepInEx/plugins/FinalSuspect.dll.temp"; + public static readonly string BepInLogOutPutPath = $"{Environment.CurrentDirectory}/BepInEx/LogOutput.log"; #endif + public static readonly string FSLogOutPutPath = $"{Application.persistentDataPath}/FinalSuspect/Logs"; + public static readonly string AutoLogOutPutPath = FSLogOutPutPath + "/AutoLogs"; + // 下载URL保持不变 public const string DownloadUrl_Github = "https://github.com/Slok7565/FinalSuspect/releases/latest/download/FinalSuspect.dll"; @@ -67,6 +71,17 @@ private static IReadOnlyList URLs } } + public const string QQInviteUrl = "https://qm.qq.com/q/ZA7Lnjz3SC"; + public const string DiscordInviteUrl = "https://discord.gg/kz787Zg7h8/"; + public const string WebsiteUrl = "https://finalsuspect.pages.dev/"; + public const string GithubRepoUrl = "https://github.com/Slok7565/FinalSuspect/"; + + public const string BugReportUrl_Github = + "https://github.com/Slok7565/FinalSuspect/issues/new?template=BugReport_en.yaml"; + + public const string BugReportUrl_Gitee = + "https://gitee.com/LezaiYa/FinalSuspectAssets/issues/new?template=BugReport.yaml"; + public static string GetFile(FileType fileType, RemoteType remoteType, string file) { return GetRemoteUrl(fileType, remoteType) + file; diff --git a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs index 51ad109..7f035ee 100644 --- a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs +++ b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs @@ -110,7 +110,7 @@ private static async Task DownloadInternal( #if Android if (fileType is FileType.Depends) { - File.Copy(filePath, "/data/data/dev.allofus.starlight/files/BepInEx/core/"+ currentFile); + File.Copy(filePath, BepInCorePath + currentFile); } #endif diff --git a/FinalSuspect/Modules/Resources/VersionChecker.cs b/FinalSuspect/Modules/Resources/VersionChecker.cs index 46edc13..2486f69 100644 --- a/FinalSuspect/Modules/Resources/VersionChecker.cs +++ b/FinalSuspect/Modules/Resources/VersionChecker.cs @@ -139,7 +139,13 @@ private static async Task GetVersionInfo(string url) _verHead = new string(data["verHead"]?.ToString()); - CanUpdate = bool.Parse(new string(data["CanUpdate"]?.ToString())); + CanUpdate = +#if Windows + bool.Parse(new string(data["CanUpdate"]?.ToString())); +#elif Android + false; +#endif + _verDate = new string(data["verDate"]?.ToString()); diff --git a/FinalSuspect/Patches/System/LoadPatch.cs b/FinalSuspect/Patches/System/LoadPatch.cs index 9caa952..6a5d117 100644 --- a/FinalSuspect/Patches/System/LoadPatch.cs +++ b/FinalSuspect/Patches/System/LoadPatch.cs @@ -417,7 +417,7 @@ private static void CheckForListResources(ref List targetList, FileType #if Android if (fileType is FileType.Depends) { - File.Copy(path, "/data/data/dev.allofus.starlight/files/BepInEx/core/"+ resource); + File.Copy(path, BepInCorePath+ resource); } #endif } diff --git a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs index 446cfa2..7cf33d5 100644 --- a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs +++ b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs @@ -14,8 +14,6 @@ namespace FinalSuspect.Patches.System; [HarmonyPatch] public class MainMenuManagerPatch { - //public static GameObject WebsiteButton; - [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenGameModeMenu))] [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenAccountMenu))] [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenCredits))] @@ -63,9 +61,8 @@ public static void SetOnline_Postfix() public static void MainMenuManager_LateUpdate(MainMenuManager __instance) { CustomPopup.Update(); - - var text = VersionShowerStartPatch.OVersionShower.transform.FindChild("Text_TMP").gameObject - .GetComponent().sizeDelta = new Vector2(3.9f, 0.2359f); + VersionShowerStartPatch.OVersionShower.transform.FindChild("Text_TMP").gameObject.GetComponent() + .sizeDelta = new Vector2(3.9f, 0.2359f); if (!GameObject.Find("MainUI")) ShowingPanel = false; VersionShowerStartPatch.CreditTextCredential.gameObject.SetActive(!ShowingPanel && Active); __instance.quitButton.gameObject.SetActive(true); @@ -104,22 +101,22 @@ public static void Start_Postfix(MainMenuManager __instance) var col = 0; var inviteLinkName = IsChineseUser ? "QQ群" : "Discord"; - var inviteLinkUrl = IsChineseUser ? Main.QQInviteUrl : Main.DiscordInviteUrl; + var inviteLinkUrl = IsChineseUser ? QQInviteUrl : DiscordInviteUrl; if (!InviteButton) InviteButton = CreatButton(inviteLinkName, () => { OpenUrl(inviteLinkUrl); }); InviteButton.gameObject.SetActive(true); InviteButton.name = "FinalSuspect Extra Link Button"; - //if (WebsiteButton == null) WebsiteButton = CreatButton(GetString("Website"), () => Application.OpenURL(Main.WebsiteUrl)); - //WebsiteButton.gameObject.SetActive(true); - //WebsiteButton.name = "FinalSuspect Website Button"; + if (WebsiteButton == null) WebsiteButton = CreatButton(GetString("Website"), () => OpenUrl(WebsiteUrl)); + WebsiteButton.gameObject.SetActive(true); + WebsiteButton.name = "FinalSuspect Website Button"; - if (!GithubButton) GithubButton = CreatButton("Github", () => OpenUrl(Main.GithubRepoUrl)); + if (!GithubButton) GithubButton = CreatButton("Github", () => OpenUrl(GithubRepoUrl)); GithubButton.gameObject.SetActive(true); GithubButton.name = "FinalSuspect Github Button"; var bugLinkName = IsChineseUser ? "Bug 反馈" : "Bug Report"; - var bugLinkUrl = IsChineseUser ? Main.BugReportUrl_Gitee : Main.BugReportUrl_Github; + var bugLinkUrl = IsChineseUser ? BugReportUrl_Gitee : BugReportUrl_Github; if (!BugReportButton) BugReportButton = CreatButton(bugLinkName, () => { OpenUrl(bugLinkUrl); }); BugReportButton.gameObject.SetActive(true); BugReportButton.name = "FinalSuspect Bug Report Button"; diff --git a/FinalSuspect/main.cs b/FinalSuspect/main.cs index 8be9a1e..9f84251 100644 --- a/FinalSuspect/main.cs +++ b/FinalSuspect/main.cs @@ -45,18 +45,6 @@ public class Main : BasePlugin private const string DisplayedVersion_Date = BuildTime.Date; - - // == 链接相关设定 / Link Config == - public const string QQInviteUrl = "https://qm.qq.com/q/ZA7Lnjz3SC"; - public const string DiscordInviteUrl = "https://discord.gg/kz787Zg7h8/"; - public const string GithubRepoUrl = "https://github.com/Slok7565/FinalSuspect/"; - - public const string BugReportUrl_Github = - "https://github.com/Slok7565/FinalSuspect/issues/new?template=BugReport_en.yaml"; - - public const string BugReportUrl_Gitee = - "https://gitee.com/LezaiYa/FinalSuspectAssets/issues/new?template=BugReport.yaml"; - public static readonly string DisplayedVersion = #if RELEASE $"{DisplayedVersion_Head}_{DisplayedVersion_Date}"; From f712a7dc7aede9130a0f1a027d999fd797407b5e Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 3 Oct 2025 13:26:10 +0800 Subject: [PATCH 09/19] Code Optimization --- Assets/ModNews/SChinese/FS.v1.3.txt | 9 +- .../ClientActionItem.cs | 2 +- .../ClientFeatureItem.cs | 2 +- .../ClientItemsPatch.cs} | 82 +++++----- .../ClientOptionItem.cs | 2 +- .../MainMenuStyle/MainMenuStyleManager.cs | 6 +- .../MainMenuStyle/MainMenuStylePanel.cs | 13 +- .../FeatureItems/ModUnloaderScreen.cs | 4 +- .../FeatureItems/MyMusic/AudioLoader.cs | 4 +- .../FeatureItems/MyMusic/AudioManager.cs | 2 +- .../FeatureItems/MyMusic/AudioPlayer.cs | 10 +- .../FeatureItems/MyMusic/MyMusicPanel.cs | 7 +- .../FeatureItems/NameTag/NameTagEditMenu.cs | 6 +- .../FeatureItems/NameTag/NameTagManager.cs | 2 +- .../FeatureItems/NameTag/NameTagNewWindow.cs | 2 +- .../FeatureItems/NameTag/NameTagPanel.cs | 4 +- .../FeatureItems/NameTag/UiHelper.cs | 2 +- .../Resources/ResourcesManager.cs | 2 +- .../FeatureItems/Resources/ResourcesPanel.cs | 11 +- .../FinalAntiCheat/Core/DllChecker.cs | 11 +- .../DataHandling/FinalAntiCheat/Core/FAC.cs | 2 +- .../DataHandling/FinalAntiCheat/Core/Git.cs | 2 + .../FinalAntiCheat/Core/PlayerCheatData.cs | 4 +- .../Handlers/Valid/SetRoleHandler.cs | 3 +- .../FinalGameData/FinalGameData.cs | 1 + .../DataHandling/FinalLocalHandling.cs | 38 ++--- FinalSuspect/DataHandling/FinalPlayerData.cs | 3 +- FinalSuspect/Helpers/RoleHelper.cs | 118 +++++++++++++++ .../Core/Game/PlayerControlExtension/_Role.cs | 8 +- FinalSuspect/Modules/Core/Game/Utils.cs | 91 +---------- .../Modules/Core/Plugin/ConfigManager.cs | 66 ++++++++ .../Modules/Core/Plugin/DebugModeManager.cs | 7 +- .../Plugin/{Debugger.cs => FinalLogger.cs} | 50 ++++--- FinalSuspect/Modules/Core/Plugin/HashAuth.cs | 76 ---------- .../Modules/Core/Plugin/LaunchingInfo.cs | 31 ++++ .../Modules/Core/Plugin/ModMainMenuManager.cs | 6 + .../Plugin/RegistryManager/RegistryManager.cs | 4 +- .../Modules/Core/Plugin/SystemEnvironment.cs | 7 + .../CheckingandBlocking/BanManager.cs | 6 +- .../Features/CheckingandBlocking/RPC.cs | 10 +- .../CheckingandBlocking/SpamManager.cs | 2 +- .../DisplayerRoleTagHelper.cs | 4 +- .../Modules/Features/InGameRoleInfoMenu.cs | 4 +- FinalSuspect/Modules/Features/Zoom.cs | 2 +- FinalSuspect/Modules/Random/IRandom.cs | 7 + FinalSuspect/Modules/Resources/ModUpdater.cs | 6 +- FinalSuspect/Modules/Resources/PathManager.cs | 17 ++- .../Modules/Resources/ResourcesDownloader.cs | 2 +- .../Modules/Resources/VersionChecker.cs | 13 +- .../Game_Vanilla/EndGameManagerPatch.cs | 4 +- FinalSuspect/Patches/Game_Vanilla/Guardian.cs | 9 +- FinalSuspect/Patches/Game_Vanilla/HudPatch.cs | 12 +- .../Patches/Game_Vanilla/IntroPatch.cs | 14 +- .../Patches/Game_Vanilla/LobbyPatch.cs | 5 +- .../Patches/Game_Vanilla/OutroPatch.cs | 4 +- .../Patches/System/AprilFoolsModePatch.cs | 6 +- FinalSuspect/Patches/System/ClientPatch.cs | 2 +- FinalSuspect/Patches/System/ControlPatch.cs | 8 +- .../Patches/System/CredentialsPatch.cs | 33 ++-- .../Patches/System/GameOptionPatch.cs | 34 +++-- .../Patches/System/GameStartManagerPatch.cs | 6 +- FinalSuspect/Patches/System/LoadPatch.cs | 41 ++--- .../Patches/System/LobbyPanelPatch.cs | 34 ++--- .../System/MainMenuButtonHoverAnimation.cs | 4 +- .../Patches/System/MainMenuManagerPatch.cs | 37 +++-- .../System/SwitchShipCostumeButtonPatch.cs | 2 +- FinalSuspect/main.cs | 141 ------------------ 67 files changed, 574 insertions(+), 595 deletions(-) rename FinalSuspect/{ClientActions => ClientItems}/ClientActionItem.cs (99%) rename FinalSuspect/{ClientActions => ClientItems}/ClientFeatureItem.cs (99%) rename FinalSuspect/{ClientActions/ClientActionsPatch.cs => ClientItems/ClientItemsPatch.cs} (81%) rename FinalSuspect/{ClientActions => ClientItems}/ClientOptionItem.cs (98%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs (96%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs (96%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/ModUnloaderScreen.cs (97%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/MyMusic/AudioLoader.cs (99%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/MyMusic/AudioManager.cs (99%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/MyMusic/AudioPlayer.cs (96%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/MyMusic/MyMusicPanel.cs (98%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/NameTag/NameTagEditMenu.cs (98%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/NameTag/NameTagManager.cs (99%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/NameTag/NameTagNewWindow.cs (98%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/NameTag/NameTagPanel.cs (98%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/NameTag/UiHelper.cs (98%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/Resources/ResourcesManager.cs (94%) rename FinalSuspect/{ClientActions => ClientItems}/FeatureItems/Resources/ResourcesPanel.cs (96%) create mode 100644 FinalSuspect/Helpers/RoleHelper.cs create mode 100644 FinalSuspect/Modules/Core/Plugin/ConfigManager.cs rename FinalSuspect/Modules/Core/Plugin/{Debugger.cs => FinalLogger.cs} (89%) delete mode 100644 FinalSuspect/Modules/Core/Plugin/HashAuth.cs create mode 100644 FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index dfcb57b..16724f6 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -5,9 +5,9 @@ #Date:2025-08-15T00:00:00Z #----------------------------- # 简体中文 -自Starlight问世,安卓玩家也有了享受模组的权利 -因此,我们在适配了最新版本的同时,也对Starlight进行了适配 -享受使用手机游玩Final Suspect的时光吧! +Starlight为安卓平台带来了模组体验。 +我们已完成最新版本适配,并全面支持Starlight。 +尽享手机端Final Suspect的游戏乐趣吧! ## 对应官方版本 - 基于 Among Us v17.0.0 @@ -43,7 +43,8 @@ ## 新增 - 适配**Among Us v17.0.0** -制作: LezaiYa +- 恢复官网 +制作: LezaiYa | 立绘: 小黄117 - 适配**Starlight**安装模组启动器 制作: Slok diff --git a/FinalSuspect/ClientActions/ClientActionItem.cs b/FinalSuspect/ClientItems/ClientActionItem.cs similarity index 99% rename from FinalSuspect/ClientActions/ClientActionItem.cs rename to FinalSuspect/ClientItems/ClientActionItem.cs index a2c1733..b782679 100644 --- a/FinalSuspect/ClientActions/ClientActionItem.cs +++ b/FinalSuspect/ClientItems/ClientActionItem.cs @@ -4,7 +4,7 @@ using UnityEngine.UI; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions; +namespace FinalSuspect.ClientItems; public class ClientActionItem { diff --git a/FinalSuspect/ClientActions/ClientFeatureItem.cs b/FinalSuspect/ClientItems/ClientFeatureItem.cs similarity index 99% rename from FinalSuspect/ClientActions/ClientFeatureItem.cs rename to FinalSuspect/ClientItems/ClientFeatureItem.cs index 23b4ba1..841cbdc 100644 --- a/FinalSuspect/ClientActions/ClientFeatureItem.cs +++ b/FinalSuspect/ClientItems/ClientFeatureItem.cs @@ -4,7 +4,7 @@ using UnityEngine.UI; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions; +namespace FinalSuspect.ClientItems; public class ClientFeatureItem { diff --git a/FinalSuspect/ClientActions/ClientActionsPatch.cs b/FinalSuspect/ClientItems/ClientItemsPatch.cs similarity index 81% rename from FinalSuspect/ClientActions/ClientActionsPatch.cs rename to FinalSuspect/ClientItems/ClientItemsPatch.cs index f072d34..f60e9ee 100644 --- a/FinalSuspect/ClientActions/ClientActionsPatch.cs +++ b/FinalSuspect/ClientItems/ClientItemsPatch.cs @@ -1,18 +1,18 @@ using System; using System.IO; using BepInEx.Configuration; -using FinalSuspect.ClientActions.FeatureItems; -using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; -using FinalSuspect.ClientActions.FeatureItems.NameTag; -using FinalSuspect.ClientActions.FeatureItems.Resources; +using FinalSuspect.ClientItems.FeatureItems; +using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.NameTag; +using FinalSuspect.ClientItems.FeatureItems.Resources; using FinalSuspect.Helpers; using FinalSuspect.Modules.Features; using FinalSuspect.Patches.System; using UnityEngine; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions; +namespace FinalSuspect.ClientItems; [HarmonyPatch(typeof(OptionsMenuBehaviour), nameof(OptionsMenuBehaviour.Start))] public static class OptionsMenuBehaviourStartPatch @@ -61,9 +61,9 @@ public static void Postfix(OptionsMenuBehaviour __instance) if (!_reseted || !DebugModeManager.IsDebugMode) { _reseted = true; - Main.VersionCheat.Value = false; - Main.GodMode.Value = false; - Main.NoGameEnd.Value = false; + ConfigManager.VersionCheat.Value = false; + ConfigManager.GodMode.Value = false; + ConfigManager.NoGameEnd.Value = false; } if (Recreate) @@ -94,41 +94,45 @@ public static void Postfix(OptionsMenuBehaviour __instance) NameTagPanel.CustomBackground = null; } - CreateOptionItem(ref _unlockFPS, "UnlockFPS", Main.UnlockFPS, __instance, UnlockFPSButtonToggle); - CreateOptionItem(ref _switchOutfitType, "SwitchOutfitType", Main.SwitchOutfitType, __instance, SwitchMode); + CreateOptionItem(ref _unlockFPS, "UnlockFPS", ConfigManager.UnlockFPS, __instance, UnlockFPSButtonToggle); + CreateOptionItem(ref _switchOutfitType, "SwitchOutfitType", ConfigManager.SwitchOutfitType, __instance, + SwitchMode); CreateOptionItem(ref _kickPlayerWithAbnormalFriendCode, "KickPlayerWithAbnormalFriendCode", - Main.KickPlayerWithAbnormalFriendCode, __instance); - CreateOptionItem(ref _kickPlayerInBanList, "KickPlayerInBanList", Main.KickPlayerInBanList, __instance); - CreateOptionItem(ref _kickPlayerWithDenyName, "KickPlayerWithDenyName", Main.KickPlayerWithDenyName, + ConfigManager.KickPlayerWithAbnormalFriendCode, __instance); + CreateOptionItem(ref _kickPlayerInBanList, "KickPlayerInBanList", ConfigManager.KickPlayerInBanList, __instance); - CreateOptionItem(ref _spamDenyWord, "SpamDenyWord", Main.SpamDenyWord, __instance); - CreateOptionItem(ref _enableFac, "EnableFAC", Main.EnableFAC, __instance); - CreateOptionItem(ref _enableGuardian, "EnableGuardian", Main.EnableGuardian, __instance); - CreateOptionItem(ref _autoStartGame, "AutoStartGame", Main.AutoStartGame, __instance, AutoStartButtonToggle); - CreateOptionItem(ref _autoEndGame, "AutoEndGame", Main.AutoEndGame, __instance); + CreateOptionItem(ref _kickPlayerWithDenyName, "KickPlayerWithDenyName", ConfigManager.KickPlayerWithDenyName, + __instance); + CreateOptionItem(ref _spamDenyWord, "SpamDenyWord", ConfigManager.SpamDenyWord, __instance); + CreateOptionItem(ref _enableFac, "EnableFAC", ConfigManager.EnableFAC, __instance); + CreateOptionItem(ref _enableGuardian, "EnableGuardian", ConfigManager.EnableGuardian, __instance); + CreateOptionItem(ref _autoStartGame, "AutoStartGame", ConfigManager.AutoStartGame, __instance, + AutoStartButtonToggle); + CreateOptionItem(ref _autoEndGame, "AutoEndGame", ConfigManager.AutoEndGame, __instance); //CreateOptionItem(ref PrunkMode, "PrunkMode", Main.PrunkMode, __instance); - CreateOptionItem(ref _disableVanillaSound, "DisableVanillaSound", Main.DisableVanillaSound, __instance, () => - { - if (Main.DisableVanillaSound.Value) - AudioPlayer.StopPlayVanilla(); - else - AudioPlayer.StartPlayVanilla(); - }); - CreateOptionItem(ref _showPlayerInfo, "ShowPlayerInfo", Main.ShowPlayerInfo, __instance); - CreateOptionItem(ref _fastLaunchMode, "FastLaunchMode", Main.FastLaunchMode, __instance); - CreateOptionItem(ref _offlineMode, "OfflineMode", Main.OfflineMode, __instance, (() => + CreateOptionItem(ref _disableVanillaSound, "DisableVanillaSound", ConfigManager.DisableVanillaSound, __instance, + () => + { + if (ConfigManager.DisableVanillaSound.Value) + AudioPlayer.StopPlayVanilla(); + else + AudioPlayer.StartPlayVanilla(); + }); + CreateOptionItem(ref _showPlayerInfo, "ShowPlayerInfo", ConfigManager.ShowPlayerInfo, __instance); + CreateOptionItem(ref _fastLaunchMode, "FastLaunchMode", ConfigManager.FastLaunchMode, __instance); + CreateOptionItem(ref _offlineMode, "OfflineMode", ConfigManager.OfflineMode, __instance, (() => { __instance.Close(); CustomPopup.Show(GetString("ClientOption.OfflineMode"), GetString("UpdateResult.Succeed_Text"), [(GetString(StringNames.ExitGame), Application.Quit)]); })); - CreateOptionItem(ref _useModCursor, "UseModCursor", Main.UseModCursor, __instance, SetCursor); + CreateOptionItem(ref _useModCursor, "UseModCursor", ConfigManager.UseModCursor, __instance, SetCursor); if (DebugModeManager.IsDebugMode) { - CreateOptionItem(ref _versionCheat, "VersionCheat", Main.VersionCheat, __instance); - CreateOptionItem(ref _godMode, "GodMode", Main.GodMode, __instance); - CreateOptionItem(ref _noGameEnd, "NoGameEnd", Main.NoGameEnd, __instance); + CreateOptionItem(ref _versionCheat, "VersionCheat", ConfigManager.VersionCheat, __instance); + CreateOptionItem(ref _godMode, "GodMode", ConfigManager.GodMode, __instance); + CreateOptionItem(ref _noGameEnd, "NoGameEnd", ConfigManager.NoGameEnd, __instance); } CreateFeatureItem(ref _dumpLog, "DumpLog", () => { DumpLog(); }, __instance); @@ -254,7 +258,7 @@ private static void SetFeatureItemDisabled(ClientFeatureItem item) private static void UnlockFPSButtonToggle() { - Application.targetFrameRate = Main.UnlockFPS.Value ? 165 : 60; + Application.targetFrameRate = ConfigManager.UnlockFPS.Value ? 165 : 60; SendInGame(string.Format(GetString("Notification.FPSSetTo"), Application.targetFrameRate)); } @@ -270,7 +274,7 @@ private static void SwitchMode() private static void AutoStartButtonToggle() { - if (!Main.AutoStartGame.Value && IsCountDown) GameStartManager.Instance.ResetStartState(); + if (!ConfigManager.AutoStartGame.Value && IsCountDown) GameStartManager.Instance.ResetStartState(); } public static void SetCursor() @@ -278,11 +282,11 @@ public static void SetCursor() try { var sprite = LoadSprite("Cursor.png"); - Cursor.SetCursor(Main.UseModCursor.Value ? sprite.texture : null, Vector2.zero, CursorMode.Auto); + Cursor.SetCursor(ConfigManager.UseModCursor.Value ? sprite.texture : null, Vector2.zero, CursorMode.Auto); } catch { - Main.UseModCursor.Value = false; + ConfigManager.UseModCursor.Value = false; } } } @@ -319,14 +323,14 @@ public static void Postfix() OptionsMenuBehaviourStartPatch.Recreate = true; try { - Object.Destroy(VersionShowerStartPatch.VisitText); + Object.Destroy(ModMainMenuManager.VisitText); } catch { /* ignored */ } - VersionShowerStartPatch.VisitText = null; + ModMainMenuManager.VisitText = null; VersionShowerStartPatch.CreateVisitText(null); OptionsMenuBehaviourStartPatch.Postfix(OptionsMenuBehaviourStartPatch.Instance); } diff --git a/FinalSuspect/ClientActions/ClientOptionItem.cs b/FinalSuspect/ClientItems/ClientOptionItem.cs similarity index 98% rename from FinalSuspect/ClientActions/ClientOptionItem.cs rename to FinalSuspect/ClientItems/ClientOptionItem.cs index 240419a..bb3ae17 100644 --- a/FinalSuspect/ClientActions/ClientOptionItem.cs +++ b/FinalSuspect/ClientItems/ClientOptionItem.cs @@ -3,7 +3,7 @@ using FinalSuspect.Helpers; using UnityEngine; -namespace FinalSuspect.ClientActions; +namespace FinalSuspect.ClientItems; public sealed class ClientOptionItem : ClientActionItem { diff --git a/FinalSuspect/ClientActions/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs similarity index 96% rename from FinalSuspect/ClientActions/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs rename to FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs index a94f7f1..543b0f1 100644 --- a/FinalSuspect/ClientActions/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs @@ -1,9 +1,9 @@ using System.IO; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Modules.Resources; using UnityEngine; -namespace FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; +namespace FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; public abstract class MainMenuStyleManager { @@ -63,7 +63,7 @@ public abstract class MainMenuStyleManager new Color(0.255f, 0.482f, 1f, 0.8f), new Color(0.333f, 0.255f, 1f, 0.8f), new Color(0.0235f, 0.6f, 1f, 0.8f), - ]) + ]), //new( //"WhenLookingBackAtTheEnd", //false, diff --git a/FinalSuspect/ClientActions/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs similarity index 96% rename from FinalSuspect/ClientActions/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs rename to FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs index d631490..ef881be 100644 --- a/FinalSuspect/ClientActions/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs @@ -1,14 +1,14 @@ using System; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Helpers; using FinalSuspect.Patches.System; using TMPro; using UnityEngine; using UnityEngine.UI; -using static FinalSuspect.ClientActions.FeatureItems.MainMenuStyle.MainMenuStyleManager; +using static FinalSuspect.ClientItems.FeatureItems.MainMenuStyle.MainMenuStyleManager; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; +namespace FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; public static class MainMenuStylePanel { @@ -19,7 +19,7 @@ public static class MainMenuStylePanel private static SpriteRenderer _previewImage; public static SpriteRenderer CustomBackground { get; set; } public static List Items { get; private set; } = []; - private static int CurrentPage { get; set; } = Main.CurrentStyleId.Value + 1; + private static int CurrentPage { get; set; } = ConfigManager.CurrentStyleId.Value + 1; private static int TotalPageCount => MainMenuStyles.Count; public static void Hide() => CustomBackground?.gameObject.SetActive(false); @@ -39,7 +39,7 @@ public static void Init(OptionsMenuBehaviour optionsMenuBehaviour) CreateHelpText(optionsMenuBehaviour); CreateDescriptionText(optionsMenuBehaviour); CreatePageNavigationButtons(mouseMoveToggle); - var currentBackground = MainMenuStyles[Main.CurrentStyleId.Value]; + var currentBackground = MainMenuStyles[ConfigManager.CurrentStyleId.Value]; currentBackground.CurrentState = CurrentState.Applied; Refresh(currentBackground); } @@ -80,7 +80,7 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) button.OnClick.AddListener(new Action(() => { var id = CurrentPage - 1; - Main.CurrentStyleId.Value = id; + ConfigManager.CurrentStyleId.Value = id; var style = MainMenuStyles[id]; MainMenuStyles.Where(x => x.Applied).Do(x => x.CurrentState = CurrentState.NotApply); style.CurrentState = CurrentState.Applied; @@ -130,6 +130,7 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) ModMainMenuManager.InviteButton.GetComponent(), ModMainMenuManager.GithubButton.GetComponent(), ModMainMenuManager.BugReportButton.GetComponent(), + ModMainMenuManager.WebsiteButton.GetComponent() ], (minorActiveSprite, style.MainUIColors[2], shade, Color.white, Color.white) }, diff --git a/FinalSuspect/ClientActions/FeatureItems/ModUnloaderScreen.cs b/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs similarity index 97% rename from FinalSuspect/ClientActions/FeatureItems/ModUnloaderScreen.cs rename to FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs index 36dd9bf..b5de88c 100644 --- a/FinalSuspect/ClientActions/FeatureItems/ModUnloaderScreen.cs +++ b/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs @@ -6,7 +6,7 @@ using UnityEngine.UI; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions.FeatureItems; +namespace FinalSuspect.ClientItems.FeatureItems; public static class ModUnloaderScreen { @@ -17,7 +17,7 @@ public static class ModUnloaderScreen public static void Init(OptionsMenuBehaviour optionsMenuBehaviour) { - Popup = Object.Instantiate(optionsMenuBehaviour.Background, ClientFeatureItem.CustomBackground.transform); + Popup = Object.Instantiate(optionsMenuBehaviour.Background, optionsMenuBehaviour.transform); Popup.name = "UnloadModPopup"; Popup.transform.localPosition = new Vector3(0f, 0f, -8f); Popup.transform.localScale = new Vector3(0.8f, 0.8f, 1f); diff --git a/FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioLoader.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs similarity index 99% rename from FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioLoader.cs rename to FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs index 20a2cd5..b5b8299 100644 --- a/FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioLoader.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs @@ -2,12 +2,12 @@ using System.IO; using System.Text; using System.Threading.Tasks; -using UnityEngine; using NAudio.Wave; +using UnityEngine; // ReSharper disable RedundantAssignment -namespace FinalSuspect.ClientActions.FeatureItems.MyMusic; +namespace FinalSuspect.ClientItems.FeatureItems.MyMusic; /// /// 异步音频加载器 diff --git a/FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioManager.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs similarity index 99% rename from FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioManager.cs rename to FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs index 3b86499..88dcfc4 100644 --- a/FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs @@ -6,7 +6,7 @@ using FinalSuspect.Modules.Resources; using UnityEngine; -namespace FinalSuspect.ClientActions.FeatureItems.MyMusic; +namespace FinalSuspect.ClientItems.FeatureItems.MyMusic; public static class AudioManager { diff --git a/FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioPlayer.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs similarity index 96% rename from FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioPlayer.cs rename to FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs index e047e5e..31bb0ed 100644 --- a/FinalSuspect/ClientActions/FeatureItems/MyMusic/AudioPlayer.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs @@ -5,7 +5,7 @@ using UnityEngine.SceneManagement; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions.FeatureItems.MyMusic; +namespace FinalSuspect.ClientItems.FeatureItems.MyMusic; public static class AudioPlayer { @@ -81,7 +81,7 @@ public static void StopPlayMod(bool playNew = false) }); CurrentMusic = null; _ = new MainThreadTask(MyMusicPanel.RefreshTagList, "Refresh Tag List"); - if (Main.DisableVanillaSound.Value || playNew) + if (ConfigManager.DisableVanillaSound.Value || playNew) StopPlayVanilla(); else StartPlayVanilla(); @@ -171,7 +171,7 @@ public static bool Prefix(SoundManager __instance, [HarmonyArgument(0)] AudioCli [HarmonyArgument(1)] bool loop) { var isPlaying = FinalMusic.Musics.Any(x => x.CurrentAudioStates == AudiosStates.Playing); - var disableVanilla = Main.DisableVanillaSound.Value; + var disableVanilla = ConfigManager.DisableVanillaSound.Value; return !(isPlaying || disableVanilla) || !loop; } } @@ -185,7 +185,7 @@ public static bool Prefix([HarmonyArgument(0)] string name, { var isPlaying = FinalMusic.Musics.Any(x => x.CurrentAudioStates == AudiosStates.Playing); var isModMusic = FinalMusic.Musics.Any(x => x.FileName == name); - var disableVanilla = Main.DisableVanillaSound.Value; + var disableVanilla = ConfigManager.DisableVanillaSound.Value; return !(isPlaying || disableVanilla) || !loop || isModMusic; } } @@ -198,7 +198,7 @@ public static bool Prefix([HarmonyArgument(0)] string name) if (name is "MainBG") return false; var isPlaying = FinalMusic.Musics.Any(x => x.CurrentAudioStates == AudiosStates.Playing); var isModMusic = FinalMusic.Musics.Any(x => x.FileName == name); - var disableVanilla = Main.DisableVanillaSound.Value; + var disableVanilla = ConfigManager.DisableVanillaSound.Value; return !(isPlaying || disableVanilla) || isModMusic; diff --git a/FinalSuspect/ClientActions/FeatureItems/MyMusic/MyMusicPanel.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs similarity index 98% rename from FinalSuspect/ClientActions/FeatureItems/MyMusic/MyMusicPanel.cs rename to FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs index e37e848..a00b5d7 100644 --- a/FinalSuspect/ClientActions/FeatureItems/MyMusic/MyMusicPanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs @@ -5,9 +5,9 @@ using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; -using static FinalSuspect.ClientActions.FeatureItems.MyMusic.AudioPlayer; +using static FinalSuspect.ClientItems.FeatureItems.MyMusic.AudioPlayer; -namespace FinalSuspect.ClientActions.FeatureItems.MyMusic; +namespace FinalSuspect.ClientItems.FeatureItems.MyMusic; [SuppressMessage("ReSharper", "PossibleLossOfFraction")] public static class MyMusicPanel @@ -397,8 +397,7 @@ public static void Update() _timeText.text = $"{formattedCurrentTime}/{formattedClipLength}"; - if (formattedCurrentTime != formattedClipLength && - currentSource.clip.length - currentSource.time >= 0.1f) return; + if (formattedCurrentTime != formattedClipLength && currentSource.GetRemainingTime() >= 0.1f) return; HandlePlayMode(); } catch diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs similarity index 98% rename from FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs rename to FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs index b541e52..d0b0fd4 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagEditMenu.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs @@ -6,12 +6,12 @@ using Newtonsoft.Json; using TMPro; using UnityEngine; -using static FinalSuspect.ClientActions.FeatureItems.NameTag.NameTagManager; -using Component = FinalSuspect.ClientActions.FeatureItems.NameTag.NameTagManager.Component; +using static FinalSuspect.ClientItems.FeatureItems.NameTag.NameTagManager; +using Component = FinalSuspect.ClientItems.FeatureItems.NameTag.NameTagManager.Component; using File = System.IO.File; using Path = System.IO.Path; -namespace FinalSuspect.ClientActions.FeatureItems.NameTag; +namespace FinalSuspect.ClientItems.FeatureItems.NameTag; public static class NameTagEditMenu { diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagManager.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs similarity index 99% rename from FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagManager.cs rename to FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs index 1a252e9..1e709af 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs @@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq; using UnityEngine; -namespace FinalSuspect.ClientActions.FeatureItems.NameTag; +namespace FinalSuspect.ClientItems.FeatureItems.NameTag; public static class NameTagManager { diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs similarity index 98% rename from FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs rename to FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs index 51dbdee..eae3ecd 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagNewWindow.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs @@ -3,7 +3,7 @@ using TMPro; using UnityEngine; -namespace FinalSuspect.ClientActions.FeatureItems.NameTag; +namespace FinalSuspect.ClientItems.FeatureItems.NameTag; public static class NameTagNewWindow { diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagPanel.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs similarity index 98% rename from FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagPanel.cs rename to FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs index 726b37a..f8af618 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/NameTagPanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs @@ -3,10 +3,10 @@ using TMPro; using UnityEngine; using UnityEngine.UI; -using static FinalSuspect.ClientActions.FeatureItems.NameTag.NameTagManager; +using static FinalSuspect.ClientItems.FeatureItems.NameTag.NameTagManager; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions.FeatureItems.NameTag; +namespace FinalSuspect.ClientItems.FeatureItems.NameTag; public static class NameTagPanel { diff --git a/FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs similarity index 98% rename from FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs rename to FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs index a8197f1..c7d7b2d 100644 --- a/FinalSuspect/ClientActions/FeatureItems/NameTag/UiHelper.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs @@ -5,7 +5,7 @@ using UnityEngine.UI; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions.FeatureItems.NameTag; +namespace FinalSuspect.ClientItems.FeatureItems.NameTag; public static class UiHelper { diff --git a/FinalSuspect/ClientActions/FeatureItems/Resources/ResourcesManager.cs b/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesManager.cs similarity index 94% rename from FinalSuspect/ClientActions/FeatureItems/Resources/ResourcesManager.cs rename to FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesManager.cs index 2189949..b39858b 100644 --- a/FinalSuspect/ClientActions/FeatureItems/Resources/ResourcesManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesManager.cs @@ -3,7 +3,7 @@ using System.Threading.Tasks; using FinalSuspect.Helpers; -namespace FinalSuspect.ClientActions.FeatureItems.Resources; +namespace FinalSuspect.ClientItems.FeatureItems.Resources; public static class ResourcesManager { diff --git a/FinalSuspect/ClientActions/FeatureItems/Resources/ResourcesPanel.cs b/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs similarity index 96% rename from FinalSuspect/ClientActions/FeatureItems/Resources/ResourcesPanel.cs rename to FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs index 4d5e6e4..57d4123 100644 --- a/FinalSuspect/ClientActions/FeatureItems/Resources/ResourcesPanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs @@ -1,18 +1,18 @@ using System; using System.IO; using System.Threading.Tasks; -using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Helpers; using FinalSuspect.Modules.Features; using FinalSuspect.Modules.Resources; using TMPro; using UnityEngine; using UnityEngine.UI; -using static FinalSuspect.ClientActions.FeatureItems.Resources.ResourcesManager; +using static FinalSuspect.ClientItems.FeatureItems.Resources.ResourcesManager; using Object = UnityEngine.Object; -namespace FinalSuspect.ClientActions.FeatureItems.Resources; +namespace FinalSuspect.ClientItems.FeatureItems.Resources; public static class ResourcesPanel { @@ -205,7 +205,8 @@ public static void RefreshTagList() { packageStates[packageName] = CurrentState.None; RefreshTagList(); - MainMenuStylePanel.Refresh(MainMenuStyleManager.MainMenuStyles[Main.CurrentStyleId.Value]); + MainMenuStylePanel.Refresh( + MainMenuStyleManager.MainMenuStyles[ConfigManager.CurrentStyleId.Value]); MyMusicPanel.RefreshTagList(); }, 3F, "Refresh Tag List"); } diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs index 6966928..80c4c1c 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs @@ -1,14 +1,19 @@ +#if Windows using System; using System.IO; +using UnityEngine; +#endif using BepInEx; using BepInEx.Unity.IL2CPP; -using UnityEngine; +using FinalSuspect.Attributes; + namespace FinalSuspect.DataHandling.FinalAntiCheat.Core; -internal static class DllChecker +public static class DllChecker { - internal static void Init() + [PluginModuleInitializer(InitializePriority.High)] + internal static void OnInitialization() { #if Windows // SM的文件名是写死的 diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/FAC.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/FAC.cs index 40444b1..edd6430 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/FAC.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/FAC.cs @@ -52,7 +52,7 @@ public static bool ReceiveRpc(PlayerControl pc, byte callId, MessageReader reade reason = "Hacking"; ban = false; - if (!Main.EnableFAC.Value || !pc || reader == null || pc.AmOwner) + if (!ConfigManager.EnableFAC.Value || !pc || reader == null || pc.AmOwner) return false; try diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs index 40721fa..e884503 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs @@ -1,5 +1,7 @@ +#if Windows using System.IO; using UnityEngine; +#endif [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))] // ReSharper disable once CheckNamespace diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/PlayerCheatData.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/PlayerCheatData.cs index 1c0b715..8db00d8 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/PlayerCheatData.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/PlayerCheatData.cs @@ -69,7 +69,7 @@ private void HandleBan() private void HandleSuspectCheater() { - if (!Main.EnableFAC.Value || !IsSuspectCheater || + if (!ConfigManager.EnableFAC.Value || !IsSuspectCheater || (LastHandleCheater != -1 && LastHandleCheater + 1 >= GetTimeStamp())) return; LastHandleCheater = GetTimeStamp(); if (!AmongUsClient.Instance.AmHost) @@ -84,7 +84,7 @@ private void HandleSuspectCheater() private void HandleHacker() { - if (!Main.EnableGuardian.Value || !IsHacker || + if (!ConfigManager.EnableGuardian.Value || !IsHacker || (LastHandleCheater != -1 && LastHandleCheater + 1 >= GetTimeStamp())) return; LastHandleCheater = GetTimeStamp(); if (!AmongUsClient.Instance.AmHost) diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Valid/SetRoleHandler.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Valid/SetRoleHandler.cs index 861e5e0..ba33b98 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Valid/SetRoleHandler.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Valid/SetRoleHandler.cs @@ -1,5 +1,6 @@ using AmongUs.GameOptions; using FinalSuspect.DataHandling.FinalAntiCheat.Interfaces; +using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using Hazel; @@ -22,6 +23,6 @@ public bool HandleLobby(PlayerControl sender, MessageReader reader, public bool HandleGame_All(PlayerControl sender, MessageReader reader, ref bool notify, ref string reason, ref bool ban) { - return sender.GetFinalData().RoleAssigned && !IsGhost((RoleTypes)reader.ReadUInt16()); + return sender.GetFinalData().RoleAssigned && !RoleHelper.IsGhost((RoleTypes)reader.ReadUInt16()); } } \ No newline at end of file diff --git a/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs b/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs index 24c9bc5..8ea25d9 100644 --- a/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs +++ b/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs @@ -13,6 +13,7 @@ public static partial class FinalGameData public static Color LastLocalPlayerRoleColor; public static bool JoinedCompleted; public static bool IntroDestroyed; + public static string HostNickName = ""; [GameModuleInitializer] public static void Init() diff --git a/FinalSuspect/DataHandling/FinalLocalHandling.cs b/FinalSuspect/DataHandling/FinalLocalHandling.cs index 160466e..d8ac5a5 100644 --- a/FinalSuspect/DataHandling/FinalLocalHandling.cs +++ b/FinalSuspect/DataHandling/FinalLocalHandling.cs @@ -1,4 +1,4 @@ -using FinalSuspect.ClientActions.FeatureItems.NameTag; +using FinalSuspect.ClientItems.FeatureItems.NameTag; using FinalSuspect.DataHandling.FinalGameData; using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; @@ -38,7 +38,7 @@ public static string CheckAndGetNameWithDetails( var ap = NameTagManager.ApplyFor(player).displayName; name += ap.RemoveHtmlTags() == "" ? "" : $" ({ap})"; if (!player.GetCheatData().IsSuspectCheater && !player.GetCheatData().IsHacker || - !Main.EnableFAC.Value) return name; + !ConfigManager.EnableFAC.Value) return name; topcolor = ColorHelper.FaultColor; toptext = toptext.CheckAndAppendText(GetString("Id.Cheater")); return name; @@ -61,10 +61,10 @@ private static void GetLobbyText(this FinalPlayerData data, ref Color topcolor, { switch (Main.version.CompareTo(ver.Version)) { - case 0 when ver.Tag == $"{Main.GitCommit}({Main.GitBranch})": + case 0 when ver.Tag == $"{LaunchingInfo.GitCommit}({LaunchingInfo.GitBranch})": topcolor = ColorHelper.FSColor; break; - case 0 when ver.Tag != $"{Main.GitCommit}({Main.GitBranch})": + case 0 when ver.Tag != $"{LaunchingInfo.GitCommit}({LaunchingInfo.GitBranch})": toptext = toptext.CheckAndAppendText($"{ver.Tag}"); topcolor = Color.yellow; break; @@ -82,7 +82,7 @@ private static void GetLobbyText(this FinalPlayerData data, ref Color topcolor, else topcolor = ColorHelper.ClientlessColor; } - if (!Main.ShowPlayerInfo.Value) return; + if (!ConfigManager.ShowPlayerInfo.Value) return; bottomtext = bottomtext.CheckAndAppendText($"{player.GetPlatform()} {player.GetClient().FriendCode}"); bottomcolor = ColorHelper.DownloadYellow; } @@ -91,7 +91,7 @@ private static void GetLobbyText(this FinalPlayerData data, ref Color topcolor, private static void GetGameText(this FinalPlayerData data, ref Color color, ref string roleText, bool topswap) { if (!IsInGame) return; - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; var roleType = GetRoleById(data.PlayerId); var player = data.Player; @@ -99,7 +99,7 @@ private static void GetGameText(this FinalPlayerData data, ref Color color, ref if (CanSeeTargetRole(player, out var bothImp)) { - color = GetRoleColor(roleType); + color = RoleHelper.GetRoleColor(roleType); roleText = !topswap ? $"{GetRoleString(roleType.ToString())} {GetProgressText(player)} {GetVitalText(player.PlayerId, doColor: CanSeeOthersRole())} " : $"{GetVitalText(player.PlayerId, doColor: CanSeeOthersRole())} {GetProgressText(player)} {GetRoleString(roleType.ToString())}"; @@ -133,7 +133,7 @@ private static string CheckAndAppendText(this string toptext, string extratext) public static void SetVentOutlineColor(Vent __instance, ref bool mainTarget) { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; var color = PlayerControl.LocalPlayer.GetRoleColor(); __instance.myRend.material.SetColor(OutlineColor, color); __instance.myRend.material.SetColor(AddColor, mainTarget ? color : Color.clear); @@ -141,7 +141,7 @@ public static void SetVentOutlineColor(Vent __instance, ref bool mainTarget) public static void ShowMap(MapBehaviour map, MapOptions opts) { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; foreach (var data in FinalPlayerData.AllPlayerData) if (data.IsDisconnected) { @@ -163,7 +163,7 @@ public static void ShowMap(MapBehaviour map, MapOptions opts) } var roleType = PlayerControl.LocalPlayer.Data.Role.Role; - var color = GetRoleColor(roleType); + var color = RoleHelper.GetRoleColor(roleType); var mode = opts.Mode; switch (mode) { @@ -180,7 +180,7 @@ public static void ShowMap(MapBehaviour map, MapOptions opts) public static void UpdateMap() { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; foreach (var data in FinalPlayerData.AllPlayerData) { var player = data.Player; @@ -212,11 +212,11 @@ public static void UpdateMap() public static bool GetHauntFilterText(HauntMenuMinigame __instance) { - if (!Main.EnableFinalSuspect.Value) return true; + if (!ConfigManager.EnableFinalSuspect.Value) return true; var role = __instance.HauntTarget.GetRoleType(); - var color = GetRoleColor(role); + var color = RoleHelper.GetRoleColor(role); __instance.NameText.color = __instance.FilterText.color = color; - __instance.FilterText.text = GetRoleName(role); + __instance.FilterText.text = RoleHelper.GetRoleName(role); return false; } @@ -224,7 +224,7 @@ public static void GetChatBubbleText(byte playerId, ref string name, ref Color32 { try { - if (!Main.EnableFinalSuspect.Value) + if (!ConfigManager.EnableFinalSuspect.Value) { namecolor = Color.white; return; @@ -256,7 +256,7 @@ public static void GetChatBubbleText(byte playerId, ref string name, ref Color32 [HarmonyPostfix] public static void OnFixedUpdate(PlayerControl __instance) { - Main.EnableFinalSuspect.Value = !OtherModHost; + ConfigManager.EnableFinalSuspect.Value = !OtherModHost; if (!__instance) return; @@ -264,7 +264,7 @@ public static void OnFixedUpdate(PlayerControl __instance) { var name = __instance.CheckAndGetNameWithDetails(out var topcolor, out var bottomcolor, out var toptext, out var bottomtext); - if (Main.EnableFinalSuspect.Value) + if (ConfigManager.EnableFinalSuspect.Value) { DisconnectSync(__instance); DeathSync(__instance); @@ -334,7 +334,7 @@ private static void DeathSync(PlayerControl pc) [HarmonyPriority(Priority.HigherThanNormal)] public static void OnMeetingStart(MeetingHud __instance) { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; foreach (var pva in __instance.playerStates) try { @@ -368,7 +368,7 @@ public static void OnMeetingStart(MeetingHud __instance) [HarmonyPriority(Priority.First)] public static void MeetingHudUpdate(MeetingHud __instance) { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; foreach (var pva in __instance.playerStates) try { diff --git a/FinalSuspect/DataHandling/FinalPlayerData.cs b/FinalSuspect/DataHandling/FinalPlayerData.cs index f066585..14d0338 100644 --- a/FinalSuspect/DataHandling/FinalPlayerData.cs +++ b/FinalSuspect/DataHandling/FinalPlayerData.cs @@ -3,6 +3,7 @@ using FinalSuspect.Attributes; using FinalSuspect.DataHandling.FinalAntiCheat.Core; using FinalSuspect.DataHandling.FinalGameData; +using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using FinalSuspect.Modules.Features.DisplayedRoleTag; using UnityEngine; @@ -49,7 +50,7 @@ public void SetRole(RoleTypes role) if (!RoleAssigned) { RoleWhenAlive = role; - SetAsImp(role.IsImpostor()); + SetAsImp(RoleHelper.IsImpostor(role)); } else { diff --git a/FinalSuspect/Helpers/RoleHelper.cs b/FinalSuspect/Helpers/RoleHelper.cs new file mode 100644 index 0000000..9c6296f --- /dev/null +++ b/FinalSuspect/Helpers/RoleHelper.cs @@ -0,0 +1,118 @@ +using System; +using AmongUs.GameOptions; +using UnityEngine; + +namespace FinalSuspect.Helpers; + +public static class RoleHelper +{ + private static readonly Dictionary roleColors = new() + { + { RoleTypes.CrewmateGhost, "#8CFFFF" }, + { RoleTypes.GuardianAngel, "#8CFFDB" }, + { RoleTypes.Crewmate, "#8CFFFF" }, + { RoleTypes.Scientist, "#F8FF8C" }, + { RoleTypes.Engineer, "#A5A8FF" }, + { RoleTypes.Noisemaker, "#FFC08C" }, + { RoleTypes.Tracker, "#93FF8C" }, + { RoleTypes.ImpostorGhost, "#FF1919" }, + { RoleTypes.Impostor, "#FF1919" }, + { RoleTypes.Shapeshifter, "#FF819E" }, + { RoleTypes.Phantom, "#CA8AFF" }, + { RoleTypes.Detective, "#70A1DA" }, + { RoleTypes.Viper, "#F06762" } + }; + + public static RoleTypes GetRoleType(byte id) + { + return GetRoleById(id); + } + + public static bool IsImpostor(this RoleTypes role) + { + return role switch + { + RoleTypes.Impostor + or RoleTypes.Shapeshifter + or RoleTypes.Phantom + or RoleTypes.ImpostorGhost + or RoleTypes.Viper => true, + _ => false + }; + } + + public static bool IsGhost(RoleTypes role) + { + return role switch + { + RoleTypes.ImpostorGhost or RoleTypes.CrewmateGhost or RoleTypes.GuardianAngel => true, + _ => false + }; + } + + public static string GetRoleName(RoleTypes role) + { + return GetRoleString(Enum.GetName(typeof(RoleTypes), role)); + } + + public static Color GetRoleColor(RoleTypes role) + { + roleColors.TryGetValue(role, out var hexColor); + _ = ColorUtility.TryParseHtmlString(hexColor, out var c); + return c; + } + + public static string GetRoleColorCode(RoleTypes role) + { + roleColors.TryGetValue(role, out var hexColor); + return hexColor; + } + + public static string GetRoleInfoForVanilla(this RoleTypes role, bool roleHelp = false) + { + return IsNormalGame ? GetNormalGameRoleInfo(role, roleHelp) : GetHideNSeekRoleInfo(role, roleHelp); + } + + private static string GetNormalGameRoleInfo(RoleTypes role, bool roleHelp) + { + var text = role.ToString(); + + if (!roleHelp) + { + return GetString($"{text}Blurb"); + } + + return role is RoleTypes.Crewmate or RoleTypes.Impostor + ? GetString($"RolesHelp_{text}Role") + : $"{GetString($"RolesHelp_{text}_01")}\n{GetString($"RolesHelp_{text}_02")}"; + } + + private static string GetHideNSeekRoleInfo(RoleTypes role, bool roleHelp) + { + var text = role.ToString(); + + if (!roleHelp) + { + return GetString($"HnS{text}Blurb"); + } + + return role switch + { + RoleTypes.Engineer => GetCrewmateRules(), + RoleTypes.Impostor => GetImpostorRules(), + _ => throw new ArgumentOutOfRangeException(nameof(role), role, $"Unsupported role type: {role}") + }; + } + + private static string GetCrewmateRules() => + string.Join("\n", + GetString(StringNames.RuleOneCrewmates), + GetString(StringNames.RuleTwoCrewmates), + GetString(StringNames.RuleThreeCrewmates)); + + private static string GetImpostorRules() => + string.Join("\n", + GetString(StringNames.RuleOneImpostor), + GetString(StringNames.RuleTwoImpostor), + GetString(StringNames.RuleThreeImpostor)); +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs index 1a72540..1c7c57a 100644 --- a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs +++ b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs @@ -8,23 +8,23 @@ public static class _Role { public static RoleTypes GetRoleType(this PlayerControl player) { - return Utils.GetRoleType(player.PlayerId); + return RoleHelper.GetRoleType(player.PlayerId); } public static bool IsImpostor(this PlayerControl pc) { - return !IsLobby && pc.GetRoleType().IsImpostor(); + return !IsLobby && RoleHelper.IsImpostor(pc.GetRoleType()); } public static string GetNameWithRole(this PlayerControl player, bool forUser = false) { var ret = $"{player?.Data?.PlayerName}{(IsInGame ? - $"({GetRoleName(player.GetRoleType())})" : "")}"; + $"({RoleHelper.GetRoleName(player.GetRoleType())})" : "")}"; return forUser ? ret : ret.RemoveHtmlTags(); } public static Color GetRoleColor(this PlayerControl player) { - return Utils.GetRoleColor(player.GetRoleType()); + return RoleHelper.GetRoleColor(player.GetRoleType()); } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index c90c5ce..9a137e7 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -463,33 +463,6 @@ public static bool IsActive(SystemTypes type) } } - public static RoleTypes GetRoleType(byte id) - { - return GetRoleById(id); - } - - public static bool IsImpostor(this RoleTypes role) - { - return role switch - { - RoleTypes.Impostor - or RoleTypes.Shapeshifter - or RoleTypes.Phantom - or RoleTypes.ImpostorGhost - or RoleTypes.Viper => true, - _ => false - }; - } - - public static bool IsGhost(RoleTypes role) - { - return role switch - { - RoleTypes.ImpostorGhost or RoleTypes.CrewmateGhost or RoleTypes.GuardianAngel => true, - _ => false - }; - } - public static bool CanSeeTargetRole(PlayerControl target, out bool bothImp) { var LocalDead = !PlayerControl.LocalPlayer.IsAlive(); @@ -500,7 +473,7 @@ public static bool CanSeeTargetRole(PlayerControl target, out bool bothImp) return target.IsLocalPlayer() || BothDeathCanSee || (bothImp && LocalDead) || - Main.GodMode.Value || + ConfigManager.GodMode.Value || IsFreePlay; } @@ -512,65 +485,10 @@ public static bool CanSeeOthersRole() var IsAngel = PlayerControl.LocalPlayer.GetRoleType() is RoleTypes.GuardianAngel; return (!IsAngel && LocalDead) || - Main.GodMode.Value || + ConfigManager.GodMode.Value || IsFreePlay; } - public static string GetRoleName(RoleTypes role) - { - return GetRoleString(Enum.GetName(typeof(RoleTypes), role)); - } - - public static Color GetRoleColor(RoleTypes role) - { - Main.roleColors.TryGetValue(role, out var hexColor); - _ = ColorUtility.TryParseHtmlString(hexColor, out var c); - return c; - } - - public static string GetRoleColorCode(RoleTypes role) - { - Main.roleColors.TryGetValue(role, out var hexColor); - return hexColor; - } - - public static string GetRoleInfoForVanilla(this RoleTypes role, bool InfoLong = false) - { - if (role is RoleTypes.Crewmate or RoleTypes.Impostor) - InfoLong = false; - - var text = role.ToString(); - - if (IsNormalGame) - { - if (InfoLong) - { - return role is not RoleTypes.Crewmate and not RoleTypes.Impostor - ? $"{GetString($"RolesHelp_{text}_01")}\n{GetString($"RolesHelp_{text}_02")}" - : $"{GetString($"RolesHelp_{text}Role")}"; - } - - return GetString($"{text}Blurb"); - } - - if (InfoLong) - switch (role) - { - case RoleTypes.Engineer: - return $"{GetString(StringNames.RuleOneCrewmates)}" + - $"\n{GetString(StringNames.RuleTwoCrewmates)}" + - $"\n{GetString(StringNames.RuleThreeCrewmates)}"; - case RoleTypes.Impostor: - return $"{GetString(StringNames.RuleOneImpostor)}" + - $"\n{GetString(StringNames.RuleTwoImpostor)}" + - $"\n{GetString(StringNames.RuleThreeImpostor)}"; - } - - var Info = "Blurb" + (InfoLong ? "Long" : ""); - text = "HnS" + text; - return GetString($"{text}{Info}"); - } - public static string SummaryTexts(byte id) { var thisData = GetFinalDataById(id); @@ -596,10 +514,11 @@ public static string SummaryTexts(byte id) var oldRole = thisData.RoleWhenAlive ?? RoleTypes.Crewmate; var newRole = thisData.RoleAfterDeath ?? (thisData.IsImpostor ? RoleTypes.ImpostorGhost : RoleTypes.CrewmateGhost); - builder.Append(StringHelper.ColorString(GetRoleColor(oldRole), GetRoleString($"{oldRole}"))); + builder.Append(StringHelper.ColorString(RoleHelper.GetRoleColor(oldRole), GetRoleString($"{oldRole}"))); if (thisData.IsDead && newRole != oldRole) - builder.Append($"=> {StringHelper.ColorString(GetRoleColor(newRole), GetRoleString($"{newRole}"))}"); + builder.Append( + $"=> {StringHelper.ColorString(RoleHelper.GetRoleColor(newRole), GetRoleString($"{newRole}"))}"); builder.Append(""); diff --git a/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs b/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs new file mode 100644 index 0000000..c95cbe2 --- /dev/null +++ b/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs @@ -0,0 +1,66 @@ +using BepInEx.Configuration; +using FinalSuspect.Attributes; +using FinalSuspect.Helpers; + +namespace FinalSuspect.Modules.Core.Plugin; + +public static class ConfigManager +{ + public static ConfigEntry KickPlayerWithAbnormalFriendCode { get; private set; } + public static ConfigEntry KickPlayerWithDenyName { get; private set; } + public static ConfigEntry KickPlayerInBanList { get; private set; } + public static ConfigEntry SpamDenyWord { get; private set; } + public static ConfigEntry UnlockFPS { get; private set; } + public static ConfigEntry SwitchOutfitType { get; private set; } + public static ConfigEntry AutoStartGame { get; private set; } + public static ConfigEntry AutoEndGame { get; private set; } + public static ConfigEntry DisableVanillaSound { get; private set; } + public static ConfigEntry EnableFAC { get; private set; } + public static ConfigEntry EnableGuardian { get; private set; } + public static ConfigEntry ShowPlayerInfo { get; private set; } + public static ConfigEntry FastLaunchMode { get; private set; } + public static ConfigEntry OfflineMode { get; private set; } + public static ConfigEntry UseModCursor { get; private set; } + public static ConfigEntry VersionCheat { get; private set; } + public static ConfigEntry GodMode { get; private set; } + public static ConfigEntry NoGameEnd { get; private set; } + public static ConfigEntry HideName { get; private set; } + public static ConfigEntry HideColor { get; private set; } + public static ConfigEntry ShowResults { get; private set; } + public static ConfigEntry EnableFinalSuspect { get; private set; } + public static ConfigEntry LanguageUpdateBypass { get; private set; } + public static ConfigEntry CurrentStyleId { get; private set; } + + [PluginModuleInitializer(InitializePriority.VeryHigh)] + public static void OnInitialization() + { + var config = Main.Instance.Config; + //Configs + HideName = config.Bind("Final System", "Hide Game Code Name", "Final Suspect"); + HideColor = config.Bind("Final System", "Hide Game Code Color", $"{ColorHelper.FSColorHex}"); + EnableFinalSuspect = config.Bind("Final System", "Enable Final Suspect", true); + ShowResults = config.Bind("Final System", "Show Results", true); + LanguageUpdateBypass = config.Bind("Final System", "Language Update Bypass", BypassType.Dont); + CurrentStyleId = config.Bind("Final System", "BG Id", 0); + + UnlockFPS = config.Bind("Client Options", "Unlock FPS", false); + SwitchOutfitType = config.Bind("Client Options", "Switch Outfit", OutfitType.BeanMode); + KickPlayerWithAbnormalFriendCode = config.Bind("Client Options", "Kick Player FriendCode Not Exist", true); + KickPlayerInBanList = config.Bind("Client Options", "Kick Player In BanList", true); + KickPlayerWithDenyName = config.Bind("Client Options", "Kick Player With Deny Name", true); + SpamDenyWord = config.Bind("Client Options", "Spam Deny Word", true); + AutoStartGame = config.Bind("Client Options", "Auto Start Game", false); + AutoEndGame = config.Bind("Client Options", "Auto End Game", false); + DisableVanillaSound = config.Bind("Client Options", "Disable Vanilla Sound", false); + EnableFAC = config.Bind("Client Options", "Enable FAC", false); + EnableGuardian = config.Bind("Client Options", "Enable Guardian", true); + ShowPlayerInfo = config.Bind("Client Options", "Show Player Info", true); + FastLaunchMode = config.Bind("Client Options", "Fast Launch Mode", false); + OfflineMode = config.Bind("Client Options", "Offline Mode", false); + UseModCursor = config.Bind("Client Options", "Use Mod Cursor", true); + + VersionCheat = config.Bind("Client Options", "Version Cheat", false); + GodMode = config.Bind("Client Options", "God Mode", false); + NoGameEnd = config.Bind("Client Options", "No Game End", false); + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/DebugModeManager.cs b/FinalSuspect/Modules/Core/Plugin/DebugModeManager.cs index 6545c1b..7b38d44 100644 --- a/FinalSuspect/Modules/Core/Plugin/DebugModeManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/DebugModeManager.cs @@ -6,13 +6,12 @@ public static class DebugModeManager // 同时,可在游戏内选项菜单中启用调试模式。 private static bool AmDebugger { get; set; } #if DEBUG - = true; + = true; #endif public static bool IsDebugMode => AmDebugger; - public static void Auth(HashAuth auth, string input) + public static void Auth() { - // AmDebugger = 启用调试版本 || 通过调试密钥认证 - AmDebugger = AmDebugger || auth.CheckString(input); + // 以后还会有用的 } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/Debugger.cs b/FinalSuspect/Modules/Core/Plugin/FinalLogger.cs similarity index 89% rename from FinalSuspect/Modules/Core/Plugin/Debugger.cs rename to FinalSuspect/Modules/Core/Plugin/FinalLogger.cs index 6db8d33..d7e6a80 100644 --- a/FinalSuspect/Modules/Core/Plugin/Debugger.cs +++ b/FinalSuspect/Modules/Core/Plugin/FinalLogger.cs @@ -1,47 +1,44 @@ using System; using System.Diagnostics; using System.IO; -using System.Net.Http; using System.Runtime.CompilerServices; +using FinalSuspect.Attributes; using FinalSuspect.Patches.Game_Vanilla; using LogLevel = BepInEx.Logging.LogLevel; namespace FinalSuspect.Modules.Core.Plugin; -internal class Webhook -{ - public static void Send(string text) - { - if (Main.WebhookURL.Value == "none") return; - HttpClient httpClient = new(); - Dictionary strs = new() - { - { "content", text }, - { "username", "FinalSuspect-Debugger" }, - { "avatar_url", "https://npm.elemecdn.com/hexo-static@1.0.1/img/avatar.webp" } - }; - var awaiter = httpClient.PostAsync( - Main.WebhookURL.Value, new FormUrlEncodedContent(strs)).GetAwaiter(); - awaiter.GetResult(); - } -} - internal static class FinalLogger { private static bool isEnable; private static readonly List disableList = []; private static readonly List sendToGameList = []; - public static bool isDetail = false; + public static bool isDetail; public static bool isAlsoInGame = false; - public static void Enable() + [PluginModuleInitializer(InitializePriority.VeryHigh)] + public static void OnInitialization() { - isEnable = true; + Main.Logger = BepInEx.Logging.Logger.CreateLogSource("FinalSuspect"); + Enable(); + Disable("SwitchSystem"); + Disable("ModNews"); + Disable("CancelPet"); + if (!DebugModeManager.IsDebugMode) + { + Disable("Download Resources"); + Disable("GetAnnouncements"); + Disable("GetConfigs"); + Disable("Get Remote"); + Disable("Downloader"); + } + + isDetail = DebugModeManager.IsDebugMode; } - public static void Disable() + public static void Enable() { - isEnable = false; + isEnable = true; } public static void Enable(string tag, bool toGame = false) @@ -51,6 +48,11 @@ public static void Enable(string tag, bool toGame = false) else sendToGameList.Remove(tag); } + public static void Disable() + { + isEnable = false; + } + public static void Disable(string tag) { if (!disableList.Contains(tag)) disableList.Add(tag); diff --git a/FinalSuspect/Modules/Core/Plugin/HashAuth.cs b/FinalSuspect/Modules/Core/Plugin/HashAuth.cs deleted file mode 100644 index e5ea6aa..0000000 --- a/FinalSuspect/Modules/Core/Plugin/HashAuth.cs +++ /dev/null @@ -1,76 +0,0 @@ -using System.Security.Cryptography; -using System.Text; - -namespace FinalSuspect.Modules.Core.Plugin; - -public class HashAuth(string hashValue, string salt = null, HashAlgorithm algorithm = null) -{ - private readonly HashAlgorithm algorithm = algorithm ?? SHA256.Create(); - - /// - /// 验证字符串是否匹配哈希值 - /// - public bool CheckString(string value) - { - var hash = CalculateHash(value); - return hashValue == hash; - } - - /// - /// 计算字符串的哈希值 - /// - private string CalculateHash(string source) - { - return CalculateHash(source, salt, algorithm); - } - - /// - /// 计算带盐值的哈希值 - /// - /// 源字符串 - /// 盐值 - /// 哈希算法实例 - private static string CalculateHash(string source, string salt, HashAlgorithm algorithm = null) - { - // 初始化算法 - algorithm ??= SHA256.Create(); - - // 添加盐值 - if (salt != null) source += salt; - - // 字符串转字节数组 - var sourceBytes = Encoding.UTF8.GetBytes(source); - - // 计算哈希值 - var hashBytes = algorithm.ComputeHash(sourceBytes); - - // 转换为十六进制字符串 - var sb = new StringBuilder(); - foreach (var b in hashBytes) - sb.Append(b.ToString("x2")); // 每个字节转为2位十六进制 - - return sb.ToString(); - } - - /// - /// 通过未哈希值创建验证器(仅用于测试) - /// - /// 原始值 - /// 盐值 - /// - /// 此方法会同时生成哈希值并输出日志,仅用于开发测试阶段 - /// - public static HashAuth CreateByUnhashedValue(string value, string salt = null) - { - // 计算哈希值 - var algorithm = SHA256.Create(); - var hashValue = CalculateHash(value, salt, algorithm); - - // 输出计算结果日志 - Info($"哈希值计算结果: {value} => {hashValue} {(salt == null ? "" : $"(salt: {salt})")}", "HashAuth"); - Warn("请将上方生成的值粘贴到源代码中", "HashAuth"); - - // 返回新实例 - return new HashAuth(hashValue, salt, algorithm); - } -} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs b/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs new file mode 100644 index 0000000..ede7ec1 --- /dev/null +++ b/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs @@ -0,0 +1,31 @@ +using FinalSuspect.Attributes; +using UnityEngine; + +namespace FinalSuspect.Modules.Core.Plugin; + +public class LaunchingInfo +{ + [PluginModuleInitializer(InitializePriority.Low)] + public static void OnInitialization() + { + Info($"{Application.version}", "AmongUs Version"); + + var handler = Handler("GitVersion"); + handler.Info($"{nameof(GitBaseTag)}: {GitBaseTag}"); + handler.Info($"{nameof(GitCommit)}: {GitCommit}"); + handler.Info($"{nameof(GitCommits)}: {GitCommits}"); + handler.Info($"{nameof(GitIsDirty)}: {GitIsDirty}"); + handler.Info($"{nameof(GitSha)}: {GitSha}"); + handler.Info($"{nameof(GitTag)}: {GitTag}"); + } + +#pragma warning disable CS0618 // 类型或成员已过时 + public const string GitBaseTag = ThisAssembly.Git.BaseTag; + public const string GitCommit = ThisAssembly.Git.Commit; + public const string GitCommits = ThisAssembly.Git.Commits; + public const string GitBranch = ThisAssembly.Git.Branch; + public const bool GitIsDirty = ThisAssembly.Git.IsDirty; + public const string GitSha = ThisAssembly.Git.Sha; + public const string GitTag = ThisAssembly.Git.Tag; +#pragma warning restore CS0618 +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs b/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs index effd894..86b3b8b 100644 --- a/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs @@ -1,3 +1,4 @@ +using TMPro; using UnityEngine; namespace FinalSuspect.Modules.Core.Plugin; @@ -35,4 +36,9 @@ public static class ModMainMenuManager public static Vector3 RightPanelOp = new(2.8f, -0.4f, -5.0f); public static Dictionary AllButtons = new(); public static bool Active = true; + public static GameObject OVersionShower; + public static TextMeshPro VisitText; + public static TextMeshPro CreditTextCredential; + public static GameObject ModLogo; + public static GameObject AuthorLogo; } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs index 135ffed..25a92bc 100644 --- a/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/RegistryManager.cs @@ -1,5 +1,6 @@ using System; using System.IO; +using FinalSuspect.Attributes; namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; @@ -23,7 +24,8 @@ public static string LastStartVersion set => PreferenceStore.SetString("Last launched version", value); } - public static void Init() + [PluginModuleInitializer(InitializePriority.High)] + public static void OnInitialization() { try { diff --git a/FinalSuspect/Modules/Core/Plugin/SystemEnvironment.cs b/FinalSuspect/Modules/Core/Plugin/SystemEnvironment.cs index f16e50a..9eefffb 100644 --- a/FinalSuspect/Modules/Core/Plugin/SystemEnvironment.cs +++ b/FinalSuspect/Modules/Core/Plugin/SystemEnvironment.cs @@ -1,10 +1,17 @@ using System; using System.Threading.Tasks; +using FinalSuspect.Attributes; namespace FinalSuspect.Modules.Core.Plugin; public static class SystemEnvironment { + [PluginModuleInitializer(InitializePriority.VeryLow)] + public static void OnInitialization() + { + Task.Run(SetEnvironmentVariablesAsync); + } + public static async Task SetEnvironmentVariablesAsync() { // 将最近打开的 FinalSuspect 应用程序文件夹的路径设置为用户环境变量 diff --git a/FinalSuspect/Modules/Features/CheckingandBlocking/BanManager.cs b/FinalSuspect/Modules/Features/CheckingandBlocking/BanManager.cs index d07a569..9ba501f 100644 --- a/FinalSuspect/Modules/Features/CheckingandBlocking/BanManager.cs +++ b/FinalSuspect/Modules/Features/CheckingandBlocking/BanManager.cs @@ -34,7 +34,7 @@ public static void AddBanPlayer(ClientData player) public static void CheckDenyNamePlayer(ClientData player) { - if (!AmongUsClient.Instance.AmHost || !Main.KickPlayerWithDenyName.Value) return; + if (!AmongUsClient.Instance.AmHost || !ConfigManager.KickPlayerWithDenyName.Value) return; try { var existingNames = SpamManager.ReturnAllNewLinesInFile(DENY_NAME_LIST_PATH); @@ -61,7 +61,7 @@ bool IsDevFriendCode(string name) => public static void CheckFriendCode(ClientData player) { - if (!AmongUsClient.Instance.AmHost || !Main.KickPlayerWithAbnormalFriendCode.Value) return; + if (!AmongUsClient.Instance.AmHost || !ConfigManager.KickPlayerWithAbnormalFriendCode.Value) return; //用于检测是否为xxx#1145/xxx#1337的重复代码前缀 //InnerSloth的好友代码不会出现前端重复 如果有前端重复一定是UE或者SM黑客 var currentPrefixes = AmongUsClient.Instance.allClients @@ -97,7 +97,7 @@ public static void CheckFriendCode(ClientData player) public static void CheckBanPlayer(ClientData player) { - if (!AmongUsClient.Instance.AmHost && !Main.KickPlayerInBanList.Value) return; + if (!AmongUsClient.Instance.AmHost && !ConfigManager.KickPlayerInBanList.Value) return; if (player.IsBannedPlayer() || DestroyableSingleton.Instance.IsPlayerBlockedUsername(player.FriendCode)) KickPlayer(player.Id, true, "BanedByBanList", KickLevel.CheatDetected); diff --git a/FinalSuspect/Modules/Features/CheckingandBlocking/RPC.cs b/FinalSuspect/Modules/Features/CheckingandBlocking/RPC.cs index d9181f1..f7d2173 100644 --- a/FinalSuspect/Modules/Features/CheckingandBlocking/RPC.cs +++ b/FinalSuspect/Modules/Features/CheckingandBlocking/RPC.cs @@ -139,7 +139,7 @@ private static void HandleCheckNameRpc(PlayerControl player, MessageReader reade var name = reader.ReadString(); Info("RPC Check Name For Player: " + name, "CheckName"); if (player.IsHost()) - Main.HostNickName = name; + FinalGameData.HostNickName = name; if (FinalPlayerData.AllPlayerData.All(data => data.PlayerId != player.PlayerId)) FinalPlayerData.CreateDataFor(player, name); } @@ -192,7 +192,7 @@ public static void Postfix(InnerNetObject __instance, [HarmonyArgument(0)] byte FinalGameData.PlayerVersion.PlayerVersions[id] = new FinalGameData.PlayerVersion(version, tag, forkId); - if (Main.VersionCheat.Value && AmongUsClient.Instance.AmHost) + if (ConfigManager.VersionCheat.Value && AmongUsClient.Instance.AmHost) FinalGameData.PlayerVersion.PlayerVersions[id] = FinalGameData.PlayerVersion.PlayerVersions[id]; @@ -241,14 +241,14 @@ public static async Task RpcVersionCheck() } if (PlayerControl.LocalPlayer == null || AmongUsClient.Instance == null) return; - if (!Main.VersionCheat.Value) + if (!ConfigManager.VersionCheat.Value) { var writer = AmongUsClient.Instance.StartRpcImmediately( PlayerControl.LocalPlayer.NetId, (byte)RpcCalls.CancelPet, SendOption.Reliable); writer.Write(Main.PluginVersion); - writer.Write($"{Main.GitCommit}({Main.GitBranch})"); + writer.Write($"{LaunchingInfo.GitCommit}({LaunchingInfo.GitBranch})"); writer.Write(Main.ForkId); AmongUsClient.Instance.FinishRpcImmediately(writer); } @@ -257,7 +257,7 @@ public static async Task RpcVersionCheck() FinalGameData.PlayerVersion.PlayerVersions[PlayerControl.LocalPlayer.GetClientId()] = new FinalGameData.PlayerVersion( Version.Parse(Main.PluginVersion), - $"{Main.GitCommit}({Main.GitBranch})", + $"{LaunchingInfo.GitCommit}({LaunchingInfo.GitBranch})", Main.ForkId ); } diff --git a/FinalSuspect/Modules/Features/CheckingandBlocking/SpamManager.cs b/FinalSuspect/Modules/Features/CheckingandBlocking/SpamManager.cs index 4f4e26b..7f48682 100644 --- a/FinalSuspect/Modules/Features/CheckingandBlocking/SpamManager.cs +++ b/FinalSuspect/Modules/Features/CheckingandBlocking/SpamManager.cs @@ -216,7 +216,7 @@ private static bool ShouldAddToFacList(string line) public static void CheckSpam(ref string text) { - if (!Main.SpamDenyWord.Value || BanWords.Count == 0) return; + if (!ConfigManager.SpamDenyWord.Value || BanWords.Count == 0) return; try { diff --git a/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs b/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs index 2a2facc..c359e12 100644 --- a/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs +++ b/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs @@ -159,7 +159,7 @@ public static void ShowSelectionPanel(MeetingHud __instance, PlayerControl pc) { var color = category switch { - CategoryType.Role => GetRoleColor(RoleTypes.Crewmate), + CategoryType.Role => RoleHelper.GetRoleColor(RoleTypes.Crewmate), CategoryType.PlayerIdentityTag => GetIdentityColor(IdentityTypes.Safe), CategoryType.Room => (Color)ColorHelper.ClientlessColor, _ => throw new ArgumentOutOfRangeException(nameof(category), category, null) @@ -222,7 +222,7 @@ void CreateOption(CategoryType category, string value) var color = category switch { - CategoryType.Role => GetRoleColor(Enum.Parse(value)), + CategoryType.Role => RoleHelper.GetRoleColor(Enum.Parse(value)), CategoryType.PlayerIdentityTag => GetIdentityColor(Enum.Parse(value)), CategoryType.Room => (Color)ColorHelper.ClientlessColor, _ => throw new ArgumentOutOfRangeException(nameof(category), category, null) diff --git a/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs b/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs index 80ae064..edcd2c0 100644 --- a/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs +++ b/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs @@ -70,11 +70,11 @@ public static void SetRoleInfoRef(PlayerControl player) builder.AppendFormat("\n", BlankLineSize); // 职业名 var role = player.Data.Role.Role; - builder.Append($"{GetRoleName(role).Color(GetRoleColor(role))}"); + builder.Append($"{RoleHelper.GetRoleName(role).Color(RoleHelper.GetRoleColor(role))}"); // 职业阵营 / 原版职业 var roleTeam = player.IsImpostor() ? "Imp" : "Crew"; builder.Append($" ({GetString($"RoleType.{roleTeam}")})\n"); - builder.Append($"{player.GetRoleType().GetRoleInfoForVanilla(true) ?? ""}\n"); + builder.Append($"{RoleHelper.GetRoleInfoForVanilla(player.GetRoleType(), true) ?? ""}\n"); RoleInfoTMP.text = builder.ToString(); var HnSPrefix = ""; if (!IsNormalGame && player.IsAlive()) diff --git a/FinalSuspect/Modules/Features/Zoom.cs b/FinalSuspect/Modules/Features/Zoom.cs index 0460170..96f06d2 100644 --- a/FinalSuspect/Modules/Features/Zoom.cs +++ b/FinalSuspect/Modules/Features/Zoom.cs @@ -36,7 +36,7 @@ public static void Postfix() case < 0: { if (IsDead || IsFreePlay || - DebugModeManager.IsDebugMode || IsLobby || Main.GodMode.Value) + DebugModeManager.IsDebugMode || IsLobby || ConfigManager.GodMode.Value) if (Camera.main?.orthographicSize < 18.0f) SetZoomSize(true); break; diff --git a/FinalSuspect/Modules/Random/IRandom.cs b/FinalSuspect/Modules/Random/IRandom.cs index c1ae573..0e1bc87 100644 --- a/FinalSuspect/Modules/Random/IRandom.cs +++ b/FinalSuspect/Modules/Random/IRandom.cs @@ -1,4 +1,5 @@ using System; +using FinalSuspect.Attributes; namespace FinalSuspect.Modules.Random; @@ -42,4 +43,10 @@ public static void SetInstanceById(int id) Warn($"无效ID: {id}", "IRandom.SetInstanceById"); } } + + [PluginModuleInitializer] + public static void OnInitialization() + { + SetInstance(new NetRandomWrapper()); + } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Resources/ModUpdater.cs b/FinalSuspect/Modules/Resources/ModUpdater.cs index 14bc8b6..bcfe3d3 100644 --- a/FinalSuspect/Modules/Resources/ModUpdater.cs +++ b/FinalSuspect/Modules/Resources/ModUpdater.cs @@ -1,3 +1,4 @@ +#if Windows using System; using System.IO; using System.Security.Cryptography; @@ -5,8 +6,9 @@ using System.Threading; using System.Threading.Tasks; using FinalSuspect.Modules.Features; -using TMPro; using UnityEngine; +#endif +using TMPro; namespace FinalSuspect.Modules.Resources; @@ -28,6 +30,7 @@ public static void SetUpdateButtonStatus() public static void StartUpdate(string url = "waitToSelect") { +#if Windows if (url == "waitToSelect") { List<(string, Action)> btns = @@ -145,5 +148,6 @@ private static string GetMD5HashFromFile(string fileName) Exception(ex, "GetMD5HashFromFile"); return ""; } +#endif } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Resources/PathManager.cs b/FinalSuspect/Modules/Resources/PathManager.cs index ada49da..be25420 100644 --- a/FinalSuspect/Modules/Resources/PathManager.cs +++ b/FinalSuspect/Modules/Resources/PathManager.cs @@ -10,9 +10,9 @@ public static class PathManager #if Android private static readonly string LocalPath_Data = Application.persistentDataPath + "/FinalSuspect_Data/"; public static readonly string LANGUAGE_FOLDER_NAME = LocalPath_Data + "Language"; - private static readonly string DependsSavePath = LocalPath_Data + "Depend"; + private static readonly string DependsSavePath = LocalPath_Data + "Depend/"; public static readonly string BAN_LIST_PATH = LocalPath_Data + "BanList.txt"; - public const string BepInExPath = "/data/data/dev.allofus.starlight/files/BepInEx/" + public const string BepInExPath = "/data/data/dev.allofus.starlight/files/BepInEx/"; #else private const string LocalPath_Data = "Final Suspect_Data/"; public const string LANGUAGE_FOLDER_NAME = LocalPath_Data + "Language"; @@ -22,9 +22,8 @@ public static class PathManager #if Android - public static readonly string BepInLogOutPutPath = BepInExPath + "LogOutput.log"; - public static readonly string BepInCorePath = BepInExPath + "core"; - public static readonly string BepInLogOutPutPath = BepInExPath + "/BepInEx/LogOutput.log"; + public const string BepInLogOutPutPath = BepInExPath + "LogOutput.log"; + public const string BepInCorePath = BepInExPath + "core/"; #else public const string DownloadFileTempPath = "BepInEx/plugins/FinalSuspect.dll.temp"; public static readonly string BepInLogOutPutPath = $"{Environment.CurrentDirectory}/BepInEx/LogOutput.log"; @@ -33,7 +32,7 @@ public static class PathManager public static readonly string FSLogOutPutPath = $"{Application.persistentDataPath}/FinalSuspect/Logs"; public static readonly string AutoLogOutPutPath = FSLogOutPutPath + "/AutoLogs"; - // 下载URL保持不变 +#if Windows public const string DownloadUrl_Github = "https://github.com/Slok7565/FinalSuspect/releases/latest/download/FinalSuspect.dll"; @@ -42,7 +41,8 @@ public static class PathManager public const string DownloadUrl_FangKuaiRemote = "https://dlhk.fangkuai.fun/FinalSuspect/FinalSuspect.dll"; - + // 下载URL保持不变 +#endif public static readonly string BANEDWORDS_FILE_PATH = GetBanFilesPath("BanWords.json"); public static readonly string DENY_NAME_LIST_PATH = GetBanFilesPath("DenyName.json"); @@ -148,6 +148,9 @@ public static void InitializePaths() CheckAndCreate(GetLocalPath(LocalType.Resources) + "SoundEffects"); CheckAndCreate(GetLocalPath(LocalType.Resources) + "Images"); CheckAndCreate(GetLocalPath(LocalType.Resources) + "Languages", false); +#if Android + CheckAndCreate(DependsSavePath); +#endif CheckAndCreate(LANGUAGE_FOLDER_NAME, false); CheckAndCreate(GetLocalPath(LocalType.Ban)); diff --git a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs index 7f035ee..86cc373 100644 --- a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs +++ b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs @@ -5,7 +5,7 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; namespace FinalSuspect.Modules.Resources; diff --git a/FinalSuspect/Modules/Resources/VersionChecker.cs b/FinalSuspect/Modules/Resources/VersionChecker.cs index 2486f69..07a62af 100644 --- a/FinalSuspect/Modules/Resources/VersionChecker.cs +++ b/FinalSuspect/Modules/Resources/VersionChecker.cs @@ -1,8 +1,8 @@ using System; using System.Threading; using System.Threading.Tasks; -using FinalSuspect.ClientActions.FeatureItems.NameTag; -using FinalSuspect.ClientActions.FeatureItems.Resources; +using FinalSuspect.ClientItems.FeatureItems.NameTag; +using FinalSuspect.ClientItems.FeatureItems.Resources; using FinalSuspect.Helpers; using FinalSuspect.Modules.Features; using FinalSuspect.Modules.Features.CheckingandBlocking; @@ -72,7 +72,10 @@ private static void Retry() private static async Task CheckForUpdate() { IsChecked = false; - ModUpdater.DeleteOldFiles(); +#if Windows + ModUpdater.DeleteOldFiles(); +#endif + foreach (var url in GetInfoFileUrlList(true)) { @@ -119,7 +122,7 @@ private static async Task CheckForUpdate() } ModUpdater.SetUpdateButtonStatus(); - VersionShowerStartPatch.VisitText.text = IsChecked + ModMainMenuManager.VisitText.text = IsChecked ? string.Format(GetString("FinalSuspectWelcomeText"), ColorHelper.FSColorHex) : GetString("RetrieveVersionInfoFailed"); }, "Check For Update"); @@ -181,7 +184,7 @@ public class Start public static void Postfix() { CustomPopup.Init(); - if (FirstStart && !Main.OfflineMode.Value) + if (FirstStart && !ConfigManager.OfflineMode.Value) { StartTasks(); CustomPopup.Show(GetString("UpdateCheck.Popup_Title"), GetString("Tip.LoadingWithDot"), null); diff --git a/FinalSuspect/Patches/Game_Vanilla/EndGameManagerPatch.cs b/FinalSuspect/Patches/Game_Vanilla/EndGameManagerPatch.cs index dc96f51..974fb5e 100644 --- a/FinalSuspect/Patches/Game_Vanilla/EndGameManagerPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/EndGameManagerPatch.cs @@ -7,7 +7,7 @@ public class EndGameManagerPatch [HarmonyPostfix] public static void ShowButtons_Postfix(EndGameManager __instance) { - if (!Main.AutoEndGame.Value) return; + if (!ConfigManager.AutoEndGame.Value) return; DestroyableSingleton.Instance.ContinueButton.gameObject.SetActive(false); _ = new LateTask(__instance.Navigation.NextGame, 2f, "Auto End Game"); } @@ -21,6 +21,6 @@ public class GameEndChecker [HarmonyPrefix] public static bool CheckEndCriteria() { - return !(Main.NoGameEnd.Value && DebugModeManager.IsDebugMode); + return !(ConfigManager.NoGameEnd.Value && DebugModeManager.IsDebugMode); } } \ No newline at end of file diff --git a/FinalSuspect/Patches/Game_Vanilla/Guardian.cs b/FinalSuspect/Patches/Game_Vanilla/Guardian.cs index 85f922f..9b62796 100644 --- a/FinalSuspect/Patches/Game_Vanilla/Guardian.cs +++ b/FinalSuspect/Patches/Game_Vanilla/Guardian.cs @@ -12,7 +12,8 @@ public static class HandleGameDataPatch { public static bool Prefix(InnerNetClient __instance, [HarmonyArgument(0)] MessageReader parentReader) { - if (!IsLobby || IsNotJoined || !FinalGameData.JoinedCompleted || !Main.EnableGuardian.Value) return true; + if (!IsLobby || IsNotJoined || !FinalGameData.JoinedCompleted || + !ConfigManager.EnableGuardian.Value) return true; try { @@ -36,7 +37,8 @@ public static class HandleGameDataInnerPatch public static bool Prefix(InnerNetClient._HandleGameDataInner_d__165 __instance) { - if (!IsLobby || IsNotJoined || !FinalGameData.JoinedCompleted || !Main.EnableGuardian.Value) return true; + if (!IsLobby || IsNotJoined || !FinalGameData.JoinedCompleted || + !ConfigManager.EnableGuardian.Value) return true; var reader = __instance.reader; if (reader.BytesRemaining < 1) { @@ -170,7 +172,8 @@ internal class HandleMessagePatch public static bool Prefix(InnerNetServer.Player client, MessageReader reader) { - if (!IsLobby || IsNotJoined || !FinalGameData.JoinedCompleted || !Main.EnableGuardian.Value) return true; + if (!IsLobby || IsNotJoined || !FinalGameData.JoinedCompleted || + !ConfigManager.EnableGuardian.Value) return true; if (!playerMsgCounters.TryGetValue(client.Id, out var counter)) { diff --git a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs index a6bb950..e44d5bb 100644 --- a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs @@ -41,8 +41,8 @@ public static void Postfix(TaskPanelBehaviour __instance) var taskText = __instance.taskText.text; if (taskText == "None") return; - var RoleWithInfo = $"{GetRoleName(role)}:\r\n"; - RoleWithInfo += role.GetRoleInfoForVanilla(); + var RoleWithInfo = $"{RoleHelper.GetRoleName(role)}:\r\n"; + RoleWithInfo += RoleHelper.GetRoleInfoForVanilla(role); var AllText = StringHelper.ColorString(player.GetRoleColor(), RoleWithInfo); @@ -152,7 +152,7 @@ private static void SetChatBG(HudManager __instance) if (PlayerControl.LocalPlayer.IsImpostor()) color = ColorHelper.ImpostorRedPale; else - color = GetRoleColor(RoleTypes.Crewmate); + color = RoleHelper.GetRoleColor(RoleTypes.Crewmate); } else { @@ -174,7 +174,7 @@ private static void SetAbilityButtonColor(HudManager __instance) if (!IsInGame) return; var role = PlayerControl.LocalPlayer.GetRoleType(); - var color = GetRoleColor(role); + var color = RoleHelper.GetRoleColor(role); __instance.AbilityButton.buttonLabelText.SetOutlineColor(color); __instance.AbilityButton.cooldownTimerText.color = color; __instance.SecondaryAbilityButton.buttonLabelText.SetOutlineColor(color); @@ -223,7 +223,7 @@ private static void UpdateResult(HudManager __instance) { if (IsFreePlay || (!IsInGame && GetLineCount(FinalGameData.LastResultText) < 6)) return; - var showInitially = Main.ShowResults.Value; + var showInitially = ConfigManager.ShowResults.Value; showHideButton ??= new SimpleButton( @@ -238,7 +238,7 @@ private static void UpdateResult(HudManager __instance) { var setToActive = !roleSummary.gameObject.activeSelf; roleSummary.gameObject.SetActive(setToActive); - Main.ShowResults.Value = setToActive; + ConfigManager.ShowResults.Value = setToActive; showHideButton.Label.text = GetString(setToActive ? "Summary.HideResults" : "Summary.ShowResults"); }, GetString(showInitially ? "Summary.HideResults" : "Summary.ShowResults")) diff --git a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs index 4035512..19b11af 100644 --- a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs @@ -27,7 +27,7 @@ public static void Postfix(IntroCutscene._ShowRole_d__41 __instance, ref bool __ public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __result) #endif { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; var intro = __instance.__4__this; _ = new MainThreadTask(() => @@ -35,12 +35,12 @@ public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __ var roleType = PlayerControl.LocalPlayer.Data.Role.Role; intro.YouAreText.color = intro.RoleText.color = - intro.RoleBlurbText.color = GetRoleColor(roleType); - intro.RoleText.text = GetRoleName(roleType); + intro.RoleBlurbText.color = RoleHelper.GetRoleColor(roleType); + intro.RoleText.text = RoleHelper.GetRoleName(roleType); intro.RoleText.fontWeight = FontWeight.Thin; - intro.RoleText.SetOutlineColor(GetRoleColor(roleType).ShadeColor(0.1f).SetAlpha(0.38f)); + intro.RoleText.SetOutlineColor(RoleHelper.GetRoleColor(roleType).ShadeColor(0.1f).SetAlpha(0.38f)); intro.RoleText.SetOutlineThickness(0.17f); - intro.RoleBlurbText.text = roleType.GetRoleInfoForVanilla(); + intro.RoleBlurbText.text = RoleHelper.GetRoleInfoForVanilla(roleType); }, "Override Role Text"); } @@ -48,7 +48,7 @@ public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __ [HarmonyPostfix] public static void BeginImpostor_Postfix(IntroCutscene __instance) { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; __instance.ImpostorText.gameObject.SetActive(true); @@ -74,7 +74,7 @@ public static void BeginImpostor_Postfix(IntroCutscene __instance) [HarmonyPostfix] public static void BeginCrewmate_Postfix(IntroCutscene __instance) { - if (!Main.EnableFinalSuspect.Value) return; + if (!ConfigManager.EnableFinalSuspect.Value) return; __instance.TeamTitle.text = $"{GetString("Team.Crew")}"; __instance.ImpostorText.text = diff --git a/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs b/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs index ad50205..c17b0f5 100644 --- a/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs @@ -1,4 +1,5 @@ -using TMPro; +using FinalSuspect.DataHandling.FinalGameData; +using TMPro; using UnityEngine; using Object = UnityEngine.Object; @@ -32,7 +33,7 @@ public static void Postfix(HostInfoPanel __instance) HostText = __instance.content.transform.FindChild("Name").GetComponent(); var htmlStringRgb = ColorUtility.ToHtmlStringRGB(Palette.PlayerColors[__instance.player.ColorId]); - var hostName = Main.HostNickName; + var hostName = FinalGameData.HostNickName; var youLabel = DestroyableSingleton.Instance.GetString(StringNames.HostYouLabel); HostText.text = diff --git a/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs index 2af96b2..f5258fe 100644 --- a/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs @@ -40,7 +40,7 @@ public static void Prefix() public static void Postfix(EndGameManager __instance) { - var showInitially = Main.ShowResults.Value; + var showInitially = ConfigManager.ShowResults.Value; var WinnerTextObject = Object.Instantiate(__instance.WinText.gameObject); WinnerTextObject.transform.position = new Vector3(__instance.WinText.transform.position.x, @@ -69,7 +69,7 @@ public static void Postfix(EndGameManager __instance) { var setToActive = !roleSummary.gameObject.activeSelf; roleSummary.gameObject.SetActive(setToActive); - Main.ShowResults.Value = setToActive; + ConfigManager.ShowResults.Value = setToActive; __instance.WinText.gameObject.SetActive(!setToActive); WinnerTextObject.SetActive(!setToActive); showHideButton.Label.text = GetString(setToActive ? "Summary.HideResults" : "Summary.ShowResults"); diff --git a/FinalSuspect/Patches/System/AprilFoolsModePatch.cs b/FinalSuspect/Patches/System/AprilFoolsModePatch.cs index 6ca7872..2df3bd2 100644 --- a/FinalSuspect/Patches/System/AprilFoolsModePatch.cs +++ b/FinalSuspect/Patches/System/AprilFoolsModePatch.cs @@ -12,7 +12,7 @@ public static class GetNormalBodyTypePatch { public static void Postfix(ref PlayerBodyTypes __result) { - switch (Main.SwitchOutfitType.Value) + switch (ConfigManager.SwitchOutfitType.Value) { case OutfitType.HorseMode: __result = PlayerBodyTypes.Horse; @@ -34,7 +34,7 @@ public static class GetHnsBodyTypePatch public static void Postfix(ref PlayerBodyTypes __result, [HarmonyArgument(0)] PlayerControl player) { if (player == null || player.Data == null || player.Data.Role == null) - switch (Main.SwitchOutfitType.Value) + switch (ConfigManager.SwitchOutfitType.Value) { case OutfitType.HorseMode: __result = PlayerBodyTypes.Horse; @@ -48,7 +48,7 @@ public static void Postfix(ref PlayerBodyTypes __result, [HarmonyArgument(0)] Pl return; } - switch (Main.SwitchOutfitType.Value) + switch (ConfigManager.SwitchOutfitType.Value) { case OutfitType.HorseMode when player.Data.Role.IsImpostor: __result = PlayerBodyTypes.Normal; diff --git a/FinalSuspect/Patches/System/ClientPatch.cs b/FinalSuspect/Patches/System/ClientPatch.cs index f5fe68e..67e8602 100644 --- a/FinalSuspect/Patches/System/ClientPatch.cs +++ b/FinalSuspect/Patches/System/ClientPatch.cs @@ -18,7 +18,7 @@ internal class MakePublicPatch { public static bool Prefix() { - if (Main.OfflineMode.Value) return true; + if (ConfigManager.OfflineMode.Value) return true; if (!VersionChecker.IsBroken && (!VersionChecker.HasUpdate || !VersionChecker.ForceUpdate) && VersionChecker.IsSupported) return true; var message = ""; diff --git a/FinalSuspect/Patches/System/ControlPatch.cs b/FinalSuspect/Patches/System/ControlPatch.cs index c339b4a..3745c47 100644 --- a/FinalSuspect/Patches/System/ControlPatch.cs +++ b/FinalSuspect/Patches/System/ControlPatch.cs @@ -84,12 +84,12 @@ public static void Postfix() { if (IsNotJoined) { - VersionShowerStartPatch.ModLogo.SetActive(ModMainMenuManager.Active); - VersionShowerStartPatch.AuthorLogo.SetActive(ModMainMenuManager.Active); + ModMainMenuManager.ModLogo.SetActive(ModMainMenuManager.Active); + ModMainMenuManager.AuthorLogo.SetActive(ModMainMenuManager.Active); ModMainMenuManager.Active = !ModMainMenuManager.Active; ModMainMenuManager.Instance.mainMenuUI.SetActive(ModMainMenuManager.Active); - VersionShowerStartPatch.CreditTextCredential.gameObject.SetActive(ModMainMenuManager.Active); - VersionShowerStartPatch.VisitText.gameObject.SetActive(ModMainMenuManager.Active); + ModMainMenuManager.CreditTextCredential.gameObject.SetActive(ModMainMenuManager.Active); + ModMainMenuManager.VisitText.gameObject.SetActive(ModMainMenuManager.Active); DestroyableSingleton.Instance.gameObject.SetActive(ModMainMenuManager.Active); ModMainMenuManager.ModStamp.SetActive(ModMainMenuManager.Active); } diff --git a/FinalSuspect/Patches/System/CredentialsPatch.cs b/FinalSuspect/Patches/System/CredentialsPatch.cs index dad0c63..df52fb7 100644 --- a/FinalSuspect/Patches/System/CredentialsPatch.cs +++ b/FinalSuspect/Patches/System/CredentialsPatch.cs @@ -1,8 +1,8 @@ using System.Text; -using FinalSuspect.ClientActions; -using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; -using FinalSuspect.ClientActions.FeatureItems.NameTag; +using FinalSuspect.ClientItems; +using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.NameTag; using FinalSuspect.Helpers; using FinalSuspect.Modules.Resources; using FinalSuspect.Patches.Game_Vanilla; @@ -57,7 +57,8 @@ public static void Postfix(PingTracker __instance) (GameSettingMenu.Instance?.gameObject.active ?? false) || IsInMeeting || (FriendsListUI.Instance?.gameObject.active ?? false) - || ((HudManagerPatch.showHideButton?.Button?.gameObject.active ?? false) && Main.ShowResults.Value)) + || ((HudManagerPatch.showHideButton?.Button?.gameObject.active ?? false) && + ConfigManager.ShowResults.Value)) _creditTextCredential.text = ""; var ping = AmongUsClient.Instance.Ping; @@ -84,13 +85,7 @@ public static void Postfix(PingTracker __instance) [HarmonyPatch(typeof(VersionShower), nameof(VersionShower.Start))] public class VersionShowerStartPatch { - public static GameObject OVersionShower; - public static TextMeshPro VisitText; - public static TextMeshPro CreditTextCredential; - public static GameObject ModLogo; - public static GameObject AuthorLogo; - - private static VersionShower _instance; + private static VersionShower Instance; public static void Postfix(VersionShower __instance) { @@ -113,7 +108,8 @@ public static void Postfix(VersionShower __instance) } #endif #if !RELEASE - Main.CredentialsText += $"\r\n{Main.GitBranch} - {Main.GitCommit}"; + Main.CredentialsText += + $"\r\n{LaunchingInfo.GitBranch} - {LaunchingInfo.GitCommit}"; #endif if (Main.IsAprilFools) @@ -140,7 +136,8 @@ public static void Postfix(VersionShower __instance) $"Slok"); credentialsText += "\n"; #if DEBUG - var versionText = $"{Main.GitBranch} - {Main.GitCommit}"; + var versionText = + $"{LaunchingInfo.GitBranch} - {LaunchingInfo.GitCommit}"; #elif RELEASE var versionText = $"FS - v{Main.DisplayedVersion}"; @@ -205,9 +202,9 @@ public static void Postfix(VersionShower __instance) public static void CreateVisitText(VersionShower __instance) { if (!__instance) - __instance = _instance; + __instance = Instance; else - _instance = __instance; + Instance = __instance; VisitText = Object.Instantiate(__instance.text, OVersionShower.transform.parent); VisitText.name = "FinalSuspect VisitText"; @@ -243,7 +240,7 @@ public static void Postfix(MainMenuManager __instance) Color shade = new(0f, 0f, 0f, 0f); var standardActiveSprite = __instance.newsButton.activeSprites.GetComponent().sprite; var minorActiveSprite = __instance.quitButton.activeSprites.GetComponent().sprite; - var style = MainMenuStyleManager.MainMenuStyles[Main.CurrentStyleId.Value]; + var style = MainMenuStyleManager.MainMenuStyles[ConfigManager.CurrentStyleId.Value]; var friendsButton = FriendsButton.GetComponent(); Dictionary, (Sprite, Color, Color, Color, Color)> mainButtons = new() @@ -424,7 +421,7 @@ public static void Postfix(ModManager __instance) private static void OnSceneChange(string name) { if (name is not "MainMenu" and not "MatchMaking") return; - var style = MainMenuStyleManager.MainMenuStyles[Main.CurrentStyleId.Value]; + var style = MainMenuStyleManager.MainMenuStyles[ConfigManager.CurrentStyleId.Value]; var audio = FinalMusic.Musics.FirstOrDefault(x => x.CurrentAudio == style.MainMenuMusic); if (audio != null) { diff --git a/FinalSuspect/Patches/System/GameOptionPatch.cs b/FinalSuspect/Patches/System/GameOptionPatch.cs index fc8d13d..18ea067 100644 --- a/FinalSuspect/Patches/System/GameOptionPatch.cs +++ b/FinalSuspect/Patches/System/GameOptionPatch.cs @@ -10,7 +10,7 @@ internal class RoleOptionSettingPatch { public static void Postfix(RoleOptionSetting __instance) { - var roleColor = GetRoleColor(__instance.Role.Role); + var roleColor = RoleHelper.GetRoleColor(__instance.Role.Role); __instance.labelSprite.color = roleColor.ShadeColor(0.2f); __instance.titleText.color = Color.white; } @@ -21,16 +21,16 @@ internal class RolesSettingsMenuPatch { private static readonly List rolecolors = [ - GetRoleColor(RoleTypes.Scientist), - GetRoleColor(RoleTypes.GuardianAngel), - GetRoleColor(RoleTypes.Engineer), - - GetRoleColor(RoleTypes.Noisemaker), - GetRoleColor(RoleTypes.Tracker), - GetRoleColor(RoleTypes.Detective), - GetRoleColor(RoleTypes.Shapeshifter), - GetRoleColor(RoleTypes.Phantom), - GetRoleColor(RoleTypes.Viper) + RoleHelper.GetRoleColor(RoleTypes.Scientist), + RoleHelper.GetRoleColor(RoleTypes.GuardianAngel), + RoleHelper.GetRoleColor(RoleTypes.Engineer), + + RoleHelper.GetRoleColor(RoleTypes.Noisemaker), + RoleHelper.GetRoleColor(RoleTypes.Tracker), + RoleHelper.GetRoleColor(RoleTypes.Detective), + RoleHelper.GetRoleColor(RoleTypes.Shapeshifter), + RoleHelper.GetRoleColor(RoleTypes.Phantom), + RoleHelper.GetRoleColor(RoleTypes.Viper) ]; public static void Postfix() @@ -57,7 +57,9 @@ private static void ConfigureHeaderButtons() var index = 0; foreach (var button in headerbuttons) { - var roleColor = index <= 5 ? GetRoleColor(RoleTypes.Crewmate) : GetRoleColor(RoleTypes.Impostor); + var roleColor = index <= 5 + ? RoleHelper.GetRoleColor(RoleTypes.Crewmate) + : RoleHelper.GetRoleColor(RoleTypes.Impostor); SetColor(button, rolecolors[index], roleColor); index++; } @@ -104,16 +106,16 @@ internal class GameOptionsMenuPatch { private static readonly List normalbannercolors = [ - GetRoleColor(RoleTypes.Impostor), - GetRoleColor(RoleTypes.Crewmate), + RoleHelper.GetRoleColor(RoleTypes.Impostor), + RoleHelper.GetRoleColor(RoleTypes.Crewmate), Color.yellow, Color.green ]; private static readonly List hnSbannercolors = [ - GetRoleColor(RoleTypes.Crewmate), - GetRoleColor(RoleTypes.Impostor), + RoleHelper.GetRoleColor(RoleTypes.Crewmate), + RoleHelper.GetRoleColor(RoleTypes.Impostor), Palette.Purple, Color.green ]; diff --git a/FinalSuspect/Patches/System/GameStartManagerPatch.cs b/FinalSuspect/Patches/System/GameStartManagerPatch.cs index 7a44db4..0c65ae1 100644 --- a/FinalSuspect/Patches/System/GameStartManagerPatch.cs +++ b/FinalSuspect/Patches/System/GameStartManagerPatch.cs @@ -65,9 +65,9 @@ public static void Postfix(GameStartManager __instance) _hideName.gameObject.SetActive(true); _hideName.name = "HideName"; _hideName.color = - ColorUtility.TryParseHtmlString(Main.HideColor.Value, out var color) ? color : + ColorUtility.TryParseHtmlString(ConfigManager.HideColor.Value, out var color) ? color : ColorUtility.TryParseHtmlString(ColorHelper.FSColorHex, out var modColor) ? modColor : _hideName.color; - _hideName.text = Main.HideName.Value; + _hideName.text = ConfigManager.HideName.Value; _warningText = Object.Instantiate(__instance.GameStartText, __instance.transform); _warningText.name = "WarningText"; @@ -139,7 +139,7 @@ public static bool Prefix(GameStartManager __instance) _hideName.enabled = false; } - if (!Main.AutoStartGame.Value + if (!ConfigManager.AutoStartGame.Value || !AmongUsClient.Instance.AmHost || GameStartManager.Instance.startState == GameStartManager.StartingStates.Starting || IsInitGame) return true; diff --git a/FinalSuspect/Patches/System/LoadPatch.cs b/FinalSuspect/Patches/System/LoadPatch.cs index 6a5d117..e96cd9b 100644 --- a/FinalSuspect/Patches/System/LoadPatch.cs +++ b/FinalSuspect/Patches/System/LoadPatch.cs @@ -2,8 +2,8 @@ using System.Collections; using System.IO; using BepInEx.Unity.IL2CPP.Utils; -using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; -using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Plugin.RegistryManager; using FinalSuspect.Modules.Resources; @@ -124,10 +124,10 @@ private static void HandleFirstLaunchText() private static IEnumerator HandleCoreLoadingProcess(SplashManager instance) { - var fastLaunchMode = (CheckFastLaunchModeCondition() || Main.OfflineMode.Value) && !_firstLaunch; - Main.FastLaunchMode.Value = fastLaunchMode; + var fastLaunchMode = (CheckFastLaunchModeCondition() || ConfigManager.OfflineMode.Value) && !_firstLaunch; + ConfigManager.FastLaunchMode.Value = fastLaunchMode; if (!fastLaunchMode) - Main.OfflineMode.Value = false; + ConfigManager.OfflineMode.Value = false; yield return fastLaunchMode ? HandleFastLaunchMode() : HandleNormalBoot(); @@ -140,8 +140,9 @@ private static IEnumerator HandleCoreLoadingProcess(SplashManager instance) private static bool CheckFastLaunchModeCondition() { - var currentVersion = $"{Main.PluginVersion}|{Main.DisplayedVersion}|{Main.GitCommit}-{Main.GitBranch}"; - var bypassType = Main.LanguageUpdateBypass.Value; + var currentVersion = + $"{Main.PluginVersion}|{Main.DisplayedVersion}|{LaunchingInfo.GitCommit}-{LaunchingInfo.GitBranch}"; + var bypassType = ConfigManager.LanguageUpdateBypass.Value; _reloadLanguage = currentVersion != RegistryManager.LastStartVersion && bypassType == BypassType.Dont; @@ -151,7 +152,7 @@ private static bool CheckFastLaunchModeCondition() RegistryManager.LastStartVersion = currentVersion; break; case BypassType.Once: - Main.LanguageUpdateBypass.Value = BypassType.Dont; + ConfigManager.LanguageUpdateBypass.Value = BypassType.Dont; break; case BypassType.LongTerm: default: @@ -160,7 +161,7 @@ private static bool CheckFastLaunchModeCondition() CheckForListResources(ref ResourcesHelper.RemoteDependList, FileType.Depends); - return Main.FastLaunchMode.Value && !_reloadLanguage && ResourcesHelper.RemoteDependList.Count == 0; + return ConfigManager.FastLaunchMode.Value && !_reloadLanguage && ResourcesHelper.RemoteDependList.Count == 0; } #endregion @@ -172,15 +173,15 @@ private static IEnumerator HandleFastLaunchMode() SetFastLaunchModeVisuals(); TranslatorInit(); AudioManager.ReloadTag(); - var style = MainMenuStyleManager.MainMenuStyles[Main.CurrentStyleId.Value]; + var style = MainMenuStyleManager.MainMenuStyles[ConfigManager.CurrentStyleId.Value]; var audio = FinalMusic.Musics.FirstOrDefault(x => x.CurrentAudio == style.MainMenuMusic); if (audio != null) AudioPlayer.Play(audio, true); UpdateProcessText( - GetString(Main.OfflineMode.Value ? "ClientOption.OfflineMode" : "ClientOption.FastLaunchMode"), - Main.OfflineMode.Value ? Color.gray : Color.green); + GetString(ConfigManager.OfflineMode.Value ? "ClientOption.OfflineMode" : "ClientOption.FastLaunchMode"), + ConfigManager.OfflineMode.Value ? Color.gray : Color.green); yield return new WaitForSeconds(1f); _skipLoadAnimation = true; } @@ -195,7 +196,7 @@ private static void SetFastLaunchModeVisuals() _modLogo.transform.localPosition = new Vector3(0, 0, -5f); _modLogo.transform.localScale = new Vector3(1.5f, 1.5f, 1f); - _glow.color = Main.OfflineMode.Value ? Color.gray : Color.green; + _glow.color = ConfigManager.OfflineMode.Value ? Color.gray : Color.green; } private static IEnumerator HandleNormalBoot() @@ -267,12 +268,11 @@ private static IEnumerator ShowLoadingProgress() private static IEnumerator LoadEssentialResources(SplashManager instance) { - yield return LoadAmongUsTranslation(); - - if (Main.FastLaunchMode.Value) + if (ConfigManager.FastLaunchMode.Value) { + yield return LoadAmongUsTranslation(); FinishSceneLoad(instance); - if (Main.OfflineMode.Value) + if (ConfigManager.OfflineMode.Value) yield break; } @@ -292,10 +292,11 @@ private static IEnumerator LoadEssentialResources(SplashManager instance) { TranslatorInit(); AudioManager.ReloadTag(); - var style = MainMenuStyleManager.MainMenuStyles[Main.CurrentStyleId.Value]; + var style = MainMenuStyleManager.MainMenuStyles[ConfigManager.CurrentStyleId.Value]; var audio = FinalMusic.Musics.FirstOrDefault(x => x.CurrentAudio == style.MainMenuMusic); if (audio != null) AudioPlayer.Play(audio, true); + yield return LoadAmongUsTranslation(); } } @@ -417,7 +418,7 @@ private static void CheckForListResources(ref List targetList, FileType #if Android if (fileType is FileType.Depends) { - File.Copy(path, BepInCorePath+ resource); + File.Copy(path, BepInCorePath + resource); } #endif } @@ -438,7 +439,7 @@ private static IEnumerator DownloadResources(List resources, FileType fi if (!task.IsFaulted && task.Result) continue; Error($"Download failed: {resource} - {task.Exception}", "Download Resource"); - if (!essential || Main.FastLaunchMode.Value) continue; + if (!essential || ConfigManager.FastLaunchMode.Value) continue; yield return HandleDownloadError(); Fatal("DOWNLOAD ESSENTIAL RESOURCES FAILED", "Download Resource"); } diff --git a/FinalSuspect/Patches/System/LobbyPanelPatch.cs b/FinalSuspect/Patches/System/LobbyPanelPatch.cs index 65df358..2a6922a 100644 --- a/FinalSuspect/Patches/System/LobbyPanelPatch.cs +++ b/FinalSuspect/Patches/System/LobbyPanelPatch.cs @@ -45,31 +45,31 @@ internal class LobbyViewSettingsPanePatch { private static readonly List normalBannerColors = [ - GetRoleColor(RoleTypes.Impostor), - GetRoleColor(RoleTypes.Crewmate), + RoleHelper.GetRoleColor(RoleTypes.Impostor), + RoleHelper.GetRoleColor(RoleTypes.Crewmate), Color.yellow, Color.green ]; private static readonly List hnsBannerColors = [ - GetRoleColor(RoleTypes.Crewmate), - GetRoleColor(RoleTypes.Impostor), + RoleHelper.GetRoleColor(RoleTypes.Crewmate), + RoleHelper.GetRoleColor(RoleTypes.Impostor), Palette.Purple, Color.green ]; private static readonly List rolecolors = [ - GetRoleColor(RoleTypes.Engineer), - GetRoleColor(RoleTypes.GuardianAngel), - GetRoleColor(RoleTypes.Scientist), - GetRoleColor(RoleTypes.Tracker), - GetRoleColor(RoleTypes.Noisemaker), - GetRoleColor(RoleTypes.Detective), - GetRoleColor(RoleTypes.Shapeshifter), - GetRoleColor(RoleTypes.Phantom), - GetRoleColor(RoleTypes.Viper) + RoleHelper.GetRoleColor(RoleTypes.Engineer), + RoleHelper.GetRoleColor(RoleTypes.GuardianAngel), + RoleHelper.GetRoleColor(RoleTypes.Scientist), + RoleHelper.GetRoleColor(RoleTypes.Tracker), + RoleHelper.GetRoleColor(RoleTypes.Noisemaker), + RoleHelper.GetRoleColor(RoleTypes.Detective), + RoleHelper.GetRoleColor(RoleTypes.Shapeshifter), + RoleHelper.GetRoleColor(RoleTypes.Phantom), + RoleHelper.GetRoleColor(RoleTypes.Viper) ]; private static readonly List roleCatColors = @@ -148,8 +148,8 @@ private static void Update(LobbyViewSettingsPane __instance) case "ViewSettingsInfoPanel_Role Variant(Clone)": { var roleColor = bannerIndex <= 5 - ? GetRoleColor(RoleTypes.Crewmate) - : GetRoleColor(RoleTypes.Impostor); + ? RoleHelper.GetRoleColor(RoleTypes.Crewmate) + : RoleHelper.GetRoleColor(RoleTypes.Impostor); SetColorForRolesBanner(banner.gameObject, rolecolors[bannerIndex], roleColor); if (banner.gameObject.transform.FindChild("LabelBackground").gameObject .GetComponent().color != new Color(0.3f, 0.3f, 0.3f, 1)) @@ -166,8 +166,8 @@ private static void Update(LobbyViewSettingsPane __instance) { var iconIndex = enableRoleIndex.First(); var roleColor = iconIndex <= 5 - ? GetRoleColor(RoleTypes.Crewmate) - : GetRoleColor(RoleTypes.Impostor); + ? RoleHelper.GetRoleColor(RoleTypes.Crewmate) + : RoleHelper.GetRoleColor(RoleTypes.Impostor); SetColorForIcon(banner.gameObject, rolecolors[iconIndex], roleColor); enableRoleIndex.RemoveAt(0); } diff --git a/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs b/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs index 82bef85..a283cf3 100644 --- a/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs +++ b/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs @@ -1,4 +1,4 @@ -using FinalSuspect.ClientActions.FeatureItems.MainMenuStyle; +using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; using FinalSuspect.Helpers; using Il2CppSystem; using UnityEngine; @@ -30,7 +30,7 @@ private static void Update_Postfix(MainMenuManager __instance) { if (!GameObject.Find("MainUI")) return; - var style = MainMenuStyleManager.MainMenuStyles[Main.CurrentStyleId.Value]; + var style = MainMenuStyleManager.MainMenuStyles[ConfigManager.CurrentStyleId.Value]; FormatButtonColor(__instance, __instance.newsButton, !ModNewsHistory.AnnouncementLoadComplete ? ColorHelper.ConvertToLightGray(style.MainUIColors[1]) diff --git a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs index 7cf33d5..2f6a020 100644 --- a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs +++ b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs @@ -61,12 +61,10 @@ public static void SetOnline_Postfix() public static void MainMenuManager_LateUpdate(MainMenuManager __instance) { CustomPopup.Update(); - VersionShowerStartPatch.OVersionShower.transform.FindChild("Text_TMP").gameObject.GetComponent() + OVersionShower.transform.FindChild("Text_TMP").gameObject.GetComponent() .sizeDelta = new Vector2(3.9f, 0.2359f); if (!GameObject.Find("MainUI")) ShowingPanel = false; - VersionShowerStartPatch.CreditTextCredential.gameObject.SetActive(!ShowingPanel && Active); - __instance.quitButton.gameObject.SetActive(true); - GithubButton.SetActive(true); + CreditTextCredential.gameObject.SetActive(!ShowingPanel && Active); if (RightPanel) { var pos1 = RightPanel.transform.localPosition; @@ -145,7 +143,7 @@ public static void Start_Postfix(MainMenuManager __instance) UpdateButton.transform.transform.FindChild("FontPlacer").GetChild(0).gameObject.DestroyTranslator(); } - Application.targetFrameRate = Main.UnlockFPS.Value ? 165 : 60; + Application.targetFrameRate = ConfigManager.UnlockFPS.Value ? 165 : 60; return; void OpenUrl(string url) @@ -168,6 +166,8 @@ GameObject CreatButton(string text, Action action) var template = col == 1 ? __instance.creditsButton.gameObject : __instance.quitButton.gameObject; var button = Object.Instantiate(template, template.transform.parent); + Object.Destroy(button.GetComponent()); + button.SetActive(true); button.transform.transform.FindChild("FontPlacer").GetChild(0).gameObject.DestroyTranslator(); var buttonText = button.transform.FindChild("FontPlacer").GetChild(0).GetComponent(); buttonText.text = text; @@ -175,7 +175,16 @@ GameObject CreatButton(string text, Action action) passiveButton.OnClick = new Button.ButtonClickedEvent(); passiveButton.OnClick.AddListener(action); var aspectPosition = button.GetComponent(); - aspectPosition.anchorPoint = new Vector2(col == 1 ? 0.415f : 0.583f, 0.5f - 0.08f * row); +#if Android + var yPosition = col == 1 ? 0.5f - 0.08f * row : 0.5f - 0.08f * (row - 1); +#else + var yPosition = 0.5f - 0.08f * row; +#endif + + aspectPosition.anchorPoint = new Vector2( + col == 1 ? 0.415f : 0.583f, + yPosition + ); var scale = button.transform.localScale; button.transform.localScale = new Vector3(scale.x * GetResolutionOffset(), button.transform.localScale.y); MainMenuCustomButtons.Add(button); @@ -189,26 +198,26 @@ private static void OpenURLAndroid(string url) { AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"); AndroidJavaObject currentActivity = unityPlayer.GetStatic("currentActivity"); - + // 创建 Intent AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent"); AndroidJavaObject intentObject = - new AndroidJavaObject("android.content.Intent", "android.intent.action.VIEW"); - + new AndroidJavaObject("android.content.Intent", "android.intent.action.VIEW"); + // 创建 URI AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri"); AndroidJavaObject uriObject = uriClass.CallStatic("parse", url); - + // 设置 Intent 的数据 intentObject.Call("setData", uriObject); - + // 设置标志确保在新任务中打开 int FLAG_ACTIVITY_NEW_TASK = 0x10000000; intentObject.Call("setFlags", FLAG_ACTIVITY_NEW_TASK); - + // 启动 Activity currentActivity.Call("startActivity", intentObject); - + // 释放资源(虽然不是必须的,但推荐) unityPlayer.Dispose(); currentActivity.Dispose(); @@ -217,7 +226,7 @@ private static void OpenURLAndroid(string url) uriClass.Dispose(); uriObject.Dispose(); } - catch + catch { // 降级到Application.OpenURL Application.OpenURL(url); diff --git a/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs b/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs index 88c7016..da7604c 100644 --- a/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs +++ b/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs @@ -1,4 +1,4 @@ -using FinalSuspect.ClientActions.FeatureItems.MyMusic; +using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Modules.Features.CheckingandBlocking; using UnityEngine; diff --git a/FinalSuspect/main.cs b/FinalSuspect/main.cs index 9f84251..fb64300 100644 --- a/FinalSuspect/main.cs +++ b/FinalSuspect/main.cs @@ -1,18 +1,12 @@ using System; -using System.Threading.Tasks; using AmongUs.GameOptions; using BepInEx; -using BepInEx.Configuration; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using FinalSuspect; using FinalSuspect.Attributes; -using FinalSuspect.DataHandling.FinalAntiCheat.Core; -using FinalSuspect.Helpers; using FinalSuspect.Internal; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; -using FinalSuspect.Modules.Core.Plugin.RegistryManager; -using FinalSuspect.Modules.Random; using FinalSuspect.Modules.Resources; using Il2CppInterop.Runtime.Injection; using UnityEngine; @@ -35,8 +29,6 @@ public class Main : BasePlugin public const string PluginVersion = "1.2.99"; public const string PluginGuid = "cn.slok.finalsuspect"; public const int PluginCreation = 1; - public const string DebugKeyHash = "c0fd562955ba56af3ae20d7ec9e64c664f0facecef4b3e366e109306adeae29d"; - public const string DebugKeySalt = "59687b"; // == 版本相关设定 / Version Config == public const string LowestSupportedVersion = "2025.9.9"; // 17.0.0 @@ -58,24 +50,6 @@ public class Main : BasePlugin public static bool ExceptionMessageIsShown; public static string CredentialsText; - public static readonly Dictionary roleColors = new() - { - { RoleTypes.CrewmateGhost, "#8CFFFF" }, - { RoleTypes.GuardianAngel, "#8CFFDB" }, - { RoleTypes.Crewmate, "#8CFFFF" }, - { RoleTypes.Scientist, "#F8FF8C" }, - { RoleTypes.Engineer, "#A5A8FF" }, - { RoleTypes.Noisemaker, "#FFC08C" }, - { RoleTypes.Tracker, "#93FF8C" }, - { RoleTypes.ImpostorGhost, "#FF1919" }, - { RoleTypes.Impostor, "#FF1919" }, - { RoleTypes.Shapeshifter, "#FF819E" }, - { RoleTypes.Phantom, "#CA8AFF" }, - { RoleTypes.Detective, "#70A1DA" }, - { RoleTypes.Viper, "#F06762" } - }; - - public static string HostNickName = ""; public static readonly bool IsInitialRelease = DateTime.Now is { Month: 8, Day: >= 15 and <= 19 }; public static readonly bool IsAprilFools = DateTime.Now is { Month: 4, Day: >= 1 and <= 10 }; @@ -85,44 +59,11 @@ DateTime.Now.Year is 2025 && DateTime.Now.Month is 8 && public static Main Instance; - // == 认证设定 / Authentication Config == - public static HashAuth DebugKeyAuth { get; private set; } - public static ConfigEntry DebugKeyInput { get; private set; } - // ========== public Harmony Harmony { get; } = new(PluginGuid); public static NormalGameOptionsV10 NormalOptions => GameOptionsManager.Instance.currentNormalGameOptions; public static HideNSeekGameOptionsV10 HideNSeekOptions => GameOptionsManager.Instance.currentHideNSeekGameOptions; - //Client Options - public static ConfigEntry KickPlayerWithAbnormalFriendCode { get; private set; } - public static ConfigEntry KickPlayerWithDenyName { get; private set; } - public static ConfigEntry KickPlayerInBanList { get; private set; } - public static ConfigEntry SpamDenyWord { get; private set; } - public static ConfigEntry UnlockFPS { get; private set; } - public static ConfigEntry SwitchOutfitType { get; private set; } - public static ConfigEntry AutoStartGame { get; private set; } - public static ConfigEntry AutoEndGame { get; private set; } - public static ConfigEntry DisableVanillaSound { get; private set; } - public static ConfigEntry EnableFAC { get; private set; } - public static ConfigEntry EnableGuardian { get; private set; } - public static ConfigEntry ShowPlayerInfo { get; private set; } - public static ConfigEntry FastLaunchMode { get; private set; } - public static ConfigEntry OfflineMode { get; private set; } - public static ConfigEntry UseModCursor { get; private set; } - public static ConfigEntry VersionCheat { get; private set; } - public static ConfigEntry GodMode { get; private set; } - public static ConfigEntry NoGameEnd { get; private set; } - - //Other Configs - public static ConfigEntry HideName { get; private set; } - public static ConfigEntry HideColor { get; private set; } - public static ConfigEntry ShowResults { get; private set; } - public static ConfigEntry WebhookURL { get; private set; } - public static ConfigEntry EnableFinalSuspect { get; private set; } - public static ConfigEntry LanguageUpdateBypass { get; private set; } - public static ConfigEntry CurrentStyleId { get; private set; } - public static IEnumerable AllPlayerControls => PlayerControl.AllPlayerControls.ToArray().Where(p => p); @@ -133,83 +74,11 @@ public override void Load() { Instance = this; - //Configs - HideName = Config.Bind("Final System", "Hide Game Code Name", "Final Suspect"); - HideColor = Config.Bind("Final System", "Hide Game Code Color", $"{ColorHelper.FSColorHex}"); - EnableFinalSuspect = Config.Bind("Final System", "Enable Final Suspect", true); - ShowResults = Config.Bind("Final System", "Show Results", true); - LanguageUpdateBypass = Config.Bind("Final System", "Language Update Bypass", BypassType.Dont); - CurrentStyleId = Config.Bind("Final System", "BG Id", 0); - - DebugKeyInput = Config.Bind("Authentication", "Debug Key", ""); - - UnlockFPS = Config.Bind("Client Options", "Unlock FPS", false); - SwitchOutfitType = Config.Bind("Client Options", "Switch Outfit", OutfitType.BeanMode); - KickPlayerWithAbnormalFriendCode = Config.Bind("Client Options", "Kick Player FriendCode Not Exist", true); - KickPlayerInBanList = Config.Bind("Client Options", "Kick Player In BanList", true); - KickPlayerWithDenyName = Config.Bind("Client Options", "Kick Player With Deny Name", true); - SpamDenyWord = Config.Bind("Client Options", "Spam Deny Word", true); - AutoStartGame = Config.Bind("Client Options", "Auto Start Game", false); - AutoEndGame = Config.Bind("Client Options", "Auto End Game", false); - DisableVanillaSound = Config.Bind("Client Options", "Disable Vanilla Sound", false); - EnableFAC = Config.Bind("Client Options", "Enable FAC", false); - EnableGuardian = Config.Bind("Client Options", "Enable Guardian", true); - //PrunkMode = Config.Bind("Client Options", "Prunk Mode", false); - ShowPlayerInfo = Config.Bind("Client Options", "Show Player Info", true); - FastLaunchMode = Config.Bind("Client Options", "Fast Launch Mode", false); - OfflineMode = Config.Bind("Client Options", "Offline Mode", false); - UseModCursor = Config.Bind("Client Options", "Use Mod Cursor", true); - - VersionCheat = Config.Bind("Client Options", "Version Cheat", false); - GodMode = Config.Bind("Client Options", "God Mode", false); - NoGameEnd = Config.Bind("Client Options", "No Game End", false); - - Logger = BepInEx.Logging.Logger.CreateLogSource("FinalSuspect"); - Enable(); - Disable("SwitchSystem"); - Disable("ModNews"); - Disable("CancelPet"); - if (!DebugModeManager.IsDebugMode) - { - Disable("Download Resources"); - Disable("GetAnnouncements"); - Disable("GetConfigs"); - } - - isDetail = true; - - // 認証関連-初期化 - DebugKeyAuth = new HashAuth(DebugKeyHash, DebugKeySalt); - - // 認証関連-認証 - DebugModeManager.Auth(DebugKeyAuth, DebugKeyInput.Value); - - WebhookURL = Config.Bind("hook", "WebhookURL", "none"); - hasArgumentException = false; ExceptionMessage = ""; - - RegistryManager.Init(); // 这是优先级最高的模块初始化方法,不能使用模块初始化属性 - DllChecker.Init(); - PluginModuleInitializerAttribute.InitializeAll(); - IRandom.SetInstance(new NetRandomWrapper()); - - Info($"{Application.version}", "AmongUs Version"); - - var handler = Handler("GitVersion"); - handler.Info($"{nameof(GitBaseTag)}: {GitBaseTag}"); - handler.Info($"{nameof(GitCommit)}: {GitCommit}"); - handler.Info($"{nameof(GitCommits)}: {GitCommits}"); - handler.Info($"{nameof(GitIsDirty)}: {GitIsDirty}"); - handler.Info($"{nameof(GitSha)}: {GitSha}"); - handler.Info($"{nameof(GitTag)}: {GitTag}"); - ClassInjector.RegisterTypeInIl2Cpp(); - - Task.Run(SystemEnvironment.SetEnvironmentVariablesAsync); - Harmony.PatchAll(); @@ -229,16 +98,6 @@ public override void Load() private const int DisplayedVersion_TestCreation = 1; #endif - -#pragma warning disable CS0618 // 类型或成员已过时 - public const string GitBaseTag = ThisAssembly.Git.BaseTag; - public const string GitCommit = ThisAssembly.Git.Commit; - public const string GitCommits = ThisAssembly.Git.Commits; - public const string GitBranch = ThisAssembly.Git.Branch; - public const bool GitIsDirty = ThisAssembly.Git.IsDirty; - public const string GitSha = ThisAssembly.Git.Sha; - public const string GitTag = ThisAssembly.Git.Tag; -#pragma warning restore CS0618 } /// From a8b173953fe2a403073f7d3d848eaaf36e1ca658 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 3 Oct 2025 20:18:29 +0800 Subject: [PATCH 10/19] Complete --- FinalSuspect/Patches/Game_Vanilla/HudPatch.cs | 2 ++ FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs | 4 ++++ FinalSuspect/Patches/System/Others/UnityEnginePatch.cs | 2 -- FinalSuspect/Patches/System/PhasePatch.cs | 5 ++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs index e44d5bb..7558292 100644 --- a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs @@ -247,6 +247,8 @@ private static void UpdateResult(HudManager __instance) FontSize = 2f }; + showHideButton.Button.gameObject.SetActive(true); + StringBuilder sb = new($"{GetString("Summary.Text")}{FinalGameData.LastGameResult}"); if (IsInGame) { diff --git a/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs index f5258fe..2583ac9 100644 --- a/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs @@ -79,6 +79,10 @@ public static void Postfix(EndGameManager __instance) Scale = new Vector2(1.5f, 0.5f), FontSize = 2f }; + + + showHideButton.Button.gameObject.SetActive(true); + var lastGameResult = DidHumansWin ? GetString("Summary.CrewsWin") : GetString("Summary.ImpsWin"); FinalGameData.LastGameResult = lastGameResult; StringBuilder sb = new($"{GetString("Summary.Text")}{lastGameResult}"); diff --git a/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs b/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs index f1a4e80..05367d6 100644 --- a/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs +++ b/FinalSuspect/Patches/System/Others/UnityEnginePatch.cs @@ -11,8 +11,6 @@ public static bool Prefix([HarmonyArgument(0)] Object obj) try { Return = obj.name is not "LobbyInfoPane" and not "GameStartManager" || IsFreePlay || IsNotJoined; - if (obj.name is "IntroCutscene") - IntroCutsceneOnDestroyPatch.Postfix(); } catch { diff --git a/FinalSuspect/Patches/System/PhasePatch.cs b/FinalSuspect/Patches/System/PhasePatch.cs index 8a0f463..f25decb 100644 --- a/FinalSuspect/Patches/System/PhasePatch.cs +++ b/FinalSuspect/Patches/System/PhasePatch.cs @@ -80,7 +80,10 @@ public static void Postfix() }*/ #if Windows -[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.OnDestroy))] +[HarmonyPatch(nameof(IntroCutscene.OnDestroy))] +#elif Android +[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.StartSFX))] +[HarmonyPatch(typeof(FungleShipStatus), nameof(FungleShipStatus.StartSFX))] #endif public static class IntroCutsceneOnDestroyPatch { From b2718632cc6a0f38b5c9d22985805baed6ff8b1c Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Fri, 3 Oct 2025 23:53:14 +0800 Subject: [PATCH 11/19] update btns --- Assets/Languages/SChinese.yaml | 1 + Assets/ModNews/SChinese/FS.v1.3.txt | 5 ++ .../FeatureItems/ModUnloaderScreen.cs | 2 +- .../Modules/Features/InGameRoleInfoMenu.cs | 10 +++ FinalSuspect/Patches/System/ControlPatch.cs | 11 ++- .../Patches/System/GameStartManagerPatch.cs | 25 ++++++ .../Patches/System/LobbyPanelPatch.cs | 82 +++++++++++++++++-- FinalSuspect/Patches/System/PhasePatch.cs | 2 +- 8 files changed, 127 insertions(+), 11 deletions(-) diff --git a/Assets/Languages/SChinese.yaml b/Assets/Languages/SChinese.yaml index 0908f38..0b52d24 100644 --- a/Assets/Languages/SChinese.yaml +++ b/Assets/Languages/SChinese.yaml @@ -368,6 +368,7 @@ Back: "返回" Yes: "是" No: "否" Cancel: "取消" +Skip: "跳过" Unload: "切换" Retry: "重试" PreviousPage: "上一页" diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index 16724f6..5fbd01c 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -39,6 +39,7 @@ Starlight为安卓平台带来了模组体验。 ## 更改 - 修改职业介绍格式 制作: Slok, LezaiYa +- 适当缩小预设信息板 - 将[LezaiYa]("https://github.com/NewLezaiYa")列入**开发者** ## 新增 @@ -46,6 +47,10 @@ Starlight为安卓平台带来了模组体验。 - 恢复官网 制作: LezaiYa | 立绘: 小黄117 - 适配**Starlight**安装模组启动器 +- 开始游戏闪屏动画 +- 按键: 跳过倒计时开始游戏 +- 按键: 职业介绍 +- 按键: 显示/隐藏预设信息板 制作: Slok ## 重制 diff --git a/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs b/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs index b5de88c..aa9296a 100644 --- a/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs +++ b/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs @@ -17,7 +17,7 @@ public static class ModUnloaderScreen public static void Init(OptionsMenuBehaviour optionsMenuBehaviour) { - Popup = Object.Instantiate(optionsMenuBehaviour.Background, optionsMenuBehaviour.transform); + Popup = Object.Instantiate(optionsMenuBehaviour.Background, ClientFeatureItem.CustomBackground.transform); Popup.name = "UnloadModPopup"; Popup.transform.localPosition = new Vector3(0f, 0f, -8f); Popup.transform.localScale = new Vector3(0.8f, 0.8f, 1f); diff --git a/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs b/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs index edcd2c0..9720bdb 100644 --- a/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs +++ b/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs @@ -82,6 +82,16 @@ public static void SetRoleInfoRef(PlayerControl player) RoleIllustrationRend.sprite = LoadSprite($"CI_{HnSPrefix + role}.png", 320f); } + public static void Toggle() + { + if (Showing) + Hide(); + else + { + Show(); + } + } + public static void Show() { if (!Fill || !Menu) Init(); diff --git a/FinalSuspect/Patches/System/ControlPatch.cs b/FinalSuspect/Patches/System/ControlPatch.cs index 3745c47..c98b634 100644 --- a/FinalSuspect/Patches/System/ControlPatch.cs +++ b/FinalSuspect/Patches/System/ControlPatch.cs @@ -16,11 +16,14 @@ private static readonly (int, int)[] resolutions = public static void Postfix() { //职业介绍 - if (IsInGame && (IsCanMove || IsInMeeting) && Input.GetKey(KeyCode.F1)) + if (IsInGame && (IsCanMove || IsInMeeting)) { - if (!InGameRoleInfoMenu.Showing) - InGameRoleInfoMenu.SetRoleInfoRef(PlayerControl.LocalPlayer); - InGameRoleInfoMenu.Show(); + if (Input.GetKeyDown(KeyCode.F1)) + { + if (!InGameRoleInfoMenu.Showing) + InGameRoleInfoMenu.SetRoleInfoRef(PlayerControl.LocalPlayer); + InGameRoleInfoMenu.Toggle(); + } } else { diff --git a/FinalSuspect/Patches/System/GameStartManagerPatch.cs b/FinalSuspect/Patches/System/GameStartManagerPatch.cs index 0c65ae1..babb1b6 100644 --- a/FinalSuspect/Patches/System/GameStartManagerPatch.cs +++ b/FinalSuspect/Patches/System/GameStartManagerPatch.cs @@ -36,6 +36,7 @@ public static class GameStartManagerPatch private static Vector3 _gameStartTextlocalPosition; private static TextMeshPro _timerText; private static PassiveButton _cancelButton; + private static PassiveButton _skipButton; private static TextMeshPro _warningText; private static TextMeshPro _hideName; @@ -109,6 +110,29 @@ public static void Postfix(GameStartManager __instance) _cancelButton.OnClick.AddListener((Action)(__instance.ResetStartState)); _cancelButton.gameObject.SetActive(false); + _skipButton = Object.Instantiate(__instance.StartButton, __instance.transform); + var skipLabel = _skipButton.GetComponentInChildren(); + skipLabel.DestroyTranslator(); + _skipButton.transform.localScale = new Vector3(0.5f, 0.5f, 1f); + _skipButton.transform.localPosition = new Vector3(2f, 0.13f, 0f); + skipLabel.text = GetString("Skip"); + var skipButtonInactiveRenderer = _skipButton.inactiveSprites.GetComponent(); + skipButtonInactiveRenderer.color = new Color(0f, 0.6f, 0.6f, 1f); + var skipButtonActiveRenderer = _skipButton.activeSprites.GetComponent(); + skipButtonActiveRenderer.color = new Color(0f, 0.6f, 0.6f, 1f); + var skipButtonInactiveShine = _skipButton.inactiveSprites.transform.Find("Shine"); + if (skipButtonInactiveShine) skipButtonInactiveShine.gameObject.SetActive(false); + + _skipButton.activeTextColor = _skipButton.inactiveTextColor = Color.white; + + _skipButton.OnClick = new Button.ButtonClickedEvent(); + _skipButton.OnClick.AddListener(new Action(() => + { + GameStartManager.Instance.countDownTimer = 0; + SoundManager.Instance.StopSound(GameStartManager.Instance.gameStartSound); + })); + _skipButton.gameObject.SetActive(false); + if (!AmongUsClient.Instance.AmHost || (!VersionChecker.IsBroken && (!VersionChecker.HasUpdate || !VersionChecker.ForceUpdate) && VersionChecker.IsSupported)) return; @@ -159,6 +183,7 @@ public static void Postfix(GameStartManager __instance) if (AmongUsClient.Instance.AmHost) { _cancelButton.gameObject.SetActive(__instance.startState == GameStartManager.StartingStates.Countdown); + _skipButton.gameObject.SetActive(__instance.startState == GameStartManager.StartingStates.Countdown); __instance.StartButton.gameObject.SetActive(!_cancelButton.gameObject.active); } diff --git a/FinalSuspect/Patches/System/LobbyPanelPatch.cs b/FinalSuspect/Patches/System/LobbyPanelPatch.cs index 2a6922a..46262da 100644 --- a/FinalSuspect/Patches/System/LobbyPanelPatch.cs +++ b/FinalSuspect/Patches/System/LobbyPanelPatch.cs @@ -1,20 +1,26 @@ using AmongUs.GameOptions; using FinalSuspect.Attributes; using FinalSuspect.Helpers; -using Il2CppSystem; +using System; +using FinalSuspect.Modules.Features; using TMPro; using UnityEngine; +using UnityEngine.UI; +using Object = UnityEngine.Object; namespace FinalSuspect.Patches.System; [HarmonyPatch(typeof(LobbyInfoPane), nameof(LobbyInfoPane.Update))] internal class LobbyInfoPaneUpdatePatch { + private static GameObject _showHidePaneButton; + private static GameObject _roleInfoPaneButton; + [GameModuleInitializer] public static void Init() { - var trans = DestroyableSingleton.Instance.transform.FindChild("AspectSize") - .FindChild("GameSettingsButtons"); + var aspect = DestroyableSingleton.Instance.transform.FindChild("AspectSize"); + var trans = aspect.FindChild("GameSettingsButtons"); trans.FindChild("Host Buttons").gameObject.SetActive(false); trans.FindChild("Client Buttons").gameObject.SetActive(true); var header = trans.FindChild("ButtonSettingsHeader").gameObject; @@ -27,6 +33,73 @@ public static void Init() DestroyableSingleton.Instance.gameObject.GetComponent().DistanceFromEdge += Vector3.forward * -60; + DestroyableSingleton.Instance.gameObject.transform.localScale *= 0.8f; + if (!_showHidePaneButton) + { + Object.Destroy(_showHidePaneButton); + _showHidePaneButton = null; + } + + _showHidePaneButton = + Object.Instantiate(aspect.FindChild("GameCodeSection").FindChild("CopyGameCodeButton").gameObject, + aspect.parent.parent); + _showHidePaneButton.name = "Show Hide Panel Button"; + _showHidePaneButton.transform.localPosition = new Vector3(-0.2f, -0.5f, 1f); + _showHidePaneButton.transform.localScale = new Vector3(0.5f, 0.5f, 1f); + _showHidePaneButton.SetActive(true); + Object.Destroy(_showHidePaneButton.GetComponent()); + _showHidePaneButton.SetActive(true); + var _show_aspectPosi = _showHidePaneButton.AddComponent(); + + _show_aspectPosi.updateAlways = true; + var _show_passive = _showHidePaneButton.GetComponent(); + _show_passive.OnClick = new Button.ButtonClickedEvent(); + _show_passive.OnClick.AddListener(new Action(() => + { + ControllerManagerUpdatePatch.ShowSettingsPanel = !ControllerManagerUpdatePatch.ShowSettingsPanel; + })); + _showHidePaneButton.transform.FindChild("Inactive").GetComponent().color = + new Color(0.8f, 0.8f, 1f, 0.3f); + _showHidePaneButton.transform.FindChild("Icon").GetComponent().sprite = + LoadSprite("eye.png", 0.01f); + _ = new LateTask(() => + { + _show_aspectPosi.Alignment = AspectPosition.EdgeAlignments.Right; + _show_aspectPosi.DistanceFromEdge = new Vector3(0.22f, 1.85f, -80f); + _showHidePaneButton.transform.FindChild("Icon").GetComponent().sprite = + LoadSprite("eye.png", 100f); + }, 0.2f, "Reset Icon"); + + + _roleInfoPaneButton = + Object.Instantiate(aspect.FindChild("GameCodeSection").FindChild("CopyGameCodeButton").gameObject, + aspect.parent.parent); + _roleInfoPaneButton.name = "Show Hide Panel Button"; + _roleInfoPaneButton.transform.localPosition = new Vector3(-0.2f, -0.5f, 1f); + _roleInfoPaneButton.transform.localScale = new Vector3(0.5f, 0.5f, 1f); + _roleInfoPaneButton.SetActive(true); + Object.Destroy(_roleInfoPaneButton.GetComponent()); + _roleInfoPaneButton.SetActive(true); + var aspectPosi = _roleInfoPaneButton.AddComponent(); + + aspectPosi.updateAlways = true; + var passive = _roleInfoPaneButton.GetComponent(); + passive.OnClick = new Button.ButtonClickedEvent(); + passive.OnClick.AddListener(new Action(() => + { + if (IsInGame && (IsCanMove || IsInMeeting)) + { + if (!InGameRoleInfoMenu.Showing) + InGameRoleInfoMenu.SetRoleInfoRef(PlayerControl.LocalPlayer); + InGameRoleInfoMenu.Toggle(); + } + })); + _roleInfoPaneButton.transform.FindChild("Inactive").GetComponent().color = + new Color(0.8f, 0.8f, 0.8f, 0.3f); + aspectPosi.Alignment = AspectPosition.EdgeAlignments.Right; + aspectPosi.DistanceFromEdge = new Vector3(0.58f, 1.85f, -80f); + _roleInfoPaneButton.transform.FindChild("Icon").GetComponent().sprite = + LoadSprite("roleHelp.png", 100f); } public static void Postfix() @@ -232,7 +305,7 @@ private static void SetColorForIcon(GameObject obj, Color iconcolor, Color bgcol cat.FindChild("Divider").gameObject.GetComponent().color = bgcolor.ShadeColor(0.32f); cat.FindChild("HeaderText").gameObject.GetComponent().color = Color.white; cat.FindChild("Icon").gameObject.GetComponent().color = iconcolor; - obj.ForEachChild((Action)SetColor); + obj.ForEachChild((Il2CppSystem.Action)SetColor); return; void SetColor(GameObject _obj) @@ -262,7 +335,6 @@ private static void SetColorForCat(GameObject obj, Color color) color.ShadeColor(0.18f); } } - /* //不屎山更稳定,但是代码量大得多且还需要额外写Update [HarmonyPatch(typeof(LobbyViewSettingsPane))] diff --git a/FinalSuspect/Patches/System/PhasePatch.cs b/FinalSuspect/Patches/System/PhasePatch.cs index f25decb..3f94329 100644 --- a/FinalSuspect/Patches/System/PhasePatch.cs +++ b/FinalSuspect/Patches/System/PhasePatch.cs @@ -80,7 +80,7 @@ public static void Postfix() }*/ #if Windows -[HarmonyPatch(nameof(IntroCutscene.OnDestroy))] +[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.OnDestroy))] #elif Android [HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.StartSFX))] [HarmonyPatch(typeof(FungleShipStatus), nameof(FungleShipStatus.StartSFX))] From 585b5d106f87fc5a9c2124eb2cb94c450cbcfaf2 Mon Sep 17 00:00:00 2001 From: NewLezaiYa <3651440375@qq.com> Date: Sat, 4 Oct 2025 02:04:21 +0800 Subject: [PATCH 12/19] BanMod RPC --- .../FinalAntiCheat/Handlers/Invalid/BanMod.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/BanMod.cs diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/BanMod.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/BanMod.cs new file mode 100644 index 0000000..216acf6 --- /dev/null +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/BanMod.cs @@ -0,0 +1,23 @@ +using FinalSuspect.DataHandling.FinalAntiCheat.Interfaces; +using Hazel; + +namespace FinalSuspect.DataHandling.FinalAntiCheat.Handlers.Invalid; + +public class BanMod : IRpcHandler +{ + public List TargetRpcs => + [ + 201, + 202, + 203, + 204, + 205 + ]; + + public bool HandleInvalidRPC(PlayerControl sender, MessageReader reader, + ref bool notify, ref string reason, ref bool ban) + { + reason = "BanMod"; + return false; + } +} \ No newline at end of file From 8cb8e7d2ceccf2d9f1624322777e4a0b33613e92 Mon Sep 17 00:00:00 2001 From: NewLezaiYa <3651440375@qq.com> Date: Sat, 4 Oct 2025 02:04:48 +0800 Subject: [PATCH 13/19] VersionCheck RPC --- .../Handlers/Invalid/VersionCheck.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/VersionCheck.cs diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/VersionCheck.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/VersionCheck.cs new file mode 100644 index 0000000..0dbedbc --- /dev/null +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Handlers/Invalid/VersionCheck.cs @@ -0,0 +1,19 @@ +using FinalSuspect.DataHandling.FinalAntiCheat.Interfaces; +using Hazel; + +namespace FinalSuspect.DataHandling.FinalAntiCheat.Handlers.Invalid; + +public class VersionCheck : IRpcHandler +{ + public List TargetRpcs => + [ + 80 + ]; + + public bool HandleInvalidRPC(PlayerControl sender, MessageReader reader, + ref bool notify, ref string reason, ref bool ban) + { + reason = "VersionCheck"; + return false; + } +} \ No newline at end of file From dac29ab778add09614478576b5c84bca54b8715f Mon Sep 17 00:00:00 2001 From: NewLezaiYa <3651440375@qq.com> Date: Sat, 4 Oct 2025 02:05:32 +0800 Subject: [PATCH 14/19] ModNew update --- Assets/ModNews/SChinese/FS.v1.3.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index 5fbd01c..d72df81 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -45,6 +45,8 @@ Starlight为安卓平台带来了模组体验。 ## 新增 - 适配**Among Us v17.0.0** - 恢复官网 +- 增加对BanMod的RPC检测 +- 增加对VersionCheck的RPC检测 制作: LezaiYa | 立绘: 小黄117 - 适配**Starlight**安装模组启动器 - 开始游戏闪屏动画 From 7de9ced0036aa70cb7a85835da3514cf0f4f22e9 Mon Sep 17 00:00:00 2001 From: NewLezaiYa <3651440375@qq.com> Date: Sat, 4 Oct 2025 02:06:17 +0800 Subject: [PATCH 15/19] fix error content --- Assets/ModNews/SChinese/FS.v1.2_20250815.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/ModNews/SChinese/FS.v1.2_20250815.txt b/Assets/ModNews/SChinese/FS.v1.2_20250815.txt index 76d3b91..a0e6e11 100644 --- a/Assets/ModNews/SChinese/FS.v1.2_20250815.txt +++ b/Assets/ModNews/SChinese/FS.v1.2_20250815.txt @@ -135,8 +135,8 @@ Slok在脱离原制作团队后会将精力聚焦于一个全新的游戏—— - 增加对好友代码的检测 - 增加对NonalusAntiCheatMenu的RPC检测 制作: Nonalus -- 为BetterAmongUs添加了RPC152检测 -- 为HostGuard添加了RPC176检测 +- 增加对BetterAmongUs的RPC检测 +- 增加对HostGuard的RPC检测 - 当目录存在其它模组时,将强制关闭游戏 制作: LezaiYa - 游戏内展示预设信息面板 From 628afe6ac66089ff6b09e845ad1612419377a742 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Sat, 4 Oct 2025 18:12:58 +0800 Subject: [PATCH 16/19] Bug fix & code optimization --- Assets/ModNews/SChinese/FS.v1.3.txt | 8 +- FinalSuspect/ClientItems/ClientActionItem.cs | 1 - FinalSuspect/ClientItems/ClientFeatureItem.cs | 1 - FinalSuspect/ClientItems/ClientItemsPatch.cs | 7 +- FinalSuspect/ClientItems/ClientOptionItem.cs | 1 - .../MainMenuStyle/MainMenuStyleManager.cs | 1 - .../MainMenuStyle/MainMenuStylePanel.cs | 22 +- .../FeatureItems/ModUnloaderScreen.cs | 1 - .../FeatureItems/MyMusic/AudioLoader.cs | 1 - .../FeatureItems/MyMusic/AudioManager.cs | 1 - .../FeatureItems/MyMusic/AudioPlayer.cs | 1 - .../FeatureItems/MyMusic/MyMusicPanel.cs | 3 +- .../FeatureItems/NameTag/NameTagEditMenu.cs | 1 - .../FeatureItems/NameTag/NameTagManager.cs | 1 - .../FeatureItems/NameTag/NameTagNewWindow.cs | 1 - .../FeatureItems/NameTag/NameTagPanel.cs | 1 - .../FeatureItems/NameTag/UiHelper.cs | 1 - .../FeatureItems/Resources/ResourcesPanel.cs | 3 +- .../FinalAntiCheat/Core/DllChecker.cs | 7 +- .../DataHandling/FinalAntiCheat/Core/Git.cs | 1 - .../FinalGameData/FinalGameData.cs | 8 - .../DataHandling/FinalLocalHandling.cs | 1 - FinalSuspect/DataHandling/FinalPlayerData.cs | 3 +- FinalSuspect/GlobalUsings.cs | 7 +- FinalSuspect/Helpers/AudioSourceHelper.cs | 2 - FinalSuspect/Helpers/ColorHelper.cs | 4 +- FinalSuspect/Helpers/ObjectHelper.cs | 11 +- FinalSuspect/Helpers/ResourcesHelper.cs | 4 +- FinalSuspect/Helpers/RoleHelper.cs | 1 - FinalSuspect/Helpers/StringHelper.cs | 1 - .../Core/Game/PlayerControlExtension/_Data.cs | 1 - .../Core/Game/PlayerControlExtension/_Role.cs | 3 +- .../Modules/Core/Game/ServerAddManager.cs | 7 +- .../Modules/Core/Game/UI/InGameInfoPane.cs | 104 ++++++++ .../Game/UI}/InGameRoleInfoMenu.cs | 74 +++++- .../Modules/Core/Game/UI/LastResult.cs | 174 +++++++++++++ .../Modules/Core/Game/UI/LoadingAnima.cs | 126 ++++++++++ .../Modules/Core/Game/UI/ModGameManager.cs | 44 ++++ .../Modules/Core/Game/UI/StartAnima.cs | 16 ++ FinalSuspect/Modules/Core/Game/Utils.cs | 1 - .../Modules/Core/Plugin/ConfigManager.cs | 14 +- FinalSuspect/Modules/Core/Plugin/ErrorText.cs | 1 - .../Modules/Core/Plugin/LaunchingInfo.cs | 1 - .../RegistryManager/WindowsPreferenceStore.cs | 3 +- .../Plugin/UI}/CustomPopup.cs | 3 +- .../{ModMainMenuManager.cs => UI/MainMenu.cs} | 6 +- .../DisplayerRoleTagHelper.cs | 1 - FinalSuspect/Modules/Features/Zoom.cs | 2 +- FinalSuspect/Modules/Resources/ModUpdater.cs | 13 +- FinalSuspect/Modules/Resources/PathManager.cs | 4 +- .../Modules/Resources/ResourcesDownloader.cs | 4 +- .../Modules/Resources/VersionChecker.cs | 7 +- .../Patches/Game_Vanilla/ChatBubblePatch.cs | 1 - .../Patches/Game_Vanilla/ChatControlPatch.cs | 1 - FinalSuspect/Patches/Game_Vanilla/HudPatch.cs | 236 +----------------- .../Patches/Game_Vanilla/IntroPatch.cs | 3 +- .../Patches/Game_Vanilla/LobbyPatch.cs | 1 - .../Game_Vanilla/MapRealTimeLocationPatch.cs | 1 - .../Patches/Game_Vanilla/OutroPatch.cs | 59 ++--- .../Game_Vanilla/PlayerContorolPatch.cs | 1 - .../Game_Vanilla/PlayerJoinAndLeftPatch.cs | 5 +- .../Game_Vanilla/ServerDropDownPatch.cs | 1 - .../Patches/Game_Vanilla/ShipStatusPatch.cs | 1 - .../Game_Vanilla/TaskProgressTrackerPatch.cs | 1 - .../Patches/System/AccountManagerPatch.cs | 88 +------ .../Patches/System/AnnouncementPatch.cs | 3 +- FinalSuspect/Patches/System/ClientPatch.cs | 1 - FinalSuspect/Patches/System/ColorPatch.cs | 1 - FinalSuspect/Patches/System/ControlPatch.cs | 41 +-- .../Patches/System/CredentialsPatch.cs | 25 +- .../Patches/System/GameOptionPatch.cs | 1 - .../Patches/System/GameStartManagerPatch.cs | 1 - .../Patches/System/JoinGameButtonPatch.cs | 1 - .../Patches/System/LoadManagerPatch.cs | 1 - FinalSuspect/Patches/System/LoadPatch.cs | 15 +- FinalSuspect/Patches/System/LobbyListPatch.cs | 1 - .../Patches/System/LobbyPanelPatch.cs | 102 +------- .../Patches/System/LobbyScreenPatch.cs | 6 +- .../System/MainMenuButtonHoverAnimation.cs | 12 +- .../Patches/System/MainMenuManagerPatch.cs | 5 +- .../Patches/System/MeetingButtonPatch.cs | 1 - FinalSuspect/Patches/System/PhasePatch.cs | 14 +- .../Patches/System/RegionMenuPatch.cs | 1 - .../System/SwitchShipCostumeButtonPatch.cs | 1 - FinalSuspect/Templates/SimpleButton.cs | 1 - FinalSuspect/Templates/TMPTemplate.cs | 1 - FinalSuspect/main.cs | 2 - 87 files changed, 694 insertions(+), 657 deletions(-) create mode 100644 FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs rename FinalSuspect/Modules/{Features => Core/Game/UI}/InGameRoleInfoMenu.cs (66%) create mode 100644 FinalSuspect/Modules/Core/Game/UI/LastResult.cs create mode 100644 FinalSuspect/Modules/Core/Game/UI/LoadingAnima.cs create mode 100644 FinalSuspect/Modules/Core/Game/UI/ModGameManager.cs create mode 100644 FinalSuspect/Modules/Core/Game/UI/StartAnima.cs rename FinalSuspect/Modules/{Features => Core/Plugin/UI}/CustomPopup.cs (99%) rename FinalSuspect/Modules/Core/Plugin/{ModMainMenuManager.cs => UI/MainMenu.cs} (92%) diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index 5fbd01c..a9c7102 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -32,15 +32,18 @@ Starlight为安卓平台带来了模组体验。 ## 修正 - 修复了部分分辨率下出现UI错误的问题 - 修复了「人满自动开始游戏」错误多次开始游戏导致游戏崩溃的问题 +- 修复了预设信息板无法隐藏的问题 修复: Slok ## 优化 +- 优化代码 ## 更改 - 修改职业介绍格式 制作: Slok, LezaiYa - 适当缩小预设信息板 - 将[LezaiYa]("https://github.com/NewLezaiYa")列入**开发者** +制作: Slok ## 新增 - 适配**Among Us v17.0.0** @@ -55,4 +58,7 @@ Starlight为安卓平台带来了模组体验。 ## 重制 -## 删除 \ No newline at end of file +## 删除 +- 暂时删除: ~~快捷键: 左Shift: 加入上一个加入的房间~~ +- 暂时删除: ~~快捷键: 右Shift: 加入剪贴板中的房间~~ +决定: Slok | 原因: 易误触&无恰当展示空间 \ No newline at end of file diff --git a/FinalSuspect/ClientItems/ClientActionItem.cs b/FinalSuspect/ClientItems/ClientActionItem.cs index b782679..0222db5 100644 --- a/FinalSuspect/ClientItems/ClientActionItem.cs +++ b/FinalSuspect/ClientItems/ClientActionItem.cs @@ -1,6 +1,5 @@ using System; using FinalSuspect.Helpers; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/ClientItems/ClientFeatureItem.cs b/FinalSuspect/ClientItems/ClientFeatureItem.cs index 841cbdc..b7947e8 100644 --- a/FinalSuspect/ClientItems/ClientFeatureItem.cs +++ b/FinalSuspect/ClientItems/ClientFeatureItem.cs @@ -1,6 +1,5 @@ using System; using FinalSuspect.Helpers; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/ClientItems/ClientItemsPatch.cs b/FinalSuspect/ClientItems/ClientItemsPatch.cs index f60e9ee..7ee5bfa 100644 --- a/FinalSuspect/ClientItems/ClientItemsPatch.cs +++ b/FinalSuspect/ClientItems/ClientItemsPatch.cs @@ -7,9 +7,8 @@ using FinalSuspect.ClientItems.FeatureItems.NameTag; using FinalSuspect.ClientItems.FeatureItems.Resources; using FinalSuspect.Helpers; -using FinalSuspect.Modules.Features; +using FinalSuspect.Modules.Core.Plugin.UI; using FinalSuspect.Patches.System; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.ClientItems; @@ -323,14 +322,14 @@ public static void Postfix() OptionsMenuBehaviourStartPatch.Recreate = true; try { - Object.Destroy(ModMainMenuManager.VisitText); + Object.Destroy(MainMenu.VisitText); } catch { /* ignored */ } - ModMainMenuManager.VisitText = null; + MainMenu.VisitText = null; VersionShowerStartPatch.CreateVisitText(null); OptionsMenuBehaviourStartPatch.Postfix(OptionsMenuBehaviourStartPatch.Instance); } diff --git a/FinalSuspect/ClientItems/ClientOptionItem.cs b/FinalSuspect/ClientItems/ClientOptionItem.cs index bb3ae17..f48223f 100644 --- a/FinalSuspect/ClientItems/ClientOptionItem.cs +++ b/FinalSuspect/ClientItems/ClientOptionItem.cs @@ -1,7 +1,6 @@ using System; using BepInEx.Configuration; using FinalSuspect.Helpers; -using UnityEngine; namespace FinalSuspect.ClientItems; diff --git a/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs index 543b0f1..579299d 100644 --- a/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStyleManager.cs @@ -1,7 +1,6 @@ using System.IO; using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Modules.Resources; -using UnityEngine; namespace FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; diff --git a/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs index ef881be..52a7152 100644 --- a/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MainMenuStyle/MainMenuStylePanel.cs @@ -1,9 +1,9 @@ using System; using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Helpers; +using FinalSuspect.Modules.Core.Plugin.UI; using FinalSuspect.Patches.System; using TMPro; -using UnityEngine; using UnityEngine.UI; using static FinalSuspect.ClientItems.FeatureItems.MainMenuStyle.MainMenuStyleManager; using Object = UnityEngine.Object; @@ -85,7 +85,7 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) MainMenuStyles.Where(x => x.Applied).Do(x => x.CurrentState = CurrentState.NotApply); style.CurrentState = CurrentState.Applied; Refresh(style); - var sr = ModMainMenuManager.FinalSuspect_Background.GetComponent(); + var sr = MainMenu.FinalSuspect_Background.GetComponent(); sr.sprite = style.Sprite; if (id == 3) @@ -95,8 +95,8 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) sr.sprite = LoadSprite("FinalSuspect-BG-MiraStudioNewYear.png", 179f); } - ModMainMenuManager.Starfield.SetActive(style.StarFieldActive); - var starGen = ModMainMenuManager.Starfield.GetComponent(); + MainMenu.Starfield.SetActive(style.StarFieldActive); + var starGen = MainMenu.Starfield.GetComponent(); starGen.SetDirection(new Vector2(0, style.StarGenDire)); var instance = DestroyableSingleton.Instance; @@ -104,7 +104,7 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) var standardActiveSprite = instance.newsButton.activeSprites.GetComponent().sprite; var minorActiveSprite = instance.quitButton.activeSprites.GetComponent().sprite; AwakeFriendCodeUIPatch.Prefix(); - var friendsButton = ModMainMenuManager.FriendsButton.GetComponent(); + var friendsButton = MainMenu.FriendsButton.GetComponent(); Dictionary, (Sprite, Color, Color, Color, Color)> mainButtons = new() { { @@ -127,10 +127,10 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) [ instance.creditsButton, instance.quitButton, - ModMainMenuManager.InviteButton.GetComponent(), - ModMainMenuManager.GithubButton.GetComponent(), - ModMainMenuManager.BugReportButton.GetComponent(), - ModMainMenuManager.WebsiteButton.GetComponent() + MainMenu.InviteButton.GetComponent(), + MainMenu.GithubButton.GetComponent(), + MainMenu.BugReportButton.GetComponent(), + MainMenu.WebsiteButton.GetComponent() ], (minorActiveSprite, style.MainUIColors[2], shade, Color.white, Color.white) }, @@ -146,8 +146,8 @@ private static void CreateApplyButton(ToggleButtonBehaviour template) kvp.Value.Item5); }); - if (ModMainMenuManager.BackgroundTexture) - ModMainMenuManager.BackgroundTexture.GetComponent().color = + if (MainMenu.BackgroundTexture) + MainMenu.BackgroundTexture.GetComponent().color = style.MainUIColors[0].SetAlpha(1); var lastAudio = FinalMusic.Musics.FirstOrDefault(x => x.PlayAsMainMenuMusic); diff --git a/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs b/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs index aa9296a..dc624c0 100644 --- a/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs +++ b/FinalSuspect/ClientItems/FeatureItems/ModUnloaderScreen.cs @@ -2,7 +2,6 @@ using FinalSuspect.Patches.System; using InnerNet; using TMPro; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs index b5b8299..98814fd 100644 --- a/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioLoader.cs @@ -3,7 +3,6 @@ using System.Text; using System.Threading.Tasks; using NAudio.Wave; -using UnityEngine; // ReSharper disable RedundantAssignment diff --git a/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs index 88dcfc4..d939d8c 100644 --- a/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioManager.cs @@ -4,7 +4,6 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Features.CheckingandBlocking; using FinalSuspect.Modules.Resources; -using UnityEngine; namespace FinalSuspect.ClientItems.FeatureItems.MyMusic; diff --git a/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs index 31bb0ed..0265258 100644 --- a/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/AudioPlayer.cs @@ -1,7 +1,6 @@ using System; using System.Collections; using BepInEx.Unity.IL2CPP.Utils; -using UnityEngine; using UnityEngine.SceneManagement; using Object = UnityEngine.Object; diff --git a/FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs b/FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs index a00b5d7..7912ea9 100644 --- a/FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/MyMusic/MyMusicPanel.cs @@ -2,10 +2,9 @@ using System.Diagnostics.CodeAnalysis; using FinalSuspect.Helpers; using TMPro; -using UnityEngine; using UnityEngine.UI; -using Object = UnityEngine.Object; using static FinalSuspect.ClientItems.FeatureItems.MyMusic.AudioPlayer; +using Object = UnityEngine.Object; namespace FinalSuspect.ClientItems.FeatureItems.MyMusic; diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs index d0b0fd4..52f573c 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagEditMenu.cs @@ -5,7 +5,6 @@ using Il2CppSystem.IO; using Newtonsoft.Json; using TMPro; -using UnityEngine; using static FinalSuspect.ClientItems.FeatureItems.NameTag.NameTagManager; using Component = FinalSuspect.ClientItems.FeatureItems.NameTag.NameTagManager.Component; using File = System.IO.File; diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs index 1e709af..9c3062d 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs @@ -7,7 +7,6 @@ using FinalSuspect.Modules.Resources; using Il2CppSystem.Linq; using Newtonsoft.Json.Linq; -using UnityEngine; namespace FinalSuspect.ClientItems.FeatureItems.NameTag; diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs index eae3ecd..6b606ad 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagNewWindow.cs @@ -1,7 +1,6 @@ using System; using System.Text.RegularExpressions; using TMPro; -using UnityEngine; namespace FinalSuspect.ClientItems.FeatureItems.NameTag; diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs index f8af618..6d0df82 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagPanel.cs @@ -1,7 +1,6 @@ using System; using FinalSuspect.Helpers; using TMPro; -using UnityEngine; using UnityEngine.UI; using static FinalSuspect.ClientItems.FeatureItems.NameTag.NameTagManager; using Object = UnityEngine.Object; diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs index c7d7b2d..4331949 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/UiHelper.cs @@ -1,7 +1,6 @@ using System; using FinalSuspect.Helpers; using TMPro; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs b/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs index 57d4123..a401dc4 100644 --- a/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs +++ b/FinalSuspect/ClientItems/FeatureItems/Resources/ResourcesPanel.cs @@ -4,10 +4,9 @@ using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Helpers; -using FinalSuspect.Modules.Features; +using FinalSuspect.Modules.Core.Plugin.UI; using FinalSuspect.Modules.Resources; using TMPro; -using UnityEngine; using UnityEngine.UI; using static FinalSuspect.ClientItems.FeatureItems.Resources.ResourcesManager; using Object = UnityEngine.Object; diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs index 80c4c1c..da595b2 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/DllChecker.cs @@ -1,11 +1,10 @@ +using BepInEx; +using BepInEx.Unity.IL2CPP; +using FinalSuspect.Attributes; #if Windows using System; using System.IO; -using UnityEngine; #endif -using BepInEx; -using BepInEx.Unity.IL2CPP; -using FinalSuspect.Attributes; namespace FinalSuspect.DataHandling.FinalAntiCheat.Core; diff --git a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs index e884503..bdc7d0f 100644 --- a/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs +++ b/FinalSuspect/DataHandling/FinalAntiCheat/Core/Git.cs @@ -1,6 +1,5 @@ #if Windows using System.IO; -using UnityEngine; #endif [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))] diff --git a/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs b/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs index 8ea25d9..e61d3ce 100644 --- a/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs +++ b/FinalSuspect/DataHandling/FinalGameData/FinalGameData.cs @@ -1,16 +1,9 @@ using FinalSuspect.Attributes; -using UnityEngine; namespace FinalSuspect.DataHandling.FinalGameData; public static partial class FinalGameData { - public static string LastResultText; - public static string LastRoomCode; - public static string LastServer; - public static string LastGameData; - public static string LastGameResult; - public static Color LastLocalPlayerRoleColor; public static bool JoinedCompleted; public static bool IntroDestroyed; public static string HostNickName = ""; @@ -19,7 +12,6 @@ public static partial class FinalGameData public static void Init() { IntroDestroyed = false; - LastResultText = LastGameData = LastGameResult = LastRoomCode = LastServer = ""; } } diff --git a/FinalSuspect/DataHandling/FinalLocalHandling.cs b/FinalSuspect/DataHandling/FinalLocalHandling.cs index d8ac5a5..327d21b 100644 --- a/FinalSuspect/DataHandling/FinalLocalHandling.cs +++ b/FinalSuspect/DataHandling/FinalLocalHandling.cs @@ -4,7 +4,6 @@ using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using FinalSuspect.Modules.Features.CheckingandBlocking; using TMPro; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.DataHandling; diff --git a/FinalSuspect/DataHandling/FinalPlayerData.cs b/FinalSuspect/DataHandling/FinalPlayerData.cs index 14d0338..678a1e4 100644 --- a/FinalSuspect/DataHandling/FinalPlayerData.cs +++ b/FinalSuspect/DataHandling/FinalPlayerData.cs @@ -6,7 +6,6 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using FinalSuspect.Modules.Features.DisplayedRoleTag; -using UnityEngine; namespace FinalSuspect.DataHandling; @@ -50,7 +49,7 @@ public void SetRole(RoleTypes role) if (!RoleAssigned) { RoleWhenAlive = role; - SetAsImp(RoleHelper.IsImpostor(role)); + SetAsImp(role.IsImpostor()); } else { diff --git a/FinalSuspect/GlobalUsings.cs b/FinalSuspect/GlobalUsings.cs index 6343f92..ae92008 100644 --- a/FinalSuspect/GlobalUsings.cs +++ b/FinalSuspect/GlobalUsings.cs @@ -1,16 +1,13 @@ -//全局的using -//爱了爱了 -//古希腊掌管using的神 - global using System.Collections.Generic; global using System.Linq; global using System.Reflection; global using FinalSuspect.DataHandling; global using FinalSuspect.Modules.Core.Plugin; global using HarmonyLib; +global using UnityEngine; global using static FinalSuspect.DataHandling.FinalAntiCheat.Core.FAC; global using static FinalSuspect.DataHandling.FinalGameData.FinalGameData.GameStates; global using static FinalSuspect.Modules.Core.Game.Utils; -global using static FinalSuspect.Modules.Core.Plugin.Translator; global using static FinalSuspect.Modules.Core.Plugin.FinalLogger; +global using static FinalSuspect.Modules.Core.Plugin.Translator; global using static FinalSuspect.Modules.Resources.PathManager; \ No newline at end of file diff --git a/FinalSuspect/Helpers/AudioSourceHelper.cs b/FinalSuspect/Helpers/AudioSourceHelper.cs index a060f87..c838bc4 100644 --- a/FinalSuspect/Helpers/AudioSourceHelper.cs +++ b/FinalSuspect/Helpers/AudioSourceHelper.cs @@ -1,5 +1,3 @@ -using UnityEngine; - namespace FinalSuspect.Helpers; public static class AudioSourceHelper diff --git a/FinalSuspect/Helpers/ColorHelper.cs b/FinalSuspect/Helpers/ColorHelper.cs index 741ff40..c35f7c1 100644 --- a/FinalSuspect/Helpers/ColorHelper.cs +++ b/FinalSuspect/Helpers/ColorHelper.cs @@ -1,6 +1,4 @@ -using UnityEngine; - -namespace FinalSuspect.Helpers; +namespace FinalSuspect.Helpers; public static class ColorHelper { diff --git a/FinalSuspect/Helpers/ObjectHelper.cs b/FinalSuspect/Helpers/ObjectHelper.cs index 3e8652f..73208e6 100644 --- a/FinalSuspect/Helpers/ObjectHelper.cs +++ b/FinalSuspect/Helpers/ObjectHelper.cs @@ -1,5 +1,5 @@ using Il2CppSystem; -using UnityEngine; +using TMPro; using Object = UnityEngine.Object; namespace FinalSuspect.Helpers; @@ -59,4 +59,13 @@ public static SpriteRenderer CreateSpriteRenderer(string name, string spriteName return renderer; } + + public static TextMeshPro InstantiateTextComponent(TextMeshPro template, Vector3 position, Transform parent = null) + { + var text = Object.Instantiate(template, parent); + text.transform.localPosition = position; + text.fontStyle = FontStyles.Bold; + text.text = string.Empty; + return text; + } } \ No newline at end of file diff --git a/FinalSuspect/Helpers/ResourcesHelper.cs b/FinalSuspect/Helpers/ResourcesHelper.cs index 4b6eda1..4b30f7d 100644 --- a/FinalSuspect/Helpers/ResourcesHelper.cs +++ b/FinalSuspect/Helpers/ResourcesHelper.cs @@ -50,8 +50,8 @@ public static class ResourcesHelper "Plate_Category.png", "Plate_Content.png", "KeyBackground.png", - "KeyLeftShift.png", - "KeyRightShift.png", + //"KeyLeftShift.png", + //"KeyRightShift.png", "LastResult-BG.png", ]; diff --git a/FinalSuspect/Helpers/RoleHelper.cs b/FinalSuspect/Helpers/RoleHelper.cs index 9c6296f..5f51c65 100644 --- a/FinalSuspect/Helpers/RoleHelper.cs +++ b/FinalSuspect/Helpers/RoleHelper.cs @@ -1,6 +1,5 @@ using System; using AmongUs.GameOptions; -using UnityEngine; namespace FinalSuspect.Helpers; diff --git a/FinalSuspect/Helpers/StringHelper.cs b/FinalSuspect/Helpers/StringHelper.cs index 47cc319..31c8624 100644 --- a/FinalSuspect/Helpers/StringHelper.cs +++ b/FinalSuspect/Helpers/StringHelper.cs @@ -1,6 +1,5 @@ using System.Text; using System.Text.RegularExpressions; -using UnityEngine; namespace FinalSuspect.Helpers; diff --git a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Data.cs b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Data.cs index 089262c..0d16b9b 100644 --- a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Data.cs +++ b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Data.cs @@ -2,7 +2,6 @@ using FinalSuspect.DataHandling.FinalAntiCheat.Core; using FinalSuspect.DataHandling.FinalGameData; using FinalSuspect.Helpers; -using UnityEngine; namespace FinalSuspect.Modules.Core.Game.PlayerControlExtension; diff --git a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs index 1c7c57a..a5bfd8a 100644 --- a/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs +++ b/FinalSuspect/Modules/Core/Game/PlayerControlExtension/_Role.cs @@ -1,6 +1,5 @@ using AmongUs.GameOptions; using FinalSuspect.Helpers; -using UnityEngine; namespace FinalSuspect.Modules.Core.Game.PlayerControlExtension; @@ -13,7 +12,7 @@ public static RoleTypes GetRoleType(this PlayerControl player) public static bool IsImpostor(this PlayerControl pc) { - return !IsLobby && RoleHelper.IsImpostor(pc.GetRoleType()); + return !IsLobby && pc.GetRoleType().IsImpostor(); } public static string GetNameWithRole(this PlayerControl player, bool forUser = false) diff --git a/FinalSuspect/Modules/Core/Game/ServerAddManager.cs b/FinalSuspect/Modules/Core/Game/ServerAddManager.cs index a7cd58e..1d9198a 100644 --- a/FinalSuspect/Modules/Core/Game/ServerAddManager.cs +++ b/FinalSuspect/Modules/Core/Game/ServerAddManager.cs @@ -1,9 +1,8 @@ -#if Windows +using FinalSuspect.Helpers; +using FinalSuspect.Patches.System; +#if Windows using FinalSuspect.Attributes; #endif -using FinalSuspect.Helpers; -using FinalSuspect.Patches.System; -using UnityEngine; namespace FinalSuspect.Modules.Core.Game; diff --git a/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs b/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs new file mode 100644 index 0000000..3aa1e06 --- /dev/null +++ b/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs @@ -0,0 +1,104 @@ +using FinalSuspect.Attributes; +using FinalSuspect.DataHandling.FinalGameData; +using FinalSuspect.Modules.Features.DisplayedRoleTag; +using TMPro; +using static FinalSuspect.Modules.Core.Game.UI.ModGameManager; + +namespace FinalSuspect.Modules.Core.Game.UI; + +public static class InGameInfoPane +{ + private static GameObject _switchPaneButton; + public static LobbyInfoPane Instance; + + [GameModuleInitializer] + public static void OnInitialization() + { + var lobbyPane = Instance; + var aspect = lobbyPane.transform.FindChild("AspectSize"); + SetupInfoPaneUI(aspect); + AdjustInfoPane(lobbyPane); + CreateHidePaneButton(aspect); + } + + private static void SetupInfoPaneUI(Transform aspect) + { + var trans = aspect.FindChild("GameSettingsButtons"); + + trans.FindChild("Host Buttons").gameObject.SetActive(false); + trans.FindChild("Client Buttons").gameObject.SetActive(true); + + var header = trans.FindChild("ButtonSettingsHeader").gameObject; + var headerTransform = header.transform; + headerTransform.localPosition = + new Vector3(-0.282f, headerTransform.localPosition.y, headerTransform.localPosition.z); + + var tmp = header.GetComponent(); + tmp.text += $" - {GetString("PressF2ToHidePane")}"; + + var rect = header.GetComponent(); + rect.sizeDelta = new Vector2(3f, rect.sizeDelta.y); + } + + private static void AdjustInfoPane(LobbyInfoPane lobbyPane) + { + var aspectPosition = lobbyPane.gameObject.GetComponent(); + aspectPosition.DistanceFromEdge += Vector3.forward * -60; + + lobbyPane.gameObject.transform.localScale *= 0.8f; + } + + private static void CreateHidePaneButton(Transform aspect) + { + if (_switchPaneButton != null) + { + Object.Destroy(_switchPaneButton); + _switchPaneButton = null; + } + + + var buttonTemplate = aspect.FindChild("GameCodeSection").FindChild("CopyGameCodeButton").gameObject; + _switchPaneButton = CreateFunctionalButton( + buttonTemplate, + HudManager.Instance.gameObject.transform, + "Show Hide Panel Button", + new Vector3(-0.2f, -0.5f, 1f), + "eye.png", + new Color(0.8f, 0.8f, 1f, 0.3f), + new Vector3(0.22f, 1.85f, -80f), + () => + { + Test(1); + ConfigManager.ShowInfoPanel.Value = !ConfigManager.ShowInfoPanel.Value; + Test(ConfigManager.ShowInfoPanel.Value); + }); + } + + public static void CheckForHotkey() + { + if (!Input.GetKeyDown(KeyCode.F2) || !IsInGame) return; + Test(0); + ConfigManager.ShowInfoPanel.Value = !ConfigManager.ShowInfoPanel.Value; + Test(ConfigManager.ShowInfoPanel.Value); + } + + public static void SetShowInfoPanel() + { + var showInfo = ConfigManager.ShowInfoPanel.Value; + var map = MapBehaviour.Instance != null && (MapBehaviour.Instance?.gameObject.activeSelf ?? false); + var notShowPane = + (DestroyableSingleton.Instance?.Chat?.IsOpenOrOpening ?? false) + || map + || !showInfo + || !FinalGameData.IntroDestroyed + || (DisplayerRoleTagHelper.selectionUI?.active ?? false); + if (IsFreePlay || !IsInGame) return; + if ((Instance?.gameObject.activeSelf ?? true) && notShowPane) + { + Test(0); + Instance?.DeactivatePane(); + } + + Instance?.gameObject.SetActive(!notShowPane); + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs b/FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs similarity index 66% rename from FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs rename to FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs index 9720bdb..d019b70 100644 --- a/FinalSuspect/Modules/Features/InGameRoleInfoMenu.cs +++ b/FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs @@ -3,9 +3,9 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using TMPro; -using UnityEngine; +using static FinalSuspect.Modules.Core.Game.UI.ModGameManager; -namespace FinalSuspect.Modules.Features; +namespace FinalSuspect.Modules.Core.Game.UI; public static class InGameRoleInfoMenu { @@ -20,6 +20,8 @@ public static class InGameRoleInfoMenu private static GameObject RoleInfo; private static GameObject RoleIllustration; + + private static GameObject _roleInfoPaneButton; public static bool Showing => Fill && Fill.active && Menu && Menu.active; private static SpriteRenderer FillRend => Fill.GetComponent(); private static SpriteRenderer RoleIllustrationRend => RoleIllustration.GetComponent(); @@ -62,7 +64,7 @@ private static void Init() ForceHide(); } - public static void SetRoleInfoRef(PlayerControl player) + private static void SetRoleInfoRef(PlayerControl player) { if (!player) return; if (!Fill || !Menu) Init(); @@ -74,7 +76,7 @@ public static void SetRoleInfoRef(PlayerControl player) // 职业阵营 / 原版职业 var roleTeam = player.IsImpostor() ? "Imp" : "Crew"; builder.Append($" ({GetString($"RoleType.{roleTeam}")})\n"); - builder.Append($"{RoleHelper.GetRoleInfoForVanilla(player.GetRoleType(), true) ?? ""}\n"); + builder.Append($"{player.GetRoleType().GetRoleInfoForVanilla(true) ?? ""}\n"); RoleInfoTMP.text = builder.ToString(); var HnSPrefix = ""; if (!IsNormalGame && player.IsAlive()) @@ -82,7 +84,7 @@ public static void SetRoleInfoRef(PlayerControl player) RoleIllustrationRend.sprite = LoadSprite($"CI_{HnSPrefix + role}.png", 320f); } - public static void Toggle() + private static void Toggle() { if (Showing) Hide(); @@ -92,27 +94,73 @@ public static void Toggle() } } - public static void Show() + private static void Show() { if (!Fill || !Menu) Init(); if (Showing) return; Fill?.SetActive(true); Menu?.SetActive(true); - //HudManager.Instance?.gameObject.SetActive(false); } - public static void Hide() + private static void Hide() { if (!Showing) return; - Fill?.SetActive(false); - Menu?.SetActive(false); - //HudManager.Instance?.gameObject?.SetActive(true); + ForceHide(); } - public static void ForceHide() + private static void ForceHide() { Fill?.SetActive(false); Menu?.SetActive(false); - //HudManager.Instance?.gameObject?.SetActive(true); + } + + [GameModuleInitializer] + public static void OnInitialization() + { + var lobbyPane = InGameInfoPane.Instance; + var aspect = lobbyPane.transform.FindChild("AspectSize"); + CreateRoleInfoButton(aspect); + } + + private static void CreateRoleInfoButton(Transform aspect) + { + if (_roleInfoPaneButton != null) + { + Object.Destroy(_roleInfoPaneButton); + _roleInfoPaneButton = null; + } + + var buttonTemplate = aspect.FindChild("GameCodeSection").FindChild("CopyGameCodeButton").gameObject; + _roleInfoPaneButton = CreateFunctionalButton( + buttonTemplate, + HudManager.Instance.gameObject.transform, + "Role Info Panel Button", + new Vector3(-0.2f, -0.5f, 1f), + "roleHelp.png", + new Color(0.8f, 0.8f, 0.8f, 0.3f), + new Vector3(0.58f, 1.85f, -800f), + () => + { + if (!IsInGame || (!IsCanMove && !IsInMeeting)) return; + if (!Showing) + SetRoleInfoRef(PlayerControl.LocalPlayer); + Toggle(); + } + ); + } + + public static void CheckForHotkey() + { + if (IsInGame && (IsCanMove || IsInMeeting)) + { + if (!Input.GetKeyDown(KeyCode.F1)) return; + if (!Showing) + SetRoleInfoRef(PlayerControl.LocalPlayer); + Toggle(); + } + else + { + Hide(); + } } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/UI/LastResult.cs b/FinalSuspect/Modules/Core/Game/UI/LastResult.cs new file mode 100644 index 0000000..455e7ba --- /dev/null +++ b/FinalSuspect/Modules/Core/Game/UI/LastResult.cs @@ -0,0 +1,174 @@ +using System; +using System.Text; +using AmongUs.Data; +using AmongUs.GameOptions; +using FinalSuspect.Attributes; +using FinalSuspect.Helpers; +using FinalSuspect.Modules.Core.Game.PlayerControlExtension; +using FinalSuspect.Patches.System; +using FinalSuspect.Templates; +using InnerNet; +using TMPro; +using Object = UnityEngine.Object; + +namespace FinalSuspect.Modules.Core.Game.UI; + +public static class LastResult +{ + public static TextMeshPro roleSummary; + public static SimpleButton LastResultButton; + public static bool DidHumansWin; + private static SpriteRenderer backgroundRenderer; + + public static string LastResultText; + public static string LastRoomCode; + public static string LastServer; + public static string LastGameData; + public static string LastGameResult; + public static Color LastLocalPlayerRoleColor; + + + public static Dictionary SummaryText = new(); + + [GameModuleInitializer] + public static void OnInitialization() + { + DestroyAll(); + LastResultText = LastGameData = LastGameResult = LastRoomCode = LastServer = ""; + } + + public static void DestroyAll() + { + try + { + Object.Destroy(LastResultButton.Button.gameObject); + Object.Destroy(roleSummary.gameObject); + Object.Destroy(backgroundRenderer.gameObject); + } + catch + { + /* ignored */ + } + + LastResultButton = null; + roleSummary = null; + backgroundRenderer = null; + } + + public static void UpdateResult(HudManager __instance) + { + if (IsFreePlay || (!IsInGame && GetLineCount(LastResultText) < 6)) + return; + var showInitially = ConfigManager.ShowResults.Value; + + LastResultButton ??= + new SimpleButton( + __instance.transform, + "Show Hide Last Result Button", + IsInGame + ? new Vector3(0.2f * GetResolutionOffset(), 2.685f, -14f) + : new Vector3(-4.5f * GetResolutionOffset(), 2.6f, -14f), // 比 BackgroundLayer(z = -13) 更靠前 + new Color32(209, 190, 255, byte.MaxValue), + new Color32(208, 222, 255, byte.MaxValue), + () => + { + var setToActive = !roleSummary.gameObject.activeSelf; + roleSummary.gameObject.SetActive(setToActive); + ConfigManager.ShowResults.Value = setToActive; + LastResultButton.Label.text = + GetString(setToActive ? "Summary.HideResults" : "Summary.ShowResults"); + }, + GetString(showInitially ? "Summary.HideResults" : "Summary.ShowResults")) + { + Scale = new Vector2(1.5f, 0.5f), + FontSize = 2f + }; + + LastResultButton.Button.gameObject.SetActive(true); + + StringBuilder sb = new($"{GetString("Summary.Text")}{LastGameResult}"); + if (IsInGame) + { + LastRoomCode = GameCode.IntToGameName(AmongUsClient.Instance.GameId); + LastServer = IsOnlineGame + ? PingTrackerUpdatePatch.ServerName + : GetString("Local"); + } + + var gamecode = StringHelper.ColorString( + ColorHelper.FSColor, + DataManager.Settings.Gameplay.StreamerMode + ? new string('*', LastRoomCode.Length) + : LastRoomCode); + sb.Append("\n" + LastServer + " " + gamecode); + if (IsInGame) + { + StringBuilder sb2 = new(); + foreach (var data in FinalPlayerData.AllPlayerData) + sb2.Append("\n\u3000 ").Append(SummaryTexts(data.PlayerId)); + + LastGameData = sb2.ToString(); + } + + sb.Append(LastGameData); + LastResultText = sb.ToString(); + if (!roleSummary) + { + roleSummary = TMPTemplate.Create( + "RoleSummaryText", LastResultText, + Color.white, + 1.25f, + TextAlignmentOptions.TopLeft, + showInitially, + LastResultButton.Button.transform); + roleSummary.transform.localPosition = + new Vector3(IsInGame ? 0f : 1.7f, -0.4f, -1f); + roleSummary.transform.localScale = new Vector3(1.2f, 1.2f, 1f); + roleSummary.fontStyle = FontStyles.Bold; + roleSummary.SetOutlineColor(Color.black); + roleSummary.SetOutlineThickness(0.15f); + + var backgroundObject = new GameObject("RoleSummaryBackground"); + backgroundObject.transform.SetParent(roleSummary.transform); + backgroundRenderer = backgroundObject.AddComponent(); + backgroundRenderer.sprite = LoadSprite("LastResult-BG.png", 200f); + backgroundRenderer.color = new Color(0.5f, 0.5f, 0.5f, 1f); + } + + LastResultButton.Button.transform.localPosition = + IsInGame ? new Vector3(0.2f, 2.685f, -14f) : new Vector3(-4.5f, 2.6f, -1f); + if (IsInGame) + { + LastResultButton.Button.gameObject.SetActive + (PlayerControl.LocalPlayer.GetRoleType() is RoleTypes.CrewmateGhost or RoleTypes.ImpostorGhost && + !IsInMeeting); + } + else + LastResultButton.Button.gameObject.SetActive(true); + + roleSummary.text = LastResultText; + AdjustBackgroundSize(); + } + + private static void AdjustBackgroundSize() + { + if (!roleSummary || !backgroundRenderer) return; + var textBounds = roleSummary.textBounds; + + var backgroundSprite = backgroundRenderer.sprite; + if (!backgroundSprite) return; + var scaleX = (textBounds.size.x + 0.4f) / backgroundSprite.bounds.size.x; + var scaleY = (textBounds.size.y + 0.5f) / backgroundSprite.bounds.size.y; + + backgroundRenderer.transform.localScale = new Vector3(scaleX, scaleY, 1f); + backgroundRenderer.transform.localPosition = new Vector3(textBounds.center.x, textBounds.center.y, 2f); + } + + private static int GetLineCount(string text) + { + if (string.IsNullOrEmpty(text)) + return 0; + var lines = text.Split(["\r\n", "\n"], StringSplitOptions.None); + return lines.Length; + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/UI/LoadingAnima.cs b/FinalSuspect/Modules/Core/Game/UI/LoadingAnima.cs new file mode 100644 index 0000000..26a1559 --- /dev/null +++ b/FinalSuspect/Modules/Core/Game/UI/LoadingAnima.cs @@ -0,0 +1,126 @@ +using System.Collections; +using BepInEx.Unity.IL2CPP.Utils; +using FinalSuspect.Attributes; + +namespace FinalSuspect.Modules.Core.Game.UI; + +public static class LoadingAnima +{ + private static GameObject ModLoading; + private static int currentIndex; + + private static readonly List AllRoleRoleIllustration = + []; + + private static readonly string[] CI_Order = + [ + "Crewmate", + "HnSEngineer", + "Engineer", + "GuardianAngel", + "Scientist", + "Tracker", + "Noisemaker", + "Detective", + "CrewmateGhost", + "Impostor", + "HnSImpostor", + "Shapeshifter", + "Phantom", + "Viper", + "ImpostorGhost", + ]; + + [PluginModuleInitializer] + public static void OnInitialization() + { + foreach (var role in CI_Order) + { + AllRoleRoleIllustration.Add(LoadSprite($"CI_{role}.png", 450f)); + } + } + + public static void Create(HudManager __instance) + { + if (!ModLoading) + { + ModLoading = new GameObject("ModLoading") { layer = 5 }; + ModLoading.transform.SetParent(__instance.GameLoadAnimation.transform.parent); + + var Sprite = ModLoading.AddComponent(); + Sprite.color = Color.white; + Sprite.flipX = false; + ModLoading.SetActive(false); + __instance.StartCoroutine(SwitchRoleIllustration(Sprite)); + + var ap = ModLoading.AddComponent(); + ap.Alignment = AspectPosition.EdgeAlignments.RightBottom; + ap.DistanceFromEdge = new Vector3(0.6f, 0.5f, -1000); + ap.updateAlways = true; + + ModLoading.transform.localScale = new Vector3(0.4f, 0.4f, 1f); + } + + ModLoading.SetActive(!IsInGame && !IsLobby); + } + + public static void Create(AccountManager __instance) + { + try + { + var loading = GameObject.Find("Loading"); + loading.SetActive(false); + + var bgf = GameObject.Find("BackgroundFill"); + var _crewpetWalk0001 = bgf.transform.FindChild("crewpet_walk0001").gameObject; + var r = _crewpetWalk0001.GetComponent(); + r.speed = 0f; + var modLoading = new GameObject("Final Suspect Loading Anima") { layer = 5 }; + modLoading.transform.SetParent(_crewpetWalk0001.transform.parent); + modLoading.transform.localScale = new Vector3(0.4f, 0.4f, 1f); + var sprite = modLoading.AddComponent(); + sprite.color = Color.white; + sprite.flipX = false; + __instance.StartCoroutine(SwitchRoleIllustration(sprite)); + _crewpetWalk0001.SetActive(false); + + var aspectPosition = modLoading.AddComponent(); + aspectPosition.Alignment = AspectPosition.EdgeAlignments.RightBottom; + aspectPosition.DistanceFromEdge = new Vector3(0.6f, 0.5f, -1000); + aspectPosition.updateAlways = true; + } + catch + { + /* ignored */ + } + } + + private static IEnumerator SwitchRoleIllustration(SpriteRenderer renderer) + { + while (true) + { + if (AllRoleRoleIllustration.Count == 0) yield break; + + renderer.sprite = AllRoleRoleIllustration[currentIndex]; + var p = 1f; + while (p > 0f) + { + p -= Time.deltaTime * 2.8f; + var alpha = 1 - p; + renderer.color = Color.white.AlphaMultiplied(alpha); + yield return null; + } + + currentIndex = (currentIndex + 1) % AllRoleRoleIllustration.Count; + + yield return new WaitForSeconds(1f); + p = 1f; + while (p > 0f) + { + p -= Time.deltaTime * 2.8f; + renderer.color = Color.white.AlphaMultiplied(p); + yield return null; + } + } + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/UI/ModGameManager.cs b/FinalSuspect/Modules/Core/Game/UI/ModGameManager.cs new file mode 100644 index 0000000..c2ba35d --- /dev/null +++ b/FinalSuspect/Modules/Core/Game/UI/ModGameManager.cs @@ -0,0 +1,44 @@ +using System; +using UnityEngine.UI; +using Object = UnityEngine.Object; + +namespace FinalSuspect.Modules.Core.Game.UI; + +public static class ModGameManager +{ + public static GameObject CreateFunctionalButton( + GameObject template, + Transform parent, + string name, + Vector3 localPosition, + string iconSpriteName, + Color inactiveColor, + Vector3 edgeDistance, + Action onClickAction) + { + var button = Object.Instantiate(template, parent); + button.name = name; + button.transform.localPosition = localPosition; + button.transform.localScale = new Vector3(0.5f, 0.5f, 1f); + button.SetActive(true); + + Object.Destroy(button.GetComponent()); + + var inactiveSprite = button.transform.FindChild("Inactive").GetComponent(); + inactiveSprite.color = inactiveColor; + + var iconSprite = button.transform.FindChild("Icon").GetComponent(); + iconSprite.sprite = LoadSprite(iconSpriteName, 100f); + + var aspectPos = button.AddComponent(); + aspectPos.updateAlways = true; + aspectPos.Alignment = AspectPosition.EdgeAlignments.Right; + aspectPos.DistanceFromEdge = edgeDistance; + + var passiveButton = button.GetComponent(); + passiveButton.OnClick = new Button.ButtonClickedEvent(); + passiveButton.OnClick.AddListener(new Action(onClickAction)); + + return button; + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/UI/StartAnima.cs b/FinalSuspect/Modules/Core/Game/UI/StartAnima.cs new file mode 100644 index 0000000..7230ee5 --- /dev/null +++ b/FinalSuspect/Modules/Core/Game/UI/StartAnima.cs @@ -0,0 +1,16 @@ +using FinalSuspect.Attributes; +using FinalSuspect.Helpers; + +namespace FinalSuspect.Modules.Core.Game.UI; + +public class StartAnima +{ + [GameModuleInitializer] + public static void OnInitialization() + { + var flash = ObjectHelper.CreateSpriteRenderer("Flash", "eye.png", 0.01f, new Vector3(0, 0, -80)); + flash.color = Color.white; + flash.transform.SetParent(HudManager.Instance.gameObject.transform); + _ = new LateTask(() => { Object.Destroy(flash); }, 1f, "Destroy Flash"); + } +} \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index 9a137e7..3aba21e 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -10,7 +10,6 @@ using FinalSuspect.Modules.Resources; using FinalSuspect.Patches.Game_Vanilla; using InnerNet; -using UnityEngine; namespace FinalSuspect.Modules.Core.Game; diff --git a/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs b/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs index c95cbe2..e30095b 100644 --- a/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs @@ -27,6 +27,7 @@ public static class ConfigManager public static ConfigEntry HideName { get; private set; } public static ConfigEntry HideColor { get; private set; } public static ConfigEntry ShowResults { get; private set; } + public static ConfigEntry ShowInfoPanel { get; private set; } public static ConfigEntry EnableFinalSuspect { get; private set; } public static ConfigEntry LanguageUpdateBypass { get; private set; } public static ConfigEntry CurrentStyleId { get; private set; } @@ -40,13 +41,14 @@ public static void OnInitialization() HideColor = config.Bind("Final System", "Hide Game Code Color", $"{ColorHelper.FSColorHex}"); EnableFinalSuspect = config.Bind("Final System", "Enable Final Suspect", true); ShowResults = config.Bind("Final System", "Show Results", true); + ShowInfoPanel = config.Bind("Final System", "Show InfoPanel", true); LanguageUpdateBypass = config.Bind("Final System", "Language Update Bypass", BypassType.Dont); - CurrentStyleId = config.Bind("Final System", "BG Id", 0); + CurrentStyleId = config.Bind("Final System", "Background Id", 0); UnlockFPS = config.Bind("Client Options", "Unlock FPS", false); SwitchOutfitType = config.Bind("Client Options", "Switch Outfit", OutfitType.BeanMode); - KickPlayerWithAbnormalFriendCode = config.Bind("Client Options", "Kick Player FriendCode Not Exist", true); - KickPlayerInBanList = config.Bind("Client Options", "Kick Player In BanList", true); + KickPlayerWithAbnormalFriendCode = config.Bind("Client Options", "Kick Player With Abnormal FriendCode", true); + KickPlayerInBanList = config.Bind("Client Options", "Kick Player In Ban List", true); KickPlayerWithDenyName = config.Bind("Client Options", "Kick Player With Deny Name", true); SpamDenyWord = config.Bind("Client Options", "Spam Deny Word", true); AutoStartGame = config.Bind("Client Options", "Auto Start Game", false); @@ -59,8 +61,8 @@ public static void OnInitialization() OfflineMode = config.Bind("Client Options", "Offline Mode", false); UseModCursor = config.Bind("Client Options", "Use Mod Cursor", true); - VersionCheat = config.Bind("Client Options", "Version Cheat", false); - GodMode = config.Bind("Client Options", "God Mode", false); - NoGameEnd = config.Bind("Client Options", "No Game End", false); + VersionCheat = config.Bind("Debug Options", "Version Cheat", false); + GodMode = config.Bind("Debug Options", "God Mode", false); + NoGameEnd = config.Bind("Debug Options", "No Game End", false); } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Plugin/ErrorText.cs b/FinalSuspect/Modules/Core/Plugin/ErrorText.cs index f14fc9e..03feb01 100644 --- a/FinalSuspect/Modules/Core/Plugin/ErrorText.cs +++ b/FinalSuspect/Modules/Core/Plugin/ErrorText.cs @@ -1,5 +1,4 @@ using TMPro; -using UnityEngine; namespace FinalSuspect.Modules.Core.Plugin; diff --git a/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs b/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs index ede7ec1..2adde82 100644 --- a/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs +++ b/FinalSuspect/Modules/Core/Plugin/LaunchingInfo.cs @@ -1,5 +1,4 @@ using FinalSuspect.Attributes; -using UnityEngine; namespace FinalSuspect.Modules.Core.Plugin; diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs index 2b3a9ba..5db1fa2 100644 --- a/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/WindowsPreferenceStore.cs @@ -1,6 +1,7 @@ #if Windows #pragma warning disable CA1416 using System; +using System.IO; using Microsoft.Win32; namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; @@ -38,7 +39,7 @@ public void Init() { try { - SetString("Path", System.IO.Path.GetFullPath("./")); + SetString("Path", Path.GetFullPath("./")); Info("[WindowsPreferenceStore] 注册表初始化完成", "Registry Manager"); } catch (Exception e) diff --git a/FinalSuspect/Modules/Features/CustomPopup.cs b/FinalSuspect/Modules/Core/Plugin/UI/CustomPopup.cs similarity index 99% rename from FinalSuspect/Modules/Features/CustomPopup.cs rename to FinalSuspect/Modules/Core/Plugin/UI/CustomPopup.cs index 6f5736b..823c4ec 100644 --- a/FinalSuspect/Modules/Features/CustomPopup.cs +++ b/FinalSuspect/Modules/Core/Plugin/UI/CustomPopup.cs @@ -1,13 +1,12 @@ using System; using FinalSuspect.Helpers; using TMPro; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; #pragma warning disable CS8602 // 解引用可能出现空引用。 -namespace FinalSuspect.Modules.Features; +namespace FinalSuspect.Modules.Core.Plugin.UI; #nullable enable public static class CustomPopup diff --git a/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs b/FinalSuspect/Modules/Core/Plugin/UI/MainMenu.cs similarity index 92% rename from FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs rename to FinalSuspect/Modules/Core/Plugin/UI/MainMenu.cs index 86b3b8b..ed07218 100644 --- a/FinalSuspect/Modules/Core/Plugin/ModMainMenuManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/UI/MainMenu.cs @@ -1,9 +1,8 @@ using TMPro; -using UnityEngine; -namespace FinalSuspect.Modules.Core.Plugin; +namespace FinalSuspect.Modules.Core.Plugin.UI; -public static class ModMainMenuManager +public static class MainMenu { public static MainMenuManager Instance; @@ -41,4 +40,5 @@ public static class ModMainMenuManager public static TextMeshPro CreditTextCredential; public static GameObject ModLogo; public static GameObject AuthorLogo; + public static string CredentialsText; } \ No newline at end of file diff --git a/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs b/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs index c359e12..af5d405 100644 --- a/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs +++ b/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs @@ -3,7 +3,6 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using TMPro; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/Modules/Features/Zoom.cs b/FinalSuspect/Modules/Features/Zoom.cs index 96f06d2..6cb837f 100644 --- a/FinalSuspect/Modules/Features/Zoom.cs +++ b/FinalSuspect/Modules/Features/Zoom.cs @@ -1,7 +1,7 @@ using System; using FinalSuspect.Attributes; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; -using UnityEngine; +using FinalSuspect.Modules.Core.Game.UI; namespace FinalSuspect.Modules.Features; diff --git a/FinalSuspect/Modules/Resources/ModUpdater.cs b/FinalSuspect/Modules/Resources/ModUpdater.cs index bcfe3d3..03c9286 100644 --- a/FinalSuspect/Modules/Resources/ModUpdater.cs +++ b/FinalSuspect/Modules/Resources/ModUpdater.cs @@ -1,3 +1,5 @@ +using FinalSuspect.Modules.Core.Plugin.UI; +using TMPro; #if Windows using System; using System.IO; @@ -5,10 +7,7 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using FinalSuspect.Modules.Features; -using UnityEngine; #endif -using TMPro; namespace FinalSuspect.Modules.Resources; @@ -19,10 +18,10 @@ public class ModUpdater public static void SetUpdateButtonStatus() { - ModMainMenuManager.UpdateButton.SetActive(VersionChecker.IsChecked && VersionChecker.HasUpdate && - (VersionChecker.FirstStart || VersionChecker.ForceUpdate)); - ModMainMenuManager.PlayButton.SetActive(!ModMainMenuManager.UpdateButton.activeSelf); - var buttonText = ModMainMenuManager.UpdateButton.transform.FindChild("FontPlacer").GetChild(0) + MainMenu.UpdateButton.SetActive(VersionChecker.IsChecked && VersionChecker.HasUpdate && + (VersionChecker.FirstStart || VersionChecker.ForceUpdate)); + MainMenu.PlayButton.SetActive(!MainMenu.UpdateButton.activeSelf); + var buttonText = MainMenu.UpdateButton.transform.FindChild("FontPlacer").GetChild(0) .GetComponent(); buttonText.text = $"{(VersionChecker.CanUpdate ? GetString("UpdateRemind.updatePopup") : GetString("UpdateRemind.updateNotice"))}\nv{VersionChecker.ShowVer ?? " ???"}"; diff --git a/FinalSuspect/Modules/Resources/PathManager.cs b/FinalSuspect/Modules/Resources/PathManager.cs index be25420..5fe1fab 100644 --- a/FinalSuspect/Modules/Resources/PathManager.cs +++ b/FinalSuspect/Modules/Resources/PathManager.cs @@ -1,7 +1,6 @@ using System; using System.IO; using FinalSuspect.Attributes; -using UnityEngine; namespace FinalSuspect.Modules.Resources; @@ -266,7 +265,8 @@ public enum FileType SoundEffects, Depends, ModNews, - Languages + Languages, + //AutoDecided //v2.0 } public enum RemoteType diff --git a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs index 86cc373..13fe756 100644 --- a/FinalSuspect/Modules/Resources/ResourcesDownloader.cs +++ b/FinalSuspect/Modules/Resources/ResourcesDownloader.cs @@ -14,13 +14,13 @@ public static class ResourcesDownloader public static async Task StartDownload(FileType fileType, string file) { return await DownloadInternal(fileType, file, - (remoteType) => GetFile(fileType, remoteType, file)); + remoteType => GetFile(fileType, remoteType, file)); } public static async Task StartDownloadAsPackage(string packageName, FileType fileType, string file) { return await DownloadInternal(fileType, file, - (remoteType) => GetPackageFile(packageName, remoteType, file)); + remoteType => GetPackageFile(packageName, remoteType, file)); } private static async Task DownloadInternal( diff --git a/FinalSuspect/Modules/Resources/VersionChecker.cs b/FinalSuspect/Modules/Resources/VersionChecker.cs index 07a62af..529a2f8 100644 --- a/FinalSuspect/Modules/Resources/VersionChecker.cs +++ b/FinalSuspect/Modules/Resources/VersionChecker.cs @@ -4,11 +4,10 @@ using FinalSuspect.ClientItems.FeatureItems.NameTag; using FinalSuspect.ClientItems.FeatureItems.Resources; using FinalSuspect.Helpers; -using FinalSuspect.Modules.Features; +using FinalSuspect.Modules.Core.Plugin.UI; using FinalSuspect.Modules.Features.CheckingandBlocking; using FinalSuspect.Patches.System; using Newtonsoft.Json.Linq; -using UnityEngine; namespace FinalSuspect.Modules.Resources; @@ -73,7 +72,7 @@ private static async Task CheckForUpdate() { IsChecked = false; #if Windows - ModUpdater.DeleteOldFiles(); + ModUpdater.DeleteOldFiles(); #endif @@ -122,7 +121,7 @@ private static async Task CheckForUpdate() } ModUpdater.SetUpdateButtonStatus(); - ModMainMenuManager.VisitText.text = IsChecked + MainMenu.VisitText.text = IsChecked ? string.Format(GetString("FinalSuspectWelcomeText"), ColorHelper.FSColorHex) : GetString("RetrieveVersionInfoFailed"); }, "Check For Update"); diff --git a/FinalSuspect/Patches/Game_Vanilla/ChatBubblePatch.cs b/FinalSuspect/Patches/Game_Vanilla/ChatBubblePatch.cs index cf9e146..3436652 100644 --- a/FinalSuspect/Patches/Game_Vanilla/ChatBubblePatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/ChatBubblePatch.cs @@ -1,5 +1,4 @@ using FinalSuspect.Helpers; -using UnityEngine; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/Game_Vanilla/ChatControlPatch.cs b/FinalSuspect/Patches/Game_Vanilla/ChatControlPatch.cs index 7fada4d..6b162e0 100644 --- a/FinalSuspect/Patches/Game_Vanilla/ChatControlPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/ChatControlPatch.cs @@ -1,7 +1,6 @@ using AmongUs.Data; using FinalSuspect.Modules.Features.CheckingandBlocking; using InnerNet; -using UnityEngine; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs index 7558292..c353cbc 100644 --- a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs @@ -1,20 +1,10 @@ using System; -using System.Collections; using System.Text; -using AmongUs.Data; using AmongUs.GameOptions; -using BepInEx.Unity.IL2CPP.Utils; using FinalSuspect.Attributes; -using FinalSuspect.DataHandling.FinalGameData; using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; -using FinalSuspect.Modules.Features.DisplayedRoleTag; -using FinalSuspect.Patches.System; -using FinalSuspect.Templates; -using InnerNet; -using TMPro; -using UnityEngine; -using Object = UnityEngine.Object; +using FinalSuspect.Modules.Core.Game.UI; namespace FinalSuspect.Patches.Game_Vanilla; @@ -42,7 +32,7 @@ public static void Postfix(TaskPanelBehaviour __instance) if (taskText == "None") return; var RoleWithInfo = $"{RoleHelper.GetRoleName(role)}:\r\n"; - RoleWithInfo += RoleHelper.GetRoleInfoForVanilla(role); + RoleWithInfo += role.GetRoleInfoForVanilla(); var AllText = StringHelper.ColorString(player.GetRoleColor(), RoleWithInfo); @@ -86,64 +76,8 @@ public static void Postfix(TaskPanelBehaviour __instance) public static class HudManagerPatch { - private static GameObject ModLoading; - - private static int currentIndex; - - private static TextMeshPro roleSummary; - public static SimpleButton showHideButton; - private static SpriteRenderer backgroundRenderer; - private static bool Refresh; - private static IEnumerator SwitchRoleIllustration(SpriteRenderer spriter) - { - while (true) - { - if (AwakeAccountManager.AllRoleRoleIllustration.Length == 0) yield break; - - spriter.sprite = AwakeAccountManager.AllRoleRoleIllustration[currentIndex]; - var p = 1f; - while (p > 0f) - { - p -= Time.deltaTime * 2.8f; - var alpha = 1 - p; - spriter.color = Color.white.AlphaMultiplied(alpha); - yield return null; - } - - currentIndex = (currentIndex + 1) % AwakeAccountManager.AllRoleRoleIllustration.Length; - - yield return new WaitForSeconds(1f); - p = 1f; - while (p > 0f) - { - p -= Time.deltaTime * 2.8f; - spriter.color = Color.white.AlphaMultiplied(p); - yield return null; - } - } - } - - [GameModuleInitializer] - public static void Init() - { - try - { - Object.Destroy(showHideButton.Button.gameObject); - Object.Destroy(roleSummary.gameObject); - Object.Destroy(backgroundRenderer.gameObject); //销毁背景 - } - catch - { - /* ignored */ - } - - showHideButton = null; - roleSummary = null; - backgroundRenderer = null; - } - private static void SetChatBG(HudManager __instance) { Color color; @@ -193,168 +127,15 @@ private static void SetAbilityButtonColor(HudManager __instance) __instance.SecondaryAbilityButton.gameObject.SetActive(active2); } - private static void SetShowInfoPanel() - { - if (IsFreePlay || !IsInGame) return; - - var notShowPane = - (DestroyableSingleton.Instance?.Chat?.IsOpenOrOpening ?? false) || - (MapBehaviour.Instance?.gameObject.activeSelf ?? false) || - !ControllerManagerUpdatePatch.ShowSettingsPanel || - !FinalGameData.IntroDestroyed || - (DisplayerRoleTagHelper.selectionUI?.active ?? false); - if (DestroyableSingleton.Instance?.gameObject.activeSelf == true && notShowPane) - { - DestroyableSingleton.Instance.DeactivatePane(); - } - - DestroyableSingleton.Instance?.gameObject.SetActive(!notShowPane); - } - - private static int GetLineCount(string text) - { - if (string.IsNullOrEmpty(text)) - return 0; - var lines = text.Split(["\r\n", "\n"], StringSplitOptions.None); - return lines.Length; - } - - private static void UpdateResult(HudManager __instance) - { - if (IsFreePlay || (!IsInGame && GetLineCount(FinalGameData.LastResultText) < 6)) - return; - var showInitially = ConfigManager.ShowResults.Value; - - showHideButton ??= - new SimpleButton( - __instance.transform, - "ShowHideResultsButton", - IsInGame - ? new Vector3(0.2f * GetResolutionOffset(), 2.685f, -14f) - : new Vector3(-4.5f * GetResolutionOffset(), 2.6f, -14f), // 比 BackgroundLayer(z = -13) 更靠前 - new Color32(209, 190, 255, byte.MaxValue), - new Color32(208, 222, 255, byte.MaxValue), - () => - { - var setToActive = !roleSummary.gameObject.activeSelf; - roleSummary.gameObject.SetActive(setToActive); - ConfigManager.ShowResults.Value = setToActive; - showHideButton.Label.text = GetString(setToActive ? "Summary.HideResults" : "Summary.ShowResults"); - }, - GetString(showInitially ? "Summary.HideResults" : "Summary.ShowResults")) - { - Scale = new Vector2(1.5f, 0.5f), - FontSize = 2f - }; - - showHideButton.Button.gameObject.SetActive(true); - - StringBuilder sb = new($"{GetString("Summary.Text")}{FinalGameData.LastGameResult}"); - if (IsInGame) - { - FinalGameData.LastRoomCode = GameCode.IntToGameName(AmongUsClient.Instance.GameId); - FinalGameData.LastServer = IsOnlineGame - ? PingTrackerUpdatePatch.ServerName - : GetString("Local"); - } - - var gamecode = StringHelper.ColorString( - ColorHelper.FSColor, - DataManager.Settings.Gameplay.StreamerMode - ? new string('*', FinalGameData.LastRoomCode.Length) - : FinalGameData.LastRoomCode); - sb.Append("\n" + FinalGameData.LastServer + " " + gamecode); - if (IsInGame) - { - StringBuilder sb2 = new(); - foreach (var data in FinalPlayerData.AllPlayerData) - sb2.Append("\n\u3000 ").Append(SummaryTexts(data.PlayerId)); - - FinalGameData.LastGameData = sb2.ToString(); - } - - sb.Append(FinalGameData.LastGameData); - FinalGameData.LastResultText = sb.ToString(); - if (!roleSummary) - { - roleSummary = TMPTemplate.Create( - "RoleSummaryText", FinalGameData.LastResultText, - Color.white, - 1.25f, - TextAlignmentOptions.TopLeft, - showInitially, - showHideButton.Button.transform); - roleSummary.transform.localPosition = - new Vector3(IsInGame ? 0f : 1.7f, -0.4f, -1f); - roleSummary.transform.localScale = new Vector3(1.2f, 1.2f, 1f); - roleSummary.fontStyle = FontStyles.Bold; - roleSummary.SetOutlineColor(Color.black); - roleSummary.SetOutlineThickness(0.15f); - - var backgroundObject = new GameObject("RoleSummaryBackground"); - backgroundObject.transform.SetParent(roleSummary.transform); - backgroundRenderer = backgroundObject.AddComponent(); - backgroundRenderer.sprite = LoadSprite("LastResult-BG.png", 200f); - backgroundRenderer.color = new Color(0.5f, 0.5f, 0.5f, 1f); - } - - showHideButton.Button.transform.localPosition = - IsInGame ? new Vector3(0.2f, 2.685f, -14f) : new Vector3(-4.5f, 2.6f, -1f); - if (IsInGame) - { - showHideButton.Button.gameObject.SetActive - (PlayerControl.LocalPlayer.GetRoleType() is RoleTypes.CrewmateGhost or RoleTypes.ImpostorGhost && - !IsInMeeting); - } - else - showHideButton.Button.gameObject.SetActive(true); - - roleSummary.text = FinalGameData.LastResultText; - AdjustBackgroundSize(); - } - - private static void AdjustBackgroundSize() - { - if (!roleSummary || !backgroundRenderer) return; - var textBounds = roleSummary.textBounds; - - var backgroundSprite = backgroundRenderer.sprite; - if (!backgroundSprite) return; - var scaleX = (textBounds.size.x + 0.4f) / backgroundSprite.bounds.size.x; - var scaleY = (textBounds.size.y + 0.5f) / backgroundSprite.bounds.size.y; - - backgroundRenderer.transform.localScale = new Vector3(scaleX, scaleY, 1f); - backgroundRenderer.transform.localPosition = new Vector3(textBounds.center.x, textBounds.center.y, 2f); - } - [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] public static class Update { public static void Prefix(HudManager __instance) { - if (!ModLoading) - { - ModLoading = new GameObject("ModLoading") { layer = 5 }; - ModLoading.transform.SetParent(__instance.GameLoadAnimation.transform.parent); - - var Sprite = ModLoading.AddComponent(); - Sprite.color = Color.white; - Sprite.flipX = false; - ModLoading.SetActive(false); - __instance.StartCoroutine(SwitchRoleIllustration(Sprite)); - - var ap = ModLoading.AddComponent(); - ap.Alignment = AspectPosition.EdgeAlignments.RightBottom; - ap.DistanceFromEdge = new Vector3(0.6f, 0.5f, -1000); - ap.updateAlways = true; - - ModLoading.transform.localScale = new Vector3(0.4f, 0.4f, 1f); - } - - ModLoading.SetActive(!IsInGame && !IsLobby); + LoadingAnima.Create(__instance); - var ap_n = __instance.Notifier.GetComponent(); - ap_n.DistanceFromEdge = new Vector3(ap_n.DistanceFromEdge.x, ap_n.DistanceFromEdge.y, -900); + var notifier_aspectPosition = __instance.Notifier.GetComponent(); + notifier_aspectPosition.DistanceFromEdge -= Vector3.back * 900; //ModLogo.SetActive(!IsInGame && !IsLobby); /*Scrapped @@ -406,13 +187,14 @@ public static void Postfix(HudManager __instance) { try { - UpdateResult(__instance); + LastResult.UpdateResult(__instance); SetChatBG(__instance); SetAbilityButtonColor(__instance); - SetShowInfoPanel(); + InGameInfoPane.SetShowInfoPanel(); } - catch + catch (Exception e) { + Error(e.Message, "Update"); /* ignored */ } } diff --git a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs index 19b11af..c5298f6 100644 --- a/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/IntroPatch.cs @@ -3,7 +3,6 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using TMPro; -using UnityEngine; namespace FinalSuspect.Patches.Game_Vanilla; @@ -40,7 +39,7 @@ public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __ intro.RoleText.fontWeight = FontWeight.Thin; intro.RoleText.SetOutlineColor(RoleHelper.GetRoleColor(roleType).ShadeColor(0.1f).SetAlpha(0.38f)); intro.RoleText.SetOutlineThickness(0.17f); - intro.RoleBlurbText.text = RoleHelper.GetRoleInfoForVanilla(roleType); + intro.RoleBlurbText.text = roleType.GetRoleInfoForVanilla(); }, "Override Role Text"); } diff --git a/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs b/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs index c17b0f5..b37d9a6 100644 --- a/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/LobbyPatch.cs @@ -1,6 +1,5 @@ using FinalSuspect.DataHandling.FinalGameData; using TMPro; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/Game_Vanilla/MapRealTimeLocationPatch.cs b/FinalSuspect/Patches/Game_Vanilla/MapRealTimeLocationPatch.cs index ccc7fcd..71bebc0 100644 --- a/FinalSuspect/Patches/Game_Vanilla/MapRealTimeLocationPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/MapRealTimeLocationPatch.cs @@ -1,7 +1,6 @@ using System.Collections; using BepInEx.Unity.IL2CPP.Utils; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; -using UnityEngine; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs b/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs index 2583ac9..5678461 100644 --- a/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/OutroPatch.cs @@ -5,34 +5,27 @@ using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using FinalSuspect.Templates; using TMPro; -using UnityEngine; +using static FinalSuspect.Modules.Core.Game.UI.LastResult; namespace FinalSuspect.Patches.Game_Vanilla; [HarmonyPatch(typeof(AmongUsClient), nameof(AmongUsClient.OnGameEnd))] internal class AmongUsClientEndGamePatch { - public static Dictionary SummaryText = new(); - public static void Postfix() { FinalPlayerData.AllPlayerData .Where(x => x.RealDeathReason is not VanillaDeathReason.None && !x.IsDead) .Do(x => x.SetDead()); - FinalGameData.LastLocalPlayerRoleColor = PlayerControl.LocalPlayer.GetRoleColor(); + LastLocalPlayerRoleColor = PlayerControl.LocalPlayer.GetRoleColor(); SummaryText = new Dictionary(); - foreach (var data in FinalPlayerData.AllPlayerData) - SummaryText[data.PlayerId] = SummaryTexts(data.PlayerId); + foreach (var data in FinalPlayerData.AllPlayerData) SummaryText[data.PlayerId] = SummaryTexts(data.PlayerId); } } [HarmonyPatch(typeof(EndGameManager), nameof(EndGameManager.SetEverythingUp))] internal class SetEverythingUpPatch { - private static TextMeshPro roleSummary; - private static SimpleButton showHideButton; - private static bool DidHumansWin; - public static void Prefix() { DidHumansWin = GameManager.Instance.DidHumansWin(EndGameResult.CachedGameOverReason); @@ -41,7 +34,7 @@ public static void Prefix() public static void Postfix(EndGameManager __instance) { var showInitially = ConfigManager.ShowResults.Value; - + var crewmateWin = DidHumansWin; var WinnerTextObject = Object.Instantiate(__instance.WinText.gameObject); WinnerTextObject.transform.position = new Vector3(__instance.WinText.transform.position.x, __instance.WinText.transform.position.y - 0.5f, __instance.WinText.transform.position.z); @@ -49,22 +42,25 @@ public static void Postfix(EndGameManager __instance) var winnerText = WinnerTextObject.GetComponent(); winnerText.fontSizeMin = 3f; - var winnerColor = DidHumansWin ? "#8CFFFF" : "#FF1919"; - __instance.BackgroundBar.material.color = __instance.WinText.color = - winnerText.color = DidHumansWin ? Palette.CrewmateBlue : Palette.ImpostorRed; - __instance.WinText.text = DidHumansWin ? GetString("Outro.Crews_Win") : GetString("Outro.Imps_Win"); - winnerText.text = DidHumansWin ? GetString("Outro.Crews_WinBlurb") : GetString("Outro.Imps_WinBlurb"); + __instance.BackgroundBar.material.color = + __instance.WinText.color = + winnerText.color = crewmateWin ? Palette.CrewmateBlue : Palette.ImpostorRed; + var winner = $"Outro.{(crewmateWin ? "Crews" : "Imps")}_Win"; + __instance.WinText.text = GetString(winner); + winnerText.text = GetString($"{winner}Blurb"); __instance.WinText.gameObject.SetActive(!showInitially); WinnerTextObject.SetActive(!showInitially); - showHideButton = + var winnerColor = DidHumansWin ? "#8CFFFF" : "#FF1919"; + DestroyAll(); + LastResultButton = new SimpleButton( __instance.transform, "ShowHideResultsButton", new Vector3(-4.5f * GetResolutionOffset(), 2.6f, -14f), // 比 BackgroundLayer(z = -13) 更靠前 - FinalGameData.LastLocalPlayerRoleColor, - FinalGameData.LastLocalPlayerRoleColor.ShadeColor(0.1f), + LastLocalPlayerRoleColor, + LastLocalPlayerRoleColor.ShadeColor(0.1f), () => { var setToActive = !roleSummary.gameObject.activeSelf; @@ -72,7 +68,8 @@ public static void Postfix(EndGameManager __instance) ConfigManager.ShowResults.Value = setToActive; __instance.WinText.gameObject.SetActive(!setToActive); WinnerTextObject.SetActive(!setToActive); - showHideButton.Label.text = GetString(setToActive ? "Summary.HideResults" : "Summary.ShowResults"); + LastResultButton.Label.text = + GetString(setToActive ? "Summary.HideResults" : "Summary.ShowResults"); }, GetString(showInitially ? "Summary.HideResults" : "Summary.ShowResults")) { @@ -81,44 +78,42 @@ public static void Postfix(EndGameManager __instance) }; - showHideButton.Button.gameObject.SetActive(true); + LastResultButton.Button.gameObject.SetActive(true); var lastGameResult = DidHumansWin ? GetString("Summary.CrewsWin") : GetString("Summary.ImpsWin"); - FinalGameData.LastGameResult = lastGameResult; + LastGameResult = lastGameResult; StringBuilder sb = new($"{GetString("Summary.Text")}{lastGameResult}"); var gameCode = StringHelper.ColorString( ColorHelper.FSColor, DataManager.Settings.Gameplay.StreamerMode - ? new string('*', FinalGameData.LastRoomCode.Length) - : FinalGameData.LastRoomCode); - sb.Append("\n" + FinalGameData.LastServer + " " + gameCode); + ? new string('*', LastRoomCode.Length) + : LastRoomCode); + sb.Append("\n" + LastServer + " " + gameCode); sb.Append("\n" + GetString("Tip.HideSummaryTextToShowWinText")); StringBuilder sb2 = new(); foreach (var data in FinalPlayerData.AllPlayerData.Where(x => x.IsImpostor != DidHumansWin)) sb2.Append($"\n★ ") - .Append(AmongUsClientEndGamePatch.SummaryText[data.PlayerId]); + .Append(SummaryText[data.PlayerId]); foreach (var data in FinalPlayerData.AllPlayerData.Where(x => x.IsImpostor == DidHumansWin)) - sb2.Append("\n\u3000 ").Append(AmongUsClientEndGamePatch.SummaryText[data.PlayerId]); + sb2.Append("\n\u3000 ").Append(SummaryText[data.PlayerId]); - FinalGameData.LastGameData = sb2.ToString(); + LastGameData = sb2.ToString(); sb.Append(sb2); - HudManagerPatch.Init(); + roleSummary = TMPTemplate.Create( "RoleSummaryText", sb.ToString(), Color.white, 1.25f, TextAlignmentOptions.TopLeft, - showInitially, - showHideButton.Button.transform); + showInitially, LastResultButton.Button.transform); roleSummary.transform.localPosition = new Vector3(1.7f, -0.4f, -1f); roleSummary.transform.localScale = new Vector3(1.2f, 1.2f, 1f); roleSummary.fontStyle = FontStyles.Bold; roleSummary.SetOutlineColor(Color.black); roleSummary.SetOutlineThickness(0.15f); - FinalPlayerData.DisposeAll(); } } \ No newline at end of file diff --git a/FinalSuspect/Patches/Game_Vanilla/PlayerContorolPatch.cs b/FinalSuspect/Patches/Game_Vanilla/PlayerContorolPatch.cs index e76cc82..cdff7a2 100644 --- a/FinalSuspect/Patches/Game_Vanilla/PlayerContorolPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/PlayerContorolPatch.cs @@ -1,7 +1,6 @@ using AmongUs.GameOptions; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using TMPro; -using UnityEngine; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs b/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs index 3bd6d15..144c216 100644 --- a/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/PlayerJoinAndLeftPatch.cs @@ -3,6 +3,7 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; +using FinalSuspect.Modules.Core.Game.UI; using FinalSuspect.Modules.Features.CheckingandBlocking; using InnerNet; @@ -13,7 +14,7 @@ public class OnGameJoinedPatch { public static void Postfix(AmongUsClient __instance) { - HudManagerPatch.Init(); + LastResult.DestroyAll(); Info($"{__instance.GameId} 加入房间", "OnGameJoined"); FinalGameData.PlayerVersion.PlayerVersions = new Dictionary(); FinalPlayerData.InitializeAll(); @@ -42,8 +43,8 @@ public static void Prefix(InnerNetClient __instance, DisconnectReasons reason, s ShowDisconnectPopupPatch.StringReason = stringReason; Info($"断开连接(理由:{reason}:{stringReason},Ping:{__instance.Ping})", "Session"); - HudManagerPatch.Init(); FinalPlayerData.DisposeAll(); + LastResult.DestroyAll(); ErrorText.Instance.CheatDetected = false; ErrorText.Instance.SBDetected = false; diff --git a/FinalSuspect/Patches/Game_Vanilla/ServerDropDownPatch.cs b/FinalSuspect/Patches/Game_Vanilla/ServerDropDownPatch.cs index f8d85c3..934d09b 100644 --- a/FinalSuspect/Patches/Game_Vanilla/ServerDropDownPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/ServerDropDownPatch.cs @@ -1,6 +1,5 @@ using System; using Il2CppInterop.Runtime.InteropTypes.Arrays; -using UnityEngine; using UnityEngine.SceneManagement; using Object = Il2CppSystem.Object; diff --git a/FinalSuspect/Patches/Game_Vanilla/ShipStatusPatch.cs b/FinalSuspect/Patches/Game_Vanilla/ShipStatusPatch.cs index a073573..d743b6f 100644 --- a/FinalSuspect/Patches/Game_Vanilla/ShipStatusPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/ShipStatusPatch.cs @@ -1,5 +1,4 @@ using FinalSuspect.Helpers; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/Game_Vanilla/TaskProgressTrackerPatch.cs b/FinalSuspect/Patches/Game_Vanilla/TaskProgressTrackerPatch.cs index bec9b33..3c923c2 100644 --- a/FinalSuspect/Patches/Game_Vanilla/TaskProgressTrackerPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/TaskProgressTrackerPatch.cs @@ -1,7 +1,6 @@ using FinalSuspect.Helpers; using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using TMPro; -using UnityEngine; namespace FinalSuspect.Patches.Game_Vanilla; diff --git a/FinalSuspect/Patches/System/AccountManagerPatch.cs b/FinalSuspect/Patches/System/AccountManagerPatch.cs index 0574886..4b7821e 100644 --- a/FinalSuspect/Patches/System/AccountManagerPatch.cs +++ b/FinalSuspect/Patches/System/AccountManagerPatch.cs @@ -1,7 +1,5 @@ -using System.Collections; -using BepInEx.Unity.IL2CPP.Utils; -using UnityEngine; -using static FinalSuspect.Modules.Core.Plugin.ModMainMenuManager; +using FinalSuspect.Modules.Core.Game.UI; +using static FinalSuspect.Modules.Core.Plugin.UI.MainMenu; namespace FinalSuspect.Patches.System; @@ -28,88 +26,8 @@ public static void Prefix() [HarmonyPatch(typeof(AccountManager), nameof(AccountManager.Awake))] public static class AwakeAccountManager { - public static readonly Sprite[] AllRoleRoleIllustration = - [ - LoadSprite("CI_Crewmate.png", 450f), - LoadSprite("CI_HnSEngineer.png", 450f), - LoadSprite("CI_Engineer.png", 450f), - LoadSprite("CI_GuardianAngel.png", 450f), - LoadSprite("CI_Scientist.png", 450f), - LoadSprite("CI_Tracker.png", 450f), - LoadSprite("CI_Noisemaker.png", 450f), - LoadSprite("CI_Detective.png", 450f), - LoadSprite("CI_CrewmateGhost.png", 450f), - LoadSprite("CI_Impostor.png", 450f), - LoadSprite("CI_HnSImpostor.png", 450f), - LoadSprite("CI_Shapeshifter.png", 450f), - LoadSprite("CI_Phantom.png", 450f), - LoadSprite("CI_Viper.png", 450f), - LoadSprite("CI_ImpostorGhost.png", 450f), - ]; - - private static int _currentIndex; - - private static GameObject _crewpetWalk0001; - private static GameObject _modLoading; - public static void Prefix(AccountManager __instance) { - try - { - var loading = GameObject.Find("Loading"); - loading.SetActive(false); - - var bgf = GameObject.Find("BackgroundFill"); - _crewpetWalk0001 = bgf.transform.FindChild("crewpet_walk0001").gameObject; - var r = _crewpetWalk0001.GetComponent(); - r.speed = 0f; - _modLoading = new GameObject("ModLoading"); - _modLoading.transform.SetParent(_crewpetWalk0001.transform.parent); - _modLoading.transform.localScale = new Vector3(0.4f, 0.4f, 1f); - _modLoading.transform.localPosition = new Vector3(4.5f, -2.4f, -1f); - var sprite = _modLoading.AddComponent(); - sprite.color = Color.white; - sprite.flipX = false; - __instance.StartCoroutine(SwitchRoleIllustration(sprite)); - _crewpetWalk0001.SetActive(false); - - var ap = _modLoading.AddComponent(); - ap.Alignment = AspectPosition.EdgeAlignments.RightBottom; - ap.DistanceFromEdge = new Vector3(0.6f, 0.5f, -1000); - ap.updateAlways = true; - } - catch - { - /* ignored */ - } - } - - private static IEnumerator SwitchRoleIllustration(SpriteRenderer spriter) - { - while (true) - { - if (AllRoleRoleIllustration.Length == 0) yield break; - - spriter.sprite = AllRoleRoleIllustration[_currentIndex]; - var p = 1f; - while (p > 0f) - { - p -= Time.deltaTime * 2.8f; - var alpha = 1 - p; - spriter.color = Color.white.AlphaMultiplied(alpha); - yield return null; - } - - _currentIndex = (_currentIndex + 1) % AllRoleRoleIllustration.Length; - - yield return new WaitForSeconds(1f); - p = 1f; - while (p > 0f) - { - p -= Time.deltaTime * 2.8f; - spriter.color = Color.white.AlphaMultiplied(p); - yield return null; - } - } + LoadingAnima.Create(__instance); } } \ No newline at end of file diff --git a/FinalSuspect/Patches/System/AnnouncementPatch.cs b/FinalSuspect/Patches/System/AnnouncementPatch.cs index 8f9e5a2..dbe6865 100644 --- a/FinalSuspect/Patches/System/AnnouncementPatch.cs +++ b/FinalSuspect/Patches/System/AnnouncementPatch.cs @@ -8,8 +8,7 @@ using Assets.InnerNet; using FinalSuspect.Helpers; using Il2CppInterop.Runtime.InteropTypes.Arrays; -using UnityEngine; -using static FinalSuspect.Modules.Core.Plugin.ModMainMenuManager; +using static FinalSuspect.Modules.Core.Plugin.UI.MainMenu; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/ClientPatch.cs b/FinalSuspect/Patches/System/ClientPatch.cs index 67e8602..b9c274a 100644 --- a/FinalSuspect/Patches/System/ClientPatch.cs +++ b/FinalSuspect/Patches/System/ClientPatch.cs @@ -8,7 +8,6 @@ using FinalSuspect.Patches.Game_Vanilla; using InnerNet; using TMPro; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/ColorPatch.cs b/FinalSuspect/Patches/System/ColorPatch.cs index 91cb2d0..8941888 100644 --- a/FinalSuspect/Patches/System/ColorPatch.cs +++ b/FinalSuspect/Patches/System/ColorPatch.cs @@ -1,5 +1,4 @@ using FinalSuspect.Helpers; -using UnityEngine; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/ControlPatch.cs b/FinalSuspect/Patches/System/ControlPatch.cs index c98b634..7175d7b 100644 --- a/FinalSuspect/Patches/System/ControlPatch.cs +++ b/FinalSuspect/Patches/System/ControlPatch.cs @@ -1,6 +1,6 @@ using System; -using FinalSuspect.Modules.Features; -using UnityEngine; +using FinalSuspect.Modules.Core.Game.UI; +using FinalSuspect.Modules.Core.Plugin.UI; namespace FinalSuspect.Patches.System; @@ -11,29 +11,12 @@ private static readonly (int, int)[] resolutions = [(480, 270), (640, 360), (800, 450), (1280, 720), (1600, 900), (1920, 1080)]; private static int _resolutionIndex; - public static bool ShowSettingsPanel = true; public static void Postfix() { //职业介绍 - if (IsInGame && (IsCanMove || IsInMeeting)) - { - if (Input.GetKeyDown(KeyCode.F1)) - { - if (!InGameRoleInfoMenu.Showing) - InGameRoleInfoMenu.SetRoleInfoRef(PlayerControl.LocalPlayer); - InGameRoleInfoMenu.Toggle(); - } - } - else - { - InGameRoleInfoMenu.Hide(); - } - - if (Input.GetKeyDown(KeyCode.F2) && IsInGame) - { - ShowSettingsPanel = !ShowSettingsPanel; - } + InGameRoleInfoMenu.CheckForHotkey(); + InGameInfoPane.CheckForHotkey(); //更改分辨率 @@ -87,14 +70,14 @@ public static void Postfix() { if (IsNotJoined) { - ModMainMenuManager.ModLogo.SetActive(ModMainMenuManager.Active); - ModMainMenuManager.AuthorLogo.SetActive(ModMainMenuManager.Active); - ModMainMenuManager.Active = !ModMainMenuManager.Active; - ModMainMenuManager.Instance.mainMenuUI.SetActive(ModMainMenuManager.Active); - ModMainMenuManager.CreditTextCredential.gameObject.SetActive(ModMainMenuManager.Active); - ModMainMenuManager.VisitText.gameObject.SetActive(ModMainMenuManager.Active); - DestroyableSingleton.Instance.gameObject.SetActive(ModMainMenuManager.Active); - ModMainMenuManager.ModStamp.SetActive(ModMainMenuManager.Active); + MainMenu.ModLogo.SetActive(MainMenu.Active); + MainMenu.AuthorLogo.SetActive(MainMenu.Active); + MainMenu.Active = !MainMenu.Active; + MainMenu.Instance.mainMenuUI.SetActive(MainMenu.Active); + MainMenu.CreditTextCredential.gameObject.SetActive(MainMenu.Active); + MainMenu.VisitText.gameObject.SetActive(MainMenu.Active); + DestroyableSingleton.Instance.gameObject.SetActive(MainMenu.Active); + MainMenu.ModStamp.SetActive(MainMenu.Active); } } diff --git a/FinalSuspect/Patches/System/CredentialsPatch.cs b/FinalSuspect/Patches/System/CredentialsPatch.cs index df52fb7..18c4b30 100644 --- a/FinalSuspect/Patches/System/CredentialsPatch.cs +++ b/FinalSuspect/Patches/System/CredentialsPatch.cs @@ -4,16 +4,15 @@ using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.ClientItems.FeatureItems.NameTag; using FinalSuspect.Helpers; +using FinalSuspect.Modules.Core.Game.UI; using FinalSuspect.Modules.Resources; -using FinalSuspect.Patches.Game_Vanilla; using FinalSuspect.Templates; using Il2CppSystem; using TMPro; -using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; -using static FinalSuspect.Modules.Core.Plugin.ModMainMenuManager; +using static FinalSuspect.Modules.Core.Plugin.UI.MainMenu; using ColorHelper = FinalSuspect.Helpers.ColorHelper; using Object = UnityEngine.Object; @@ -50,14 +49,14 @@ public static void Postfix(PingTracker __instance) StringBuilder sb = new(); - sb.Append(Main.CredentialsText); + sb.Append(CredentialsText); _creditTextCredential.text = sb.ToString(); if ( (GameSettingMenu.Instance?.gameObject.active ?? false) || IsInMeeting || (FriendsListUI.Instance?.gameObject.active ?? false) - || ((HudManagerPatch.showHideButton?.Button?.gameObject.active ?? false) && + || ((LastResult.LastResultButton?.Button?.gameObject.active ?? false) && ConfigManager.ShowResults.Value)) _creditTextCredential.text = ""; @@ -91,14 +90,14 @@ public static void Postfix(VersionShower __instance) { TMPTemplate.SetBase(__instance.text); - Main.CredentialsText = + CredentialsText = $"\r\n" + $"== " + $"{Main.ModName} " + $"==" + ""; - Main.CredentialsText += "\r\n By Slok"; - Main.CredentialsText += $"\r\nv{Main.DisplayedVersion}"; + CredentialsText += "\r\n By Slok"; + CredentialsText += $"\r\nv{Main.DisplayedVersion}"; #if !DEBUG var additionalCredentials = GetString("TextBelowVersionText"); @@ -108,20 +107,20 @@ public static void Postfix(VersionShower __instance) } #endif #if !RELEASE - Main.CredentialsText += + CredentialsText += $"\r\n{LaunchingInfo.GitBranch} - {LaunchingInfo.GitCommit}"; #endif if (Main.IsAprilFools) { - Main.CredentialsText = + CredentialsText = $"\r\n" + $"== " + $"Feline Susspekt " + $"==" + ""; - Main.CredentialsText += "\r\n By XtremeWives"; - Main.CredentialsText += "\r\n 4.1.Never Gonna Give You Up"; + CredentialsText += "\r\n By XtremeWives"; + CredentialsText += "\r\n 4.1.Never Gonna Give You Up"; } ErrorText.Create(__instance.text); @@ -178,7 +177,7 @@ public static void Postfix(VersionShower __instance) }; AuthorLogo.AddComponent().sprite = LoadSprite("AuthorLogo2.png", 840f); AuthorLogo.GetComponent().color = new Color32(255, 255, 255, 120); - AuthorLogo.transform.SetParent(VisitText.transform.parent); + AuthorLogo.transform.SetParent(null); var ap_authorLogo = AuthorLogo.gameObject.AddComponent(); ap_authorLogo.Alignment = AspectPosition.EdgeAlignments.LeftBottom; ap_authorLogo.DistanceFromEdge = new Vector3(0.6f, 0.5f); diff --git a/FinalSuspect/Patches/System/GameOptionPatch.cs b/FinalSuspect/Patches/System/GameOptionPatch.cs index 18ea067..c569a48 100644 --- a/FinalSuspect/Patches/System/GameOptionPatch.cs +++ b/FinalSuspect/Patches/System/GameOptionPatch.cs @@ -1,7 +1,6 @@ using AmongUs.GameOptions; using FinalSuspect.Helpers; using TMPro; -using UnityEngine; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/GameStartManagerPatch.cs b/FinalSuspect/Patches/System/GameStartManagerPatch.cs index babb1b6..004545f 100644 --- a/FinalSuspect/Patches/System/GameStartManagerPatch.cs +++ b/FinalSuspect/Patches/System/GameStartManagerPatch.cs @@ -5,7 +5,6 @@ using FinalSuspect.Modules.Resources; using InnerNet; using TMPro; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/Patches/System/JoinGameButtonPatch.cs b/FinalSuspect/Patches/System/JoinGameButtonPatch.cs index d71c118..a5b8879 100644 --- a/FinalSuspect/Patches/System/JoinGameButtonPatch.cs +++ b/FinalSuspect/Patches/System/JoinGameButtonPatch.cs @@ -1,5 +1,4 @@ using System.Text.RegularExpressions; -using UnityEngine; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/LoadManagerPatch.cs b/FinalSuspect/Patches/System/LoadManagerPatch.cs index 69cf259..71baead 100644 --- a/FinalSuspect/Patches/System/LoadManagerPatch.cs +++ b/FinalSuspect/Patches/System/LoadManagerPatch.cs @@ -1,5 +1,4 @@ using FinalSuspect.Helpers; -using UnityEngine; using Image = UnityEngine.UI.Image; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/LoadPatch.cs b/FinalSuspect/Patches/System/LoadPatch.cs index e96cd9b..fdd9891 100644 --- a/FinalSuspect/Patches/System/LoadPatch.cs +++ b/FinalSuspect/Patches/System/LoadPatch.cs @@ -8,7 +8,6 @@ using FinalSuspect.Modules.Core.Plugin.RegistryManager; using FinalSuspect.Modules.Resources; using TMPro; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.Patches.System; @@ -72,17 +71,9 @@ public static void Update(SplashManager __instance) private static void CreateTextComponents(SplashManager instance) { - _loadText = CreateTextComponent(instance, new Vector3(0f, -0.28f, -10f)); - _processText = CreateTextComponent(instance, new Vector3(0f, -0.7f, -10f)); - } - - private static TextMeshPro CreateTextComponent(SplashManager instance, Vector3 position) - { - var text = Object.Instantiate(instance.errorPopup.InfoText, null); - text.transform.localPosition = position; - text.fontStyle = FontStyles.Bold; - text.text = string.Empty; - return text; + var temp = instance.errorPopup.InfoText; + _loadText = ObjectHelper.InstantiateTextComponent(temp, new Vector3(0f, -0.28f, -10f)); + _processText = ObjectHelper.InstantiateTextComponent(temp, new Vector3(0f, -0.7f, -10f)); } private static void CreateLogoComponents() diff --git a/FinalSuspect/Patches/System/LobbyListPatch.cs b/FinalSuspect/Patches/System/LobbyListPatch.cs index 952b36e..ba9e1ca 100644 --- a/FinalSuspect/Patches/System/LobbyListPatch.cs +++ b/FinalSuspect/Patches/System/LobbyListPatch.cs @@ -2,7 +2,6 @@ using FinalSuspect.Helpers; using InnerNet; using TMPro; -using UnityEngine; using Object = UnityEngine.Object; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/LobbyPanelPatch.cs b/FinalSuspect/Patches/System/LobbyPanelPatch.cs index 46262da..1e629b6 100644 --- a/FinalSuspect/Patches/System/LobbyPanelPatch.cs +++ b/FinalSuspect/Patches/System/LobbyPanelPatch.cs @@ -1,109 +1,17 @@ using AmongUs.GameOptions; -using FinalSuspect.Attributes; using FinalSuspect.Helpers; -using System; -using FinalSuspect.Modules.Features; +using FinalSuspect.Modules.Core.Game.UI; +using Il2CppSystem; using TMPro; -using UnityEngine; -using UnityEngine.UI; -using Object = UnityEngine.Object; namespace FinalSuspect.Patches.System; [HarmonyPatch(typeof(LobbyInfoPane), nameof(LobbyInfoPane.Update))] internal class LobbyInfoPaneUpdatePatch { - private static GameObject _showHidePaneButton; - private static GameObject _roleInfoPaneButton; - - [GameModuleInitializer] - public static void Init() - { - var aspect = DestroyableSingleton.Instance.transform.FindChild("AspectSize"); - var trans = aspect.FindChild("GameSettingsButtons"); - trans.FindChild("Host Buttons").gameObject.SetActive(false); - trans.FindChild("Client Buttons").gameObject.SetActive(true); - var header = trans.FindChild("ButtonSettingsHeader").gameObject; - header.transform.localPosition = - new Vector3(-0.282f, header.transform.localPosition.y, header.transform.localPosition.z); - var tmp = header.GetComponent(); - tmp.text += $" - {GetString("PressF2ToHidePane")}"; - var rect = header.gameObject.GetComponent(); - rect.sizeDelta = new Vector2(3f, rect.sizeDelta.y); - - DestroyableSingleton.Instance.gameObject.GetComponent().DistanceFromEdge += - Vector3.forward * -60; - DestroyableSingleton.Instance.gameObject.transform.localScale *= 0.8f; - if (!_showHidePaneButton) - { - Object.Destroy(_showHidePaneButton); - _showHidePaneButton = null; - } - - _showHidePaneButton = - Object.Instantiate(aspect.FindChild("GameCodeSection").FindChild("CopyGameCodeButton").gameObject, - aspect.parent.parent); - _showHidePaneButton.name = "Show Hide Panel Button"; - _showHidePaneButton.transform.localPosition = new Vector3(-0.2f, -0.5f, 1f); - _showHidePaneButton.transform.localScale = new Vector3(0.5f, 0.5f, 1f); - _showHidePaneButton.SetActive(true); - Object.Destroy(_showHidePaneButton.GetComponent()); - _showHidePaneButton.SetActive(true); - var _show_aspectPosi = _showHidePaneButton.AddComponent(); - - _show_aspectPosi.updateAlways = true; - var _show_passive = _showHidePaneButton.GetComponent(); - _show_passive.OnClick = new Button.ButtonClickedEvent(); - _show_passive.OnClick.AddListener(new Action(() => - { - ControllerManagerUpdatePatch.ShowSettingsPanel = !ControllerManagerUpdatePatch.ShowSettingsPanel; - })); - _showHidePaneButton.transform.FindChild("Inactive").GetComponent().color = - new Color(0.8f, 0.8f, 1f, 0.3f); - _showHidePaneButton.transform.FindChild("Icon").GetComponent().sprite = - LoadSprite("eye.png", 0.01f); - _ = new LateTask(() => - { - _show_aspectPosi.Alignment = AspectPosition.EdgeAlignments.Right; - _show_aspectPosi.DistanceFromEdge = new Vector3(0.22f, 1.85f, -80f); - _showHidePaneButton.transform.FindChild("Icon").GetComponent().sprite = - LoadSprite("eye.png", 100f); - }, 0.2f, "Reset Icon"); - - - _roleInfoPaneButton = - Object.Instantiate(aspect.FindChild("GameCodeSection").FindChild("CopyGameCodeButton").gameObject, - aspect.parent.parent); - _roleInfoPaneButton.name = "Show Hide Panel Button"; - _roleInfoPaneButton.transform.localPosition = new Vector3(-0.2f, -0.5f, 1f); - _roleInfoPaneButton.transform.localScale = new Vector3(0.5f, 0.5f, 1f); - _roleInfoPaneButton.SetActive(true); - Object.Destroy(_roleInfoPaneButton.GetComponent()); - _roleInfoPaneButton.SetActive(true); - var aspectPosi = _roleInfoPaneButton.AddComponent(); - - aspectPosi.updateAlways = true; - var passive = _roleInfoPaneButton.GetComponent(); - passive.OnClick = new Button.ButtonClickedEvent(); - passive.OnClick.AddListener(new Action(() => - { - if (IsInGame && (IsCanMove || IsInMeeting)) - { - if (!InGameRoleInfoMenu.Showing) - InGameRoleInfoMenu.SetRoleInfoRef(PlayerControl.LocalPlayer); - InGameRoleInfoMenu.Toggle(); - } - })); - _roleInfoPaneButton.transform.FindChild("Inactive").GetComponent().color = - new Color(0.8f, 0.8f, 0.8f, 0.3f); - aspectPosi.Alignment = AspectPosition.EdgeAlignments.Right; - aspectPosi.DistanceFromEdge = new Vector3(0.58f, 1.85f, -80f); - _roleInfoPaneButton.transform.FindChild("Icon").GetComponent().sprite = - LoadSprite("roleHelp.png", 100f); - } - - public static void Postfix() + public static void Postfix(LobbyInfoPane __instance) { + InGameInfoPane.Instance = __instance; var aspectSize = GameObject.Find("AspectSize"); aspectSize.transform.FindChild("Background").gameObject.GetComponent().color = new Color(1, 1, 1, 0.4f); @@ -305,7 +213,7 @@ private static void SetColorForIcon(GameObject obj, Color iconcolor, Color bgcol cat.FindChild("Divider").gameObject.GetComponent().color = bgcolor.ShadeColor(0.32f); cat.FindChild("HeaderText").gameObject.GetComponent().color = Color.white; cat.FindChild("Icon").gameObject.GetComponent().color = iconcolor; - obj.ForEachChild((Il2CppSystem.Action)SetColor); + obj.ForEachChild((Action)SetColor); return; void SetColor(GameObject _obj) diff --git a/FinalSuspect/Patches/System/LobbyScreenPatch.cs b/FinalSuspect/Patches/System/LobbyScreenPatch.cs index 5c0386d..a24f71e 100644 --- a/FinalSuspect/Patches/System/LobbyScreenPatch.cs +++ b/FinalSuspect/Patches/System/LobbyScreenPatch.cs @@ -1,9 +1,8 @@ -using System.Text.RegularExpressions; +/*using System.Text.RegularExpressions; using AmongUs.Data; using FinalSuspect.Helpers; using InnerNet; using TMPro; -using UnityEngine; namespace FinalSuspect.Patches.System; @@ -142,4 +141,5 @@ public static void Postfix(MainMenuManager __instance) } } } -} \ No newline at end of file +}*/ + diff --git a/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs b/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs index a283cf3..cc28cdd 100644 --- a/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs +++ b/FinalSuspect/Patches/System/MainMenuButtonHoverAnimation.cs @@ -1,7 +1,7 @@ using FinalSuspect.ClientItems.FeatureItems.MainMenuStyle; using FinalSuspect.Helpers; +using FinalSuspect.Modules.Core.Plugin.UI; using Il2CppSystem; -using UnityEngine; namespace FinalSuspect.Patches.System; @@ -20,8 +20,8 @@ private static void Start_Postfix(MainMenuManager __instance) private static void SetButtonStatus(GameObject obj, bool active) { - ModMainMenuManager.AllButtons.TryAdd(obj, (obj.transform.position, active)); - ModMainMenuManager.AllButtons[obj] = (ModMainMenuManager.AllButtons[obj].Item1, active); + MainMenu.AllButtons.TryAdd(obj, (obj.transform.position, active)); + MainMenu.AllButtons[obj] = (MainMenu.AllButtons[obj].Item1, active); } [HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.LateUpdate))] @@ -37,7 +37,7 @@ private static void Update_Postfix(MainMenuManager __instance) : style.MainUIColors[1], new Color(0f, 0f, 0f, 0f), Color.white, Color.white); __instance.newsButton.enabled = ModNewsHistory.AnnouncementLoadComplete; - foreach (var (button, value) in ModMainMenuManager.AllButtons.Where(x => x.Key != null && x.Key.active)) + foreach (var (button, value) in MainMenu.AllButtons.Where(x => x.Key != null && x.Key.active)) { var pos = button.transform.position; var targetPos = value.Item1 + new Vector3(value.Item2 ? 0.35f : 0f, 0f, 0f); @@ -50,14 +50,14 @@ private static void Update_Postfix(MainMenuManager __instance) public static void RefreshButtons(GameObject obj) { - ModMainMenuManager.AllButtons = new Dictionary(); + MainMenu.AllButtons = new Dictionary(); obj.ForEachChild((Action)Init); } private static void Init(GameObject obj) { if (obj.name is "BottomButtonBounds" or "Divider") return; - if (ModMainMenuManager.AllButtons.ContainsKey(obj)) return; + if (MainMenu.AllButtons.ContainsKey(obj)) return; SetButtonStatus(obj, false); var pb = obj.GetComponent(); pb.OnMouseOver.AddListener((global::System.Action)(() => SetButtonStatus(obj, true))); diff --git a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs index 2f6a020..d39d206 100644 --- a/FinalSuspect/Patches/System/MainMenuManagerPatch.cs +++ b/FinalSuspect/Patches/System/MainMenuManagerPatch.cs @@ -1,12 +1,11 @@ using System; using FinalSuspect.Helpers; -using FinalSuspect.Modules.Features; +using FinalSuspect.Modules.Core.Plugin.UI; using FinalSuspect.Modules.Resources; using FinalSuspect.Templates; using TMPro; -using UnityEngine; using UnityEngine.UI; -using static FinalSuspect.Modules.Core.Plugin.ModMainMenuManager; +using static FinalSuspect.Modules.Core.Plugin.UI.MainMenu; using Object = UnityEngine.Object; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/MeetingButtonPatch.cs b/FinalSuspect/Patches/System/MeetingButtonPatch.cs index 1a26441..1a1b628 100644 --- a/FinalSuspect/Patches/System/MeetingButtonPatch.cs +++ b/FinalSuspect/Patches/System/MeetingButtonPatch.cs @@ -1,6 +1,5 @@ using System; using FinalSuspect.Helpers; -using UnityEngine; using UnityEngine.UI; using static FinalSuspect.Modules.Features.DisplayedRoleTag.DisplayerRoleTagHelper; using Object = UnityEngine.Object; diff --git a/FinalSuspect/Patches/System/PhasePatch.cs b/FinalSuspect/Patches/System/PhasePatch.cs index 3f94329..95d8956 100644 --- a/FinalSuspect/Patches/System/PhasePatch.cs +++ b/FinalSuspect/Patches/System/PhasePatch.cs @@ -79,15 +79,17 @@ public static void Postfix() } }*/ +[HarmonyPatch] +public static class IntroCutsceneOnDestroyPatch +{ #if Windows -[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.OnDestroy))] + [HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.OnDestroy))] #elif Android -[HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.StartSFX))] -[HarmonyPatch(typeof(FungleShipStatus), nameof(FungleShipStatus.StartSFX))] + [HarmonyPatch(typeof(ShipStatus), nameof(ShipStatus.StartSFX))] + [HarmonyPatch(typeof(FungleShipStatus), nameof(FungleShipStatus.StartSFX))] #endif -public static class IntroCutsceneOnDestroyPatch -{ - public static void Postfix() + [HarmonyPostfix] + public static void OnDestroy() { FinalGameData.IntroDestroyed = true; Info("OnDestroy", "IntroCutscene"); diff --git a/FinalSuspect/Patches/System/RegionMenuPatch.cs b/FinalSuspect/Patches/System/RegionMenuPatch.cs index c8db9e6..182fee3 100644 --- a/FinalSuspect/Patches/System/RegionMenuPatch.cs +++ b/FinalSuspect/Patches/System/RegionMenuPatch.cs @@ -1,5 +1,4 @@ using FinalSuspect.Modules.Core.Game; -using UnityEngine; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs b/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs index da7604c..53d4b33 100644 --- a/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs +++ b/FinalSuspect/Patches/System/SwitchShipCostumeButtonPatch.cs @@ -1,6 +1,5 @@ using FinalSuspect.ClientItems.FeatureItems.MyMusic; using FinalSuspect.Modules.Features.CheckingandBlocking; -using UnityEngine; namespace FinalSuspect.Patches.System; diff --git a/FinalSuspect/Templates/SimpleButton.cs b/FinalSuspect/Templates/SimpleButton.cs index 7003dd7..1f19297 100644 --- a/FinalSuspect/Templates/SimpleButton.cs +++ b/FinalSuspect/Templates/SimpleButton.cs @@ -1,7 +1,6 @@ using System; using FinalSuspect.Helpers; using TMPro; -using UnityEngine; using UnityEngine.UI; using Object = UnityEngine.Object; diff --git a/FinalSuspect/Templates/TMPTemplate.cs b/FinalSuspect/Templates/TMPTemplate.cs index b0d597c..ff11808 100644 --- a/FinalSuspect/Templates/TMPTemplate.cs +++ b/FinalSuspect/Templates/TMPTemplate.cs @@ -1,5 +1,4 @@ using TMPro; -using UnityEngine; namespace FinalSuspect.Templates; diff --git a/FinalSuspect/main.cs b/FinalSuspect/main.cs index fb64300..647e68c 100644 --- a/FinalSuspect/main.cs +++ b/FinalSuspect/main.cs @@ -9,7 +9,6 @@ using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using FinalSuspect.Modules.Resources; using Il2CppInterop.Runtime.Injection; -using UnityEngine; // ReSharper disable MemberCanBePrivate.Global @@ -48,7 +47,6 @@ public class Main : BasePlugin public static bool hasArgumentException; public static string ExceptionMessage; public static bool ExceptionMessageIsShown; - public static string CredentialsText; public static readonly bool IsInitialRelease = DateTime.Now is { Month: 8, Day: >= 15 and <= 19 }; public static readonly bool IsAprilFools = DateTime.Now is { Month: 4, Day: >= 1 and <= 10 }; From 9e38b59d76b04e353bd9e7e162d01d81e7daf481 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Sat, 4 Oct 2025 18:49:49 +0800 Subject: [PATCH 17/19] bug fix --- Assets/ModNews/SChinese/FS.v1.3.txt | 10 +- .../SChinese/FeaturesIntroduction.v1.3.txt | 142 ++++++++++++++++++ FinalSuspect/ClientItems/ClientItemsPatch.cs | 7 + .../FeatureItems/NameTag/NameTagManager.cs | 3 + .../DataHandling/FinalLocalHandling.cs | 11 +- .../Modules/Core/Plugin/ConfigManager.cs | 4 + .../RegistryManager/AndroidPreferenceStore.cs | 1 - .../DisplayerRoleTagHelper.cs | 1 - 8 files changed, 171 insertions(+), 8 deletions(-) create mode 100644 Assets/ModNews/SChinese/FeaturesIntroduction.v1.3.txt diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index a477d5b..bde4cdf 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -33,6 +33,7 @@ Starlight为安卓平台带来了模组体验。 - 修复了部分分辨率下出现UI错误的问题 - 修复了「人满自动开始游戏」错误多次开始游戏导致游戏崩溃的问题 - 修复了预设信息板无法隐藏的问题 +- 修复了变形者变形后仍显示原本备注及会议标签的问题 修复: Slok ## 优化 @@ -46,17 +47,18 @@ Starlight为安卓平台带来了模组体验。 制作: Slok ## 新增 -- 适配**Among Us v17.0.0** - 恢复官网 -- 增加对BanMod的RPC检测 -- 增加对VersionCheck的RPC检测 -制作: LezaiYa | 立绘: 小黄117 +- 增加对**BanMod**的RPC检测 +- 增加对**VersionCheck**的RPC检测 +制作: LezaiYa - 适配**Starlight**安装模组启动器 - 开始游戏闪屏动画 - 按键: 跳过倒计时开始游戏 - 按键: 职业介绍 - 按键: 显示/隐藏预设信息板 制作: Slok +- 适配**Among Us v17.0.0** +制作: LezaiYa | 立绘: 小黄117 ## 重制 diff --git a/Assets/ModNews/SChinese/FeaturesIntroduction.v1.3.txt b/Assets/ModNews/SChinese/FeaturesIntroduction.v1.3.txt new file mode 100644 index 0000000..61abc79 --- /dev/null +++ b/Assets/ModNews/SChinese/FeaturesIntroduction.v1.3.txt @@ -0,0 +1,142 @@ +#Number:1000010 +#Title:v1.3 功能&优化介绍 +#SubTitle:★★★★我们奇奇妙妙的内容★★★★ +#ShortTitle:★v1.3 内容介绍 +#Date:2025-08-15T00:00:00Z +#----------------------------- +# 简体中文 +## 本文件涵盖注意事项与功能介绍!请务必完整阅读! +## 注意! +- 如果您看到作弊者,这说明他们曾进行过非法行为或存在于模组封禁名单中,并不代表他们的行为一定是作弊行为或他们正在作弊 +例如: 当您看见(无效的RPC:151)代表对方可能是**「Better Among Us」**玩家,但FS并不适配此模组的RPC,且FS始终会将发送无效RPC的玩家视为作弊 +当然,您也大可放心,因为我们独特的互认方法,您不会在他们的视野里被判定为作弊者! +- 当模组出现Bug时,请点击「客户端功能-输出日志」输出日志,将其连同Bug一起反馈! +- 除了「简体中文」与「English」之外,所有语言都由AI翻译,可能出现偏差,请及时反馈! +- 开启离线模式后,模组将停止获取屏蔽词、公告、远程资源及更新检查,也不会再下载必要资源。这可能导致您错过关键版本更新,或出现不可预见的错误。请谨慎使用! + +## 优化 - 29 +*全局:* +- 模组鼠标光标 +- 模组右上角图标 +*主页:* +- 启动游戏程序动画 +- 加载动画-职业立绘轮播 +- 主页UI布局 +- 主页背景 +*在线搜索:* +- 房间名称优化 +- 非官方服务器着色 +*游戏中-全局:* +- 延迟显示处的帧数&服务器显示 +- 模组版本信息显示 +- 聊天气泡颜色优化 +- 聊天框背景 +- 断连原因优化 +- 玩家名称查重优化 +- 开始游戏动画优化 +- 进入游戏加载动画-职业立绘轮播 +- 加载进度条颜色优化 +*游戏中-大厅:* +- 大厅信息版背景优化 +- 设置编辑界面着色 +- 设置编辑界面背景优化 +- 设置查看界面着色 +- 等候仓增加团队Logo +*游戏中-进行:* +- 开场动画 +- 根据职业与阵营为小地图背景着色 +- 不同职业分别着色 +- 技能按钮文本着色 +- 冷却文本颜色 +- 会议中退出玩家显示 +*游戏结算:* +- 结算文本优化 + +## 功能 - 57 +*全局:(设置界面-客户端功能使用)* +- 输出日志 +- 清空自动日志 +- 切换原版 +- 资源管理(仅限主页使用) +- 名称标识管理(仅限主页使用) +- 我的音乐(PC支持自定义音乐,类型: ".wav", ".flac", ".aif", ".aiff", ".mp3") +- 切换主页风格 +*加载界面:* +- 自动下载远程模组资源(重要资源下载失败自动退出游戏) +*主页:* +- 自动检查模组版本更新 +*在线搜索:* +- 房主平台显示以及据此为房间名着色 +- 房间号显示 +- 房间剩余时间百分比显示 +- 更多服务器选择 +- 房主名称显示 +*游戏中-全局:* +- Final Anti-Cheat反作弊(FAC 2.0) +- 客户端守护(抵御对程序本体攻击的黑客) +- 违禁词检查&屏蔽 +- 解锁帧数限制(由60FPS升至165FPS) +- 自动踢出符合条件的玩家 +*游戏中-大厅:* +- 展示玩家平台与客户端信息 +- 人满自动开始游戏 +- 与其他本模组玩家互认 +- 显示大厅关闭时间(仅创建房间的房主) +- 重制开始游戏倒计时 +- 跳过倒计时开始游戏 +*游戏中-进行:* +- 场景&会议职业显示 +- 任务进度/击杀数显示 +- 滑动鼠标滚轮使用千里眼(使用条件: 练习模式&本地游戏全局、在线游戏大厅/死亡后非守护天使) +- 死后非守护天使可见他人职业、任务进度/击杀数、位置 +- 死后非守护天使可通过小地图查看尸体及所有人位置 +- 死后可见他人死因&凶手 +- 死后可以使用复盘信息 +- 幽幽鬼影追踪为职业着色 +- 愚人节地图彩蛋 +- 会议标签系统(可以为玩家打上标签以防止忘记身份) +- 任务总进度百分比显示 +- 职业介绍 +- 预设信息版游戏内使用 +*游戏结算:* +- 复盘信息(职业、任务进度/击杀数、死因&凶手) +- 自动返回大厅 +*快捷键-全局:* +- F4: 全屏 +- F10: 打开游戏根目录 +- F11: 更改分辨率 +- Ctrl+F1: 日志输出 +- Ctrl+F2: 切换日志是否在游戏中输出(仅房主) +*快捷键-首页:* +- Tab: 隐藏UI +*快捷键-聊天:* +- Ctrl+C: 复制当前聊天框文本 +- Ctrl+V: 粘贴文本到聊天框 +- Ctrl+X: 剪切当前聊天文本 +- ↑: 追溯上一条自己的聊天历史 +- ↓: 追溯下一条自己的聊天历史 +*快捷键-游戏中:* +- F1: 显示职业介绍及立绘 +- F2: 显示/隐藏预设信息版 +*快捷键-大厅:* +- Shift: 跳过开始游戏倒计时直接开始游戏(仅房主) +- C: 重置开始游戏倒计时(仅房主) + +*可选设置:(设置界面-客户端选项) - 15* +- 切换外观形象[经典豆子模式 - 愚人节牧马模式 - 愚人节长颈豆模式] +- 解锁帧数限制 +- 踢出好友代码异常的玩家 +- 踢出使用违规昵称的玩家 +- 踢出被封禁的玩家 +- 屏蔽违禁词 +- 人满自动开始游戏 +- 结束时自动返回大厅 +- 禁用原版游戏音乐 +- 启用反作弊 +- 启用客户端守护(试验性) +- 展示玩家平台与客户端信息 +- 使用模组鼠标光标(PC) +- 快速启动模式 +- 离线模式(试验性) +*可选设置:(其他)* +- 切换地图风格(仅限The Skeld骷髅舰, 按钮位于安保室) \ No newline at end of file diff --git a/FinalSuspect/ClientItems/ClientItemsPatch.cs b/FinalSuspect/ClientItems/ClientItemsPatch.cs index 7ee5bfa..19be0e1 100644 --- a/FinalSuspect/ClientItems/ClientItemsPatch.cs +++ b/FinalSuspect/ClientItems/ClientItemsPatch.cs @@ -29,7 +29,10 @@ public static class OptionsMenuBehaviourStartPatch private static ClientOptionItem _enableFac; private static ClientOptionItem _enableGuardian; private static ClientOptionItem _showPlayerInfo; +#if Windows private static ClientOptionItem _useModCursor; +#endif + private static ClientOptionItem _fastLaunchMode; private static ClientOptionItem _offlineMode; @@ -125,7 +128,9 @@ public static void Postfix(OptionsMenuBehaviour __instance) CustomPopup.Show(GetString("ClientOption.OfflineMode"), GetString("UpdateResult.Succeed_Text"), [(GetString(StringNames.ExitGame), Application.Quit)]); })); +#if Windows CreateOptionItem(ref _useModCursor, "UseModCursor", ConfigManager.UseModCursor, __instance, SetCursor); +#endif if (DebugModeManager.IsDebugMode) { @@ -278,6 +283,7 @@ private static void AutoStartButtonToggle() public static void SetCursor() { +#if Windows try { var sprite = LoadSprite("Cursor.png"); @@ -287,6 +293,7 @@ public static void SetCursor() { ConfigManager.UseModCursor.Value = false; } +#endif } } diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs index 9c3062d..16c8a30 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs @@ -52,6 +52,9 @@ static Component CloneCom(Component com) public static (string title, string prefix, string suffix, string name, string displayName, string lastTag) ApplyFor(PlayerControl player) { + if (player.shapeshiftTargetPlayerId != -1) + player = GetPlayerById((byte)player.shapeshiftTargetPlayerId); + var a = AllNameTags.TryGetValue(player.FriendCode, out var tag); return a diff --git a/FinalSuspect/DataHandling/FinalLocalHandling.cs b/FinalSuspect/DataHandling/FinalLocalHandling.cs index 327d21b..a792a87 100644 --- a/FinalSuspect/DataHandling/FinalLocalHandling.cs +++ b/FinalSuspect/DataHandling/FinalLocalHandling.cs @@ -92,8 +92,15 @@ private static void GetGameText(this FinalPlayerData data, ref Color color, ref if (!IsInGame) return; if (!ConfigManager.EnableFinalSuspect.Value) return; - var roleType = GetRoleById(data.PlayerId); var player = data.Player; + if (player.shapeshiftTargetPlayerId != -1) + { + var playerId = (byte)player.shapeshiftTargetPlayerId; + data = GetFinalDataById(playerId); + player = data.Player; + } + + var roleType = GetRoleById(data.PlayerId); var roleTag = data.RoleTag; if (CanSeeTargetRole(player, out var bothImp)) @@ -101,7 +108,7 @@ private static void GetGameText(this FinalPlayerData data, ref Color color, ref color = RoleHelper.GetRoleColor(roleType); roleText = !topswap ? $"{GetRoleString(roleType.ToString())} {GetProgressText(player)} {GetVitalText(player.PlayerId, doColor: CanSeeOthersRole())} " - : $"{GetVitalText(player.PlayerId, doColor: CanSeeOthersRole())} {GetProgressText(player)} {GetRoleString(roleType.ToString())}"; + : $"{GetVitalText(data.PlayerId, doColor: CanSeeOthersRole())} {GetProgressText(player)} {GetRoleString(roleType.ToString())}"; } else if (roleTag.TagColor != Color.white || roleTag.TagStr != "" || roleTag.Room != "") { diff --git a/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs b/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs index e30095b..23ddf9d 100644 --- a/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs +++ b/FinalSuspect/Modules/Core/Plugin/ConfigManager.cs @@ -20,7 +20,9 @@ public static class ConfigManager public static ConfigEntry ShowPlayerInfo { get; private set; } public static ConfigEntry FastLaunchMode { get; private set; } public static ConfigEntry OfflineMode { get; private set; } +#if Windows public static ConfigEntry UseModCursor { get; private set; } +#endif public static ConfigEntry VersionCheat { get; private set; } public static ConfigEntry GodMode { get; private set; } public static ConfigEntry NoGameEnd { get; private set; } @@ -59,7 +61,9 @@ public static void OnInitialization() ShowPlayerInfo = config.Bind("Client Options", "Show Player Info", true); FastLaunchMode = config.Bind("Client Options", "Fast Launch Mode", false); OfflineMode = config.Bind("Client Options", "Offline Mode", false); +#if Windows UseModCursor = config.Bind("Client Options", "Use Mod Cursor", true); +#endif VersionCheat = config.Bind("Debug Options", "Version Cheat", false); GodMode = config.Bind("Debug Options", "God Mode", false); diff --git a/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs b/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs index d85181e..6bd571f 100644 --- a/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs +++ b/FinalSuspect/Modules/Core/Plugin/RegistryManager/AndroidPreferenceStore.cs @@ -1,6 +1,5 @@ #if Android using System; -using UnityEngine; namespace FinalSuspect.Modules.Core.Plugin.RegistryManager; diff --git a/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs b/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs index af5d405..06083fb 100644 --- a/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs +++ b/FinalSuspect/Modules/Features/DisplayedRoleTag/DisplayerRoleTagHelper.cs @@ -215,7 +215,6 @@ public static void ShowSelectionPanel(MeetingHud __instance, PlayerControl pc) void CreateOption(CategoryType category, string value) { - // 初始化列表(.NET 6+ 语法) CategoryButtons.TryAdd(category, []); if (CategoryButtons[category].Any(x => x.parent.name == value)) return; From 7add993a80a524c02c1de92c91deb00c2bbef27c Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Sat, 4 Oct 2025 20:45:23 +0800 Subject: [PATCH 18/19] zoom --- Assets/ModNews/SChinese/FS.v1.3.txt | 1 + .../FeatureItems/NameTag/NameTagManager.cs | 2 +- .../DataHandling/FinalLocalHandling.cs | 3 +- FinalSuspect/Helpers/RoleHelper.cs | 2 +- .../Modules/Core/Game/UI/InGameInfoPane.cs | 71 +++++++++++++++---- .../Core/Game/UI/InGameRoleInfoMenu.cs | 2 +- .../Modules/Core/Game/UI/LastResult.cs | 15 ++-- FinalSuspect/Modules/Core/Game/Utils.cs | 1 + FinalSuspect/Modules/Features/Zoom.cs | 33 +++++++++ FinalSuspect/Patches/Game_Vanilla/HudPatch.cs | 12 +++- FinalSuspect/main.cs | 2 +- 11 files changed, 117 insertions(+), 27 deletions(-) diff --git a/Assets/ModNews/SChinese/FS.v1.3.txt b/Assets/ModNews/SChinese/FS.v1.3.txt index bde4cdf..e6727a0 100644 --- a/Assets/ModNews/SChinese/FS.v1.3.txt +++ b/Assets/ModNews/SChinese/FS.v1.3.txt @@ -34,6 +34,7 @@ Starlight为安卓平台带来了模组体验。 - 修复了「人满自动开始游戏」错误多次开始游戏导致游戏崩溃的问题 - 修复了预设信息板无法隐藏的问题 - 修复了变形者变形后仍显示原本备注及会议标签的问题 +- 修复了复盘信息错位的问题 修复: Slok ## 优化 diff --git a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs index 16c8a30..f586116 100644 --- a/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs +++ b/FinalSuspect/ClientItems/FeatureItems/NameTag/NameTagManager.cs @@ -57,7 +57,7 @@ public static (string title, string prefix, string suffix, string name, string d var a = AllNameTags.TryGetValue(player.FriendCode, out var tag); - return a + return a && !IsActive(SystemTypes.MushroomMixupSabotage) ? tag.Apply(player.GetDataName()) : ("", "", "", "", "", ""); } diff --git a/FinalSuspect/DataHandling/FinalLocalHandling.cs b/FinalSuspect/DataHandling/FinalLocalHandling.cs index a792a87..c2d99ee 100644 --- a/FinalSuspect/DataHandling/FinalLocalHandling.cs +++ b/FinalSuspect/DataHandling/FinalLocalHandling.cs @@ -110,7 +110,8 @@ private static void GetGameText(this FinalPlayerData data, ref Color color, ref ? $"{GetRoleString(roleType.ToString())} {GetProgressText(player)} {GetVitalText(player.PlayerId, doColor: CanSeeOthersRole())} " : $"{GetVitalText(data.PlayerId, doColor: CanSeeOthersRole())} {GetProgressText(player)} {GetRoleString(roleType.ToString())}"; } - else if (roleTag.TagColor != Color.white || roleTag.TagStr != "" || roleTag.Room != "") + else if ((roleTag.TagColor != Color.white || roleTag.TagStr != "" || roleTag.Room != "") && + !IsActive(SystemTypes.MushroomMixupSabotage)) { color = data.RoleTag.TagColor; roleText = !topswap diff --git a/FinalSuspect/Helpers/RoleHelper.cs b/FinalSuspect/Helpers/RoleHelper.cs index 5f51c65..cc6f25d 100644 --- a/FinalSuspect/Helpers/RoleHelper.cs +++ b/FinalSuspect/Helpers/RoleHelper.cs @@ -82,7 +82,7 @@ private static string GetNormalGameRoleInfo(RoleTypes role, bool roleHelp) } return role is RoleTypes.Crewmate or RoleTypes.Impostor - ? GetString($"RolesHelp_{text}Role") + ? GetString($"{text}BlurbLong") : $"{GetString($"RolesHelp_{text}_01")}\n{GetString($"RolesHelp_{text}_02")}"; } diff --git a/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs b/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs index 3aa1e06..93e0255 100644 --- a/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs +++ b/FinalSuspect/Modules/Core/Game/UI/InGameInfoPane.cs @@ -84,21 +84,68 @@ public static void CheckForHotkey() public static void SetShowInfoPanel() { - var showInfo = ConfigManager.ShowInfoPanel.Value; - var map = MapBehaviour.Instance != null && (MapBehaviour.Instance?.gameObject.activeSelf ?? false); - var notShowPane = - (DestroyableSingleton.Instance?.Chat?.IsOpenOrOpening ?? false) - || map - || !showInfo - || !FinalGameData.IntroDestroyed - || (DisplayerRoleTagHelper.selectionUI?.active ?? false); if (IsFreePlay || !IsInGame) return; - if ((Instance?.gameObject.activeSelf ?? true) && notShowPane) + var showInfo = ConfigManager.ShowInfoPanel.Value; + + // 使用独立的方法处理每个可能失败的条件 + var map = SafeCheckMapStatus(); + var chatOpen = SafeCheckChatStatus(); + var selectionUIActive = SafeCheckSelectionUIStatus(); + + var notShowPane = chatOpen || map || !showInfo || !FinalGameData.IntroDestroyed || selectionUIActive; + SafeSetPanelState(notShowPane); + } + + private static bool SafeCheckMapStatus() + { + try + { + return MapBehaviour.Instance != null && (MapBehaviour.Instance?.gameObject.activeSelf ?? false); + } + catch { - Test(0); - Instance?.DeactivatePane(); + return false; } + } - Instance?.gameObject.SetActive(!notShowPane); + private static bool SafeCheckChatStatus() + { + try + { + return DestroyableSingleton.Instance?.Chat?.IsOpenOrOpening ?? false; + } + catch + { + return false; + } + } + + private static bool SafeCheckSelectionUIStatus() + { + try + { + return DisplayerRoleTagHelper.selectionUI?.active ?? false; + } + catch + { + return false; + } + } + + private static void SafeSetPanelState(bool notShowPane) + { + try + { + if ((Instance?.gameObject.activeSelf ?? true) && notShowPane) + { + Instance?.DeactivatePane(); + } + + Instance?.gameObject.SetActive(!notShowPane); + } + catch + { + /* ignored */ + } } } \ No newline at end of file diff --git a/FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs b/FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs index d019b70..28f190f 100644 --- a/FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs +++ b/FinalSuspect/Modules/Core/Game/UI/InGameRoleInfoMenu.cs @@ -138,7 +138,7 @@ private static void CreateRoleInfoButton(Transform aspect) new Vector3(-0.2f, -0.5f, 1f), "roleHelp.png", new Color(0.8f, 0.8f, 0.8f, 0.3f), - new Vector3(0.58f, 1.85f, -800f), + new Vector3(0.58f, 1.85f, -980f), () => { if (!IsInGame || (!IsCanMove && !IsInMeeting)) return; diff --git a/FinalSuspect/Modules/Core/Game/UI/LastResult.cs b/FinalSuspect/Modules/Core/Game/UI/LastResult.cs index 455e7ba..4a046de 100644 --- a/FinalSuspect/Modules/Core/Game/UI/LastResult.cs +++ b/FinalSuspect/Modules/Core/Game/UI/LastResult.cs @@ -1,10 +1,8 @@ using System; using System.Text; using AmongUs.Data; -using AmongUs.GameOptions; using FinalSuspect.Attributes; using FinalSuspect.Helpers; -using FinalSuspect.Modules.Core.Game.PlayerControlExtension; using FinalSuspect.Patches.System; using FinalSuspect.Templates; using InnerNet; @@ -65,9 +63,7 @@ public static void UpdateResult(HudManager __instance) new SimpleButton( __instance.transform, "Show Hide Last Result Button", - IsInGame - ? new Vector3(0.2f * GetResolutionOffset(), 2.685f, -14f) - : new Vector3(-4.5f * GetResolutionOffset(), 2.6f, -14f), // 比 BackgroundLayer(z = -13) 更靠前 + Vector3.zero, new Color32(209, 190, 255, byte.MaxValue), new Color32(208, 222, 255, byte.MaxValue), () => @@ -84,8 +80,11 @@ public static void UpdateResult(HudManager __instance) FontSize = 2f }; - LastResultButton.Button.gameObject.SetActive(true); - + if (!LastResultButton.Button.gameObject.TryGetComponent(out var aspectPosition)) + aspectPosition = LastResultButton.Button.gameObject.AddComponent(); + aspectPosition.updateAlways = true; + aspectPosition.Alignment = AspectPosition.EdgeAlignments.LeftTop; + aspectPosition.DistanceFromEdge = new Vector3(IsInGame ? 5.6f : 0.8f, 0.3f, 1f); StringBuilder sb = new($"{GetString("Summary.Text")}{LastGameResult}"); if (IsInGame) { @@ -140,7 +139,7 @@ public static void UpdateResult(HudManager __instance) if (IsInGame) { LastResultButton.Button.gameObject.SetActive - (PlayerControl.LocalPlayer.GetRoleType() is RoleTypes.CrewmateGhost or RoleTypes.ImpostorGhost && + (CanSeeOthersRole() && !IsInMeeting); } else diff --git a/FinalSuspect/Modules/Core/Game/Utils.cs b/FinalSuspect/Modules/Core/Game/Utils.cs index 3aba21e..d71ff2d 100644 --- a/FinalSuspect/Modules/Core/Game/Utils.cs +++ b/FinalSuspect/Modules/Core/Game/Utils.cs @@ -406,6 +406,7 @@ public static string GetVitalText(byte playerId, bool summary = false, bool doCo public static bool IsActive(SystemTypes type) { + if (!IsInGame) return false; if (!IsNormalGame) return false; if (!ShipStatus.Instance.Systems.ContainsKey(type)) return false; diff --git a/FinalSuspect/Modules/Features/Zoom.cs b/FinalSuspect/Modules/Features/Zoom.cs index 6cb837f..6f9fc19 100644 --- a/FinalSuspect/Modules/Features/Zoom.cs +++ b/FinalSuspect/Modules/Features/Zoom.cs @@ -25,6 +25,8 @@ public static void Postfix() } if (Camera.main?.orthographicSize > 3.0f) ResetButtons = true; + +#if Windows switch (Input.mouseScrollDelta.y) { case > 0: @@ -42,6 +44,37 @@ public static void Postfix() break; } } +#elif Android + if (Input.touchCount == 2) + { + var touchZero = Input.GetTouch(0); + var touchOne = Input.GetTouch(1); + + var touchZeroPrevPos = touchZero.position - touchZero.deltaPosition; + var touchOnePrevPos = touchOne.position - touchOne.deltaPosition; + + var prevMagnitude = (touchZeroPrevPos - touchOnePrevPos).magnitude; + var currentMagnitude = (touchZero.position - touchOne.position).magnitude; + + var difference = currentMagnitude - prevMagnitude; + + if (Math.Abs(difference) > 0.1f) + { + if (difference > 0) + { + if (Camera.main?.orthographicSize > 3.0f) + SetZoomSize(); + } + else + { + if (IsDead || IsFreePlay || + DebugModeManager.IsDebugMode || IsLobby || ConfigManager.GodMode.Value) + if (Camera.main?.orthographicSize < 18.0f) + SetZoomSize(true); + } + } + } +#endif Flag.NewFlag("Zoom"); } diff --git a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs index c353cbc..553c45a 100644 --- a/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs +++ b/FinalSuspect/Patches/Game_Vanilla/HudPatch.cs @@ -127,6 +127,16 @@ private static void SetAbilityButtonColor(HudManager __instance) __instance.SecondaryAbilityButton.gameObject.SetActive(active2); } + [HarmonyPatch(typeof(HudManager), nameof(HudManager.Start))] + public static class HudManagerStartPatch + { + public static void Postfix(HudManager __instance) + { + var notifier_aspectPosition = __instance.Notifier.GetComponent(); + notifier_aspectPosition.DistanceFromEdge += Vector3.back * 900; + } + } + [HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] public static class Update { @@ -134,8 +144,6 @@ public static void Prefix(HudManager __instance) { LoadingAnima.Create(__instance); - var notifier_aspectPosition = __instance.Notifier.GetComponent(); - notifier_aspectPosition.DistanceFromEdge -= Vector3.back * 900; //ModLogo.SetActive(!IsInGame && !IsLobby); /*Scrapped diff --git a/FinalSuspect/main.cs b/FinalSuspect/main.cs index 647e68c..070e717 100644 --- a/FinalSuspect/main.cs +++ b/FinalSuspect/main.cs @@ -94,7 +94,7 @@ public override void Load() /// private const VersionTypes DisplayedVersion_Type = VersionTypes.Canary; - private const int DisplayedVersion_TestCreation = 1; + private const int DisplayedVersion_TestCreation = 3; #endif } From 50d1a8c4c9abfff574fa0f7ce728208458b516e8 Mon Sep 17 00:00:00 2001 From: Slok7565 Date: Sat, 4 Oct 2025 23:11:18 +0800 Subject: [PATCH 19/19] Support Finish --- Assets/Languages/SChinese.yaml | 2 +- FinalSuspect/Patches/System/CreditsControllerPatch.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Assets/Languages/SChinese.yaml b/Assets/Languages/SChinese.yaml index 0b52d24..59f1f56 100644 --- a/Assets/Languages/SChinese.yaml +++ b/Assets/Languages/SChinese.yaml @@ -1,4 +1,4 @@ -# FinalSuspect 的语言文件 / Translation file of FinalSuspect + # FinalSuspect 的语言文件 / Translation file of FinalSuspect # 作者署名(不需要请留空)/ A sign of an author (Please leave blank when not needed) # 注: 为了防止您的翻译在版本更新中重制,请修改本地目录Among Us/BepInEx/cn.slok.finalsuspect.cfg的值"Language Update Bypass"修改为"LongTerm" diff --git a/FinalSuspect/Patches/System/CreditsControllerPatch.cs b/FinalSuspect/Patches/System/CreditsControllerPatch.cs index 53f08ec..ac13d82 100644 --- a/FinalSuspect/Patches/System/CreditsControllerPatch.cs +++ b/FinalSuspect/Patches/System/CreditsControllerPatch.cs @@ -10,7 +10,7 @@ public class CreditsControllerPatch var devList = new List { $"{Main.ModName}", - $"By By Slok", + $"By Slok", "Thanks: LezaiYa", //Others $"{GetString("Id.Contributor")}", @@ -78,7 +78,8 @@ void AddPersonToCredits(List list) public static void AddCreditPrefix(CreditsController __instance, [HarmonyArgument(0)] CreditsController.CreditStruct originalCredit) { - if (originalCredit.columns[0] != "logoImage") return; + //这里安卓还有点小问题 + if (originalCredit?.columns[0] != "logoImage") return; foreach (var credit in GetModCredits()) {