Draw Grid Mode: number of slices less than 3 will now be remembered correctly

Draw Grid Mode: added option to to draw the slices relative to the origin of the drawing (so that you don't have to change the slice interpolation all the time)
This commit is contained in:
biwa 2020-06-08 23:00:14 +02:00
parent f10bf59775
commit 95dd6e284e
4 changed files with 81 additions and 36 deletions

View file

@ -45,6 +45,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
private int horizontalslices;
private int verticalslices;
private bool triangulate;
private bool relativeinterpolation;
private GridLockMode gridlockmode;
private InterpolationTools.Mode horizontalinterpolation;
private InterpolationTools.Mode verticalinterpolation;
@ -471,28 +472,41 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void UpdateReferencePoints(DrawnVertex p1, DrawnVertex p2)
{
if(!p1.pos.IsFinite() || !p2.pos.IsFinite()) return;
if(p1.pos.x < p2.pos.x)
// If relative interpolation is enabled the interpolation will use the point where the drawing
// started as the origin, not always the top left corner
if (relativeinterpolation)
{
start.x = p1.pos.x;
start.y = p1.pos.y;
end.x = p2.pos.x;
}
else
end.y = p2.pos.y;
}
else
{
start.x = p2.pos.x;
end.x = p1.pos.x;
if (p1.pos.x < p2.pos.x)
{
start.x = p1.pos.x;
end.x = p2.pos.x;
}
else
{
start.x = p2.pos.x;
end.x = p1.pos.x;
}
if (p1.pos.y < p2.pos.y)
{
start.y = p1.pos.y;
end.y = p2.pos.y;
}
else
{
start.y = p2.pos.y;
end.y = p1.pos.y;
}
}
if(p1.pos.y < p2.pos.y)
{
start.y = p1.pos.y;
end.y = p2.pos.y;
}
else
{
start.y = p2.pos.y;
end.y = p1.pos.y;
}
width = (int)(end.x - start.x);
height = (int)(end.y - start.y);
@ -507,8 +521,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Load stored settings
triangulate = General.Settings.ReadPluginSetting("drawgridmode.triangulate", false);
gridlockmode = (GridLockMode)General.Settings.ReadPluginSetting("drawgridmode.gridlockmode", 0);
horizontalslices = Math.Max(General.Settings.ReadPluginSetting("drawgridmode.horizontalslices", 3), 3);
verticalslices = Math.Max(General.Settings.ReadPluginSetting("drawgridmode.verticalslices", 3), 3);
horizontalslices = Math.Max(General.Settings.ReadPluginSetting("drawgridmode.horizontalslices", 3), 1);
verticalslices = Math.Max(General.Settings.ReadPluginSetting("drawgridmode.verticalslices", 3), 1);
relativeinterpolation = General.Settings.ReadPluginSetting("drawgridmode.relativeinterpolation", true);
horizontalinterpolation = (InterpolationTools.Mode)General.Settings.ReadPluginSetting("drawgridmode.horizontalinterpolation", 0);
verticalinterpolation = (InterpolationTools.Mode)General.Settings.ReadPluginSetting("drawgridmode.verticalinterpolation", 0);
@ -527,10 +542,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
panel.OnGridLockModeChanged += OptionsPanelOnGridLockChanged;
panel.OnContinuousDrawingChanged += OnContinuousDrawingChanged;
panel.OnShowGuidelinesChanged += OnShowGuidelinesChanged;
panel.OnRelativeInterpolationChanged += OnRelativeInterpolationChanged;
// Needs to be set after adding the OnContinuousDrawingChanged event...
panel.ContinuousDrawing = General.Settings.ReadPluginSetting("drawgridmode.continuousdrawing", false);
panel.ShowGuidelines = General.Settings.ReadPluginSetting("drawgridmode.showguidelines", false);
panel.RelativeInterpolation = relativeinterpolation;
}
protected override void AddInterface()
@ -548,6 +565,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
General.Settings.WritePluginSetting("drawgridmode.gridlockmode", (int)gridlockmode);
General.Settings.WritePluginSetting("drawgridmode.horizontalslices", horizontalslices);
General.Settings.WritePluginSetting("drawgridmode.verticalslices", verticalslices);
General.Settings.WritePluginSetting("drawgridmode.relativeinterpolation", relativeinterpolation);
General.Settings.WritePluginSetting("drawgridmode.horizontalinterpolation", (int)horizontalinterpolation);
General.Settings.WritePluginSetting("drawgridmode.verticalinterpolation", (int)verticalinterpolation);
General.Settings.WritePluginSetting("drawgridmode.continuousdrawing", panel.ContinuousDrawing);
@ -559,6 +577,12 @@ namespace CodeImp.DoomBuilder.BuilderModes
panel = null;
}
protected void OnRelativeInterpolationChanged(object value, EventArgs e)
{
relativeinterpolation = (bool)value;
Update();
}
#endregion
#region ================== Actions

View file

@ -43,6 +43,7 @@
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.relativeinterpolation = new System.Windows.Forms.CheckBox();
this.showguidelines = new System.Windows.Forms.CheckBox();
this.continuousdrawing = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
@ -54,8 +55,8 @@
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox1.Controls.Add(this.gridlockmode);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.triangulate);
@ -73,8 +74,8 @@
//
// gridlockmode
//
this.gridlockmode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridlockmode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gridlockmode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.gridlockmode.FormattingEnabled = true;
this.gridlockmode.Items.AddRange(new object[] {
@ -154,8 +155,8 @@
//
// groupBox2
//
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox2.Controls.Add(this.interpvmode);
this.groupBox2.Controls.Add(this.interphmode);
this.groupBox2.Controls.Add(this.label3);
@ -169,8 +170,8 @@
//
// interpvmode
//
this.interpvmode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.interpvmode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.interpvmode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.interpvmode.FormattingEnabled = true;
this.interpvmode.Location = new System.Drawing.Point(77, 46);
@ -182,8 +183,8 @@
//
// interphmode
//
this.interphmode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.interphmode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.interphmode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.interphmode.FormattingEnabled = true;
this.interphmode.Location = new System.Drawing.Point(77, 19);
@ -213,17 +214,29 @@
//
// groupBox3
//
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.groupBox3.Controls.Add(this.relativeinterpolation);
this.groupBox3.Controls.Add(this.showguidelines);
this.groupBox3.Controls.Add(this.continuousdrawing);
this.groupBox3.Location = new System.Drawing.Point(3, 225);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(200, 71);
this.groupBox3.Size = new System.Drawing.Size(200, 98);
this.groupBox3.TabIndex = 11;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Additional options";
//
// relativeinterpolation
//
this.relativeinterpolation.AutoSize = true;
this.relativeinterpolation.Location = new System.Drawing.Point(20, 70);
this.relativeinterpolation.Name = "relativeinterpolation";
this.relativeinterpolation.Size = new System.Drawing.Size(125, 17);
this.relativeinterpolation.TabIndex = 17;
this.relativeinterpolation.Text = "Relative interpolation";
this.relativeinterpolation.UseVisualStyleBackColor = true;
this.relativeinterpolation.CheckedChanged += new System.EventHandler(this.relativeinterpolation_CheckedChanged);
//
// showguidelines
//
this.showguidelines.AutoSize = true;
@ -286,5 +299,6 @@
private System.Windows.Forms.ComboBox gridlockmode;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.CheckBox showguidelines;
private System.Windows.Forms.CheckBox relativeinterpolation;
}
}

View file

@ -11,6 +11,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public event EventHandler OnGridLockModeChanged;
public event EventHandler OnContinuousDrawingChanged;
public event EventHandler OnShowGuidelinesChanged;
public event EventHandler OnRelativeInterpolationChanged;
private bool blockevents;
@ -22,6 +23,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
public int MaxVerticalSlices { get { return (int)slicesV.Maximum; } set { slicesV.Maximum = value; } }
public bool ContinuousDrawing { get { return continuousdrawing.Checked; } set { continuousdrawing.Checked = value; } }
public bool ShowGuidelines { get { return showguidelines.Checked; } set { showguidelines.Checked = value; } }
public bool RelativeInterpolation { get { return relativeinterpolation.Checked; } set { relativeinterpolation.Checked = value; } }
public InterpolationMode HorizontalInterpolationMode
{
@ -86,17 +88,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
if(mode == GridLockMode.NONE || mode == GridLockMode.HORIZONTAL) slicesV.Value = 3;
blockevents = false;
if(OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
OnValueChanged?.Invoke(this, EventArgs.Empty);
}
private void continuousdrawing_CheckedChanged(object sender, EventArgs e)
{
if(OnContinuousDrawingChanged != null) OnContinuousDrawingChanged(continuousdrawing.Checked, EventArgs.Empty);
OnContinuousDrawingChanged?.Invoke(continuousdrawing.Checked, EventArgs.Empty);
}
private void showguidelines_CheckedChanged(object sender, EventArgs e)
{
if(OnShowGuidelinesChanged != null) OnShowGuidelinesChanged(showguidelines.Checked, EventArgs.Empty);
OnShowGuidelinesChanged?.Invoke(showguidelines.Checked, EventArgs.Empty);
}
private void relativeinterpolation_CheckedChanged(object sender, EventArgs e)
{
OnRelativeInterpolationChanged?.Invoke(relativeinterpolation.Checked, EventArgs.Empty);
}
}
}

View file

@ -112,9 +112,9 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>