From 7b4a916d84f18140b68f3ead939317decb6622ad Mon Sep 17 00:00:00 2001 From: Daemon Date: Sat, 1 May 2021 22:05:34 +0100 Subject: [PATCH] Added region menu editor Added Przebot region Added ability to hide certain regions --- README.md | 8 +- Unify/Controls/Button.cs | 104 ++++++++++++++ Unify/Controls/Popup.cs | 77 ++++++++++ Unify/Patches/Regions.cs | 268 +++++++++++++++++++++++++++++++---- Unify/Unify.cs | 44 ++++-- Unify/Unify.csproj | 8 +- build/Unify-2021.4.12s.dll | Bin 11264 -> 17408 bytes build/Unify-2021.4.14s.dll | Bin 0 -> 22016 bytes images/RegionsMenu.png | Bin 148750 -> 274688 bytes images/RegionsMenuEditor.png | Bin 0 -> 303538 bytes 10 files changed, 461 insertions(+), 48 deletions(-) create mode 100644 Unify/Controls/Button.cs create mode 100644 Unify/Controls/Popup.cs create mode 100644 build/Unify-2021.4.14s.dll create mode 100644 images/RegionsMenuEditor.png diff --git a/README.md b/README.md index e7aace3..667de2f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,9 @@ # Unify -An Among Us mod to add extra regions to the regions menu. +An Among Us mod to add extra regions to the region menu. -![Regions menu](images/RegionsMenu.png) +![Region menu](images/RegionsMenu.png) +![Region menu editor](images/RegionsMenuEditor.png) # Table of Contents - [Features](#features) @@ -15,6 +16,7 @@ The following regions have been added: - [skeld.net](https://skeld.net/) - localhost *(for playing on a server running on your computer)* - matux.fr +- Przebot (may be unreliable or outdated) Regions can be connected to directly using an IP address. @@ -22,7 +24,7 @@ Custom regions can be added as detailed below in the [configuration](#configuration) section. Other mods can add regions via the -`AddRegion(string name, string ip, ushort port)` method. +`AddRegion(string name, string ip, ushort port)` API method. ## Installation diff --git a/Unify/Controls/Button.cs b/Unify/Controls/Button.cs new file mode 100644 index 0000000..042b2a5 --- /dev/null +++ b/Unify/Controls/Button.cs @@ -0,0 +1,104 @@ +using System; +using System.Threading.Tasks; +using Reactor.Extensions; +using TMPro; +using UnityEngine; +using UnityEngine.SceneManagement; +using Object = UnityEngine.Object; + +namespace Unify.Controls +{ + public class Button + { + private static readonly TaskCompletionSource Initialized = new TaskCompletionSource(); + private static GameObject _instance; + + private readonly SpriteRenderer _spriteRenderer; + private readonly BoxCollider2D _boxCollider2D; + + public GameObject GameObject { get; } + public TextMeshPro Text { get; } + public Vector2 Size + { + get => _spriteRenderer.size; + set + { + Text.rectTransform.sizeDelta = value; + _spriteRenderer.size = value; + _boxCollider2D.size = value; + } + } + public AspectPosition Position { get; } + public UnityEngine.UI.Button.ButtonClickedEvent OnClick { get; } + + private Button(string text, Vector2 size, Vector2 position) + { + GameObject = Object.Instantiate(_instance).DontDestroy(); + + Text = GameObject.GetComponentInChildren(); + Position = GameObject.GetComponent(); + OnClick = GameObject.GetComponent().OnClick; + _spriteRenderer = GameObject.GetComponent(); + _boxCollider2D = GameObject.GetComponent(); + + Text.text = text; + Text.rectTransform.sizeDelta = size; + Position.DistanceFromEdge = new Vector3(position.x, position.y, -100f); + _spriteRenderer.size = size; + _boxCollider2D.size = size; + } + + public static async Task