55using static Astrum . AstralCore . Managers . CommandManager ;
66using static Astrum . AstralCore . Managers . ModuleManager ;
77
8- [ assembly: MelonInfo ( typeof ( Astrum . AstralUI . UIMGUI ) , "AstralUI.UIMGUI" , "0.1 .0" , downloadLink : "github.com/Astrum-Project/AstralUI.UIMGUI" ) ]
8+ [ assembly: MelonInfo ( typeof ( Astrum . AstralUI . UIMGUI ) , "AstralUI.UIMGUI" , "0.2 .0" , downloadLink : "github.com/Astrum-Project/AstralUI.UIMGUI" ) ]
99[ assembly: MelonColor ( ConsoleColor . DarkMagenta ) ]
1010
1111namespace Astrum . AstralUI
1212{
1313 public class UIMGUI : MelonMod
1414 {
15- public Module currentModule = null ;
16- private Rect position = new Rect ( Screen . width / 2 - 78 , Screen . height / 2 - 307 , 156 , 482 ) ;
15+ public static Color32 color = new ( 0x56 , 0x00 , 0xA5 , 0xFF ) ;
16+ public static Module currentModule = null ;
17+
18+ private static Rect position = new ( Screen . width / 2 - 78 , Screen . height / 2 - 307 , 156 , 482 ) ;
19+
20+ public override void OnApplicationStart ( )
21+ {
22+ MelonPreferences_Category category = MelonPreferences . CreateCategory ( "Astrum-AstralUI-UIMGUI" , "AstralUI UIMGUI" ) ;
23+
24+ category . CreateEntry ( nameof ( color ) , new Color32 ( 0x56 , 0x00 , 0xA5 , 0xFF ) , "Color" ) ;
25+ }
26+
27+ public override void OnPreferencesSaved ( ) => OnPreferencesLoaded ( ) ;
28+ public override void OnPreferencesLoaded ( )
29+ {
30+ MelonPreferences_Category category = MelonPreferences . GetCategory ( "Astrum-AstralUI-UIMGUI" ) ;
31+
32+ color = category . GetEntry < Color32 > ( nameof ( color ) ) . Value ;
33+ }
1734
1835 public override void OnGUI ( )
1936 {
2037 if ( ! Input . GetKey ( KeyCode . Tab ) ) return ;
2138
22- GUI . backgroundColor = new Color32 ( 0x56 , 0x00 , 0xA5 , 0xFF ) ;
39+ GUI . backgroundColor = color ;
2340 GUI . color = Color . white ;
2441
2542 position = GUI . Window ( 25 , position , ( GUI . WindowFunction ) ModulesWindow , "Modules" ) ;
@@ -44,28 +61,22 @@ private void CommandsWindow(int windowID)
4461
4562 foreach ( KeyValuePair < string , Command > command in currentModule . commands )
4663 {
47- if ( command . Value is ConVar < bool > )
48- {
49- ConVar < bool > c = ( ConVar < bool > ) command . Value ;
50- c . Value = GUI . Toggle ( CreateRect ( ref i ) , c . Value , command . Key ) ;
51- }
52- else if ( command . Value is ConVar < float > )
64+ if ( command . Value is ConVar < bool > cb )
65+ cb . Value = GUI . Toggle ( CreateRect ( ref i ) , cb . Value , command . Key ) ;
66+ else if ( command . Value is ConVar < float > cf )
5367 {
54- ConVar < float > c = ( ConVar < float > ) command . Value ;
55- GUI . Label ( CreateRect ( ref i ) , command . Key + $ ": ({ c . Value . ToString ( "0.00" ) } )") ;
56- c . Value = GUI . HorizontalSlider ( CreateRect ( ref i ) , c . Value , c . Value - 10 , c . Value + 10 ) ;
68+ GUI . Label ( CreateRect ( ref i ) , command . Key + $ ": ({ cf . Value : 0.00} )") ;
69+ cf . Value = GUI . HorizontalSlider ( CreateRect ( ref i ) , cf . Value , cf . Value - 10 , cf . Value + 10 ) ;
5770 }
58- else if ( command . Value is Button ) {
71+ else if ( command . Value is Button )
72+ {
5973 if ( GUI . Button ( CreateRect ( ref i ) , command . Key ) )
6074 ( command . Value as Button ) ? . onClick ( ) ;
6175 }
62- else
63- {
64- GUI . Label ( CreateRect ( ref i ) , command . Key + " (Unsupported type)" ) ;
65- }
76+ else GUI . Label ( CreateRect ( ref i ) , command . Key + " (Unsupported type)" ) ;
6677 }
6778 }
6879
69- private static Rect CreateRect ( ref int i ) => new Rect ( 3 , i ++ * 22 + 21 , 300 , 20 ) ;
80+ private static Rect CreateRect ( ref int i ) => new ( 3 , i ++ * 22 + 21 , 300 , 20 ) ;
7081 }
7182}
0 commit comments