Пример #1
0
        protected override bool Matches(VpdbFlavor fileFlavor, SettingsManager.Lighting setting)
        {
            switch (fileFlavor.Lighting)
            {
            case VpdbFlavor.VpdbLighting.Day:
                return(setting == SettingsManager.Lighting.Day);

            case VpdbFlavor.VpdbLighting.Night:
                return(setting == SettingsManager.Lighting.Night);

            case VpdbFlavor.VpdbLighting.Any:
                return(MustMatchExactly(setting));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #2
0
        protected override bool Matches(VpdbFlavor fileFlavor, SettingsManager.Orientation setting)
        {
            switch (fileFlavor.Orientation)
            {
            case VpdbFlavor.VpdbOrientation.FS:
                return(setting == SettingsManager.Orientation.Portrait);

            case VpdbFlavor.VpdbOrientation.WS:
                return(setting == SettingsManager.Orientation.Landscape);

            case VpdbFlavor.VpdbOrientation.Any:
                return(MustMatchExactly(setting));

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Пример #3
0
 /// <summary>
 /// Computes a weight relative to how the flavor of a given file scores
 /// against the user setting.
 /// </summary>
 /// <remarks>
 /// Note that "universal" files result in "exact" matches (3).
 /// </remarks>
 /// <param name="fileFlavor">Flavor of the file</param>
 /// <param name="setting">Setting to match against</param>
 /// <param name="previousFlavor">If an update, this is the flavor of the previous file</param>
 /// <param name="primarySetting">If fallback, this is the primary setting. WTF C# why can't you accept null for a typed param?</param>
 /// <returns>3 on exact match, 1 if matched by "any" and 0 if no match.</returns>
 private int Weight(VpdbFlavor fileFlavor, TSettingFlavor setting, VpdbFlavor previousFlavor, object primarySetting)
 {
     if (MustMatchExactly(setting))
     {
         return(Matches(fileFlavor, setting) ? 3 : 0);
     }
     if (MustMatchSame(setting))
     {
         if (previousFlavor != null)
         {
             return(Matches(fileFlavor, previousFlavor) ? 3 : 0);
         }
         if (primarySetting != null)
         {
             return(Matches(fileFlavor, (TSettingFlavor)primarySetting) ? 3 : 0);
         }
         return(0);
     }
     if (MustMatchAny(setting))
     {
         return(1);
     }
     throw new ArgumentOutOfRangeException(nameof(setting), setting, null);
 }
Пример #4
0
 protected override bool Matches(VpdbFlavor firstFlavor, VpdbFlavor secondFlavor)
 {
     return(firstFlavor.Lighting == secondFlavor.Lighting);
 }
Пример #5
0
 protected override bool Matches(VpdbFlavor firstFlavor, VpdbFlavor secondFlavor)
 {
     return(firstFlavor.Orientation == secondFlavor.Orientation);
 }
Пример #6
0
 /// <summary>
 /// Checks if two flavors are the same.
 /// </summary>
 /// <param name="firstFlavor">First flavor</param>
 /// <param name="secondFlavor">Second flavpr</param>
 /// <returns></returns>
 protected abstract bool Matches(VpdbFlavor firstFlavor, VpdbFlavor secondFlavor);
Пример #7
0
 /// <summary>
 /// Checks if a given file flavor matches a given setting.
 /// </summary>
 /// <seealso cref="MustMatchExactly"/>
 /// <param name="fileFlavor">Flavor of the file to check</param>
 /// <param name="setting">Setting to check against (only <see cref="MustMatchExactly"/> setting given)</param>
 /// <returns>True if file flavor matches, false otherwise.</returns>
 protected abstract bool Matches(VpdbFlavor fileFlavor, TSettingFlavor setting);