Esempio n. 1
0
        public string ScriptContent(RuntimeScript script, KeyObject obj)
        {
            var ac = AppCommands.ToAppCommnad(script?.Data);
            var r  = AppCommands.GetResource();

            return(string.Format(AppCommands.AppCommandContextLocalizing(r), ac.HasValue ?
                                 AppCommands.APPCOMMANDToString(ac.Value, r) : "unknown"));
        }
        public RuntimeContext GetContext()
        {
            var runnable = GetRunnableWithMainFor(GetDeclareXInstructions());

            var script = new RuntimeScript(runnable);

               return new RuntimeContext(script);
        }
    void OnGUI()
    {
        if (Application.isPlaying == false)
        {
            Close();
            return;
        }

        if (webView.Hook(this))
        {
            webView.LoadURL("file:///" + Application.dataPath + "/UniScript/Scripts/Editor/Debugger/www/index.html");
            timer = 0.525f;
        }

        webView.OnGUI(new Rect(Vector2.zero, new Vector2(490, 200)));

        var e = Event.current;

        EditorGUILayout.BeginVertical();
        GUILayout.Space(205);
        eval = EditorGUILayout.TextField("REPL", eval);
        if (e.keyCode == KeyCode.Return)
        {
            evalResult = RuntimeScript.Eval(eval);
        }
        EditorGUILayout.LabelField(evalResult);

        EditorGUILayout.BeginHorizontal();
        GUILayout.Space(20);

        EditorGUILayout.BeginVertical();
        EditorGUILayout.LabelField("Locals", EditorStyles.boldLabel);
        EditorGUI.indentLevel++;
        foreach (var local in RuntimeScript.dump.locals)
        {
            EditorGUILayout.TextField(local.Key, local.Value.ToString());
        }
        EditorGUI.indentLevel--;
        EditorGUILayout.EndVertical();

        GUILayout.Space(40);

        EditorGUILayout.BeginVertical();
        callstackScroll = EditorGUILayout.BeginScrollView(callstackScroll, true, false);
        EditorGUILayout.LabelField("Callstack", EditorStyles.boldLabel);
        foreach (var callFrame in RuntimeScript.dump.callStack.Reverse())
        {
            EditorGUI.indentLevel++;
            EditorGUILayout.LabelField(callFrame.signature);
        }
        EditorGUI.indentLevel = 0;
        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
        EditorGUILayout.EndFadeGroup();

        EditorGUILayout.EndVertical();
    }
 public bool ShowDialog(RuntimeScript runtimeScript, KeyObject obj)
 {
     using (var acd = new AppCommandDialog())
         if (acd.ShowDialog() == DialogResult.OK && acd.SelectedCommand != null)
         {
             runtimeScript.RuntimeName = AppCommandRuntime.AppCommandRuntimeName;
             runtimeScript.Data        = acd.SelectedCommand.GetData();
             return(true);
         }
     return(false);
 }
Esempio n. 5
0
        public VirtualInputDialog(RuntimeScript runtimeScript, KeyObject obj)
        {
            RuntimeScript = runtimeScript;
            KeyObject     = obj;

            InitializeComponent();
            InitializeForm();
            InitializeComboBox();
            InitializeSetting();

            btnOk.DialogResult = DialogResult.None;
        }
Esempio n. 6
0
 public void MenuClicking(IScriptEditor scriptEditor,
                          NUMC.Design.Controls.TreeNode node, RuntimeScript runtimeScript, KeyObject obj)
 {
     _scriptEditor  = scriptEditor;
     _runtimeScript = runtimeScript;
     _keyObject     = obj;
     if (_editMenu != null)
     {
         _editMenu.Visible = _editMenu.Enabled = runtimeScript != null &&
                                                 AppCommandRuntime.AppCommandRuntimeName == runtimeScript.RuntimeName;
     }
 }
Esempio n. 7
0
 public void MenuClicking(IScriptEditor scriptEditor,
                          Design.Controls.TreeNode node, RuntimeScript runtimeScript, KeyObject obj)
 {
     ScriptEditor  = scriptEditor;
     RuntimeScript = runtimeScript;
     KeyObject     = obj;
     if (AddMenu != null && EditMenu != null)
     {
         EditMenu.Visible = runtimeScript != null &&
                            VirtualInputRuntime.RuntimeNames.Contains(runtimeScript.RuntimeName);
     }
 }
