11using Il2CppSystem ;
2- using LaunchpadReloaded . API . Settings ;
3- using MiraAPI . PluginLoading ;
42using System . Linq ;
53using BepInEx . Configuration ;
64using LaunchpadReloaded . Components ;
7- using Reactor . Utilities ;
5+ using MiraAPI . Hud ;
6+ using MiraAPI . LocalSettings ;
7+ using MiraAPI . LocalSettings . Attributes ;
88using Object = Il2CppSystem . Object ;
99
1010namespace LaunchpadReloaded . Features ;
1111
12- public class LaunchpadSettings
12+ public class LaunchpadSettings : LocalSettingsTab
1313{
14- public static LaunchpadSettings ? Instance { get ; private set ; }
14+ public override string TabName => "Launchpad" ;
1515
16- public CustomSetting Bloom { get ; }
17- public CustomSetting UseCustomBloomSettings { get ; }
18- public CustomSetting LockedCamera { get ; }
19- public CustomSetting UniqueDummies { get ; }
20- public CustomSetting ButtonLocation { get ; }
16+ public override LocalSettingTabAppearance TabAppearance { get ; } = new ( )
17+ {
18+ TabIcon = LaunchpadAssets . HackButton
19+ } ;
20+
21+ [ LocalToggleSetting ]
22+ public ConfigEntry < bool > Bloom { get ; }
23+
24+ [ LocalToggleSetting ]
25+ public ConfigEntry < bool > CustomBloomSettings { get ; }
26+
27+ [ LocalSliderSetting ( formatString : "0.0" , min : 0.5f , max : 5f ) ]
28+ public ConfigEntry < float > BloomSlider { get ; }
2129
22- public ConfigEntry < float > BloomThreshold { get ; }
30+ [ LocalToggleSetting ]
31+ public ConfigEntry < bool > LockedCamera { get ; private set ; }
2332
24- private LaunchpadSettings ( )
33+ [ LocalToggleSetting ]
34+ public ConfigEntry < bool > UniqueDummies { get ; }
35+
36+ [ LocalEnumSetting ( names : [ "Bottom Left" , "Bottom Right" ] ) ]
37+ public ConfigEntry < ButtonLocation > ButtonLocation { get ; }
38+
39+ public LaunchpadSettings ( ConfigFile config ) : base ( config )
2540 {
26- var configFile = PluginSingleton < LaunchpadReloadedPlugin > . Instance . GetConfigFile ( ) ;
27- var buttonConfig = configFile . Bind ( "LP Settings" , "Button Location" , true , "Move buttons to the left side of the screen" ) ;
28- var bloomConfig = configFile . Bind ( "LP Settings" , "Bloom" , true , "Enable bloom effect" ) ;
29- var lockedCameraConfig = configFile . Bind ( "LP Settings " , "Locked Camera " , false , "Lock camera to player" ) ;
30- var uniqueDummiesConfig = configFile . Bind ( "LP Settings" , "Unique Freeplay Dummies" , true , "Give each dummy a unique name" ) ;
41+ Bloom = config . Bind ( "General" , "Enable Bloom" , true ) ;
42+ Bloom . SettingChanged += ( _ , _ ) => { SetBloom ( Bloom . Value ) ; } ;
43+
44+ CustomBloomSettings = config . Bind ( "General " , "Custom Bloom Settings " , false ) ;
45+ CustomBloomSettings . SettingChanged += ( _ , _ ) => { SetBloom ( Bloom . Value ) ; } ;
3146
32- ButtonLocation = new CustomSetting ( "Buttons On Left" , buttonConfig . Value )
47+ BloomSlider = config . Bind ( "General" , "Bloom Threshold" , 1.2f ) ;
48+ BloomSlider . SettingChanged += ( _ , _ ) => { SetBloom ( Bloom . Value ) ; } ;
49+
50+ LockedCamera = config . Bind ( "General" , "Locked Camera" , false ) ;
51+
52+ ButtonLocation = config . Bind ( "General" , "Button Location" , MiraAPI . Hud . ButtonLocation . BottomRight ) ;
53+ ButtonLocation . SettingChanged += ( _ , _ ) =>
3354 {
34- ChangedEvent = val =>
55+ foreach ( var button in MiraAPI . PluginLoading . MiraPluginManager . GetPluginByGuid ( LaunchpadReloadedPlugin . Id ) ! . Buttons )
3556 {
36- var plugin = MiraPluginManager . GetPluginByGuid ( LaunchpadReloadedPlugin . Id ) ! ;
37- foreach ( var button in plugin . Buttons )
38- {
39- button . SetButtonLocation ( val ? MiraAPI . Hud . ButtonLocation . BottomLeft : MiraAPI . Hud . ButtonLocation . BottomRight ) ;
40- }
57+ button . SetButtonLocation ( ButtonLocation . Value ) ;
4158 }
4259 } ;
4360
44- Bloom = new CustomSetting ( "Bloom" , bloomConfig . Value )
61+ UniqueDummies = config . Bind ( "General" , "Unique Freeplay Dummies" , false ) ;
62+ UniqueDummies . SettingChanged += ( _ , _ ) =>
4563 {
46- ChangedEvent = SetBloom
47- } ;
48-
49- UseCustomBloomSettings = new CustomSetting ( "Use Custom Bloom Settings" , false )
50- {
51- ChangedEvent = _ => { SetBloom ( Bloom . Enabled ) ; }
52- } ;
64+ if ( ! TutorialManager . InstanceExists || ! AccountManager . InstanceExists )
65+ {
66+ return ;
67+ }
5368
54- BloomThreshold = configFile . Bind ( "LP Settings" , "Custom Bloom Threshold" , 1.2f , "Bloom threshold (linear)" ) ;
55- BloomThreshold . SettingChanged += ( _ , _ ) => { SetBloom ( Bloom . Enabled ) ; } ;
69+ var dummies = UnityEngine . Object . FindObjectsOfType < DummyBehaviour > ( ) . ToArray ( ) . Reverse ( ) . ToList ( ) ;
5670
57- LockedCamera = new CustomSetting ( "Locked Camera" , lockedCameraConfig . Value ) ;
58- UniqueDummies = new CustomSetting ( "Unique Freeplay Dummies" , uniqueDummiesConfig . Value )
59- {
60- ChangedEvent = val =>
71+ for ( var i = 0 ; i < dummies . Count ; i ++ )
6172 {
62- if ( ! TutorialManager . InstanceExists || ! AccountManager . InstanceExists )
73+ var dummy = dummies [ i ] ;
74+ if ( ! dummy . myPlayer )
6375 {
64- return ;
76+ continue ;
6577 }
6678
67- var dummies = UnityEngine . Object . FindObjectsOfType < DummyBehaviour > ( ) . ToArray ( ) . Reverse ( ) . ToList ( ) ;
68-
69- for ( var i = 0 ; i < dummies . Count ; i ++ )
70- {
71- var dummy = dummies [ i ] ;
72- if ( ! dummy . myPlayer )
73- {
74- continue ;
75- }
76-
77- dummy . myPlayer . SetName ( val ? AccountManager . Instance . GetRandomName ( ) :
78- DestroyableSingleton < TranslationController > . Instance . GetString ( StringNames . Dummy , Array . Empty < Object > ( ) ) + " " + i ) ;
79- }
79+ dummy . myPlayer . SetName ( UniqueDummies . Value
80+ ? AccountManager . Instance . GetRandomName ( )
81+ : DestroyableSingleton < TranslationController > . Instance . GetString ( StringNames . Dummy ,
82+ Array . Empty < Object > ( ) ) + " " + i ) ;
8083 }
8184 } ;
8285 }
8386
87+
8488 public static void SetBloom ( bool enabled )
8589 {
8690 if ( ! HudManager . InstanceExists )
@@ -95,9 +99,4 @@ public static void SetBloom(bool enabled)
9599 bloom . enabled = enabled ;
96100 bloom . SetBloomByMap ( ) ;
97101 }
98-
99- public static void Initialize ( )
100- {
101- Instance = new LaunchpadSettings ( ) ;
102- }
103102}
0 commit comments