コード例 #1
0
ファイル: template.cs プロジェクト: p-mcgowan/se-scripts
    public void Render(DrawingSurface ds, string name = null)
    {
        string      dsName   = name ?? ds.name;
        List <Node> nodeList = null;

        if (!this.renderNodes.TryGetValue(dsName, out nodeList))
        {
            ds.Text("No template found").Draw();
            return;
        }

        DsCallback callback = null;
        int        i        = 0;

        this.removeNodes.Clear();
        foreach (Node node in nodeList)
        {
            if (node.action == "newline")
            {
                ds.Newline();
                continue;
            }

            if (node.action == "text")
            {
                ds.AddTextSprite((MySprite)node.sprite);
                continue;
            }

            if (node.action == "config")
            {
                this.ConfigureScreen(ds, node.options);
                removeNodes.Add(i);
                continue;
            }

            if (this.methods.TryGetValue(node.action, out callback))
            {
                callback(ds, node.text, node.options);
            }
            else
            {
                ds.Text($"{{{node.action}}}");
            }
            i++;
        }
        ds.Draw();

        foreach (int removeNode in removeNodes)
        {
            nodeList.RemoveAt(removeNode);
        }
    }
コード例 #2
0
ファイル: template.cs プロジェクト: p-mcgowan/se-scripts
 public void Register(string key, DsCallback callback)
 {
     this.methods[key] = callback;
 }