--check/--colorの擬似展開を廃止しUI値を唯一のソースに変更
このコミットが含まれているのは:
1ファイル変更
-80
@@ -10,8 +10,6 @@ namespace LuaScript.Compat
|
||||
{
|
||||
None,
|
||||
Dialog,
|
||||
Color,
|
||||
Check,
|
||||
Param,
|
||||
}
|
||||
|
||||
@@ -90,12 +88,6 @@ namespace LuaScript.Compat
|
||||
case DirectiveKind.Dialog:
|
||||
AppendDialog(content, prelude);
|
||||
break;
|
||||
case DirectiveKind.Color:
|
||||
AppendColor(content, prelude);
|
||||
break;
|
||||
case DirectiveKind.Check:
|
||||
AppendCheck(name, content, prelude);
|
||||
break;
|
||||
case DirectiveKind.Param:
|
||||
AppendParam(content, prelude);
|
||||
break;
|
||||
@@ -106,12 +98,8 @@ namespace LuaScript.Compat
|
||||
{
|
||||
if (name.Equals("dialog", StringComparison.OrdinalIgnoreCase))
|
||||
return DirectiveKind.Dialog;
|
||||
if (name.Equals("color", StringComparison.OrdinalIgnoreCase))
|
||||
return DirectiveKind.Color;
|
||||
if (name.Equals("param", StringComparison.OrdinalIgnoreCase))
|
||||
return DirectiveKind.Param;
|
||||
if (name.Length > 5 && name.StartsWith("check", StringComparison.OrdinalIgnoreCase) && AllDigits(name, 5))
|
||||
return DirectiveKind.Check;
|
||||
return DirectiveKind.None;
|
||||
}
|
||||
|
||||
@@ -131,22 +119,6 @@ namespace LuaScript.Compat
|
||||
}
|
||||
}
|
||||
|
||||
private static void AppendColor(string content, List<string> prelude)
|
||||
{
|
||||
string token = FirstToken(content);
|
||||
if (IsColorLiteral(token))
|
||||
prelude.Add("local color = " + token);
|
||||
}
|
||||
|
||||
private static void AppendCheck(string name, string content, List<string> prelude)
|
||||
{
|
||||
string index = name.Substring(5);
|
||||
var parts = content.Split(',');
|
||||
string def = parts[parts.Length - 1].Trim();
|
||||
if (IsIntegerLiteral(def))
|
||||
prelude.Add("obj.check" + index + " = " + def);
|
||||
}
|
||||
|
||||
private static void AppendParam(string content, List<string> prelude)
|
||||
{
|
||||
string trimmed = content.Trim();
|
||||
@@ -154,55 +126,6 @@ namespace LuaScript.Compat
|
||||
prelude.Add(trimmed);
|
||||
}
|
||||
|
||||
private static string FirstToken(string content)
|
||||
{
|
||||
int start = SkipSpaces(content, 0);
|
||||
int i = start;
|
||||
while (i < content.Length && content[i] != ',' && content[i] != ' ' && content[i] != '\t')
|
||||
i++;
|
||||
return content.Substring(start, i - start);
|
||||
}
|
||||
|
||||
private static bool IsColorLiteral(string token)
|
||||
{
|
||||
if (token.Length == 0)
|
||||
return false;
|
||||
if (token.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
if (token.Length <= 2)
|
||||
return false;
|
||||
for (int k = 2; k < token.Length; k++)
|
||||
if (!IsHexDigit(token[k]))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
foreach (char c in token)
|
||||
if (c < '0' || c > '9')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool IsIntegerLiteral(string token)
|
||||
{
|
||||
if (token.Length == 0)
|
||||
return false;
|
||||
int start = token[0] == '-' || token[0] == '+' ? 1 : 0;
|
||||
if (start >= token.Length)
|
||||
return false;
|
||||
for (int i = start; i < token.Length; i++)
|
||||
if (token[i] < '0' || token[i] > '9')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static bool AllDigits(string text, int start)
|
||||
{
|
||||
for (int i = start; i < text.Length; i++)
|
||||
if (text[i] < '0' || text[i] > '9')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private static int SkipSpaces(string text, int index)
|
||||
{
|
||||
while (index < text.Length && (text[index] == ' ' || text[index] == '\t'))
|
||||
@@ -212,8 +135,5 @@ namespace LuaScript.Compat
|
||||
|
||||
private static bool IsNameChar(char c) =>
|
||||
(c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9');
|
||||
|
||||
private static bool IsHexDigit(char c) =>
|
||||
(c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする