mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-18 22:41:46 +00:00
cleaning up
This commit is contained in:
parent
09da6dbefd
commit
ae79633c39
12 changed files with 150 additions and 102 deletions
|
@ -124,7 +124,6 @@
|
|||
<Compile Include="Geometry\EarClipPolygon.cs" />
|
||||
<Compile Include="Geometry\SidedefAngleSorter.cs" />
|
||||
<Compile Include="Geometry\SidedefsTracePath.cs" />
|
||||
<Compile Include="Geometry\TriangleList.cs" />
|
||||
<Compile Include="Geometry\Vector2D.cs" />
|
||||
<Compile Include="Geometry\Vector3D.cs" />
|
||||
<Compile Include="Data\TexturePatch.cs" />
|
||||
|
|
|
@ -38,13 +38,14 @@ using CodeImp.DoomBuilder.Data;
|
|||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
[EditMode(DisplayName = "Sector Brightness",
|
||||
[EditMode(DisplayName = "Brightness Mode",
|
||||
SwitchAction = "brightnessmode",
|
||||
ButtonDesc = "Brightness Mode",
|
||||
ButtonImage = "BrightnessMode.png",
|
||||
ButtonOrder = int.MinValue + 201)]
|
||||
ButtonOrder = int.MinValue + 201,
|
||||
AllowCopyPaste = false)]
|
||||
|
||||
public class BrightnessMode : SectorsMode
|
||||
public sealed class BrightnessMode : BaseClassicMode
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -52,6 +53,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Variables
|
||||
|
||||
// Highlighted item
|
||||
private Sector highlighted;
|
||||
|
||||
// Interface
|
||||
private bool editpressed;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
@ -80,12 +87,92 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
// This updates the overlay
|
||||
private void UpdateOverlay()
|
||||
{
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
// Go for all sectors
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
{
|
||||
// Determine color by brightness
|
||||
PixelColor brightnesscolor = new PixelColor(255, (byte)s.Brightness, (byte)s.Brightness, (byte)s.Brightness);
|
||||
int brightnessint = brightnesscolor.ToInt();
|
||||
|
||||
|
||||
// This was only to test if it would work
|
||||
// It works, but it is very slow
|
||||
/*
|
||||
// Load texture image
|
||||
ImageData texture = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||
if(!texture.IsLoaded) texture.LoadImage();
|
||||
|
||||
// Make vertices
|
||||
FlatVertex[] verts = new FlatVertex[s.Vertices.Length];
|
||||
s.Vertices.CopyTo(verts, 0);
|
||||
for(int i = 0; i < verts.Length; i++)
|
||||
{
|
||||
verts[i].u = verts[i].x / texture.ScaledWidth;
|
||||
verts[i].v = verts[i].y / texture.ScaledHeight;
|
||||
}
|
||||
|
||||
// Render the geometry
|
||||
renderer.RenderGeometry(verts, texture, true);
|
||||
*/
|
||||
|
||||
// Render the geometry
|
||||
renderer.RenderGeometry(s.FlatVertices, null, true);
|
||||
}
|
||||
|
||||
if(selecting) RenderMultiSelection();
|
||||
|
||||
renderer.Finish();
|
||||
}
|
||||
}
|
||||
|
||||
// This highlights a new item
|
||||
protected void Highlight(Sector s)
|
||||
{
|
||||
// Update display
|
||||
if(renderer.StartPlotter(false))
|
||||
{
|
||||
// Undraw previous highlight
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
renderer.PlotSector(highlighted);
|
||||
|
||||
// Set new highlight
|
||||
highlighted = s;
|
||||
|
||||
// Render highlighted item
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
renderer.PlotSector(highlighted, General.Colors.Highlight);
|
||||
|
||||
// Done
|
||||
renderer.Finish();
|
||||
renderer.Present();
|
||||
}
|
||||
|
||||
// Show highlight info
|
||||
if((highlighted != null) && !highlighted.IsDisposed)
|
||||
General.Interface.ShowSectorInfo(highlighted);
|
||||
else
|
||||
General.Interface.HideInfo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
// Mode engages
|
||||
public override void OnEngage()
|
||||
{
|
||||
base.OnEngage();
|
||||
|
||||
// Make customized presentation
|
||||
// No selection
|
||||
General.Map.Map.ClearAllMarks(false);
|
||||
General.Map.Map.ClearAllSelected();
|
||||
|
||||
// Make custom presentation
|
||||
CustomPresentation p = new CustomPresentation();
|
||||
p.AddLayer(new PresentLayer(RendererLayer.Background, BlendingMode.Mask));
|
||||
p.AddLayer(new PresentLayer(RendererLayer.Grid, BlendingMode.Mask));
|
||||
|
@ -122,50 +209,57 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
renderer.Present();
|
||||
}
|
||||
|
||||
// This updates the overlay
|
||||
private void UpdateOverlay()
|
||||
// Mouse moves
|
||||
public override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
if(renderer.StartOverlay(true))
|
||||
base.OnMouseMove(e);
|
||||
|
||||
// Not holding any buttons?
|
||||
if(e.Button == MouseButtons.None)
|
||||
{
|
||||
// Go for all sectors
|
||||
foreach(Sector s in General.Map.Map.Sectors)
|
||||
// Find the nearest linedef within highlight range
|
||||
Linedef l = General.Map.Map.NearestLinedef(mousemappos);
|
||||
if(l != null)
|
||||
{
|
||||
// Determine color by brightness
|
||||
PixelColor brightnesscolor = new PixelColor(255, (byte)s.Brightness, (byte)s.Brightness, (byte)s.Brightness);
|
||||
int brightnessint = brightnesscolor.ToInt();
|
||||
|
||||
/*
|
||||
// Load texture image
|
||||
ImageData texture = General.Map.Data.GetFlatImage(s.LongFloorTexture);
|
||||
if(!texture.IsLoaded) texture.LoadImage();
|
||||
|
||||
// Make vertices
|
||||
FlatVertex[] verts = new FlatVertex[s.Vertices.Length];
|
||||
s.Vertices.CopyTo(verts, 0);
|
||||
for(int i = 0; i < verts.Length; i++)
|
||||
// Check on which side of the linedef the mouse is
|
||||
float side = l.SideOfLine(mousemappos);
|
||||
if(side > 0)
|
||||
{
|
||||
verts[i].u = verts[i].x / texture.ScaledWidth;
|
||||
verts[i].v = verts[i].y / texture.ScaledHeight;
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
// Render the geometry
|
||||
renderer.RenderGeometry(verts, texture, true);
|
||||
*/
|
||||
|
||||
// Render the geometry
|
||||
renderer.RenderGeometry(s.FlatVertices, null, true);
|
||||
}
|
||||
|
||||
if(selecting) RenderMultiSelection();
|
||||
|
||||
renderer.Finish();
|
||||
else
|
||||
{
|
||||
// Highlight nothing
|
||||
if(highlighted != null) Highlight(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Actions
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
public class EarClipPolygon : LinkedList<EarClipVertex>
|
||||
public sealed class EarClipPolygon : LinkedList<EarClipVertex>
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
public class EarClipVertex
|
||||
public sealed class EarClipVertex
|
||||
{
|
||||
#region ================== Variables
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
internal class LinedefAngleSorter : IComparer<Linedef>
|
||||
internal sealed class LinedefAngleSorter : IComparer<Linedef>
|
||||
{
|
||||
// Variables
|
||||
private Linedef baseline;
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
/// <summary>
|
||||
/// This is used to indicate a side of a line without the need for a sidedef.
|
||||
/// </summary>
|
||||
public class LinedefSide
|
||||
public sealed class LinedefSide
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
public class LinedefTracePath : List<Linedef>
|
||||
public sealed class LinedefTracePath : List<Linedef>
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
internal class SidedefAngleSorter : IComparer<Sidedef>
|
||||
internal sealed class SidedefAngleSorter : IComparer<Sidedef>
|
||||
{
|
||||
// Variables
|
||||
private Sidedef baseside;
|
||||
|
|
|
@ -31,7 +31,7 @@ using CodeImp.DoomBuilder.Map;
|
|||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
public class SidedefsTracePath : List<Sidedef>
|
||||
public sealed class SidedefsTracePath : List<Sidedef>
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
|
|
@ -1,44 +0,0 @@
|
|||
|
||||
#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 CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Rendering;
|
||||
using SlimDX.Direct3D9;
|
||||
using System.Drawing;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.Geometry
|
||||
{
|
||||
public class TriangleList : List<Vector2D>
|
||||
{
|
||||
// This adds a triangle
|
||||
internal void Add(EarClipVertex[] t)
|
||||
{
|
||||
base.Add(t[0].Position);
|
||||
base.Add(t[1].Position);
|
||||
base.Add(t[2].Position);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,7 +94,6 @@ namespace CodeImp.DoomBuilder.Geometry
|
|||
private Triangulation(Sector s)
|
||||
{
|
||||
// Initialize
|
||||
TriangleList triangles = new TriangleList();
|
||||
List<EarClipPolygon> polys;
|
||||
List<int> islandslist = new List<int>();
|
||||
List<Vector2D> verticeslist = new List<Vector2D>();
|
||||
|
|
Loading…
Reference in a new issue