Esempio n. 1
0
        // Called once an asyncronous compiling task has completed.
        private void OnCompileComplete(ScriptCompileResult results)
        {
            // Update the script object.
            script.Code     = codeEditor.Text;
            script.Errors   = results.Errors;
            script.Warnings = results.Warnings;

            // Update the error message status-strip.
            if (script.HasErrors)
            {
                displayedError          = script.Errors[0];
                labelErrorMessage.Text  = displayedError.ToString();
                labelErrorMessage.Image = ZeldaEditor.ResourceProperties.Resources.exclamation;
            }
            else
            {
                displayedError          = null;
                labelErrorMessage.Text  = "";
                labelErrorMessage.Image = null;
            }

            // Update the world-tree-view's scripts (if there is an error icon for a failed compile).
            if (!script.IsHidden)
            {
                editorControl.EditorForm.worldTreeView.RefreshScripts();
            }
        }
Esempio n. 2
0
 // Check when the compiling has finished.
 private void RecompileUpdate(object sender, EventArgs e)
 {
     // Check if we have finished compiling.
     if (IsCompiling)
     {
         if (compileTask.IsCompleted)
         {
             ScriptCompileResult results = compileTask.Result;
             compileTask = null;
             OnCompileComplete(results);
         }
     }
     // Begin recompiling.
     else if (needsRecompiling && !editorControl.IsBusyCompiling)
     {
         BeginCompilingScript();
     }
     // Check if the form has been closed.
     else if (IsDisposed)
     {
         Application.Idle -= RecompileUpdate;                 // <--- Concurrency error much??
     }
 }
Esempio n. 3
0
        //-----------------------------------------------------------------------------
        // Internal Methods
        //-----------------------------------------------------------------------------

        // Compile the final code for a script only to find any errors and/or warnings.
        private static ScriptCompileResult CompileScript(string code)
        {
            // Setup the compile options.
            CompilerParameters options = new CompilerParameters();

            options.GenerateExecutable = false;                  // We want a Dll (Class Library)
            options.GenerateInMemory   = true;

            // Add the assembly references.
            Assembly zeldaApiAssembly = Assembly.GetAssembly(typeof(ZeldaAPI.CustomScriptBase));

            options.ReferencedAssemblies.Add(zeldaApiAssembly.Location);

            // Create a C# code provider and compile the code.
            Microsoft.CSharp.CSharpCodeProvider csProvider = new Microsoft.CSharp.CSharpCodeProvider();
            CompilerResults csResult = csProvider.CompileAssemblyFromSource(options, code);

            // Copy warnings and errors into the ScriptComileResult.
            ScriptCompileResult result = new ScriptCompileResult();

            foreach (CompilerError csError in csResult.Errors)
            {
                ScriptCompileError error = new ScriptCompileError(csError.Line,
                                                                  csError.Column, csError.ErrorNumber, csError.ErrorText, csError.IsWarning);
                if (error.IsWarning)
                {
                    result.Warnings.Add(error);
                }
                else
                {
                    result.Errors.Add(error);
                }
            }

            return(result);
        }
Esempio n. 4
0
 private void OnCompileCompleted(ScriptCompileResult result)
 {
     world.ScriptManager.RawAssembly = result.RawAssembly;
     Console.WriteLine("Compiled scripts with " + result.Errors.Count + " errors and " + result.Warnings.Count + " warnings.");
     editorForm.statusLabelTask.Text = "";
 }