SHA256
forked from ADOFAIEditorForum/ADOFAIRenderer
Add Basic Reworked UI
This commit is contained in:
13 files changed
+218
-406
No files matched your search
@@ -9,7 +9,6 @@ namespace ADOFAIRenderer.Data
|
||||
private struct FieldEntry
|
||||
{
|
||||
public List<DoubleLimit> Limits;
|
||||
public bool Optional;
|
||||
}
|
||||
|
||||
private readonly VisualElement _rootVisualElement;
|
||||
@@ -25,34 +24,22 @@ namespace ADOFAIRenderer.Data
|
||||
/// Multiple limits can be added to the same field — they are all checked in order.
|
||||
/// </summary>
|
||||
/// <param name="fieldName">The name of the DoubleField in the UXML.</param>
|
||||
/// <param name="optional">
|
||||
/// If true, the field is allowed to be empty. Limits are only enforced when a value is present.
|
||||
/// </param>
|
||||
/// <param name="limits">The limits to apply.</param>
|
||||
public DoubleInputValidator AddLimits(string fieldName, bool optional, params DoubleLimit[] limits)
|
||||
public DoubleInputValidator AddLimits(string fieldName, params DoubleLimit[] limits)
|
||||
{
|
||||
if (!_fields.TryGetValue(fieldName, out var entry))
|
||||
{
|
||||
entry = new FieldEntry
|
||||
{
|
||||
Limits = new List<DoubleLimit>(),
|
||||
Optional = optional
|
||||
Limits = new List<DoubleLimit>()
|
||||
};
|
||||
}
|
||||
|
||||
entry.Optional = optional;
|
||||
entry.Limits.AddRange(limits);
|
||||
_fields[fieldName] = entry;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="AddLimits(string, bool, DoubleLimit[])"/>
|
||||
/// <remarks>Shorthand for required (non-optional) fields.</remarks>
|
||||
public DoubleInputValidator AddLimits(string fieldName, params DoubleLimit[] limits)
|
||||
{
|
||||
return AddLimits(fieldName, false, limits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queries all registered fields from the root VisualElement and
|
||||
/// registers value-changed callbacks that rollback invalid values.
|
||||
@@ -73,12 +60,10 @@ namespace ADOFAIRenderer.Data
|
||||
}
|
||||
|
||||
var limits = entry.Limits;
|
||||
var optional = entry.Optional;
|
||||
|
||||
field.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
// Optional fields allow empty input — skip validation when cleared
|
||||
if (optional && string.IsNullOrEmpty(field.text))
|
||||
if (string.IsNullOrEmpty(field.text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,13 +13,16 @@ namespace ADOFAIRenderer.Data
|
||||
/// <typeparam name="T">The enum type to bind.</typeparam>
|
||||
public class EnumDropdownBinder<T> where T : struct, Enum
|
||||
{
|
||||
private readonly DropdownField _dropdown;
|
||||
private readonly DropdownField? _dropdown;
|
||||
private readonly List<T> _values;
|
||||
private Action<T>? _onValueChanged;
|
||||
|
||||
/// <summary>
|
||||
/// The currently selected enum value.
|
||||
/// </summary>
|
||||
public T Value => _values[_dropdown.index >= 0 ? _dropdown.index : 0];
|
||||
public T Value => _dropdown != null && _dropdown.index >= 0 && _dropdown.index < _values.Count
|
||||
? _values[_dropdown.index]
|
||||
: default;
|
||||
|
||||
/// <summary>
|
||||
/// Queries a <see cref="DropdownField"/> by name from the root VisualElement,
|
||||
@@ -30,18 +33,24 @@ namespace ADOFAIRenderer.Data
|
||||
/// <param name="defaultValue">The initial selected value. Defaults to the first enum member.</param>
|
||||
public EnumDropdownBinder(VisualElement rootVisualElement, string fieldName, T? defaultValue = null)
|
||||
{
|
||||
_values = Enum.GetValues(typeof(T)).Cast<T>().ToList();
|
||||
|
||||
_dropdown = rootVisualElement.Q<DropdownField>(fieldName);
|
||||
if (_dropdown == null)
|
||||
{
|
||||
Melon<RenderMod>.Logger.Error(
|
||||
$"DropdownField '{fieldName}'을(를) 찾을 수 없습니다.");
|
||||
_values = new List<T>();
|
||||
return;
|
||||
}
|
||||
|
||||
_values = Enum.GetValues(typeof(T)).Cast<T>().ToList();
|
||||
_dropdown.choices = _values.Select(v => v.ToString()).ToList();
|
||||
|
||||
// Register the callback BEFORE setting index so the initial selection fires it too
|
||||
_dropdown.RegisterValueChangedCallback(_ =>
|
||||
{
|
||||
_onValueChanged?.Invoke(Value);
|
||||
});
|
||||
|
||||
var initial = defaultValue ?? _values[0];
|
||||
_dropdown.index = _values.IndexOf(initial);
|
||||
}
|
||||
@@ -51,10 +60,13 @@ namespace ADOFAIRenderer.Data
|
||||
/// </summary>
|
||||
public void OnValueChanged(Action<T> callback)
|
||||
{
|
||||
_dropdown?.RegisterValueChangedCallback(evt =>
|
||||
_onValueChanged = callback;
|
||||
|
||||
// Fire immediately with current value so the caller gets the initial state
|
||||
if (_dropdown != null)
|
||||
{
|
||||
callback(Value);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ namespace ADOFAIRenderer.Data
|
||||
private struct FieldEntry
|
||||
{
|
||||
public List<IntegerLimit> Limits;
|
||||
public bool Optional;
|
||||
}
|
||||
|
||||
private readonly VisualElement _rootVisualElement;
|
||||
@@ -25,34 +24,22 @@ namespace ADOFAIRenderer.Data
|
||||
/// Multiple limits can be added to the same field — they are all checked in order.
|
||||
/// </summary>
|
||||
/// <param name="fieldName">The name of the IntegerField in the UXML.</param>
|
||||
/// <param name="optional">
|
||||
/// If true, the field is allowed to be empty. Limits are only enforced when a value is present.
|
||||
/// </param>
|
||||
/// <param name="limits">The limits to apply.</param>
|
||||
public IntegerInputValidator AddLimits(string fieldName, bool optional, params IntegerLimit[] limits)
|
||||
public IntegerInputValidator AddLimits(string fieldName, params IntegerLimit[] limits)
|
||||
{
|
||||
if (!_fields.TryGetValue(fieldName, out var entry))
|
||||
{
|
||||
entry = new FieldEntry
|
||||
{
|
||||
Limits = new List<IntegerLimit>(),
|
||||
Optional = optional
|
||||
Limits = new List<IntegerLimit>()
|
||||
};
|
||||
}
|
||||
|
||||
entry.Optional = optional;
|
||||
entry.Limits.AddRange(limits);
|
||||
_fields[fieldName] = entry;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="AddLimits(string, bool, IntegerLimit[])"/>
|
||||
/// <remarks>Shorthand for required (non-optional) fields.</remarks>
|
||||
public IntegerInputValidator AddLimits(string fieldName, params IntegerLimit[] limits)
|
||||
{
|
||||
return AddLimits(fieldName, false, limits);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queries all registered fields from the root VisualElement and
|
||||
/// registers value-changed callbacks that rollback invalid values.
|
||||
@@ -73,12 +60,10 @@ namespace ADOFAIRenderer.Data
|
||||
}
|
||||
|
||||
var limits = entry.Limits;
|
||||
var optional = entry.Optional;
|
||||
|
||||
field.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
// Optional fields allow empty input — skip validation when cleared
|
||||
if (optional && string.IsNullOrEmpty(field.text))
|
||||
if (string.IsNullOrEmpty(field.text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
+25
-1
@@ -1,7 +1,31 @@
|
||||
namespace ADOFAIRenderer.Configuration
|
||||
using ADOFAIRenderer.Util.FFmpeg;
|
||||
|
||||
namespace ADOFAIRenderer.Data
|
||||
{
|
||||
public class RenderConfig
|
||||
{
|
||||
public double RenderFPS;
|
||||
public double VideoFPS;
|
||||
|
||||
public int RenderWidth;
|
||||
public int RenderHeight;
|
||||
|
||||
public Codec Codec;
|
||||
public EncodingConfig? EncodingConfig = null;
|
||||
|
||||
public double DelayAfterLevelEnd;
|
||||
public bool ShowJudgementText;
|
||||
|
||||
public int? RandomSeed = null;
|
||||
public bool ProcessAudio;
|
||||
}
|
||||
|
||||
public class EncodingConfig
|
||||
{
|
||||
public RateControlMode RateControlMode;
|
||||
|
||||
public int Bitrate;
|
||||
public int MaxBitrate;
|
||||
public int QP;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user