UltimateZoneBuilder/Source/BuilderModes/VisualModes/BaseVisualMode.cs
2008-12-02 06:53:24 +00:00

143 lines
3.1 KiB
C#

#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;
#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)
UseByDefault = true)]
public class BaseVisualMode : VisualMode
{
#region ================== Constants
#endregion
#region ================== Variables
#endregion
#region ================== Properties
#endregion
#region ================== Constructor / Disposer
// Constructor
public BaseVisualMode()
{
// Initialize
// 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
// This creates a visual sector
protected override VisualSector CreateVisualSector(Sector s)
{
return new BaseVisualSector(s);
}
// This draws a frame
public override void OnRedrawDisplay()
{
// Start drawing
if(renderer.Start())
{
// Begin with geometry
renderer.StartGeometry();
// This adds all visible geometry for rendering
AddGeometry();
// Done rendering geometry
renderer.FinishGeometry();
// Present!
renderer.Finish();
}
}
#endregion
#region ================== Methods
// TEST:
public override void OnMouseDown(MouseEventArgs e)
{
// Make ray
Vector3D start = CameraPosition;
Vector3D delta = CameraTarget.GetFixedLength(General.Settings.ViewDistance);
VisualPickResult pick = PickObject(start, start + delta);
// Any result?
if(pick.geometry != null)
{
if(pick.geometry is VisualMiddleSingle)
{
VisualMiddleSingle sd = (pick.geometry as VisualMiddleSingle);
General.Interface.ShowLinedefInfo(sd.Sidedef.Line);
}
}
else
{
General.Interface.HideInfo();
}
}
#endregion
}
}