예제 #1
0
        public static void SaveSafetySettings(int presetNum, string name)
        {
            if (!AreWeUsingCustomSafetySettings())
            {
                return;
            }
            try
            {
                var fManager = GameObject.Find("_Application").GetComponent <FeaturePermissionManager>();
                applySafety.Invoke(FeaturePermissionManager.prop_FeaturePermissionManager_0, new object[] { });
                var rankSettingList = new List <Classes.RankSetting> {
                };
                foreach (var 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 }
                    };

                    var tempRankSetting = new Classes.RankSetting(rankPerm.Key, tempSettings);
                    rankSettingList.Add(tempRankSetting);
                }

                var presetTest = new Classes.SettingsPreset(presetNum, name)
                {
                    settingRanks = rankSettingList
                };
                try
                {
                    Settings.availablePresets.ActualPresets[GetActualPresetFromPresetNum(presetNum)] = presetTest;
                }
                catch
                {
                    Settings.availablePresets.ActualPresets.Add(presetTest);
                }

                Helpers.SaveSafetyJSON();

                MelonLogger.Msg($"Saved safety preset -> \"{name}\" ({presetNum})");

                Settings.UpdateSelectablePresets();
            }
            catch (Exception e)
            {
                MelonLoader.MelonLogger.Error(e.Message);
            }
        }
예제 #2
0
        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);
            }
        }