From f1e0c5cf80d50da9df72c48984df0b65b2297510 Mon Sep 17 00:00:00 2001 From: Przebor Date: Tue, 30 Mar 2021 09:09:38 +0200 Subject: [PATCH] Latest version Updated code to latest version of Among Us. Release soon --- .../CustomServersClient.csproj | 12 ++++---- CustomServersClient/CustomServersPatches.cs | 29 ++++++++----------- README.md | 3 ++ 3 files changed, 21 insertions(+), 23 deletions(-) diff --git a/CustomServersClient/CustomServersClient.csproj b/CustomServersClient/CustomServersClient.csproj index 86f1f58..e23dd1d 100644 --- a/CustomServersClient/CustomServersClient.csproj +++ b/CustomServersClient/CustomServersClient.csproj @@ -3,24 +3,24 @@ netstandard2.1 1.4.0 - 2020.12.9s - NuclearPowered/Mappings:0.1.2 + 2021.3.5s + NuclearPowered/Mappings:0.2.0 andruzzzhka - 2020.12.9s + 2021.3.5s $(DefineConstants);STEAM - 2020.11.17i + 2021.3.5i $(DefineConstants);ITCH - + @@ -29,6 +29,6 @@ - + diff --git a/CustomServersClient/CustomServersPatches.cs b/CustomServersClient/CustomServersPatches.cs index 6223bcb..764acb9 100644 --- a/CustomServersClient/CustomServersPatches.cs +++ b/CustomServersClient/CustomServersPatches.cs @@ -4,8 +4,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using System; using UnhollowerBaseLib; using CustomServersClient.UI; +using Il2CppSystem.Diagnostics.Tracing; +using Il2CppSystem.Globalization; namespace CustomServersClient { @@ -13,9 +16,8 @@ public static class CustomServersPatches { public static List customServers = new List(); - static RegionInfo[] _defaultRegions = new RegionInfo[3]; - - static bool _firstRun = true; + private static IRegionInfo[] _defaultRegions = ServerManager.DefaultRegions; + static ServersManagementForm _managementForm; [HarmonyPatch(typeof(RegionMenu), nameof(RegionMenu.OnEnable))] @@ -27,16 +29,6 @@ public static bool Prefix(ref RegionMenu __instance) { ClearOnClickAction(__instance.ButtonPool); - if (_firstRun) - { - for (int i = 0; i < 3; i++) - { - _defaultRegions[i] = ServerManager.DefaultRegions[i]; - } - - _firstRun = false; - } - Directory.CreateDirectory(CustomServersPlugin.userDataPath); if (File.Exists(Path.Combine(CustomServersPlugin.userDataPath, CustomServersPlugin.customServersFilePath))) @@ -51,9 +43,10 @@ public static bool Prefix(ref RegionMenu __instance) if (ServerManager.DefaultRegions.Count != 4 + customServers.Count || forceReloadServers) { - var regions = new RegionInfo[4 + customServers.Count]; + var regions = new IRegionInfo[4 + customServers.Count]; - regions[0] = new RegionInfo("Manage servers...", "MANAGE_SERVERS", null); + regions[0] = new DnsRegionInfo("Manage servers...", "Manage servers...", StringNames.NoTranslation, + "Manage servers...").Cast(); for (int i = 0; i < 3; i++) { @@ -64,10 +57,12 @@ public static bool Prefix(ref RegionMenu __instance) { Il2CppReferenceArray servers = new ServerInfo[1] { new ServerInfo(customServers[i].name, customServers[i].ip, (ushort)customServers[i].port) }; - regions[i + 4] = new RegionInfo(customServers[i].name, "0", servers); + regions[i + 4] = new DnsRegionInfo(customServers[i].ip, customServers[i].name, StringNames.NoTranslation, servers).Cast(); } ServerManager.DefaultRegions = regions; + ServerManager.Instance.AvailableRegions = regions; + ServerManager.Instance.SaveServers(); } return true; @@ -97,7 +92,7 @@ public static class RegionMenuChooseOptionPatch { public static bool Prefix(ref RegionMenu.c__DisplayClass2_0 __instance) { - if (__instance.region.PingServer == "MANAGE_SERVERS") + if (__instance.region.PingServer == "Manage servers...") { if (_managementForm == null || _managementForm.IsDisposed) _managementForm = new ServersManagementForm(); diff --git a/README.md b/README.md index eaad131..6ad8b4e 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,9 @@ Works on Itch as of **v2020.11.17i**. 4. Compiled dll should be automatically copied to your `BepInEx/plugins` folder (Reactor feature) ## Screenshot ![screenshot_0](https://cdn.discordapp.com/attachments/759066383090188308/763331715740729364/unknown.png) +## Hall of Fame +- latest version is available thanks to [updated Unify](https://github.com/MoltenMods/Unify) + ## TO-DO - Make the mod work with latest Among Us (v2021.3.5)