Stair sector builder: renamen "Single sectors" option to "Single steps". Added option to keep distinct sectors when using single steps

This commit is contained in:
biwa 2019-12-14 14:32:33 +01:00 committed by sphere
parent 367a3ed6c6
commit 2afc9eb7e4
4 changed files with 142 additions and 41 deletions

View File

@ -50,7 +50,8 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
public int sectordepth;
public int spacing;
public bool frontside;
public bool singlesectors;
public bool singlesteps;
public bool distinctsectors;
public bool singledirection;
public bool distinctbaseheights;

View File

@ -82,10 +82,16 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
set { distinctbaseheights = value; }
}
public CheckBox SingleSectors
public CheckBox SingleSteps
{
get { return singlesectors; }
set { singlesectors = value; }
get { return singlesteps; }
set { singlesteps = value; }
}
public CheckBox DistinctSectors
{
get { return distinctsectors; }
set { distinctsectors = value; }
}
public CheckBox SingleDirection
@ -466,17 +472,23 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
singledirection.Checked = false;
singledirection.Enabled = false;
singlesectors.Checked = true;
singlesectors.Enabled = false;
singlesteps.Checked = true;
singlesteps.Enabled = false;
}
}
private void singlesectors_CheckedChanged(object sender, EventArgs e)
private void singleseteps_CheckedChanged(object sender, EventArgs e)
{
if(singlesectors.Checked)
if (singlesteps.Checked)
{
singledirection.Enabled = true;
distinctsectors.Enabled = true;
}
else
{
singledirection.Enabled = false;
distinctsectors.Enabled = false;
}
DoRedrawDisplay();
}
@ -677,7 +689,8 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
pf.sectordepth = (int)SectorDepth;
pf.spacing = Spacing;
pf.frontside = SideFront;
pf.singlesectors = SingleSectors.Checked;
pf.singlesteps = SingleSteps.Checked;
pf.distinctsectors = distinctsectors.Checked;
pf.singledirection = SingleDirection.Checked;
pf.distinctbaseheights = DistinctBaseHeights.Checked;
@ -752,12 +765,13 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
tabcontrol.SelectedIndex = p.stairtype;
// Straight stairs
SectorDepth = (uint)p.sectordepth;
Spacing = p.spacing;
SideFront = p.frontside;
SingleSectors.Checked = p.singlesectors;
SingleDirection.Checked = p.singledirection;
// Straight stairs
SectorDepth = (uint)p.sectordepth;
Spacing = p.spacing;
SideFront = p.frontside;
SingleSteps.Checked = p.singlesteps;
distinctsectors.Checked = p.distinctsectors;
SingleDirection.Checked = p.singledirection;
DistinctBaseHeights.Checked = p.distinctbaseheights;
// Auto curve TODO
@ -877,5 +891,19 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
{
ceilingbase.Text = originalceilingbase.ToString();
}
private void prefabs_DoubleClick(object sender, EventArgs e)
{
if (prefabs.SelectedIndices.Count == 0) return;
LoadPrefab(prefabs.SelectedIndices[0]);
DoRedrawDisplay();
}
private void distinctsectors_CheckedChanged(object sender, EventArgs e)
{
DoRedrawDisplay();
}
}
}

View File

