first commit
This commit is contained in:
commit
761b95080f
404 files changed
+312608
No files matched your search
@@ -0,0 +1,41 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace anjianjingling.Lua
|
||||
{
|
||||
/// <summary>任务列表中的一个脚本任务。</summary>
|
||||
public sealed class LuaTask
|
||||
{
|
||||
public string Name { get; set; } = "新任务";
|
||||
public bool Enabled { get; set; } = true;
|
||||
|
||||
/// <summary>true=无限循环(会阻塞后续任务,需手动停止)。</summary>
|
||||
public bool Infinite { get; set; } = false;
|
||||
|
||||
public int LoopCount { get; set; } = 1;
|
||||
public int IntervalMs { get; set; } = 1000;
|
||||
public string Script { get; set; } = "";
|
||||
|
||||
/// <summary>积木画布 JSON(有内容时优先于脚本)。</summary>
|
||||
public string Blocks { get; set; } = "";
|
||||
|
||||
/// <summary>启动热键(如 F8),空表示不绑定。</summary>
|
||||
public string Hotkey { get; set; } = "";
|
||||
|
||||
public string Source { get; set; } = "";
|
||||
|
||||
public string ModeText => Infinite ? "无限循环" : $"{LoopCount} 次";
|
||||
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
|
||||
/// <summary>任务列表 JSON 读写(.ajt)。</summary>
|
||||
public static class LuaTaskFile
|
||||
{
|
||||
private static readonly JsonSerializerOptions Opt = new() { WriteIndented = true };
|
||||
|
||||
public static string ToJson(IEnumerable<LuaTask> tasks) => JsonSerializer.Serialize(tasks, Opt);
|
||||
|
||||
public static List<LuaTask> FromJson(string json)
|
||||
=> JsonSerializer.Deserialize<List<LuaTask>>(json) ?? new();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user