Visual mode, UDMF: added "Scale Texture Up (X)", "Scale Texture Down (X)", "Scale Texture Up (Y)", "Scale Texture Down (Y)" actions. Default keys are Num6, Num4, Num8, Num5.

Visual mode, UDMF: renamed "Rotate Thing Clockwise" and "Rotate Thing Counterclockwise" actions to "Rotate Clockwise" and "Rotate Counterclockwise". These actions can now be used to change rotation of floor/ceiling textures.
Visual mode, UDMF: "Reset Texture Offsets" action now also resets sidedef's scale and floor/ceiling's scale and rotation.
Visual mode, UDMF: control line's OffsetX and OffsetY were not taken into account when calculating texture offsets of 3d floors' sides.
Visual mode, UDMF: fixed a ton of bugs in Auto align functions.
Visual mode, UDMF: when using "Move Texture Left/Right/Up/Down by 1" actions texture offsets were not updated properly when texture's scale was < 1.0.
Visual mode, UDMF: OffsetX and OffsetY were not taken into account in "Fit Texture Width/Height" actions.
Dockers Panel: added Pin/Unpin button, which acts the same as "Preferences -> Interface -> Side panels -> Auto hide" checkbox.
Texture size labels can now be disabled by unchecking "Preferences -> Interface -> Show texture and flat sizes in browsers" checkbox.
Texture size labels now are not shown for unknown textures.
Most of texture size labels had incorrect bg color.
ZDoom_linedefs.cfg: action specials 223 and 224 had incorrect Arg0.
This commit is contained in:
MaxED 2013-06-24 14:21:13 +00:00
parent 8ebd348e44
commit b77b8e61d9
33 changed files with 657 additions and 336 deletions

View file

@ -2499,8 +2499,8 @@ zdoom
arg0 arg0
{ {
title = "Line Tag"; title = "Sector Tag";
type = 15; type = 13;
} }
arg1 arg1
{ {
@ -2539,8 +2539,8 @@ zdoom
arg0 arg0
{ {
title = "Line Tag"; title = "Sector Tag";
type = 15; type = 13;
} }
arg1 arg1
{ {

View file

@ -889,6 +889,8 @@
<None Include="Resources\Marine.png" /> <None Include="Resources\Marine.png" />
<Content Include="Resources\Model.png" /> <Content Include="Resources\Model.png" />
<Content Include="Resources\Model_selected.png" /> <Content Include="Resources\Model_selected.png" />
<None Include="Resources\Unpin.png" />
<None Include="Resources\Pin.png" />
<None Include="Resources\Reset.png" /> <None Include="Resources\Reset.png" />
<None Include="Resources\TagStatistics.png" /> <None Include="Resources\TagStatistics.png" />
<None Include="Resources\VisualVertices.png" /> <None Include="Resources\VisualVertices.png" />

View file

@ -28,10 +28,21 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.buttonTogglePinning = new System.Windows.Forms.Button();
this.splitter = new CodeImp.DoomBuilder.Controls.TransparentPanel(); this.splitter = new CodeImp.DoomBuilder.Controls.TransparentPanel();
this.tabs = new CodeImp.DoomBuilder.Controls.DockersTabsControl(); this.tabs = new CodeImp.DoomBuilder.Controls.DockersTabsControl();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonTogglePinning
//
this.buttonTogglePinning.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.buttonTogglePinning.Location = new System.Drawing.Point(282, 4);
this.buttonTogglePinning.Name = "buttonTogglePinning";
this.buttonTogglePinning.Size = new System.Drawing.Size(24, 24);
this.buttonTogglePinning.TabIndex = 0;
this.buttonTogglePinning.UseVisualStyleBackColor = true;
this.buttonTogglePinning.Click += new System.EventHandler(this.buttonTogglePinning_Click);
//
// splitter // splitter
// //
this.splitter.BackColor = System.Drawing.SystemColors.Control; this.splitter.BackColor = System.Drawing.SystemColors.Control;
@ -75,6 +86,7 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.Controls.Add(this.buttonTogglePinning);
this.Controls.Add(this.splitter); this.Controls.Add(this.splitter);
this.Controls.Add(this.tabs); this.Controls.Add(this.tabs);
this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
@ -90,5 +102,6 @@
private DockersTabsControl tabs; private DockersTabsControl tabs;
private TransparentPanel splitter; private TransparentPanel splitter;
private System.Windows.Forms.Button buttonTogglePinning;
} }
} }

View file

@ -87,6 +87,8 @@ namespace CodeImp.DoomBuilder.Controls
{ {
InitializeComponent(); InitializeComponent();
expandedwidth = (int)((float)this.Width * (this.CurrentAutoScaleDimensions.Width / this.AutoScaleDimensions.Width)); expandedwidth = (int)((float)this.Width * (this.CurrentAutoScaleDimensions.Width / this.AutoScaleDimensions.Width));
tabs.TabsOffsetTop = buttonTogglePinning.Bottom + 2; //mxd
buttonTogglePinning.Image = General.Settings.CollapseDockers ? CodeImp.DoomBuilder.Properties.Resources.Unpin : CodeImp.DoomBuilder.Properties.Resources.Pin; //mxd
} }
#endregion #endregion
@ -119,6 +121,8 @@ namespace CodeImp.DoomBuilder.Controls
splitter.Dock = DockStyle.Left; splitter.Dock = DockStyle.Left;
tabs.Alignment = TabAlignment.Right; tabs.Alignment = TabAlignment.Right;
tabs.Location = new Point(0, 0); tabs.Location = new Point(0, 0);
buttonTogglePinning.Location = new Point(this.ClientRectangle.Width - buttonTogglePinning.Width - 2, buttonTogglePinning.Top); //mxd
buttonTogglePinning.Anchor = AnchorStyles.Right | AnchorStyles.Top; //mxd
tabs.Size = new Size(this.ClientRectangle.Width + 2, this.ClientRectangle.Height); tabs.Size = new Size(this.ClientRectangle.Width + 2, this.ClientRectangle.Height);
} }
else else
@ -126,6 +130,8 @@ namespace CodeImp.DoomBuilder.Controls
splitter.Dock = DockStyle.Right; splitter.Dock = DockStyle.Right;
tabs.Alignment = TabAlignment.Left; tabs.Alignment = TabAlignment.Left;
tabs.Location = new Point(-2, 0); tabs.Location = new Point(-2, 0);
buttonTogglePinning.Location = new Point(2, buttonTogglePinning.Top); //mxd
buttonTogglePinning.Anchor = AnchorStyles.Left | AnchorStyles.Top; //mxd
tabs.Size = new Size(this.ClientRectangle.Width + 2, this.ClientRectangle.Height); tabs.Size = new Size(this.ClientRectangle.Width + 2, this.ClientRectangle.Height);
} }
@ -427,6 +433,13 @@ namespace CodeImp.DoomBuilder.Controls
UserResize(this, EventArgs.Empty); UserResize(this, EventArgs.Empty);
} }
} }
//mxd
private void buttonTogglePinning_Click(object sender, EventArgs e) {
General.Settings.CollapseDockers = !General.Settings.CollapseDockers;
General.MainWindow.SetupInterface();
buttonTogglePinning.Image = General.Settings.CollapseDockers ? CodeImp.DoomBuilder.Properties.Resources.Unpin : CodeImp.DoomBuilder.Properties.Resources.Pin;
}
#endregion #endregion
} }

View file

@ -37,11 +37,14 @@ namespace CodeImp.DoomBuilder.Controls
private Bitmap tabsimage; private Bitmap tabsimage;
private int highlighttab; private int highlighttab;
private int tabsOffsetTop; //mxd
#endregion #endregion
#region ================== Properties #region ================== Properties
public int TabsOffsetTop { get { return tabsOffsetTop; } internal set { tabsOffsetTop = value; } } //mxd
#endregion #endregion
#region ================== Constructor #region ================== Constructor
@ -121,6 +124,9 @@ namespace CodeImp.DoomBuilder.Controls
{ {
VisualStyleRenderer renderer; VisualStyleRenderer renderer;
Rectangle tr = this.GetTabRect(i); Rectangle tr = this.GetTabRect(i);
//mxd. A cheap way to display pin button without rewriting this sodding control from scratch...
if(i == 0) tr.Height -= tabsOffsetTop;
// Tab selected? // Tab selected?
if(i == this.SelectedIndex) if(i == this.SelectedIndex)
@ -136,7 +142,8 @@ namespace CodeImp.DoomBuilder.Controls
renderer = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal); renderer = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Normal);
// Draw tab // Draw tab
Rectangle r = new Rectangle(posoffset + 2, 2, tr.Height, tr.Width - 2); int ox = (this.Alignment == TabAlignment.Left ? tabsOffsetTop : 0); //mxd
Rectangle r = new Rectangle(posoffset + ox + 2, 2, tr.Height, tr.Width - 2);
renderer.DrawBackground(g, r); renderer.DrawBackground(g, r);
g.DrawString(this.TabPages[i].Text, this.Font, SystemBrushes.ControlText, new RectangleF(r.Location, r.Size), drawformat); g.DrawString(this.TabPages[i].Text, this.Font, SystemBrushes.ControlText, new RectangleF(r.Location, r.Size), drawformat);
} }
@ -149,6 +156,8 @@ namespace CodeImp.DoomBuilder.Controls
{ {
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Pressed); VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Tab.TabItem.Pressed);
Rectangle tr = this.GetTabRect(this.SelectedIndex); Rectangle tr = this.GetTabRect(this.SelectedIndex);
if(this.SelectedIndex == 0) tr.Height -= tabsOffsetTop; //mxd
if(this.Alignment == TabAlignment.Left) selectedposoffset += tabsOffsetTop; //mxd
Rectangle r = new Rectangle(selectedposoffset, 0, tr.Height + 4, tr.Width); Rectangle r = new Rectangle(selectedposoffset, 0, tr.Height + 4, tr.Width);
renderer.DrawBackground(g, r); renderer.DrawBackground(g, r);
g.DrawString(this.TabPages[this.SelectedIndex].Text, this.Font, SystemBrushes.ControlText, new RectangleF(r.X, r.Y, r.Width, r.Height - 2), drawformat); g.DrawString(this.TabPages[this.SelectedIndex].Text, this.Font, SystemBrushes.ControlText, new RectangleF(r.X, r.Y, r.Width, r.Height - 2), drawformat);

View file

@ -55,7 +55,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelSize // labelSize
// //
this.labelSize.AutoSize = true; this.labelSize.AutoSize = true;
this.labelSize.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelSize.BackColor = System.Drawing.Color.Black;
this.labelSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.labelSize.Font = new System.Drawing.Font("Microsoft Sans Serif", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
this.labelSize.ForeColor = System.Drawing.Color.White; this.labelSize.ForeColor = System.Drawing.Color.White;
this.labelSize.Location = new System.Drawing.Point(1, 1); this.labelSize.Location = new System.Drawing.Point(1, 1);

View file

@ -189,7 +189,7 @@ namespace CodeImp.DoomBuilder.Controls
//mxd //mxd
protected void DisplayImageSize(float width, float height) { protected void DisplayImageSize(float width, float height) {
if(width == -1 && height == -1) { if(!General.Settings.ShowTextureSizes || (width == -1 && height == -1)) {
labelSize.Visible = false; labelSize.Visible = false;
return; return;
} }

View file

@ -474,7 +474,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelTextureFrontTop // labelTextureFrontTop
// //
this.labelTextureFrontTop.AutoSize = true; this.labelTextureFrontTop.AutoSize = true;
this.labelTextureFrontTop.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelTextureFrontTop.BackColor = System.Drawing.Color.Black;
this.labelTextureFrontTop.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTextureFrontTop.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTextureFrontTop.ForeColor = System.Drawing.Color.White; this.labelTextureFrontTop.ForeColor = System.Drawing.Color.White;
this.labelTextureFrontTop.Location = new System.Drawing.Point(2, 1); this.labelTextureFrontTop.Location = new System.Drawing.Point(2, 1);
@ -563,7 +563,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelTextureFrontMid // labelTextureFrontMid
// //
this.labelTextureFrontMid.AutoSize = true; this.labelTextureFrontMid.AutoSize = true;
this.labelTextureFrontMid.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelTextureFrontMid.BackColor = System.Drawing.Color.Black;
this.labelTextureFrontMid.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTextureFrontMid.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTextureFrontMid.ForeColor = System.Drawing.Color.White; this.labelTextureFrontMid.ForeColor = System.Drawing.Color.White;
this.labelTextureFrontMid.Location = new System.Drawing.Point(2, 1); this.labelTextureFrontMid.Location = new System.Drawing.Point(2, 1);
@ -652,7 +652,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelTextureFrontBottom // labelTextureFrontBottom
// //
this.labelTextureFrontBottom.AutoSize = true; this.labelTextureFrontBottom.AutoSize = true;
this.labelTextureFrontBottom.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelTextureFrontBottom.BackColor = System.Drawing.Color.Black;
this.labelTextureFrontBottom.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTextureFrontBottom.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTextureFrontBottom.ForeColor = System.Drawing.Color.White; this.labelTextureFrontBottom.ForeColor = System.Drawing.Color.White;
this.labelTextureFrontBottom.Location = new System.Drawing.Point(2, 1); this.labelTextureFrontBottom.Location = new System.Drawing.Point(2, 1);
@ -777,7 +777,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelTextureBackTop // labelTextureBackTop
// //
this.labelTextureBackTop.AutoSize = true; this.labelTextureBackTop.AutoSize = true;
this.labelTextureBackTop.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelTextureBackTop.BackColor = System.Drawing.Color.Black;
this.labelTextureBackTop.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTextureBackTop.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTextureBackTop.ForeColor = System.Drawing.Color.White; this.labelTextureBackTop.ForeColor = System.Drawing.Color.White;
this.labelTextureBackTop.Location = new System.Drawing.Point(2, 1); this.labelTextureBackTop.Location = new System.Drawing.Point(2, 1);
@ -866,7 +866,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelTextureBackMid // labelTextureBackMid
// //
this.labelTextureBackMid.AutoSize = true; this.labelTextureBackMid.AutoSize = true;
this.labelTextureBackMid.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelTextureBackMid.BackColor = System.Drawing.Color.Black;
this.labelTextureBackMid.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTextureBackMid.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTextureBackMid.ForeColor = System.Drawing.Color.White; this.labelTextureBackMid.ForeColor = System.Drawing.Color.White;
this.labelTextureBackMid.Location = new System.Drawing.Point(2, 1); this.labelTextureBackMid.Location = new System.Drawing.Point(2, 1);
@ -955,7 +955,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelTextureBackBottom // labelTextureBackBottom
// //
this.labelTextureBackBottom.AutoSize = true; this.labelTextureBackBottom.AutoSize = true;
this.labelTextureBackBottom.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelTextureBackBottom.BackColor = System.Drawing.Color.Black;
this.labelTextureBackBottom.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelTextureBackBottom.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelTextureBackBottom.ForeColor = System.Drawing.Color.White; this.labelTextureBackBottom.ForeColor = System.Drawing.Color.White;
this.labelTextureBackBottom.Location = new System.Drawing.Point(2, 1); this.labelTextureBackBottom.Location = new System.Drawing.Point(2, 1);

View file

@ -445,7 +445,7 @@ namespace CodeImp.DoomBuilder.Controls
{ {
//mxd //mxd
ImageData texture = General.Map.Data.GetTextureImage(name); ImageData texture = General.Map.Data.GetTextureImage(name);
if(texture.ImageState == ImageLoadState.Ready) { if(General.Settings.ShowTextureSizes && texture.ImageState == ImageLoadState.Ready) {
label.Visible = true; label.Visible = true;
label.Text = texture.ScaledWidth + "x" + texture.ScaledHeight; label.Text = texture.ScaledWidth + "x" + texture.ScaledHeight;
} else { } else {

View file

@ -236,7 +236,7 @@ namespace CodeImp.DoomBuilder.Controls
// //
this.brightness.Location = new System.Drawing.Point(177, 75); this.brightness.Location = new System.Drawing.Point(177, 75);
this.brightness.Name = "brightness"; this.brightness.Name = "brightness";
this.brightness.Size = new System.Drawing.Size(56, 14); this.brightness.Size = new System.Drawing.Size(38, 14);
this.brightness.TabIndex = 17; this.brightness.TabIndex = 17;
this.brightness.Text = "0"; this.brightness.Text = "0";
// //
@ -244,7 +244,7 @@ namespace CodeImp.DoomBuilder.Controls
// //
this.height.Location = new System.Drawing.Point(177, 55); this.height.Location = new System.Drawing.Point(177, 55);
this.height.Name = "height"; this.height.Name = "height";
this.height.Size = new System.Drawing.Size(56, 14); this.height.Size = new System.Drawing.Size(38, 14);
this.height.TabIndex = 11; this.height.TabIndex = 11;
this.height.Text = "0"; this.height.Text = "0";
// //
@ -457,7 +457,7 @@ namespace CodeImp.DoomBuilder.Controls
// labelFloorTextureSize // labelFloorTextureSize
// //
this.labelFloorTextureSize.AutoSize = true; this.labelFloorTextureSize.AutoSize = true;
this.labelFloorTextureSize.BackColor = System.Drawing.SystemColors.ActiveCaptionText; this.labelFloorTextureSize.BackColor = System.Drawing.Color.Black;
this.labelFloorTextureSize.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.labelFloorTextureSize.Font = new System.Drawing.Font("Arial", 7F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.labelFloorTextureSize.ForeColor = System.Drawing.Color.White; this.labelFloorTextureSize.ForeColor = System.Drawing.Color.White;
this.labelFloorTextureSize.Location = new System.Drawing.Point(3, 1); this.labelFloorTextureSize.Location = new System.Drawing.Point(3, 1);

View file

@ -221,7 +221,7 @@ namespace CodeImp.DoomBuilder.Controls
} }
protected void DisplayTextureSize(Label label, ImageData texture) { protected void DisplayTextureSize(Label label, ImageData texture) {
if(texture.ImageState == ImageLoadState.Ready) { if(General.Settings.ShowTextureSizes && texture.ImageState == ImageLoadState.Ready && !string.IsNullOrEmpty(texture.Name)) {
label.Visible = true; label.Visible = true;
label.Text = texture.ScaledWidth + "x" + texture.ScaledHeight; label.Text = texture.ScaledWidth + "x" + texture.ScaledHeight;
} else { } else {

View file

@ -382,6 +382,13 @@ namespace CodeImp.DoomBuilder.Properties {
} }
} }
internal static System.Drawing.Bitmap Pin {
get {
object obj = ResourceManager.GetObject("Pin", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap Prefab { internal static System.Drawing.Bitmap Prefab {
get { get {
object obj = ResourceManager.GetObject("Prefab", resourceCulture); object obj = ResourceManager.GetObject("Prefab", resourceCulture);
@ -606,6 +613,13 @@ namespace CodeImp.DoomBuilder.Properties {
} }
} }
internal static System.Drawing.Bitmap Unpin {
get {
object obj = ResourceManager.GetObject("Unpin", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
internal static System.Drawing.Bitmap ViewBrightness { internal static System.Drawing.Bitmap ViewBrightness {
get { get {
object obj = ResourceManager.GetObject("ViewBrightness", resourceCulture); object obj = ResourceManager.GetObject("ViewBrightness", resourceCulture);

View file

@ -382,4 +382,10 @@
<data name="Reset" type="System.Resources.ResXFileRef, System.Windows.Forms"> <data name="Reset" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Reset.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value> <value>..\Resources\Reset.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data> </data>
<data name="Pin" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Pin.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Unpin" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Unpin.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root> </root>

View file

@ -249,7 +249,7 @@ namespace CodeImp.DoomBuilder.VisualModes
WALL_UPPER, WALL_UPPER,
WALL_MIDDLE, WALL_MIDDLE,
WALL_MIDDLE_3D, WALL_MIDDLE_3D,
WALL_BOTTOM, WALL_LOWER,
UNKNOWN, UNKNOWN,
} }
} }

View file

@ -31,5 +31,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
public const int ThingMove = 6; //mxd public const int ThingMove = 6; //mxd
public const int ThingRotate = 7; //mxd public const int ThingRotate = 7; //mxd
public const int SurfaceBrightnessChange = 8; //mxd public const int SurfaceBrightnessChange = 8; //mxd
public const int TextureScaleChange = 9; //mxd
} }
} }

View file

@ -397,8 +397,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.buttonMarqueSelectTouching.Name = "buttonMarqueSelectTouching"; this.buttonMarqueSelectTouching.Name = "buttonMarqueSelectTouching";
this.buttonMarqueSelectTouching.Size = new System.Drawing.Size(23, 22); this.buttonMarqueSelectTouching.Size = new System.Drawing.Size(23, 22);
this.buttonMarqueSelectTouching.Text = "Select Touching"; this.buttonMarqueSelectTouching.Text = "Select Touching";
this.buttonMarqueSelectTouching.ToolTipText = "Toggle between \"select touching\" and \"select inside\"\r\nrectangular selection modes" + this.buttonMarqueSelectTouching.ToolTipText = "Toggle between \"select touching\" and \"select inside\"\r\nrectangular selection modes";
"";
this.buttonMarqueSelectTouching.Click += new System.EventHandler(this.buttonMarqueSelectTouching_Click); this.buttonMarqueSelectTouching.Click += new System.EventHandler(this.buttonMarqueSelectTouching_Click);
// //
// buttonAlignThingsToWall // buttonAlignThingsToWall
@ -421,7 +420,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
this.buttonTextureOffsetLock.Name = "buttonTextureOffsetLock"; this.buttonTextureOffsetLock.Name = "buttonTextureOffsetLock";
this.buttonTextureOffsetLock.Size = new System.Drawing.Size(23, 22); this.buttonTextureOffsetLock.Size = new System.Drawing.Size(23, 22);
this.buttonTextureOffsetLock.ToolTipText = "Pin Texture Offsets.\r\nWhen enabled, keeps floor and ceiling texture offsets\r\ncons" + this.buttonTextureOffsetLock.ToolTipText = "Pin Texture Offsets.\r\nWhen enabled, keeps floor and ceiling texture offsets\r\ncons" +
"tant while sector is dragged\r\n"; "tant while sector is dragged";
this.buttonTextureOffsetLock.Click += new System.EventHandler(this.buttonTextureOffsetLock_Click); this.buttonTextureOffsetLock.Click += new System.EventHandler(this.buttonTextureOffsetLock_Click);
// //
// alignLinedefsItem // alignLinedefsItem

View file

@ -725,6 +725,58 @@ movetexturedown8
default = 65576; default = 65576;
} }
//mxd
scaletextureupx
{
title = "Scale Texture Up (X)";
category = "visual";
description = "Increases horizontal scale of targeted or selected textures by 0.25 (UDMF only).";
allowkeys = true;
allowmouse = true;
allowscroll = true;
repeat = true;
default = 102;
}
//mxd
scaletexturedownx
{
title = "Scale Texture Down (X)";
category = "visual";
description = "Decreases horizontal scale of targeted or selected textures by 0.25 (UDMF only).";
allowkeys = true;
allowmouse = true;
allowscroll = true;
repeat = true;
default = 100;
}
//mxd
scaletextureupy
{
title = "Scale Texture Up (Y)";
category = "visual";
description = "Increases vertical scale of targeted or selected textures by 0.25 (UDMF only).";
allowkeys = true;
allowmouse = true;
allowscroll = true;
repeat = true;
default = 104;
}
//mxd
scaletexturedowny
{
title = "Scale Texture Down (Y)";
category = "visual";
description = "Decreases vertical scale of targeted or selected textures by 0.25 (UDMF only).";
allowkeys = true;
allowmouse = true;
allowscroll = true;
repeat = true;
default = 101;
}
textureselect textureselect
{ {
title = "Select Texture"; title = "Select Texture";
@ -878,7 +930,7 @@ resettexture
{ {
title = "Reset Texture Offsets"; title = "Reset Texture Offsets";
category = "visual"; category = "visual";
description = "Resets the texture offsets on the targeted or selected sidedef to 0, 0."; description = "Resets the texture offsets on the targeted or selected sidedef to 0, 0. Also resets sidedef's scale and floor/ceiling's scale and rotation in UDMF map format.";
allowkeys = true; allowkeys = true;
allowmouse = true; allowmouse = true;
allowscroll = true; allowscroll = true;
@ -1002,9 +1054,9 @@ flipselectionh
//mxd //mxd
rotatethingscw rotatethingscw
{ {
title = "Rotate Thing Clockwise"; title = "Rotate Clockwise";
category = "visual"; category = "visual";
description = "Rotates selected things clockwise."; description = "Rotates selected things clockwise. Also rotates floor/ceiling textures in UDMF map format.";
allowkeys = true; allowkeys = true;
allowmouse = false; allowmouse = false;
allowscroll = true; allowscroll = true;
@ -1015,9 +1067,9 @@ rotatethingscw
//mxd //mxd
rotatethingsccw rotatethingsccw
{ {
title = "Rotate Thing Counterclockwise"; title = "Rotate Counterclockwise";
category = "visual"; category = "visual";
description = "Rotates selected things counterclockwise."; description = "Rotates selected things counterclockwise. Also rotates floor/ceiling textures in UDMF map format.";
allowkeys = true; allowkeys = true;
allowmouse = false; allowmouse = false;
allowscroll = true; allowscroll = true;
@ -1030,7 +1082,7 @@ gzdbvisualmode
{ {
title = "GZDB Visual Mode"; title = "GZDB Visual Mode";
category = "modes"; category = "modes";
description = "Switches to the (G)ZDoom visual editing mode."; description = "Switches to the (G)ZDoom visual editing mode. Hold Shift key to invert 'Synhcronise selection between Visual and Classic modes' setting.";
allowkeys = true; allowkeys = true;
allowmouse = true; allowmouse = true;
allowscroll = true; allowscroll = true;

View file

@ -61,8 +61,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
private float dragstartanglexy; private float dragstartanglexy;
private float dragstartanglez; private float dragstartanglez;
private Vector3D dragorigin; private Vector3D dragorigin;
//private Vector3D deltaxy;
//private Vector3D deltaz;
private int startoffsetx; private int startoffsetx;
private int startoffsety; private int startoffsety;
protected bool uvdragging; protected bool uvdragging;
@ -95,6 +93,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// This changes the height // This changes the height
protected abstract void ChangeHeight(int amount); protected abstract void ChangeHeight(int amount);
protected abstract void ChangeTextureScale(float incrementX, float incrementY); //mxd
public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
// This swaps triangles so that the plane faces the other way // This swaps triangles so that the plane faces the other way
@ -678,6 +677,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Texture offset change // Texture offset change
public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
{ {
if(horizontal == 0 && vertical == 0) return; //mxd
//mxd //mxd
if (!General.Map.UDMF) { if (!General.Map.UDMF) {
General.ShowErrorMessage("Floor/ceiling texture offsets cannot be changed in this map format!", MessageBoxButtons.OK); General.ShowErrorMessage("Floor/ceiling texture offsets cannot be changed in this map format!", MessageBoxButtons.OK);
@ -714,12 +715,59 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply offsets // Apply offsets
MoveTextureOffset(new Point(-horizontal, -vertical)); MoveTextureOffset(new Point(-horizontal, -vertical));
mode.SetActionResult("Changed texture offsets by " + (-horizontal) + ", " + (-vertical) + ".");
// Update sector geometry // Update sector geometry
Sector s = GetControlSector();
if(s.Index != Sector.Sector.Index) {
s.UpdateNeeded = true;
s.UpdateCache();
mode.GetSectorData(s).Update();
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
vs.UpdateSectorGeometry(false);
vs.Rebuild();
}
Sector.Sector.UpdateNeeded = true;
Sector.Sector.UpdateCache();
Sector.UpdateSectorGeometry(false); Sector.UpdateSectorGeometry(false);
Sector.Rebuild(); Sector.Rebuild();
} }
public virtual void OnChangeTextureRotation(float angle) {
if(!General.Map.UDMF) return;
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change texture rotation");
string key = (GeometryType == VisualGeometryType.FLOOR ? "rotationfloor" : "rotationceiling");
mode.SetActionResult( (GeometryType == VisualGeometryType.FLOOR ? "Floor" : "Ceiling") + " rotation changed to " + angle);
//set value
Sector s = GetControlSector();
UDMFTools.SetFloat(s.Fields, key, angle, 0.0f, true);
if(s.Index != Sector.Sector.Index) {
s.UpdateNeeded = true;
s.UpdateCache();
mode.GetSectorData(s).Update();
BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
vs.UpdateSectorGeometry(false);
}
Sector.Sector.UpdateNeeded = true;
Sector.Sector.UpdateCache();
Sector.UpdateSectorGeometry(false);
}
//mxd
public virtual void OnChangeTextureScale(float incrementX, float incrementY) {
if(!General.Map.UDMF) return;
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change texture scale");
ChangeTextureScale(incrementX, incrementY);
}
#endregion #endregion
} }

View file

@ -26,6 +26,7 @@ using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Geometry; using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using System.Drawing; using System.Drawing;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -368,8 +369,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
protected float getRoundedTextureOffset(float oldValue, float offset, float scale) { protected float getRoundedTextureOffset(float oldValue, float offset, float scale) {
if(offset == 0f) return oldValue; if(offset == 0f) return oldValue;
float result = (float)Math.Round(oldValue + (offset * scale)); float scaledOffset = offset * scale;
if (result == oldValue) result += 1f * (offset < 0 ? -1 : 1); float result = (float)Math.Round(oldValue + scaledOffset);
if(result == oldValue) result += (scaledOffset < 0 ? -1 : 1);
return result; return result;
} }
@ -390,6 +392,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd
protected void selectNeighbours(string texture, bool select, bool withSameTexture, bool withSameHeight) { protected void selectNeighbours(string texture, bool select, bool withSameTexture, bool withSameHeight) {
if(!withSameTexture && !withSameHeight) if(!withSameTexture && !withSameHeight)
return; return;
@ -496,6 +499,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public abstract bool Setup(); public abstract bool Setup();
protected abstract void SetTextureOffsetX(int x); protected abstract void SetTextureOffsetX(int x);
protected abstract void SetTextureOffsetY(int y); protected abstract void SetTextureOffsetY(int y);
protected virtual void ResetTextureScale() { } //mxd
protected abstract void MoveTextureOffset(Point xy); protected abstract void MoveTextureOffset(Point xy);
protected abstract Point GetTextureOffset(); protected abstract Point GetTextureOffset();
public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd public virtual void SelectNeighbours(bool select, bool withSameTexture, bool withSameHeight) { } //mxd
@ -595,6 +599,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(General.Map.UDMF) { if(General.Map.UDMF) {
SetTextureOffsetX(0); SetTextureOffsetX(0);
SetTextureOffsetY(0); SetTextureOffsetY(0);
ResetTextureScale();
} else { } else {
Sidedef.OffsetX = 0; Sidedef.OffsetX = 0;
Sidedef.OffsetY = 0; Sidedef.OffsetY = 0;
@ -784,17 +789,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
List<Sidedef> sides = mode.GetSelectedSidedefs(); List<Sidedef> sides = mode.GetSelectedSidedefs();
foreach(Sidedef sd in sides) sd.Marked = false; foreach(Sidedef sd in sides) sd.Marked = false;
} }
SidedefPart part;
if(this is VisualLower)
part = SidedefPart.Lower;
else if(this is VisualUpper)
part = SidedefPart.Upper;
else
part = SidedefPart.Middle;
// Do the alignment // Do the alignment
mode.AutoAlignTextures(this.Sidedef, part, base.Texture, alignx, aligny, false); mode.AutoAlignTextures(this, base.Texture, alignx, aligny, false);
// Get the changed sidedefs // Get the changed sidedefs
List<Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true); List<Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true);
@ -1098,6 +1095,63 @@ namespace CodeImp.DoomBuilder.BuilderModes
parts.SetupAllParts(); parts.SetupAllParts();
} }
//mxd
public virtual void OnChangeTextureScale(float incrementX, float incrementY) {
if(!General.Map.UDMF) return;
if((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Change wall scale");
string keyX;
string keyY;
switch(GeometryType) {
case VisualGeometryType.WALL_UPPER:
keyX = "scalex_top";
keyY = "scaley_top";
break;
case VisualGeometryType.WALL_MIDDLE:
case VisualGeometryType.WALL_MIDDLE_3D:
keyX = "scalex_mid";
keyY = "scaley_mid";
break;
case VisualGeometryType.WALL_LOWER:
keyX = "scalex_bottom";
keyY = "scaley_bottom";
break;
default:
throw new Exception("OnChangeTextureScale(): Got unknown GeometryType: " + GeometryType);
}
float scaleX = Sidedef.Fields.GetValue(keyX, 1.0f);
float scaleY = Sidedef.Fields.GetValue(keyY, 1.0f);
Sidedef.Fields.BeforeFieldsChange();
if(incrementX != 0) {
if(scaleX + incrementX == 0)
scaleX *= -1;
else
scaleX += incrementX;
UDMFTools.SetFloat(Sidedef.Fields, keyX, scaleX, 1.0f, false);
}
if(incrementY != 0) {
if(scaleY + incrementY == 0)
scaleY *= -1;
else
scaleY += incrementY;
UDMFTools.SetFloat(Sidedef.Fields, keyY, scaleY, 1.0f, false);
}
//update geometry
Setup();
mode.SetActionResult("Wall scale changed to " + scaleX + ", " + scaleY);
}
#endregion #endregion
} }
} }

View file

@ -31,6 +31,7 @@ using CodeImp.DoomBuilder.Config;
using CodeImp.DoomBuilder.GZBuilder.Data; using CodeImp.DoomBuilder.GZBuilder.Data;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.Data; using CodeImp.DoomBuilder.Data;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -2132,6 +2133,42 @@ namespace CodeImp.DoomBuilder.BuilderModes
PostAction(); PostAction();
} }
//mxd
[BeginAction("scaletextureupx")]
public void ScaleTextureUpX() {
PreAction(UndoGroup.TextureScaleChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureScale(0.25f, 0);
PostAction();
}
//mxd
[BeginAction("scaletexturedownx")]
public void ScaleTextureDownX() {
PreAction(UndoGroup.TextureScaleChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureScale(-0.25f, 0);
PostAction();
}
//mxd
[BeginAction("scaletextureupy")]
public void ScaleTextureUpY() {
PreAction(UndoGroup.TextureScaleChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureScale(0, 0.25f);
PostAction();
}
//mxd
[BeginAction("scaletexturedowny")]
public void ScaleTextureDownY() {
PreAction(UndoGroup.TextureScaleChange);
List<IVisualEventReceiver> objs = GetSelectedObjects(true, true, false, false);
foreach(IVisualEventReceiver i in objs) i.OnChangeTextureScale(0, -0.25f);
PostAction();
}
[BeginAction("textureselect")] [BeginAction("textureselect")]
public void TextureSelect() public void TextureSelect()
{ {
@ -2426,40 +2463,39 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd. rotate clockwise //mxd. rotate clockwise
[BeginAction("rotatethingscw")] [BeginAction("rotatethingscw")]
public void RotateThingsCW() { public void RotateCW() {
List<VisualThing> things = GetSelectedVisualThings(true); rotateThingsAndTextures(5);
PreAction(UndoGroup.ThingRotate);
if (things.Count == 0) {
General.Interface.DisplayStatus(StatusType.Warning, "This action requires selected Things!");
return;
}
foreach (VisualThing t in things)
((BaseVisualThing)t).OnRotate(General.ClampAngle(t.Thing.AngleDoom + 5));
PostAction();
} }
//mxd. rotate counterclockwise //mxd. rotate counterclockwise
[BeginAction("rotatethingsccw")] [BeginAction("rotatethingsccw")]
public void RotateThingsCCW() { public void RotateCCW() {
List<VisualThing> things = GetSelectedVisualThings(true); rotateThingsAndTextures(-5);
PreAction(UndoGroup.ThingRotate);
if (things.Count == 0) {
General.Interface.DisplayStatus(StatusType.Warning, "This action requires selected Things!");
return;
}
foreach (VisualThing t in things)
((BaseVisualThing)t).OnRotate(General.ClampAngle(t.Thing.AngleDoom - 5));
PostAction();
} }
//mxd
private void rotateThingsAndTextures(int increment) {
PreAction(UndoGroup.ThingRotate);
List<IVisualEventReceiver> selection = GetSelectedObjects(true, false, true, false);
if(selection.Count == 0) return;
foreach(IVisualEventReceiver obj in selection) {
if(obj is BaseVisualThing) {
BaseVisualThing t = obj as BaseVisualThing;
t.Rotate(General.ClampAngle(t.Thing.AngleDoom + increment));
}else if(obj is VisualFloor) {
VisualFloor vf = obj as VisualFloor;
vf.OnChangeTextureRotation(General.ClampAngle(vf.GetControlSector().Fields.GetValue("rotationfloor", 0.0f) + increment));
} else if(obj is VisualCeiling) {
VisualCeiling vc = obj as VisualCeiling;
vc.OnChangeTextureRotation(General.ClampAngle(vc.GetControlSector().Fields.GetValue("rotationceiling", 0.0f) + increment));
}
}
PostAction();
}
//mxd //mxd
[BeginAction("togglegzdoomrenderingeffects")] [BeginAction("togglegzdoomrenderingeffects")]
public void ToggleGZDoomRenderingEffects() { public void ToggleGZDoomRenderingEffects() {
@ -2554,7 +2590,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
update = false; update = false;
//assign/remove action //assign/remove action
if(vg.GeometryType == VisualGeometryType.WALL_BOTTOM) { if(vg.GeometryType == VisualGeometryType.WALL_LOWER) {
if(vg.Sidedef.Line.Action == 0 || (vg.Sidedef.Line.Action == 181 && vg.Sidedef.Line.Args[0] == 0)) { if(vg.Sidedef.Line.Action == 0 || (vg.Sidedef.Line.Action == 181 && vg.Sidedef.Line.Args[0] == 0)) {
//check if the sector already has floor slopes //check if the sector already has floor slopes
foreach(Sidedef side in vg.Sidedef.Sector.Sidedefs) { foreach(Sidedef side in vg.Sidedef.Sector.Sidedefs) {
@ -2658,9 +2694,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
#region ================== Texture Alignment #region ================== Texture Alignment
//mxd //mxd
public void AutoAlignTextures(Sidedef start, SidedefPart part, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) { internal void AutoAlignTextures(BaseVisualGeometrySidedef start, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) {
if(General.Map.UDMF) if(General.Map.UDMF)
autoAlignTextures(start, part, texture, alignx, aligny, resetsidemarks); autoAlignTexturesUDMF(start, texture, alignx, aligny, resetsidemarks);
else else
autoAlignTextures(start, texture, alignx, aligny, resetsidemarks); autoAlignTextures(start, texture, alignx, aligny, resetsidemarks);
} }
@ -2671,33 +2707,30 @@ namespace CodeImp.DoomBuilder.BuilderModes
// When resetsidemarks is set to true, all sidedefs will first be marked false (not aligned). // When resetsidemarks is set to true, all sidedefs will first be marked false (not aligned).
// Setting resetsidemarks to false is usefull to align only within a specific selection // Setting resetsidemarks to false is usefull to align only within a specific selection
// (set the marked property to true for the sidedefs outside the selection) // (set the marked property to true for the sidedefs outside the selection)
private void autoAlignTextures(Sidedef start, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) { private void autoAlignTextures(BaseVisualGeometrySidedef start, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) {
Stack<SidedefAlignJob> todo = new Stack<SidedefAlignJob>(50); Stack<SidedefAlignJob> todo = new Stack<SidedefAlignJob>(50);
float scalex = (General.Map.Config.ScaledTextureOffsets && !texture.WorldPanning) ? texture.Scale.x : 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; 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) // Mark all sidedefs false (they will be marked true when the texture is aligned). mxd. Don't seem to be used anywhere...
if(resetsidemarks) if(resetsidemarks)
General.Map.Map.ClearMarkedSidedefs(false); General.Map.Map.ClearMarkedSidedefs(false);
// Begin with first sidedef // Begin with first sidedef
SidedefAlignJob first = new SidedefAlignJob(); SidedefAlignJob first = new SidedefAlignJob();
first.sidedef = start; first.sidedef = start.Sidedef;
first.offsetx = start.OffsetX; first.offsetx = start.Sidedef.OffsetX;
int ystartalign = start.Sidedef.OffsetY; //mxd
//mxd. 3D floors alignment //mxd
if(!start.LowRequired() && !start.HighRequired()) { if(start.GeometryType == VisualGeometryType.WALL_MIDDLE_3D) {
List<Sidedef> controlSides = getControlSides(start, false); first.controlSide = start.GetControlLinedef().Front;
foreach(Sidedef s in controlSides) { first.offsetx += first.controlSide.OffsetX;
if((s.LongMiddleTexture == texture.LongName) && (s.MiddleRequired() || ((s.MiddleTexture.Length > 0) && (s.MiddleTexture[0] != '-')))) { ystartalign += first.controlSide.OffsetY;
first.controlSide = s; } else {
break; first.controlSide = start.Sidedef;
}
}
} }
if(first.controlSide == null) first.controlSide = start;
first.forward = true; first.forward = true;
todo.Push(first); todo.Push(first);
@ -2713,9 +2746,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Apply alignment // Apply alignment
if(alignx) if(alignx)
j.sidedef.OffsetX = (int)j.offsetx; j.controlSide.OffsetX = (int)j.offsetx;
if(aligny) if(aligny)
j.sidedef.OffsetY = (int)Math.Round((start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + start.OffsetY; j.sidedef.OffsetY = (int)Math.Round((first.controlSide.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign;
forwardoffset = (int)j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex); forwardoffset = (int)j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex);
backwardoffset = (int)j.offsetx; backwardoffset = (int)j.offsetx;
@ -2746,7 +2779,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(alignx) if(alignx)
j.sidedef.OffsetX = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex); j.sidedef.OffsetX = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex);
if(aligny) if(aligny)
j.sidedef.OffsetY = (int)Math.Round((start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + start.OffsetY; j.sidedef.OffsetY = (int)Math.Round((first.controlSide.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign;
forwardoffset = (int)j.offsetx; forwardoffset = (int)j.offsetx;
backwardoffset = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex); backwardoffset = (int)j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex);
@ -2778,76 +2811,84 @@ namespace CodeImp.DoomBuilder.BuilderModes
// When resetsidemarks is set to true, all sidedefs will first be marked false (not aligned). // When resetsidemarks is set to true, all sidedefs will first be marked false (not aligned).
// Setting resetsidemarks to false is usefull to align only within a specific selection // Setting resetsidemarks to false is usefull to align only within a specific selection
// (set the marked property to true for the sidedefs outside the selection) // (set the marked property to true for the sidedefs outside the selection)
private void autoAlignTextures(Sidedef start, SidedefPart part, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) { private void autoAlignTexturesUDMF(BaseVisualGeometrySidedef start, ImageData texture, bool alignx, bool aligny, bool resetsidemarks) {
// Mark all sidedefs false (they will be marked true when the texture is aligned)
if(resetsidemarks) General.Map.Map.ClearMarkedSidedefs(false);
if(!texture.IsImageLoaded) return;
Stack<SidedefAlignJob> todo = new Stack<SidedefAlignJob>(50); Stack<SidedefAlignJob> todo = new Stack<SidedefAlignJob>(50);
float scalex = (General.Map.Config.ScaledTextureOffsets && !texture.WorldPanning) ? texture.Scale.x : 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; 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) Sidedef startControlSide = (start.GeometryType == VisualGeometryType.WALL_MIDDLE_3D ? start.GetControlLinedef().Front : start.Sidedef);
if(resetsidemarks)
General.Map.Map.ClearMarkedSidedefs(false);
if(!texture.IsImageLoaded) //mxd
return; List<BaseVisualGeometrySidedef> selectedVisualSides = new List<BaseVisualGeometrySidedef>();
if(!singleselection) {
foreach(IVisualEventReceiver i in selectedobjects) {
if(i is BaseVisualGeometrySidedef) {
BaseVisualGeometrySidedef sd = i as BaseVisualGeometrySidedef;
if(!selectedVisualSides.Contains(sd)) selectedVisualSides.Add(sd);
}
}
}
SidedefAlignJob first = new SidedefAlignJob();
//mxd. scaleY
switch(start.GeometryType) {
case VisualGeometryType.WALL_UPPER:
first.scaleY = start.Sidedef.Fields.GetValue("scaley_top", 1.0f);
break;
case VisualGeometryType.WALL_MIDDLE:
case VisualGeometryType.WALL_MIDDLE_3D:
first.scaleY = startControlSide.Fields.GetValue("scaley_mid", 1.0f);
break;
case VisualGeometryType.WALL_LOWER:
first.scaleY = start.Sidedef.Fields.GetValue("scaley_bottom", 1.0f);
break;
}
// Determine the Y alignment // Determine the Y alignment
float ystartalign = start.OffsetY; float ystartalign = start.Sidedef.OffsetY;
switch(part) { switch(start.GeometryType) {
case SidedefPart.Upper: case VisualGeometryType.WALL_UPPER:
ystartalign += GetTopOffsetY(start, start.Fields.GetValue("offsety_top", 0.0f), false);//mxd ystartalign += GetTopOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_top", 0.0f), first.scaleY, false);//mxd
break; break;
case SidedefPart.Middle: case VisualGeometryType.WALL_MIDDLE:
ystartalign += GetMiddleOffsetY(start, start.Fields.GetValue("offsety_mid", 0.0f), false);//mxd ystartalign += GetMiddleOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_mid", 0.0f), first.scaleY, false);//mxd
break; break;
case SidedefPart.Lower: case VisualGeometryType.WALL_MIDDLE_3D: //mxd. 3d-floors are not affected by Lower/Upper unpegged flags
ystartalign += GetBottomOffsetY(start, start.Fields.GetValue("offsety_bottom", 0.0f), false);//mxd ystartalign += startControlSide.OffsetY - (start.Sidedef.Sector.CeilHeight - startControlSide.Sector.CeilHeight);
ystartalign += start.Sidedef.Fields.GetValue("offsety_mid", 0.0f);
ystartalign += startControlSide.Fields.GetValue("offsety_mid", 0.0f);
break;
case VisualGeometryType.WALL_LOWER:
ystartalign += GetBottomOffsetY(start.Sidedef, start.Sidedef.Fields.GetValue("offsety_bottom", 0.0f), first.scaleY, false);//mxd
break; break;
} }
// Begin with first sidedef // Begin with first sidedef
SidedefAlignJob first = new SidedefAlignJob(); first.sidedef = start.Sidedef;
first.sidedef = start; first.offsetx = start.Sidedef.OffsetX;
first.offsetx = start.OffsetX; switch(start.GeometryType) {
switch(part) { case VisualGeometryType.WALL_UPPER:
case SidedefPart.Upper: first.offsetx += start.Sidedef.Fields.GetValue("offsetx_top", 0.0f);
first.offsetx += start.Fields.GetValue("offsetx_top", 0.0f);
break; break;
case SidedefPart.Middle: case VisualGeometryType.WALL_MIDDLE:
first.offsetx += start.Fields.GetValue("offsetx_mid", 0.0f); first.offsetx += start.Sidedef.Fields.GetValue("offsetx_mid", 0.0f);
break; break;
case SidedefPart.Lower: case VisualGeometryType.WALL_MIDDLE_3D: //mxd. Yup, 4 sets of texture offsets are used
first.offsetx += start.Fields.GetValue("offsetx_bottom", 0.0f); first.offsetx += start.Sidedef.Fields.GetValue("offsetx_mid", 0.0f);
first.offsetx += startControlSide.OffsetX;
first.offsetx += startControlSide.Fields.GetValue("offsetx_mid", 0.0f);
break;
case VisualGeometryType.WALL_LOWER:
first.offsetx += start.Sidedef.Fields.GetValue("offsetx_bottom", 0.0f);
break; break;
} }
first.forward = true; first.forward = true;
first.controlSide = startControlSide; //mxd
//mxd. 3D floors alignment
if(part == SidedefPart.Middle) {
List<Sidedef> controlSides = getControlSides(start, true); //mxd
foreach(Sidedef s in controlSides) {
if((s.LongMiddleTexture == texture.LongName) && (s.MiddleRequired() || ((s.MiddleTexture.Length > 0) && (s.MiddleTexture[0] != '-')))) {
first.controlSide = s;
break;
}
}
} else {
first.controlSide = start;
}
//mxd. scaleY
switch(part) {
case SidedefPart.Upper:
first.scaleY = start.Fields.GetValue("scaley_top", 1.0f);
break;
case SidedefPart.Middle:
first.scaleY = start.Fields.GetValue("scaley_mid", 1.0f);
break;
case SidedefPart.Lower:
first.scaleY = start.Fields.GetValue("scaley_bottom", 1.0f);
break;
}
todo.Push(first); todo.Push(first);
// Continue until nothing more to align // Continue until nothing more to align
@ -2860,73 +2901,82 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Get the align job to do // Get the align job to do
SidedefAlignJob j = todo.Pop(); SidedefAlignJob j = todo.Pop();
bool matchtop = ((j.sidedef.LongHighTexture == texture.LongName) && j.sidedef.HighRequired()); bool matchtop = (!j.sidedef.Marked && (j.sidedef.LongHighTexture == texture.LongName) && j.sidedef.HighRequired());
bool matchbottom = ((j.sidedef.LongLowTexture == texture.LongName) && j.sidedef.LowRequired()); bool matchbottom = (!j.sidedef.Marked && (j.sidedef.LongLowTexture == texture.LongName) && j.sidedef.LowRequired());
bool matchmid = ((j.controlSide.LongMiddleTexture == texture.LongName) && (j.controlSide.MiddleRequired() || ((j.controlSide.MiddleTexture.Length > 0) && (j.controlSide.MiddleTexture[0] != '-')))); //mxd bool matchmid = ((j.controlSide.LongMiddleTexture == texture.LongName) && (j.controlSide.MiddleRequired() || ((j.controlSide.MiddleTexture.Length > 0) && (j.controlSide.MiddleTexture[0] != '-')))); //mxd
//mxd. If there's a selection, check if matched part is actually selected
if(!singleselection) {
if(matchtop) matchtop = sidePartIsSelected(selectedVisualSides, j.sidedef, VisualGeometryType.WALL_UPPER);
if(matchbottom) matchbottom = sidePartIsSelected(selectedVisualSides, j.sidedef, VisualGeometryType.WALL_LOWER);
if(matchmid) matchmid = sidePartIsSelected(selectedVisualSides, j.sidedef, VisualGeometryType.WALL_MIDDLE) ||
sidePartIsSelected(selectedVisualSides, j.sidedef, VisualGeometryType.WALL_MIDDLE_3D);
}
if(!matchbottom && !matchtop && !matchmid) continue; //mxd
if(matchtop) if(matchtop)
offsetscalex = j.sidedef.Fields.GetValue("scalex_top", 1.0f); offsetscalex = j.sidedef.Fields.GetValue("scalex_top", 1.0f);
else if(matchbottom) else if(matchbottom)
offsetscalex = j.sidedef.Fields.GetValue("scalex_bottom", 1.0f); offsetscalex = j.sidedef.Fields.GetValue("scalex_bottom", 1.0f);
else if(matchmid) else if(matchmid)
offsetscalex = j.sidedef.Fields.GetValue("scalex_mid", 1.0f); offsetscalex = j.controlSide.Fields.GetValue("scalex_mid", 1.0f);
//mxd. Apply scaleY
j.sidedef.Fields.BeforeFieldsChange(); j.sidedef.Fields.BeforeFieldsChange();
if(j.scaleY == 1.0f) { j.controlSide.Fields.BeforeFieldsChange(); //mxd
if(matchtop && j.sidedef.Fields.GetValue("scaley_top", 1.0f) != 1.0f)
j.sidedef.Fields.Remove("scaley_top"); //mxd. Apply scaleY
else if(matchmid && j.sidedef.Fields.GetValue("scaley_mid", 1.0f) != 1.0f) if(matchtop) UDMFTools.SetFloat(j.sidedef.Fields, "scaley_top", j.scaleY, 1.0f, false);
j.sidedef.Fields.Remove("scaley_mid"); if(matchmid) UDMFTools.SetFloat(j.controlSide.Fields, "scaley_mid", j.scaleY, 1.0f, false);
else if(matchbottom && j.sidedef.Fields.GetValue("scaley_bottom", 1.0f) != 1.0f) if(matchbottom) UDMFTools.SetFloat(j.sidedef.Fields, "scaley_bottom", j.scaleY, 1.0f, false);
j.sidedef.Fields.Remove("scaley_bottom");
} else {
if(matchtop && j.sidedef.Fields.GetValue("scaley_top", 1.0f) != j.scaleY)
j.sidedef.Fields["scaley_top"] = new UniValue(UniversalType.Float, j.scaleY);
if(matchmid && j.sidedef.Fields.GetValue("scaley_mid", 1.0f) != j.scaleY)
j.sidedef.Fields["scaley_mid"] = new UniValue(UniversalType.Float, j.scaleY);
if(matchbottom && j.sidedef.Fields.GetValue("scaley_bottom", 1.0f) != j.scaleY)
j.sidedef.Fields["scaley_bottom"] = new UniValue(UniversalType.Float, j.scaleY);
}
if(j.forward) { if(j.forward) {
// Apply alignment // Apply alignment
if(alignx) { if(alignx) {
float offset = j.offsetx; float offset = j.offsetx;
offset %= (float)texture.Width;//mxd
offset -= j.sidedef.OffsetX; offset -= j.sidedef.OffsetX;
j.sidedef.Fields.BeforeFieldsChange();
if(matchtop) if(matchtop)
j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, offset % (float)texture.Width);
if(matchbottom) if(matchbottom)
j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, offset % (float)texture.Width);
if(matchmid) if(matchmid) {
j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, offset); if(j.sidedef.Index != j.controlSide.Index) { //mxd. if it's a part of 3d-floor
} offset -= j.controlSide.OffsetX;
if(aligny) { offset -= j.controlSide.Fields.GetValue("offsetx_mid", 0.0f);
float offset = ((float)(start.Sector.CeilHeight - j.sidedef.Sector.CeilHeight) / scaley) + ystartalign; }
offset -= j.sidedef.OffsetY;
j.sidedef.Fields.BeforeFieldsChange(); j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, offset % (float)texture.Width);
}
}
if(aligny) {
float offset = ((float)(start.Sidedef.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) * j.scaleY + ystartalign; //mxd
offset -= j.sidedef.OffsetY; //mxd
offset = (float)Math.Round(offset); //mxd
if(matchtop) if(matchtop)
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetTopOffsetY(j.sidedef, offset, j.scaleY, true) % (float)texture.Height); //mxd
if(matchbottom) if(matchbottom)
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetBottomOffsetY(j.sidedef, offset, j.scaleY, true) % (float)texture.Height); //mxd
if(matchmid) { if(matchmid) {
//mxd. Side is part of a 3D floor? //mxd. Side is part of a 3D floor?
if(j.sidedef.Index != j.controlSide.Index) { if(j.sidedef.Index != j.controlSide.Index) {
offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign; offset -= j.controlSide.OffsetY;
offset -= j.sidedef.OffsetY; offset -= j.controlSide.Fields.GetValue("offsety_mid", 0.0f);
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offset % (float)texture.Height);
} else {
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetMiddleOffsetY(j.sidedef, offset, j.scaleY, true) % (float)texture.Height);//mxd
} }
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height);//mxd
} }
} }
forwardoffset = j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex * offsetscalex); forwardoffset = j.offsetx + (int)Math.Round(j.sidedef.Line.Length / scalex * offsetscalex);
backwardoffset = j.offsetx; backwardoffset = j.offsetx;
// Done this sidedef // Done this sidedef
j.sidedef.Marked = true; j.sidedef.Marked = true;
j.controlSide.Marked = true;
// Add sidedefs backward (connected to the left vertex) // Add sidedefs backward (connected to the left vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End; v = j.sidedef.IsFront ? j.sidedef.Line.Start : j.sidedef.Line.End;
@ -2938,34 +2988,40 @@ namespace CodeImp.DoomBuilder.BuilderModes
} else { } else {
// Apply alignment // Apply alignment
if(alignx) { if(alignx) {
float offset = j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex); float offset = j.offsetx - (int)Math.Round(j.sidedef.Line.Length / scalex * offsetscalex);
offset %= (float)texture.Width; //mxd
offset -= j.sidedef.OffsetX; offset -= j.sidedef.OffsetX;
j.sidedef.Fields.BeforeFieldsChange();
if(matchtop) if(matchtop)
j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsetx_top"] = new UniValue(UniversalType.Float, offset % (float)texture.Width);
if(matchbottom) if(matchbottom)
j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, offset); j.sidedef.Fields["offsetx_bottom"] = new UniValue(UniversalType.Float, offset % (float)texture.Width);
if(matchmid) if(matchmid) {
j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, offset); if(j.sidedef.Index != j.controlSide.Index) { //mxd
offset -= j.controlSide.OffsetX;
offset -= j.controlSide.Fields.GetValue("offsetx_mid", 0.0f);
}
j.sidedef.Fields["offsetx_mid"] = new UniValue(UniversalType.Float, offset % (float)texture.Width);
}
} }
if(aligny) { if(aligny) {
float offset = ((float)(start.Sector.CeilHeight - j.sidedef.Sector.CeilHeight) / scaley) + ystartalign; float offset = ((float)(start.Sidedef.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) * j.scaleY + ystartalign; //mxd
offset -= j.sidedef.OffsetY; offset -= j.sidedef.OffsetY; //mxd
offset = (float)Math.Round(offset); //mxd
j.sidedef.Fields.BeforeFieldsChange();
if(matchtop) if(matchtop)
j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetTopOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd j.sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, GetTopOffsetY(j.sidedef, offset, j.scaleY, true) % (float)texture.Height); //mxd
if(matchbottom) if(matchbottom)
j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetBottomOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd j.sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, GetBottomOffsetY(j.sidedef, offset, j.scaleY, true) % (float)texture.Height); //mxd
if(matchmid) { if(matchmid) {
//mxd. Side is part of a 3D floor? //mxd. Side is part of a 3D floor?
if(j.sidedef.Index != j.controlSide.Index) { if(j.sidedef.Index != j.controlSide.Index) {
offset = ((float)(start.Sector.CeilHeight - j.controlSide.Sector.CeilHeight) / scaley) + ystartalign; offset -= j.controlSide.OffsetY;
offset -= j.sidedef.OffsetY; offset -= j.controlSide.Fields.GetValue("offsety_mid", 0.0f);
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offset % (float)texture.Height); //mxd
} else {
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetMiddleOffsetY(j.sidedef, offset, j.scaleY, true) % (float)texture.Height); //mxd
} }
j.sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, GetMiddleOffsetY(j.sidedef, offset, true) % (float)texture.Height); //mxd
} }
} }
forwardoffset = j.offsetx; forwardoffset = j.offsetx;
@ -2973,6 +3029,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Done this sidedef // Done this sidedef
j.sidedef.Marked = true; j.sidedef.Marked = true;
j.controlSide.Marked = true;
// Add sidedefs forward (connected to the right vertex) // Add sidedefs forward (connected to the right vertex)
v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start; v = j.sidedef.IsFront ? j.sidedef.Line.End : j.sidedef.Line.Start;
@ -2990,6 +3047,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
foreach(Linedef ld in v.Linedefs) { foreach(Linedef ld in v.Linedefs) {
Sidedef side1 = forward ? ld.Front : ld.Back; Sidedef side1 = forward ? ld.Front : ld.Back;
Sidedef side2 = forward ? ld.Back : ld.Front; Sidedef side2 = forward ? ld.Back : ld.Front;
if((ld.Start == v) && (side1 != null) && !side1.Marked) { if((ld.Start == v) && (side1 != null) && !side1.Marked) {
List<Sidedef> controlSides = getControlSides(side1, udmf);//mxd List<Sidedef> controlSides = getControlSides(side1, udmf);//mxd
@ -3002,7 +3060,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
nj.sidedef = side1; nj.sidedef = side1;
nj.controlSide = s; //mxd nj.controlSide = s; //mxd
stack.Push(nj); stack.Push(nj);
break;
} }
} }
} else if((ld.End == v) && (side2 != null) && !side2.Marked) { } else if((ld.End == v) && (side2 != null) && !side2.Marked) {
@ -3017,48 +3074,52 @@ namespace CodeImp.DoomBuilder.BuilderModes
nj.sidedef = side2; nj.sidedef = side2;
nj.controlSide = s; //mxd nj.controlSide = s; //mxd
stack.Push(nj); stack.Push(nj);
break;
} }
} }
} }
} }
} }
//mxd
private bool sidePartIsSelected(List<BaseVisualGeometrySidedef> selection, Sidedef side, VisualGeometryType geoType) {
foreach(BaseVisualGeometrySidedef vs in selection)
if(vs.GeometryType == geoType && vs.Sidedef.Index == side.Index) return true;
return false;
}
//mxd. This converts offsetY from/to "normalized" offset for given upper wall //mxd. This converts offsetY from/to "normalized" offset for given upper wall
internal float GetTopOffsetY(Sidedef side, float offset, bool fromNormalized) { internal float GetTopOffsetY(Sidedef side, float offset, float scaleY, bool fromNormalized) {
if(side.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag) || side.Other == null || side.Other.Sector == null) if(side.Line.IsFlagSet(General.Map.Config.UpperUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
return offset; return offset;
//if we don't have UpperUnpegged flag, normalize offset //if we don't have UpperUnpegged flag, normalize offset
float scale = side.Fields.GetValue("scaley_top", 1.0f); float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.CeilHeight) * scaleY;
float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.CeilHeight) * scale;
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight); if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight); return (float)Math.Round(offset - surfaceHeight);
} }
//mxd. This converts offsetY from/to "normalized" offset for given middle wall //mxd. This converts offsetY from/to "normalized" offset for given middle wall
internal float GetMiddleOffsetY(Sidedef side, float offset, bool fromNormalized) { internal float GetMiddleOffsetY(Sidedef side, float offset, float scaleY, bool fromNormalized) {
if(!side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Sector == null) if(!side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Sector == null)
return offset; return offset;
//if we have LowerUnpegged flag, normalize offset //if we have LowerUnpegged flag, normalize offset
float scale = side.Fields.GetValue("scaley_mid", 1.0f); float surfaceHeight = (side.Sector.CeilHeight - side.Sector.FloorHeight) * scaleY;
float surfaceHeight = (side.Sector.CeilHeight - side.Sector.FloorHeight) * scale;
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight); if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight); return (float)Math.Round(offset - surfaceHeight);
} }
//mxd. This converts offsetY from/to "normalized" offset for given lower wall //mxd. This converts offsetY from/to "normalized" offset for given lower wall
internal float GetBottomOffsetY(Sidedef side, float offset, bool fromNormalized) { internal float GetBottomOffsetY(Sidedef side, float offset, float scaleY, bool fromNormalized) {
offset *= scaleY;
if(side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Other == null || side.Other.Sector == null) if(side.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag) || side.Other == null || side.Other.Sector == null)
return offset; return offset;
//normalize offset //normalize offset
float scale = side.Fields.GetValue("scaley_bottom", 1.0f); float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.FloorHeight) * scaleY;
float surfaceHeight = (side.Sector.CeilHeight - side.Other.Sector.FloorHeight) * scale;
if(fromNormalized) return (float)Math.Round(offset + surfaceHeight); if(fromNormalized) return (float)Math.Round(offset + surfaceHeight);
return (float)Math.Round(offset - surfaceHeight); return (float)Math.Round(offset - surfaceHeight);
} }

View file

@ -441,6 +441,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnMouseMove(MouseEventArgs e) { } public virtual void OnMouseMove(MouseEventArgs e) { }
public virtual void OnChangeTargetBrightness(bool up) { } public virtual void OnChangeTargetBrightness(bool up) { }
public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { } public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public virtual void OnChangeTextureScale(float incrementX, float incrementY) { } //mxd
public virtual void OnSelectTexture() { } public virtual void OnSelectTexture() { }
public virtual void OnCopyTexture() { } public virtual void OnCopyTexture() { }
public virtual void OnPasteTexture() { } public virtual void OnPasteTexture() { }
@ -570,7 +571,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
//mxd //mxd
public void OnRotate(int ammount) { public void Rotate(int ammount) {
if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket)) if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
undoticket = mode.CreateUndo("Rotate thing"); undoticket = mode.CreateUndo("Rotate thing");
Thing.Rotate(ammount); Thing.Rotate(ammount);

View file

@ -218,6 +218,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public virtual void OnMouseMove(MouseEventArgs e) { } public virtual void OnMouseMove(MouseEventArgs e) { }
public virtual void OnChangeTargetBrightness(bool up) { } public virtual void OnChangeTargetBrightness(bool up) { }
public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { } public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public virtual void OnChangeTextureScale(float incrementX, float incrementY) { }
public virtual void OnSelectTexture() { } public virtual void OnSelectTexture() { }
public virtual void OnCopyTexture() { } public virtual void OnCopyTexture() { }
public virtual void OnPasteTexture() { } public virtual void OnPasteTexture() { }

View file

@ -33,6 +33,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
void OnChangeTargetHeight(int amount); void OnChangeTargetHeight(int amount);
void OnChangeTargetBrightness(bool up); void OnChangeTargetBrightness(bool up);
void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection); void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection);
void OnChangeTextureScale(float incrementX, float incrementY); //mxd
void OnResetTextureOffset(); void OnResetTextureOffset();
void OnSelectTexture(); void OnSelectTexture();
void OnCopyTexture(); void OnCopyTexture();

View file

@ -34,6 +34,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void OnChangeTargetHeight(int amount) { } public void OnChangeTargetHeight(int amount) { }
public void OnChangeTargetBrightness(bool up) { } public void OnChangeTargetBrightness(bool up) { }
public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { } public void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection) { }
public virtual void OnChangeTextureScale(float incrementX, float incrementY) { } //mxd
public void OnResetTextureOffset() { } public void OnResetTextureOffset() { }
public void OnSelectTexture() { } public void OnSelectTexture() { }
public void OnCopyTexture() { } public void OnCopyTexture() { }

View file

@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -177,11 +178,50 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
Sector s = GetControlSector(); Sector s = GetControlSector();
s.Fields.BeforeFieldsChange(); s.Fields.BeforeFieldsChange();
float oldx = s.Fields.GetValue("xpanningceiling", 0.0f); float nx = s.Fields.GetValue("xpanningceiling", 0.0f) + (float)xy.X;
float oldy = s.Fields.GetValue("ypanningceiling", 0.0f); float ny = s.Fields.GetValue("ypanningceiling", 0.0f) + (float)xy.Y;
s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, oldx + (float)xy.X); s.Fields["xpanningceiling"] = new UniValue(UniversalType.Float, nx);
s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y); s.Fields["ypanningceiling"] = new UniValue(UniversalType.Float, ny);
s.UpdateNeeded = true; s.UpdateNeeded = true;
mode.SetActionResult("Changed ceiling texture offsets to " + nx + ", " + ny + ".");
}
//mxd. Texture scale change
protected override void ChangeTextureScale(float incrementX, float incrementY) {
Sector s = GetControlSector();
float scaleX = s.Fields.GetValue("xscaleceiling", 1.0f);
float scaleY = s.Fields.GetValue("yscaleceiling", 1.0f);
s.Fields.BeforeFieldsChange();
if(incrementX != 0) {
if(scaleX + incrementX == 0)
scaleX *= -1;
else
scaleX += incrementX;
UDMFTools.SetFloat(s.Fields, "xscaleceiling", scaleX, 1.0f, false);
}
if(incrementY != 0) {
if(scaleY + incrementY == 0)
scaleY *= -1;
else
scaleY += incrementY;
UDMFTools.SetFloat(s.Fields, "yscaleceiling", scaleY, 1.0f, false);
}
//update geometry
onTextureChanged();
s.UpdateNeeded = true;
s.UpdateCache();
if(s.Index != Sector.Sector.Index) {
Sector.Sector.UpdateNeeded = true;
Sector.Sector.UpdateCache();
}
mode.SetActionResult("Ceiling scale changed to " + scaleX + ", " + scaleY);
} }
//mxd //mxd
@ -190,14 +230,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.CreateUndo("Reset texture offsets"); mode.CreateUndo("Reset texture offsets");
mode.SetActionResult("Texture offsets reset."); mode.SetActionResult("Texture offsets reset.");
Sector.Sector.Fields.BeforeFieldsChange();
if(Sector.Sector.Fields.ContainsKey("xpanningceiling")) { string[] keys = new string[] { "xpanningceiling", "ypanningceiling", "xscaleceiling", "yscaleceiling", "rotationceiling" };
Sector.Sector.Fields.Remove("xpanningceiling");
Sector.Sector.UpdateNeeded = true; foreach(string key in keys){
} if(Sector.Sector.Fields.ContainsKey(key)) {
if(Sector.Sector.Fields.ContainsKey("ypanningceiling")) { Sector.Sector.Fields.Remove(key);
Sector.Sector.Fields.Remove("ypanningceiling"); Sector.Sector.UpdateNeeded = true;
Sector.Sector.UpdateNeeded = true; }
} }
if(Sector.Sector.UpdateNeeded) if(Sector.Sector.UpdateNeeded)
@ -212,7 +253,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.CreateUndo("Paste ceiling " + BuilderPlug.Me.CopiedFlat); mode.CreateUndo("Paste ceiling " + BuilderPlug.Me.CopiedFlat);
mode.SetActionResult("Pasted flat " + BuilderPlug.Me.CopiedFlat + " on ceiling."); mode.SetActionResult("Pasted flat " + BuilderPlug.Me.CopiedFlat + " on ceiling.");
SetTexture(BuilderPlug.Me.CopiedFlat); SetTexture(BuilderPlug.Me.CopiedFlat);
this.Setup();
//mxd. 3D floors may need updating... //mxd. 3D floors may need updating...
onTextureChanged(); onTextureChanged();

View file

@ -25,6 +25,7 @@ using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -170,11 +171,50 @@ namespace CodeImp.DoomBuilder.BuilderModes
//mxd //mxd
Sector s = GetControlSector(); Sector s = GetControlSector();
s.Fields.BeforeFieldsChange(); s.Fields.BeforeFieldsChange();
float oldx = s.Fields.GetValue("xpanningfloor", 0.0f); float nx = s.Fields.GetValue("xpanningfloor", 0.0f) + (float)xy.X;
float oldy = s.Fields.GetValue("ypanningfloor", 0.0f); float ny = s.Fields.GetValue("ypanningfloor", 0.0f) + (float)xy.Y;
s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, oldx + (float)xy.X); s.Fields["xpanningfloor"] = new UniValue(UniversalType.Float, nx);
s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, oldy + (float)xy.Y); s.Fields["ypanningfloor"] = new UniValue(UniversalType.Float, ny);
s.UpdateNeeded = true; s.UpdateNeeded = true;
mode.SetActionResult("Changed floor texture offsets to " + nx + ", " + ny + ".");
}
//mxd. Texture scale change
protected override void ChangeTextureScale(float incrementX, float incrementY) {
Sector s = GetControlSector();
float scaleX = s.Fields.GetValue("xscalefloor", 1.0f);
float scaleY = s.Fields.GetValue("yscalefloor", 1.0f);
s.Fields.BeforeFieldsChange();
if(incrementX != 0) {
if(scaleX + incrementX == 0)
scaleX *= -1;
else
scaleX += incrementX;
UDMFTools.SetFloat(s.Fields, "xscalefloor", scaleX, 1.0f, false);
}
if(incrementY != 0) {
if(scaleY + incrementY == 0)
scaleY *= -1;
else
scaleY += incrementY;
UDMFTools.SetFloat(s.Fields, "yscalefloor", scaleY, 1.0f, false);
}
//update geometry
onTextureChanged();
s.UpdateNeeded = true;
s.UpdateCache();
if(s.Index != Sector.Sector.Index) {
Sector.Sector.UpdateNeeded = true;
Sector.Sector.UpdateCache();
}
mode.SetActionResult("Floor scale changed to " + scaleX + ", " + scaleY);
} }
//mxd //mxd
@ -185,13 +225,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.SetActionResult("Texture offsets reset."); mode.SetActionResult("Texture offsets reset.");
Sector.Sector.Fields.BeforeFieldsChange(); Sector.Sector.Fields.BeforeFieldsChange();
if(Sector.Sector.Fields.ContainsKey("xpanningfloor")) { string[] keys = new string[] { "xpanningfloor", "ypanningfloor", "xscalefloor", "yscalefloor", "rotationfloor" };
Sector.Sector.Fields.Remove("xpanningfloor");
Sector.Sector.UpdateNeeded = true; foreach(string key in keys) {
} if(Sector.Sector.Fields.ContainsKey(key)) {
if(Sector.Sector.Fields.ContainsKey("ypanningfloor")) { Sector.Sector.Fields.Remove(key);
Sector.Sector.Fields.Remove("ypanningfloor"); Sector.Sector.UpdateNeeded = true;
Sector.Sector.UpdateNeeded = true; }
} }
if(Sector.Sector.UpdateNeeded) if(Sector.Sector.UpdateNeeded)
@ -206,7 +246,6 @@ namespace CodeImp.DoomBuilder.BuilderModes
mode.CreateUndo("Paste floor " + BuilderPlug.Me.CopiedFlat); mode.CreateUndo("Paste floor " + BuilderPlug.Me.CopiedFlat);
mode.SetActionResult("Pasted flat " + BuilderPlug.Me.CopiedFlat + " on floor."); mode.SetActionResult("Pasted flat " + BuilderPlug.Me.CopiedFlat + " on floor.");
SetTexture(BuilderPlug.Me.CopiedFlat); SetTexture(BuilderPlug.Me.CopiedFlat);
this.Setup();
//mxd. 3D floors may need updating... //mxd. 3D floors may need updating...
onTextureChanged(); onTextureChanged();

