Draw Rectangle mode, Draw Ellipse mode: fixed a possible crash when restoring bevel/subdivisions values.

Draw Curve mode: added "Reset" button to the toolbar.
Draw Rectangle/Ellipse/Grid modes: "Reset" toolbar buttons didn't have a proper tooltip.
This commit is contained in:
MaxED 2014-07-02 10:12:53 +00:00
parent 17c793f17d
commit 7254c62ee0
8 changed files with 55 additions and 24 deletions

View file

@ -73,8 +73,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
//got shape //got shape
if (bevelWidth < 0) { if (bevelWidth < 0) {
int bevelSign = (bevelWidth > 0 ? 1 : -1); currentBevelWidth = -Math.Min(Math.Abs(bevelWidth), Math.Min(width, height) / 2) + 1;
currentBevelWidth = Math.Min(Math.Abs(bevelWidth), Math.Min(width, height) / 2) * bevelSign;
} else { } else {
currentBevelWidth = bevelWidth; currentBevelWidth = bevelWidth;
} }
@ -108,7 +107,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
protected override string getHintText() { protected override string getHintText() {
return "BVL: "+bevelWidth+"; VERTS: "+subdivisions; return "BVL: " + bevelWidth + "; VERTS: " + subdivisions;
} }
#endregion #endregion
@ -154,7 +153,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
} }
protected override void decreaseBevel() { protected override void decreaseBevel() {
if(currentBevelWidth == bevelWidth || bevelWidth > 0) { if(bevelWidth > 0 || currentBevelWidth <= bevelWidth + 1) {
bevelWidth = Math.Max(bevelWidth - General.Map.Grid.GridSize, panel.MinSpikiness); bevelWidth = Math.Max(bevelWidth - General.Map.Grid.GridSize, panel.MinSpikiness);
panel.Spikiness = bevelWidth; panel.Spikiness = bevelWidth;
Update(); Update();

View file

@ -26,8 +26,9 @@
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.toolstrip = new System.Windows.Forms.ToolStrip(); this.toolstrip = new System.Windows.Forms.ToolStrip();
this.seglen = new CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown();
this.seglabel = new System.Windows.Forms.ToolStripLabel(); this.seglabel = new System.Windows.Forms.ToolStripLabel();
this.seglen = new CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown();
this.reset = new System.Windows.Forms.ToolStripButton();
this.toolstrip.SuspendLayout(); this.toolstrip.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
@ -35,22 +36,14 @@
// //
this.toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.seglabel, this.seglabel,
this.seglen}); this.seglen,
this.reset});
this.toolstrip.Location = new System.Drawing.Point(0, 0); this.toolstrip.Location = new System.Drawing.Point(0, 0);
this.toolstrip.Name = "toolstrip"; this.toolstrip.Name = "toolstrip";
this.toolstrip.Size = new System.Drawing.Size(249, 25); this.toolstrip.Size = new System.Drawing.Size(249, 25);
this.toolstrip.TabIndex = 7; this.toolstrip.TabIndex = 7;
this.toolstrip.Text = "toolStrip1"; this.toolstrip.Text = "toolStrip1";
// //
// seglen
//
this.seglen.AutoSize = false;
this.seglen.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.seglen.Name = "seglen";
this.seglen.Size = new System.Drawing.Size(56, 20);
this.seglen.Text = "0";
this.seglen.ValueChanged += new System.EventHandler(this.seglen_ValueChanged);
//
// seglabel // seglabel
// //
this.seglabel.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.Gear; this.seglabel.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.Gear;
@ -58,6 +51,40 @@
this.seglabel.Size = new System.Drawing.Size(113, 22); this.seglabel.Size = new System.Drawing.Size(113, 22);
this.seglabel.Text = "Segment Length:"; this.seglabel.Text = "Segment Length:";
// //
// seglen
//
this.seglen.AutoSize = false;
this.seglen.Margin = new System.Windows.Forms.Padding(3, 0, 0, 0);
this.seglen.Maximum = new decimal(new int[] {
100,
0,
0,
0});
this.seglen.Minimum = new decimal(new int[] {
0,
0,
0,
0});
this.seglen.Name = "seglen";
this.seglen.Size = new System.Drawing.Size(56, 20);
this.seglen.Text = "0";
this.seglen.Value = new decimal(new int[] {
0,
0,
0,
0});
this.seglen.ValueChanged += new System.EventHandler(this.seglen_ValueChanged);
//
// reset
//
this.reset.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.reset.Image = global::CodeImp.DoomBuilder.BuilderModes.Properties.Resources.Reset;
this.reset.ImageTransparentColor = System.Drawing.Color.Magenta;
this.reset.Name = "reset";
this.reset.Size = new System.Drawing.Size(23, 22);
this.reset.Text = "Reset";
this.reset.Click += new System.EventHandler(this.reset_Click);
//
// DrawCurveOptionsPanel // DrawCurveOptionsPanel
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -78,6 +105,7 @@
private System.Windows.Forms.ToolStripLabel seglabel; private System.Windows.Forms.ToolStripLabel seglabel;
internal CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown seglen; internal CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown seglen;
private System.Windows.Forms.ToolStrip toolstrip; private System.Windows.Forms.ToolStrip toolstrip;
private System.Windows.Forms.ToolStripButton reset;
} }
} }

