35 lines
1.3 KiB
C#
35 lines
1.3 KiB
C#
namespace TuneBoss.Core.Models;
|
|
|
|
/// <summary>How a sub-field of a settings byte is edited.</summary>
|
|
public enum MiscEditorKind
|
|
{
|
|
Flag, // single bit → checkbox
|
|
Enum, // bit range → combo (Options indexed by value)
|
|
Number, // bit range → numeric 0..(mask>>shift)
|
|
}
|
|
|
|
/// <summary>
|
|
/// One sub-field occupying a contiguous bit range of a byte.
|
|
/// Value = (byte & Mask) >> shift(Mask); written back masked.
|
|
/// </summary>
|
|
public sealed record MiscBitField(
|
|
string Label,
|
|
int Mask, // e.g. 0x01 (flag), 0xF0 (high nibble), 0x7F (7-bit value)
|
|
MiscEditorKind Kind = MiscEditorKind.Flag,
|
|
string[]? Options = null) // Enum only: option labels indexed by value
|
|
{
|
|
/// <summary>Human-readable label: underscores → spaces, shortforms expanded.</summary>
|
|
public string DisplayText => MiscDisplayText.For(Label);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Decomposition of a single settings byte into bit sub-fields, plus optional
|
|
/// inter-bit constraints (bit indices 0..7).
|
|
/// </summary>
|
|
public sealed record MiscByteSpec(
|
|
MiscBlock Block,
|
|
string FieldLabel, // must match a MiscField.Label in MiscFieldRegistry
|
|
MiscBitField[] Fields,
|
|
(int A, int B)[]? MutualExclusive = null, // checking one clears the other
|
|
(int A, int B)[]? Linked = null); // toggling one toggles the other
|