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
if (bevelWidth < 0) {
int bevelSign = (bevelWidth > 0 ? 1 : -1);
currentBevelWidth = Math.Min(Math.Abs(bevelWidth), Math.Min(width, height) / 2) * bevelSign;
currentBevelWidth = -Math.Min(Math.Abs(bevelWidth), Math.Min(width, height) / 2) + 1;
} else {
currentBevelWidth = bevelWidth;
}
@ -108,7 +107,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
protected override string getHintText() {
return "BVL: "+bevelWidth+"; VERTS: "+subdivisions;
return "BVL: " + bevelWidth + "; VERTS: " + subdivisions;
}
#endregion
@ -154,7 +153,7 @@ namespace CodeImp.DoomBuilder.BuilderModes
}
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);
panel.Spikiness = bevelWidth;
Update();

View file

@ -26,8 +26,9 @@
/// </summary>
private void InitializeComponent() {
this.toolstrip = new System.Windows.Forms.ToolStrip();
this.seglen = new CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown();
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.SuspendLayout();
//
@ -35,22 +36,14 @@
//
this.toolstrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.seglabel,
this.seglen});
this.seglen,
this.reset});
this.toolstrip.Location = new System.Drawing.Point(0, 0);
this.toolstrip.Name = "toolstrip";
this.toolstrip.Size = new System.Drawing.Size(249, 25);
this.toolstrip.TabIndex = 7;
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
//
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.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
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
@ -78,6 +105,7 @@
private System.Windows.Forms.ToolStripLabel seglabel;
internal CodeImp.DoomBuilder.Controls.ToolStripNumericUpDown seglen;
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() {
General.Interface.AddButton(seglabel);
General.Interface.AddButton(seglen);
General.Interface.AddButton(reset);
}
public void Unregister() {
General.Interface.RemoveButton(reset);
General.Interface.RemoveButton(seglen);
General.Interface.RemoveButton(seglabel);
}
@ -32,5 +34,9 @@ namespace CodeImp.DoomBuilder.BuilderModes
private void seglen_ValueChanged(object sender, EventArgs e) {
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});
this.subdivs.ValueChanged += new System.EventHandler(this.ValueChanged);
//
// spikinesslabel
//
@ -107,7 +106,6 @@
0,
0,
0});
this.spikiness.ValueChanged += new System.EventHandler(this.ValueChanged);
//
// reset
//
@ -116,7 +114,7 @@
this.reset.ImageTransparentColor = System.Drawing.Color.Magenta;
this.reset.Name = "reset";
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);
//
// DrawEllipseOptionsPanel

View file

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

View file

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

View file

@ -116,7 +116,7 @@
this.reset.ImageTransparentColor = System.Drawing.Color.Magenta;
this.reset.Name = "reset";
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);
//
// DrawRectangleOptionsPanel

View file

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