Add portrait settings support to school creation and update related API and UI components. Enhance error handling for invalid presets and ensure proper cloning of settings. Update tests to validate new functionality.
This commit is contained in:
@@ -233,6 +233,33 @@ internal sealed class SwarmUiConfigFile
|
||||
Presets = [SwarmUiPresetDefinition.CreateDefault(), SwarmUiPresetDefinition.CreateChild()],
|
||||
AgeRules = [new SwarmUiAgeRule { MinAge = 6, MaxAge = 11, PresetId = "child" }],
|
||||
};
|
||||
|
||||
public static SwarmUiConfigFile Clone(SwarmUiConfigFile source)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(source, CloneJson);
|
||||
var copy = JsonSerializer.Deserialize<SwarmUiConfigFile>(json, CloneJson) ?? CreateDefault();
|
||||
copy.Model = null;
|
||||
copy.Steps = null;
|
||||
copy.CfgScale = null;
|
||||
copy.ClipSkip = null;
|
||||
copy.Sampler = null;
|
||||
copy.Scheduler = null;
|
||||
copy.Seed = null;
|
||||
copy.Positive = null;
|
||||
copy.Negative = null;
|
||||
copy.Avatar = null;
|
||||
copy.Custom = null;
|
||||
copy.FullBody = null;
|
||||
copy.NormalizeAfterLoad();
|
||||
return copy;
|
||||
}
|
||||
|
||||
private static readonly JsonSerializerOptions CloneJson = new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||
PropertyNameCaseInsensitive = true,
|
||||
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
||||
};
|
||||
}
|
||||
|
||||
internal sealed class SwarmUiPresetDefinition
|
||||
|
||||
Reference in New Issue
Block a user