Newer
Older
#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;
using CodeImp.DoomBuilder.Config;
#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;
private const float CAMERA_FLOOR_OFFSET = 41f; // same as in doom
private const float CAMERA_CEILING_OFFSET = 10f;
#endregion
#region ================== Variables
// Gravity vector
private Vector3D gravity;
// Object picking
private VisualPickResult target;
private double lastpicktime;
private bool locktarget;
// 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.
// We keep these to determine if we need to make a new undo level
private bool selectionchanged;
private int lastundogroup;
private VisualActionResult actionresult;
private bool undocreated;
// List of selected objects when an action is performed
private List<IVisualEventReceiver> selectedobjects;
#endregion
#region ================== Properties
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
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;
}
}
}
public IRenderer3D Renderer { get { return renderer; } }
public bool IsSingleSelection { get { return singleselection; } }
public bool SelectionChanged { get { return selectionchanged; } set { selectionchanged |= value; } }
#endregion
#region ================== Constructor / Disposer
// Constructor
public BaseVisualMode()
{
// Initialize
this.gravity = new Vector3D(0.0f, 0.0f, 0.0f);
codeimp
committed
this.selectedobjects = new List<IVisualEventReceiver>();
// 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
codeimp
committed
// This calculates brightness level
internal static int CalculateBrightness(int level)
{
float flevel = level;
if(level < 192) flevel = (192.0f - (float)(192 - level) * 1.5f); // simulate doom light levels
byte blevel = (byte)General.Clamp((int)flevel, 0, 255);
PixelColor c = new PixelColor(255, blevel, blevel, blevel);
return c.ToInt();
}
codeimp
committed
// 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;
}
// This is called before an action is performed
public void PreAction(int multiselectionundogroup)
actionresult = new VisualActionResult();
PickTargetUnlocked();
// If the action is not performed on a selected object, clear the
// current selection and make a temporary selection for the target.
codeimp
committed
if((target.picked != null) && !target.picked.Selected && (BuilderPlug.Me.VisualModeClearSelection || (selectedobjects.Count == 0)))
// Single object, no selection
singleselection = true;
ClearSelection();
undocreated = false;
singleselection = false;
// 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
if((lastundogroup != multiselectionundogroup) || (lastundogroup == UndoGroup.None) ||
(multiselectionundogroup == UndoGroup.None) || selectionchanged)
{
// We want to create a new undo level, but not just yet
lastundogroup = multiselectionundogroup;
undocreated = false;
}
else
// We don't want to make a new undo level (changes will be combined)
undocreated = true;
}
codeimp
committed
// Called before an action is performed. This does not make an undo level
private void PreActionNoChange()
{
actionresult = new VisualActionResult();
singleselection = false;
undocreated = false;
// This is called after an action is performed
if(!string.IsNullOrEmpty(actionresult.displaystatus))
General.Interface.DisplayStatus(StatusType.Action, actionresult.displaystatus);
// Reset changed flags
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
BaseVisualSector bvs = (vs.Value as BaseVisualSector);
bvs.Floor.Changed = false;
bvs.Ceiling.Changed = false;
}
if(singleselection)
ClearSelection();
UpdateChangedObjects();
ShowTargetInfo();
}
// 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
public int CreateUndo(string description, int group, int grouptag)
if(!undocreated)
{
undocreated = true;
if(singleselection)
return General.Map.UndoRedo.CreateUndo(description, this, group, grouptag);
else
return General.Map.UndoRedo.CreateUndo(description, this, UndoGroup.None, 0);
}
// 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
public int CreateUndo(string description)
return CreateUndo(description, UndoGroup.None, 0);
}
// This makes a list of the selected object
codeimp
committed
private void RebuildSelectedObjectsList()
{
// Make list of selected objects
selectedobjects = new List<IVisualEventReceiver>();
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
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)
{
List<VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd);
foreach(VisualGeometry sdg in sidedefgeos)
{
if(sdg.Selected) selectedobjects.Add((sdg as IVisualEventReceiver));
}
}
}
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
{
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
if(bvt.Selected) selectedobjects.Add(bvt);
}
// 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);
return vt.Setup() ? vt : null;
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
// 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();
}
}
// This updates the VisualSectors and VisualThings that have their Changed property set
private void UpdateChangedObjects()
{
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
BaseVisualSector bvs = (BaseVisualSector)vs.Value;
if(bvs.Changed) bvs.Rebuild();
}
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
{
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
}
}
#endregion
#region ================== Events
// Help!
public override void OnHelp()
{
General.ShowHelp("e_visual.html");
}
codeimp
committed
// When returning to another mode
public override void OnDisengage()
{
base.OnDisengage();
General.Map.Map.Update();
}
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
// 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?
if(General.Map.VisualCamera.Position.z <= (General.Map.VisualCamera.Sector.FloorHeight + CAMERA_FLOOR_OFFSET + 0.1f))
{
// 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,
General.Map.VisualCamera.Sector.FloorHeight + CAMERA_FLOOR_OFFSET);
}
else
{
// Fall down
gravity += new Vector3D(0.0f, 0.0f, (float)(GRAVITY * deltatime));
General.Map.VisualCamera.Position += gravity;
}
// Camera above ceiling level?
if(General.Map.VisualCamera.Position.z >= (General.Map.VisualCamera.Sector.CeilHeight - CAMERA_CEILING_OFFSET - 0.1f))
{
// Stay below ceiling
General.Map.VisualCamera.Position = new Vector3D(General.Map.VisualCamera.Position.x,
General.Map.VisualCamera.Position.y,
General.Map.VisualCamera.Sector.CeilHeight - CAMERA_CEILING_OFFSET);
}
}
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
if(BuilderPlug.Me.UseHighlight)
renderer.SetHighlightedObject(target.picked);
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
// 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();
}
// 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.
protected override void ResourcesReloadedPartial()
{
bool sectorsmarked = false;
if(General.Map.UndoRedo.GeometryChanged)
{
// 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)
{
sd.Marked = true;
if(sd.Other != null) sd.Other.Marked = true;
}
}
// Go for all sidedefs to update
foreach(Sidedef sd in General.Map.Map.Sidedefs)
{
if(sd.Marked && VisualSectorExists(sd.Sector))
{
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)
{
if(s.Marked && VisualSectorExists(s))
{
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)
if(vt.Key.Marked) vt.Value.Update();
}
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)
vt.Value.Dispose();
codeimp
committed
// Apply new lists
allthings = new Dictionary<Thing, VisualThing>(allthings.Count);
}
// Clear visibility collections
visiblesectors.Clear();
visibleblocks.Clear();
visiblegeometry.Clear();
visiblethings.Clear();
// Make new blockmap
codeimp
committed
if(sectorsmarked)
FillBlockMap();
// Visibility culling (this re-creates the needed resources)
DoCulling();
}
// Determine what we're aiming at now
PickTarget();
}
// Mouse moves
public override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
codeimp
committed
GetTargetEventReceiver(true).OnMouseMove(e);
// Undo performed
public override void OnUndoEnd()
{
base.OnUndoEnd();
codeimp
committed
RebuildSelectedObjectsList();
// We can't group with this undo level anymore
lastundogroup = UndoGroup.None;
}
codeimp
committed
// Redo performed
public override void OnRedoEnd()
{
base.OnRedoEnd();
RebuildSelectedObjectsList();
}
#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)
{
Dictionary<Sidedef, int> donesides = new Dictionary<Sidedef, int>(selectedobjects.Count);
List<IVisualEventReceiver> objs = GetSelectedObjects(false, true, false);
foreach(IVisualEventReceiver i in objs)
if(i is BaseVisualGeometrySidedef)
{
if(!donesides.ContainsKey((i as BaseVisualGeometrySidedef).Sidedef))
{
i.OnChangeTextureOffset(dx, dy);
donesides.Add((i as BaseVisualGeometrySidedef).Sidedef, 0);
}
}
}
}
// Apply upper unpegged flag
public void ApplyUpperUnpegged(bool set)
{
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs)
{
i.ApplyUpperUnpegged(set);
}
}
// Apply lower unpegged flag
public void ApplyLowerUnpegged(bool set)
{
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs)
{
i.ApplyLowerUnpegged(set);
}
}
// Apply texture change
public void ApplySelectTexture(string texture, bool flat)
{
List<IVisualEventReceiver> objs;
if(General.Map.Config.MixTexturesFlats)
{
// Apply on all compatible types
objs = GetSelectedObjects(true, true, false);
}
else
{
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
// 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);
}
public List<Sector> GetSelectedSectors()
{
List<Sector> sectors = new List<Sector>();
foreach(IVisualEventReceiver i in selectedobjects)
{
if(i is BaseVisualGeometrySector)
{
Sector s = (i as BaseVisualGeometrySector).Sector.Sector;
if(!added.ContainsKey(s))
{
sectors.Add(s);
added.Add(s, 0);
}
}
// 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);
}
return sectors;
}
public List<Linedef> GetSelectedLinedefs()
{
List<Linedef> linedefs = new List<Linedef>();
foreach(IVisualEventReceiver i in selectedobjects)
{
if(i is BaseVisualGeometrySidedef)
{
Linedef l = (i as BaseVisualGeometrySidedef).Sidedef.Line;
if(!added.ContainsKey(l))
{
linedefs.Add(l);
added.Add(l, 0);
}
}
// 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);
}
return linedefs;
}
codeimp
committed
// 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);
}
}
}
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualGeometrySidedef))
{
Sidedef sd = (target.picked as BaseVisualGeometrySidedef).Sidedef;
if(!added.ContainsKey(sd))
sidedefs.Add(sd);
}
codeimp
committed
return sidedefs;
}
public List<Thing> GetSelectedThings()
{
List<Thing> things = new List<Thing>();
foreach(IVisualEventReceiver i in selectedobjects)
{
if(i is BaseVisualThing)
{
Thing t = (i as BaseVisualThing).Thing;
if(!added.ContainsKey(t))
{
things.Add(t);
added.Add(t, 0);
}
}
// Add highlight?
if((selectedobjects.Count == 0) && (target.picked is BaseVisualThing))
{
Thing t = (target.picked as BaseVisualThing).Thing;
if(!added.ContainsKey(t))
things.Add(t);
}
return things;
}
codeimp
committed
// 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();
}
}
#endregion
#region ================== Actions
[BeginAction("clearselection", BaseAction = true)]
public void ClearSelection()
{
selectedobjects = new List<IVisualEventReceiver>();
foreach(KeyValuePair<Sector, VisualSector> vs in allsectors)
{
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)
{
List<VisualGeometry> sidedefgeos = bvs.GetSidedefGeometry(sd);
foreach(VisualGeometry sdg in sidedefgeos)
{
sdg.Selected = false;
}
}
}
foreach(KeyValuePair<Thing, VisualThing> vt in allthings)
{
BaseVisualThing bvt = (BaseVisualThing)vt.Value;
bvt.Selected = false;
}
}
[BeginAction("visualselect", BaseAction = true)]
public void BeginSelect()
{
PreActionNoChange();
codeimp
committed
GetTargetEventReceiver(true).OnSelectBegin();
PostAction();
}
[EndAction("visualselect", BaseAction = true)]
public void EndSelect()
{
codeimp
committed
GetTargetEventReceiver(true).OnSelectEnd();
Renderer.ShowSelection = true;
Renderer.ShowHighlight = true;
PostAction();
}
[BeginAction("visualedit", BaseAction = true)]
public void BeginEdit()
{
PreAction(UndoGroup.None);
codeimp
committed
GetTargetEventReceiver(false).OnEditBegin();
PostAction();
}
[EndAction("visualedit", BaseAction = true)]
public void EndEdit()
{
codeimp
committed
GetTargetEventReceiver(false).OnEditEnd();
PostAction();
}
[BeginAction("raisesector8")]
public void RaiseSector8()
{
PreAction(UndoGroup.SectorHeightChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(8);
PostAction();
}
[BeginAction("lowersector8")]
public void LowerSector8()
{
PreAction(UndoGroup.SectorHeightChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-8);
PostAction();
}
[BeginAction("raisesector1")]
public void RaiseSector1()
{
PreAction(UndoGroup.SectorHeightChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(1);
PostAction();
}
[BeginAction("lowersector1")]
public void LowerSector1()
{
PreAction(UndoGroup.SectorHeightChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetHeight(-1);
PostAction();
}
[BeginAction("showvisualthings")]
public void ShowVisualThings()
{
BuilderPlug.Me.ShowVisualThings++;
if(BuilderPlug.Me.ShowVisualThings > 2) BuilderPlug.Me.ShowVisualThings = 0;
}
[BeginAction("raisebrightness8")]
public void RaiseBrightness8()
{
PreAction(UndoGroup.SectorBrightnessChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, true);
foreach(IVisualEventReceiver i in objs) i.OnChangeTargetBrightness(true);
PostAction();