Esempio n. 1
0
 // Enable or disable the mod inheritance of every mod in mods.
 public void SetMultipleModInheritances(IEnumerable <Mod> mods, bool inherit)
 {
     if (mods.Aggregate(false, (current, mod) => current | FixInheritance(mod.Index, inherit)))
     {
         ModSettingChanged.Invoke(ModSettingChange.MultiInheritance, -1, -1, 0, false);
     }
 }
Esempio n. 2
0
    // Enable or disable the mod inheritance of mod idx.
    public bool SetModInheritance(int idx, bool inherit)
    {
        if (FixInheritance(idx, inherit))
        {
            ModSettingChanged.Invoke(ModSettingChange.Inheritance, idx, inherit ? 0 : 1, 0, false);
            return(true);
        }

        return(false);
    }
Esempio n. 3
0
    // Set the priority of mod idx to newValue if it differs from the current priority.
    // If mod idx is currently inherited, stop the inheritance.
    public bool SetModPriority(int idx, int newValue)
    {
        var oldValue = _settings[idx]?.Priority ?? this[idx].Settings?.Priority ?? 0;

        if (newValue != oldValue)
        {
            var inheritance = FixInheritance(idx, false);
            _settings[idx] !.Priority = newValue;
            ModSettingChanged.Invoke(ModSettingChange.Priority, idx, inheritance ? -1 : oldValue, 0, false);
            return(true);
        }

        return(false);
    }
Esempio n. 4
0
    // Set the enabled state mod idx to newValue if it differs from the current enabled state.
    // If mod idx is currently inherited, stop the inheritance.
    public bool SetModState(int idx, bool newValue)
    {
        var oldValue = _settings[idx]?.Enabled ?? this[idx].Settings?.Enabled ?? false;

        if (newValue != oldValue)
        {
            var inheritance = FixInheritance(idx, false);
            _settings[idx] !.Enabled = newValue;
            ModSettingChanged.Invoke(ModSettingChange.EnableState, idx, inheritance ? -1 : newValue ? 0 : 1, 0, false);
            return(true);
        }

        return(false);
    }
Esempio n. 5
0
    // Set a given setting group settingName of mod idx to newValue if it differs from the current value and fix it if necessary.
    // If mod idx is currently inherited, stop the inheritance.
    public bool SetModSetting(int idx, int groupIdx, uint newValue)
    {
        var settings = _settings[idx] != null ? _settings[idx] !.Settings : this[idx].Settings?.Settings;
        var oldValue = settings?[groupIdx] ?? 0;

        if (oldValue != newValue)
        {
            var inheritance = FixInheritance(idx, false);
            _settings[idx] !.SetValue(Penumbra.ModManager[idx], groupIdx, newValue);
            ModSettingChanged.Invoke(ModSettingChange.Setting, idx, inheritance ? -1 : ( int )oldValue, groupIdx, false);
            return(true);
        }

        return(false);
    }
Esempio n. 6
0
    // Set the enabled state of every mod in mods to the new value.
    // If the mod is currently inherited, stop the inheritance.
    public void SetMultipleModStates(IEnumerable <Mod> mods, bool newValue)
    {
        var changes = false;

        foreach (var mod in mods)
        {
            var oldValue = _settings[mod.Index]?.Enabled;
            if (newValue != oldValue)
            {
                FixInheritance(mod.Index, false);
                _settings[mod.Index] !.Enabled = newValue;
                changes = true;
            }
        }

        if (changes)
        {
            ModSettingChanged.Invoke(ModSettingChange.MultiEnableState, -1, -1, 0, false);
        }
    }