Ejemplo n.º 1
0
        public LinkResult Compile(ProjectInfo projectInfo, ScriptInfo scriptInfo, bool runAfterCompiling)
        {
            var sfdProcess = Process.GetProcessesByName("Superfighters Deluxe").FirstOrDefault();

            if (sfdProcess == null)
            {
                return(new LinkResult(AutomationError.SfdNotOpen));
            }

            var result     = CopyToClipboard(projectInfo, scriptInfo);
            var sourceCode = result.Content;

            //var sourceCode = await Task.Run(() => _linker.Link(ProjectInfo, ScriptInfo));

            // Switch to the Script Editor window
            WinUtil.BringWindowToFront("Script Editor");

            // Wait until the window is switching back
            while (WinUtil.GetActiveWindowTitle() == null)
            {
            }

            if (WinUtil.GetActiveWindowTitle() == "Script Editor")
            {
                // Tab to focus in the editor's text area if not already
                WinUtil.SimulateKey("{TAB}");
                // CTRL-A Select all text in editor
                WinUtil.SimulateKey("^(a)");
                // CTRL-V Paste clipboard content
                WinUtil.SimulateKey("^(v)");
                // Compile newly pasted code
                WinUtil.SimulateKey("{F5}");

                if (runAfterCompiling)
                {
                    RunMapEditorTestIfSuccess();
                }

                return(result);
            }
            else
            {
                return(new LinkResult(AutomationError.ScriptEditorNotOpen));
            }
        }