11using BepInEx ;
22using BepInEx . Configuration ;
3+ using BepInEx . Configuration . Json ;
34using BepInEx . Logging ;
45using HarmonyLib ;
5- using MaidStatus ;
6- using PrivateMaidMode ;
7- using RootMotion ;
6+ using Newtonsoft . Json ;
87using System ;
9- using System . Collections ;
108using System . Collections . Generic ;
11- using System . Linq ;
9+ using System . IO ;
1210using System . Reflection ;
1311using System . Security ;
1412using System . Security . Permissions ;
15- using System . Text ;
1613using UnityEngine ;
17- using UnityEngine . SceneManagement ;
18- using UnityEngine . UI ;
19- using UniverseLib ;
20- using UniverseLib . Input ;
21- using UniverseLib . UI ;
14+ using UnityEngine . Events ;
15+ using static Newtonsoft . Json . JsonToken ;
16+
2217
2318
2419// If there are errors in the above using statements, restore the NuGet packages:
3934
4035// This is the major & minor version with an asterisk (*) appended to auto increment numbers.
4136[ assembly: AssemblyVersion ( COM3D2 . ButtJiggle . PluginInfo . PLUGIN_VERSION + ".*" ) ]
37+ [ assembly: AssemblyFileVersion ( COM3D2 . ButtJiggle . PluginInfo . PLUGIN_VERSION ) ]
4238
43- // These two lines tell your plugin to not give a flying fuck about accessing private variables/classes whatever.
39+ // These two lines tell your plugin to not give a flying flip about accessing private variables/classes whatever.
4440// It requires a publicized stubb of the library with those private objects though.
4541[ module: UnverifiableCode ]
4642[ assembly: SecurityPermission ( SecurityAction . RequestMinimum , SkipVerification = true ) ]
@@ -55,7 +51,7 @@ public static class PluginInfo
5551 // The name of this plugin.
5652 public const string PLUGIN_NAME = "Butt Jiggle" ;
5753 // The version of this plugin.
58- public const string PLUGIN_VERSION = "0.7 " ;
54+ public const string PLUGIN_VERSION = "0.11 " ;
5955 }
6056}
6157
@@ -76,51 +72,126 @@ public sealed partial class ButtJiggle : BaseUnityPlugin
7672 private ManualLogSource _Logger => base . Logger ;
7773
7874 internal static ConfigEntry < KeyboardShortcut > UIHotkey ;
75+
76+
77+ internal static ConfigEntry < double > ButtJiggle_ConfigVersion ;
78+
7979 internal static ConfigEntry < bool > ButtJiggle_Enabled ;
80- internal static ConfigEntry < float > ButtJiggle_DefaultSoftness ;
80+ internal static ConfigEntry < float > ButtJiggle_DefaultSoftness_Hip ;
81+ internal static ConfigEntry < float > ButtJiggle_DefaultSoftness_Pelvis ;
82+
83+ //internal static ConfigEntry<bool> Experimental_PelvisEnabled;
84+
85+ internal static ConfigEntry < bool > GlobalOverride_Enabled ;
86+ internal static ConfigEntry < string > GlobalOverride_Json ;
87+ internal static ConfigEntryJson < MaidJiggleOverride > GlobalOverride_Settings ;
88+
89+ public UnityEvent OnGlobalOverrideUpdated ;
8190
8291 void Awake ( )
8392 {
8493 // Useful for engaging coroutines or accessing non-static variables. Completely optional though.
8594 Instance = this ;
8695
8796 // Binds the configuration. In other words it sets your ConfigEntry var to your config setup.
88- ButtJiggle_Enabled = Config . Bind ( "Butt Jiggle" , "Enabled" , true , "Description" ) ;
89- ButtJiggle_DefaultSoftness = Config . Bind ( "Butt Jiggle" , "DefaultSoftness" , 0.5f , "Description" ) ;
97+ ButtJiggle_ConfigVersion = Config . Bind ( "ButtJiggle" , "ConfigVersion" , 0.0 , new ConfigDescription (
98+ "Do not change this" ,
99+ null ,
100+ new ConfigurationManagerAttributes ( )
101+ {
102+ IsAdvanced = true ,
103+ ReadOnly = true ,
104+ }
105+ ) ) ;
106+
107+ ButtJiggle_Enabled = Config . Bind ( "ButtJiggle" , "Enabled" , true ) ;
108+ ButtJiggle_DefaultSoftness_Hip = Config . Bind ( "ButtJiggle" , "DefaultSoftness.Hip" , MaidJiggleOverride . Default . HipOverride . Softness . Value ) ;
109+ ButtJiggle_DefaultSoftness_Pelvis = Config . Bind ( "ButtJiggle" , "DefaultSoftness.Pelvis" , MaidJiggleOverride . Default . PelvisOverride . Softness . Value ) ;
110+ if ( ButtJiggle_ConfigVersion . Value < 1.11 )
111+ {
112+ ButtJiggle_DefaultSoftness_Pelvis . Value = MaidJiggleOverride . Default . PelvisOverride . Softness . Value ;
113+ }
114+
115+ //Experimental_PelvisEnabled = Config.Bind("Experimental", "PelvisEnabled", false);
116+
117+
118+ ConfigBindGlobalOverride ( ) ;
90119
91120 // Add the keybind
92121 KeyboardShortcut hotkey = new KeyboardShortcut ( KeyCode . A , KeyCode . LeftControl ) ;
93- UIHotkey = Config . Bind ( "UI" , "Toggle" , hotkey , "Recomend using Ctrl A for 'Ass'" ) ;
122+ UIHotkey = Config . Bind ( "UI" , "Toggle" , hotkey , "Recommend using Ctrl A for 'Ass'" ) ;
94123
95- Logger . LogInfo ( "Patching ButtJiggle" ) ;
124+ ButtJiggle_ConfigVersion . Value = double . Parse ( PluginInfo . PLUGIN_VERSION ) ;
125+
126+ Logger . LogDebug ( "Patching ButtJiggle" ) ;
96127 Harmony . CreateAndPatchAll ( typeof ( ButtJiggle ) ) ;
97128
98- Logger . LogInfo ( "Patching TBodyPatch" ) ;
129+ Logger . LogDebug ( "Patching TBodyPatch" ) ;
99130 Harmony . CreateAndPatchAll ( typeof ( TBodyPatch ) ) ;
100131
101- Logger . LogInfo ( "Patching BoneMorph_Patch" ) ;
132+ Logger . LogDebug ( "Patching BoneMorph_Patch" ) ;
102133 Harmony . CreateAndPatchAll ( typeof ( BoneMorph_Patch ) ) ;
103134
104- Logger . LogInfo ( "Finished patching" ) ;
135+ Logger . LogDebug ( "Finished patching" ) ;
105136 }
106137
107138 void Start ( )
108139 {
109140 Universe_Init ( ) ;
110141 }
111142
112- private bool m_IsHotkeyHandled = false ;
113143 void Update ( )
114144 {
115- if ( UIHotkey . Value . IsDown ( ) && ! m_IsHotkeyHandled )
145+ if ( UIHotkey . Value . IsDown ( ) )
116146 {
117147 ToggleUI ( ) ;
118- m_IsHotkeyHandled = true ;
119148 }
120- else if ( UIHotkey . Value . IsUp ( ) )
149+ }
150+
151+ private void ConfigBindGlobalOverride ( )
152+ {
153+ if ( GlobalOverride_Enabled != null ) return ;
154+
155+ string defaultJson = SerializeGlobalOverride ( ) ;
156+
157+ GlobalOverride_Enabled = Config . Bind ( "GlobalOverride" , "Enabled" , false , "Enable global override of jiggle settings" ) ;
158+ //GlobalOverride_Json = Config.Bind("Global Override", "Json" , defaultJson, "The jiggle settings in JSON format" );
159+ GlobalOverride_Settings = Config . BindJson ( "GlobalOverride" , "Settings" , MaidJiggleOverride . Default , "The settings used for the global override" ) ;
160+
161+ if ( ButtJiggle_ConfigVersion . Value < 1.11 )
121162 {
122- m_IsHotkeyHandled = false ;
163+ GlobalOverride_Settings . Value = MaidJiggleOverride . Default ;
123164 }
165+
166+ JiggleBoneHelper . UseGlobalOverride = GlobalOverride_Enabled . Value ;
167+ JiggleBoneHelper . GlobalOverride = GlobalOverride_Settings . Value ;
168+
169+ GlobalOverride_Enabled . SettingChanged += delegate ( object sender , EventArgs eventArgs )
170+ {
171+ JiggleBoneHelper . UseGlobalOverride = GlobalOverride_Enabled . Value ;
172+ OnGlobalOverrideUpdated . Invoke ( ) ;
173+ } ;
174+ GlobalOverride_Settings . SettingChanged += delegate ( object sender , EventArgs eventArgs )
175+ {
176+ JiggleBoneHelper . GlobalOverride = GlobalOverride_Settings . Value ;
177+ OnGlobalOverrideUpdated . Invoke ( ) ;
178+ } ;
179+ }
180+
181+ public static void ConfigSaveGlobalOverride ( )
182+ {
183+ Logger . LogDebug ( "ConfigSaveGlobalOverride" ) ;
184+ GlobalOverride_Enabled . Value = JiggleBoneHelper . UseGlobalOverride ;
185+ //GlobalOverride_Json .Value = SerializeGlobalOverride();
186+ GlobalOverride_Settings . Value = JiggleBoneHelper . GlobalOverride ;
187+ }
188+
189+ private static string SerializeGlobalOverride ( )
190+ {
191+ JsonSerializer serializer = new JsonSerializer ( ) ;
192+ StringWriter writer = new StringWriter ( ) ;
193+ serializer . Serialize ( writer , JiggleBoneHelper . GlobalOverride ) ;
194+ return writer . ToString ( ) ;
124195 }
125196 }
126197}
0 commit comments