2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#region ================== Copyright (c) 2007 Pascal vd Heiden
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Pascal vd Heiden, www.codeimp.com
|
|
|
|
* This program is released under GNU General Public License
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Namespaces
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
|
|
|
using System.IO;
|
|
|
|
using System.Reflection;
|
|
|
|
using CodeImp.DoomBuilder.Windows;
|
|
|
|
using CodeImp.DoomBuilder.IO;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Editing;
|
|
|
|
using CodeImp.DoomBuilder.Actions;
|
|
|
|
using CodeImp.DoomBuilder.VisualModes;
|
2009-07-10 08:25:04 +00:00
|
|
|
using CodeImp.DoomBuilder.Config;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
|
|
|
{
|
|
|
|
[EditMode(DisplayName = "Visual Mode",
|
|
|
|
SwitchAction = "visualmode", // Action name used to switch to this mode
|
|
|
|
ButtonImage = "VisualMode.png", // Image resource name for the button
|
|
|
|
ButtonOrder = 0, // Position of the button (lower is more to the left)
|
|
|
|
ButtonGroup = "001_visual",
|
|
|
|
UseByDefault = true)]
|
|
|
|
|
|
|
|
public class BaseVisualMode : VisualMode
|
|
|
|
{
|
|
|
|
#region ================== Constants
|
|
|
|
|
|
|
|
// Object picking
|
|
|
|
private const double PICK_INTERVAL = 80.0d;
|
|
|
|
private const float PICK_RANGE = 0.98f;
|
|
|
|
|
|
|
|
// Gravity
|
|
|
|
private const float GRAVITY = -0.06f;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Variables
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2010-01-02 20:22:05 +00:00
|
|
|
// Gravity
|
2009-05-01 20:31:17 +00:00
|
|
|
private Vector3D gravity;
|
2010-01-02 20:22:05 +00:00
|
|
|
private float cameraflooroffset = 41f; // same as in doom
|
|
|
|
private float cameraceilingoffset = 10f;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Object picking
|
|
|
|
private VisualPickResult target;
|
|
|
|
private double lastpicktime;
|
|
|
|
private bool locktarget;
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
// This is true when a selection was made because the action is performed
|
|
|
|
// on an object that was not selected. In this case the previous selection
|
|
|
|
// is cleared and the targeted object is temporarely selected to perform
|
|
|
|
// the action on. After the action is completed, the object is deselected.
|
2009-05-02 14:59:05 +00:00
|
|
|
private bool singleselection;
|
2009-04-19 18:07:22 +00:00
|
|
|
|
2009-05-02 14:59:05 +00:00
|
|
|
// We keep these to determine if we need to make a new undo level
|
|
|
|
private bool selectionchanged;
|
2009-05-05 09:50:23 +00:00
|
|
|
private int lastundogroup;
|
2009-05-02 14:59:05 +00:00
|
|
|
private VisualActionResult actionresult;
|
2009-05-03 19:22:32 +00:00
|
|
|
private bool undocreated;
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
// List of selected objects when an action is performed
|
|
|
|
private List<IVisualEventReceiver> selectedobjects;
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Properties
|
|
|
|
|
2009-05-17 14:00:36 +00:00
|
|
|
public override object HighlightedObject
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
// Geometry picked?
|
|
|
|
if(target.picked is VisualGeometry)
|
|
|
|
{
|
|
|
|
VisualGeometry pickedgeo = (target.picked as VisualGeometry);
|
|
|
|
|
|
|
|
if(pickedgeo.Sidedef != null)
|
|
|
|
return pickedgeo.Sidedef;
|
|
|
|
else if(pickedgeo.Sector != null)
|
|
|
|
return pickedgeo.Sector;
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
// Thing picked?
|
|
|
|
else if(target.picked is VisualThing)
|
|
|
|
{
|
|
|
|
VisualThing pickedthing = (target.picked as VisualThing);
|
|
|
|
return pickedthing.Thing;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
public IRenderer3D Renderer { get { return renderer; } }
|
2009-05-02 14:59:05 +00:00
|
|
|
|
|
|
|
public bool IsSingleSelection { get { return singleselection; } }
|
|
|
|
public bool SelectionChanged { get { return selectionchanged; } set { selectionchanged |= value; } }
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Constructor / Disposer
|
|
|
|
|
|
|
|
// Constructor
|
|
|
|
public BaseVisualMode()
|
|
|
|
{
|
|
|
|
// Initialize
|
|
|
|
this.gravity = new Vector3D(0.0f, 0.0f, 0.0f);
|
2009-07-07 11:29:56 +00:00
|
|
|
this.selectedobjects = new List<IVisualEventReceiver>();
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// We have no destructor
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disposer
|
|
|
|
public override void Dispose()
|
|
|
|
{
|
|
|
|
// Not already disposed?
|
|
|
|
if(!isdisposed)
|
|
|
|
{
|
|
|
|
// Clean up
|
|
|
|
|
|
|
|
// Done
|
|
|
|
base.Dispose();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Methods
|
|
|
|
|
2009-07-12 09:32:53 +00:00
|
|
|
// This calculates brightness level
|
2009-07-12 09:58:05 +00:00
|
|
|
internal int CalculateBrightness(int level)
|
2009-07-12 09:32:53 +00:00
|
|
|
{
|
2009-07-12 09:58:05 +00:00
|
|
|
return renderer.CalculateBrightness(level);
|
2009-07-12 09:32:53 +00:00
|
|
|
}
|
2012-06-02 20:25:46 +00:00
|
|
|
|
|
|
|
//mxd. This calculates brightness level with doom-style shading
|
|
|
|
internal int CalculateBrightness(int level, Sidedef sd) {
|
|
|
|
return renderer.CalculateBrightness(level, sd);
|
|
|
|
}
|
2009-07-12 09:32:53 +00:00
|
|
|
|
2009-07-07 11:29:56 +00:00
|
|
|
// This adds a selected object
|
|
|
|
internal void AddSelectedObject(IVisualEventReceiver obj)
|
|
|
|
{
|
|
|
|
selectedobjects.Add(obj);
|
|
|
|
selectionchanged = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This removes a selected object
|
|
|
|
internal void RemoveSelectedObject(IVisualEventReceiver obj)
|
|
|
|
{
|
|
|
|
selectedobjects.Remove(obj);
|
|
|
|
selectionchanged = true;
|
|
|
|
}
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
// This is called before an action is performed
|
2009-05-05 09:50:23 +00:00
|
|
|
public void PreAction(int multiselectionundogroup)
|
2009-05-01 20:31:17 +00:00
|
|
|
{
|
2009-05-02 14:59:05 +00:00
|
|
|
actionresult = new VisualActionResult();
|
2009-05-01 20:31:17 +00:00
|
|
|
|
|
|
|
PickTargetUnlocked();
|
|
|
|
|
|
|
|
// If the action is not performed on a selected object, clear the
|
|
|
|
// current selection and make a temporary selection for the target.
|
2009-07-07 11:29:56 +00:00
|
|
|
if((target.picked != null) && !target.picked.Selected && (BuilderPlug.Me.VisualModeClearSelection || (selectedobjects.Count == 0)))
|
2009-05-01 20:31:17 +00:00
|
|
|
{
|
2009-05-02 14:59:05 +00:00
|
|
|
// Single object, no selection
|
|
|
|
singleselection = true;
|
2009-05-01 20:31:17 +00:00
|
|
|
ClearSelection();
|
2009-05-03 19:22:32 +00:00
|
|
|
undocreated = false;
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
2009-05-02 14:59:05 +00:00
|
|
|
else
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
singleselection = false;
|
|
|
|
|
2009-05-02 14:59:05 +00:00
|
|
|
// Check if we should make a new undo level
|
|
|
|
// We don't want to do this if this is the same action with the same
|
|
|
|
// selection and the action wants to group the undo levels
|
2009-05-05 09:50:23 +00:00
|
|
|
if((lastundogroup != multiselectionundogroup) || (lastundogroup == UndoGroup.None) ||
|
|
|
|
(multiselectionundogroup == UndoGroup.None) || selectionchanged)
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
|
|
|
// We want to create a new undo level, but not just yet
|
2009-05-05 09:50:23 +00:00
|
|
|
lastundogroup = multiselectionundogroup;
|
2009-05-03 19:22:32 +00:00
|
|
|
undocreated = false;
|
|
|
|
}
|
|
|
|
else
|
2009-05-02 14:59:05 +00:00
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
// We don't want to make a new undo level (changes will be combined)
|
|
|
|
undocreated = true;
|
2009-05-02 14:59:05 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
|
|
|
|
2009-07-07 11:29:56 +00:00
|
|
|
// Called before an action is performed. This does not make an undo level
|
2009-05-03 19:22:32 +00:00
|
|
|
private void PreActionNoChange()
|
|
|
|
{
|
|
|
|
actionresult = new VisualActionResult();
|
|
|
|
singleselection = false;
|
|
|
|
undocreated = false;
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
2009-05-02 14:59:05 +00:00
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
// This is called after an action is performed
|
2009-05-02 14:59:05 +00:00
|
|
|
private void PostAction()
|
2009-05-01 20:31:17 +00:00
|
|
|
{
|
2009-05-02 14:59:05 +00:00
|
|
|
if(!string.IsNullOrEmpty(actionresult.displaystatus))
|
|
|
|
General.Interface.DisplayStatus(StatusType.Action, actionresult.displaystatus);
|
2009-05-04 06:13:56 +00:00
|
|
|
|
|
|
|
// Reset changed flags
|
|
|
|
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
|
|
|
|
{
|
|
|
|
BaseVisualSector bvs = (vs.Value as BaseVisualSector);
|
|
|
|
bvs.Floor.Changed = false;
|
|
|
|
bvs.Ceiling.Changed = false;
|
|
|
|
}
|
2009-05-05 11:26:50 +00:00
|
|
|
|
2009-05-02 14:59:05 +00:00
|
|
|
selectionchanged = false;
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
if(singleselection)
|
|
|
|
ClearSelection();
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
UpdateChangedObjects();
|
|
|
|
ShowTargetInfo();
|
|
|
|
}
|
2009-05-02 14:59:05 +00:00
|
|
|
|
|
|
|
// This sets the result for an action
|
|
|
|
public void SetActionResult(VisualActionResult result)
|
|
|
|
{
|
|
|
|
actionresult = result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This sets the result for an action
|
|
|
|
public void SetActionResult(string displaystatus)
|
|
|
|
{
|
|
|
|
actionresult = new VisualActionResult();
|
|
|
|
actionresult.displaystatus = displaystatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This creates an undo, when only a single selection is made
|
|
|
|
// When a multi-selection is made, the undo is created by the PreAction function
|
2009-05-05 09:50:23 +00:00
|
|
|
public int CreateUndo(string description, int group, int grouptag)
|
2009-05-02 14:59:05 +00:00
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
if(!undocreated)
|
|
|
|
{
|
|
|
|
undocreated = true;
|
|
|
|
|
|
|
|
if(singleselection)
|
2009-05-05 09:50:23 +00:00
|
|
|
return General.Map.UndoRedo.CreateUndo(description, this, group, grouptag);
|
2009-05-03 19:22:32 +00:00
|
|
|
else
|
2009-05-05 09:50:23 +00:00
|
|
|
return General.Map.UndoRedo.CreateUndo(description, this, UndoGroup.None, 0);
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-05-02 14:59:05 +00:00
|
|
|
else
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
2009-05-02 14:59:05 +00:00
|
|
|
return 0;
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-05-02 14:59:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This creates an undo, when only a single selection is made
|
|
|
|
// When a multi-selection is made, the undo is created by the PreAction function
|
2009-05-03 19:22:32 +00:00
|
|
|
public int CreateUndo(string description)
|
2009-05-02 14:59:05 +00:00
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
return CreateUndo(description, UndoGroup.None, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This makes a list of the selected object
|
2009-07-07 11:29:56 +00:00
|
|
|
private void RebuildSelectedObjectsList()
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
|
|
|
// Make list of selected objects
|
|
|
|
selectedobjects = new List<IVisualEventReceiver>();
|
|
|
|
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
|
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vs.Value != null)
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
|
|
|
|
if((bvs.Floor != null) && bvs.Floor.Selected) selectedobjects.Add(bvs.Floor);
|
|
|
|
if((bvs.Ceiling != null) && bvs.Ceiling.Selected) selectedobjects.Add(bvs.Ceiling);
|
|
|
|
foreach(Sidedef sd in vs.Key.Sidedefs)
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
List<VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd);
|
|
|
|
foreach(VisualGeometry sdg in sidedefgeos)
|
|
|
|
{
|
|
|
|
if(sdg.Selected) selectedobjects.Add((sdg as IVisualEventReceiver));
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
|
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vt.Value != null)
|
|
|
|
{
|
|
|
|
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
|
|
|
|
if(bvt.Selected) selectedobjects.Add(bvt);
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-05-02 14:59:05 +00:00
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// This creates a visual sector
|
|
|
|
protected override VisualSector CreateVisualSector(Sector s)
|
|
|
|
{
|
|
|
|
BaseVisualSector vs = new BaseVisualSector(this, s);
|
|
|
|
return vs;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This creates a visual thing
|
|
|
|
protected override VisualThing CreateVisualThing(Thing t)
|
|
|
|
{
|
|
|
|
BaseVisualThing vt = new BaseVisualThing(this, t);
|
2009-05-01 20:31:17 +00:00
|
|
|
return vt.Setup() ? vt : null;
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// This locks the target so that it isn't changed until unlocked
|
|
|
|
public void LockTarget()
|
|
|
|
{
|
|
|
|
locktarget = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This unlocks the target so that is changes to the aimed geometry again
|
|
|
|
public void UnlockTarget()
|
|
|
|
{
|
|
|
|
locktarget = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This picks a new target, if not locked
|
|
|
|
private void PickTargetUnlocked()
|
|
|
|
{
|
|
|
|
if(!locktarget) PickTarget();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This picks a new target
|
|
|
|
private void PickTarget()
|
|
|
|
{
|
|
|
|
// Find the object we are aiming at
|
|
|
|
Vector3D start = General.Map.VisualCamera.Position;
|
|
|
|
Vector3D delta = General.Map.VisualCamera.Target - General.Map.VisualCamera.Position;
|
|
|
|
delta = delta.GetFixedLength(General.Settings.ViewDistance * PICK_RANGE);
|
|
|
|
VisualPickResult newtarget = PickObject(start, start + delta);
|
|
|
|
|
|
|
|
// Should we update the info on panels?
|
|
|
|
bool updateinfo = (newtarget.picked != target.picked);
|
|
|
|
|
|
|
|
// Apply new target
|
|
|
|
target = newtarget;
|
|
|
|
|
|
|
|
// Show target info
|
|
|
|
if(updateinfo) ShowTargetInfo();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This shows the picked target information
|
|
|
|
public void ShowTargetInfo()
|
|
|
|
{
|
|
|
|
// Any result?
|
|
|
|
if(target.picked != null)
|
|
|
|
{
|
|
|
|
// Geometry picked?
|
|
|
|
if(target.picked is VisualGeometry)
|
|
|
|
{
|
|
|
|
VisualGeometry pickedgeo = (target.picked as VisualGeometry);
|
|
|
|
|
|
|
|
if(pickedgeo.Sidedef != null)
|
|
|
|
General.Interface.ShowLinedefInfo(pickedgeo.Sidedef.Line);
|
|
|
|
else if(pickedgeo.Sidedef == null)
|
|
|
|
General.Interface.ShowSectorInfo(pickedgeo.Sector.Sector);
|
|
|
|
else
|
|
|
|
General.Interface.HideInfo();
|
|
|
|
}
|
|
|
|
// Thing picked?
|
|
|
|
if(target.picked is VisualThing)
|
|
|
|
{
|
|
|
|
VisualThing pickedthing = (target.picked as VisualThing);
|
|
|
|
General.Interface.ShowThingInfo(pickedthing.Thing);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
General.Interface.HideInfo();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
// This updates the VisualSectors and VisualThings that have their Changed property set
|
|
|
|
private void UpdateChangedObjects()
|
|
|
|
{
|
|
|
|
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
|
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vs.Value != null)
|
|
|
|
{
|
|
|
|
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
|
|
|
|
if(bvs.Changed) bvs.Rebuild();
|
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
|
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vt.Value != null)
|
|
|
|
{
|
|
|
|
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
|
|
|
|
if(bvt.Changed) bvt.Rebuild();
|
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-29 14:03:35 +00:00
|
|
|
|
|
|
|
//mxd
|
2012-06-29 18:58:18 +00:00
|
|
|
protected override void moveSelectedThings(Vector2D direction, bool absolutePosition) {
|
2012-06-29 14:03:35 +00:00
|
|
|
List<VisualThing> things = GetSelectedVisualThings(true);
|
|
|
|
|
|
|
|
if (things.Count == 0) {
|
|
|
|
General.Interface.DisplayStatus(StatusType.Warning, "Select some Things first!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-06-29 18:58:18 +00:00
|
|
|
//move things...
|
|
|
|
if (!absolutePosition) { //...relatively (that's easy)
|
|
|
|
int camAngle = (int)Math.Round(General.Map.VisualCamera.AngleXY * 180 / Math.PI);
|
|
|
|
int sector = (int)(General.ClampAngle(camAngle - 45f) / 90f);
|
|
|
|
direction = direction.GetRotated((float)(sector * Math.PI / 2f));
|
|
|
|
|
|
|
|
for (int i = 0; i < things.Count; i++) {
|
|
|
|
BaseVisualThing t = things[i] as BaseVisualThing;
|
|
|
|
t.OnMove(t.Thing.Position + new Vector3D(direction));
|
|
|
|
}
|
|
|
|
} else { //...to specified location preserving relative positioning (that's harder)
|
|
|
|
if (things.Count == 1) {//just move it there
|
|
|
|
BaseVisualThing t = things[0] as BaseVisualThing;
|
|
|
|
t.OnMove(new Vector3D(direction.x, direction.y, t.Thing.Position.z));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//we need some reference
|
|
|
|
float minX = things[0].Thing.Position.x;
|
|
|
|
float maxX = minX;
|
|
|
|
float minY = things[0].Thing.Position.y;
|
|
|
|
float maxY = minY;
|
|
|
|
|
|
|
|
//get bounding coordinates for selected things
|
|
|
|
for (int i = 1; i < things.Count; i++) {
|
|
|
|
if (things[i].Thing.Position.x < minX)
|
|
|
|
minX = things[i].Thing.Position.x;
|
|
|
|
else if (things[i].Thing.Position.x > maxX)
|
|
|
|
maxX = things[i].Thing.Position.x;
|
|
|
|
|
|
|
|
if (things[i].Thing.Position.y < minY)
|
|
|
|
minY = things[i].Thing.Position.y;
|
|
|
|
else if (things[i].Thing.Position.y > maxY)
|
|
|
|
maxY = things[i].Thing.Position.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
Vector2D selectionCenter = new Vector2D(minX + (maxX - minX) / 2, minY + (maxY - minY) / 2);
|
|
|
|
|
|
|
|
//move them
|
|
|
|
for (int i = 0; i < things.Count; i++) {
|
|
|
|
BaseVisualThing t = things[i] as BaseVisualThing;
|
|
|
|
t.OnMove(new Vector3D(direction.x - (selectionCenter.x - t.Thing.Position.x), direction.y - (selectionCenter.y - t.Thing.Position.y), t.Thing.Position.z));
|
|
|
|
}
|
2012-06-29 14:03:35 +00:00
|
|
|
}
|
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region ================== Events
|
|
|
|
|
2009-04-26 21:21:55 +00:00
|
|
|
// Help!
|
|
|
|
public override void OnHelp()
|
|
|
|
{
|
|
|
|
General.ShowHelp("e_visual.html");
|
|
|
|
}
|
2009-06-17 21:56:07 +00:00
|
|
|
|
2010-01-02 20:22:05 +00:00
|
|
|
// When entering this mode
|
|
|
|
public override void OnEngage()
|
|
|
|
{
|
|
|
|
base.OnEngage();
|
|
|
|
|
|
|
|
// Read settings
|
|
|
|
cameraflooroffset = General.Map.Config.ReadSetting("cameraflooroffset", cameraflooroffset);
|
|
|
|
cameraceilingoffset = General.Map.Config.ReadSetting("cameraceilingoffset", cameraceilingoffset);
|
|
|
|
}
|
|
|
|
|
2009-06-17 21:56:07 +00:00
|
|
|
// When returning to another mode
|
|
|
|
public override void OnDisengage()
|
|
|
|
{
|
|
|
|
base.OnDisengage();
|
|
|
|
General.Map.Map.Update();
|
|
|
|
}
|
2009-04-26 21:21:55 +00:00
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Processing
|
|
|
|
public override void OnProcess(double deltatime)
|
|
|
|
{
|
|
|
|
// Process things?
|
|
|
|
base.ProcessThings = (BuilderPlug.Me.ShowVisualThings != 0);
|
|
|
|
|
|
|
|
// Setup the move multiplier depending on gravity
|
|
|
|
Vector3D movemultiplier = new Vector3D(1.0f, 1.0f, 1.0f);
|
|
|
|
if(BuilderPlug.Me.UseGravity) movemultiplier.z = 0.0f;
|
|
|
|
General.Map.VisualCamera.MoveMultiplier = movemultiplier;
|
|
|
|
|
|
|
|
// Apply gravity?
|
|
|
|
if(BuilderPlug.Me.UseGravity && (General.Map.VisualCamera.Sector != null))
|
|
|
|
{
|
|
|
|
// Camera below floor level?
|
2010-01-02 20:22:05 +00:00
|
|
|
if(General.Map.VisualCamera.Position.z <= (General.Map.VisualCamera.Sector.FloorHeight + cameraflooroffset + 0.1f))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Stay above floor
|
|
|
|
gravity = new Vector3D(0.0f, 0.0f, 0.0f);
|
|
|
|
General.Map.VisualCamera.Position = new Vector3D(General.Map.VisualCamera.Position.x,
|
|
|
|
General.Map.VisualCamera.Position.y,
|
2010-01-02 20:22:05 +00:00
|
|
|
General.Map.VisualCamera.Sector.FloorHeight + cameraflooroffset);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Fall down
|
|
|
|
gravity += new Vector3D(0.0f, 0.0f, (float)(GRAVITY * deltatime));
|
|
|
|
General.Map.VisualCamera.Position += gravity;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Camera above ceiling level?
|
2010-01-02 20:22:05 +00:00
|
|
|
if(General.Map.VisualCamera.Position.z >= (General.Map.VisualCamera.Sector.CeilHeight - cameraceilingoffset - 0.1f))
|
2009-04-19 18:07:22 +00:00
|
|
|
{
|
|
|
|
// Stay below ceiling
|
|
|
|
General.Map.VisualCamera.Position = new Vector3D(General.Map.VisualCamera.Position.x,
|
|
|
|
General.Map.VisualCamera.Position.y,
|
2010-01-02 20:22:05 +00:00
|
|
|
General.Map.VisualCamera.Sector.CeilHeight - cameraceilingoffset);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gravity = new Vector3D(0.0f, 0.0f, 0.0f);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do processing
|
|
|
|
base.OnProcess(deltatime);
|
|
|
|
|
|
|
|
// Process visible geometry
|
|
|
|
foreach(IVisualEventReceiver g in visiblegeometry)
|
|
|
|
{
|
|
|
|
g.OnProcess(deltatime);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Time to pick a new target?
|
|
|
|
if(General.Clock.CurrentTime > (lastpicktime + PICK_INTERVAL))
|
|
|
|
{
|
|
|
|
PickTargetUnlocked();
|
|
|
|
lastpicktime = General.Clock.CurrentTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The mouse is always in motion
|
|
|
|
MouseEventArgs args = new MouseEventArgs(General.Interface.MouseButtons, 0, 0, 0, 0);
|
|
|
|
OnMouseMove(args);
|
|
|
|
}
|
|
|
|
|
|
|
|
// This draws a frame
|
|
|
|
public override void OnRedrawDisplay()
|
|
|
|
{
|
|
|
|
// Start drawing
|
|
|
|
if(renderer.Start())
|
|
|
|
{
|
|
|
|
// Use fog!
|
|
|
|
renderer.SetFogMode(true);
|
|
|
|
|
|
|
|
// Set target for highlighting
|
2009-07-07 14:52:39 +00:00
|
|
|
if(BuilderPlug.Me.UseHighlight)
|
|
|
|
renderer.SetHighlightedObject(target.picked);
|
2009-04-19 18:07:22 +00:00
|
|
|
|
|
|
|
// Begin with geometry
|
|
|
|
renderer.StartGeometry();
|
|
|
|
|
|
|
|
// Render all visible sectors
|
|
|
|
foreach(VisualGeometry g in visiblegeometry)
|
|
|
|
renderer.AddSectorGeometry(g);
|
|
|
|
|
|
|
|
if(BuilderPlug.Me.ShowVisualThings != 0)
|
|
|
|
{
|
|
|
|
// Render things in cages?
|
|
|
|
renderer.DrawThingCages = ((BuilderPlug.Me.ShowVisualThings & 2) != 0);
|
|
|
|
|
|
|
|
// Render all visible things
|
|
|
|
foreach(VisualThing t in visiblethings)
|
|
|
|
renderer.AddThingGeometry(t);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Done rendering geometry
|
|
|
|
renderer.FinishGeometry();
|
|
|
|
|
|
|
|
// Render crosshair
|
|
|
|
renderer.RenderCrosshair();
|
|
|
|
|
|
|
|
// Present!
|
|
|
|
renderer.Finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// After resources were reloaded
|
|
|
|
protected override void ResourcesReloaded()
|
|
|
|
{
|
|
|
|
base.ResourcesReloaded();
|
|
|
|
PickTarget();
|
|
|
|
}
|
|
|
|
|
2009-06-16 08:49:14 +00:00
|
|
|
// This usually happens when geometry is changed by undo, redo, cut or paste actions
|
|
|
|
// and uses the marks to check what needs to be reloaded.
|
2009-06-11 21:21:20 +00:00
|
|
|
protected override void ResourcesReloadedPartial()
|
|
|
|
{
|
2009-06-16 08:49:14 +00:00
|
|
|
bool sectorsmarked = false;
|
|
|
|
|
2009-07-07 15:11:09 +00:00
|
|
|
if(General.Map.UndoRedo.GeometryChanged)
|
2009-06-16 08:49:14 +00:00
|
|
|
{
|
|
|
|
// Let the core do this (it will just dispose the sectors that were changed)
|
|
|
|
base.ResourcesReloadedPartial();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Neighbour sectors must be updated as well
|
|
|
|
foreach(Sector s in General.Map.Map.Sectors)
|
|
|
|
{
|
|
|
|
if(s.Marked)
|
|
|
|
{
|
|
|
|
sectorsmarked = true;
|
|
|
|
foreach(Sidedef sd in s.Sidedefs)
|
2009-06-27 09:45:35 +00:00
|
|
|
{
|
|
|
|
sd.Marked = true;
|
2009-06-16 08:49:14 +00:00
|
|
|
if(sd.Other != null) sd.Other.Marked = true;
|
2009-06-27 09:45:35 +00:00
|
|
|
}
|
2009-06-16 08:49:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go for all sidedefs to update
|
|
|
|
foreach(Sidedef sd in General.Map.Map.Sidedefs)
|
|
|
|
{
|
2009-06-16 18:28:33 +00:00
|
|
|
if(sd.Marked && VisualSectorExists(sd.Sector))
|
2009-06-16 08:49:14 +00:00
|
|
|
{
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(sd.Sector);
|
|
|
|
VisualSidedefParts parts = vs.GetSidedefParts(sd);
|
|
|
|
parts.SetupAllParts();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Go for all sectors to update
|
|
|
|
foreach(Sector s in General.Map.Map.Sectors)
|
|
|
|
{
|
2009-06-16 18:28:33 +00:00
|
|
|
if(s.Marked && VisualSectorExists(s))
|
2009-06-16 08:49:14 +00:00
|
|
|
{
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)GetVisualSector(s);
|
|
|
|
vs.Floor.Setup();
|
|
|
|
vs.Ceiling.Setup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!sectorsmarked)
|
|
|
|
{
|
|
|
|
// No sectors or geometry changed. So we only have
|
|
|
|
// to update things when they have changed.
|
|
|
|
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
|
2011-12-02 23:11:16 +00:00
|
|
|
if((vt.Value != null) && vt.Key.Marked) (vt.Value as BaseVisualThing).Rebuild();
|
2009-06-16 08:49:14 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Things depend on the sector they are in and because we can't
|
|
|
|
// easily determine which ones changed, we dispose all things
|
|
|
|
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vt.Value != null) vt.Value.Dispose();
|
2009-07-05 09:40:18 +00:00
|
|
|
|
|
|
|
// Apply new lists
|
|
|
|
allthings = new Dictionary<Thing, VisualThing>(allthings.Count);
|
2009-06-16 08:49:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Clear visibility collections
|
|
|
|
visiblesectors.Clear();
|
|
|
|
visibleblocks.Clear();
|
|
|
|
visiblegeometry.Clear();
|
|
|
|
visiblethings.Clear();
|
|
|
|
|
|
|
|
// Make new blockmap
|
2010-08-01 18:49:46 +00:00
|
|
|
if(sectorsmarked || General.Map.UndoRedo.PopulationChanged)
|
2009-07-05 09:40:18 +00:00
|
|
|
FillBlockMap();
|
2009-06-16 08:49:14 +00:00
|
|
|
|
|
|
|
// Visibility culling (this re-creates the needed resources)
|
|
|
|
DoCulling();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Determine what we're aiming at now
|
2009-06-11 21:21:20 +00:00
|
|
|
PickTarget();
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
// Mouse moves
|
|
|
|
public override void OnMouseMove(MouseEventArgs e)
|
|
|
|
{
|
|
|
|
base.OnMouseMove(e);
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(true).OnMouseMove(e);
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 09:50:23 +00:00
|
|
|
// Undo performed
|
|
|
|
public override void OnUndoEnd()
|
|
|
|
{
|
|
|
|
base.OnUndoEnd();
|
2009-07-07 11:29:56 +00:00
|
|
|
RebuildSelectedObjectsList();
|
|
|
|
|
2009-05-05 09:50:23 +00:00
|
|
|
// We can't group with this undo level anymore
|
|
|
|
lastundogroup = UndoGroup.None;
|
|
|
|
}
|
|
|
|
|
2009-07-07 11:29:56 +00:00
|
|
|
// Redo performed
|
|
|
|
public override void OnRedoEnd()
|
|
|
|
{
|
|
|
|
base.OnRedoEnd();
|
|
|
|
RebuildSelectedObjectsList();
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#endregion
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
#region ================== Action Assist
|
|
|
|
|
|
|
|
// Because some actions can only be called on a single (the targeted) object because
|
|
|
|
// they show a dialog window or something, these functions help applying the result
|
|
|
|
// to all compatible selected objects.
|
|
|
|
|
|
|
|
// Apply texture offsets
|
|
|
|
public void ApplyTextureOffsetChange(int dx, int dy)
|
|
|
|
{
|
2009-05-04 06:13:56 +00:00
|
|
|
Dictionary<Sidedef, int> donesides = new Dictionary<Sidedef, int>(selectedobjects.Count);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false);
|
|
|
|
foreach(IVisualEventReceiver i in objs)
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
2009-05-04 06:13:56 +00:00
|
|
|
if(i is BaseVisualGeometrySidedef)
|
|
|
|
{
|
|
|
|
if(!donesides.ContainsKey((i as BaseVisualGeometrySidedef).Sidedef))
|
|
|
|
{
|
|
|
|
i.OnChangeTextureOffset(dx, dy);
|
|
|
|
donesides.Add((i as BaseVisualGeometrySidedef).Sidedef, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply upper unpegged flag
|
|
|
|
public void ApplyUpperUnpegged(bool set)
|
|
|
|
{
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs)
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
|
|
|
i.ApplyUpperUnpegged(set);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply lower unpegged flag
|
|
|
|
public void ApplyLowerUnpegged(bool set)
|
|
|
|
{
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs)
|
2009-05-03 19:22:32 +00:00
|
|
|
{
|
|
|
|
i.ApplyLowerUnpegged(set);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Apply texture change
|
|
|
|
public void ApplySelectTexture(string texture, bool flat)
|
|
|
|
{
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs;
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
if(General.Map.Config.MixTexturesFlats)
|
|
|
|
{
|
|
|
|
// Apply on all compatible types
|
2009-07-11 10:28:58 +00:00
|
|
|
objs = GetSelectedObjects(true, true, false);
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-07-11 10:28:58 +00:00
|
|
|
// We don't want to mix textures and flats, so apply only on the appropriate type
|
|
|
|
objs = GetSelectedObjects(flat, !flat, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(IVisualEventReceiver i in objs)
|
|
|
|
{
|
|
|
|
i.ApplyTexture(texture);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// This returns all selected objects
|
|
|
|
internal List<IVisualEventReceiver> GetSelectedObjects(bool includesectors, bool includesidedefs, bool includethings)
|
|
|
|
{
|
|
|
|
List<IVisualEventReceiver> objs = new List<IVisualEventReceiver>();
|
|
|
|
foreach(IVisualEventReceiver i in selectedobjects)
|
|
|
|
{
|
|
|
|
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
|
|
|
|
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
|
|
|
|
else if((i is BaseVisualThing) && includethings) objs.Add(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add highlight?
|
|
|
|
if(selectedobjects.Count == 0)
|
|
|
|
{
|
|
|
|
IVisualEventReceiver i = (target.picked as IVisualEventReceiver);
|
|
|
|
if((i is BaseVisualGeometrySector) && includesectors) objs.Add(i);
|
|
|
|
else if((i is BaseVisualGeometrySidedef) && includesidedefs) objs.Add(i);
|
|
|
|
else if((i is BaseVisualThing) && includethings) objs.Add(i);
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-07-11 10:28:58 +00:00
|
|
|
|
|
|
|
return objs;
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
|
|
|
|
2009-05-05 19:12:36 +00:00
|
|
|
// This returns all selected sectors, no doubles
|
2009-05-03 19:22:32 +00:00
|
|
|
public List<Sector> GetSelectedSectors()
|
|
|
|
{
|
2009-05-05 19:12:36 +00:00
|
|
|
Dictionary<Sector, int> added = new Dictionary<Sector, int>();
|
2009-05-03 19:22:32 +00:00
|
|
|
List<Sector> sectors = new List<Sector>();
|
|
|
|
foreach(IVisualEventReceiver i in selectedobjects)
|
|
|
|
{
|
2009-05-05 19:12:36 +00:00
|
|
|
if(i is BaseVisualGeometrySector)
|
|
|
|
{
|
|
|
|
Sector s = (i as BaseVisualGeometrySector).Sector.Sector;
|
|
|
|
if(!added.ContainsKey(s))
|
|
|
|
{
|
|
|
|
sectors.Add(s);
|
|
|
|
added.Add(s, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-07-11 10:28:58 +00:00
|
|
|
|
|
|
|
// Add highlight?
|
|
|
|
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySector))
|
|
|
|
{
|
|
|
|
Sector s = (target.picked as BaseVisualGeometrySector).Sector.Sector;
|
|
|
|
if(!added.ContainsKey(s))
|
|
|
|
sectors.Add(s);
|
|
|
|
}
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
return sectors;
|
|
|
|
}
|
|
|
|
|
2009-05-05 19:12:36 +00:00
|
|
|
// This returns all selected linedefs, no doubles
|
2009-05-03 19:22:32 +00:00
|
|
|
public List<Linedef> GetSelectedLinedefs()
|
|
|
|
{
|
2009-05-05 19:12:36 +00:00
|
|
|
Dictionary<Linedef, int> added = new Dictionary<Linedef, int>();
|
2009-05-03 19:22:32 +00:00
|
|
|
List<Linedef> linedefs = new List<Linedef>();
|
|
|
|
foreach(IVisualEventReceiver i in selectedobjects)
|
|
|
|
{
|
2009-05-05 19:12:36 +00:00
|
|
|
if(i is BaseVisualGeometrySidedef)
|
|
|
|
{
|
|
|
|
Linedef l = (i as BaseVisualGeometrySidedef).Sidedef.Line;
|
|
|
|
if(!added.ContainsKey(l))
|
|
|
|
{
|
|
|
|
linedefs.Add(l);
|
|
|
|
added.Add(l, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-07-11 10:28:58 +00:00
|
|
|
|
|
|
|
// Add highlight?
|
|
|
|
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
|
|
|
|
{
|
|
|
|
Linedef l = (target.picked as BaseVisualGeometrySidedef).Sidedef.Line;
|
|
|
|
if(!added.ContainsKey(l))
|
|
|
|
linedefs.Add(l);
|
|
|
|
}
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
return linedefs;
|
|
|
|
}
|
|
|
|
|
2009-06-12 09:44:38 +00:00
|
|
|
// This returns all selected sidedefs, no doubles
|
|
|
|
public List<Sidedef> GetSelectedSidedefs()
|
|
|
|
{
|
|
|
|
Dictionary<Sidedef, int> added = new Dictionary<Sidedef, int>();
|
|
|
|
List<Sidedef> sidedefs = new List<Sidedef>();
|
|
|
|
foreach(IVisualEventReceiver i in selectedobjects)
|
|
|
|
{
|
|
|
|
if(i is BaseVisualGeometrySidedef)
|
|
|
|
{
|
|
|
|
Sidedef sd = (i as BaseVisualGeometrySidedef).Sidedef;
|
|
|
|
if(!added.ContainsKey(sd))
|
|
|
|
{
|
|
|
|
sidedefs.Add(sd);
|
|
|
|
added.Add(sd, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-07-11 10:28:58 +00:00
|
|
|
|
|
|
|
// Add highlight?
|
|
|
|
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
|
|
|
|
{
|
|
|
|
Sidedef sd = (target.picked as BaseVisualGeometrySidedef).Sidedef;
|
|
|
|
if(!added.ContainsKey(sd))
|
|
|
|
sidedefs.Add(sd);
|
|
|
|
}
|
|
|
|
|
2009-06-12 09:44:38 +00:00
|
|
|
return sidedefs;
|
|
|
|
}
|
|
|
|
|
2009-05-05 19:12:36 +00:00
|
|
|
// This returns all selected things, no doubles
|
2009-05-03 19:22:32 +00:00
|
|
|
public List<Thing> GetSelectedThings()
|
|
|
|
{
|
2009-05-05 19:12:36 +00:00
|
|
|
Dictionary<Thing, int> added = new Dictionary<Thing, int>();
|
2009-05-03 19:22:32 +00:00
|
|
|
List<Thing> things = new List<Thing>();
|
|
|
|
foreach(IVisualEventReceiver i in selectedobjects)
|
|
|
|
{
|
2009-05-05 19:12:36 +00:00
|
|
|
if(i is BaseVisualThing)
|
|
|
|
{
|
|
|
|
Thing t = (i as BaseVisualThing).Thing;
|
|
|
|
if(!added.ContainsKey(t))
|
|
|
|
{
|
|
|
|
things.Add(t);
|
|
|
|
added.Add(t, 0);
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 19:22:32 +00:00
|
|
|
}
|
2009-07-11 10:28:58 +00:00
|
|
|
|
|
|
|
// Add highlight?
|
|
|
|
if((selectedobjects.Count == 0) && (target.picked is BaseVisualThing))
|
|
|
|
{
|
|
|
|
Thing t = (target.picked as BaseVisualThing).Thing;
|
|
|
|
if(!added.ContainsKey(t))
|
|
|
|
things.Add(t);
|
|
|
|
}
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
return things;
|
|
|
|
}
|
2009-07-07 11:29:56 +00:00
|
|
|
|
|
|
|
// This returns the IVisualEventReceiver on which the action must be performed
|
|
|
|
private IVisualEventReceiver GetTargetEventReceiver(bool targetonly)
|
|
|
|
{
|
|
|
|
if(target.picked != null)
|
|
|
|
{
|
|
|
|
if(singleselection || target.picked.Selected || targetonly)
|
|
|
|
{
|
|
|
|
return (IVisualEventReceiver)target.picked;
|
|
|
|
}
|
|
|
|
else if(selectedobjects.Count > 0)
|
|
|
|
{
|
|
|
|
return selectedobjects[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return (IVisualEventReceiver)target.picked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return new NullVisualEventReceiver();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-03 19:22:32 +00:00
|
|
|
#endregion
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
#region ================== Actions
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
[BeginAction("clearselection", BaseAction = true)]
|
|
|
|
public void ClearSelection()
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
selectedobjects = new List<IVisualEventReceiver>();
|
|
|
|
|
2009-05-01 20:31:17 +00:00
|
|
|
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
|
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vs.Value != null)
|
2009-05-01 20:31:17 +00:00
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
|
|
|
|
if(bvs.Floor != null) bvs.Floor.Selected = false;
|
|
|
|
if(bvs.Ceiling != null) bvs.Ceiling.Selected = false;
|
|
|
|
foreach(Sidedef sd in vs.Key.Sidedefs)
|
2009-05-01 20:31:17 +00:00
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
List<VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd);
|
|
|
|
foreach(VisualGeometry sdg in sidedefgeos)
|
|
|
|
{
|
|
|
|
sdg.Selected = false;
|
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
|
|
|
|
{
|
2011-12-02 23:11:16 +00:00
|
|
|
if(vt.Value != null)
|
|
|
|
{
|
|
|
|
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
|
|
|
|
bvt.Selected = false;
|
|
|
|
}
|
2009-05-01 20:31:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
[BeginAction("visualselect", BaseAction = true)]
|
|
|
|
public void BeginSelect()
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
PreActionNoChange();
|
2009-04-19 18:07:22 +00:00
|
|
|
PickTargetUnlocked();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(true).OnSelectBegin();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[EndAction("visualselect", BaseAction = true)]
|
|
|
|
public void EndSelect()
|
|
|
|
{
|
2009-07-11 10:28:58 +00:00
|
|
|
//PreActionNoChange();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(true).OnSelectEnd();
|
2009-07-07 14:52:39 +00:00
|
|
|
Renderer.ShowSelection = true;
|
|
|
|
Renderer.ShowHighlight = true;
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("visualedit", BaseAction = true)]
|
|
|
|
public void BeginEdit()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnEditBegin();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[EndAction("visualedit", BaseAction = true)]
|
|
|
|
public void EndEdit()
|
|
|
|
{
|
2009-07-11 10:28:58 +00:00
|
|
|
PreActionNoChange();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnEditEnd();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("raisesector8")]
|
|
|
|
public void RaiseSector8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.SectorHeightChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(8);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("lowersector8")]
|
|
|
|
public void LowerSector8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.SectorHeightChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-8);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("raisesector1")]
|
|
|
|
public void RaiseSector1()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.SectorHeightChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(1);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("lowersector1")]
|
|
|
|
public void LowerSector1()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.SectorHeightChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-1);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("showvisualthings")]
|
|
|
|
public void ShowVisualThings()
|
|
|
|
{
|
|
|
|
BuilderPlug.Me.ShowVisualThings++;
|
|
|
|
if(BuilderPlug.Me.ShowVisualThings > 2) BuilderPlug.Me.ShowVisualThings = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("raisebrightness8")]
|
|
|
|
public void RaiseBrightness8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.SectorBrightnessChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(true);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("lowerbrightness8")]
|
|
|
|
public void LowerBrightness8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.SectorBrightnessChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(false);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetextureleft")]
|
|
|
|
public void MoveTextureLeft1()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-1, 0);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetextureright")]
|
|
|
|
public void MoveTextureRight1()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(1, 0);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetextureup")]
|
|
|
|
public void MoveTextureUp1()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -1);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetexturedown")]
|
|
|
|
public void MoveTextureDown1()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 1);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetextureleft8")]
|
|
|
|
public void MoveTextureLeft8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(-8, 0);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetextureright8")]
|
|
|
|
public void MoveTextureRight8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(8, 0);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetextureup8")]
|
|
|
|
public void MoveTextureUp8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, -8);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("movetexturedown8")]
|
|
|
|
public void MoveTextureDown8()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.TextureOffsetChange);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureOffset(0, 8);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("textureselect")]
|
|
|
|
public void TextureSelect()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.SetCrosshairBusy(true);
|
|
|
|
General.Interface.RedrawDisplay();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnSelectTexture();
|
2009-05-01 20:31:17 +00:00
|
|
|
UpdateChangedObjects();
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.SetCrosshairBusy(false);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("texturecopy")]
|
|
|
|
public void TextureCopy()
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
PreActionNoChange();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnCopyTexture();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("texturepaste")]
|
|
|
|
public void TexturePaste()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnPasteTexture();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("visualautoalignx")]
|
|
|
|
public void TextureAutoAlignX()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.SetCrosshairBusy(true);
|
|
|
|
General.Interface.RedrawDisplay();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnTextureAlign(true, false);
|
2009-05-01 20:31:17 +00:00
|
|
|
UpdateChangedObjects();
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.SetCrosshairBusy(false);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("visualautoaligny")]
|
|
|
|
public void TextureAutoAlignY()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.SetCrosshairBusy(true);
|
|
|
|
General.Interface.RedrawDisplay();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnTextureAlign(false, true);
|
2009-05-01 20:31:17 +00:00
|
|
|
UpdateChangedObjects();
|
2009-04-19 18:07:22 +00:00
|
|
|
renderer.SetCrosshairBusy(false);
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("toggleupperunpegged")]
|
|
|
|
public void ToggleUpperUnpegged()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnToggleUpperUnpegged();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("togglelowerunpegged")]
|
|
|
|
public void ToggleLowerUnpegged()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnToggleLowerUnpegged();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("togglegravity")]
|
|
|
|
public void ToggleGravity()
|
|
|
|
{
|
|
|
|
BuilderPlug.Me.UseGravity = !BuilderPlug.Me.UseGravity;
|
|
|
|
string onoff = BuilderPlug.Me.UseGravity ? "ON" : "OFF";
|
|
|
|
General.Interface.DisplayStatus(StatusType.Action, "Gravity is now " + onoff + ".");
|
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("togglebrightness")]
|
|
|
|
public void ToggleBrightness()
|
|
|
|
{
|
|
|
|
renderer.FullBrightness = !renderer.FullBrightness;
|
|
|
|
string onoff = renderer.FullBrightness ? "ON" : "OFF";
|
|
|
|
General.Interface.DisplayStatus(StatusType.Action, "Full Brightness is now " + onoff + ".");
|
|
|
|
}
|
2009-07-07 14:52:39 +00:00
|
|
|
|
|
|
|
[BeginAction("togglehighlight")]
|
|
|
|
public void ToggleHighlight()
|
|
|
|
{
|
|
|
|
BuilderPlug.Me.UseHighlight = !BuilderPlug.Me.UseHighlight;
|
|
|
|
string onoff = BuilderPlug.Me.UseHighlight ? "ON" : "OFF";
|
|
|
|
General.Interface.DisplayStatus(StatusType.Action, "Highlight is now " + onoff + ".");
|
|
|
|
}
|
|
|
|
|
2009-04-19 18:07:22 +00:00
|
|
|
[BeginAction("resettexture")]
|
|
|
|
public void ResetTexture()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnResetTextureOffset();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("floodfilltextures")]
|
|
|
|
public void FloodfillTextures()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnTextureFloodfill();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("texturecopyoffsets")]
|
|
|
|
public void TextureCopyOffsets()
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
PreActionNoChange();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnCopyTextureOffsets();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("texturepasteoffsets")]
|
|
|
|
public void TexturePasteOffsets()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnPasteTextureOffsets();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("copyproperties")]
|
|
|
|
public void CopyProperties()
|
|
|
|
{
|
2009-05-03 19:22:32 +00:00
|
|
|
PreActionNoChange();
|
2009-07-07 11:29:56 +00:00
|
|
|
GetTargetEventReceiver(false).OnCopyProperties();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("pasteproperties")]
|
|
|
|
public void PasteProperties()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnPasteProperties();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("insertitem", BaseAction = true)]
|
|
|
|
public void Insert()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnInsert();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BeginAction("deleteitem", BaseAction = true)]
|
|
|
|
public void Delete()
|
|
|
|
{
|
2009-05-05 09:50:23 +00:00
|
|
|
PreAction(UndoGroup.None);
|
2009-07-11 10:28:58 +00:00
|
|
|
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
|
|
|
|
foreach(IVisualEventReceiver i in objs) i.OnDelete();
|
2009-05-03 19:22:32 +00:00
|
|
|
PostAction();
|
2009-04-19 18:07:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|