SHA256
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user