View file

@ -22,9 +22,11 @@ namespace CodeImp.DoomBuilder.BuilderModes
public void Register() { public void Register() {
General.Interface.AddButton(seglabel); General.Interface.AddButton(seglabel);
General.Interface.AddButton(seglen); General.Interface.AddButton(seglen);
General.Interface.AddButton(reset);
} }
public void Unregister() { public void Unregister() {
General.Interface.RemoveButton(reset);
General.Interface.RemoveButton(seglen); General.Interface.RemoveButton(seglen);
General.Interface.RemoveButton(seglabel); General.Interface.RemoveButton(seglabel);
} }
@ -32,5 +34,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void seglen_ValueChanged(object sender, EventArgs e) { private void seglen_ValueChanged(object sender, EventArgs e) {
if(!blockEvents && OnValueChanged != null) OnValueChanged(this, EventArgs.Empty); if(!blockEvents && OnValueChanged != null) OnValueChanged(this, EventArgs.Empty);
} }
private void reset_Click(object sender, EventArgs e) {
seglen.Value = seglen.Minimum;
}
} }
} }

View file

@ -77,7 +77,6 @@
0, 0,
0, 0,
0}); 0});
this.subdivs.ValueChanged += new System.EventHandler(this.ValueChanged);
// //
// spikinesslabel // spikinesslabel
// //
@ -107,7 +106,6 @@
0, 0,
0, 0,
0}); 0});
this.spikiness.ValueChanged += new System.EventHandler(this.ValueChanged);
// //
// reset // reset
// //
@ -116,7 +114,7 @@
this.reset.ImageTransparentColor = System.Drawing.Color.Magenta; this.reset.ImageTransparentColor = System.Drawing.Color.Magenta;
this.reset.Name = "reset"; this.reset.Name = "reset";
this.reset.Size = new System.Drawing.Size(23, 22); this.reset.Size = new System.Drawing.Size(23, 22);
this.reset.Text = "toolStripButton1"; this.reset.Text = "Reset";
this.reset.Click += new System.EventHandler(this.reset_Click); this.reset.Click += new System.EventHandler(this.reset_Click);
// //
// DrawEllipseOptionsPanel // DrawEllipseOptionsPanel

View file

@ -20,14 +20,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
public DrawEllipseOptionsPanel() { public DrawEllipseOptionsPanel() {
InitializeComponent(); InitializeComponent();
}
public void Register() {
spikiness.Value = aquityValue; spikiness.Value = aquityValue;
subdivs.Value = subdivsValue; subdivs.Value = subdivsValue;
spikiness.ValueChanged += ValueChanged; spikiness.ValueChanged += ValueChanged;
subdivs.ValueChanged += ValueChanged; subdivs.ValueChanged += ValueChanged;
}
public void Register() {
General.Interface.AddButton(subdivslabel); General.Interface.AddButton(subdivslabel);
General.Interface.AddButton(subdivs); General.Interface.AddButton(subdivs);
General.Interface.AddButton(spikinesslabel); General.Interface.AddButton(spikinesslabel);

View file

@ -122,7 +122,7 @@
this.reset.ImageTransparentColor = System.Drawing.Color.Magenta; this.reset.ImageTransparentColor = System.Drawing.Color.Magenta;
this.reset.Name = "reset"; this.reset.Name = "reset";
this.reset.Size = new System.Drawing.Size(23, 22); this.reset.Size = new System.Drawing.Size(23, 22);
this.reset.Text = "toolStripButton1"; this.reset.Text = "Reset";
// //
// cbseparator // cbseparator
// //

View file

@ -116,7 +116,7 @@
this.reset.ImageTransparentColor = System.Drawing.Color.Magenta; this.reset.ImageTransparentColor = System.Drawing.Color.Magenta;
this.reset.Name = "reset"; this.reset.Name = "reset";
this.reset.Size = new System.Drawing.Size(23, 22); this.reset.Size = new System.Drawing.Size(23, 22);
this.reset.Text = "toolStripButton1"; this.reset.Text = "Reset";
this.reset.Click += new System.EventHandler(this.reset_Click); this.reset.Click += new System.EventHandler(this.reset_Click);
// //
// DrawRectangleOptionsPanel // DrawRectangleOptionsPanel

View file

@ -20,14 +20,14 @@ namespace CodeImp.DoomBuilder.BuilderModes
public DrawRectangleOptionsPanel() { public DrawRectangleOptionsPanel() {
InitializeComponent(); InitializeComponent();
}
public void Register() {
radius.Value = radiusValue; radius.Value = radiusValue;
subdivs.Value = subdivsValue; subdivs.Value = subdivsValue;
radius.ValueChanged += ValueChanged; radius.ValueChanged += ValueChanged;
subdivs.ValueChanged += ValueChanged; subdivs.ValueChanged += ValueChanged;
}
public void Register() {
General.Interface.AddButton(radiuslabel); General.Interface.AddButton(radiuslabel);
General.Interface.AddButton(radius); General.Interface.AddButton(radius);
General.Interface.AddButton(subdivslabel); General.Interface.AddButton(subdivslabel);