Skip to content

Commit

Permalink
SKCell v0.13.0 Update
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyrim07 committed Oct 10, 2023
1 parent 78868f3 commit 0fcf9b9
Show file tree
Hide file tree
Showing 119 changed files with 6,082 additions and 159 deletions.
8 changes: 8 additions & 0 deletions Assets/SKCell/Attributes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions Assets/SKCell/Attributes/SKFolderAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using UnityEngine;
namespace SKCell
{
/// <summary>
/// Start a folder in the inspector.
/// </summary>
public class SKFolderAttribute : PropertyAttribute
{
public string name;
public bool foldout;
public SKFolderAttribute(string name)
{
this.name = name;
this.foldout = true;
}
}

/// <summary>
/// End the current folder.
/// </summary>
public class SKEndFolderAttribute : PropertyAttribute
{
public SKEndFolderAttribute(){}
}

/// <summary>
/// Make a button in the inspector that executes a function.
/// </summary>
public class SKInspectorButtonAttribute : Attribute
{
public string name;
public bool onTop = true;
public SKInspectorButtonAttribute(string name, bool onTop=true)
{
this.name = name;
this.onTop = onTop;
}
}

/// <summary>
/// Display the field in the inspector only if the specified field matches the value.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)]
public class SKConditionalFieldAttribute : PropertyAttribute
{
public string ConditionalField { get; }
public object ConditionalValue { get; }

public SKConditionalFieldAttribute(string conditionalField, object conditionalValue)
{
ConditionalField = conditionalField;
ConditionalValue = conditionalValue;
}
}

[AttributeUsage(AttributeTargets.Field)]
public class SKResettableAttribute : PropertyAttribute
{
}

/// <summary>
/// Instead of the field name, display the specidied text in the inspector.
/// </summary>
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Class, AllowMultiple = true)]
public class SKInspectorTextAttribute : PropertyAttribute
{
public string Message { get; }

public SKInspectorTextAttribute(string message)
{
Message = message;
}
}
}
11 changes: 11 additions & 0 deletions Assets/SKCell/Attributes/SKFolderAttribute.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions Assets/SKCell/CSV/CSV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public static List<List<string>> Decode(string text)
List<List<string>> result = new List<List<string>>();
List<string> line = new List<string>();
string field = "";
bool isInQuotation = false;//字符串模式
bool isInField = true;//是否在读取Field,用来表示空Field
bool isInQuotation = false;
bool isInField = true;
int i = 0;
while (i < text.Length)
{
Expand All @@ -61,7 +61,7 @@ public static List<List<string>> Decode(string text)
{
if (ch == '"')
{
if (i < text.Length - 1 && text[i + 1] == '"')//重复"只算一个,切不结束字符串模式
if (i < text.Length - 1 && text[i + 1] == '"')
{
field += '"';
i++;
Expand All @@ -73,7 +73,7 @@ public static List<List<string>> Decode(string text)
}
else
{
field += ch;//字符串模式中所有字符都要加入
field += ch;
}
}
else
Expand All @@ -87,7 +87,7 @@ public static List<List<string>> Decode(string text)
break;
case '"':
if (isInField)
isInQuotation = true;//进入字符串模式
isInQuotation = true;
else
field += ch;
break;
Expand All @@ -100,8 +100,8 @@ public static List<List<string>> Decode(string text)
}
result.Add(line);
line = new List<string>();
isInField = true;//下一行首先应该是数据
if (i < text.Length - 1 && text[i + 1] == '\n')//跳过\r\n
isInField = true;
if (i < text.Length - 1 && text[i + 1] == '\n')
i++;
break;
default:
Expand All @@ -112,8 +112,8 @@ public static List<List<string>> Decode(string text)
}
i++;
}
//收尾工作
if (field.Length > 0 || isInField && line.Count > 0)//如果是isInField标记的单元格,则要保证这行有其他数据,否则单独一个空单元格的行是没有意义的

if (field.Length > 0 || isInField && line.Count > 0)
line.Add(field);

if (line.Count > 0)
Expand Down
Loading

0 comments on commit 0fcf9b9

Please sign in to comment.