private void compileScriptToolStripMenuItem_Click(object sender, EventArgs e) { this.FixMasters(); var r = this.PluginTree.SelectedRecord as Record; var plugin = this.GetPluginFromNode(r); if (plugin == null || plugin.Parent == null) { return; } string errors; if (this.Selection.SelectedSubrecord && this.Selection.Record.Name != "SCPT") { var sr = this.SubrecordList.SubRecord; if (sr == null) { return; } if (sr.Name != "SCTX") { MessageBox.Show("You need to select a SCPT record or SCTX subrecord to compile", "Error"); return; } ScriptCompiler.Setup(plugin.Masters); Record r2; if (!ScriptCompiler.CompileResultScript(sr, out r2, out errors)) { MessageBox.Show("There were compilation errors:\n" + errors); } else { var srs = r.SubRecords; int i = srs.IndexOf(sr); if (i >= 0) { while (i > 0 && (srs[i - 1].Name == "SCDA" || srs[i - 1].Name == "SCHR")) { srs.RemoveAt(--i); } while (i < srs.Count && (srs[i].Name == "SCTX" || srs[i].Name == "SLSD" || srs[i].Name == "SCVR" || srs[i].Name == "SCRO" || srs[i].Name == "SCRV")) { srs.RemoveAt(i); } srs.InsertRange(i, r2.SubRecords); this.RebuildSelection(); this.PluginTree.RefreshObject(r); } } return; } if (r == null || (r.Name != "SCPT")) { MessageBox.Show("You need to select a SCPT record or SCTX subrecord to compile", "Error"); return; } ScriptCompiler.Setup(plugin.Masters); if (!ScriptCompiler.Compile(r, out errors)) { MessageBox.Show("There were compilation errors:\n" + errors); } else { this.RebuildSelection(); this.PluginTree.RebuildObjects(); } }
/// <summary> /// Compiles the result script. /// </summary> public void CompileResultScript(SubRecord sr, out Record r2, out string msg) { ScriptCompiler.CompileResultScript(sr, out r2, out msg); }