Repository URL to install this package:
Version:
1.3.1 ▾
|
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using UnityEditor.AnimatedValues;
namespace Fluctio.FluctioSim.EditorUtils.SettingsManagement.Table
{
[SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
[SuppressMessage("ReSharper", "UnusedMember.Global")]
[SuppressMessage("ReSharper", "UnusedMethodReturnValue.Global")]
public record TableDefinition<TLabel, TInfo>(
bool IsFoldout,
string Title,
Dictionary<string, TableRowDefinition<TLabel, TInfo>> Rows,
Action DrawHeader,
Action<TLabel, TInfo, string> DrawRow,
bool DoesFoldoutStartOpen = true)
{
public TableValues<TInfo> GetDefaults()
{
var defaultValues = new TableValues<TInfo>();
foreach (var (rowKey, rowDefinition) in Rows)
{
defaultValues.Dictionary[rowKey] = rowDefinition.DefaultInfo;
}
defaultValues.foldoutState = new AnimBool(DoesFoldoutStartOpen);
return defaultValues;
}
}
public record TableRowDefinition<TLabel, TInfo>(TLabel Label, TInfo DefaultInfo);
}