@ -40,7 +40,7 @@
this.label11 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.singledirection = new System.Windows.Forms.CheckBox();
this.singlesectors = new System.Windows.Forms.CheckBox();
this.singlesteps = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.sideback = new System.Windows.Forms.RadioButton();
this.sidefront = new System.Windows.Forms.RadioButton();
@ -107,6 +107,7 @@
this.groupBox10 = new System.Windows.Forms.GroupBox();
this.middletexturetexture = new CodeImp.DoomBuilder.Controls.TextureSelectorControl();
this.middletexture = new System.Windows.Forms.CheckBox();
this.distinctsectors = new System.Windows.Forms.CheckBox();
this.groupBox1.SuspendLayout();
this.tabcontrol.SuspendLayout();
this.tabPage1.SuspendLayout();
@ -244,11 +245,12 @@
//
// groupBox3
//
this.groupBox3.Controls.Add(this.distinctsectors);
this.groupBox3.Controls.Add(this.singledirection);
this.groupBox3.Controls.Add(this.singlesectors);
this.groupBox3.Controls.Add(this.singlesteps);
this.groupBox3.Location = new System.Drawing.Point(82, 94);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(124, 79);
this.groupBox3.Size = new System.Drawing.Size(124, 93);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Appearance";
@ -257,7 +259,7 @@
//
this.singledirection.AutoSize = true;
this.singledirection.Enabled = false;
this.singledirection.Location = new System.Drawing.Point(7, 46);
this.singledirection.Location = new System.Drawing.Point(10, 64);
this.singledirection.Name = "singledirection";
this.singledirection.Size = new System.Drawing.Size(99, 18);
this.singledirection.TabIndex = 1;
@ -265,17 +267,17 @@
this.singledirection.UseVisualStyleBackColor = true;
this.singledirection.CheckedChanged += new System.EventHandler(this.singledirection_CheckedChanged);
//
// singlesectors
// singlesteps
//
this.singlesectors.AutoSize = true;
this.singlesectors.Enabled = false;
this.singlesectors.Location = new System.Drawing.Point(7, 22);
this.singlesectors.Name = "singlesectors";
this.singlesectors.Size = new System.Drawing.Size(95, 18);
this.singlesectors.TabIndex = 0;
this.singlesectors.Text = "Single sectors";
this.singlesectors.UseVisualStyleBackColor = true;
this.singlesectors.CheckedChanged += new System.EventHandler(this.singlesectors_CheckedChanged);
this.singlesteps.AutoSize = true;
this.singlesteps.Enabled = false;
this.singlesteps.Location = new System.Drawing.Point(10, 22);
this.singlesteps.Name = "singlesteps";
this.singlesteps.Size = new System.Drawing.Size(85, 18);
this.singlesteps.TabIndex = 0;
this.singlesteps.Text = "Single steps";
this.singlesteps.UseVisualStyleBackColor = true;
this.singlesteps.CheckedChanged += new System.EventHandler(this.singleseteps_CheckedChanged);
//
// groupBox2
//
@ -283,7 +285,7 @@
this.groupBox2.Controls.Add(this.sidefront);
this.groupBox2.Location = new System.Drawing.Point(11, 94);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(65, 79);
this.groupBox2.Size = new System.Drawing.Size(65, 93);
this.groupBox2.TabIndex = 2;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Side";
@ -291,7 +293,7 @@
// sideback
//
this.sideback.AutoSize = true;
this.sideback.Location = new System.Drawing.Point(7, 46);
this.sideback.Location = new System.Drawing.Point(7, 54);
this.sideback.Name = "sideback";
this.sideback.Size = new System.Drawing.Size(49, 18);
this.sideback.TabIndex = 1;
@ -304,7 +306,7 @@
//
this.sidefront.AutoSize = true;
this.sidefront.Checked = true;
this.sidefront.Location = new System.Drawing.Point(7, 22);
this.sidefront.Location = new System.Drawing.Point(7, 30);
this.sidefront.Name = "sidefront";
this.sidefront.Size = new System.Drawing.Size(50, 18);
this.sidefront.TabIndex = 0;
@ -1018,6 +1020,18 @@
this.middletexture.UseVisualStyleBackColor = true;
this.middletexture.CheckedChanged += new System.EventHandler(this.middletexture_CheckedChanged);
//
// distinctsectors
//
this.distinctsectors.AutoSize = true;
this.distinctsectors.Enabled = false;
this.distinctsectors.Location = new System.Drawing.Point(10, 43);
this.distinctsectors.Name = "distinctsectors";
this.distinctsectors.Size = new System.Drawing.Size(101, 18);
this.distinctsectors.TabIndex = 2;
this.distinctsectors.Text = "Distinct sectors";
this.distinctsectors.UseVisualStyleBackColor = true;
this.distinctsectors.CheckedChanged += new System.EventHandler(this.distinctsectors_CheckedChanged);
//
// StairSectorBuilderForm
//
this.AcceptButton = this.btnOK;
@ -1100,7 +1114,7 @@
private System.Windows.Forms.RadioButton sidefront;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox singledirection;
private System.Windows.Forms.CheckBox singlesectors;
private System.Windows.Forms.CheckBox singlesteps;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.CheckBox floorflat;
private CodeImp.DoomBuilder.Controls.FlatSelectorControl floorflattexture;
@ -1164,5 +1178,6 @@
private System.Windows.Forms.GroupBox groupBox10;
private CodeImp.DoomBuilder.Controls.TextureSelectorControl middletexturetexture;
private System.Windows.Forms.CheckBox middletexture;
private System.Windows.Forms.CheckBox distinctsectors;
}
}

View File

