public static void LoadSafetySettings(int presetNum) { Classes.SettingsPreset toLoadPreset; try { toLoadPreset = Settings.availablePresets.ActualPresets.ElementAt(presetNum - 1); } catch { MelonLoader.MelonLogger.Msg("No saved safety settings could be loaded."); return; } if (!IsPresetValid(toLoadPreset.settingsPresetNum)) { MelonLoader.MelonLogger.Msg("This preset is an empty default. Nothing to load here."); return; } try { FeaturePermissionManager fManager = GameObject.Find("_Application").GetComponent <FeaturePermissionManager>(); foreach (Il2CppSystem.Collections.Generic.KeyValuePair <UserSocialClass, FeaturePermissionSet> rankPerm in fManager.field_Private_Dictionary_2_UserSocialClass_FeaturePermissionSet_0) { FeaturePermissionSet test = rankPerm.Value; foreach (Classes.RankSetting rSetting in toLoadPreset.settingRanks) { if (rSetting.UserRank == rankPerm.Key) { test.field_Public_Boolean_0 = rSetting.UserSettings["SpeakingPermission"]; // Voice test.field_Public_Boolean_1 = rSetting.UserSettings["AvatarPermission"]; // Avatar test.field_Public_Boolean_2 = rSetting.UserSettings["UserIconPermission"]; // UserIcons test.field_Public_Boolean_3 = rSetting.UserSettings["AudioPermission"]; // Audio test.field_Public_Boolean_4 = rSetting.UserSettings["ParticlesLightsPermission"]; // Light&Particles test.field_Public_Boolean_5 = rSetting.UserSettings["ShaderPermission"]; // Shaders test.field_Public_Boolean_6 = rSetting.UserSettings["AnimationPermission"]; // CustomAnimations } } } MelonLoader.MelonLogger.Msg($"Loaded safety preset -> \"{toLoadPreset.settingsPresetName}\" ({toLoadPreset.settingsPresetNum})"); fManager.Method_Public_Void_2(); // Apply Safety Settings / Reload avatars } catch (Exception e) { MelonLoader.MelonLogger.Error(e.StackTrace); } }
public static void SaveSafetySettings(int presetNum, string name) { try { FeaturePermissionManager fManager = GameObject.Find("_Application").GetComponent <FeaturePermissionManager>(); fManager.Method_Public_Void_2(); // Apply current safety settings List <Classes.RankSetting> rankSettingList = new List <Classes.RankSetting> { }; foreach (Il2CppSystem.Collections.Generic.KeyValuePair <UserSocialClass, FeaturePermissionSet> rankPerm in fManager.field_Private_Dictionary_2_UserSocialClass_FeaturePermissionSet_0) { Dictionary <string, bool> tempSettings = new Dictionary <string, bool> { { "SpeakingPermission", rankPerm.Value.field_Public_Boolean_0 }, { "AvatarPermission", rankPerm.Value.field_Public_Boolean_1 }, { "UserIconPermission", rankPerm.Value.field_Public_Boolean_2 }, { "AudioPermission", rankPerm.Value.field_Public_Boolean_3 }, { "ParticlesLightsPermission", rankPerm.Value.field_Public_Boolean_4 }, { "ShaderPermission", rankPerm.Value.field_Public_Boolean_5 }, { "AnimationPermission", rankPerm.Value.field_Public_Boolean_6 } }; Classes.RankSetting tempRankSetting = new Classes.RankSetting(rankPerm.Key, tempSettings); rankSettingList.Add(tempRankSetting); } Classes.SettingsPreset presetTest = new Classes.SettingsPreset(presetNum, name); presetTest.settingRanks = rankSettingList; Settings.availablePresets.ActualPresets[presetNum - 1] = presetTest; Helpers.SaveSafetyJSON(); MelonLoader.MelonLogger.Msg($"Saved safety preset -> \"{name}\" ({presetNum})"); Settings.UpdateSelectablePresets(); } catch (Exception e) { MelonLoader.MelonLogger.Error(e.Message); } }