mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2024-11-23 04:12:12 +00:00
@ work in progress
This commit is contained in:
parent
f95e8bd09f
commit
4a21274521
9 changed files with 307 additions and 13 deletions
BIN
Resources/Icons/CeilingAlign.png
Normal file
BIN
Resources/Icons/CeilingAlign.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 579 B |
BIN
Resources/Icons/FloorAlign.png
Normal file
BIN
Resources/Icons/FloorAlign.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 583 B |
103
Source/Plugins/GZDoomEditing/ClassicModes/CeilingAlignMode.cs
Normal file
103
Source/Plugins/GZDoomEditing/ClassicModes/CeilingAlignMode.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
|
||||
#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.Data;
|
||||
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 System.Drawing;
|
||||
using CodeImp.DoomBuilder.Actions;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||
{
|
||||
[EditMode(DisplayName = "Ceiling Align Mode",
|
||||
SwitchAction = "ceilingalignmode",
|
||||
ButtonImage = "CeilingAlign.png",
|
||||
ButtonOrder = int.MinValue + 211,
|
||||
ButtonGroup = "000_editing",
|
||||
Volatile = true)]
|
||||
|
||||
public class CeilingAlignMode : FlatAlignMode
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override string XScaleName { get { return "xscaleceiling"; } }
|
||||
public override string YScaleName { get { return "yscaleceiling"; } }
|
||||
public override string XOffsetName { get { return "xpanningceiling"; } }
|
||||
public override string YOffsetName { get { return "ypanningceiling"; } }
|
||||
public override string RotationName { get { return "rotationceiling"; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public CeilingAlignMode()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// Get the texture data to align
|
||||
protected override ImageData GetTexture(Sector editsector)
|
||||
{
|
||||
return General.Map.Data.GetFlatImage(editsector.LongCeilTexture);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
// Mode engages
|
||||
public override void OnEngage()
|
||||
{
|
||||
base.OnEngage();
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
public override void OnDisengage()
|
||||
{
|
||||
base.OnDisengage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -24,6 +24,7 @@ using System.Text;
|
|||
using System.Windows.Forms;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
using CodeImp.DoomBuilder.Windows;
|
||||
using CodeImp.DoomBuilder.IO;
|
||||
using CodeImp.DoomBuilder.Map;
|
||||
|
@ -37,14 +38,7 @@ using CodeImp.DoomBuilder.Actions;
|
|||
|
||||
namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||
{
|
||||
[EditMode(DisplayName = "Flat Align Mode",
|
||||
SwitchAction = "flatalignmode",
|
||||
ButtonImage = "VisualModeZ.png",
|
||||
ButtonOrder = int.MinValue + 210,
|
||||
ButtonGroup = "000_editing",
|
||||
Volatile = true)]
|
||||
|
||||
public class FlatAlignMode : BaseClassicMode
|
||||
public abstract class FlatAlignMode : BaseClassicMode
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
|
@ -53,13 +47,29 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
#region ================== Variables
|
||||
|
||||
private ICollection<Sector> selection;
|
||||
protected Sector editsector;
|
||||
private ImageData texture;
|
||||
private Vector2D texturegraboffset;
|
||||
private float rotation;
|
||||
private Vector2D scale;
|
||||
private Vector2D offset;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public abstract string XScaleName { get; }
|
||||
public abstract string YScaleName { get; }
|
||||
public abstract string XOffsetName { get; }
|
||||
public abstract string YOffsetName { get; }
|
||||
public abstract string RotationName { get; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public FlatAlignMode()
|
||||
protected FlatAlignMode()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -67,6 +77,26 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
|
||||
#region ================== Methods
|
||||
|
||||
protected abstract ImageData GetTexture(Sector editsector);
|
||||
|
||||
// Transforms p from Texture space into World space
|
||||
protected Vector2D TexToWorld(Vector2D p)
|
||||
{
|
||||
p /= scale;
|
||||
p -= offset;
|
||||
p = p.GetRotated(-rotation);
|
||||
return p;
|
||||
}
|
||||
|
||||
// Transforms p from World space into Texture space
|
||||
protected Vector2D WorldToTex(Vector2D p)
|
||||
{
|
||||
p = p.GetRotated(rotation);
|
||||
p += offset;
|
||||
p *= scale;
|
||||
return p;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
@ -114,10 +144,44 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
General.Interface.MessageBeep(MessageBeepType.Default);
|
||||
General.Interface.DisplayStatus(StatusType.Info, "A selected sector is required for this action.");
|
||||
General.Editing.CancelMode();
|
||||
return;
|
||||
}
|
||||
editsector = General.GetByIndex(selection, 0);
|
||||
|
||||
// Get the texture
|
||||
texture = GetTexture(editsector);
|
||||
if((texture == null) || (texture == General.Map.Data.WhiteTexture) ||
|
||||
(texture.Width <= 0) || (texture.Height <= 0) || !texture.IsImageLoaded)
|
||||
{
|
||||
General.Interface.MessageBeep(MessageBeepType.Default);
|
||||
General.Interface.DisplayStatus(StatusType.Info, "The selected sector must have a loaded texture to align.");
|
||||
General.Editing.CancelMode();
|
||||
return;
|
||||
}
|
||||
|
||||
// Find the nearest texture corner
|
||||
// Cache the transformation values
|
||||
rotation = Angle2D.DegToRad(editsector.Fields.GetValue(RotationName, 0.0f));
|
||||
scale.x = editsector.Fields.GetValue(XScaleName, 1.0f);
|
||||
scale.y = editsector.Fields.GetValue(YScaleName, 1.0f);
|
||||
offset.x = editsector.Fields.GetValue(XOffsetName, 0.0f);
|
||||
offset.y = -editsector.Fields.GetValue(YOffsetName, 0.0f);
|
||||
|
||||
// We want the texture corner nearest to the center of the sector
|
||||
Vector2D fp;
|
||||
fp.x = (editsector.BBox.Left + editsector.BBox.Right) / 2;
|
||||
fp.y = (editsector.BBox.Top + editsector.BBox.Bottom) / 2;
|
||||
|
||||
// Transform the point into texture space
|
||||
fp = WorldToTex(fp);
|
||||
|
||||
// Snap to the nearest left-top corner
|
||||
fp.x = (float)Math.Round(fp.x / texture.ScaledWidth) * texture.ScaledWidth;
|
||||
fp.y = (float)Math.Round(fp.y / texture.ScaledHeight) * texture.ScaledHeight;
|
||||
texturegraboffset = fp;
|
||||
|
||||
// Transorm the point into world space
|
||||
// fp = fp.GetRotated(rotation);
|
||||
// fp = (fp / scale) + offset;
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
|
@ -153,6 +217,13 @@ namespace CodeImp.DoomBuilder.GZDoomEditing
|
|||
// Render overlay
|
||||
if(renderer.StartOverlay(true))
|
||||
{
|
||||
Vector2D rightpoint = texturegraboffset + new Vector2D(texture.ScaledWidth, 0f);
|
||||
|
||||
Vector2D p1world = TexToWorld(texturegraboffset);
|
||||
Vector2D p2world = TexToWorld(rightpoint);
|
||||
|
||||
renderer.RenderLine(p1world, p2world, 1f, General.Colors.Highlight, true);
|
||||
|
||||
renderer.Finish();
|
||||
}
|
||||
|
||||
|
|
103
Source/Plugins/GZDoomEditing/ClassicModes/FloorAlignMode.cs
Normal file
103
Source/Plugins/GZDoomEditing/ClassicModes/FloorAlignMode.cs
Normal file
|
@ -0,0 +1,103 @@
|
|||
|
||||
#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.Data;
|
||||
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 System.Drawing;
|
||||
using CodeImp.DoomBuilder.Actions;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.GZDoomEditing
|
||||
{
|
||||
[EditMode(DisplayName = "Floor Align Mode",
|
||||
SwitchAction = "flooralignmode",
|
||||
ButtonImage = "FloorAlign.png",
|
||||
ButtonOrder = int.MinValue + 210,
|
||||
ButtonGroup = "000_editing",
|
||||
Volatile = true)]
|
||||
|
||||
public class FloorAlignMode : FlatAlignMode
|
||||
{
|
||||
#region ================== Constants
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Variables
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public override string XScaleName { get { return "xscalefloor"; } }
|
||||
public override string YScaleName { get { return "yscalefloor"; } }
|
||||
public override string XOffsetName { get { return "xpanningfloor"; } }
|
||||
public override string YOffsetName { get { return "ypanningfloor"; } }
|
||||
public override string RotationName { get { return "rotationfloor"; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
||||
// Constructor
|
||||
public FloorAlignMode()
|
||||
{
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Methods
|
||||
|
||||
// Get the texture data to align
|
||||
protected override ImageData GetTexture(Sector editsector)
|
||||
{
|
||||
return General.Map.Data.GetFlatImage(editsector.LongFloorTexture);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Events
|
||||
|
||||
// Mode engages
|
||||
public override void OnEngage()
|
||||
{
|
||||
base.OnEngage();
|
||||
}
|
||||
|
||||
// Mode disengages
|
||||
public override void OnDisengage()
|
||||
{
|
||||
base.OnDisengage();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -42,7 +42,9 @@
|
|||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ClassicModes\BaseClassicMode.cs" />
|
||||
<Compile Include="ClassicModes\CeilingAlignMode.cs" />
|
||||
<Compile Include="ClassicModes\FlatAlignMode.cs" />
|
||||
<Compile Include="ClassicModes\FloorAlignMode.cs" />
|
||||
<Compile Include="General\BuilderPlug.cs" />
|
||||
<Compile Include="General\CopyStructures.cs" />
|
||||
<Compile Include="General\UndoGroup.cs" />
|
||||
|
@ -106,6 +108,10 @@
|
|||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\CeilingAlign.png" />
|
||||
<EmbeddedResource Include="Resources\FloorAlign.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
|
|
@ -12,13 +12,24 @@ gzdoomvisualmode
|
|||
allowscroll = true;
|
||||
}
|
||||
|
||||
flatalignmode
|
||||
flooralignmode
|
||||
{
|
||||
title = "Flat Align Mode";
|
||||
title = "Floor Align Mode";
|
||||
category = "modes";
|
||||
description = "Switches to the (G)ZDoom Flat Align mode.";
|
||||
description = "Switches to the (G)ZDoom Floor Align mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
ceilingalignmode
|
||||
{
|
||||
title = "Ceiling Align Mode";
|
||||
category = "modes";
|
||||
description = "Switches to the (G)ZDoom Ceiling Align mode.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
BIN
Source/Plugins/GZDoomEditing/Resources/CeilingAlign.png
Normal file
BIN
Source/Plugins/GZDoomEditing/Resources/CeilingAlign.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 579 B |
BIN
Source/Plugins/GZDoomEditing/Resources/FloorAlign.png
Normal file
BIN
Source/Plugins/GZDoomEditing/Resources/FloorAlign.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 583 B |
Loading…
Reference in a new issue