Пример #1
0
        private static string FilterName(GUIModFilter filter, ModuleTag tag = null, ModuleLabel label = null)
        {
            switch (filter)
            {
            case GUIModFilter.Compatible:               return(Properties.Resources.MainFilterCompatible);

            case GUIModFilter.Incompatible:             return(Properties.Resources.MainFilterIncompatible);

            case GUIModFilter.Installed:                return(Properties.Resources.MainFilterInstalled);

            case GUIModFilter.NotInstalled:             return(Properties.Resources.MainFilterNotInstalled);

            case GUIModFilter.InstalledUpdateAvailable: return(Properties.Resources.MainFilterUpgradeable);

            case GUIModFilter.Replaceable:              return(Properties.Resources.MainFilterReplaceable);

            case GUIModFilter.Cached:                   return(Properties.Resources.MainFilterCached);

            case GUIModFilter.Uncached:                 return(Properties.Resources.MainFilterUncached);

            case GUIModFilter.NewInRepository:          return(Properties.Resources.MainFilterNew);

            case GUIModFilter.All:                      return(Properties.Resources.MainFilterAll);

            case GUIModFilter.CustomLabel:              return(string.Format(Properties.Resources.MainFilterLabel, label?.Name ?? "CUSTOM"));

            case GUIModFilter.Tag:
                return(tag == null
                        ? Properties.Resources.MainFilterUntagged
                        : string.Format(Properties.Resources.MainFilterTag, tag.Name));
            }
            return("");
        }
Пример #2
0
        private bool IsModInFilter(GUIModFilter filter, ModuleTag tag, ModuleLabel label, GUIMod m)
        {
            switch (filter)
            {
            case GUIModFilter.Compatible:               return(!m.IsIncompatible);

            case GUIModFilter.Installed:                return(m.IsInstalled);

            case GUIModFilter.InstalledUpdateAvailable: return(m.IsInstalled && m.HasUpdate);

            case GUIModFilter.Cached:                   return(m.IsCached);

            case GUIModFilter.Uncached:                 return(!m.IsCached);

            case GUIModFilter.NewInRepository:          return(m.IsNew);

            case GUIModFilter.NotInstalled:             return(!m.IsInstalled);

            case GUIModFilter.Incompatible:             return(m.IsIncompatible);

            case GUIModFilter.Replaceable:              return(m.IsInstalled && m.HasReplacement);

            case GUIModFilter.All:                      return(true);

            case GUIModFilter.Tag:                      return(tag?.ModuleIdentifiers.Contains(m.Identifier)
                                                               ?? ModuleTags.Untagged.Contains(m.Identifier));

            case GUIModFilter.CustomLabel:              return(label?.ModuleIdentifiers?.Contains(m.Identifier) ?? false);

            default:                                    throw new Kraken(string.Format(Properties.Resources.MainModListUnknownFilter, filter));
            }
        }
Пример #3
0
 public static SavedSearch FilterToSavedSearch(GUIModFilter filter, ModuleTag tag = null, ModuleLabel label = null)
 {
     return(new SavedSearch()
     {
         Name = FilterName(filter, tag, label),
         Values = new List <string>()
         {
             new ModSearch(filter, tag, label).Combined
         },
     });
 }
Пример #4
0
 private bool HiddenByTagsOrLabels(GUIModFilter filter, ModuleTag tag, ModuleLabel label, GUIMod m, string instanceName)
 {
     if (filter != GUIModFilter.CustomLabel)
     {
         // "Hide" labels apply to all non-custom filters
         if (ModuleLabels?.LabelsFor(instanceName)
             .Where(l => l != label && l.Hide)
             .Any(l => l.ModuleIdentifiers.Contains(m.Identifier))
             ?? false)
         {
             return(true);
         }
         if (ModuleTags?.Tags?.Values
             .Where(t => t != tag && t.Visible == false)
             .Any(t => t.ModuleIdentifiers.Contains(m.Identifier))
             ?? false)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #5
0
        public void BuildTagIndexFor(AvailableModule am)
        {
            bool tagged = false;

            foreach (CkanModule m in am.AllAvailable())
            {
                if (m.Tags != null)
                {
                    tagged = true;
                    foreach (string tagName in m.Tags)
                    {
                        ModuleTag tag = null;
                        if (Tags.TryGetValue(tagName, out tag))
                        {
                            tag.Add(m.identifier);
                        }
                        else
                        {
                            Tags.Add(tagName, new ModuleTag()
                            {
                                Name              = tagName,
                                Visible           = !HiddenTags.Contains(tagName),
                                ModuleIdentifiers = new HashSet <string>()
                                {
                                    m.identifier
                                },
                            });
                        }
                    }
                }
            }
            if (!tagged)
            {
                Untagged.Add(am.AllAvailable().First().identifier);
            }
        }
Пример #6
0
        public ModSearch(GUIModFilter filter, ModuleTag tag = null, ModuleLabel label = null)
        {
            switch (filter)
            {
            case GUIModFilter.Compatible:               Compatible = true;  break;

            case GUIModFilter.Incompatible:             Compatible = false; break;

            case GUIModFilter.Installed:                Installed = true;  break;

            case GUIModFilter.NotInstalled:             Installed = false; break;

            case GUIModFilter.InstalledUpdateAvailable: Upgradeable = true;  break;

            case GUIModFilter.Replaceable:              Replaceable = true;  break;

            case GUIModFilter.Cached:                   Cached = true;  break;

            case GUIModFilter.Uncached:                 Cached = false; break;

            case GUIModFilter.NewInRepository:          NewlyCompatible = true;  break;

            case GUIModFilter.Tag:                      TagNames.Add(tag?.Name); break;

            case GUIModFilter.CustomLabel:
                if (label != null)
                {
                    Labels.Add(label);
                }
                break;

            default:
            case GUIModFilter.All:                                               break;
            }
            Combined = getCombined();
        }
Пример #7
0
 private bool TagInSearches(ModuleTag tag)
 {
     return(activeSearches?.Any(s => s?.TagNames.Contains(tag.Name) ?? false) ?? false);
 }