public void DoScriptAt(Vector2D mappos, float rendererscale) { bool snaptogrid = General.Interface.ShiftState ^ General.Interface.SnapToGrid; bool snaptonearest = General.Interface.CtrlState ^ General.Interface.AutoMerge; if (General.Interface.MouseInDisplay) { // Make undo for the draw General.Map.UndoRedo.CreateUndo("Run script"); General.Interface.SetCursor(Cursors.AppStarting); General.Interface.DisplayStatus(StatusType.Info, "Executing script!"); /* * List<Sector> oldsectors = new List<Sector>(General.Map.Map.Sectors); * List<Sector> allnewsectors = new List<Sector>(); */ WadScriptVM vm = new WadScriptVM(this); vm.RunVM(snaptogrid, snaptonearest, mappos); /* * int i = 1; * foreach (Sector s in General.Map.Map.Sectors) * { * if (!oldsectors.Contains(s)) * { * allnewsectors.Add(s); * s.SetFloorTexture("FLAT" + i++); * } * } */ // Snap to map format accuracy General.Map.Map.SnapAllToAccuracy(); // Clear selection General.Map.Map.ClearAllSelected(); // Update cached values General.Map.Map.Update(); // Update the used textures General.Map.Data.UpdateUsedTextures(); // Map is changed General.Map.IsChanged = true; General.Interface.SetCursor(Cursors.Default); General.Interface.RedrawDisplay(); General.Interface.DisplayStatus(StatusType.Info, "Execution done!"); } // add support for mouseless scripts }
// returns false on error public bool CompileFromFilename(string filename, WadScriptVM invm) { if (!File.Exists(filename)) { Logger.WriteLogLine("WadScript.Compiler: attempt to compile nonexistent file " + filename); return(false); } return(CompileFromCharArray(File.ReadAllText(filename).ToCharArray(), invm)); }
// returns false on error public bool CompileFromCharArray(char[] infile, WadScriptVM invm) { vm = invm; if (!Tokenize(infile)) { Error("Unknown Tokenizer Error (sorry)"); return(false); } vm.lines = lines; for (int i = 0; i < tokens.Count; i++) { Logger.WriteLogLine(tokenTypes[i].ToString() + " token \"" + tokens[i] + "\" at line number " + tokenLineNumbers[i]); } SyntaxGen(); Logger.WriteLogLine(DebugPrintParseTree(string.Empty, syntaxtree, 0)); return(true); }