restrict ZwinderStateManagerSettings to reasonable values
This commit is contained in:
parent
6de742b01b
commit
a421a60a20
|
@ -0,0 +1,59 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
/// <summary>
|
||||
/// Used in conjunction with the <see cref="RangeAttribute" /> will perform range validation against an int value using PropertyGrid
|
||||
/// </summary>
|
||||
public class IntConverter : TypeConverter
|
||||
{
|
||||
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
|
||||
{
|
||||
return ((sourceType == typeof(string)) || base.CanConvertFrom(context, sourceType));
|
||||
}
|
||||
|
||||
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
|
||||
{
|
||||
var range = context.Instance
|
||||
.GetType()
|
||||
.GetProperty(context.PropertyDescriptor.Name)
|
||||
.GetCustomAttributes()
|
||||
.FirstOrDefault(i => i.GetType() == typeof(RangeAttribute)) as RangeAttribute;
|
||||
|
||||
range.Validate(value, context.PropertyDescriptor.Name);
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
throw new FormatException($"{context.PropertyDescriptor.Name} can not be null");
|
||||
}
|
||||
|
||||
if (int.TryParse(value.ToString(), out int intVal))
|
||||
{
|
||||
return intVal;
|
||||
}
|
||||
|
||||
throw new FormatException($"Invalid value: {value}, {context.PropertyDescriptor.Name} must be an integer.");
|
||||
}
|
||||
|
||||
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
|
||||
{
|
||||
if (destinationType == null)
|
||||
{
|
||||
throw new ArgumentNullException("destinationType");
|
||||
}
|
||||
|
||||
if (destinationType == typeof(string))
|
||||
{
|
||||
int num = Convert.ToInt32(value);
|
||||
return num.ToString();
|
||||
}
|
||||
|
||||
return base.ConvertTo(context, culture, value, destinationType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace BizHawk.Client.Common
|
||||
{
|
||||
|
@ -32,10 +33,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
[DisplayName("Current - Buffer Size")]
|
||||
[Description("Max amount of buffer space to use in MB. \n\nThe Current buffer is the primary buffer used near the last edited frame. This should be the largest buffer to ensure minimal gaps during editing.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(64, 32768)]
|
||||
public int CurrentBufferSize { get; set; } = 256;
|
||||
|
||||
[DisplayName("Current - Target Frame Length")]
|
||||
[Description("Desired frame length (number of emulated frames you can go back before running out of buffer) \n\nThe Current buffer is the primary buffer used near the last edited frame. This should be the largest buffer to ensure minimal gaps during editing.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(1, int.MaxValue)]
|
||||
public int CurrentTargetFrameLength { get; set; } = 500;
|
||||
|
||||
/// <summary>
|
||||
|
@ -47,10 +50,12 @@ namespace BizHawk.Client.Common
|
|||
|
||||
[DisplayName("Recent - Buffer Size")]
|
||||
[Description("Max amount of buffer space to use in MB.\n\nThe Recent buffer is the where current frames decay too as the buffer fills up. The goal of this buffer is maximize the amount of movie that can be fairly quickly navigated to. Therefore, a high target frame length is ideal here.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(64, 32768)]
|
||||
public int RecentBufferSize { get; set; } = 128;
|
||||
|
||||
[DisplayName("Recent - Target Frame Length")]
|
||||
[Description("Desired frame length (number of emulated frames you can go back before running out of buffer). The Recent buffer is the where current frames decay too as the buffer fills up. The goal of this buffer is maximize the amount of movie that can be fairly quickly navigated to. Therefore, a high target frame length is ideal here.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(1, int.MaxValue)]
|
||||
public int RecentTargetFrameLength { get; set; } = 2000;
|
||||
|
||||
/// <summary>
|
||||
|
@ -62,14 +67,17 @@ namespace BizHawk.Client.Common
|
|||
|
||||
[DisplayName("Gaps - Buffer Size")]
|
||||
[Description("Max amount of buffer space to use in MB\n\nThe Gap buffer is used for temporary storage when replaying older segment of the run without editing. It is used to 're-greenzone' large gaps while navigating around in an older area of the movie. This buffer can be small, and a similar size to target frame length ratio as current is ideal.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(64, 32768)]
|
||||
public int GapsBufferSize { get; set; } = 64;
|
||||
|
||||
[DisplayName("Gaps - Target Frame Length")]
|
||||
[Description("Desired frame length (number of emulated frames you can go back before running out of buffer)\n\nThe Gap buffer is used for temporary storage when replaying older segment of the run without editing. It is used to 're-greenzone' large gaps while navigating around in an older area of the movie. This buffer can be small, and a similar size to target frame length ratio as current is ideal.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(1, int.MaxValue)]
|
||||
public int GapsTargetFrameLength { get; set; } = 125;
|
||||
|
||||
[DisplayName("Ancient State Interval")]
|
||||
[Description("Once both the Current and Recent buffers have filled, some states are put into reserved to ensure there is always a state somewhat near a desired frame to navigate to. These states never decay but are invalidated. This number should be as high as possible without being overly cumbersome to replay this many frames.")]
|
||||
[TypeConverter(typeof(IntConverter)), Range(1, int.MaxValue)]
|
||||
public int AncientStateInterval { get; set; } = 5000;
|
||||
|
||||
// Just to simplify some other code.
|
||||
|
|
Loading…
Reference in New Issue