Added different tabbing options for VKV key and value seperation.
This commit is contained in:
parent
7c96f30d1b
commit
13c9adf781
@ -14,3 +14,4 @@ global using System.Threading;
|
||||
global using Valve;
|
||||
global using Valve.Miscellaneous;
|
||||
global using Valve.Vkv;
|
||||
global using Valve.Vkv.ObjectModels;
|
||||
|
||||
8
SrcMod/Valve.NET/Vkv/SpacingMode.cs
Normal file
8
SrcMod/Valve.NET/Vkv/SpacingMode.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Valve.Vkv;
|
||||
|
||||
public enum SpacingMode
|
||||
{
|
||||
SingleSpace = 0,
|
||||
IndentSizeSpacing,
|
||||
DoubleTab,
|
||||
}
|
||||
@ -289,7 +289,20 @@ public static class VkvConvert
|
||||
|
||||
writer.Write(new string(' ', indentLevel));
|
||||
writer.Write(SerializeString(name, options));
|
||||
writer.Write(' ');
|
||||
|
||||
switch (options.spacing)
|
||||
{
|
||||
case SpacingMode.SingleSpace: writer.Write(' ');
|
||||
break;
|
||||
|
||||
case SpacingMode.IndentSizeSpacing: writer.Write(new string(' ', options.indentSize));
|
||||
break;
|
||||
|
||||
case SpacingMode.DoubleTab: writer.Write("\t\t");
|
||||
break;
|
||||
|
||||
default: throw new VkvSerializationException($"Unknown spacing mode \"{options.spacing}\".");
|
||||
}
|
||||
|
||||
serializedValue = SerializeString(serializedValue, options);
|
||||
writer.WriteLine(serializedValue);
|
||||
@ -325,7 +338,6 @@ public static class VkvConvert
|
||||
if (options.useQuotes) content = $"\"{content}\"";
|
||||
return content;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ToNodeTree
|
||||
|
||||
@ -8,6 +8,7 @@ public record class VkvOptions
|
||||
public int indentSize;
|
||||
public bool resetStreamPosition;
|
||||
public bool serializeProperties;
|
||||
public SpacingMode spacing;
|
||||
public bool useEscapeCodes;
|
||||
public bool useQuotes;
|
||||
|
||||
@ -17,6 +18,7 @@ public record class VkvOptions
|
||||
indentSize = 4;
|
||||
resetStreamPosition = false;
|
||||
serializeProperties = true;
|
||||
spacing = SpacingMode.DoubleTab;
|
||||
useEscapeCodes = false;
|
||||
useQuotes = false;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user