mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
Modify and apply COOL animations in Main Menu (#96)
* Modify and apply COOL animations in Main Menu Credits for code: TONX and MoreGamemodes * Remove EHR logo and bring back Among Us text @HyperAtill request on DIscord * bro, credits are fixed 💀 💀 * add Website, Discord, and Github Button (from TOHE) * bro 💀 * forgot to add in en-us * this should fix it
This commit is contained in:
1 parent
b29e976eb2
commit
b51aa966bb
9 files changed
+378
-223
No files matched your search
@@ -0,0 +1,22 @@
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace EHR;
|
||||
|
||||
public static class ObjectHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// オブジェクトの<see cref="TextTranslatorTMP"/>コンポーネントを破棄します
|
||||
/// </summary>
|
||||
public static void DestroyTranslator(this GameObject obj)
|
||||
{
|
||||
if (obj == null) return;
|
||||
obj.ForEachChild((Il2CppSystem.Action<GameObject>)DestroyTranslator);
|
||||
TextTranslatorTMP[] translator = obj.GetComponentsInChildren<TextTranslatorTMP>(true);
|
||||
translator?.Do(Object.Destroy);
|
||||
}
|
||||
/// <summary>
|
||||
/// オブジェクトの<see cref="TextTranslatorTMP"/>コンポーネントを破棄します
|
||||
/// </summary>
|
||||
public static void DestroyTranslator(this MonoBehaviour obj) => obj?.gameObject?.DestroyTranslator();
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace EHR;
|
||||
|
||||
public class SimpleButton
|
||||
{
|
||||
/// <summary>新しいボタンを作成する</summary>
|
||||
/// <param name="parent">親オブジェクト</param>
|
||||
/// <param name="name">オブジェクト名</param>
|
||||
/// <param name="normalColor">通常時の背景色</param>
|
||||
/// <param name="hoverColor">マウスホバー時の背景色</param>
|
||||
/// <param name="action">クリック時に発火するアクション</param>
|
||||
/// <param name="label">ボタンのラベル</param>
|
||||
/// <param name="scale">ボタンの大きさ</param>
|
||||
/// <param name="isActive">初期状態でアクティブにするかどうか(デフォルトtrue)</param>
|
||||
public SimpleButton(
|
||||
Transform parent,
|
||||
string name,
|
||||
Vector3 localPosition,
|
||||
Color32 normalColor,
|
||||
Color32 hoverColor,
|
||||
Action action,
|
||||
string label,
|
||||
bool isActive = true)
|
||||
{
|
||||
if (baseButton == null)
|
||||
{
|
||||
throw new InvalidOperationException("baseButtonが未設定");
|
||||
}
|
||||
|
||||
Button = Object.Instantiate(baseButton, parent);
|
||||
Label = Button.transform.Find("FontPlacer/Text_TMP").GetComponent<TextMeshPro>();
|
||||
NormalSprite = Button.inactiveSprites.GetComponent<SpriteRenderer>();
|
||||
HoverSprite = Button.activeSprites.GetComponent<SpriteRenderer>();
|
||||
buttonCollider = Button.GetComponent<BoxCollider2D>();
|
||||
|
||||
// ラベルをセンタリング
|
||||
var container = Label.transform.parent;
|
||||
Object.Destroy(Label.GetComponent<AspectPosition>());
|
||||
container.SetLocalX(0f);
|
||||
Label.transform.SetLocalX(0f);
|
||||
Label.horizontalAlignment = HorizontalAlignmentOptions.Center;
|
||||
|
||||
Button.name = name;
|
||||
Button.transform.localPosition = localPosition;
|
||||
NormalSprite.color = normalColor;
|
||||
HoverSprite.color = hoverColor;
|
||||
Button.OnClick.AddListener(action);
|
||||
Label.text = label;
|
||||
Button.gameObject.SetActive(isActive);
|
||||
}
|
||||
public PassiveButton Button { get; }
|
||||
public TextMeshPro Label { get; }
|
||||
public SpriteRenderer NormalSprite { get; }
|
||||
public SpriteRenderer HoverSprite { get; }
|
||||
private readonly BoxCollider2D buttonCollider;
|
||||
private Vector2 _scale;
|
||||
public Vector2 Scale
|
||||
{
|
||||
get => _scale;
|
||||
set => _scale = NormalSprite.size = HoverSprite.size = buttonCollider.size = value;
|
||||
}
|
||||
private float _fontSize;
|
||||
public float FontSize
|
||||
{
|
||||
get => _fontSize;
|
||||
set => _fontSize = Label.fontSize = Label.fontSizeMin = Label.fontSizeMax = value;
|
||||
}
|
||||
|
||||
private static PassiveButton baseButton;
|
||||
public static void SetBase(PassiveButton passiveButton)
|
||||
{
|
||||
if (baseButton != null || passiveButton == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// 複製
|
||||
baseButton = Object.Instantiate(passiveButton);
|
||||
var label = baseButton.transform.Find("FontPlacer/Text_TMP").GetComponent<TextMeshPro>();
|
||||
baseButton.gameObject.SetActive(false);
|
||||
// シーン切替時に破棄されないようにする
|
||||
Object.DontDestroyOnLoad(baseButton);
|
||||
baseButton.name = "EHR_SimpleButtonBase";
|
||||
// 不要なコンポーネントを無効化
|
||||
Object.Destroy(baseButton.GetComponent<AspectPosition>());
|
||||
label.DestroyTranslator();
|
||||
label.fontSize = label.fontSizeMax = label.fontSizeMin = 3.5f;
|
||||
label.enableWordWrapping = false;
|
||||
label.text = "EHR SIMPLE BUTTON BASE";
|
||||
// 当たり判定がズレてるのを直す
|
||||
var buttonCollider = baseButton.GetComponent<BoxCollider2D>();
|
||||
buttonCollider.offset = new(0f, 0f);
|
||||
baseButton.OnClick = new();
|
||||
}
|
||||
public static bool IsNullOrDestroyed(SimpleButton button) => button == null || button.Button == null;
|
||||
}
|
||||
+89
-140
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using EHR.Modules;
|
||||
@@ -80,52 +81,28 @@ internal class VersionShowerStartPatch
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))]
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPriority(Priority.First)]
|
||||
internal class TitleLogoPatch
|
||||
{
|
||||
public static GameObject ModStamp;
|
||||
public static GameObject Ambience;
|
||||
public static GameObject LoadingHint;
|
||||
public static GameObject LeftPanel;
|
||||
public static GameObject RightPanel;
|
||||
public static GameObject CloseRightButton;
|
||||
public static GameObject Tint;
|
||||
public static GameObject BottomButtonBounds;
|
||||
|
||||
//private static readonly Color themeColor1 = new(0.99f, 0.55f, 0.56f);
|
||||
//private static readonly Color themeColor2 = new(1f, 0.31f, 0.09f);
|
||||
//private static readonly Color themeColor3 = new(0.08f, 0.03f, 0.12f);
|
||||
//private static readonly Color themeColor4 = new(0.11f, 0.13f, 0.59f);
|
||||
//private static readonly Color themeColor5 = new(0.63f, 0.53f, 0.89f);
|
||||
//private static readonly Color themeColor6 = new(0.69f, 0.2f, 0.65f);
|
||||
//private static readonly Color themeColor7 = new(0.97f, 0.41f, 0.61f);
|
||||
//private static readonly Color themeColor8 = new(0.27f, 0.21f, 0.7f);
|
||||
//private static readonly Color themeColor9 = new(0.42f, 0.3f, 0.8f);
|
||||
//private static readonly Color themeColor10 = new(0.18f, 0.2f, 0.59f);
|
||||
//private static readonly Color themeColor11 = new(0.96f, 0.88f, 0.86f);
|
||||
|
||||
// Winter BG
|
||||
// private static readonly Color ThemeColor1 = new(0.98f, 0.7f, 0.44f);
|
||||
// private static readonly Color ThemeColor2 = new(0.98f, 0.61f, 0.42f);
|
||||
// private static readonly Color ThemeColor3 = new(0.04f, 0.41f, 0.75f);
|
||||
// private static readonly Color ThemeColor4 = new(0.12f, 0.17f, 0.47f);
|
||||
// private static readonly Color ThemeColor5 = new(0.38f, 0.44f, 0.66f);
|
||||
// private static readonly Color ThemeColor6 = new(0.72f, 0.68f, 0.79f);
|
||||
// private static readonly Color ThemeColor7 = ThemeColor1.ShadeColor(0.1f);
|
||||
// private static readonly Color ThemeColor8 = new(0.19f, 0.24f, 0.37f);
|
||||
// private static readonly Color ThemeColor9 = ThemeColor5.ShadeColor(0.1f);
|
||||
// private static readonly Color ThemeColor10 = ThemeColor4.ShadeColor(0.1f);
|
||||
// private static readonly Color ThemeColor11 = ThemeColor6.ShadeColor(0.1f);
|
||||
|
||||
// Summer BG
|
||||
private static readonly Color ThemeColor1 = new(0.706f, 0.588f, 0.455f);
|
||||
private static readonly Color ThemeColor2 = new(0.827f, 0.827f, 0.643f);
|
||||
private static readonly Color ThemeColor3 = new(0.196f, 0.196f, 0.067f);
|
||||
private static readonly Color ThemeColor4 = new(0.145f, 0.655f, 0.859f);
|
||||
private static readonly Color ThemeColor5 = new(0.580f, 0.780f, 0.820f);
|
||||
private static readonly Color ThemeColor6 = new(0.435f, 0.776f, 0.925f);
|
||||
private static readonly Color ThemeColor7 = new(0.161f, 0.439f, 0.588f);
|
||||
private static readonly Color ThemeColor8 = new(0.388f, 0.565f, 0.537f);
|
||||
private static readonly Color ThemeColor9 = new(0.463f, 0.471f, 0.188f);
|
||||
private static readonly Color ThemeColor10 = Color.black;
|
||||
private static readonly Color ThemeColor11 = ThemeColor4.ShadeColor(0.1f);
|
||||
public static Vector3 RightPanelOp;
|
||||
|
||||
private static void Postfix(MainMenuManager __instance)
|
||||
{
|
||||
|
||||
GameObject.Find("BackgroundTexture")?.SetActive(!MainMenuManagerPatch.ShowedBak);
|
||||
|
||||
if (!(ModStamp = GameObject.Find("ModStamp"))) return;
|
||||
ModStamp.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f);
|
||||
|
||||
if (!Options.IsLoaded)
|
||||
{
|
||||
LoadingHint = new("LoadingHint")
|
||||
@@ -148,114 +125,86 @@ internal class TitleLogoPatch
|
||||
try
|
||||
{
|
||||
if (Options.IsLoaded) __instance.playButton.transform.gameObject.SetActive(true);
|
||||
|
||||
SpriteRenderer activeSpriteRender = __instance.playButton.activeSprites.GetComponent<SpriteRenderer>();
|
||||
activeSpriteRender.color = ThemeColor1;
|
||||
|
||||
SpriteRenderer inactiveSpriteRender = __instance.playButton.inactiveSprites.GetComponent<SpriteRenderer>();
|
||||
inactiveSpriteRender.color = ThemeColor2;
|
||||
inactiveSpriteRender.sprite = activeSpriteRender.sprite;
|
||||
|
||||
__instance.playLocalButton.activeSprites.GetComponent<SpriteRenderer>().color = Color.yellow;
|
||||
__instance.PlayOnlineButton.activeSprites.GetComponent<SpriteRenderer>().color = Color.yellow;
|
||||
|
||||
__instance.howToPlayButton.activeSprites.GetComponent<SpriteRenderer>().color = Color.magenta;
|
||||
__instance.howToPlayButton.inactiveSprites.GetComponent<SpriteRenderer>().color = Color.blue;
|
||||
__instance.howToPlayButton.activeTextColor = Color.white;
|
||||
__instance.howToPlayButton.inactiveTextColor = Color.white;
|
||||
__instance.accountCTAButton.activeSprites.GetComponent<SpriteRenderer>().color = Color.yellow;
|
||||
|
||||
__instance.playButton.activeTextColor = ThemeColor3;
|
||||
__instance.playButton.inactiveTextColor = ThemeColor3;
|
||||
|
||||
__instance.inventoryButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor4;
|
||||
__instance.inventoryButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor5;
|
||||
__instance.inventoryButton.activeTextColor = Color.white;
|
||||
__instance.inventoryButton.inactiveTextColor = Color.white;
|
||||
|
||||
__instance.shopButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor4;
|
||||
__instance.shopButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor5;
|
||||
__instance.shopButton.activeTextColor = Color.white;
|
||||
__instance.shopButton.inactiveTextColor = Color.white;
|
||||
|
||||
__instance.newsButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor6;
|
||||
__instance.newsButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor7;
|
||||
__instance.newsButton.activeTextColor = Color.white;
|
||||
__instance.newsButton.inactiveTextColor = Color.white;
|
||||
|
||||
__instance.myAccountButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor6;
|
||||
__instance.myAccountButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor7;
|
||||
__instance.myAccountButton.activeTextColor = Color.white;
|
||||
__instance.myAccountButton.inactiveTextColor = Color.white;
|
||||
|
||||
__instance.settingsButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor6;
|
||||
__instance.settingsButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor7;
|
||||
__instance.settingsButton.activeTextColor = Color.white;
|
||||
__instance.settingsButton.inactiveTextColor = Color.white;
|
||||
|
||||
__instance.quitButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor8;
|
||||
__instance.quitButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor9;
|
||||
__instance.quitButton.activeTextColor = Color.white;
|
||||
__instance.quitButton.inactiveTextColor = Color.white;
|
||||
|
||||
__instance.creditsButton.inactiveSprites.GetComponent<SpriteRenderer>().color = ThemeColor10;
|
||||
__instance.creditsButton.activeSprites.GetComponent<SpriteRenderer>().color = ThemeColor11;
|
||||
__instance.creditsButton.activeTextColor = Color.white;
|
||||
__instance.creditsButton.inactiveTextColor = Color.white;
|
||||
|
||||
GameObject.Find("WindowShine")?.transform.gameObject.SetActive(false);
|
||||
GameObject.Find("ScreenCover")?.transform.gameObject.SetActive(false);
|
||||
GameObject.Find("BackgroundTexture")?.transform.gameObject.SetActive(false);
|
||||
|
||||
Ambience.SetActive(false);
|
||||
var customBg = new GameObject("CustomBG")
|
||||
{
|
||||
transform =
|
||||
{
|
||||
position = new(0f, 0f, 520f)
|
||||
}
|
||||
};
|
||||
var bgRenderer = customBg.AddComponent<SpriteRenderer>();
|
||||
bgRenderer.sprite = Utils.LoadSprite("EHR.Resources.Images.SummerBG.jpg", 180f);
|
||||
|
||||
if (__instance.screenTint != null)
|
||||
{
|
||||
__instance.screenTint.gameObject.transform.localPosition += new Vector3(1000f, 0f);
|
||||
__instance.screenTint.enabled = false;
|
||||
}
|
||||
|
||||
__instance.rightPanelMask?.SetActive(true);
|
||||
|
||||
GameObject leftPanel = GameObject.Find("LeftPanel")?.transform.gameObject;
|
||||
GameObject rightPanel = GameObject.Find("RightPanel")?.transform.gameObject;
|
||||
if (rightPanel != null)
|
||||
{
|
||||
rightPanel.gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
}
|
||||
|
||||
GameObject maskedBlackScreen = GameObject.Find("MaskedBlackScreen")?.transform.gameObject;
|
||||
if (maskedBlackScreen != null)
|
||||
{
|
||||
maskedBlackScreen.GetComponent<SpriteRenderer>().enabled = false;
|
||||
maskedBlackScreen.transform.localPosition = new(-2.5f, 0.6f);
|
||||
maskedBlackScreen.transform.localScale = new(7.35f, 4.5f, 4f);
|
||||
}
|
||||
|
||||
GameObject.Find("Shine")?.transform.gameObject.SetActive(false);
|
||||
|
||||
leftPanel?.GetComponentsInChildren<SpriteRenderer>(true).Where(r => r.name == "Shine").Do(r => r.color = new(0f, 0f, 1f, 0.1f));
|
||||
|
||||
if (leftPanel != null) leftPanel.gameObject.GetComponent<SpriteRenderer>().enabled = false;
|
||||
GameObject.Find("LeftPanel")?.transform.Find("Divider")?.gameObject.SetActive(false);
|
||||
|
||||
PlayerParticles particles = Object.FindObjectOfType<PlayerParticles>();
|
||||
particles?.gameObject.SetActive(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Warn(ex.ToString(), "MainMenuLoader");
|
||||
}
|
||||
}
|
||||
|
||||
if (!(LeftPanel = GameObject.Find("LeftPanel"))) return;
|
||||
LeftPanel.transform.localScale = new Vector3(0.7f, 0.7f, 0.7f);
|
||||
static void ResetParent(GameObject obj) => obj.transform.SetParent(LeftPanel.transform.parent);
|
||||
LeftPanel.ForEachChild((Il2CppSystem.Action<GameObject>)ResetParent);
|
||||
LeftPanel.SetActive(false);
|
||||
|
||||
Color shade = new(0f, 0f, 0f, 0f);
|
||||
var standardActiveSprite = __instance.newsButton.activeSprites.GetComponent<SpriteRenderer>().sprite;
|
||||
var minorActiveSprite = __instance.quitButton.activeSprites.GetComponent<SpriteRenderer>().sprite;
|
||||
|
||||
Dictionary<List<PassiveButton>, (Sprite, Color, Color, Color, Color)> mainButtons = new()
|
||||
{
|
||||
{new List<PassiveButton>() {__instance.playButton, __instance.inventoryButton, __instance.shopButton},
|
||||
(standardActiveSprite, new(1f, 0.524f, 0.549f, 0.8f), shade, Color.white, Color.white) },
|
||||
{new List<PassiveButton>() {__instance.newsButton, __instance.myAccountButton, __instance.settingsButton},
|
||||
(minorActiveSprite, new(1f, 0.825f, 0.686f, 0.8f), shade, Color.white, Color.white) },
|
||||
{new List<PassiveButton>() {__instance.creditsButton, __instance.quitButton},
|
||||
(minorActiveSprite, new(0.526f, 1f, 0.792f, 0.8f), shade, Color.white, Color.white) },
|
||||
};
|
||||
|
||||
void FormatButtonColor(PassiveButton button, Sprite borderType, Color inActiveColor, Color activeColor, Color inActiveTextColor, Color activeTextColor)
|
||||
{
|
||||
button.activeSprites.transform.FindChild("Shine")?.gameObject?.SetActive(false);
|
||||
button.inactiveSprites.transform.FindChild("Shine")?.gameObject?.SetActive(false);
|
||||
var activeRenderer = button.activeSprites.GetComponent<SpriteRenderer>();
|
||||
var inActiveRenderer = button.inactiveSprites.GetComponent<SpriteRenderer>();
|
||||
activeRenderer.sprite = minorActiveSprite;
|
||||
inActiveRenderer.sprite = minorActiveSprite;
|
||||
activeRenderer.color = activeColor.a == 0f ? new Color(inActiveColor.r, inActiveColor.g, inActiveColor.b, 1f) : activeColor;
|
||||
inActiveRenderer.color = inActiveColor;
|
||||
button.activeTextColor = activeTextColor;
|
||||
button.inactiveTextColor = inActiveTextColor;
|
||||
}
|
||||
|
||||
foreach (var kvp in mainButtons)
|
||||
kvp.Key.Do(button => FormatButtonColor(button, kvp.Value.Item1, kvp.Value.Item2, kvp.Value.Item3, kvp.Value.Item4, kvp.Value.Item5));
|
||||
|
||||
GameObject.Find("Divider")?.SetActive(false);
|
||||
|
||||
if (!(RightPanel = GameObject.Find("RightPanel"))) return;
|
||||
var rpap = RightPanel.GetComponent<AspectPosition>();
|
||||
if (rpap) Object.Destroy(rpap);
|
||||
RightPanelOp = RightPanel.transform.localPosition;
|
||||
RightPanel.transform.localPosition = RightPanelOp + new Vector3(10f, 0f, 0f);
|
||||
RightPanel.GetComponent<SpriteRenderer>().color = new(1f, 0.78f, 0.9f, 1f);
|
||||
|
||||
CloseRightButton = new GameObject("CloseRightPanelButton");
|
||||
CloseRightButton.transform.SetParent(RightPanel.transform);
|
||||
CloseRightButton.transform.localPosition = new Vector3(-4.78f, 1.3f, 1f);
|
||||
CloseRightButton.transform.localScale = new(1f, 1f, 1f);
|
||||
CloseRightButton.AddComponent<BoxCollider2D>().size = new(0.6f, 1.5f);
|
||||
var closeRightSpriteRenderer = CloseRightButton.AddComponent<SpriteRenderer>();
|
||||
closeRightSpriteRenderer.sprite = Utils.LoadSprite("EHR.Resources.Images.RightPanelCloseButton.png", 100f);
|
||||
closeRightSpriteRenderer.color = new(1f, 0.78f, 0.9f, 1f);
|
||||
var closeRightPassiveButton = CloseRightButton.AddComponent<PassiveButton>();
|
||||
closeRightPassiveButton.OnClick = new();
|
||||
closeRightPassiveButton.OnClick.AddListener((System.Action)MainMenuManagerPatch.HideRightPanel);
|
||||
closeRightPassiveButton.OnMouseOut = new();
|
||||
closeRightPassiveButton.OnMouseOut.AddListener((System.Action)(() => closeRightSpriteRenderer.color = new(1f, 0.78f, 0.9f, 1f)));
|
||||
closeRightPassiveButton.OnMouseOver = new();
|
||||
closeRightPassiveButton.OnMouseOver.AddListener((System.Action)(() => closeRightSpriteRenderer.color = new(1f, 0.68f, 0.99f, 1f)));
|
||||
|
||||
Tint = __instance.screenTint.gameObject;
|
||||
var ttap = Tint.GetComponent<AspectPosition>();
|
||||
if (ttap) Object.Destroy(ttap);
|
||||
Tint.transform.SetParent(RightPanel.transform);
|
||||
Tint.transform.localPosition = new Vector3(-0.0824f, 0.0513f, Tint.transform.localPosition.z);
|
||||
Tint.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||
__instance.howToPlayButton.gameObject.SetActive(false);
|
||||
__instance.howToPlayButton.transform.parent.Find("FreePlayButton").gameObject.SetActive(false);
|
||||
|
||||
if (!(BottomButtonBounds = GameObject.Find("BottomButtonBounds"))) return;
|
||||
BottomButtonBounds.transform.localPosition -= new Vector3(0f, 0.1f, 0f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+158
-83
@@ -2,7 +2,6 @@ using System;
|
||||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using static EHR.Translator;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace EHR;
|
||||
@@ -10,101 +9,177 @@ namespace EHR;
|
||||
[HarmonyPatch]
|
||||
public class MainMenuManagerPatch
|
||||
{
|
||||
public static GameObject Template;
|
||||
public static MainMenuManager Instance { get; private set; }
|
||||
|
||||
//public static GameObject qqButton;
|
||||
//public static GameObject discordButton;
|
||||
public static GameObject UpdateButton;
|
||||
public static PassiveButton Template;
|
||||
public static PassiveButton UpdateButton;
|
||||
private static PassiveButton gitHubButton;
|
||||
private static PassiveButton discordButton;
|
||||
private static PassiveButton websiteButton;
|
||||
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.LateUpdate)), HarmonyPostfix]
|
||||
public static void Postfix(MainMenuManager __instance)
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenGameModeMenu))]
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenAccountMenu))]
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.OpenCredits))]
|
||||
[HarmonyPrefix, HarmonyPriority(Priority.Last)]
|
||||
public static void ShowRightPanel() => ShowingPanel = true;
|
||||
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start))]
|
||||
[HarmonyPatch(typeof(OptionsMenuBehaviour), nameof(OptionsMenuBehaviour.Open))]
|
||||
[HarmonyPatch(typeof(AnnouncementPopUp), nameof(AnnouncementPopUp.Show))]
|
||||
[HarmonyPrefix, HarmonyPriority(Priority.Last)]
|
||||
public static void HideRightPanel()
|
||||
{
|
||||
if (__instance == null) return;
|
||||
try
|
||||
{
|
||||
__instance.playButton.transform.gameObject.SetActive(Options.IsLoaded);
|
||||
if (TitleLogoPatch.LoadingHint == null) return;
|
||||
TitleLogoPatch.LoadingHint.SetActive(!Options.IsLoaded);
|
||||
TitleLogoPatch.LoadingHint.GetComponent<TextMeshPro>().text = string.Format(GetString("LoadingWithPercentage"), Options.LoadingPercentage, Options.MainLoadingText, Options.RoleLoadingText);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
ShowingPanel = false;
|
||||
AccountManager.Instance?.transform?.FindChild("AccountTab/AccountWindow")?.gameObject?.SetActive(false);
|
||||
}
|
||||
|
||||
public static void ShowRightPanelImmediately()
|
||||
{
|
||||
ShowingPanel = true;
|
||||
TitleLogoPatch.RightPanel.transform.localPosition = TitleLogoPatch.RightPanelOp;
|
||||
Instance.OpenGameModeMenu();
|
||||
}
|
||||
|
||||
private static bool isOnline = false;
|
||||
public static bool ShowedBak = false;
|
||||
private static bool ShowingPanel = false;
|
||||
[HarmonyPatch(typeof(SignInStatusComponent), nameof(SignInStatusComponent.SetOnline)), HarmonyPostfix]
|
||||
public static void SetOnline_Postfix() {LateTask.New(() => { isOnline = true; }, 0.1f, "Set Online Status"); }
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPrefix]
|
||||
public static void Start_Prefix(MainMenuManager __instance)
|
||||
{
|
||||
if (Template == null) Template = GameObject.Find("/MainUI/ExitGameButton");
|
||||
if (Template == null) Template = __instance.quitButton;
|
||||
if (Template == null) return;
|
||||
|
||||
//if (CultureInfo.CurrentCulture.Name == "zh-CN")
|
||||
//{
|
||||
// //生成QQ群按钮
|
||||
// if (qqButton == null) qqButton = Object.Instantiate(template, template.transform.parent);
|
||||
// qqButton.name = "qqButton";
|
||||
// qqButton.transform.position = Vector3.Reflect(template.transform.position, Vector3.left);
|
||||
|
||||
// var qqText = qqButton.transform.GetChild(0).GetComponent<TMPro.TMP_Text>();
|
||||
// Color qqColor = new Color32(0, 164, 255, byte.MaxValue);
|
||||
// PassiveButton qqPassiveButton = qqButton.GetComponent<PassiveButton>();
|
||||
// SpriteRenderer qqButtonSprite = qqButton.GetComponent<SpriteRenderer>();
|
||||
// qqPassiveButton.OnClick = new();
|
||||
// qqPassiveButton.OnClick.AddListener((Action)(() => Application.OpenURL(Main.QQInviteUrl)));
|
||||
// qqPassiveButton.OnMouseOut.AddListener((Action)(() => qqButtonSprite.color = qqText.color = qqColor));
|
||||
// __instance.StartCoroutine(Effects.Lerp(0.01f, new Action<float>((p) => qqText.SetText("QQ群"))));
|
||||
// qqButtonSprite.color = qqText.color = qqColor;
|
||||
// qqButton.gameObject.SetActive(Main.ShowQQButton && !Main.IsAprilFools);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// //Discordボタンを生成
|
||||
// if (discordButton == null) discordButton = Object.Instantiate(template, template.transform.parent);
|
||||
// discordButton.name = "DiscordButton";
|
||||
// discordButton.transform.position = Vector3.Reflect(template.transform.position, Vector3.left);
|
||||
|
||||
// var discordText = discordButton.transform.GetChild(0).GetComponent<TMPro.TMP_Text>();
|
||||
// Color discordColor = new Color32(86, 98, 246, byte.MaxValue);
|
||||
// PassiveButton discordPassiveButton = discordButton.GetComponent<PassiveButton>();
|
||||
// SpriteRenderer discordButtonSprite = discordButton.GetComponent<SpriteRenderer>();
|
||||
// discordPassiveButton.OnClick = new();
|
||||
// discordPassiveButton.OnClick.AddListener((Action)(() => Application.OpenURL(Main.DiscordInviteUrl)));
|
||||
// discordPassiveButton.OnMouseOut.AddListener((Action)(() => discordButtonSprite.color = discordText.color = discordColor));
|
||||
// __instance.StartCoroutine(Effects.Lerp(0.01f, new Action<float>((p) => discordText.SetText("Discord"))));
|
||||
// discordButtonSprite.color = discordText.color = discordColor;
|
||||
// discordButton.gameObject.SetActive(Main.ShowDiscordButton && !Main.IsAprilFools);
|
||||
//}
|
||||
|
||||
if (UpdateButton == null) UpdateButton = Object.Instantiate(Template, Template.transform.parent);
|
||||
UpdateButton.name = "UpdateButton";
|
||||
UpdateButton.transform.position = Template.transform.position + new Vector3(0.25f, 0.75f);
|
||||
UpdateButton.transform.GetChild(0).GetComponent<RectTransform>().localScale *= 1.5f;
|
||||
|
||||
var updateText = UpdateButton.transform.GetChild(0).GetComponent<TMP_Text>();
|
||||
Color updateColor = new Color32(247, 56, 23, byte.MaxValue);
|
||||
PassiveButton updatePassiveButton = UpdateButton.GetComponent<PassiveButton>();
|
||||
SpriteRenderer updateButtonSprite = UpdateButton.GetComponent<SpriteRenderer>();
|
||||
updatePassiveButton.OnClick = new();
|
||||
updatePassiveButton.OnClick.AddListener((Action)(() =>
|
||||
if (UpdateButton == null)
|
||||
{
|
||||
UpdateButton.SetActive(false);
|
||||
ModUpdater.StartUpdate(ModUpdater.downloadUrl, true);
|
||||
}));
|
||||
updatePassiveButton.OnMouseOut.AddListener((Action)(() => updateButtonSprite.color = updateText.color = updateColor));
|
||||
updateButtonSprite.color = updateText.color = updateColor;
|
||||
updateButtonSprite.size *= 1.5f;
|
||||
UpdateButton = CreateButton(
|
||||
"updateButton",
|
||||
new(4.2f, -1.3f, 1f),
|
||||
new(255, 165, 0, byte.MaxValue),
|
||||
new(255, 200, 0, byte.MaxValue),
|
||||
() => ModUpdater.StartUpdate(ModUpdater.downloadUrl, true),
|
||||
Translator.GetString("updateButton"));
|
||||
UpdateButton.transform.localScale = Vector3.one;
|
||||
}
|
||||
UpdateButton.gameObject.SetActive(ModUpdater.hasUpdate);
|
||||
|
||||
#if RELEASE
|
||||
var freeplayButton = GameObject.Find("/MainUI/FreePlayButton");
|
||||
if (freeplayButton != null)
|
||||
{
|
||||
freeplayButton.GetComponent<PassiveButton>().OnClick = new();
|
||||
freeplayButton.GetComponent<PassiveButton>().OnClick.AddListener((Action)(() => Application.OpenURL("https://tohe.cc")));
|
||||
__instance.StartCoroutine(Effects.Lerp(0.01f, new Action<float>(p => freeplayButton.transform.GetChild(0).GetComponent<TMP_Text>().SetText(GetString("Website")))));
|
||||
}
|
||||
#endif
|
||||
Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60;
|
||||
}
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.LateUpdate)), HarmonyPostfix]
|
||||
public static void MainMenuManager_LateUpdate()
|
||||
{
|
||||
|
||||
Application.targetFrameRate = Main.UnlockFps.Value ? 165 : 60;
|
||||
if (GameObject.Find("MainUI") == null) ShowingPanel = false;
|
||||
|
||||
if (TitleLogoPatch.RightPanel != null)
|
||||
{
|
||||
var pos1 = TitleLogoPatch.RightPanel.transform.localPosition;
|
||||
Vector3 lerp1 = Vector3.Lerp(pos1, TitleLogoPatch.RightPanelOp + new Vector3(ShowingPanel ? 0f : 10f, 0f, 0f), Time.deltaTime * (ShowingPanel ? 3f : 2f));
|
||||
if (ShowingPanel
|
||||
? TitleLogoPatch.RightPanel.transform.localPosition.x > TitleLogoPatch.RightPanelOp.x + 0.03f
|
||||
: TitleLogoPatch.RightPanel.transform.localPosition.x < TitleLogoPatch.RightPanelOp.x + 9f
|
||||
) TitleLogoPatch.RightPanel.transform.localPosition = lerp1;
|
||||
}
|
||||
|
||||
if (ShowedBak || !isOnline) return;
|
||||
var bak = GameObject.Find("BackgroundTexture");
|
||||
if (bak == null || !bak.active) return;
|
||||
var pos2 = bak.transform.position;
|
||||
Vector3 lerp2 = Vector3.Lerp(pos2, new Vector3(pos2.x, 7.1f, pos2.z), Time.deltaTime * 1.4f);
|
||||
bak.transform.position = lerp2;
|
||||
if (pos2.y > 7f) ShowedBak = true;
|
||||
}
|
||||
public static SpriteRenderer MG_Logo;
|
||||
[HarmonyPatch(typeof(MainMenuManager), nameof(MainMenuManager.Start)), HarmonyPostfix, HarmonyPriority(Priority.VeryHigh)]
|
||||
public static void Start_Postfix(MainMenuManager __instance)
|
||||
{
|
||||
Instance = __instance;
|
||||
|
||||
SimpleButton.SetBase(__instance.quitButton);
|
||||
var logoObject = new GameObject("titleLogo_MG");
|
||||
var logoTransform = logoObject.transform;
|
||||
MG_Logo = logoObject.AddComponent<SpriteRenderer>();
|
||||
logoTransform.localPosition = new(2f, -0.5f, 1f);
|
||||
logoTransform.localScale *= 1.2f;
|
||||
MG_Logo.sprite = Utils.LoadSprite("EHR.Resources.Images.EHR-Icon.png", 400f);
|
||||
|
||||
// GitHub Button
|
||||
if (gitHubButton == null)
|
||||
{
|
||||
gitHubButton = CreateButton(
|
||||
"GitHubButton",
|
||||
new Vector3(-2.3f, -1.3f, 1f),
|
||||
new Color32(153, 153, 153, byte.MaxValue),
|
||||
new Color32(209, 209, 209, byte.MaxValue),
|
||||
() => Application.OpenURL("https://github.com/Gurge44/EndlessHostRoles"),
|
||||
Translator.GetString("GitHub")); //"GitHub"
|
||||
}
|
||||
gitHubButton.gameObject.SetActive(true);
|
||||
|
||||
// Discord Button
|
||||
if (discordButton == null)
|
||||
{
|
||||
discordButton = CreateButton(
|
||||
"DiscordButton",
|
||||
new Vector3(-0.5f, -1.3f, 1f),
|
||||
new Color32(88, 101, 242, byte.MaxValue),
|
||||
new Color32(148, 161, byte.MaxValue, byte.MaxValue),
|
||||
() => Application.OpenURL("https://discord.com/invite/m3ayxfumC8"),
|
||||
Translator.GetString("Discord")); //"Discord"
|
||||
}
|
||||
discordButton.gameObject.SetActive(true);
|
||||
|
||||
// Website Button
|
||||
if (websiteButton == null)
|
||||
{
|
||||
websiteButton = CreateButton(
|
||||
"WebsiteButton",
|
||||
new Vector3(1.3f, -1.3f, 1f),
|
||||
new Color32(251, 81, 44, byte.MaxValue),
|
||||
new Color32(211, 77, 48, byte.MaxValue),
|
||||
() => Application.OpenURL("https://sites.google.com/view/ehr-au"),
|
||||
Translator.GetString("Website")); //"Website"
|
||||
}
|
||||
websiteButton.gameObject.SetActive(true);
|
||||
|
||||
Application.targetFrameRate = Main.UnlockFps.Value ? 9999 : 60;
|
||||
}
|
||||
public static PassiveButton CreateButton(string name, Vector3 localPosition, Color32 normalColor, Color32 hoverColor, Action action, string label, Vector2? scale = null)
|
||||
{
|
||||
var button = Object.Instantiate(Template, Template.transform.parent);
|
||||
button.name = name;
|
||||
Object.Destroy(button.GetComponent<AspectPosition>());
|
||||
button.transform.localPosition = localPosition;
|
||||
|
||||
button.OnClick = new();
|
||||
button.OnClick.AddListener(action);
|
||||
|
||||
var buttonText = button.transform.Find("FontPlacer/Text_TMP").GetComponent<TMP_Text>();
|
||||
buttonText.DestroyTranslator();
|
||||
buttonText.fontSize = buttonText.fontSizeMax = buttonText.fontSizeMin = 3.5f;
|
||||
buttonText.enableWordWrapping = false;
|
||||
buttonText.text = label;
|
||||
var normalSprite = button.inactiveSprites.GetComponent<SpriteRenderer>();
|
||||
var hoverSprite = button.activeSprites.GetComponent<SpriteRenderer>();
|
||||
normalSprite.color = normalColor;
|
||||
hoverSprite.color = hoverColor;
|
||||
|
||||
var container = buttonText.transform.parent;
|
||||
Object.Destroy(container.GetComponent<AspectPosition>());
|
||||
Object.Destroy(buttonText.GetComponent<AspectPosition>());
|
||||
container.SetLocalX(0f);
|
||||
buttonText.transform.SetLocalX(0f);
|
||||
buttonText.horizontalAlignment = HorizontalAlignmentOptions.Center;
|
||||
|
||||
var buttonCollider = button.GetComponent<BoxCollider2D>();
|
||||
if (scale.HasValue)
|
||||
{
|
||||
normalSprite.size = hoverSprite.size = buttonCollider.size = scale.Value;
|
||||
}
|
||||
|
||||
buttonCollider.offset = new(0f, 0f);
|
||||
|
||||
return button;
|
||||
}
|
||||
}
|
||||
@@ -240,6 +240,7 @@
|
||||
>
|
||||
> - Our repo is a continuation of TOHE
|
||||
> - TONX reference: Modify character limit for chat messages
|
||||
> - TONX reference: Modify and apply cool animations on Main Menu
|
||||
>
|
||||
### :star: [TOH](https://github.com/tukasa0001/TownOfHost) :
|
||||
>
|
||||
@@ -298,6 +299,11 @@
|
||||
> - Reference: Store message history
|
||||
>
|
||||
|
||||
### :star: [MoreGamemodes](https://github.com/Rabek009/MoreGamemodes) :
|
||||
>
|
||||
> - Reference: Part of the code used for the Endless Host Roles Image in the Main Menu
|
||||
>
|
||||
|
||||
### Endless Host Roles (EHR), with Endless Possibilities, brought to you by the Endless Network.
|
||||
##### Developers:
|
||||
- Gurge44
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 2.3 MiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -2379,6 +2379,8 @@
|
||||
"AntiBlackOutLoggerSendInGame": "Because of an unknown error, the game will end to prevent black screen.",
|
||||
"AntiBlackOutRequestHostToForceEnd": "You were the reason of the black screen, you are asking the host to stop the game...",
|
||||
"AntiBlackOutHostRejectForceEnd": "You were the reason of the black screen, and the host is not going to end the game, we will disconnect you soon.",
|
||||
"GitHub": "GitHub",
|
||||
"Discord": "Discord",
|
||||
"Website": "Website",
|
||||
"NextPage": "Next Page",
|
||||
"PreviousPage": "Previous Page",
|
||||
|
||||
@@ -2399,6 +2399,8 @@
|
||||
"AntiBlackOutLoggerSendInGame": "Por causa de um erro desconhecido, o Jogo irá acabar para evitar telas pretas.",
|
||||
"AntiBlackOutRequestHostToForceEnd": "Você foi o motivo da tela preta, você está pedindo para o Anfitrião encerrar o jogo...",
|
||||
"AntiBlackOutHostRejectForceEnd": "Você foi o motivo pra tela preta, e o Anfitrião não irá encerrar o jogo, você será desconectado em breve.",
|
||||
"GitHub": "GitHub",
|
||||
"Discord": "Discord",
|
||||
"Website": "Página",
|
||||
"NextPage": "Próxima Página",
|
||||
"PreviousPage": "Página Anterior",
|
||||
|
||||
Reference in new issue
Block a user