public void Reverse(Document document) { foreach (var gp in _groupsAndParents) { var group = new Group(gp.Key) {Colour = Colour.GetRandomGroupColour()}; var parent = document.Map.WorldSpawn.FindByID(gp.Value); group.SetParent(parent); } foreach (var cp in _childrenAndParents) { var child = document.Map.WorldSpawn.FindByID(cp.Key); var parent = document.Map.WorldSpawn.FindByID(cp.Value); child.SetParent(parent); child.UpdateBoundingBox(); child.Colour = parent.Colour.Vary(); } foreach (var gp in _groupsAndParents) { var group = document.Map.WorldSpawn.FindByID(gp.Key); if (group.GetChildren().All(x => x.IsSelected)) document.Selection.Select(group); } Mediator.Publish(EditorMediator.SelectionChanged); Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); }
public void RenderDocument(ViewportBase viewport, Document document) { if (!document.Map.Cordon || document.Map.CordonBounds.IsEmpty()) return; if (ToolManager.ActiveTool != null && ToolManager.ActiveTool.GetHotkeyToolType() == HotkeyTool.Cordon) return; if (viewport is Viewport2D) Render2D((Viewport2D)viewport, document); if (viewport is Viewport3D) Render3D((Viewport3D)viewport, document); }
public void RenderDocument(ViewportBase viewport, Document document) { if (document.Pointfile == null) return; var pf = document.Pointfile; var vp2 = viewport as Viewport2D; Func<Coordinate, Coordinate> transform = x => x; if (vp2 != null) transform = vp2.Flatten; TextureHelper.Unbind(); GL.LineWidth(3); GL.Begin(PrimitiveType.Lines); var r = 1f; var g = 0.5f; var b = 0.5f; var change = 0.5f / pf.Lines.Count; foreach (var line in pf.Lines) { var start = transform(line.Start); var end = transform(line.End); GL.Color3(r, g, b); GL.Vertex3(start.DX, start.DY, start.DZ); r -= change; b += change; GL.Color3(r, g, b); GL.Vertex3(end.DX, end.DY, end.DZ); } GL.End(); GL.LineWidth(1); }
public void Perform(Document document) { document.Selection.Select(_objects.Where(x => x.BoundingBox != null)); Mediator.Publish(EditorMediator.DocumentTreeSelectedObjectsChanged, _objects); Mediator.Publish(EditorMediator.SelectionChanged); }
public ImmediateRenderer(Document document) { Document = document; _cache = null; _selectionTransformMat = Matrix.Identity; _selectionTransform = Matrix4.Identity; }
public void Perform(Document document) { var autohide = document.Map.GetAllVisgroups().First(x => x.Name == "Autohide"); _added = autohide.ID; _selection = new List<MapObject>(); foreach (var mapObject in _objects) { var o = mapObject; if (!o.AutoVisgroups.Contains(_added)) { o.AutoVisgroups.Add(_added); o.Visgroups.Add(_added); } o.IsVisgroupHidden = true; if (o.IsSelected) { _selection.Add(o); document.Selection.Deselect(o); } } Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); Mediator.Publish(EditorMediator.SelectionChanged); Mediator.Publish(EditorMediator.VisgroupsChanged); }
public void Perform(Document document) { foreach (var child in _childrenAndParents.Keys.Select(x => document.Map.WorldSpawn.FindByID(x))) { child.SetParent(document.Map.WorldSpawn); child.UpdateBoundingBox(); child.Colour = Colour.GetRandomBrushColour(); } foreach (var groupId in _groupsAndParents.Keys) { var group = document.Map.WorldSpawn.FindByID(groupId); if (group == null) continue; if (group.IsSelected) { document.Selection.Deselect(group); } group.SetParent(null); } Mediator.Publish(EditorMediator.SelectionChanged); Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); }
public void Undo(Document document) { for (var i = _actions.Count - 1; i >= 0; i--) { _actions[i].Reverse(document); } }
public void Cleanup() { if (File.Exists("before.vmf")) File.Delete("before.vmf"); if (File.Exists("after.vmf")) File.Delete("after.vmf"); _document = null; MapProvider.DeregisterAll(); }
public static void SetDocument(Document doc) { var active = ActiveTool; Deactivate(); Tools.ForEach(x => x.SetDocument(doc)); Activate(active); }
public void Reverse(Document document) { var root = document.Map.WorldSpawn; foreach (var kv in _reverse) { var obj = root.FindByID(kv.Key); if (obj == null) return; // Unclone will reset children, need to reselect them if needed var deselect = obj.FindAll().Where(x => x.IsSelected).ToList(); document.Selection.Deselect(deselect); obj.Unclone(kv.Value); var select = obj.FindAll().Where(x => deselect.Any(y => x.ID == y.ID)); document.Selection.Select(select); document.Map.UpdateAutoVisgroups(obj, true); } Mediator.Publish(EditorMediator.DocumentTreeStructureChanged, _reverse.Select(x => document.Map.WorldSpawn.FindByID(x.Key))); Mediator.Publish(EditorMediator.SelectionChanged); Mediator.Publish(EditorMediator.VisgroupsChanged); _reverse.Clear(); }
public void Perform(Document document) { document.Selection.Deselect(_objects); Mediator.Publish(EditorMediator.DocumentTreeSelectedObjectsChanged, _objects); Mediator.Publish(EditorMediator.SelectionChanged); }
public void Reverse(Document document) { document.Selection.Select(_objects); Mediator.Publish(EditorMediator.DocumentTreeSelectedObjectsChanged, _objects); Mediator.Publish(EditorMediator.SelectionChanged); }
public virtual void Reverse(Document document) { // Edit _editObjects.ForEach(x => x.Reverse(document)); // Create _objectsToCreate = document.Map.WorldSpawn.Find(x => _createdIds.Contains(x.ID)); if (_objectsToCreate.Any(x => x.IsSelected)) { document.Selection.Deselect(_objectsToCreate.Where(x => x.IsSelected)); } _objectsToCreate.ForEach(x => x.SetParent(null)); _createdIds = null; // Delete _idsToDelete = _deletedObjects.Select(x => x.Object.ID).ToList(); foreach (var dr in _deletedObjects.Where(x => x.TopMost)) { dr.Object.SetParent(document.Map.WorldSpawn.FindByID(dr.ParentID)); document.Map.UpdateAutoVisgroups(dr.Object, true); } document.Selection.Select(_deletedObjects.Where(x => x.IsSelected).Select(x => x.Object)); _deletedObjects = null; if (_objectsToCreate.Any() || _idsToDelete.Any()) { Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); } else if (_editObjects.Any()) { Mediator.Publish(EditorMediator.DocumentTreeStructureChanged, _editObjects.Select(x => document.Map.WorldSpawn.FindByID(x.ID))); } Mediator.Publish(EditorMediator.VisgroupsChanged); }
public void Reverse(Document document) { for (var i = Actions.Count - 1; i >= 0; i--) { Actions[i].Reverse(document); } }
public void Reverse(Document document) { // Deleted foreach (var del in _deletedVisgroups) { document.Map.Visgroups.Add(del); _removedObjects[del.ID].ForEach(x => x.Visgroups.Add(del.ID)); } _madeVisible.ForEach(x => x.IsVisgroupHidden = true); _removedObjects = null; _madeVisible = null; // Changed _afterchanges = new List<Tuple<int, string, Color>>(); foreach (var bc in _beforeChanges) { var vis = document.Map.Visgroups.First(x => x.ID == bc.Item1); _afterchanges.Add(Tuple.Create(vis.ID, vis.Name, vis.Colour)); vis.Name = bc.Item2; vis.Colour = bc.Item3; } _beforeChanges = null; // New document.Map.Visgroups.RemoveAll(x => _newVisgroups.Any(y => y.ID == x.ID)); Mediator.Publish(EditorMediator.VisgroupsChanged); Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); }
public void Reverse(Document document) { document.Selection.Select(_deselected); document.Selection.Deselect(_selected); Mediator.Publish(EditorMediator.DocumentTreeFacesChanged, _selected.Union(_deselected)); Mediator.Publish(EditorMediator.SelectionChanged); }
public static bool UpdateModels(this Map map, Document document, IEnumerable<MapObject> objects) { if (Sledge.Settings.View.DisableModelRendering) return false; var updated = false; foreach (var mo in objects) updated |= UpdateModels(document, mo); return updated; }
public void Reverse(Document document) { document.Selection.Select(_deselected.Where(x => x.BoundingBox != null)); document.Selection.Deselect(_selected); Mediator.Publish(EditorMediator.DocumentTreeSelectedObjectsChanged, _selected.Union(_deselected)); Mediator.Publish(EditorMediator.SelectionChanged); }
public void Perform(Document document) { document.Selection.Deselect(_deselected); document.Selection.Select(_selected); Mediator.Publish(EditorMediator.DocumentTreeObjectsChanged, _selected.Union(_deselected)); Mediator.Publish(EditorMediator.SelectionChanged); }
public static IEnumerable<MapObject> GetPastedContent(Document document) { if (!System.Windows.Forms.Clipboard.ContainsText()) return null; var str = System.Windows.Forms.Clipboard.GetText(); if (!str.StartsWith("clipboard")) return null; return ExtractCopyStream(document, str); }
public void Perform(Document document) { var parent = document.Map.WorldSpawn.FindByID(_parentId); _objects.ForEach(x => x.MapObject.SetParent(parent)); document.Map.UpdateAutoVisgroups(_objects.Select(x => x.MapObject), true); Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); Mediator.Publish(EditorMediator.VisgroupsChanged); }
public void Reverse(Document document) { _shown.ForEach(x => x.IsVisgroupHidden = true); Mediator.Publish(EditorMediator.VisgroupsChanged); Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); _shown = null; }
public void Perform(Document document) { _shown = document.Map.WorldSpawn.FindAll() .Where(x => x.IsVisgroupHidden).ToList(); _shown.ForEach(x => x.IsVisgroupHidden = false); Mediator.Publish(EditorMediator.VisgroupsChanged); Mediator.Publish(EditorMediator.DocumentTreeStructureChanged); }
public Batch(Document document, Build build, BuildProfile profile) { Document = document; Game = document.Game; Build = build; Profile = profile; var workingDir = Path.GetDirectoryName(document.MapFile); if (build.WorkingDirectory == CompileWorkingDirectory.SubDirectory && workingDir != null) { workingDir = Path.Combine(workingDir, Path.GetFileNameWithoutExtension(document.MapFileName)); } else if (build.WorkingDirectory == CompileWorkingDirectory.TemporaryDirectory || workingDir == null) { workingDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); } if (!Directory.Exists(workingDir)) Directory.CreateDirectory(workingDir); TargetFile = SaveCordonMap(document, workingDir); OriginalFile = document.MapFile; var fileFlag = '"' + TargetFile + '"'; Steps = new List<BatchCompileStep>(); if (profile.RunCsg) { Steps.Add(new BatchCompileStep { Operation = Path.Combine(build.Path, build.Csg), Flags = (profile.FullCsgParameters + ' ' + fileFlag).Trim() }); } if (profile.RunBsp) { Steps.Add(new BatchCompileStep { Operation = Path.Combine(build.Path, build.Bsp), Flags = (profile.FullBspParameters + ' ' + fileFlag).Trim() }); } if (profile.RunVis) { Steps.Add(new BatchCompileStep { Operation = Path.Combine(build.Path, build.Vis), Flags = (profile.FullVisParameters + ' ' + fileFlag).Trim() }); } if (profile.RunRad) { Steps.Add(new BatchCompileStep { Operation = Path.Combine(build.Path, build.Rad), Flags = (profile.FullRadParameters + ' ' + fileFlag).Trim() }); } }
private static void UpdateModels(Document document, MapObject mo) { mo.Children.ForEach(x => UpdateModels(document, x)); var e = mo as Entity; if (e == null || !ShouldHaveModel(e)) return; var model = GetModelName(e); var file = document.Environment.Root.TraversePath(model); if (file == null) return; SetModel(e, ModelProvider.CreateModelReference(file)); }
public void Perform(Document document) { ToolManager.Deactivate(true); document.Selection.SwitchToFaceSelection(); ToolManager.Activate(_toolType, true); Mediator.Publish(EditorMediator.DocumentTreeSelectedFacesChanged, document.Selection.GetSelectedFaces()); Mediator.Publish(EditorMediator.SelectionChanged); }
public void Reverse(Document document) { foreach (var mapObject in _objects) { var o = mapObject; o.Visgroups.Clear(); o.Visgroups.AddRange(_originals[o.ID]); } _originals = null; Mediator.Publish(EditorMediator.VisgroupsChanged); }
public void Reverse(Document document) { var desel = _deselected.Select(x => FindFace(document, x.Key, x.Value)).Where(x => x != null).ToList(); var sel = _selected.Select(x => FindFace(document, x.Key, x.Value)).Where(x => x != null).ToList(); document.Selection.Select(desel); document.Selection.Deselect(sel); Mediator.Publish(EditorMediator.DocumentTreeSelectedFacesChanged, sel.Union(desel)); Mediator.Publish(EditorMediator.SelectionChanged); }
public GridRenderable(Document document) { _program = new ShaderProgram( new Shader(ShaderType.VertexShader, VertexShader), new Shader(ShaderType.FragmentShader, FragmentShader)); _document = document; _step = -1; _buffer = new VertexBuffer<float>(Specification, Modes, 0, sizeof(float), new float[0], new[] { new uint[0] }); _array = new VertexArray<float>(_buffer); RebuildGrid(1); }