Beispiel #1
0
        public static int Main(string[] args)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = Utility.CultureUS;

                if (args.Length <= 0)
                {
                    Console.WriteLine("Usage: SB3UtilityScript \"scriptPath.txt\"");
                }
                else
                {
                    for (int i = 0; i < args.Length; i++)
                    {
                        ScriptMain script = new ScriptMain();
                        Report.Log += new Action <string>(Logger);
                        script.LoadPlugin((string)script.ScriptEnvironment.Variables[ScriptExecutor.PluginDirectoryName] + "SB3UtilityPlugins.dll");
                        script.RunScript(args[i]);
                    }
                }

                return(0);
            }
            catch (Exception ex)
            {
                Exception inner = ex;
                while (inner != null)
                {
                    Console.WriteLine(inner.Message);
                    inner = inner.InnerException;
                }

                return(-1);
            }
        }
Beispiel #2
0
        public object RunScript(string command, bool show = true)
        {
            var mem = new MemoryStream(Encoding.UTF8.GetBytes(command));

            if ((bool)Gui.Config["CaptureCommands"])
            {
                richTextBoxScript.SuspendLayout();
                Color  color    = (show) ? Color.Empty : SystemColors.GrayText;
                string cmdShown = command;
                if (timeStampToolStripMenuItem.Checked)
                {
                    string timeHeader = "[" + DateTime.Now.Hour.ToString("D2") + ":" + DateTime.Now.Minute.ToString("D2") + "] ";
                    cmdShown = timeHeader + command;
                }
                AppendText(cmdShown + (show ? "" : " // GUI only") + Environment.NewLine, color);
                richTextBoxScript.SelectionStart = richTextBoxScript.Text.Length;
                richTextBoxScript.ScrollToCaret();
                richTextBoxScript.ResumeLayout();

                if (autosaveToolStripMenuItem.Checked)
                {
                    autosaveScriptWriter.WriteLine(command);
                }
            }

            return(ScriptMain.RunScript(mem, "Script"));
        }
Beispiel #3
0
        public static int Main(string[] args)
        {
            try
            {
                Thread.CurrentThread.CurrentCulture = Utility.CultureUS;

                if (args.Length <= 0)
                {
                    Console.WriteLine("Usage: SB3UtilityScript \"scriptPath.txt\"");
                }
                else
                {
                    for (int i = 0; i < args.Length; i++)
                    {
                        ScriptMain script = new ScriptMain();
                        Report.Log += new Action<string>(Logger);
                        script.LoadPlugin((string)script.ScriptEnvironment.Variables[ScriptExecutor.PluginDirectoryName] + "SB3UtilityPlugins.dll");
                        script.RunScript(args[i]);
                    }
                }

                return 0;
            }
            catch (Exception ex)
            {
                Exception inner = ex;
                while (inner != null)
                {
                    Console.WriteLine(inner.Message);
                    inner = inner.InnerException;
                }

                return -1;
            }
        }
Beispiel #4
0
        public object RunScript(string command, bool show = true)
        {
            var mem = new MemoryStream(Encoding.UTF8.GetBytes(command));

            if ((bool)Gui.Config["CaptureCommands"])
            {
                richTextBoxScript.SuspendLayout();
                Color color = (show) ? Color.Empty : SystemColors.GrayText;
                AppendText(command + (show ? "" : " // GUI only") + Environment.NewLine, color);
                richTextBoxScript.SelectionStart = richTextBoxScript.Text.Length;
                richTextBoxScript.ScrollToCaret();
                richTextBoxScript.ResumeLayout();

                if (autosaveToolStripMenuItem.Checked)
                {
                    autosaveScriptWriter.WriteLine(command);
                }
            }

            return(ScriptMain.RunScript(mem, "Script"));
        }