Example #1
0
        /// <summary>
        /// Calls RunCMD with additional parameters taken from the classes @loom doc tag
        /// </summary>
        public override bool BuildCMD(bool failSilently)
        {
            if (!IsCompilationTarget())
            {
                MessageBar.ShowWarning(TextHelper.GetString("Info.InvalidClass"));
                return(false);
            }

            MainForm.CallCommand("SaveAllModified", null);

            string sdk = PluginBase.CurrentProject != null
                    ? PluginBase.CurrentProject.CurrentSDK
                    : loomSettings.GetDefaultSDK().Path;

            // TODO BuildCMD does it make sense?
            return(true);
        }
Example #2
0
        /// <summary>
        /// Calls RunCMD with additional parameters taken from the classes @haxe doc tag
        /// </summary>
        public override bool BuildCMD(bool failSilently)
        {
            if (!File.Exists(CurrentFile))
            {
                return(false);
            }
            // check if @haxe is defined
            Match      mCmd   = null;
            ClassModel cClass = cFile.GetPublicClass();

            if (IsFileValid)
            {
                if (cFile.Comments != null)
                {
                    mCmd = re_CMD_BuildCommand.Match(cFile.Comments);
                }
                if ((mCmd == null || !mCmd.Success) && cClass.Comments != null)
                {
                    mCmd = re_CMD_BuildCommand.Match(cClass.Comments);
                }
            }

            if (mCmd == null || !mCmd.Success)
            {
                if (!failSilently)
                {
                    MessageBar.ShowWarning(TextHelper.GetString("Info.InvalidForQuickBuild"));
                }
                return(false);
            }

            // build command
            string command = mCmd.Groups["params"].Value.Trim();

            try
            {
                command = Regex.Replace(command, "[\\r\\n]\\s*\\*", "", RegexOptions.Singleline);
                command = " " + MainForm.ProcessArgString(command) + " ";
                if (command == null || command.Length == 0)
                {
                    if (!failSilently)
                    {
                        throw new Exception(TextHelper.GetString("Info.InvalidQuickBuildCommand"));
                    }
                    return(false);
                }
                outputFile        = null;
                outputFileDetails = "";
                trustFileWanted   = false;

                // get some output information url
                MatchCollection mPar       = re_SplitParams.Matches(command + "-eof");
                int             mPlayIndex = -1;
                bool            noPlay     = false;
                if (mPar.Count > 0)
                {
                    string op;
                    for (int i = 0; i < mPar.Count; i++)
                    {
                        op = mPar[i].Groups["switch"].Value;
                        int start = mPar[i].Index + mPar[i].Length;
                        int end   = (mPar.Count > i + 1) ? mPar[i + 1].Index : start;
                        if ((op == "-swf") && (outputFile == null) && (mPlayIndex < 0))
                        {
                            if (end > start)
                            {
                                outputFile = command.Substring(start, end - start).Trim();
                            }
                        }
                        else if (op == "-swf-header")
                        {
                            if (end > start)
                            {
                                string[] dims = command.Substring(start, end - start).Trim().Split(':');
                                if (dims.Length > 2)
                                {
                                    outputFileDetails = ";" + dims[0] + ";" + dims[1];
                                }
                            }
                        }
                        else if (op == "-play")
                        {
                            if (end > start)
                            {
                                mPlayIndex = i;
                                outputFile = command.Substring(start, end - start).Trim();
                            }
                        }
                        else if (op == "-trust")
                        {
                            trustFileWanted = true;
                        }
                        else if (op == "-noplay")
                        {
                            noPlay = true;
                        }
                    }
                }
                if (outputFile != null && outputFile.Length == 0)
                {
                    outputFile = null;
                }

                // cleaning custom switches
                if (mPlayIndex >= 0)
                {
                    command = command.Substring(0, mPar[mPlayIndex].Index) + command.Substring(mPar[mPlayIndex + 1].Index);
                }
                if (trustFileWanted)
                {
                    command = command.Replace("-trust", "");
                }
                if (noPlay || !settings.PlayAfterBuild)
                {
                    command       = command.Replace("-noplay", "");
                    outputFile    = null;
                    runAfterBuild = false;
                }
                else
                {
                    runAfterBuild = (outputFile != null);
                }
            }
            catch (Exception ex)
            {
                ErrorManager.ShowError(ex);
                return(false);
            }

            // run
            RunCMD(command);
            return(true);
        }