@ -107,6 +107,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
public int floorheight;
public int ceilingheight;
public List<List<Vector2D>> sectors;
public List<List<Vector2D>> postlines;
}
@ -714,7 +715,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
GetConnectedLines(ref selectedlinedefs, -1);
// Build an independend set of steps from each selected line
if(!stairsectorbuilderform.SingleSectors.Checked)
if(!stairsectorbuilderform.SingleSteps.Checked)
{
// Go through each selected line
for(int k = 0; k < sourceld.Count; k++)
@ -761,7 +762,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
stairinfo.Add(si);
}
}
else if(stairsectorbuilderform.SingleSectors.Checked)
else if(stairsectorbuilderform.SingleSteps.Checked)
{
Vector2D direction = new Vector2D();
bool closed = false;
@ -772,6 +773,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
List<Vector2D> connecteddirections = new List<Vector2D>();
List<double> connectedlength = new List<double>();
List<List<Vector2D>> sisecs = new List<List<Vector2D>>();
List<List<Vector2D>> sipostlines = new List<List<Vector2D>>();
Vector2D globaldirection = Vector2D.FromAngle(cld.firstlinedef.Angle + Angle2D.DegToRad(stairsectorbuilderform.SideFront ? -90.0f : 90.0f));
@ -899,6 +901,20 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
}
newsec.Add(connectedvertices[k] + direction * length * (i + 1) + (direction * spacing) * i);
// Add lines to draw after the stair has been created, if desired
if (stairsectorbuilderform.DistinctSectors.Checked)
{
// Skip last and first vertex if vertices are not in a loop, the line would
// just draw over existing lines anyway
if (closed || (!closed && (k != connectedvertices.Count - 1 && k != 0)))
{
sipostlines.Add(new List<Vector2D>() {
connectedvertices[k] + direction * length * i + (direction * spacing) * i,
connectedvertices[k] + direction * length * (i + 1) + (direction * spacing) * i
});
}
}
}
if(closed == false)
@ -916,6 +932,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
GetSetTextureAndHeightInfo(cld.firstlinedef, out si);
si.sectors = sisecs;
si.postlines = sipostlines;
stairinfo.Add(si);
}
@ -1190,7 +1207,7 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
selectedcontrolpoint.crsd = -1;
selectedcontrolpoint.crsg = -1;
stairsectorbuilderform.SingleSectors.Enabled = linesconnected;
stairsectorbuilderform.SingleSteps.Enabled = linesconnected;
stairsectorbuilderform.DistinctBaseHeights.Checked = (General.Map.Map.SelectedLinedefsCount != 1);
@ -1326,8 +1343,32 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
}
}
if(stairsectorbuilderform.MiddleTexture)
General.Map.Options.DefaultWallTexture = olddefaulttexture;
// Draw post lines
foreach (StairInfo si in stairsectors)
{
if (si.postlines != null)
{
foreach (List<Vector2D> lv in si.postlines)
{
List<Sector> oldsectors = new List<Sector>(General.Map.Map.Sectors);
List<DrawnVertex> vertices = new List<DrawnVertex>();
for (int i = 0; i < lv.Count; i++)
vertices.Add(SectorVertex(lv[i]));
// Draw the new sector
if (!Tools.DrawLines(vertices)) throw new Exception("Failed drawing lines");
// Find new sectors
foreach (Sector s in General.Map.Map.Sectors)
if (!oldsectors.Contains(s))
allnewsectors.Add(s);
}
}
}
if (stairsectorbuilderform.MiddleTexture)
General.Map.Options.DefaultWallTexture = olddefaulttexture;
// Snap to map format accuracy
General.Map.Map.SnapAllToAccuracy();
@ -1447,8 +1488,22 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
renderer.RenderRectangle(rect, 2, new PixelColor(128, 255, 0, 0), true);
}
}
if (si.postlines != null)
{
foreach (List<Vector2D> lv in si.postlines)
{
for (int i = 0; i < lv.Count - 1; i++)
{
renderer.RenderLine(lv[i], lv[i + 1], LINE_THICKNESS, General.Colors.Highlight, true);
//RectangleF rect = new RectangleF(lv[i].x - CONTROLPOINT_SIZE / 2, lv[i].y - CONTROLPOINT_SIZE / 2, 10.0f, 10.0f);
//renderer.RenderRectangle(rect, 2, new PixelColor(128, 255, 0, 0), true);
}
}
}
}
renderer.Finish();
}
@ -1541,7 +1596,8 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
data.Add("sectordepth", p.sectordepth);
data.Add("spacing", p.spacing);
data.Add("frontside", p.frontside);
data.Add("singlesectors", p.singlesectors);
data.Add("singlesectors", p.singlesteps);
data.Add("distinctsectors", p.distinctsectors);
data.Add("singledirection", p.singledirection);
data.Add("distinctbaseheights", p.distinctbaseheights);
data.Add("flipping", p.flipping);
@ -1594,7 +1650,8 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
if((string)entry.Key == "sectordepth") p.sectordepth = (int)entry.Value;
if((string)entry.Key == "spacing") p.spacing = (int)entry.Value;
if((string)entry.Key == "frontside") p.frontside = (bool)entry.Value;
if((string)entry.Key == "singlesectors") p.singlesectors = (bool)entry.Value;
if((string)entry.Key == "singlesectors") p.singlesteps = (bool)entry.Value;
if((string)entry.Key == "distinctsectors") p.distinctsectors = (bool)entry.Value;
if((string)entry.Key == "singledirection") p.singledirection = (bool)entry.Value;
if((string)entry.Key == "distinctbaseheights") p.distinctbaseheights = (bool)entry.Value;
if((string)entry.Key == "flipping") p.flipping = (int)entry.Value;