mirror of
https://git.do.srb2.org/STJr/UltimateZoneBuilder.git
synced 2025-02-18 18:11:13 +00:00
Added actions in Visual Mode to copy and paste properties or texture offsets
This commit is contained in:
parent
7e3981775b
commit
f36c595d4b
9 changed files with 314 additions and 5 deletions
|
@ -77,6 +77,7 @@
|
|||
<Compile Include="FindReplace\FindSectorTags.cs" />
|
||||
<Compile Include="General\Association.cs" />
|
||||
<Compile Include="General\BuilderPlug.cs" />
|
||||
<Compile Include="General\CopyStructures.cs" />
|
||||
<Compile Include="Interface\CurveLinedefsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -66,6 +66,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
private bool editnewsector;
|
||||
private string copiedtexture;
|
||||
private string copiedflat;
|
||||
private Point copiedoffsets;
|
||||
private SectorProperties copiedsectorprops;
|
||||
private SidedefProperties copiedsidedefprops;
|
||||
private ThingProperties copiedthingprops;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -88,6 +92,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public bool EditNewSector { get { return editnewsector; } }
|
||||
public string CopiedTexture { get { return copiedtexture; } set { copiedtexture = value; } }
|
||||
public string CopiedFlat { get { return copiedflat; } set { copiedflat = value; } }
|
||||
public Point CopiedOffsets { get { return copiedoffsets; } set { copiedoffsets = value; } }
|
||||
public SectorProperties CopiedSectorProps { get { return copiedsectorprops; } set { copiedsectorprops = value; } }
|
||||
public SidedefProperties CopiedSidedefProps { get { return copiedsidedefprops; } set { copiedsidedefprops = value; } }
|
||||
public ThingProperties CopiedThingProps { get { return copiedthingprops; } set { copiedthingprops = value; } }
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
135
Source/BuilderModes/General/CopyStructures.cs
Normal file
135
Source/BuilderModes/General/CopyStructures.cs
Normal file
|
@ -0,0 +1,135 @@
|
|||
|
||||
#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 System.Drawing;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.Plugins;
|
||||
using CodeImp.DoomBuilder.Types;
|
||||
using CodeImp.DoomBuilder.Config;
|
||||
using CodeImp.DoomBuilder.Data;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace CodeImp.DoomBuilder.BuilderModes
|
||||
{
|
||||
// Sector
|
||||
public class SectorProperties
|
||||
{
|
||||
private int floorheight;
|
||||
private int ceilheight;
|
||||
private string floortexture;
|
||||
private string ceilingtexture;
|
||||
private int brightness;
|
||||
private int tag;
|
||||
|
||||
public SectorProperties(Sector s)
|
||||
{
|
||||
floorheight = s.FloorHeight;
|
||||
ceilheight = s.CeilHeight;
|
||||
floortexture = s.FloorTexture;
|
||||
ceilingtexture = s.CeilTexture;
|
||||
brightness = s.Brightness;
|
||||
tag = s.Tag;
|
||||
}
|
||||
|
||||
public void Apply(Sector s)
|
||||
{
|
||||
s.FloorHeight = floorheight;
|
||||
s.CeilHeight = ceilheight;
|
||||
s.SetFloorTexture(floortexture);
|
||||
s.SetCeilTexture(ceilingtexture);
|
||||
s.Brightness = brightness;
|
||||
s.Tag = s.Tag;
|
||||
}
|
||||
}
|
||||
|
||||
// Sidedef
|
||||
public class SidedefProperties
|
||||
{
|
||||
private string hightexture;
|
||||
private string middletexture;
|
||||
private string lowtexture;
|
||||
private int offsetx;
|
||||
private int offsety;
|
||||
|
||||
public SidedefProperties(Sidedef s)
|
||||
{
|
||||
hightexture = s.HighTexture;
|
||||
middletexture = s.MiddleTexture;
|
||||
lowtexture = s.LowTexture;
|
||||
offsetx = s.OffsetX;
|
||||
offsety = s.OffsetY;
|
||||
}
|
||||
|
||||
public void Apply(Sidedef s)
|
||||
{
|
||||
s.SetTextureHigh(hightexture);
|
||||
s.SetTextureMid(middletexture);
|
||||
s.SetTextureLow(lowtexture);
|
||||
s.OffsetX = offsetx;
|
||||
s.OffsetY = offsety;
|
||||
}
|
||||
}
|
||||
|
||||
// Thing
|
||||
public class ThingProperties
|
||||
{
|
||||
private int type;
|
||||
private float angle;
|
||||
private Dictionary<string, bool> flags;
|
||||
private int tag;
|
||||
private int action;
|
||||
private int[] args;
|
||||
|
||||
public ThingProperties(Thing t)
|
||||
{
|
||||
type = t.Type;
|
||||
angle = t.Angle;
|
||||
flags = new Dictionary<string, bool>(t.Flags);
|
||||
tag = t.Tag;
|
||||
action = t.Action;
|
||||
args = (int[])(t.Args.Clone());
|
||||
}
|
||||
|
||||
public void Apply(Thing t)
|
||||
{
|
||||
t.Type = type;
|
||||
t.Rotate(angle);
|
||||
t.Flags.Clear();
|
||||
foreach(KeyValuePair<string, bool> f in flags)
|
||||
t.Flags.Add(f.Key, f.Value);
|
||||
t.Tag = tag;
|
||||
t.Action = action;
|
||||
for(int i = 0; i < t.Args.Length; i++)
|
||||
t.Args[i] = args[i];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -437,7 +437,7 @@ movetexturedown8
|
|||
|
||||
textureselect
|
||||
{
|
||||
title = "Texture Select";
|
||||
title = "Select Texture";
|
||||
category = "visual";
|
||||
description = "Opens the texture browser to select a texture for the targeted or selected walls, floors or ceilings.";
|
||||
allowkeys = true;
|
||||
|
@ -447,7 +447,7 @@ textureselect
|
|||
|
||||
texturecopy
|
||||
{
|
||||
title = "Texture Copy";
|
||||
title = "Copy Texture";
|
||||
category = "visual";
|
||||
description = "Copies the targeted texture or flat for pasting.";
|
||||
allowkeys = true;
|
||||
|
@ -457,7 +457,7 @@ texturecopy
|
|||
|
||||
texturepaste
|
||||
{
|
||||
title = "Texture Paste";
|
||||
title = "Paste Texture";
|
||||
category = "visual";
|
||||
description = "Pastes the copied texture onto the targeted or selected walls, floors or ceilings.";
|
||||
allowkeys = true;
|
||||
|
@ -545,6 +545,46 @@ resettexture
|
|||
allowscroll = true;
|
||||
}
|
||||
|
||||
texturecopyoffsets
|
||||
{
|
||||
title = "Copy Offsets";
|
||||
category = "visual";
|
||||
description = "Copies the targeted texture offsets for pasting.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
texturepasteoffsets
|
||||
{
|
||||
title = "Paste Offsets";
|
||||
category = "visual";
|
||||
description = "Pastes the copied texture offsets onto the targeted or selected walls.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
copyproperties
|
||||
{
|
||||
title = "Copy Properties";
|
||||
category = "visual";
|
||||
description = "Copies the targeted object properties for pasting.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
pasteproperties
|
||||
{
|
||||
title = "Paste Properties";
|
||||
category = "visual";
|
||||
description = "Pastes the copied properties onto the targeted or selected object.";
|
||||
allowkeys = true;
|
||||
allowmouse = true;
|
||||
allowscroll = true;
|
||||
}
|
||||
|
||||
placevisualstart
|
||||
{
|
||||
title = "Place Visual Mode Camera";
|
||||
|
|
|
@ -125,6 +125,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void OnToggleUpperUnpegged() { }
|
||||
public virtual void OnToggleLowerUnpegged() { }
|
||||
public virtual void OnResetTextureOffset() { }
|
||||
public virtual void OnCopyTextureOffsets() { }
|
||||
public virtual void OnPasteTextureOffsets() { }
|
||||
protected virtual void SetTexture(string texturename) { }
|
||||
public virtual void OnTextureFloodfill() { }
|
||||
|
||||
|
@ -146,6 +148,24 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
}
|
||||
}
|
||||
|
||||
// Copy properties
|
||||
public virtual void OnCopyProperties()
|
||||
{
|
||||
BuilderPlug.Me.CopiedSectorProps = new SectorProperties(Sector.Sector);
|
||||
}
|
||||
|
||||
// Paste properties
|
||||
public virtual void OnPasteProperties()
|
||||
{
|
||||
if(BuilderPlug.Me.CopiedSectorProps != null)
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Paste sector properties");
|
||||
BuilderPlug.Me.CopiedSectorProps.Apply(Sector.Sector);
|
||||
UpdateSectorGeometry(true);
|
||||
mode.ShowTargetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
// Select texture
|
||||
public virtual void OnSelectTexture()
|
||||
{
|
||||
|
|
|
@ -32,6 +32,7 @@ using CodeImp.DoomBuilder.Rendering;
|
|||
using CodeImp.DoomBuilder.Geometry;
|
||||
using CodeImp.DoomBuilder.Editing;
|
||||
using CodeImp.DoomBuilder.VisualModes;
|
||||
using System.Drawing;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -314,14 +315,61 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
SetTexture(BuilderPlug.Me.CopiedTexture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Paste texture offsets
|
||||
public virtual void OnPasteTextureOffsets()
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Paste texture offsets");
|
||||
Sidedef.OffsetX = BuilderPlug.Me.CopiedOffsets.X;
|
||||
Sidedef.OffsetY = BuilderPlug.Me.CopiedOffsets.Y;
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
// Copy texture
|
||||
public virtual void OnCopyTexture()
|
||||
{
|
||||
BuilderPlug.Me.CopiedTexture = GetTextureName();
|
||||
if(General.Map.Config.MixTexturesFlats) BuilderPlug.Me.CopiedFlat = GetTextureName();
|
||||
}
|
||||
|
||||
// Copy texture offsets
|
||||
public virtual void OnCopyTextureOffsets()
|
||||
{
|
||||
BuilderPlug.Me.CopiedOffsets = new Point(Sidedef.OffsetX, Sidedef.OffsetY);
|
||||
}
|
||||
|
||||
// Copy properties
|
||||
public virtual void OnCopyProperties()
|
||||
{
|
||||
BuilderPlug.Me.CopiedSidedefProps = new SidedefProperties(Sidedef);
|
||||
}
|
||||
|
||||
// Paste properties
|
||||
public virtual void OnPasteProperties()
|
||||
{
|
||||
if(BuilderPlug.Me.CopiedSidedefProps != null)
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Paste sidedef properties");
|
||||
BuilderPlug.Me.CopiedSidedefProps.Apply(Sidedef);
|
||||
|
||||
// Update sectors on both sides
|
||||
BaseVisualSector front = (BaseVisualSector)mode.GetVisualSector(Sidedef.Sector);
|
||||
if(front != null) front.Rebuild();
|
||||
if(Sidedef.Other != null)
|
||||
{
|
||||
BaseVisualSector back = (BaseVisualSector)mode.GetVisualSector(Sidedef.Other.Sector);
|
||||
if(back != null) back.Rebuild();
|
||||
}
|
||||
mode.ShowTargetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
// Return texture name
|
||||
public virtual string GetTextureName() { return ""; }
|
||||
|
||||
|
|
|
@ -550,6 +550,38 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnTextureFloodfill();
|
||||
ShowTargetInfo();
|
||||
}
|
||||
|
||||
[BeginAction("texturecopyoffsets")]
|
||||
public void TextureCopyOffsets()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyTextureOffsets();
|
||||
ShowTargetInfo();
|
||||
}
|
||||
|
||||
[BeginAction("texturepasteoffsets")]
|
||||
public void TexturePasteOffsets()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteTextureOffsets();
|
||||
ShowTargetInfo();
|
||||
}
|
||||
|
||||
[BeginAction("copyproperties")]
|
||||
public void CopyProperties()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnCopyProperties();
|
||||
ShowTargetInfo();
|
||||
}
|
||||
|
||||
[BeginAction("pasteproperties")]
|
||||
public void PasteProperties()
|
||||
{
|
||||
PickTargetUnlocked();
|
||||
if(target.picked != null) (target.picked as IVisualEventReceiver).OnPasteProperties();
|
||||
ShowTargetInfo();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
|
|
@ -343,6 +343,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
public virtual void OnSelectTexture() { }
|
||||
public virtual void OnCopyTexture() { }
|
||||
public virtual void OnPasteTexture() { }
|
||||
public virtual void OnCopyTextureOffsets() { }
|
||||
public virtual void OnPasteTextureOffsets() { }
|
||||
public virtual void OnTextureAlign(bool alignx, bool aligny) { }
|
||||
public virtual void OnToggleUpperUnpegged() { }
|
||||
public virtual void OnToggleLowerUnpegged() { }
|
||||
|
@ -352,7 +354,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
|
||||
// Return texture name
|
||||
public virtual string GetTextureName() { return ""; }
|
||||
|
||||
|
||||
// Copy properties
|
||||
public virtual void OnCopyProperties()
|
||||
{
|
||||
BuilderPlug.Me.CopiedThingProps = new ThingProperties(Thing);
|
||||
}
|
||||
|
||||
// Paste properties
|
||||
public virtual void OnPasteProperties()
|
||||
{
|
||||
if(BuilderPlug.Me.CopiedThingProps != null)
|
||||
{
|
||||
General.Map.UndoRedo.CreateUndo("Paste thing properties");
|
||||
BuilderPlug.Me.CopiedThingProps.Apply(Thing);
|
||||
Thing.UpdateConfiguration();
|
||||
this.Rebuild();
|
||||
mode.ShowTargetInfo();
|
||||
}
|
||||
}
|
||||
|
||||
// Edit button released
|
||||
public virtual void OnEditEnd()
|
||||
{
|
||||
|
|
|
@ -51,6 +51,10 @@ namespace CodeImp.DoomBuilder.BuilderModes
|
|||
void OnSelectTexture();
|
||||
void OnCopyTexture();
|
||||
void OnPasteTexture();
|
||||
void OnCopyTextureOffsets();
|
||||
void OnPasteTextureOffsets();
|
||||
void OnCopyProperties();
|
||||
void OnPasteProperties();
|
||||
void OnTextureAlign(bool alignx, bool aligny);
|
||||
void OnTextureFloodfill();
|
||||
void OnToggleUpperUnpegged();
|
||||
|
|
Loading…
Reference in a new issue