Example #3
0
        /// <summary>
        /// Calls RunCMD with additional parameters taken from the classes @mtasc doc tag
        /// </summary>
        public override bool BuildCMD(bool failSilently)
        {
            // check if @mtasc is defined
            Match mCmd = null;

            if (IsFileValid() && CurrentClass.Comments != null)
            {
                mCmd = re_CMD_BuildCommand.Match(CurrentClass.Comments);
            }

            if (mCmd == null || !mCmd.Success)
            {
                if (!failSilently)
                {
                    MessageBar.ShowWarning("This class is invalid or does not include a @mtasc build command.");
                }
                return(false);
            }

            // build command
            string command = mCmd.Groups["params"].Value.Trim();

            try
            {
                command = " " + MainForm.ProcessArgString(command) + " ";
                if (command == null || command.Length == 0)
                {
                    if (!failSilently)
                    {
                        throw new Exception("Preprocessor returned an empty command.");
                    }
                    return(false);
                }
                builtSWF        = null;
                builtSWFSize    = "";
                trustFileWanted = false;

                // get SWF url
                MatchCollection mPar       = re_SplitParams.Matches(command + "-eof");
                int             mPlayIndex = -1;
                bool            noPlay     = false;
                if (mPar.Count > 0)
                {
                    string op;
                    for (int i = 0; i < mPar.Count; i++)
                    {
                        op = mPar[i].Groups["switch"].Value;
                        if ((op == "-swf") && (builtSWF == null) && (mPlayIndex < 0))
                        {
                            int start = mPar[i].Index + mPar[i].Length;
                            int end   = mPar[i + 1].Index;
                            if (end > start)
                            {
                                builtSWF = command.Substring(start, end - start).Trim();
                            }
                        }
                        else if ((op == "-out") && (mPlayIndex < 0))
                        {
                            int start = mPar[i].Index + mPar[i].Length;
                            int end   = mPar[i + 1].Index;
                            if (end > start)
                            {
                                builtSWF = command.Substring(start, end - start).Trim();
                            }
                        }
                        else if (op == "-header")
                        {
                            int start = mPar[i].Index + mPar[i].Length;
                            int end   = mPar[i + 1].Index;
                            if (end > start)
                            {
                                string[] dims = command.Substring(start, end - start).Trim().Split(':');
                                if (dims.Length > 2)
                                {
                                    builtSWFSize = ";" + dims[0] + ";" + dims[1];
                                }
                            }
                        }
                        else if (op == "-play")
                        {
                            int start = mPar[i].Index + mPar[i].Length;
                            int end   = mPar[i + 1].Index;
                            if (end > start)
                            {
                                mPlayIndex = i;
                                builtSWF   = command.Substring(start, end - start).Trim();
                            }
                        }
                        else if (op == "-trust")
                        {
                            trustFileWanted = true;
                        }
                        else if (op == "-noplay")
                        {
                            noPlay = true;
                        }
                    }
                }
                if (builtSWF.Length == 0)
                {
                    builtSWF = null;
                }

                // cleaning custom switches
                if (mPlayIndex >= 0)
                {
                    command = command.Substring(0, mPar[mPlayIndex].Index) + command.Substring(mPar[mPlayIndex + 1].Index);
                }
                if (trustFileWanted)
                {
                    command = command.Replace("-trust", "");
                }
                if (noPlay)
                {
                    command  = command.Replace("-noplay", "");
                    builtSWF = null;
                }
            }
            catch (Exception ex)
            {
                ErrorHandler.ShowError("Error while preprocessing the build command.", ex);
                return(false);
            }

            // run
            RunCMD(command);
            return(true);
        }
 /// <summary>
 /// Depending on the context UI, display some message
 /// </summary>
 public void DisplayError(string message)
 {
     MessageBar.ShowWarning(message);
 }