Merge remote-tracking branch 'origin/main'

This commit is contained in:
Gurge44 committed 2025-03-27 20:00:36 +01:00
commit f9ab70cd8a
4 files changed
+201 -46

No files matched your search

+6 -1
View File
@@ -137,6 +137,11 @@ public static class HudSpritePatch
newAbilityButton = CustomButton.Get("Commander");
break;
}
case CustomRoles.Cleaner:
{
newReportButton = CustomButton.Get("Clean");
break;
}
case CustomRoles.Amnesiac:
{
if (Amnesiac.RememberMode.GetValue() == 1) newKillButton = CustomButton.Get("AmnesiacKill");
@@ -510,4 +515,4 @@ public static class HudSpritePatch
}
}
}
}
}
+194 -44
View File
@@ -1,6 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using InnerNet;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -46,69 +50,215 @@ public static class RegionMenuPatch
[HarmonyPatch]
public static class ServerDropDownPatch
{
// From BetterAmongUs, code by D1GQ
[HarmonyPatch(typeof(ServerDropdown), nameof(ServerDropdown.FillServerOptions))]
[HarmonyPrefix]
internal static bool FillServerOptions_Prefix(ServerDropdown __instance)
{
if (SceneManager.GetActiveScene().name == "FindAGame") return true;
__instance.background.size = new Vector2(5, 1);
int num = 0;
int column = 0;
const int maxPerColumn = 6;
const float columnWidth = 3.15f;
const float buttonSpacing = 0.5f;
// Get all available regions except current one
var regions = DestroyableSingleton<ServerManager>.Instance.AvailableRegions.OrderBy(ServerManager.DefaultRegions.Contains).ToList();
// Calculate total columns needed
int totalColumns = Mathf.Max(1, Mathf.CeilToInt(regions.Count / (float)maxPerColumn));
int rowsInLastColumn = regions.Count % maxPerColumn;
int maxRows = (regions.Count > maxPerColumn) ? maxPerColumn : regions.Count;
foreach (IRegionInfo regionInfo in regions)
{
if (DestroyableSingleton<ServerManager>.Instance.CurrentRegion.Name == regionInfo.Name)
{
__instance.defaultButtonSelected = __instance.firstOption;
__instance.firstOption.ChangeButtonText(DestroyableSingleton<TranslationController>.Instance.GetStringWithDefault(regionInfo.TranslateName, regionInfo.Name, new Il2CppReferenceArray<Il2CppSystem.Object>(0)));
continue;
}
IRegionInfo region = regionInfo;
ServerListButton serverListButton = __instance.ButtonPool.Get<ServerListButton>();
// Calculate position based on column and row
float xPos = (column - (totalColumns - 1) / 2f) * columnWidth;
float yPos = __instance.y_posButton - buttonSpacing * (num % maxPerColumn);
serverListButton.transform.localPosition = new Vector3(xPos, yPos, -1f);
serverListButton.transform.localScale = Vector3.one;
serverListButton.Text.text = DestroyableSingleton<TranslationController>.Instance.GetStringWithDefault(
regionInfo.TranslateName,
regionInfo.Name,
new Il2CppReferenceArray<Il2CppSystem.Object>(0));
serverListButton.Text.ForceMeshUpdate(false, false);
serverListButton.Button.OnClick.RemoveAllListeners();
serverListButton.Button.OnClick.AddListener((Action)(() => __instance.ChooseOption(region)));
__instance.controllerSelectable.Add(serverListButton.Button);
// Move to next column if current column is full
num++;
if (num % maxPerColumn == 0)
{
column++;
}
}
// Calculate background dimensions
float backgroundHeight = 1.2f + buttonSpacing * (maxRows - 1);
float backgroundWidth = (totalColumns > 1) ?
(columnWidth * (totalColumns - 1) + __instance.background.size.x) :
__instance.background.size.x;
__instance.background.transform.localPosition = new Vector3(
0f,
__instance.initialYPos - (backgroundHeight - 1.2f) / 2f,
0f);
__instance.background.size = new Vector2(backgroundWidth, backgroundHeight);
return false;
}
[HarmonyPatch(typeof(ServerDropdown), nameof(ServerDropdown.FillServerOptions))]
[HarmonyPostfix]
public static void AdjustButtonPositions(ServerDropdown __instance)
// Used for find a game manager
internal static void FillServerOptions_Postfix(ServerDropdown __instance)
{
List<ServerListButton> allButtons = __instance.GetComponentsInChildren<ServerListButton>().ToList();
if (SceneManager.GetActiveScene().name != "FindAGame") return;
float buttonSpacing = 0.5f;
float columnSpacing = 3.15f;
List<ServerListButton> allButtons = __instance.GetComponentsInChildren<ServerListButton>().OrderByDescending(b => b.transform.localPosition.y).ToList();
if (allButtons.Count == 0)
return;
float buttonSpacing = 0.6f;
float columnSpacing = 4.25f;
const int buttonsPerColumn = 7;
int columnCount = (allButtons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
if (SceneManager.GetActiveScene().name == "FindAGame")
Vector3 startPosition = new Vector3(0, -buttonSpacing, 0);
for (int i = 0; i < allButtons.Count; i++)
{
const int buttonsPerColumn = 7;
int columnCount = (allButtons.Count + buttonsPerColumn - 1) / buttonsPerColumn;
Vector3 startPosition = new Vector3(0, -buttonSpacing, 0);
for (int i = 0; i < allButtons.Count; i++)
{
int col = i / buttonsPerColumn;
int row = i % buttonsPerColumn;
allButtons[i].transform.localPosition = startPosition + new Vector3(col * columnSpacing, -row * buttonSpacing, 0f);
}
int col = i / buttonsPerColumn;
int row = i % buttonsPerColumn;
allButtons[i].transform.localPosition = startPosition + new Vector3(col * columnSpacing, -row * buttonSpacing, 0f);
}
else
{
// Total 2 colums
const int buttonsInFirstColumn = 5;
int buttonsInSecondColumn = allButtons.Count - buttonsInFirstColumn;
int maxRows = Math.Min(buttonsPerColumn, allButtons.Count);
float backgroundHeight = 1.2f + buttonSpacing * (maxRows - 1);
float backgroundWidth = (columnCount > 1) ?
(columnSpacing * (columnCount - 1) + 5) : 5;
// If we have less than 5 buttons to show, skip following codes
if (buttonsInFirstColumn <= 0 || buttonsInSecondColumn <= 0)
{
for (int i = 0; i < allButtons.Count; i++)
{
allButtons[i].transform.localPosition = new Vector3(0, -i * buttonSpacing, 0);
}
return;
}
// Adjust background
__instance.background.transform.localPosition = new Vector3(
0f,
__instance.initialYPos - (backgroundHeight - 1.2f) / 2f,
0f);
__instance.background.size = new Vector2(backgroundWidth, backgroundHeight);
__instance.background.transform.localPosition += new Vector3(2f, 0, 0);
}
}
Vector3 startPosition = new Vector3(0, -buttonSpacing, 0);
[HarmonyPatch(typeof(FindAGameManager))]
public static class FindAGameManagerPatch
{
// 10+ Listing ported from BetterAmongUs, coded by D1GQ
// HostName and gamecode coded by Pietro
public static Scroller Scroller;
for (int i = 0; i < buttonsInFirstColumn; i++)
[HarmonyPatch(nameof(FindAGameManager.HandleList))]
[HarmonyPostfix]
public static void HandleList_Postfix(FindAGameManager __instance)
{
foreach (var container in __instance.gameContainers)
{
var child = container.transform.Find("Container");
var tmproObject = child.Find("TrueHostName_TMP");
TMP_Text tmpro;
if (tmproObject == null)
{
allButtons[i].transform.localPosition = startPosition + new Vector3(0, -i * buttonSpacing, 0);
tmproObject = new GameObject("TrueHostName_TMP").transform;
tmproObject.transform.SetParent(child.transform, true);
tmproObject.transform.localPosition = new(8.5f, -2.21f, -1f);
tmpro = tmproObject.gameObject.AddComponent<TextMeshPro>();
}
float secondColumnStartY = 0;
if (buttonsInSecondColumn > 1)
else
{
// Last button in second column should be at the same height as the last button in the first column
secondColumnStartY = -(buttonsInFirstColumn - buttonsInSecondColumn) * buttonSpacing;
tmpro = tmproObject.GetComponent<TextMeshPro>();
}
tmpro.fontSize = 2.5f;
tmpro.text = @$"<font=""LiberationSans SDF"" material=""LiberationSans SDF RadialMenu Material"">{container.gameListing.TrueHostName}<br>{GameCode.IntToGameNameV2(container.gameListing.GameId)}";
}
}
for (int i = 0; i < buttonsInSecondColumn; i++)
{
int buttonIndex = buttonsInFirstColumn + i;
allButtons[buttonIndex].transform.localPosition = startPosition + new Vector3(columnSpacing, secondColumnStartY - i * buttonSpacing, 0);
}
[HarmonyPatch(nameof(FindAGameManager.Start))]
[HarmonyPrefix]
internal static void Start_Prefix(FindAGameManager __instance)
{
GameContainer gameContainer = __instance.gameContainers[4];
GameObject gameObject = new GameObject("GameListScroller");
gameObject.transform.SetParent(gameContainer.transform.parent);
Scroller = gameObject.AddComponent<Scroller>();
Scroller.Inner = gameObject.transform;
Scroller.MouseMustBeOverToScroll = true;
BoxCollider2D boxCollider2D = gameContainer.transform.parent.gameObject.AddComponent<BoxCollider2D>();
boxCollider2D.size = new Vector2(100f, 100f);
Scroller.ClickMask = boxCollider2D;
Scroller.ScrollWheelSpeed = 0.3f;
Scroller.SetYBoundsMin(0f);
Scroller.SetYBoundsMax(3.5f);
Scroller.allowY = true;
foreach (GameContainer gameContainer2 in __instance.gameContainers)
{
gameContainer2.transform.SetParent(gameObject.transform);
Vector3 position = gameContainer2.transform.position;
gameContainer2.transform.position = new Vector3(position.x, position.y, 25f);
}
List<GameContainer> list = __instance.gameContainers.ToList<GameContainer>();
for (int i = 0; i < 5; i++)
{
GameContainer gameContainer3 = UnityEngine.Object.Instantiate<GameContainer>(gameContainer, gameObject.transform);
Vector3 position2 = gameContainer3.transform.position;
gameContainer3.transform.position = new Vector3(position2.x, position2.y - 0.75f * (float)(i + 1), 25f);
list.Add(gameContainer3);
}
__instance.gameContainers = list.ToArray();
SpriteRenderer spriteRenderer = CreateBlackSquareSprite();
spriteRenderer.transform.SetParent(gameObject.transform.parent);
spriteRenderer.transform.localPosition = new Vector3(0f, 3f, 1f);
spriteRenderer.transform.localScale = new Vector3(1500f, 200f, 100f);
}
[HarmonyPatch(nameof(FindAGameManager.RefreshList))]
[HarmonyPostfix]
internal static void RefreshList_Postfix()
{
Scroller scroller = Scroller;
if (scroller != null)
{
scroller.ScrollRelative(new Vector2(0f, -100f));
}
}
private static SpriteRenderer CreateBlackSquareSprite()
{
GameObject gameObject = new GameObject("CutOffTop");
SpriteRenderer spriteRenderer = gameObject.AddComponent<SpriteRenderer>();
Texture2D texture2D = new Texture2D(100, 100);
Color[] array = texture2D.GetPixels();
for (int i = 0; i < array.Length; i++)
{
array[i] = Color.black;
}
texture2D.SetPixels(array);
texture2D.Apply();
Sprite sprite = Sprite.Create(texture2D, new Rect(0f, 0f, 1f, 1f), Vector2.one * 0.5f);
spriteRenderer.sprite = sprite;
gameObject.transform.localScale = new Vector3(100f, 100f, 1f);
return spriteRenderer;
}
}
+1 -1
View File
@@ -67,7 +67,7 @@ You can also report bugs and suggest features in the #bug-reports and #suggestio
### Visit this website to find role descriptions: [Role description finder](https://gurge44.pythonanywhere.com/)
#### Over 400 roles and add-ons, 10 custom game modes, and a custom team assigner application, making EHR the most extensive mod for Among Us. And it's all free, and only the host needs to have the mod installed for the entire lobby to play!
#### Over 400 roles and add-ons, 12 custom game modes, and a custom team assigner application, making EHR the most extensive mod for Among Us. And it's all free, and only the host needs to have the mod installed for the entire lobby to play!
## List of Roles <span style="font-size: 12px;">(excluding Hide and Seek roles and vanilla roles)</span>
Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB