From 72d688f8d0faf415fd10ca006397364eee76a45b Mon Sep 17 00:00:00 2001 From: boris_i Date: Sat, 8 May 2010 13:14:48 +0000 Subject: [PATCH] Added actions to move the camera up and down in 3D visual modes (no default keys bound) @ more fixes for auto-aligning hi-res textures: now takes the WorldPanning flag into account --- Source/Core/Data/HighResImage.cs | 3 +- Source/Core/Data/ImageData.cs | 2 ++ Source/Core/Geometry/Tools.cs | 4 +-- Source/Core/Resources/Actions.cfg | 22 +++++++++++++ Source/Core/VisualModes/VisualMode.cs | 31 ++++++++++++++++++- Source/Core/ZDoom/TextureStructure.cs | 2 +- .../BuilderModes/VisualModes/VisualLower.cs | 2 +- .../VisualModes/VisualMiddleDouble.cs | 2 +- .../VisualModes/VisualMiddleSingle.cs | 2 +- .../BuilderModes/VisualModes/VisualUpper.cs | 2 +- 10 files changed, 63 insertions(+), 9 deletions(-) diff --git a/Source/Core/Data/HighResImage.cs b/Source/Core/Data/HighResImage.cs index 9bef4617..b4c9510c 100644 --- a/Source/Core/Data/HighResImage.cs +++ b/Source/Core/Data/HighResImage.cs @@ -42,13 +42,14 @@ namespace CodeImp.DoomBuilder.Data #region ================== Constructor / Disposer // Constructor - public HighResImage(string name, int width, int height, float scalex, float scaley) + public HighResImage(string name, int width, int height, float scalex, float scaley, bool worldpanning) { // Initialize this.width = width; this.height = height; this.scale.x = scalex; this.scale.y = scaley; + this.worldpanning = worldpanning; this.patches = new List(); SetName(name); diff --git a/Source/Core/Data/ImageData.cs b/Source/Core/Data/ImageData.cs index 80faff17..94db9aca 100644 --- a/Source/Core/Data/ImageData.cs +++ b/Source/Core/Data/ImageData.cs @@ -51,6 +51,7 @@ namespace CodeImp.DoomBuilder.Data protected int width; protected int height; protected Vector2D scale; + protected bool worldpanning; protected bool usecolorcorrection; // Loading @@ -96,6 +97,7 @@ namespace CodeImp.DoomBuilder.Data public float ScaledWidth { get { return width * scale.x; } } public float ScaledHeight { get { return height * scale.y; } } public Vector2D Scale { get { return scale; } } + public bool WorldPanning { get { return worldpanning; } } #endregion diff --git a/Source/Core/Geometry/Tools.cs b/Source/Core/Geometry/Tools.cs index 8041b10f..09f971e7 100644 --- a/Source/Core/Geometry/Tools.cs +++ b/Source/Core/Geometry/Tools.cs @@ -1548,8 +1548,8 @@ namespace CodeImp.DoomBuilder.Geometry public static void AutoAlignTextures(Sidedef start, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) { Stack todo = new Stack(50); - float scalex = General.Map.Config.ScaledTextureOffsets ? texture.Scale.x : 1.0f; - float scaley = General.Map.Config.ScaledTextureOffsets ? texture.Scale.y : 1.0f; + float scalex = (General.Map.Config.ScaledTextureOffsets && !texture.WorldPanning) ? texture.Scale.x : 1.0f; + float scaley = (General.Map.Config.ScaledTextureOffsets && !texture.WorldPanning) ? texture.Scale.y : 1.0f; // Mark all sidedefs false (they will be marked true when the texture is aligned) if(resetsidemarks) General.Map.Map.ClearMarkedSidedefs(false); diff --git a/Source/Core/Resources/Actions.cfg b/Source/Core/Resources/Actions.cfg index 9a0680e1..115713d7 100644 --- a/Source/Core/Resources/Actions.cfg +++ b/Source/Core/Resources/Actions.cfg @@ -419,6 +419,28 @@ moveright disregardshift = true; } +moveup +{ + title = "Move Up"; + category = "visual"; + description = "Moves the camera up in 3D Visual Mode."; + allowkeys = true; + allowmouse = true; + allowscroll = true; + disregardshift = true; +} + +movedown +{ + title = "Move Down"; + category = "visual"; + description = "Moves the camera down in 3D Visual Mode."; + allowkeys = true; + allowmouse = true; + allowscroll = true; + disregardshift = true; +} + movedoublespeed { title = "Double Speed"; diff --git a/Source/Core/VisualModes/VisualMode.cs b/Source/Core/VisualModes/VisualMode.cs index 76d1cc20..5af199a3 100644 --- a/Source/Core/VisualModes/VisualMode.cs +++ b/Source/Core/VisualModes/VisualMode.cs @@ -67,6 +67,8 @@ namespace CodeImp.DoomBuilder.VisualModes private bool keybackward; private bool keyleft; private bool keyright; + private bool keyup; + private bool keydown; private bool doublespeed; // Map @@ -274,6 +276,30 @@ namespace CodeImp.DoomBuilder.VisualModes keyright = false; } + [BeginAction("moveup", BaseAction = true)] + public virtual void BeginMoveUp() + { + keyup = true; + } + + [EndAction("moveup", BaseAction = true)] + public virtual void EndMoveUp() + { + keyup = false; + } + + [BeginAction("movedown", BaseAction = true)] + public virtual void BeginMoveDown() + { + keydown = true; + } + + [EndAction("movedown", BaseAction = true)] + public virtual void EndMoveDown() + { + keydown = false; + } + [BeginAction("movedoublespeed", BaseAction = true)] public virtual void BeginDoubleSpeed() { @@ -795,13 +821,16 @@ namespace CodeImp.DoomBuilder.VisualModes Vector3D camvecstrafe = Vector3D.FromAngleXY(General.Map.VisualCamera.AngleXY + Angle2D.PIHALF); Vector3D cammovemul = General.Map.VisualCamera.MoveMultiplier; Vector3D camdeltapos = new Vector3D(); - + Vector3D upvec = new Vector3D(0.0f, 0.0f, 1.0f); + // Move the camera if(doublespeed) multiplier = MOVE_SPEED_MULTIPLIER * 2.0f; else multiplier = MOVE_SPEED_MULTIPLIER; if(keyforward) camdeltapos += camvec * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime); if(keybackward) camdeltapos -= camvec * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime); if(keyleft) camdeltapos -= camvecstrafe * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime); if(keyright) camdeltapos += camvecstrafe * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime); + if(keyup) camdeltapos += upvec * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime); + if(keydown) camdeltapos += -upvec * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime); // Move the camera General.Map.VisualCamera.ProcessMovement(camdeltapos); diff --git a/Source/Core/ZDoom/TextureStructure.cs b/Source/Core/ZDoom/TextureStructure.cs index 1ffa37cd..557b0092 100644 --- a/Source/Core/ZDoom/TextureStructure.cs +++ b/Source/Core/ZDoom/TextureStructure.cs @@ -267,7 +267,7 @@ namespace CodeImp.DoomBuilder.ZDoom if(yscale == 0.0f) scaley = defaultscale; else scaley = 1f / yscale; // Make texture - HighResImage tex = new HighResImage(name, width, height, scalex, scaley); + HighResImage tex = new HighResImage(name, width, height, scalex, scaley, worldpanning); // Add patches foreach(PatchStructure p in patches) diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs index d228d4b4..ae45660b 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualLower.cs @@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.BuilderModes t2.y = t1.y + geoheight; // Apply texture offset - if (General.Map.Config.ScaledTextureOffsets) + if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) { t1 += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); t2 += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs index 7194fccb..f715b1be 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleDouble.cs @@ -135,7 +135,7 @@ namespace CodeImp.DoomBuilder.BuilderModes t1.y = cliptop; t2.y = tsz.y - clipbottom; - if (General.Map.Config.ScaledTextureOffsets) + if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) { t1.x = Sidedef.OffsetX * base.Texture.Scale.x; } diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs index 6b09a662..e5a0a625 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualMiddleSingle.cs @@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.BuilderModes t2.y = t1.y + geoheight; // Apply texture offset - if (General.Map.Config.ScaledTextureOffsets) + if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) { t1 += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); t2 += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); diff --git a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs index ea364ed2..efcf70e5 100644 --- a/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs +++ b/Source/Plugins/BuilderModes/VisualModes/VisualUpper.cs @@ -114,7 +114,7 @@ namespace CodeImp.DoomBuilder.BuilderModes t2.y = t1.y + geoheight; // Apply texture offset - if (General.Map.Config.ScaledTextureOffsets) + if (General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) { t1 += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y); t2 += new Vector2D(Sidedef.OffsetX * base.Texture.Scale.x, Sidedef.OffsetY * base.Texture.Scale.y);