1+ using HarmonyLib ;
2+ using Reactor . Utilities . Extensions ;
3+ using System ;
4+ using TMPro ;
5+ using UnityEngine ;
6+ using Object = UnityEngine . Object ;
7+
8+ namespace TheOtherRoles . Patches ;
9+
10+ internal class CreateGameOptionsPatch
11+ {
12+ public static PassiveButton modeButtonGS ;
13+ public static PassiveButton modeButtonHK ;
14+ public static PassiveButton modeButtonPH ;
15+
16+ [ HarmonyPatch ( typeof ( CreateGameOptions ) , nameof ( CreateGameOptions . Start ) ) ]
17+ public static class CreateGameOptionsStartPatch
18+ {
19+ private static void Postfix ( CreateGameOptions __instance )
20+ {
21+ var blackSquare = GameObject . Find ( "BlackSquare" ) ;
22+ blackSquare . transform . localPosition = new Vector3 ( - 2.35f , - 4.04f , - 1f ) ;
23+ __instance . modeButtons [ 0 ] . transform . localPosition = new Vector3 ( - 0f , - 4f , - 3f ) ;
24+ __instance . modeButtons [ 1 ] . transform . localPosition = new Vector3 ( 2.91f , - 4f , - 3f ) ;
25+ __instance . serverDropdown . transform . SetLocalY ( - 2.63f ) ;
26+
27+ __instance . modeButtons [ 0 ] . OnClick . AddListener ( ( Action ) ( ( ) =>
28+ {
29+ modeButtonGS . SelectButton ( false ) ;
30+ modeButtonHK . SelectButton ( false ) ;
31+ modeButtonPH . SelectButton ( false ) ;
32+ }
33+ ) ) ;
34+
35+ __instance . modeButtons [ 1 ] . OnClick . AddListener ( ( Action ) ( ( ) =>
36+ {
37+ modeButtonGS . SelectButton ( false ) ;
38+ modeButtonHK . SelectButton ( false ) ;
39+ modeButtonPH . SelectButton ( false ) ;
40+ }
41+ ) ) ;
42+
43+ TORMapOptions . gameMode = CustomGamemodes . Classic ;
44+
45+ modeButtonGS = Object . Instantiate ( __instance . modeButtons [ 0 ] , __instance . modeButtons [ 0 ] . transform ) ;
46+ modeButtonGS . name = "TORGUESSER" ;
47+ changeButtonText ( modeButtonGS , "TOR Guesser" ) ;
48+ modeButtonGS . transform . localPosition = new Vector3 ( 5.8f , - 0f , - 3f ) ;
49+ modeButtonGS . OnClick . RemoveAllListeners ( ) ;
50+ __instance . StartCoroutine ( Effects . Lerp ( 0.1f , new Action < float > ( p => modeButtonGS . SelectButton ( false ) ) ) ) ;
51+ modeButtonGS . OnMouseOver . AddListener ( ( Action ) ( ( ) => __instance . tooltip . SetText ( "An extension to the Classic-Gamemode and gives you a multitude of new options for Guessers." ) ) ) ;
52+ modeButtonGS . OnClick . AddListener ( ( Action ) ( ( ) =>
53+ {
54+ TORMapOptions . gameMode = CustomGamemodes . Guesser ;
55+ modeButtonGS . SelectButton ( true ) ;
56+ __instance . modeButtons [ 0 ] . SelectButton ( false ) ;
57+ __instance . modeButtons [ 1 ] . SelectButton ( false ) ;
58+ modeButtonHK . SelectButton ( false ) ;
59+ modeButtonPH . SelectButton ( false ) ;
60+ }
61+ ) ) ;
62+
63+ modeButtonHK = Object . Instantiate ( modeButtonGS , __instance . modeButtons [ 0 ] . transform ) ;
64+ modeButtonHK . name = "TORHIDENSEEK" ;
65+ changeButtonText ( modeButtonHK , "TOR Hide N Seek" ) ;
66+ modeButtonHK . transform . localPosition = new Vector3 ( 0 , - 0.8f , - 3f ) ;
67+ modeButtonHK . OnClick . RemoveAllListeners ( ) ;
68+ __instance . StartCoroutine ( Effects . Lerp ( 0.1f , new Action < float > ( p => modeButtonHK . SelectButton ( false ) ) ) ) ;
69+ modeButtonHK . OnMouseOver . AddListener ( ( Action ) ( ( ) => __instance . tooltip . SetText ( "A standalone Gamemode where Hunter have to catch their prey (\" Hunted\" players)." ) ) ) ;
70+ modeButtonHK . OnClick . AddListener ( ( Action ) ( ( ) =>
71+ {
72+ TORMapOptions . gameMode = CustomGamemodes . HideNSeek ;
73+ modeButtonHK . SelectButton ( true ) ;
74+ __instance . modeButtons [ 0 ] . SelectButton ( false ) ;
75+ __instance . modeButtons [ 1 ] . SelectButton ( false ) ;
76+ modeButtonGS . SelectButton ( false ) ;
77+ modeButtonPH . SelectButton ( false ) ;
78+ }
79+ ) ) ;
80+
81+ modeButtonPH = Object . Instantiate ( modeButtonHK , __instance . modeButtons [ 0 ] . transform ) ;
82+ modeButtonPH . name = "TORPROPHUNT" ;
83+ changeButtonText ( modeButtonPH , "TOR Prop Hunt" ) ;
84+ modeButtonPH . transform . localPosition = new Vector3 ( 2.9f , - 0.8f , - 3f ) ;
85+ modeButtonPH . OnClick . RemoveAllListeners ( ) ;
86+ __instance . StartCoroutine ( Effects . Lerp ( 0.1f , new Action < float > ( p => modeButtonPH . SelectButton ( false ) ) ) ) ;
87+ modeButtonPH . OnMouseOver . AddListener ( ( Action ) ( ( ) => __instance . tooltip . SetText ( "A standalone Gamemode where Hunters have to find the disguised players (\" Props\" )." ) ) ) ;
88+ modeButtonPH . OnClick . AddListener ( ( Action ) ( ( ) =>
89+ {
90+ TORMapOptions . gameMode = CustomGamemodes . PropHunt ;
91+ modeButtonPH . SelectButton ( true ) ;
92+ __instance . modeButtons [ 0 ] . SelectButton ( false ) ;
93+ __instance . modeButtons [ 1 ] . SelectButton ( false ) ;
94+ modeButtonGS . SelectButton ( false ) ;
95+ modeButtonHK . SelectButton ( false ) ;
96+ }
97+ ) ) ;
98+ }
99+ internal static void changeButtonText ( PassiveButton passiveButton , string buttonText )
100+ {
101+ passiveButton . transform . FindChild ( "SelectedInactive/ClassicText" ) . gameObject . GetComponentInChildren < TextTranslatorTMP > ( ) . Destroy ( ) ;
102+ passiveButton . transform . FindChild ( "Inactive/ClassicText" ) . gameObject . GetComponentInChildren < TextTranslatorTMP > ( ) . Destroy ( ) ;
103+ passiveButton . transform . FindChild ( "Highlight/ClassicText" ) . gameObject . GetComponentInChildren < TextTranslatorTMP > ( ) . Destroy ( ) ;
104+ passiveButton . transform . FindChild ( "SelectedHighlight/ClassicText" ) . gameObject . GetComponentInChildren < TextTranslatorTMP > ( ) . Destroy ( ) ;
105+
106+ passiveButton . transform . FindChild ( "SelectedInactive/ClassicText" ) . gameObject . GetComponentInChildren < TMP_Text > ( ) . SetText ( buttonText ) ;
107+ passiveButton . transform . FindChild ( "Inactive/ClassicText" ) . gameObject . GetComponentInChildren < TMP_Text > ( ) . SetText ( buttonText ) ;
108+ passiveButton . transform . FindChild ( "Highlight/ClassicText" ) . gameObject . GetComponentInChildren < TMP_Text > ( ) . SetText ( buttonText ) ;
109+ passiveButton . transform . FindChild ( "SelectedHighlight/ClassicText" ) . gameObject . GetComponentInChildren < TMP_Text > ( ) . SetText ( buttonText ) ;
110+ }
111+ }
112+ }
0 commit comments