/// <summary> /// Provides specialized functionality for a visual (3D) Doom Builder editing mode. /// </summary> protected VisualMode() { // Initialize this.renderer = General.Map.Renderer3D; this.blockmap = new VisualBlockMap(); this.allsectors = new Dictionary <Sector, VisualSector>(General.Map.Map.Sectors.Count); this.allthings = new Dictionary <Thing, VisualThing>(General.Map.Map.Things.Count); this.visibleblocks = new List <VisualBlockEntry>(); this.visiblesectors = new Dictionary <Sector, VisualSector>(50); this.visiblegeometry = new List <VisualGeometry>(200); this.visiblethings = new Dictionary <Thing, VisualThing>(100); this.processgeometry = true; this.processthings = true; this.vertices = new Dictionary <Vertex, VisualVertexPair>(); //mxd //mxd. Synch camera position to cursor position or center of the screen in 2d-mode if (General.Settings.GZSynchCameras && General.Editing.Mode is ClassicMode) { ClassicMode oldmode = (ClassicMode)General.Editing.Mode; if (oldmode.IsMouseInside) { initialcameraposition = new Vector2D(oldmode.MouseMapPos.x, oldmode.MouseMapPos.y); } else { initialcameraposition = new Vector2D(General.Map.CRenderer2D.Viewport.Left + General.Map.CRenderer2D.Viewport.Width / 2.0f, General.Map.CRenderer2D.Viewport.Top + General.Map.CRenderer2D.Viewport.Height / 2.0f); } } }
private static void ShowSelection(IEnumerable <Vector2D> points) { RectangleF area = MapSet.CreateEmptyArea(); // Make a view area from the points foreach (Vector2D p in points) { area = MapSet.IncreaseArea(area, p); } // Make the area square, using the largest side if (area.Width > area.Height) { float delta = area.Width - area.Height; area.Y -= delta * 0.5f; area.Height += delta; } else { float delta = area.Height - area.Width; area.X -= delta * 0.5f; area.Width += delta; } // Add padding area.Inflate(100f, 100f); // Zoom to area ClassicMode mode = General.Editing.Mode as ClassicMode; if (mode != null) { mode.CenterOnArea(area, 0.6f); } }
void Start () { gameManager = GameObject.FindObjectOfType<GameManager> (); GameObject.Find("LevelFailed").GetComponent<Image>().color = new Color(1f, 1f, 1f, 0f); timerText = GameObject.Find ("TimerText").GetComponent<Text> (); scoreText = GameObject.Find ("Score").GetComponent<Text> (); HighScoreText = GameObject.Find ("HighScore").GetComponent<Text> (); gameOverUIAnim = GameObject.Find ("GameOverUI").GetComponent<Animator> (); if (gameManager.subLevelIndex == 1) { currentMode = ClassicMode.Mode25; } else if (gameManager.subLevelIndex == 2) { currentMode = ClassicMode.Mode50; } else if (gameManager.subLevelIndex == 3) { currentMode = ClassicMode.Pro; } if (gameManager.isSoundOn) GetComponent<AudioSource> ().volume = 1f; else GetComponent<AudioSource> ().volume = 0f; if (currentMode == ClassicMode.Mode25) { totalTap = 25; } else if (currentMode == ClassicMode.Mode50) { totalTap = 50; } else if (currentMode == ClassicMode.Pro) { totalTap = 50; } gameManager.ResetNoteIndex(); GenerateFullGrid (); scoreText.text = timeCounter.ToString ("0.00") + " sec"; }
public static ClassicMode GetInstance() { if (instance == null) { instance = new ClassicMode(); } return(instance); }
internal override void ShowSource() { // Switch to appropriate mode... if (General.Editing.Mode.GetType().Name != targetmodename) { // Leave any volatile mode General.Editing.CancelVolatileMode(); General.Editing.ChangeMode(targetmodename); } // Select map element if it still exists if (target != null && !target.IsDisposed) { General.Map.Map.ClearAllSelected(); if (target is Vertex) { ((Vertex)target).Selected = true; } else if (target is Sidedef) { ((Sidedef)target).Line.Selected = true; } else if (target is Linedef) { ((Linedef)target).Selected = true; } else if (target is Sector) { Sector s = (Sector)target; ((ClassicMode)General.Editing.Mode).SelectMapElement(s); foreach (Sidedef sd in s.Sidedefs) { sd.Line.Selected = true; } } else if (target is Thing) { ((Thing)target).Selected = true; } else { throw new NotImplementedException("Unknown MapElement type!"); } } // Show area ClassicMode editmode = (General.Editing.Mode as ClassicMode); editmode.CenterOnArea(zoomarea, 0.6f); }
// Call this to zoom in on the given selection public virtual void ZoomToSelection(ICollection <FindReplaceObject> selection) { List <Vector2D> points = new List <Vector2D>(); RectangleF area = MapSet.CreateEmptyArea(); // Add all points to a list foreach (FindReplaceObject o in selection) { o.AddViewPoints(points); } // Make a view area from the points foreach (Vector2D p in points) { area = MapSet.IncreaseArea(area, p); } // Make the area square, using the largest side if (area.Width > area.Height) { float delta = area.Width - area.Height; area.Y -= delta * 0.5f; area.Height += delta; } else { float delta = area.Height - area.Width; area.X -= delta * 0.5f; area.Width += delta; } // Add padding area.Inflate(100f, 100f); // Zoom to area ClassicMode editmode = (General.Editing.Mode as ClassicMode); editmode.CenterOnArea(area, 0.6f); }
// Call this to zoom in on the given selection public void ZoomToObject() { List <Vector2D> points = new List <Vector2D>(); RectangleF area = MapSet.CreateEmptyArea(); // Add all points to a list foreach (MapElement obj in viewobjects) { if (obj is Vertex) { points.Add((obj as Vertex).Position); } else if (obj is Linedef) { points.Add((obj as Linedef).Start.Position); points.Add((obj as Linedef).End.Position); } else if (obj is Sidedef) { points.Add((obj as Sidedef).Line.Start.Position); points.Add((obj as Sidedef).Line.End.Position); } else if (obj is Sector) { Sector s = (obj as Sector); foreach (Sidedef sd in s.Sidedefs) { points.Add(sd.Line.Start.Position); points.Add(sd.Line.End.Position); } } else if (obj is Thing) { Thing t = (obj as Thing); Vector2D p = (Vector2D)t.Position; points.Add(p); points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f)); points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f)); points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f)); points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f)); } else { General.Fail("Unknown object given to zoom in on."); } } // Make a view area from the points foreach (Vector2D p in points) { area = MapSet.IncreaseArea(area, p); } // Make the area square, using the largest side if (area.Width > area.Height) { float delta = area.Width - area.Height; area.Y -= delta * 0.5f; area.Height += delta; } else { float delta = area.Height - area.Width; area.X -= delta * 0.5f; area.Width += delta; } // Add padding area.Inflate(100f, 100f); // Zoom to area ClassicMode editmode = (General.Editing.Mode as ClassicMode); editmode.CenterOnArea(area, 0.6f); }
private static void ProcessNodeClick(TreeNode node) { if (node == null) { return; } List <Vector2D> points = new List <Vector2D>(); RectangleF area = MapSet.CreateEmptyArea(); if (node.Parent == null) { if (node.Tag is SoundEnvironment) { SoundEnvironment se = (SoundEnvironment)node.Tag; foreach (Sector s in se.Sectors) { foreach (Sidedef sd in s.Sidedefs) { points.Add(sd.Line.Start.Position); points.Add(sd.Line.End.Position); } } } else { // Don't zoom if the wrong nodes are selected return; } } else { if (node.Tag is Thing) { Thing t = (Thing)node.Tag; // We don't want to be zoomed too closely, so add somepadding points.Add(t.Position - 200); points.Add(t.Position + 200); } else if (node.Tag is Linedef) { Linedef ld = (Linedef)node.Tag; points.Add(ld.Start.Position); points.Add(ld.End.Position); } else { // Don't zoom if the wrong nodes are selected return; } } area = MapSet.IncreaseArea(area, points); // Add padding area.Inflate(100f, 100f); // Zoom to area ClassicMode editmode = (General.Editing.Mode as ClassicMode); editmode.CenterOnArea(area, 0.0f); }
private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex < 2 || e.RowIndex == -1) { return; } //select if (e.Button == MouseButtons.Left) { int tag = (int)dataGridView.Rows[e.RowIndex].Cells[0].Value; if (e.ColumnIndex == 2) //sectors { // Deselect everything General.Map.Map.ClearAllSelected(); List <Sector> list = GetSectorsWithTag(tag, (int)dataGridView.Rows[e.RowIndex].Cells[2].Value); if (list.Count > 0) { List <Vector2D> points = new List <Vector2D>(); General.Editing.ChangeMode("SectorsMode"); ClassicMode mode = (ClassicMode)General.Editing.Mode; foreach (Sector s in list) { mode.SelectMapElement(s); foreach (Sidedef sd in s.Sidedefs) { points.Add(sd.Line.Start.Position); points.Add(sd.Line.End.Position); } } ShowSelection(points); } else { General.Interface.RedrawDisplay(); } } else if (e.ColumnIndex == 3) //linedefs { // Deselect everything General.Map.Map.ClearAllSelected(); List <Linedef> list = GetLinedefsWithTag(tag, (int)dataGridView.Rows[e.RowIndex].Cells[3].Value); if (list.Count > 0) { General.Editing.ChangeMode("LinedefsMode"); List <Vector2D> points = new List <Vector2D>(); foreach (Linedef l in list) { l.Selected = true; points.Add(l.Start.Position); points.Add(l.End.Position); } General.Map.Map.Update(); ShowSelection(points); } else { General.Interface.RedrawDisplay(); } } else if (e.ColumnIndex == 4) //things { // Deselect everything General.Map.Map.ClearAllSelected(); List <Thing> list = GetThingsWithTag(tag, (int)dataGridView.Rows[e.RowIndex].Cells[4].Value); if (list.Count > 0) { General.Editing.ChangeMode("ThingsMode"); List <Vector2D> points = new List <Vector2D>(); foreach (Thing t in list) { t.Selected = true; Vector2D p = t.Position; points.Add(p); points.Add(p + new Vector2D(t.Size * 2.0f, t.Size * 2.0f)); points.Add(p + new Vector2D(t.Size * 2.0f, -t.Size * 2.0f)); points.Add(p + new Vector2D(-t.Size * 2.0f, t.Size * 2.0f)); points.Add(p + new Vector2D(-t.Size * 2.0f, -t.Size * 2.0f)); } General.Map.Map.Update(); ShowSelection(points); } else { General.Interface.RedrawDisplay(); } } } else if (e.Button == MouseButtons.Right) //open properties window { dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true; int tag = (int)dataGridView.Rows[e.RowIndex].Cells[0].Value; if (e.ColumnIndex == 2) //sectors { List <Sector> list = GetSectorsWithTag(tag, (int)dataGridView.Rows[e.RowIndex].Cells[2].Value); if (list.Count > 0) { General.MainWindow.ShowEditSectors(list); General.Map.Map.Update(); Setup(); } } else if (e.ColumnIndex == 3) //linedefs { List <Linedef> list = GetLinedefsWithTag(tag, (int)dataGridView.Rows[e.RowIndex].Cells[3].Value); if (list.Count > 0) { General.MainWindow.ShowEditLinedefs(list); General.Map.Map.Update(); Setup(); } } else if (e.ColumnIndex == 4) //things { List <Thing> list = GetThingsWithTag(tag, (int)dataGridView.Rows[e.RowIndex].Cells[4].Value); if (list.Count > 0) { General.MainWindow.ShowEditThings(list); General.Map.Map.Update(); Setup(); } } } }
// Initializes for a new map internal bool InitializeNewMap(MapOptions options) { // Apply settings this.filename = "unnamed.map"; this.filepathname = string.Empty; this.filepath = string.Empty; this.changed = false; this.options = options; General.WriteLogLine("Creating new map with configuration \"" + options.ConfigFile + "\""); // Initiate graphics General.WriteLogLine("Initializing graphics device..."); graphics = new D3DDevice(General.MainWindow.Display); if (!graphics.Initialize()) { return(false); } // Create renderers renderer2d = new Renderer2D(graphics); renderer3d = new Renderer3D(graphics); // Load game configuration General.WriteLogLine("Loading game configuration..."); configinfo = General.GetConfigurationInfo(options.ConfigFile); config = new GameConfiguration(General.LoadGameConfiguration(options.ConfigFile)); configinfo.ApplyDefaults(config); General.Editing.UpdateCurrentEditModes(); // Create map data map = new MapSet(); // Initialize map format interface General.WriteLogLine("Initializing map format interface " + config.FormatInterface + "..."); io = MapSetIO.Create(config.FormatInterface, this); // Load data manager General.WriteLogLine("Loading data resources..."); data = new DataManager(); data.Load(CreateResourcesList()); // Update structures options.ApplyGridSettings(); map.UpdateConfiguration(); map.Update(); thingsfilter.Update(); // Bind any methods General.Actions.BindMethods(this); // Set defaults this.visualcamera = new VisualCamera(); General.Editing.ChangeMode(configinfo.StartMode); ClassicMode cmode = (General.Editing.Mode as ClassicMode); if (cmode != null) { cmode.SetZoom(Rendering.Renderer2D.DEFAULT_ZOOM); } renderer2d.SetViewMode((ViewMode)General.Settings.DefaultViewMode); // Success this.changed = false; General.WriteLogLine("Map creation done"); General.MainWindow.UpdateTitle(); //mxd return(true); }
// Results selection changed private void results_SelectedIndexChanged(object sender, EventArgs e) { //mxd if (bathselectioninprogress) { return; } // Anything selected? if (results.SelectedItems.Count > 0) { ErrorResult firstresult = (results.SelectedItems[0] as ErrorResult); if (firstresult == null) { ClearSelectedResult(); } else { bool sametype = true; List <ErrorResult> validresults = new List <ErrorResult>(); // Selected results have the same fixes? foreach (var ri in results.SelectedItems) { ErrorResult result = ri as ErrorResult; if (result == null) { continue; } validresults.Add(result); if (result.Buttons != firstresult.Buttons || result.Button1Text != firstresult.Button1Text || result.Button2Text != firstresult.Button2Text || result.Button3Text != firstresult.Button3Text) { sametype = false; break; } } resultinfo.Enabled = true; if (sametype) { resultinfo.Text = firstresult.Description; fix1.Text = firstresult.Button1Text; fix2.Text = firstresult.Button2Text; fix3.Text = firstresult.Button3Text; fix1.Visible = (firstresult.Buttons > 0); fix2.Visible = (firstresult.Buttons > 1); fix3.Visible = (firstresult.Buttons > 2); } else { resultinfo.Text = "Several types of map analysis results are selected. To display fixes, make sure that only a single result type is selected."; fix1.Visible = false; fix2.Visible = false; fix3.Visible = false; } // Zoom to area if (validresults.Count > 0) { RectangleF zoomarea = validresults[0].GetZoomArea(); foreach (ErrorResult result in validresults) { zoomarea = RectangleF.Union(zoomarea, result.GetZoomArea()); } ClassicMode editmode = (General.Editing.Mode as ClassicMode); editmode.CenterOnArea(zoomarea, 0.6f); } } UpdateTitle(); //mxd } else { ClearSelectedResult(); } General.Interface.RedrawDisplay(); }