View file

@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -49,7 +50,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public VisualLower(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s) public VisualLower(BaseVisualMode mode, VisualSector vs, Sidedef s) : base(mode, vs, s)
{ {
//mxd //mxd
geoType = VisualGeometryType.WALL_BOTTOM; geoType = VisualGeometryType.WALL_LOWER;
// We have no destructor // We have no destructor
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
@ -243,6 +244,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }
//mxd
protected override void ResetTextureScale() {
Sidedef.Fields.BeforeFieldsChange();
if(Sidedef.Fields.ContainsKey("scalex_bottom")) Sidedef.Fields.Remove("scalex_bottom");
if(Sidedef.Fields.ContainsKey("scaley_bottom")) Sidedef.Fields.Remove("scaley_bottom");
}
//mxd //mxd
public override void OnChangeTargetBrightness(bool up) { public override void OnChangeTargetBrightness(bool up) {
if(!General.Map.UDMF) { if(!General.Map.UDMF) {
@ -289,37 +297,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
if(fitWidth) { if(fitWidth) {
float scaleX = Texture.Width / Sidedef.Line.Length; float scaleX = Texture.ScaledWidth / Sidedef.Line.Length;
UDMFTools.SetFloat(Sidedef.Fields, "scalex_bottom", scaleX, 1.0f, false);
if(scaleX == 1.0f) { float offsetX = (float)Math.Round(-(float)Sidedef.OffsetX * scaleX);
if(Sidedef.Fields.GetValue("scalex_bottom", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsetx_bottom", offsetX, 0.0f, false);
Sidedef.Fields.Remove("scalex_bottom");
} else {
Sidedef.Fields["scalex_bottom"] = new UniValue(UniversalType.Float, scaleX);
}
if(Sidedef.Fields.ContainsKey("offsetx_bottom"))
Sidedef.Fields.Remove("offsetx_bottom");
} }
if(fitHeight && Sidedef.Sector != null && Sidedef.Other.Sector != null) { if(fitHeight && Sidedef.Sector != null && Sidedef.Other.Sector != null) {
float scaleY = (float)Texture.Height / (Sidedef.Other.Sector.FloorHeight - Sidedef.Sector.FloorHeight); float scaleY = (float)Texture.Height / (Sidedef.Other.Sector.FloorHeight - Sidedef.Sector.FloorHeight);
UDMFTools.SetFloat(Sidedef.Fields, "scaley_bottom", scaleY, 1.0f, false);
if(scaleY == 1.0f) { float offsetY = mode.GetBottomOffsetY(Sidedef, -Sidedef.OffsetY, scaleY, true) % Texture.Height;
if(Sidedef.Fields.GetValue("scaley_bottom", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsety_bottom", offsetY, 0.0f, false);
Sidedef.Fields.Remove("scaley_bottom");
} else {
Sidedef.Fields["scaley_bottom"] = new UniValue(UniversalType.Float, scaleY);
}
float offsetY = 0f;
if(Sidedef.Line.IsFlagSet(General.Map.Config.LowerUnpeggedFlag))
offsetY = -(float)Math.Round((Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.FloorHeight) * scaleY) % Texture.Height;
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_bottom"))
Sidedef.Fields.Remove("offsety_bottom");
else
Sidedef.Fields["offsety_bottom"] = new UniValue(UniversalType.Float, offsetY);
} }
Setup(); Setup();

View file

@ -134,7 +134,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
tsz = tsz / tscale; tsz = tsz / tscale;
// Get texture offsets // Get texture offsets
Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY);
tof = tof + toffset1 + toffset2; tof = tof + toffset1 + toffset2;
tof = tof / tscale; tof = tof / tscale;
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)

View file

@ -104,7 +104,7 @@ namespace CodeImp.DoomBuilder.BuilderModes {
tsz = tsz / tscale; tsz = tsz / tscale;
// Get texture offsets // Get texture offsets
Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY); Vector2D tof = new Vector2D(Sidedef.OffsetX, Sidedef.OffsetY) + new Vector2D(sourceside.OffsetX, sourceside.OffsetY);
tof = tof + toffset1 + toffset2; tof = tof + toffset1 + toffset2;
tof = tof / tscale; tof = tof / tscale;
if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning) if(General.Map.Config.ScaledTextureOffsets && !base.Texture.WorldPanning)

View file

@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -288,6 +289,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }
//mxd
protected override void ResetTextureScale() {
Sidedef.Fields.BeforeFieldsChange();
if(Sidedef.Fields.ContainsKey("scalex_mid")) Sidedef.Fields.Remove("scalex_mid");
if(Sidedef.Fields.ContainsKey("scaley_mid")) Sidedef.Fields.Remove("scaley_mid");
}
//mxd //mxd
public override void OnChangeTargetBrightness(bool up) { public override void OnChangeTargetBrightness(bool up) {
if(!General.Map.UDMF) { if(!General.Map.UDMF) {
@ -334,35 +342,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
if(fitWidth) { if(fitWidth) {
float scaleX = Texture.Width / Sidedef.Line.Length; float scaleX = Texture.ScaledWidth / Sidedef.Line.Length;
UDMFTools.SetFloat(Sidedef.Fields, "scalex_mid", scaleX, 1.0f, false);
if(scaleX == 1.0f) { float offsetX = (float)Math.Round(-(float)Sidedef.OffsetX * scaleX);
if(Sidedef.Fields.GetValue("scalex_mid", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsetx_mid", offsetX, 0.0f, false);
Sidedef.Fields.Remove("scalex_mid");
} else {
Sidedef.Fields["scalex_mid"] = new UniValue(UniversalType.Float, scaleX);
}
if(Sidedef.Fields.ContainsKey("offsetx_mid"))
Sidedef.Fields.Remove("offsetx_mid");
} }
if(fitHeight && Sidedef.Sector != null) { if(fitHeight && Sidedef.Sector != null) {
float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Sector.FloorHeight); float scaleY = (float)Texture.ScaledHeight / (Sidedef.Sector.CeilHeight - Sidedef.Sector.FloorHeight);
UDMFTools.SetFloat(Sidedef.Fields, "scaley_mid", scaleY, 1.0f, false);
if(scaleY == 1.0f) { float offsetY = mode.GetMiddleOffsetY(Sidedef, -Sidedef.OffsetY, scaleY, true) % Texture.Height;
if(Sidedef.Fields.GetValue("scaley_mid", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsety_mid", offsetY, 0.0f, false);
Sidedef.Fields.Remove("scaley_mid");
} else {
Sidedef.Fields["scaley_mid"] = new UniValue(UniversalType.Float, scaleY);
}
float offsetY = mode.GetMiddleOffsetY(Sidedef, 0f, true) % Texture.Height;
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_mid"))
Sidedef.Fields.Remove("offsety_mid");
else
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offsetY);
} }
Setup(); Setup();

View file

@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -239,6 +240,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }
//mxd
protected override void ResetTextureScale() {
Sidedef.Fields.BeforeFieldsChange();
if(Sidedef.Fields.ContainsKey("scalex_mid")) Sidedef.Fields.Remove("scalex_mid");
if(Sidedef.Fields.ContainsKey("scaley_mid")) Sidedef.Fields.Remove("scaley_mid");
}
//mxd //mxd
public override void OnChangeTargetBrightness(bool up) { public override void OnChangeTargetBrightness(bool up) {
if(!General.Map.UDMF) { if(!General.Map.UDMF) {
@ -285,35 +293,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
if(fitWidth) { if(fitWidth) {
float scaleX = Texture.Width / Sidedef.Line.Length; float scaleX = Texture.ScaledWidth / Sidedef.Line.Length;
UDMFTools.SetFloat(Sidedef.Fields, "scalex_mid", scaleX, 1.0f, false);
if(scaleX == 1.0f) { float offsetX = (float)Math.Round(-(float)Sidedef.OffsetX * scaleX);
if(Sidedef.Fields.GetValue("scalex_mid", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsetx_mid", offsetX, 0.0f, false);
Sidedef.Fields.Remove("scalex_mid");
} else {
Sidedef.Fields["scalex_mid"] = new UniValue(UniversalType.Float, scaleX);
}
if(Sidedef.Fields.ContainsKey("offsetx_mid"))
Sidedef.Fields.Remove("offsetx_mid");
} }
if(fitHeight && Sidedef.Sector != null){ if(fitHeight && Sidedef.Sector != null){
float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Sector.FloorHeight); float scaleY = (float)Texture.ScaledHeight / (Sidedef.Sector.CeilHeight - Sidedef.Sector.FloorHeight);
UDMFTools.SetFloat(Sidedef.Fields, "scaley_mid", scaleY, 1.0f, false);
if(scaleY == 1.0f) { float offsetY = mode.GetMiddleOffsetY(Sidedef, -Sidedef.OffsetY, scaleY, true) % Texture.Height;
if(Sidedef.Fields.GetValue("scaley_mid", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsety_mid", offsetY, 0.0f, false);
Sidedef.Fields.Remove("scaley_mid");
} else {
Sidedef.Fields["scaley_mid"] = new UniValue(UniversalType.Float, scaleY);
}
float offsetY = mode.GetMiddleOffsetY(Sidedef, 0f, true) % Texture.Height;
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_mid"))
Sidedef.Fields.Remove("offsety_mid");
else
Sidedef.Fields["offsety_mid"] = new UniValue(UniversalType.Float, offsetY);
} }
Setup(); Setup();

View file

@ -24,6 +24,7 @@ using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Rendering; using CodeImp.DoomBuilder.Rendering;
using CodeImp.DoomBuilder.Types; using CodeImp.DoomBuilder.Types;
using CodeImp.DoomBuilder.VisualModes; using CodeImp.DoomBuilder.VisualModes;
using CodeImp.DoomBuilder.GZBuilder.Tools;
#endregion #endregion
@ -242,6 +243,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
return new Point((int)oldx, (int)oldy); return new Point((int)oldx, (int)oldy);
} }
//mxd
protected override void ResetTextureScale() {
Sidedef.Fields.BeforeFieldsChange();
if(Sidedef.Fields.ContainsKey("scalex_top")) Sidedef.Fields.Remove("scalex_top");
if(Sidedef.Fields.ContainsKey("scaley_top")) Sidedef.Fields.Remove("scaley_top");
}
//mxd //mxd
public override void OnChangeTargetBrightness(bool up) { public override void OnChangeTargetBrightness(bool up) {
if(!General.Map.UDMF) { if(!General.Map.UDMF) {
@ -288,35 +296,19 @@ namespace CodeImp.DoomBuilder.BuilderModes
Sidedef.Fields.BeforeFieldsChange(); Sidedef.Fields.BeforeFieldsChange();
if(fitWidth) { if(fitWidth) {
float scaleX = Texture.Width / Sidedef.Line.Length; float scaleX = Texture.ScaledWidth / Sidedef.Line.Length;
UDMFTools.SetFloat(Sidedef.Fields, "scalex_top", scaleX, 1.0f, false);
if(scaleX == 1.0f) { float offsetX = (float)Math.Round(-(float)Sidedef.OffsetX * scaleX);
if(Sidedef.Fields.GetValue("scalex_top", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsetx_top", offsetX, 0.0f, false);
Sidedef.Fields.Remove("scalex_top");
} else {
Sidedef.Fields["scalex_top"] = new UniValue(UniversalType.Float, scaleX);
}
if(Sidedef.Fields.ContainsKey("offsetx_top"))
Sidedef.Fields.Remove("offsetx_top");
} }
if(fitHeight && Sidedef.Sector != null && Sidedef.Other.Sector != null) { if(fitHeight && Sidedef.Sector != null && Sidedef.Other.Sector != null) {
float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.CeilHeight); float scaleY = (float)Texture.Height / (Sidedef.Sector.CeilHeight - Sidedef.Other.Sector.CeilHeight);
UDMFTools.SetFloat(Sidedef.Fields, "scaley_top", scaleY, 1.0f, false);
if(scaleY == 1.0f) { float offsetY = mode.GetTopOffsetY(Sidedef, -Sidedef.OffsetY, scaleY, true) % Texture.Height;
if(Sidedef.Fields.GetValue("scaley_top", 1.0f) != 1.0f) UDMFTools.SetFloat(Sidedef.Fields, "offsety_top", offsetY, 0.0f, false);
Sidedef.Fields.Remove("scaley_top");
} else {
Sidedef.Fields["scaley_top"] = new UniValue(UniversalType.Float, scaleY);
}
float offsetY = mode.GetTopOffsetY(Sidedef, 0f, true) % Texture.Height;
if(offsetY == 0f && Sidedef.Fields.ContainsKey("offsety_top"))
Sidedef.Fields.Remove("offsety_top");
else
Sidedef.Fields["offsety_top"] = new UniValue(UniversalType.Float, offsetY);
} }
Setup(); Setup();

View file

@ -102,7 +102,7 @@ namespace CodeImp.DoomBuilder.UDMFControls
setDefaultUniversalProperties(sp.Sector.Fields, defaultSectorFields); setDefaultUniversalProperties(sp.Sector.Fields, defaultSectorFields);
break; break;
case VisualGeometryType.WALL_BOTTOM: case VisualGeometryType.WALL_LOWER:
if (firstWall == null) firstWall = sp; if (firstWall == null) firstWall = sp;
wallsBottom.Add(sp); wallsBottom.Add(sp);
setDefaultUniversalProperties(sp.Sidedef.Fields, defaultSidedefFields); setDefaultUniversalProperties(sp.Sidedef.Fields, defaultSidedefFields);
@ -692,7 +692,7 @@ namespace CodeImp.DoomBuilder.UDMFControls
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
return "scale$_mid"; return "scale$_mid";
case VisualGeometryType.WALL_BOTTOM: case VisualGeometryType.WALL_LOWER:
return "scale$_bottom"; return "scale$_bottom";
} }
return ""; return "";
@ -722,7 +722,7 @@ namespace CodeImp.DoomBuilder.UDMFControls
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
return "offset$_mid"; return "offset$_mid";
case VisualGeometryType.WALL_BOTTOM: case VisualGeometryType.WALL_LOWER:
return "offset$_bottom"; return "offset$_bottom";
} }
return ""; return "";
@ -749,7 +749,7 @@ namespace CodeImp.DoomBuilder.UDMFControls
case VisualGeometryType.CEILING: case VisualGeometryType.CEILING:
return "lightceiling"; return "lightceiling";
case VisualGeometryType.WALL_BOTTOM: case VisualGeometryType.WALL_LOWER:
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
case VisualGeometryType.WALL_MIDDLE_3D: case VisualGeometryType.WALL_MIDDLE_3D:
case VisualGeometryType.WALL_UPPER: case VisualGeometryType.WALL_UPPER:
@ -766,7 +766,7 @@ namespace CodeImp.DoomBuilder.UDMFControls
case VisualGeometryType.CEILING: case VisualGeometryType.CEILING:
return "lightceilingabsolute"; return "lightceilingabsolute";
case VisualGeometryType.WALL_BOTTOM: case VisualGeometryType.WALL_LOWER:
case VisualGeometryType.WALL_MIDDLE: case VisualGeometryType.WALL_MIDDLE:
case VisualGeometryType.WALL_MIDDLE_3D: case VisualGeometryType.WALL_MIDDLE_3D:
case VisualGeometryType.WALL_UPPER: case VisualGeometryType.WALL_UPPER: