整合SLSUtilities
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
namespace LunaWolfStudiosEditor.ScriptableSheets.Tables
|
||||
{
|
||||
public enum EscapeOption
|
||||
{
|
||||
None = 0,
|
||||
Backslash = 1,
|
||||
Repeat = 2,
|
||||
Custom = 3,
|
||||
}
|
||||
|
||||
public static class EscapeOptionExtensions
|
||||
{
|
||||
public static string GetEscapedWrapper(this EscapeOption escapeOption, char wrapper, string custom)
|
||||
{
|
||||
switch (escapeOption)
|
||||
{
|
||||
case EscapeOption.Backslash:
|
||||
return "\\" + wrapper;
|
||||
|
||||
case EscapeOption.Repeat:
|
||||
return new string(wrapper, 2);
|
||||
|
||||
case EscapeOption.Custom:
|
||||
return custom + wrapper;
|
||||
|
||||
case EscapeOption.None:
|
||||
default:
|
||||
return wrapper.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e8e003a682ff264e8113915ff58c2c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284559
|
||||
packageName: Scriptable Sheets
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Packages/com.lunawolfstudios.scriptablesheets/Editor/Modules/Tables/Settings/EscapeOption.cs
|
||||
uploadId: 823456
|
||||
@@ -0,0 +1,109 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace LunaWolfStudiosEditor.ScriptableSheets.Tables
|
||||
{
|
||||
[System.Serializable]
|
||||
public struct FlatFileFormatSettings
|
||||
{
|
||||
private static readonly Dictionary<WrapOption, Wrapper> s_Wrappers = new Dictionary<WrapOption, Wrapper>()
|
||||
{
|
||||
{ WrapOption.None, null },
|
||||
{ WrapOption.DoubleQuotes, new Wrapper('"') },
|
||||
{ WrapOption.SingleQuotes, new Wrapper('\'') },
|
||||
{ WrapOption.CurlyBraces, new Wrapper('{', '}') },
|
||||
{ WrapOption.SquareBrackets, new Wrapper('[', ']') },
|
||||
{ WrapOption.Parentheses, new Wrapper('(', ')') },
|
||||
{ WrapOption.AngleBrackets, new Wrapper('<', '>') },
|
||||
};
|
||||
|
||||
[SerializeField]
|
||||
private string m_RowDelimiter;
|
||||
public string RowDelimiter { get => m_RowDelimiter; set => m_RowDelimiter = value; }
|
||||
|
||||
[SerializeField]
|
||||
private string m_ColumnDelimiter;
|
||||
public string ColumnDelimiter { get => m_ColumnDelimiter; set => m_ColumnDelimiter = value; }
|
||||
|
||||
[SerializeField]
|
||||
private string[] m_ColumnHeaders;
|
||||
public string[] ColumnHeaders { get => m_ColumnHeaders; set => m_ColumnHeaders = value; }
|
||||
|
||||
[SerializeField]
|
||||
private int m_FirstRowIndex;
|
||||
public int FirstRowIndex { get => m_FirstRowIndex; set => m_FirstRowIndex = value; }
|
||||
|
||||
[SerializeField]
|
||||
private int m_FirstColumnIndex;
|
||||
public int FirstColumnIndex { get => m_FirstColumnIndex; set => m_FirstColumnIndex = value; }
|
||||
|
||||
[SerializeField]
|
||||
private bool m_FirstRowOnly;
|
||||
public bool FirstRowOnly { get => m_FirstRowOnly; set => m_FirstRowOnly = value; }
|
||||
|
||||
[SerializeField]
|
||||
private bool m_FirstColumOnly;
|
||||
public bool FirstColumnOnly { get => m_FirstColumOnly; set => m_FirstColumOnly = value; }
|
||||
|
||||
[SerializeField]
|
||||
private bool m_RemoveEmptyRows;
|
||||
public bool RemoveEmptyRows { get => m_RemoveEmptyRows; set => m_RemoveEmptyRows = value; }
|
||||
|
||||
[SerializeField]
|
||||
private bool m_UseStringEnums;
|
||||
public bool UseStringEnums { get => m_UseStringEnums; set => m_UseStringEnums = value; }
|
||||
|
||||
[SerializeField]
|
||||
private bool m_IgnoreCase;
|
||||
public bool IgnoreCase { get => m_IgnoreCase; set => m_IgnoreCase = value; }
|
||||
|
||||
[SerializeField]
|
||||
private WrapOption m_WrapOption;
|
||||
public WrapOption WrapOption { get => m_WrapOption; set => m_WrapOption = value; }
|
||||
|
||||
[SerializeField]
|
||||
private EscapeOption m_EscapeOption;
|
||||
public EscapeOption EscapeOption { get => m_EscapeOption; set => m_EscapeOption = value; }
|
||||
|
||||
[SerializeField]
|
||||
private string m_CustomEscapeSequence;
|
||||
public string CustomEscapeSequence { get => m_CustomEscapeSequence; set => m_CustomEscapeSequence = value; }
|
||||
|
||||
public bool HasHeaders => ColumnHeaders?.Length > 0;
|
||||
public bool HasWrapping => m_WrapOption != WrapOption.None;
|
||||
|
||||
public void SetStartingIndex(Vector2Int coordinate)
|
||||
{
|
||||
m_FirstRowIndex = coordinate.x;
|
||||
m_FirstColumnIndex = coordinate.y;
|
||||
}
|
||||
|
||||
public Wrapper GetWrapper()
|
||||
{
|
||||
if (s_Wrappers.TryGetValue(m_WrapOption, out Wrapper wrapper))
|
||||
{
|
||||
return wrapper;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Unsupported {nameof(Tables.WrapOption)} {m_WrapOption}.");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetJoinedColumnHeaders(Wrapper wrapper)
|
||||
{
|
||||
var includedColumnHeaders = m_ColumnHeaders.Skip(FirstColumnIndex);
|
||||
if (wrapper == null)
|
||||
{
|
||||
return string.Join(m_ColumnDelimiter, includedColumnHeaders);
|
||||
}
|
||||
else
|
||||
{
|
||||
var wrappedColumnHeaders = includedColumnHeaders.Select(h => wrapper.Wrap(h)).ToArray();
|
||||
return string.Join(m_ColumnDelimiter, wrappedColumnHeaders);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 369d7cd0c5aff9d4eb42dcc6cc7ef3ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284559
|
||||
packageName: Scriptable Sheets
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Packages/com.lunawolfstudios.scriptablesheets/Editor/Modules/Tables/Settings/FlatFileFormatSettings.cs
|
||||
uploadId: 823456
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace LunaWolfStudiosEditor.ScriptableSheets.Tables
|
||||
{
|
||||
public enum JsonSerializationFormat
|
||||
{
|
||||
Flat = 0,
|
||||
Hierarchy = 1,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5d5c6b2ede5b1a7488bddf517a0c57da
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284559
|
||||
packageName: Scriptable Sheets
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Packages/com.lunawolfstudios.scriptablesheets/Editor/Modules/Tables/Settings/JsonSerializationFormat.cs
|
||||
uploadId: 823456
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace LunaWolfStudiosEditor.ScriptableSheets.Tables
|
||||
{
|
||||
public enum WrapOption
|
||||
{
|
||||
None = 0,
|
||||
DoubleQuotes = 1,
|
||||
SingleQuotes = 2,
|
||||
CurlyBraces = 3,
|
||||
SquareBrackets = 4,
|
||||
Parentheses = 5,
|
||||
AngleBrackets = 6,
|
||||
}
|
||||
|
||||
public static class WrapOptionExtensions
|
||||
{
|
||||
private static readonly HashSet<WrapOption> JsonSafeOptions = new HashSet<WrapOption>()
|
||||
{
|
||||
WrapOption.None,
|
||||
WrapOption.SingleQuotes,
|
||||
WrapOption.Parentheses,
|
||||
WrapOption.AngleBrackets,
|
||||
};
|
||||
|
||||
public static bool IsJsonUnsafe(this WrapOption wrapOption)
|
||||
{
|
||||
return !JsonSafeOptions.Contains(wrapOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c482a551e3185b0498e709c5c98019fa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 284559
|
||||
packageName: Scriptable Sheets
|
||||
packageVersion: 1.8.0
|
||||
assetPath: Packages/com.lunawolfstudios.scriptablesheets/Editor/Modules/Tables/Settings/WrapOption.cs
|
||||
uploadId: 823456
|
||||
Reference in New Issue
Block a user