mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 14:31:50 +00:00
lot more.
This commit is contained in:
parent
bfba3ca0bc
commit
109e4a4690
24 changed files with 932 additions and 136 deletions
8
Documents/ideas.txt
Normal file
8
Documents/ideas.txt
Normal file
|
@ -0,0 +1,8 @@
|
|||
[15:49] <SoM> if you split a linedef with a vertex, there should be an option that will align the second half of the split
|
||||
[15:49] <SoM> so like, if I have a line that is 128 units long
|
||||
[15:49] <SoM> and I split them in half
|
||||
[15:50] <SoM> the second linedef of the split would have the offset of the first + 64
|
||||
[15:50] <SoM> I don't think it would take much effort
|
||||
[15:50] <SoM> and it could easily be optional
|
||||
[15:51] <SoM> I've been doing a lot of detailing that would be made a lot easier with a feature like this
|
||||
[15:52] <CodeImp> i dont even think that should be an option, but normal behaviour
|
BIN
Resources/Icons/LinesMode.png
Normal file
BIN
Resources/Icons/LinesMode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 291 B |
BIN
Resources/Icons/SectorsMode.png
Normal file
BIN
Resources/Icons/SectorsMode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 340 B |
BIN
Resources/Icons/VerticesMode.png
Normal file
BIN
Resources/Icons/VerticesMode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 209 B |
|
@ -54,6 +54,8 @@
|
|||
<Compile Include="Data\SpriteImage.cs" />
|
||||
<Compile Include="Data\TextureImage.cs" />
|
||||
<Compile Include="Editing\EditMode.cs" />
|
||||
<Compile Include="Editing\LinedefsMode.cs" />
|
||||
<Compile Include="Editing\SectorsMode.cs" />
|
||||
<Compile Include="Editing\VerticesMode.cs" />
|
||||
<Compile Include="Editing\ClassicMode.cs" />
|
||||
<Compile Include="Controls\ActionDelegate.cs" />
|
||||
|
@ -211,6 +213,9 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Resources\Builder.ico" />
|
||||
<None Include="Resources\SectorsMode.png" />
|
||||
<None Include="Resources\LinesMode.png" />
|
||||
<None Include="Resources\VerticesMode.png" />
|
||||
<None Include="Resources\ColorPick.png" />
|
||||
<None Include="Resources\Zoom.png" />
|
||||
<None Include="Resources\Properties.png" />
|
||||
|
|
|
@ -47,6 +47,9 @@ namespace CodeImp.DoomBuilder.Controls
|
|||
public const string PREFERENCES = "preferences";
|
||||
public const string MAPOPTIONS = "mapoptions";
|
||||
public const string RELOADRESOURCES = "reloadresources";
|
||||
public const string VERTICESMODE = "verticesmode";
|
||||
public const string LINEDEFSMODE = "linedefsmode";
|
||||
public const string SECTORSMODE = "sectorsmode";
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Mouse status
|
||||
protected Vector2D mousepos;
|
||||
protected Vector2D mousemappos;
|
||||
protected MouseButtons mousebuttons;
|
||||
protected bool mouseinside;
|
||||
|
||||
#endregion
|
||||
|
@ -121,7 +122,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
public virtual void ZoomIn()
|
||||
{
|
||||
// Zoom
|
||||
ZoomBy(1.2f);
|
||||
ZoomBy(1.3f);
|
||||
}
|
||||
|
||||
// This zooms out
|
||||
|
@ -129,7 +130,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
public virtual void ZoomOut()
|
||||
{
|
||||
// Zoom
|
||||
ZoomBy(0.8f);
|
||||
ZoomBy(0.7f);
|
||||
}
|
||||
|
||||
// This scrolls anywhere
|
||||
|
@ -178,9 +179,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
//General.Map.Map.Update();
|
||||
General.MainWindow.RedrawDisplay();
|
||||
|
||||
// Determine new unprojected mouse coordinates
|
||||
mousemappos = renderer.GetMapCoordinates(mousepos);
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
// Give a new mousemove event to update coordinates
|
||||
if(mouseinside) MouseMove(new MouseEventArgs(mousebuttons, 0, (int)mousepos.x, (int)mousepos.y, 0));
|
||||
}
|
||||
|
||||
// This zooms to a specific level
|
||||
|
@ -191,9 +191,8 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
//General.Map.Map.Update();
|
||||
General.MainWindow.RedrawDisplay();
|
||||
|
||||
// Determine new unprojected mouse coordinates
|
||||
mousemappos = renderer.GetMapCoordinates(mousepos);
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
// Give a new mousemove event to update coordinates
|
||||
if(mouseinside) MouseMove(new MouseEventArgs(mousebuttons, 0, (int)mousepos.x, (int)mousepos.y, 0));
|
||||
}
|
||||
|
||||
// This zooms and scrolls to fit the map in the window
|
||||
|
@ -230,10 +229,9 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
renderer.PositionView(left + (right - left) * 0.5f, top + (bottom - top) * 0.5f);
|
||||
//General.Map.Map.Update();
|
||||
General.MainWindow.RedrawDisplay();
|
||||
|
||||
// Determine new unprojected mouse coordinates
|
||||
mousemappos = renderer.GetMapCoordinates(mousepos);
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
|
||||
// Give a new mousemove event to update coordinates
|
||||
if(mouseinside) MouseMove(new MouseEventArgs(mousebuttons, 0, (int)mousepos.x, (int)mousepos.y, 0));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -247,6 +245,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
mouseinside = false;
|
||||
mousepos = new Vector2D(float.NaN, float.NaN);
|
||||
mousemappos = mousepos;
|
||||
mousebuttons = MouseButtons.None;
|
||||
|
||||
// Determine new unprojected mouse coordinates
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
|
@ -262,6 +261,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
mouseinside = true;
|
||||
mousepos = new Vector2D(e.X, e.Y);
|
||||
mousemappos = renderer.GetMapCoordinates(mousepos);
|
||||
mousebuttons = e.Button;
|
||||
|
||||
// Update labels in main window
|
||||
General.MainWindow.UpdateCoordinates(mousemappos);
|
||||
|
|
|
@ -59,9 +59,6 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Constructor
|
||||
public EditMode()
|
||||
{
|
||||
// Bind any methods
|
||||
ActionAttribute.BindMethods(this);
|
||||
|
||||
// We have no destructor
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
@ -72,9 +69,6 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Unbind any methods
|
||||
ActionAttribute.UnbindMethods(this);
|
||||
|
||||
// Clean up
|
||||
|
||||
// Done
|
||||
|
@ -111,6 +105,20 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
// Mode engages
|
||||
public virtual void Engage()
|
||||
{
|
||||
// Bind any methods
|
||||
ActionAttribute.BindMethods(this);
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
public virtual void Disengage()
|
||||
{
|
||||
// Unbind any methods
|
||||
ActionAttribute.UnbindMethods(this);
|
||||
}
|
||||
|
||||
// Optional interface methods
|
||||
public virtual void MouseClick(MouseEventArgs e) { }
|
||||
public virtual void MouseDoubleClick(MouseEventArgs e) { }
|
||||
|
|
172
Source/Editing/LinedefsMode.cs
Normal file
172
Source/Editing/LinedefsMode.cs
Normal file
|
@ -0,0 +1,172 @@
|
|||
|
||||
#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.Interface;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Editing
|
||||
{
|
||||
internal class LinedefsMode : ClassicMode
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
protected const float LINEDEF_HIGHLIGHT_RANGE = 20f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Highlighted item
|
||||
private Linedef highlighted;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public LinedefsMode()
|
||||
{
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public override void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
// Dispose base
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// Mode engages
|
||||
public override void Engage()
|
||||
{
|
||||
base.Engage();
|
||||
|
||||
// Check linedefs button on main window
|
||||
General.MainWindow.SetLinedefsChecked(true);
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
public override void Disengage()
|
||||
{
|
||||
base.Disengage();
|
||||
|
||||
// Check linedefs button on main window
|
||||
General.MainWindow.SetLinedefsChecked(false);
|
||||
}
|
||||
|
||||
// This redraws the display
|
||||
public unsafe override void RedrawDisplay()
|
||||
{
|
||||
// Start with a clear display
|
||||
if(renderer.StartRendering(true))
|
||||
{
|
||||
// Render lines
|
||||
renderer.RenderLinedefSet(General.Map.Map, General.Map.Map.Linedefs);
|
||||
|
||||
// Render highlighted item
|
||||
if(highlighted != null)
|
||||
renderer.RenderLinedef(highlighted, General.Colors.Highlight);
|
||||
|
||||
// Render vertices
|
||||
renderer.RenderVerticesSet(General.Map.Map, General.Map.Map.Vertices);
|
||||
|
||||
// Done
|
||||
renderer.FinishRendering();
|
||||
}
|
||||
}
|
||||
|
||||
// This highlights a new item
|
||||
protected void Highlight(Linedef l)
|
||||
{
|
||||
// Update display
|
||||
if(renderer.StartRendering(false))
|
||||
{
|
||||
// Undraw previous highlight
|
||||
if(highlighted != null)
|
||||
{
|
||||
renderer.RenderLinedef(highlighted, renderer.DetermineLinedefColor(highlighted));
|
||||
renderer.RenderVertex(highlighted.Start, renderer.DetermineVertexColor(highlighted.Start));
|
||||
renderer.RenderVertex(highlighted.End, renderer.DetermineVertexColor(highlighted.End));
|
||||
}
|
||||
|
||||
// Set new highlight
|
||||
highlighted = l;
|
||||
|
||||
// Render highlighted item
|
||||
if(highlighted != null)
|
||||
{
|
||||
renderer.RenderLinedef(highlighted, General.Colors.Highlight);
|
||||
renderer.RenderVertex(highlighted.Start, renderer.DetermineVertexColor(highlighted.Start));
|
||||
renderer.RenderVertex(highlighted.End, renderer.DetermineVertexColor(highlighted.End));
|
||||
}
|
||||
|
||||
// Done
|
||||
renderer.FinishRendering();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.MouseMove(e);
|
||||
|
||||
// Find the nearest linedef within highlight range
|
||||
Linedef l = General.Map.Map.NearestLinedefRange(mousemappos, LINEDEF_HIGHLIGHT_RANGE / renderer.Scale);
|
||||
|
||||
// Highlight if not the same
|
||||
if(l != highlighted) Highlight(l);
|
||||
}
|
||||
|
||||
// Mouse leaves
|
||||
public override void MouseLeave(EventArgs e)
|
||||
{
|
||||
base.MouseLeave(e);
|
||||
|
||||
// Highlight nothing
|
||||
Highlight(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
188
Source/Editing/SectorsMode.cs
Normal file
188
Source/Editing/SectorsMode.cs
Normal file
|
@ -0,0 +1,188 @@
|
|||
|
||||
#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.Interface;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Editing
|
||||
{
|
||||
internal class SectorsMode : ClassicMode
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Highlighted item
|
||||
private Sector highlighted;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public SectorsMode()
|
||||
{
|
||||
}
|
||||
|
||||
// Diposer
|
||||
public override void Dispose()
|
||||
{
|
||||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
// Dispose base
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// Mode engages
|
||||
public override void Engage()
|
||||
{
|
||||
base.Engage();
|
||||
|
||||
// Check sectors button on main window
|
||||
General.MainWindow.SetSectorsChecked(true);
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
public override void Disengage()
|
||||
{
|
||||
base.Disengage();
|
||||
|
||||
// Check sectors button on main window
|
||||
General.MainWindow.SetSectorsChecked(false);
|
||||
}
|
||||
|
||||
// This redraws the display
|
||||
public unsafe override void RedrawDisplay()
|
||||
{
|
||||
// Start with a clear display
|
||||
if(renderer.StartRendering(true))
|
||||
{
|
||||
// Render stuff
|
||||
renderer.RenderLinedefSet(General.Map.Map, General.Map.Map.Linedefs);
|
||||
renderer.RenderVerticesSet(General.Map.Map, General.Map.Map.Vertices);
|
||||
|
||||
// Render highlighted item
|
||||
if(highlighted != null)
|
||||
renderer.RenderSector(highlighted, General.Colors.Highlight);
|
||||
|
||||
// Done
|
||||
renderer.FinishRendering();
|
||||
}
|
||||
}
|
||||
|
||||
// This highlights a new item
|
||||
protected void Highlight(Sector s)
|
||||
{
|
||||
// Update display
|
||||
if(renderer.StartRendering(false))
|
||||
{
|
||||
// Undraw previous highlight
|
||||
if(highlighted != null)
|
||||
renderer.RenderSector(highlighted);
|
||||
|
||||
// Set new highlight
|
||||
highlighted = s;
|
||||
|
||||
// Render highlighted item
|
||||
if(highlighted != null)
|
||||
renderer.RenderSector(highlighted, General.Colors.Highlight);
|
||||
|
||||
// Done
|
||||
renderer.FinishRendering();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.MouseMove(e);
|
||||
|
||||
// Find the nearest linedef within highlight range
|
||||
Linedef l = General.Map.Map.NearestLinedef(mousemappos);
|
||||
|
||||
// Check on which side of the linedef the mouse is
|
||||
float side = l.SideOfLine(mousemappos);
|
||||
if(side > 0)
|
||||
{
|
||||
// Is there a sidedef here?
|
||||
if(l.Back != null)
|
||||
{
|
||||
// Highlight if not the same
|
||||
if(l.Back.Sector != highlighted) Highlight(l.Back.Sector);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Highlight nothing
|
||||
if(highlighted != null) Highlight(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Is there a sidedef here?
|
||||
if(l.Front != null)
|
||||
{
|
||||
// Highlight if not the same
|
||||
if(l.Front.Sector != highlighted) Highlight(l.Front.Sector);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Highlight nothing
|
||||
if(highlighted != null) Highlight(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse leaves
|
||||
public override void MouseLeave(EventArgs e)
|
||||
{
|
||||
base.MouseLeave(e);
|
||||
|
||||
// Highlight nothing
|
||||
Highlight(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ using CodeImp.DoomBuilder.Interface;
|
|||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using CodeImp.DoomBuilder.Geometry;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -37,10 +38,15 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
{
|
||||
#region ================== Constants
|
||||
|
||||
protected const float VERTEX_HIGHLIGHT_RANGE = 20f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
// Highlighted item
|
||||
private Vertex highlighted;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -49,9 +55,7 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
/// <summary>
|
||||
/// Fresh mode
|
||||
/// </summary>
|
||||
// Constructor
|
||||
public VerticesMode()
|
||||
{
|
||||
}
|
||||
|
@ -72,7 +76,25 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
|
||||
// Mode engages
|
||||
public override void Engage()
|
||||
{
|
||||
base.Engage();
|
||||
|
||||
// Check vertices button on main window
|
||||
General.MainWindow.SetVerticesChecked(true);
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
public override void Disengage()
|
||||
{
|
||||
base.Disengage();
|
||||
|
||||
// Check vertices button on main window
|
||||
General.MainWindow.SetVerticesChecked(false);
|
||||
}
|
||||
|
||||
// This redraws the display
|
||||
public unsafe override void RedrawDisplay()
|
||||
{
|
||||
|
@ -80,14 +102,61 @@ namespace CodeImp.DoomBuilder.Editing
|
|||
if(renderer.StartRendering(true))
|
||||
{
|
||||
// Render stuff
|
||||
renderer.RenderLinedefs(General.Map.Map, General.Map.Map.Linedefs, null);
|
||||
renderer.RenderVertices(General.Map.Map, General.Map.Map.Vertices, null);
|
||||
renderer.RenderLinedefSet(General.Map.Map, General.Map.Map.Linedefs);
|
||||
renderer.RenderVerticesSet(General.Map.Map, General.Map.Map.Vertices);
|
||||
|
||||
// Render highlighted item
|
||||
if(highlighted != null)
|
||||
renderer.RenderVertex(highlighted, General.Colors.Highlight);
|
||||
|
||||
// Done
|
||||
renderer.FinishRendering();
|
||||
}
|
||||
}
|
||||
|
||||
// This highlights a new item
|
||||
protected void Highlight(Vertex v)
|
||||
{
|
||||
// Update display
|
||||
if(renderer.StartRendering(false))
|
||||
{
|
||||
// Undraw previous highlight
|
||||
if(highlighted != null)
|
||||
renderer.RenderVertex(highlighted, renderer.DetermineVertexColor(highlighted));
|
||||
|
||||
// Set new highlight
|
||||
highlighted = v;
|
||||
|
||||
// Render highlighted item
|
||||
if(highlighted != null)
|
||||
renderer.RenderVertex(highlighted, General.Colors.Highlight);
|
||||
|
||||
// Done
|
||||
renderer.FinishRendering();
|
||||
}
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public override void MouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.MouseMove(e);
|
||||
|
||||
// Find the nearest vertex within highlight range
|
||||
Vertex v = General.Map.Map.NearestVertexSquareRange(mousemappos, VERTEX_HIGHLIGHT_RANGE / renderer.Scale);
|
||||
|
||||
// Highlight if not the same
|
||||
if(v != highlighted) Highlight(v);
|
||||
}
|
||||
|
||||
// Mouse leaves
|
||||
public override void MouseLeave(EventArgs e)
|
||||
{
|
||||
base.MouseLeave(e);
|
||||
|
||||
// Highlight nothing
|
||||
Highlight(null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,6 +116,9 @@ namespace CodeImp.DoomBuilder
|
|||
// Not already disposed?
|
||||
if(!isdisposed)
|
||||
{
|
||||
// Change to no mode
|
||||
ChangeMode(null);
|
||||
|
||||
// Unbind any methods
|
||||
ActionAttribute.UnbindMethods(this);
|
||||
|
||||
|
@ -126,8 +129,6 @@ namespace CodeImp.DoomBuilder
|
|||
tempwad.Dispose();
|
||||
General.WriteLogLine("Unloading map data...");
|
||||
map.Dispose();
|
||||
General.WriteLogLine("Stopping edit mode...");
|
||||
mode.Dispose();
|
||||
General.WriteLogLine("Stopping graphics device...");
|
||||
graphics.Dispose();
|
||||
|
||||
|
@ -802,6 +803,69 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
#endregion
|
||||
|
||||
#region ================== Editing Modes
|
||||
|
||||
// This changes the editing mode.
|
||||
// Order in which events occur for the old and new modes:
|
||||
//
|
||||
// - Constructor of new mode is called
|
||||
// - Disengage of old mode is called
|
||||
// ----- Mode switches -----
|
||||
// - Engage of new mode is called
|
||||
// - Dispose of old mode is called
|
||||
//
|
||||
public void ChangeMode(EditMode newmode)
|
||||
{
|
||||
EditMode oldmode = mode;
|
||||
|
||||
// Log info
|
||||
if(newmode != null)
|
||||
General.WriteLogLine("Switching edit mode to " + newmode.GetType().Name + "...");
|
||||
else
|
||||
General.WriteLogLine("Stopping edit mode...");
|
||||
|
||||
// Disenagage old mode
|
||||
if(oldmode != null) oldmode.Disengage();
|
||||
|
||||
// Apply new mode
|
||||
mode = newmode;
|
||||
|
||||
// Engage new mode
|
||||
if(newmode != null) newmode.Engage();
|
||||
|
||||
// Dispose old mode
|
||||
if(mode != null) mode.Dispose();
|
||||
|
||||
// Redraw the display
|
||||
General.MainWindow.RedrawDisplay();
|
||||
}
|
||||
|
||||
// This switches to vertices mode
|
||||
[Action(Action.VERTICESMODE)]
|
||||
public void SwitchVerticesMode()
|
||||
{
|
||||
// Change to vertices mode
|
||||
ChangeMode(new VerticesMode());
|
||||
}
|
||||
|
||||
// This switches to linedefs mode
|
||||
[Action(Action.LINEDEFSMODE)]
|
||||
public void SwitchLinedefsMode()
|
||||
{
|
||||
// Change to linedefs mode
|
||||
ChangeMode(new LinedefsMode());
|
||||
}
|
||||
|
||||
// This switches to sectors mode
|
||||
[Action(Action.SECTORSMODE)]
|
||||
public void SwitchSectorsMode()
|
||||
{
|
||||
// Change to sectors mode
|
||||
ChangeMode(new SectorsMode());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// This reloads resources
|
||||
|
@ -837,7 +901,7 @@ namespace CodeImp.DoomBuilder
|
|||
General.MainWindow.DisplayStatus(oldstatus);
|
||||
Cursor.Current = oldcursor;
|
||||
}
|
||||
|
||||
|
||||
// Game Configuration action
|
||||
[Action(Action.MAPOPTIONS)]
|
||||
public void ShowMapOptions()
|
||||
|
@ -848,7 +912,7 @@ namespace CodeImp.DoomBuilder
|
|||
{
|
||||
// Update interface
|
||||
General.MainWindow.UpdateInterface();
|
||||
|
||||
|
||||
// Reload resources
|
||||
ReloadResources();
|
||||
}
|
||||
|
@ -856,20 +920,6 @@ namespace CodeImp.DoomBuilder
|
|||
// Done
|
||||
optionsform.Dispose();
|
||||
}
|
||||
|
||||
// This changes editing mode
|
||||
public void ChangeMode(EditMode newmode)
|
||||
{
|
||||
// Dispose current mode
|
||||
if(mode != null) mode.Dispose();
|
||||
|
||||
// Set new mode
|
||||
General.WriteLogLine("Switched edit mode to " + newmode.GetType().Name);
|
||||
mode = newmode;
|
||||
|
||||
// Redraw the display
|
||||
General.MainWindow.RedrawDisplay();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -260,17 +260,17 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
return x + ", " + y;
|
||||
}
|
||||
|
||||
// Transform
|
||||
public unsafe Vector2D GetTransformed(Vector2D* offset, Vector2D* scale)
|
||||
{
|
||||
return new Vector2D((x + offset->x) * scale->x, (y + offset->y) * scale->y);
|
||||
}
|
||||
|
||||
// Transform
|
||||
public unsafe Vector2D GetTransformed(float offsetx, float offsety, float scalex, float scaley)
|
||||
{
|
||||
return new Vector2D((x + offsetx) * scalex, (y + offsety) * scaley);
|
||||
}
|
||||
|
||||
// Inverse Transform
|
||||
public unsafe Vector2D GetInvTransformed(float invoffsetx, float invoffsety, float invscalex, float invscaley)
|
||||
{
|
||||
return new Vector2D((x * invscalex) + invoffsetx, (y * invscaley) + invoffsety);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
97
Source/Interface/MainForm.Designer.cs
generated
97
Source/Interface/MainForm.Designer.cs
generated
|
@ -47,6 +47,10 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.itemnorecent = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemexit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menuedit = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemverticesmode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemlinedefsmode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemsectorsmode = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.toolStripSeparator6 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.itemmapoptions = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.menutools = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.itemreloadresources = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
@ -60,6 +64,10 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.buttonsavemap = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.buttonmapoptions = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.buttonverticesmode = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttonlinedefsmode = new System.Windows.Forms.ToolStripButton();
|
||||
this.buttonsectorsmode = new System.Windows.Forms.ToolStripButton();
|
||||
this.statusbar = new System.Windows.Forms.StatusStrip();
|
||||
this.statuslabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.zoomlabel = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
|
@ -220,11 +228,47 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
// menuedit
|
||||
//
|
||||
this.menuedit.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.itemverticesmode,
|
||||
this.itemlinedefsmode,
|
||||
this.itemsectorsmode,
|
||||
this.toolStripSeparator6,
|
||||
this.itemmapoptions});
|
||||
this.menuedit.Name = "menuedit";
|
||||
this.menuedit.Size = new System.Drawing.Size(37, 20);
|
||||
this.menuedit.Text = "Edit";
|
||||
//
|
||||
// itemverticesmode
|
||||
//
|
||||
this.itemverticesmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.VerticesMode;
|
||||
this.itemverticesmode.Name = "itemverticesmode";
|
||||
this.itemverticesmode.Size = new System.Drawing.Size(161, 22);
|
||||
this.itemverticesmode.Tag = "verticesmode";
|
||||
this.itemverticesmode.Text = "Vertices Mode";
|
||||
this.itemverticesmode.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// itemlinedefsmode
|
||||
//
|
||||
this.itemlinedefsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.LinesMode;
|
||||
this.itemlinedefsmode.Name = "itemlinedefsmode";
|
||||
this.itemlinedefsmode.Size = new System.Drawing.Size(161, 22);
|
||||
this.itemlinedefsmode.Tag = "linedefsmode";
|
||||
this.itemlinedefsmode.Text = "Linedefs Mode";
|
||||
this.itemlinedefsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// itemsectorsmode
|
||||
//
|
||||
this.itemsectorsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.SectorsMode;
|
||||
this.itemsectorsmode.Name = "itemsectorsmode";
|
||||
this.itemsectorsmode.Size = new System.Drawing.Size(161, 22);
|
||||
this.itemsectorsmode.Tag = "sectorsmode";
|
||||
this.itemsectorsmode.Text = "Sectors Mode";
|
||||
this.itemsectorsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// toolStripSeparator6
|
||||
//
|
||||
this.toolStripSeparator6.Name = "toolStripSeparator6";
|
||||
this.toolStripSeparator6.Size = new System.Drawing.Size(158, 6);
|
||||
//
|
||||
// itemmapoptions
|
||||
//
|
||||
this.itemmapoptions.Image = global::CodeImp.DoomBuilder.Properties.Resources.Properties;
|
||||
|
@ -292,7 +336,11 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.buttonopenmap,
|
||||
this.buttonsavemap,
|
||||
this.toolStripSeparator3,
|
||||
this.buttonmapoptions});
|
||||
this.buttonmapoptions,
|
||||
this.toolStripSeparator5,
|
||||
this.buttonverticesmode,
|
||||
this.buttonlinedefsmode,
|
||||
this.buttonsectorsmode});
|
||||
this.toolbar.Location = new System.Drawing.Point(0, 24);
|
||||
this.toolbar.Name = "toolbar";
|
||||
this.toolbar.Size = new System.Drawing.Size(731, 25);
|
||||
|
@ -349,6 +397,45 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
this.buttonmapoptions.Text = "Map Options";
|
||||
this.buttonmapoptions.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// toolStripSeparator5
|
||||
//
|
||||
this.toolStripSeparator5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.toolStripSeparator5.Name = "toolStripSeparator5";
|
||||
this.toolStripSeparator5.Size = new System.Drawing.Size(6, 25);
|
||||
//
|
||||
// buttonverticesmode
|
||||
//
|
||||
this.buttonverticesmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.buttonverticesmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.VerticesMode;
|
||||
this.buttonverticesmode.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.buttonverticesmode.Name = "buttonverticesmode";
|
||||
this.buttonverticesmode.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonverticesmode.Tag = "verticesmode";
|
||||
this.buttonverticesmode.Text = "Vertices Mode";
|
||||
this.buttonverticesmode.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// buttonlinedefsmode
|
||||
//
|
||||
this.buttonlinedefsmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.buttonlinedefsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.LinesMode;
|
||||
this.buttonlinedefsmode.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.buttonlinedefsmode.Name = "buttonlinedefsmode";
|
||||
this.buttonlinedefsmode.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonlinedefsmode.Tag = "linedefsmode";
|
||||
this.buttonlinedefsmode.Text = "Linedefs Mode";
|
||||
this.buttonlinedefsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// buttonsectorsmode
|
||||
//
|
||||
this.buttonsectorsmode.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.buttonsectorsmode.Image = global::CodeImp.DoomBuilder.Properties.Resources.SectorsMode;
|
||||
this.buttonsectorsmode.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.buttonsectorsmode.Name = "buttonsectorsmode";
|
||||
this.buttonsectorsmode.Size = new System.Drawing.Size(23, 22);
|
||||
this.buttonsectorsmode.Tag = "sectorsmode";
|
||||
this.buttonsectorsmode.Text = "Sectors Mode";
|
||||
this.buttonsectorsmode.Click += new System.EventHandler(this.InvokeTaggedAction);
|
||||
//
|
||||
// statusbar
|
||||
//
|
||||
this.statusbar.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
|
@ -592,5 +679,13 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
private System.Windows.Forms.ToolStripMenuItem itemmapoptions;
|
||||
private System.Windows.Forms.ToolStripButton buttonmapoptions;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemreloadresources;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
|
||||
private System.Windows.Forms.ToolStripButton buttonverticesmode;
|
||||
private System.Windows.Forms.ToolStripButton buttonlinedefsmode;
|
||||
private System.Windows.Forms.ToolStripButton buttonsectorsmode;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemverticesmode;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemlinedefsmode;
|
||||
private System.Windows.Forms.ToolStripMenuItem itemsectorsmode;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator6;
|
||||
}
|
||||
}
|
|
@ -260,7 +260,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
yposlabel.Text = coords.y.ToString("####0");
|
||||
|
||||
// Update status bar
|
||||
statusbar.Update();
|
||||
//statusbar.Update();
|
||||
}
|
||||
|
||||
// This changes zoom display
|
||||
|
@ -276,7 +276,7 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
}
|
||||
|
||||
// Update status bar
|
||||
statusbar.Update();
|
||||
//statusbar.Update();
|
||||
}
|
||||
|
||||
// Zoom to a specified level
|
||||
|
@ -670,16 +670,44 @@ namespace CodeImp.DoomBuilder.Interface
|
|||
|
||||
#region ================== Edit Menu
|
||||
|
||||
// This sets the status of the vertices button
|
||||
public void SetVerticesChecked(bool value)
|
||||
{
|
||||
itemverticesmode.Checked = value;
|
||||
buttonverticesmode.Checked = value;
|
||||
}
|
||||
|
||||
// This sets the status of the linedefs button
|
||||
public void SetLinedefsChecked(bool value)
|
||||
{
|
||||
itemlinedefsmode.Checked = value;
|
||||
buttonlinedefsmode.Checked = value;
|
||||
}
|
||||
|
||||
// This sets the status of the sectors button
|
||||
public void SetSectorsChecked(bool value)
|
||||
{
|
||||
itemsectorsmode.Checked = value;
|
||||
buttonsectorsmode.Checked = value;
|
||||
}
|
||||
|
||||
// This sets up the edit menu
|
||||
private void UpdateEditMenu()
|
||||
{
|
||||
// No edit menu when no map open
|
||||
menuedit.Enabled = (General.Map != null);
|
||||
//menuedit.Visible = (General.Map != null);
|
||||
|
||||
// Enable/disable items
|
||||
itemmapoptions.Enabled = (General.Map != null);
|
||||
itemverticesmode.Enabled = (General.Map != null);
|
||||
itemlinedefsmode.Enabled = (General.Map != null);
|
||||
itemsectorsmode.Enabled = (General.Map != null);
|
||||
|
||||
// Toolbar icons
|
||||
buttonmapoptions.Enabled = (General.Map != null);
|
||||
buttonverticesmode.Enabled = (General.Map != null);
|
||||
buttonlinedefsmode.Enabled = (General.Map != null);
|
||||
buttonsectorsmode.Enabled = (General.Map != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
|
|||
using SlimDX.Direct3D;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -329,13 +330,38 @@ namespace CodeImp.DoomBuilder.Map
|
|||
return closest;
|
||||
}
|
||||
|
||||
// This finds the line closest to the specified position
|
||||
public static Linedef NearestLinedefRange(ICollection<Linedef> selection, Vector2D pos, float maxrange)
|
||||
{
|
||||
Linedef closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float maxrangesq = maxrange * maxrange;
|
||||
float d;
|
||||
|
||||
// Go for all linedefs in selection
|
||||
foreach(Linedef l in selection)
|
||||
{
|
||||
// Calculate distance and check if closer than previous find
|
||||
d = l.DistanceToSq(pos, true);
|
||||
if((d <= maxrangesq) && (d < distance))
|
||||
{
|
||||
// This one is closer
|
||||
closest = l;
|
||||
distance = d;
|
||||
}
|
||||
}
|
||||
|
||||
// Return result
|
||||
return closest;
|
||||
}
|
||||
|
||||
// This finds the vertex closest to the specified position
|
||||
public static Vertex NearestVertex(ICollection<Vertex> selection, Vector2D pos)
|
||||
{
|
||||
Vertex closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float d;
|
||||
|
||||
|
||||
// Go for all vertices in selection
|
||||
foreach(Vertex v in selection)
|
||||
{
|
||||
|
@ -352,6 +378,38 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// Return result
|
||||
return closest;
|
||||
}
|
||||
|
||||
// This finds the vertex closest to the specified position
|
||||
public static Vertex NearestVertexSquareRange(ICollection<Vertex> selection, Vector2D pos, float maxrange)
|
||||
{
|
||||
RectangleF range = RectangleF.FromLTRB(pos.x - maxrange, pos.y - maxrange, pos.x + maxrange, pos.y + maxrange);
|
||||
Vertex closest = null;
|
||||
float distance = float.MaxValue;
|
||||
float d;
|
||||
|
||||
// Go for all vertices in selection
|
||||
foreach(Vertex v in selection)
|
||||
{
|
||||
// Within range?
|
||||
if((v.Position.x >= range.Left) && (v.Position.x <= range.Right))
|
||||
{
|
||||
if((v.Position.y >= range.Top) && (v.Position.y <= range.Bottom))
|
||||
{
|
||||
// Close than previous find?
|
||||
d = Math.Abs(v.Position.x - pos.x) + Math.Abs(v.Position.y - pos.y);
|
||||
if(d < distance)
|
||||
{
|
||||
// This one is closer
|
||||
closest = v;
|
||||
distance = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return result
|
||||
return closest;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -360,9 +418,15 @@ namespace CodeImp.DoomBuilder.Map
|
|||
// This finds the line closest to the specified position
|
||||
public Linedef NearestLinedef(Vector2D pos) { return MapSet.NearestLinedef(linedefs, pos); }
|
||||
|
||||
// This finds the line closest to the specified position
|
||||
public Linedef NearestLinedefRange(Vector2D pos, float maxrange) { return MapSet.NearestLinedefRange(linedefs, pos, maxrange); }
|
||||
|
||||
// This finds the vertex closest to the specified position
|
||||
public Vertex NearestVertex(Vector2D pos) { return MapSet.NearestVertex(vertices, pos); }
|
||||
|
||||
// This finds the vertex closest to the specified position
|
||||
public Vertex NearestVertexSquareRange(Vector2D pos, float maxrange) { return MapSet.NearestVertexSquareRange(vertices, pos, maxrange); }
|
||||
|
||||
// This performs sidedefs compression
|
||||
public void CompressSidedefs()
|
||||
{
|
||||
|
|
|
@ -66,6 +66,7 @@ namespace CodeImp.DoomBuilder.Map
|
|||
#region ================== Properties
|
||||
|
||||
public MapSet Map { get { return map; } }
|
||||
public ICollection<Sidedef> Sidedefs { get { return sidedefs; } }
|
||||
public bool IsDisposed { get { return isdisposed; } }
|
||||
public int FloorHeight { get { return floorheight; } }
|
||||
public int CeilHeight { get { return ceilheight; } }
|
||||
|
|
21
Source/Properties/Resources.Designer.cs
generated
21
Source/Properties/Resources.Designer.cs
generated
|
@ -74,6 +74,13 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap LinesMode {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("LinesMode", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap NewMap {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("NewMap", resourceCulture);
|
||||
|
@ -102,6 +109,13 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap SectorsMode {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("SectorsMode", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Splash2 {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Splash2", resourceCulture);
|
||||
|
@ -116,6 +130,13 @@ namespace CodeImp.DoomBuilder.Properties {
|
|||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap VerticesMode {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("VerticesMode", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
internal static System.Drawing.Bitmap Zoom {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("Zoom", resourceCulture);
|
||||
|
|
|
@ -118,14 +118,20 @@
|
|||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="Splash2small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash2small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="ColorPick" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ColorPick.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="NewMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewMap2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Properties" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Properties.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="File" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="VerticesMode" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\VerticesMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Splash2" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
|
@ -133,16 +139,19 @@
|
|||
<data name="Zoom" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Zoom.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="NewMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\NewMap2.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="OpenMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\OpenMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="LinesMode" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\LinesMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="SaveMap" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SaveMap.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="Properties" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Properties.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="Splash2small" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\Splash2small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="ColorPick" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\ColorPick.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
<data name="SectorsMode" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\SectorsMode.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
|
@ -56,9 +56,13 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
|
||||
// View settings (world coordinates)
|
||||
private float scale;
|
||||
private float scaleinv;
|
||||
private float offsetx;
|
||||
private float offsety;
|
||||
|
||||
private float translatex;
|
||||
private float translatey;
|
||||
private float linenormalsize;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -206,13 +210,18 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// This begins a drawing session
|
||||
public unsafe bool StartRendering(bool cleardisplay)
|
||||
{
|
||||
LockFlags lockflags;
|
||||
LockedRect rect;
|
||||
|
||||
// Do we have a texture?
|
||||
if(tex != null)
|
||||
{
|
||||
// Determine lock requirements
|
||||
if(cleardisplay) lockflags = LockFlags.Discard | LockFlags.NoSystemLock;
|
||||
else lockflags = LockFlags.NoSystemLock;
|
||||
|
||||
// Lock memory
|
||||
rect = tex.LockRectangle(0, LockFlags.Discard);
|
||||
rect = tex.LockRectangle(0, lockflags);
|
||||
|
||||
// Create plotter
|
||||
plotter = new Plotter((PixelColor*)rect.Data.DataPointer.ToPointer(), rect.Pitch / sizeof(PixelColor), pheight, width, height);
|
||||
|
@ -244,6 +253,7 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
// Change position in world coordinates
|
||||
offsetx = x;
|
||||
offsety = y;
|
||||
UpdateTransformations();
|
||||
}
|
||||
|
||||
// This changes zoom
|
||||
|
@ -251,7 +261,8 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
{
|
||||
// Change zoom scale
|
||||
this.scale = scale;
|
||||
|
||||
UpdateTransformations();
|
||||
|
||||
// Show zoom on main window
|
||||
General.MainWindow.UpdateZoom(scale);
|
||||
|
||||
|
@ -259,94 +270,131 @@ namespace CodeImp.DoomBuilder.Rendering
|
|||
foreach(Linedef l in General.Map.Map.Linedefs) l.NeedUpdate();
|
||||
}
|
||||
|
||||
// This updates some maths
|
||||
private void UpdateTransformations()
|
||||
{
|
||||
scaleinv = 1f / scale;
|
||||
translatex = -offsetx + (width * 0.5f) * scaleinv;
|
||||
translatey = -offsety - (height * 0.5f) * scaleinv;
|
||||
linenormalsize = 10f * scaleinv;
|
||||
}
|
||||
|
||||
// This unprojects mouse coordinates into map coordinates
|
||||
public Vector2D GetMapCoordinates(Vector2D mousepos)
|
||||
{
|
||||
float ox = -offsetx + (width * 0.5f) / scale;
|
||||
float oy = -offsety - (height * 0.5f) / scale;
|
||||
return mousepos.GetTransformed(ox, oy, scale, -scale);
|
||||
return mousepos.GetInvTransformed(-translatex, -translatey, scaleinv, -scaleinv);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Colors
|
||||
|
||||
// This returns the color for a vertex
|
||||
public PixelColor DetermineVertexColor(Vertex v)
|
||||
{
|
||||
// Determine color
|
||||
if(v.Selected > 0) return General.Colors.Selection;
|
||||
else return General.Colors.Vertices;
|
||||
}
|
||||
|
||||
// This returns the color for a linedef
|
||||
public PixelColor DetermineLinedefColor(Linedef l)
|
||||
{
|
||||
// Sinlgesided lines
|
||||
if((l.Back == null) || (l.Front == null))
|
||||
{
|
||||
// Determine color
|
||||
if(l.Selected > 0) return General.Colors.Selection;
|
||||
else if(l.Action != 0) return General.Colors.Actions;
|
||||
else return General.Colors.Linedefs;
|
||||
}
|
||||
// Doublesided lines
|
||||
else
|
||||
{
|
||||
// Determine color
|
||||
if(l.Selected > 0) return General.Colors.Selection;
|
||||
else if(l.Action != 0) return General.Colors.Actions.WithAlpha(DOUBLESIDED_LINE_ALPHA);
|
||||
else if((l.Flags & General.Map.Settings.SoundLinedefFlags) != 0) return General.Colors.Sounds.WithAlpha(DOUBLESIDED_LINE_ALPHA);
|
||||
else return General.Colors.Linedefs.WithAlpha(DOUBLESIDED_LINE_ALPHA);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Map Rendering
|
||||
|
||||
// This renders a set of Linedefs
|
||||
public void RenderLinedefs(MapSet map, ICollection<Linedef> linedefs, Linedef highlight)
|
||||
// This renders the linedefs of a sector with special color
|
||||
public void RenderSector(Sector s, PixelColor c)
|
||||
{
|
||||
float ox = -offsetx + (width * 0.5f) / scale;
|
||||
float oy = -offsety - (height * 0.5f) / scale;
|
||||
float indicatorlength = 10f / scale;
|
||||
PixelColor c;
|
||||
Vector2D v1, v2;
|
||||
float mx, my, ix, iy;
|
||||
|
||||
// Go for all linedefs
|
||||
foreach(Linedef l in linedefs)
|
||||
// Go for all sides in the sector
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
v1 = l.Start.Position.GetTransformed(ox, oy, scale, -scale);
|
||||
v2 = l.End.Position.GetTransformed(ox, oy, scale, -scale);
|
||||
// Render this linedef
|
||||
RenderLinedef(sd.Line, c);
|
||||
|
||||
// Sinlgesided lines
|
||||
if((l.Back == null) || (l.Front == null))
|
||||
{
|
||||
// Determine color
|
||||
if(l == highlight) c = General.Colors.Highlight;
|
||||
else if(l.Selected > 0) c = General.Colors.Selection;
|
||||
else if(l.Action != 0) c = General.Colors.Actions;
|
||||
else c = General.Colors.Linedefs;
|
||||
}
|
||||
// Doublesided lines
|
||||
else
|
||||
{
|
||||
// Determine color
|
||||
if(l == highlight) c = General.Colors.Highlight;
|
||||
else if(l.Selected > 0) c = General.Colors.Selection;
|
||||
else if(l.Action != 0) c = General.Colors.Actions.WithAlpha(DOUBLESIDED_LINE_ALPHA);
|
||||
else if((l.Flags & General.Map.Settings.SoundLinedefFlags) != 0) c = General.Colors.Sounds.WithAlpha(DOUBLESIDED_LINE_ALPHA);
|
||||
else c = General.Colors.Linedefs.WithAlpha(DOUBLESIDED_LINE_ALPHA);
|
||||
}
|
||||
|
||||
// Draw line
|
||||
plotter.DrawLineSolid((int)v1.x, (int)v1.y, (int)v2.x, (int)v2.y, c);
|
||||
|
||||
// Calculate normal indicator
|
||||
mx = (v2.x - v1.x) * 0.5f;
|
||||
my = (v2.y - v1.y) * 0.5f;
|
||||
iy = (v1.y + my) + (mx * l.LengthInv) * indicatorlength;
|
||||
ix = (v1.x + mx) - (my * l.LengthInv) * indicatorlength;
|
||||
|
||||
// Draw normal indicator
|
||||
plotter.DrawLineSolid((int)(v1.x + mx), (int)(v1.y + my), (int)ix, (int)iy, c);
|
||||
// Render the two vertices on top
|
||||
RenderVertex(sd.Line.Start, DetermineVertexColor(sd.Line.Start));
|
||||
RenderVertex(sd.Line.End, DetermineVertexColor(sd.Line.End));
|
||||
}
|
||||
}
|
||||
|
||||
// This renders a set of Linedefs
|
||||
public void RenderVertices(MapSet map, ICollection<Vertex> vertices, Vertex highlight)
|
||||
// This renders the linedefs of a sector
|
||||
public void RenderSector(Sector s)
|
||||
{
|
||||
Vector2D nv;
|
||||
float ox = -offsetx + (width * 0.5f) / scale;
|
||||
float oy = -offsety - (height * 0.5f) / scale;
|
||||
PixelColor c;
|
||||
int x, y;
|
||||
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in vertices)
|
||||
// Go for all sides in the sector
|
||||
foreach(Sidedef sd in s.Sidedefs)
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
nv = v.Position.GetTransformed(ox, oy, scale, -scale);
|
||||
x = (int)nv.x;
|
||||
y = (int)nv.y;
|
||||
|
||||
// Determine color
|
||||
if(v == highlight) c = General.Colors.Highlight;
|
||||
else if(v.Selected > 0) c = General.Colors.Selection;
|
||||
else c = General.Colors.Vertices;
|
||||
|
||||
// Draw pixel here
|
||||
plotter.DrawVertexSolid(x, y, 2, c);
|
||||
// Render this linedef
|
||||
RenderLinedef(sd.Line, DetermineLinedefColor(sd.Line));
|
||||
|
||||
// Render the two vertices on top
|
||||
RenderVertex(sd.Line.Start, DetermineVertexColor(sd.Line.Start));
|
||||
RenderVertex(sd.Line.End, DetermineVertexColor(sd.Line.End));
|
||||
}
|
||||
}
|
||||
|
||||
// This renders a single linedef
|
||||
public void RenderLinedef(Linedef l, PixelColor c)
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
Vector2D v1 = l.Start.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
Vector2D v2 = l.End.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
||||
// Draw line
|
||||
plotter.DrawLineSolid((int)v1.x, (int)v1.y, (int)v2.x, (int)v2.y, c);
|
||||
|
||||
// Calculate normal indicator
|
||||
float mx = (v2.x - v1.x) * 0.5f;
|
||||
float my = (v2.y - v1.y) * 0.5f;
|
||||
|
||||
// Draw normal indicator
|
||||
plotter.DrawLineSolid((int)(v1.x + mx), (int)(v1.y + my),
|
||||
(int)((v1.x + mx) - (my * l.LengthInv) * linenormalsize),
|
||||
(int)((v1.y + my) + (mx * l.LengthInv) * linenormalsize), c);
|
||||
}
|
||||
|
||||
// This renders a set of linedefs
|
||||
public void RenderLinedefSet(MapSet map, ICollection<Linedef> linedefs)
|
||||
{
|
||||
// Go for all linedefs
|
||||
foreach(Linedef l in linedefs) RenderLinedef(l, DetermineLinedefColor(l));
|
||||
}
|
||||
|
||||
// This renders a single vertex
|
||||
public void RenderVertex(Vertex v, PixelColor c)
|
||||
{
|
||||
// Transform vertex coordinates
|
||||
Vector2D nv = v.Position.GetTransformed(translatex, translatey, scale, -scale);
|
||||
|
||||
// Draw pixel here
|
||||
plotter.DrawVertexSolid((int)nv.x, (int)nv.y, 2, c);
|
||||
}
|
||||
|
||||
// This renders a set of vertices
|
||||
public void RenderVerticesSet(MapSet map, ICollection<Vertex> vertices)
|
||||
{
|
||||
// Go for all vertices
|
||||
foreach(Vertex v in vertices) RenderVertex(v, DetermineVertexColor(v));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -148,3 +148,30 @@ reloadresources
|
|||
allowmouse = false;
|
||||
allowscroll = false;
|
||||
}
|
||||
|
||||
verticesmode
|
||||
{
|
||||
title = "Tools: Vertices Mode";
|
||||
description = "Switches to vertices editing mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
linedefsmode
|
||||
{
|
||||
title = "Tools: Linedefs Mode";
|
||||
description = "Switches to linedefs editing mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
sectorsmode
|
||||
{
|
||||
title = "Tools: Sectors Mode";
|
||||
description = "Switches to sectors editing mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
|
BIN
Source/Resources/LinesMode.png
Normal file
BIN
Source/Resources/LinesMode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 291 B |
BIN
Source/Resources/SectorsMode.png
Normal file
BIN
Source/Resources/SectorsMode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 340 B |
BIN
Source/Resources/VerticesMode.png
Normal file
BIN
Source/Resources/VerticesMode.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 209 B |
Loading…
Reference in a new issue