mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-01-31 04:40:55 +00:00
drag texture offsets in visual mode
This commit is contained in:
parent
8192c3c058
commit
5b223fc3df
9 changed files with 165 additions and 35 deletions
|
@ -126,6 +126,7 @@
|
|||
<Compile Include="ClassicModes\ThingsMode.cs" />
|
||||
<Compile Include="ClassicModes\VerticesMode.cs" />
|
||||
<Compile Include="VisualModes\VisualMiddleDouble.cs" />
|
||||
<Compile Include="VisualModes\VisualSidedefParts.cs" />
|
||||
<Compile Include="VisualModes\VisualUpper.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -66,6 +66,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Properties
|
||||
|
||||
public bool IsDraggingUV { get { return uvdragging; } }
|
||||
new public BaseVisualSector Sector { get { return (BaseVisualSector)base.Sector; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -77,6 +78,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
this.mode = mode;
|
||||
this.deltaz = new Vector3D(0.0f, 0.0f, 1.0f);
|
||||
this.deltaxy = (sd.Line.End.Position - sd.Line.Start.Position) * sd.Line.LengthInv;
|
||||
if(!sd.IsFront) this.deltaxy = -this.deltaxy;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -104,11 +106,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Events
|
||||
|
||||
// Unused
|
||||
public virtual void OnSelectBegin() { }
|
||||
public virtual void OnSelectEnd() { }
|
||||
public virtual void OnEditBegin() { }
|
||||
|
||||
// Edit button pressed
|
||||
public virtual void OnEditBegin()
|
||||
// Select button pressed
|
||||
public virtual void OnSelectBegin()
|
||||
{
|
||||
dragstartanglexy = mode.CameraAngleXY;
|
||||
dragstartanglez = mode.CameraAngleZ;
|
||||
|
@ -117,8 +118,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
startoffsety = Sidedef.OffsetY;
|
||||
}
|
||||
|
||||
// Edit button released
|
||||
public virtual void OnEditEnd()
|
||||
// Select button released
|
||||
public virtual void OnSelectEnd()
|
||||
{
|
||||
// Was dragging?
|
||||
if(uvdragging)
|
||||
|
@ -129,13 +130,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
else
|
||||
{
|
||||
List<Linedef> lines = new List<Linedef>();
|
||||
lines.Add(this.Sidedef.Line);
|
||||
DialogResult result = General.Interface.ShowEditLinedefs(lines);
|
||||
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
|
||||
// Add/remove selection
|
||||
}
|
||||
}
|
||||
|
||||
// Edit button released
|
||||
public virtual void OnEditEnd()
|
||||
{
|
||||
List<Linedef> lines = new List<Linedef>();
|
||||
lines.Add(this.Sidedef.Line);
|
||||
DialogResult result = General.Interface.ShowEditLinedefs(lines);
|
||||
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
|
||||
}
|
||||
|
||||
// Mouse moves
|
||||
public virtual void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
|
@ -146,15 +153,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
else
|
||||
{
|
||||
// Check if tolerance is exceeded to start UV dragging
|
||||
float deltaxy = mode.CameraAngleXY - dragstartanglexy;
|
||||
float deltaz = mode.CameraAngleZ - dragstartanglez;
|
||||
if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE)
|
||||
// Select button pressed?
|
||||
if(General.Interface.CheckActionActive(General.ThisAssembly, "visualselect"))
|
||||
{
|
||||
// Start drag now
|
||||
uvdragging = true;
|
||||
mode.LockTarget();
|
||||
UpdateDragUV();
|
||||
// Check if tolerance is exceeded to start UV dragging
|
||||
float deltaxy = mode.CameraAngleXY - dragstartanglexy;
|
||||
float deltaz = mode.CameraAngleZ - dragstartanglez;
|
||||
if((Math.Abs(deltaxy) + Math.Abs(deltaz)) > DRAG_ANGLE_TOLERANCE)
|
||||
{
|
||||
// Start drag now
|
||||
uvdragging = true;
|
||||
mode.LockTarget();
|
||||
UpdateDragUV();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,13 +186,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
Vector3D dragdeltaz = dragdelta * deltaz;
|
||||
float offsetx = dragdeltaxy.GetLength();
|
||||
float offsety = dragdeltaz.GetLength();
|
||||
if((Math.Sign(dragdeltaxy.x) < 0) || (Math.Sign(dragdeltaxy.y) < 0) || (Math.Sign(dragdeltaxy.z) < 0)) offsetx = -offsetx;
|
||||
if((Math.Sign(dragdeltaz.x) < 0) || (Math.Sign(dragdeltaz.y) < 0) || (Math.Sign(dragdeltaz.z) < 0)) offsety = -offsety;
|
||||
|
||||
// Apply offsets
|
||||
Sidedef.OffsetX = startoffsetx + (int)Math.Round(offsetx);
|
||||
Sidedef.OffsetX = startoffsetx - (int)Math.Round(offsetx);
|
||||
Sidedef.OffsetY = startoffsety + (int)Math.Round(offsety);
|
||||
|
||||
// TODO: Update sidedef geometry
|
||||
|
||||
// Update sidedef geometry
|
||||
VisualSidedefParts parts = Sector.GetSidedefParts(Sidedef);
|
||||
if(parts.lower != null) parts.lower.Setup();
|
||||
if(parts.middledouble != null) parts.middledouble.Setup();
|
||||
if(parts.middlesingle != null) parts.middlesingle.Setup();
|
||||
if(parts.upper != null) parts.upper.Setup();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
@ -229,6 +229,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
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
|
||||
|
@ -279,6 +283,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public override void OnMouseMove(MouseEventArgs e)
|
||||
{
|
||||
base.OnMouseMove(e);
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnMouseMove(e);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -288,6 +293,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[BeginAction("visualselect", BaseAction = true)]
|
||||
public void BeginSelect()
|
||||
{
|
||||
General.WriteLogLine("BeginSelect");
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectBegin();
|
||||
}
|
||||
|
@ -295,6 +301,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
[EndAction("visualselect", BaseAction = true)]
|
||||
public void EndSelect()
|
||||
{
|
||||
General.WriteLogLine("EndSelect");
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnSelectEnd();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
#region ================== Variables
|
||||
|
||||
protected BaseVisualMode mode;
|
||||
|
||||
protected VisualFloor floor;
|
||||
protected VisualCeiling ceiling;
|
||||
protected Dictionary<Sidedef, VisualSidedefParts> sides;
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Properties
|
||||
|
||||
public VisualFloor Floor { get { return floor; } }
|
||||
public VisualCeiling Ceiling { get { return ceiling; } }
|
||||
|
||||
#endregion
|
||||
|
||||
#region ================== Constructor / Disposer
|
||||
|
@ -73,7 +80,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(!IsDisposed)
|
||||
{
|
||||
// Clean up
|
||||
|
||||
sides = null;
|
||||
floor = null;
|
||||
ceiling = null;
|
||||
|
||||
// Dispose base
|
||||
base.Dispose();
|
||||
}
|
||||
|
@ -90,14 +100,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
base.ClearGeometry();
|
||||
|
||||
// Create floor
|
||||
VisualFloor vf = new VisualFloor(mode, this);
|
||||
if(vf.Setup()) base.AddGeometry(vf);
|
||||
floor = new VisualFloor(mode, this);
|
||||
if(floor.Setup()) base.AddGeometry(floor);
|
||||
|
||||
// Create ceiling
|
||||
VisualCeiling vc = new VisualCeiling(mode, this);
|
||||
if(vc.Setup()) base.AddGeometry(vc);
|
||||
ceiling = new VisualCeiling(mode, this);
|
||||
if(ceiling.Setup()) base.AddGeometry(ceiling);
|
||||
|
||||
// Go for all sidedefs
|
||||
sides = new Dictionary<Sidedef, VisualSidedefParts>(base.Sector.Sidedefs.Count);
|
||||
foreach(Sidedef sd in base.Sector.Sidedefs)
|
||||
{
|
||||
// Doublesided or singlesided?
|
||||
|
@ -114,16 +125,31 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
// Create middle part
|
||||
VisualMiddleDouble vm = new VisualMiddleDouble(mode, this, sd);
|
||||
if(vm.Setup()) base.AddGeometry(vm);
|
||||
|
||||
// Store
|
||||
sides.Add(sd, new VisualSidedefParts(vu, vl, vm));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create middle part
|
||||
VisualMiddleSingle vm = new VisualMiddleSingle(mode, this, sd);
|
||||
if(vm.Setup()) base.AddGeometry(vm);
|
||||
|
||||
// Store
|
||||
sides.Add(sd, new VisualSidedefParts(vm));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// This returns the visual sidedef parts for a given sidedef
|
||||
public VisualSidedefParts GetSidedefParts(Sidedef sd)
|
||||
{
|
||||
if(sides.ContainsKey(sd))
|
||||
return sides[sd];
|
||||
else
|
||||
return new VisualSidedefParts();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
65
Source/BuilderModes/VisualModes/VisualSidedefParts.cs
Normal file
65
Source/BuilderModes/VisualModes/VisualSidedefParts.cs
Normal file
|
@ -0,0 +1,65 @@
|
|||
|
||||
#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.VisualModes;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
internal struct VisualSidedefParts
|
||||
{
|
||||
// Members
|
||||
public VisualUpper upper;
|
||||
public VisualLower lower;
|
||||
public VisualMiddleDouble middledouble;
|
||||
public VisualMiddleSingle middlesingle;
|
||||
|
||||
// Constructor
|
||||
public VisualSidedefParts(VisualUpper u, VisualLower l, VisualMiddleDouble m)
|
||||
{
|
||||
this.upper = u;
|
||||
this.lower = l;
|
||||
this.middledouble = m;
|
||||
this.middlesingle = null;
|
||||
}
|
||||
|
||||
// Constructor
|
||||
public VisualSidedefParts(VisualMiddleSingle m)
|
||||
{
|
||||
this.upper = null;
|
||||
this.lower = null;
|
||||
this.middledouble = null;
|
||||
this.middlesingle = m;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -150,7 +150,7 @@ namespace CodeImp.DoomBuilder
|
|||
|
||||
#region ================== Properties
|
||||
|
||||
internal static Assembly ThisAssembly { get { return thisasm; } }
|
||||
public static Assembly ThisAssembly { get { return thisasm; } }
|
||||
public static string AppPath { get { return apppath; } }
|
||||
public static string TempPath { get { return temppath; } }
|
||||
public static string ConfigsPath { get { return configspath; } }
|
||||
|
|
|
@ -93,8 +93,8 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
|
||||
public Vector3D CameraPosition { get { return campos; } set { campos = value; } }
|
||||
public Vector3D CameraTarget { get { return camtarget; } }
|
||||
public float CameraAngleXY { get { return camanglexy; } }
|
||||
public float CameraAngleZ { get { return camanglez; } }
|
||||
public float CameraAngleXY { get { return camanglexy; } set { camanglexy = value; } }
|
||||
public float CameraAngleZ { get { return camanglez; } set { camanglez = value; } }
|
||||
public Sector CameraSector { get { return camsector; } }
|
||||
public bool ProcessGeometry { get { return processgeometry; } set { processgeometry = value; } }
|
||||
public bool ProcessThings { get { return processthings; } set { processthings = value; } }
|
||||
|
@ -256,7 +256,7 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// Change camera angles with the mouse changes
|
||||
camanglexy -= delta.x * ANGLE_FROM_MOUSE;
|
||||
camanglez += delta.y * ANGLE_FROM_MOUSE;
|
||||
|
||||
|
||||
// Normalize angles
|
||||
camanglexy = Angle2D.Normalized(camanglexy);
|
||||
camanglez = Angle2D.Normalized(camanglez);
|
||||
|
@ -264,8 +264,6 @@ namespace CodeImp.DoomBuilder.VisualModes
|
|||
// Limit vertical angle
|
||||
if(camanglez < MAX_ANGLEZ_LOW) camanglez = MAX_ANGLEZ_LOW;
|
||||
if(camanglez > MAX_ANGLEZ_HIGH) camanglez = MAX_ANGLEZ_HIGH;
|
||||
|
||||
General.MainWindow.UpdateCoordinates(new Vector2D(camanglexy, camanglez));
|
||||
}
|
||||
|
||||
[BeginAction("moveforward", BaseAction = true)]
|
||||
|
|
|
@ -48,7 +48,8 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
bool AutoMerge { get; }
|
||||
bool SnapToGrid { get; }
|
||||
bool MouseExclusive { get; }
|
||||
|
||||
MouseButtons MouseButtons { get; }
|
||||
|
||||
// Methods
|
||||
void DisplayReady();
|
||||
void DisplayStatus(string status);
|
||||
|
|
|
@ -92,6 +92,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
|
||||
// Input
|
||||
private bool shift, ctrl, alt;
|
||||
private MouseButtons mousebuttons;
|
||||
private MouseInput mouseinput;
|
||||
private Rectangle originalclip;
|
||||
private bool mouseexclusive;
|
||||
|
@ -132,6 +133,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
public bool ShiftState { get { return shift; } }
|
||||
public bool CtrlState { get { return ctrl; } }
|
||||
public bool AltState { get { return alt; } }
|
||||
public MouseButtons MouseButtons { get { return mousebuttons; } }
|
||||
public bool MouseInDisplay { get { return mouseinside; } }
|
||||
internal RenderTargetControl Display { get { return display; } }
|
||||
public bool SnapToGrid { get { return buttonsnaptogrid.Checked; } }
|
||||
|
@ -364,6 +366,7 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
// Release all pressed keys
|
||||
General.Actions.ReleaseAllKeys();
|
||||
mousebuttons = MouseButtons.None;
|
||||
|
||||
// Stop exclusive mouse input
|
||||
BreakExclusiveMouseInput();
|
||||
|
@ -873,16 +876,25 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
}
|
||||
|
||||
// Mouse click
|
||||
private void display_MouseClick(object sender, MouseEventArgs e) { if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseClick(e); }
|
||||
private void display_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseClick(e);
|
||||
}
|
||||
|
||||
// Mouse doubleclick
|
||||
private void display_MouseDoubleClick(object sender, MouseEventArgs e) { if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseDoubleClick(e); }
|
||||
private void display_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if((General.Map != null) && (General.Editing.Mode != null)) General.Editing.Mode.OnMouseDoubleClick(e);
|
||||
}
|
||||
|
||||
// Mouse down
|
||||
private void display_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
int key = 0;
|
||||
|
||||
// Apply button
|
||||
mousebuttons |= e.Button;
|
||||
|
||||
// Create key
|
||||
switch(e.Button)
|
||||
{
|
||||
|
@ -925,6 +937,9 @@ namespace CodeImp.DoomBuilder.Windows
|
|||
{
|
||||
int key = 0;
|
||||
|
||||
// Apply button
|
||||
mousebuttons &= ~e.Button;
|
||||
|
||||
// Create key
|
||||
switch(e.Button)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue