33using System . Linq ;
44using BepInEx ;
55using HarmonyLib ;
6- using CobwebAPI ;
76using CobwebAPI . API ;
87using UnityEngine ;
8+ using UnityEngine . EventSystems ;
9+ using UnityEngine . InputSystem ;
10+ using UnityEngine . Internal ;
11+ using UnityEngineInternal . Input ;
912using UnityEngine . PlayerLoop ;
13+ using UnityEngine . UI ;
1014
1115
1216namespace ModifierModifier
@@ -20,19 +24,20 @@ public class Main : BaseUnityPlugin
2024 private Vector2 currentDrag = new Vector2 ( ) ;
2125 public Vector2 scrollPosition ;
2226 public bool menuEnabled ;
27+ private InputAction _inputAction = new InputAction ( binding : "<Keyboard>/Insert" ) ;
2328
2429 public const string ModName = "ModifierModifier" ;
2530 public const string ModAuthor = "Bazinga" ;
2631 public const string ModGUID = "com.bazinga.modifiermodifier" ;
27- public const string ModVersion = "1.0 .0" ;
32+ public const string ModVersion = "1.1 .0" ;
2833 internal Harmony Harmony ;
2934
3035 internal void Awake ( )
3136 {
3237 Harmony = new Harmony ( ModGUID ) ;
3338
3439 Harmony . PatchAll ( ) ;
35- Logger . LogInfo ( $ "{ ModName } successfully loaded! Made by { ModAuthor } ") ;
40+ Logger . LogInfo ( $ "{ ModName } successfully loaded! Made by { ModAuthor } \n Toggle Menu with the INS or INSERT key ") ;
3641
3742
3843 Main . GUIStyle . alignment = TextAnchor . MiddleCenter ;
@@ -43,46 +48,53 @@ internal void Awake()
4348 backgroundStyle . normal . textColor = Color . black ;
4449 backgroundStyle . normal . background = Texture2D . grayTexture ;
4550 menuEnabled = false ;
51+ _inputAction . Enable ( ) ;
4652 }
4753
48- void Update ( )
54+ private void Update ( )
4955 {
50- if ( Input . GetKeyDown ( KeyCode . Insert ) )
56+ if ( _inputAction . triggered )
5157 {
58+ Logger . LogInfo ( $ "Menu Toggled: { menuEnabled } ") ;
5259 menuEnabled = ! menuEnabled ;
5360 }
5461 }
5562
5663 [ HarmonyPatch ( typeof ( ModifierManager ) , "GetNonMaxedWavesMods" ) ]
5764 private void OnGUI ( )
5865 {
59-
6066 var menuRect = new Rect ( 0 , 25f , Screen . width / 2 , Screen . height / 2 ) ;
61- GUI . BeginGroup ( menuRect , GUIStyle ) ;
67+
6268 int valX = 0 ;
6369 int valY = 0 ;
64- foreach ( var mods in GetTotalNonMaxedModifiers ( ) )
70+ if ( menuEnabled )
6571 {
66- if ( ( valY + 77 ) >= ( Screen . height / 2 ) )
67- {
68- valY = 0 ;
69- valX += 173 ;
70- }
72+ GUI . BeginGroup ( menuRect , GUIStyle ) ;
7173
72- bool flag = GUI . Button ( new Rect ( 25f + valX , ( float ) ( 25 + valY ) , 150f , 40f ) , mods . data . name ,
73- Main . backgroundStyle ) ;
74- if ( flag )
74+ foreach ( var mods in GetTotalNonMaxedModifiers ( ) )
7575 {
76- Logger . LogInfo ( mods . data . name + "Has been clicked" ) ;
77- mods . levelInWaves = mods . data . maxLevel ;
78-
79- Logger . LogInfo ( mods . levelInWaves ) ;
80- Logger . LogInfo ( mods . levelInVersus ) ;
76+ if ( ( valY + 77 ) >= ( Screen . height / 2 ) )
77+ {
78+ valY = 0 ;
79+ valX += 173 ;
80+ }
81+
82+ bool flag = GUI . Button ( new Rect ( 25f + valX , ( float ) ( 25 + valY ) , 150f , 40f ) , mods . data . name ,
83+ Main . backgroundStyle ) ;
84+ if ( flag )
85+ {
86+ Logger . LogInfo ( mods . data . name + "Has been clicked" ) ;
87+ mods . levelInWaves = mods . data . maxLevel ;
88+
89+ Logger . LogInfo ( mods . levelInWaves ) ;
90+ Logger . LogInfo ( mods . levelInVersus ) ;
91+ }
92+
93+ valY += 47 ;
8194 }
82-
83- valY += 47 ;
95+ GUI . EndGroup ( ) ;
8496 }
85- GUI . EndGroup ( ) ;
97+
8698
8799
88100 }
@@ -95,7 +107,8 @@ void ModifierModifierWindow(int windowID)
95107
96108 public void MaxMod ( Modifier mod )
97109 {
98- WaveModifiers . Give ( mod . data . name , mod . data . maxLevel ) ;
110+
111+ CobwebAPI . API . WaveModifiers . Give ( mod . data . name , mod . data . maxLevel ) ;
99112 Logger . LogInfo ( mod . levelInWaves ) ;
100113 Logger . LogInfo ( mod . levelInVersus ) ;
101114 }
0 commit comments