Esempio n. 8
0
        public void Run(ScriptInfo scriptInfo, RuntimeScript runtimeScript, bool isDown)
        {
            if (runtimeScript == null || InputSimulator == null)
            {
                return;
            }
            try {
                if (isDown)
                {
                    switch (runtimeScript.RuntimeName)
                    {
                    case "NUMC.VirtualKey": {
                        var a = ConvertKeys(runtimeScript.Data);

                        for (int l = 0; l < a.Count; l++)
                        {
                            InputSimulator.Keyboard.KeyDown(a[l]);
                        }
                    } break;

                    case "NUMC.VirtualSendKeys": {
                        var a = ConvertKeys(runtimeScript.Data);

                        for (int l = 0; l < a.Count; l++)
                        {
                            InputSimulator.Keyboard.KeyPress(a[l]);
                        }
                    } break;

                    case "NUMC.TextEntry":
                        InputSimulator.Keyboard.TextEntry(runtimeScript.Data);
                        break;
                    }
                }
                else
                {
                    switch (runtimeScript.RuntimeName)
                    {
                    case "NUMC.VirtualKey": {
                        var a = ConvertKeys(runtimeScript.Data);
                        for (int l = 0; l < a.Count; l++)
                        {
                            InputSimulator.Keyboard.KeyUp(a[l]);
                        }
                    } break;
                    }
                }
            } catch (Exception ex) {
                Task.Run(() => {
                    Plugin.Plugin.PluginException(ex, "Virtual Input Runtime", "Virtual Input Runtime");
                }).Start();
            }
        }
Esempio n. 9
0
        private void AddMenu_Click(object sender, EventArgs e)
        {
            if (ScriptEditor == null || KeyObject == null || KeyObject.Scripts == null)
            {
                return;
            }
            var script = new RuntimeScript();

            if (Dialog.ShowDialog(script, KeyObject) && script != null && script.RuntimeName != null)
            {
                KeyObject.Scripts.AddRuntimeScript(script);
            }
            ScriptEditor.RefreshView();
        }
Esempio n. 10
0
        private void Item_Click(object sender, EventArgs e)
        {
            if (KeyObject == null ||
                KeyObject.Scripts == null)
            {
                return;
            }
            var script = KeyObject.Scripts.ScriptByRuntimeNames(VirtualInputRuntime.RuntimeNames);

            if (script == null)
            {
                KeyObject.Scripts.AddRuntimeScript(script = new RuntimeScript());
            }
            if (Runtime.Dialog.ShowDialog(script, KeyObject))
            {
                Service.GetService()?.Save();
            }
        }
Esempio n. 11
0
        public void Run(ScriptInfo scriptInfo, RuntimeScript script, bool isDown)
        {
            if (isDown)
            {
                switch (script.RuntimeName)
                {
                case "Plugin.AppCommand":
                    var command = AppCommands.ToAppCommnad(script.Data);
                    if (command.HasValue)
                    {
                        AppCommandAPI.Send(command.Value);
                    }
                    break;

                default: return;
                }
            }
        }
Esempio n. 12
0
        public static string ScriptContent(RuntimeScript script)
        {
            string name;

            switch (script.RuntimeName)
            {
            case "NUMC.VirtualKey":
                name = Language.Language.VirtualInputDialog_VirtualKey_Name;
                break;

            case "NUMC.VirtualSendKeys":
                name = Language.Language.VirtualInputDialog_VirtualSendKeys_Name;
                break;

            case "NUMC.TextEntry":
                name = Language.Language.VirtualInputDialog_TextEntry_Name;
                break;

            default:
                return(null);
            }
            var content = script.RuntimeName switch {
                "NUMC.VirtualKey" or "NUMC.VirtualSendKeys" => string.Join(", ", ConvertKeys(script.Data)),
                "NUMC.TextEntry" => script.Data, _ => null,
            };

            if (content != null)
            {
                if (content.Length > 30)
                {
                    content = content.Substring(0, 30) + " ...";
                }
                content = $" ({content})";
            }
            return($"{name}{content}");
        }
Esempio n. 13
0
 public bool ShowDialog(RuntimeScript runtimeScript, KeyObject obj) =>
 new VirtualInputDialog(runtimeScript, obj).ShowDialog() == System.Windows.Forms.DialogResult.OK;
Esempio n. 14
0
 string IRuntime.ScriptContent(RuntimeScript script, KeyObject obj) => ScriptContent(script);