Esempio n. 1
0
        public override CoolQRouteMessage OnMessageReceived(CoolQScopeEventArgs scope)
        {
            var routeMsg = scope.RouteMessage;

            _routeMsg = routeMsg;
            _identity = (CoolQIdentity)_routeMsg.Identity;
            _plugins  = PluginManager.Current.Plugins.OfType <MessagePlugin>()
                        .Where(k => (k.MiddlewareConfig as BackendConfig)?.CanDisabled == true)
                        .Where(k => k.TargetAuthority != Authority.Root);
            if (!DisabledList.ContainsKey(_identity))
            {
                DisabledList.Add(_identity, new List <Guid>());
            }

            _disabled = DisabledList[_identity];

            if (_routeMsg.CurrentAuthority == Authority.Public && _routeMsg.MessageType == MessageType.Group)
            {
                return(_routeMsg.ToSource(DefaultReply.AdminOnly));
            }
            if (List)
            {
                return(ShowPluginList());
            }
            if (DisabledPlugin != null)
            {
                return(EnablePlugin());
            }
            if (EnabledPlugin != null)
            {
                return(DisablePlugin());
            }

            return(_routeMsg.ToSource(DefaultReply.ParamError));
        }
Esempio n. 2
0
    public void UpdateExpertProfile()
    {
        if (Operation == SetOperation.Expert)
        {
            bool rewrite;
            if (EnabledList != null)
            {
                // Enable mods in both lists.
                int oldCount = DisabledList.Count;
                DisabledList.ExceptWith(EnabledList);
                rewrite = DisabledList.Count != oldCount;

                // Disable mods in neither list (not installed where the profile was made).
                oldCount = DisabledList.Count;
                DisabledList.UnionWith(ModSelectorService.Instance._allExpertMods.Except(EnabledList));
                rewrite |= DisabledList.Count != oldCount;
            }
            else
            {
                rewrite = true;
            }
            if (rewrite)
            {
                Save();
            }
        }
        else if (EnabledList != null)
        {
            EnabledList = null;
            Save();
        }
    }
Esempio n. 3
0
    public EnableFlag GetEnabledFlag(string modObjectName)
    {
        if (DisabledList.Contains(modObjectName))
        {
            return(EnableFlag.Disabled);
        }

        return(EnableFlag.Enabled);
    }
Esempio n. 4
0
    public void DisableAllOfType(ModSelectorService.ModType modType, bool save = true)
    {
        DisabledList = DisabledList.Union(ModSelectorService.Instance.GetModNames(modType)).ToList();
        UpdateProfileSelection();

        if (save)
        {
            Save();
        }
    }
Esempio n. 5
0
    public void EnableAll(bool save = true)
    {
        DisabledList.Clear();
        UpdateProfileSelection();

        if (save)
        {
            Save();
        }
    }
Esempio n. 6
0
    public void DisableAll(bool save = true)
    {
        DisabledList.UnionWith(ModSelectorService.Instance.GetAllModNames());
        ProfileManager.UpdateProfileSelection();

        if (save)
        {
            Save();
        }
    }
Esempio n. 7
0
    public void DisableAllOfType(ModSelectorService.ModType modType, bool save = true)
    {
        string[] modNames = ModSelectorService.Instance.GetModNames(modType).ToArray();
        DisabledList.UnionWith(modNames);
        ProfileManager.UpdateProfileSelection();

        if (save)
        {
            Save();
        }
    }
Esempio n. 8
0
    public void Disable(string modObjectName, bool save = true)
    {
        if (IsEnabled(modObjectName))
        {
            DisabledList.Add(modObjectName);
            UpdateProfileSelection();

            if (save)
            {
                Save();
            }
        }
    }
Esempio n. 9
0
    public void Disable(string modObjectName, bool save = true)
    {
        if (GetEnabledFlag(modObjectName) != EnableFlag.Disabled)
        {
            DisabledList.Add(modObjectName);

            ProfileManager.UpdateProfileSelection();

            if (save)
            {
                Save();
            }
        }
    }
Esempio n. 10
0
    public int GetTotalOfType(ModSelectorService.ModType modType, EnableFlag enableFlag)
    {
        IEnumerable <string> modNames = ModSelectorService.Instance.GetModNames(modType);

        switch (enableFlag)
        {
        case EnableFlag.Disabled:
            return(DisabledList.Intersect(modNames).Count());

        case EnableFlag.Enabled:
            return(modNames.Except(DisabledList).Count());

        default:
            return(modNames.Except(DisabledList).Count());
        }
    }
Esempio n. 11
0
    public void DisableAll(bool save = true)
    {
        DisabledList.Clear();
        UpdateProfileSelection();

        ModSelectorService modSelector = ModSelectorService.Instance;

        DisabledList.AddRange(modSelector.GetModNames(ModSelectorService.ModType.SolvableModule));
        DisabledList.AddRange(modSelector.GetModNames(ModSelectorService.ModType.NeedyModule));
        DisabledList.AddRange(modSelector.GetModNames(ModSelectorService.ModType.Bomb));
        DisabledList.AddRange(modSelector.GetModNames(ModSelectorService.ModType.GameplayRoom));
        DisabledList.AddRange(modSelector.GetModNames(ModSelectorService.ModType.Widget));
        DisabledList.AddRange(modSelector.GetModNames(ModSelectorService.ModType.Service));

        if (save)
        {
            Save();
        }
    }
Esempio n. 12
0
    public void Save()
    {
        try
        {
            EnsureProfileDirectory();

            NewJSON jsonStructure = new NewJSON()
            {
                DisabledList = new List <string>(DisabledList), Operation = Operation
            };

            if (Operation == SetOperation.Expert)
            {
                // Update the EnabledList based on currently installed mods.
                if (EnabledList == null)
                {
                    EnabledList = new HashSet <string>();
                }
                foreach (string name in ModSelectorService.Instance._allExpertMods)
                {
                    if (DisabledList.Contains(name))
                    {
                        EnabledList.Remove(name);
                    }
                    else
                    {
                        EnabledList.Add(name);
                    }
                }
                jsonStructure.EnabledList = new List <string>(EnabledList);
            }

            string jsonOutput = JsonConvert.SerializeObject(jsonStructure, Formatting.Indented);
            File.WriteAllText(FullPath, jsonOutput);
        }
        catch (Exception ex)
        {
            Debug.LogException(ex);
        }
    }
Esempio n. 13
0
 public int GetDisabledTotalOfType(ModSelectorService.ModType modType)
 {
     return(DisabledList.Intersect(ModSelectorService.Instance.GetModNames(modType)).Count());
 }
Esempio n. 14
0
 public bool IsEnabled(string modObjectName)
 {
     return(!DisabledList.Contains(modObjectName));
 }