/// <summary> /// Adds an object /// </summary> private void CreateObject() { if (step == 1) { mleftPressed = true; if (movedObject != null) currentObject = movedObject; else { currentObject = new ObjectInformation(); currentObject.Type = controls.SelectedObject.Type; currentObject.Texture = controls.SelectedObject.ToString(); currentObject.ParameterNames = controls.SelectedObject.Parameters; currentObject.ParameterValues = controls.SelectedObject.Parameters == null ? null : new string[controls.SelectedObject.Parameters.Length]; } currentObject.Position = camera.CameraToGlobalPos(new Vector2(Mouse.GetState().X, Mouse.GetState().Y)); if (currentObject.ParameterNames != null && currentObject.ParameterNames.Contains("Width")) currentObject.SetParameter("Width", selTexScale.X * ObjectTextures[currentObject.Texture].Width / camera.TotalScale); if (currentObject.ParameterNames != null && currentObject.ParameterNames.Contains("Height")) currentObject.SetParameter("Height", selTexScale.Y * ObjectTextures[currentObject.Texture].Height / camera.TotalScale); if (currentObject.ParameterNames != null && currentObject.ParameterNames.Contains("Scale")) currentObject.SetParameter("Scale", selTexScale); if (currentObject.ParameterNames != null && currentObject.ParameterNames.Contains("Rotation")) currentObject.SetParameter("Rotation", selTexRotation); if (currentObject.ParameterNames != null && currentObject.ParameterNames.Contains("FacingLeft")) currentObject.SetParameter("FacingLeft", selTexEffect == SpriteEffects.FlipHorizontally); if (movedObject == null) { if (currentObject.ParameterNames != null && (currentObject.ParameterNames.Contains("Radius") || currentObject.ParameterNames.Contains("Position2"))) // Add others later maybe { step = 2; return; } else step = 3; } else { movedObject = null; currentObject = null; return; } } else if (step == 2) { // Set other parameters mleftPressed = true; } if (step == 3) { UpdateIndex(); indices.Add(index); currentObject.Index = index; if (controls.SelectedObject.HasExtraParameters() && !windowOpen) { windowOpen = true; MouseState state = Mouse.GetState(); ParameterEditor editor = new ParameterEditor(); editor.Location = controls.Location; editor.Text = "ID: " + index; string[] extraParams = controls.SelectedObject.GetExtraParameters(); for (int i = 0; i < extraParams.Length; i++) { System.Windows.Forms.Label l = new System.Windows.Forms.Label(); l.Text = extraParams[i]; l.Location = new System.Drawing.Point(10, 10 + i * 30); l.Tag = i; editor.Controls.Add(l); System.Windows.Forms.TextBox t = new System.Windows.Forms.TextBox(); t.Location = new System.Drawing.Point(130, 10 + i * 30); t.Size = new System.Drawing.Size(275, t.Height); t.Tag = i; editor.Controls.Add(t); } System.Windows.Forms.DialogResult result = editor.ShowDialog(); for (int i = 0; i < editor.ParameterNames.Length; i++) currentObject.SetParameter(editor.ParameterNames[i], editor.ParameterValues[i]); windowOpen = false; } } objInfo.Add(currentObject); currentObject = null; step = 1; }
/// <summary> /// Checks the right click menu for selected choices /// </summary> private void CheckRightClickMenu() { if (rcMenu != null && rcMenu.Visible) { mleftPressed = true; string result = rcMenu.Update(Mouse.GetState()); if (result != "") { ObjectInformation obj = rcMenu.SelectedObj; if (result == "edit" && obj.HasExtraParameterNames()) { windowOpen = true; ParameterEditor editor = new ParameterEditor(); editor.Location = controls.Location; editor.Text = "ID: " + obj.Index.ToString(); string[] extraParams = obj.GetExtraParameterNames(); for (int i = 0; i < extraParams.Length; i++) { System.Windows.Forms.Label l = new System.Windows.Forms.Label(); l.Text = extraParams[i]; l.Location = new System.Drawing.Point(10, 10 + i * 30); l.Tag = i; editor.Controls.Add(l); System.Windows.Forms.TextBox t = new System.Windows.Forms.TextBox(); t.Location = new System.Drawing.Point(130, 10 + i * 30); t.Size = new System.Drawing.Size(275, t.Height); t.Text = obj.ValueFromName(extraParams[i]); t.Tag = i; editor.Controls.Add(t); } System.Windows.Forms.DialogResult dialogResult = editor.ShowDialog(); for (int i = 0; i < editor.ParameterNames.Length; i++) obj.SetParameter(editor.ParameterNames[i], editor.ParameterValues[i]); windowOpen = false; } else if (result == "delete") { indices.Remove(obj.Index); objInfo.Remove(obj); UpdateIndex(); } else if (result == "move") { movedObject = obj; step = 1; } else if (result == "scripts") { windowOpen = true; ScriptManager manager = new ScriptManager(); manager.Location = controls.Location; manager.Text = "Script Manager for Obj #" + obj.Index.ToString(); if (obj.Scripts != null) for (int i = 0; i < obj.Scripts.Count; i++) ((System.Windows.Forms.ListBox)manager.Controls["lstScripts"]).Items.Add(obj.Scripts[i]); System.Windows.Forms.DialogResult dialogResult = manager.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { obj.Scripts = new List<ScriptInformation>(); for (int i = 0; i < ((System.Windows.Forms.ListBox)manager.Controls["lstScripts"]).Items.Count; i++) obj.Scripts.Add((ScriptInformation)((System.Windows.Forms.ListBox)manager.Controls["lstScripts"]).Items[i]); } windowOpen = false; } } } }