Stair Sector Builder Mode: current settings can be now be saved as a default prefab that will always be loaded when using the Stair Sector Builder Mode

This commit is contained in:
biwa 2021-08-24 22:21:14 +02:00 committed by spherallic
parent d66169f2cb
commit 4c40441e01
2 changed files with 66 additions and 20 deletions

View file

@ -278,8 +278,18 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
}
}
// Show window
base.Show(owner);
// Check if there's a "[Default]" prefab and load it if so
foreach (BuilderPlug.Prefab p in BuilderPlug.Me.Prefabs)
{
if(p.name == "[Default]")
{
LoadPrefab(p);
break;
}
}
// Show window
base.Show(owner);
}
private void ComputeHeights()
@ -318,7 +328,21 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
private void btnOK_Click(object sender, EventArgs e)
{
SavePrefab("[Previous]", true, 0);
int position = 0;
// We always want to have the "[Default]" prefab on top, so look for it and add "[Previous]" after that
for (int i = 0; i < BuilderPlug.Me.Prefabs.Count; i++)
{
BuilderPlug.Prefab p = BuilderPlug.Me.Prefabs[i];
if (p.name == "[Default]")
{
position = i+1;
break;
}
}
SavePrefab("[Previous]", true, position);
General.Editing.AcceptMode();
}
@ -638,10 +662,18 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
if(name == "[Previous]")
MessageBox.Show(Owner, "The prefab name \"[Previous]\" is reserved and can not be overwritten.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else if (name == "[Default]")
MessageBox.Show(Owner, "The prefab name \"[Default]\" is reserved and can not be overwritten manually.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
else
SavePrefab(prefabname.Text.Trim(), false, -1);
}
private void prefabdefault_Click(object sender, EventArgs e)
{
SavePrefab("[Default]", true, 0);
}
private void SavePrefab(string name, bool forceoverwrite, int position)
{
int overwrite = -1;
@ -749,15 +781,16 @@ namespace CodeImp.DoomBuilder.StairSectorBuilderMode
}
}
private void prefabload_Click(object sender, EventArgs e)
{
if(prefabs.SelectedIndices.Count == 0) return;
private void LoadPrefab(int position)
{
LoadPrefab(BuilderPlug.Me.Prefabs[position]);
}
private void LoadPrefab(BuilderPlug.Prefab p)
{
loadingprefab = true;
BuilderPlug.Prefab p = BuilderPlug.Me.Prefabs[prefabs.SelectedIndices[0]];
prefabname.Text = p.name;
prefabname.Text = p.name;
NumberOfSectors = (uint)p.numberofsectors;
OuterVertexMultiplier = p.outervertexmultiplier;

View file

@ -39,6 +39,7 @@
this.spacing = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.label11 = new System.Windows.Forms.Label();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.distinctsectors = new System.Windows.Forms.CheckBox();
this.singledirection = new System.Windows.Forms.CheckBox();
this.singlesteps = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
@ -107,7 +108,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.prefabdefault = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.tabcontrol.SuspendLayout();
this.tabPage1.SuspendLayout();
@ -258,6 +259,18 @@
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Appearance";
//
// 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);
//
// singledirection
//
this.singledirection.AutoSize = true;
@ -938,6 +951,7 @@
//
// groupBox11
//
this.groupBox11.Controls.Add(this.prefabdefault);
this.groupBox11.Controls.Add(this.prefabload);
this.groupBox11.Controls.Add(this.prefabdelete);
this.groupBox11.Controls.Add(this.prefabsave);
@ -1043,17 +1057,15 @@
this.middletexture.UseVisualStyleBackColor = true;
this.middletexture.CheckedChanged += new System.EventHandler(this.middletexture_CheckedChanged);
//
// distinctsectors
// prefabdefault
//
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);
this.prefabdefault.Location = new System.Drawing.Point(247, 156);
this.prefabdefault.Name = "prefabdefault";
this.prefabdefault.Size = new System.Drawing.Size(70, 23);
this.prefabdefault.TabIndex = 29;
this.prefabdefault.Text = "Set default";
this.prefabdefault.UseVisualStyleBackColor = true;
this.prefabdefault.Click += new System.EventHandler(this.prefabdefault_Click);
//
// StairSectorBuilderForm
//
@ -1202,5 +1214,6 @@
private CodeImp.DoomBuilder.Controls.TextureSelectorControl middletexturetexture;
private System.Windows.Forms.CheckBox middletexture;
private System.Windows.Forms.CheckBox distinctsectors;
private System.Windows.Forms.Button prefabdefault;
}
}