Linedef Edit Form, UDMF: "Lock number" now has a drop-down with supported key types (no LOCKDEFS support (yet?)). You can still type lock number manually.

This commit is contained in:
MaxED 2014-11-15 20:25:16 +00:00
parent 66f75ec7c4
commit 18e52226fd
2 changed files with 62 additions and 24 deletions

View file

@ -67,8 +67,8 @@ namespace CodeImp.DoomBuilder.Windows
this.tabs = new System.Windows.Forms.TabControl();
this.tabproperties = new System.Windows.Forms.TabPage();
this.settingsGroup = new System.Windows.Forms.GroupBox();
this.lockpick = new System.Windows.Forms.ComboBox();
this.alpha = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.lockNumber = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox();
this.renderStyle = new System.Windows.Forms.ComboBox();
this.activationGroup = new System.Windows.Forms.GroupBox();
this.missingactivation = new System.Windows.Forms.PictureBox();
@ -251,9 +251,9 @@ namespace CodeImp.DoomBuilder.Windows
label14.AutoSize = true;
label14.Location = new System.Drawing.Point(330, 24);
label14.Name = "label14";
label14.Size = new System.Drawing.Size(73, 14);
label14.Size = new System.Drawing.Size(72, 14);
label14.TabIndex = 15;
label14.Text = "Lock Number:";
label14.Text = "Lock number:";
//
// label6
//
@ -556,9 +556,9 @@ namespace CodeImp.DoomBuilder.Windows
//
this.settingsGroup.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.settingsGroup.Controls.Add(this.lockpick);
this.settingsGroup.Controls.Add(this.alpha);
this.settingsGroup.Controls.Add(label6);
this.settingsGroup.Controls.Add(this.lockNumber);
this.settingsGroup.Controls.Add(label14);
this.settingsGroup.Controls.Add(this.renderStyle);
this.settingsGroup.Controls.Add(label7);
@ -569,6 +569,14 @@ namespace CodeImp.DoomBuilder.Windows
this.settingsGroup.TabStop = false;
this.settingsGroup.Text = " Settings";
//
// lockpick
//
this.lockpick.FormattingEnabled = true;
this.lockpick.Location = new System.Drawing.Point(408, 20);
this.lockpick.Name = "lockpick";
this.lockpick.Size = new System.Drawing.Size(115, 22);
this.lockpick.TabIndex = 19;
//
// alpha
//
this.alpha.AllowDecimal = true;
@ -584,20 +592,6 @@ namespace CodeImp.DoomBuilder.Windows
this.alpha.TabIndex = 18;
this.alpha.WhenTextChanged += new System.EventHandler(this.alpha_WhenTextChanged);
//
// lockNumber
//
this.lockNumber.AllowDecimal = false;
this.lockNumber.AllowNegative = false;
this.lockNumber.AllowRelative = false;
this.lockNumber.ButtonStep = 1;
this.lockNumber.ButtonStepFloat = 1F;
this.lockNumber.ButtonStepsWrapAround = false;
this.lockNumber.Location = new System.Drawing.Point(405, 19);
this.lockNumber.Name = "lockNumber";
this.lockNumber.Size = new System.Drawing.Size(65, 24);
this.lockNumber.StepValues = null;
this.lockNumber.TabIndex = 16;
//
// renderStyle
//
this.renderStyle.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
@ -1441,7 +1435,6 @@ namespace CodeImp.DoomBuilder.Windows
private System.Windows.Forms.TabPage tabBackFlags;
private System.Windows.Forms.GroupBox settingsGroup;
private System.Windows.Forms.ComboBox renderStyle;
private CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox lockNumber;
private System.Windows.Forms.Label labelLightFront;
private System.Windows.Forms.CheckBox cbLightAbsoluteBack;
private System.Windows.Forms.Label labelLightBack;
@ -1455,5 +1448,6 @@ namespace CodeImp.DoomBuilder.Windows
private System.Windows.Forms.GroupBox activationGroup;
private System.Windows.Forms.PictureBox missingactivation;
private System.Windows.Forms.ToolTip tooltip;
private System.Windows.Forms.ComboBox lockpick;
}
}

View file

@ -53,6 +53,7 @@ namespace CodeImp.DoomBuilder.Windows
private string arg0str; //mxd
private bool haveArg0Str; //mxd
private readonly string[] renderstyles; //mxd
private readonly List<int> keynumbers; //mxd
//mxd. Persistent settings
private static bool linkFrontTopScale;
@ -192,6 +193,17 @@ namespace CodeImp.DoomBuilder.Windows
// Fill activations list
foreach(LinedefActivateInfo ai in General.Map.Config.LinedefActivates) udmfactivates.Add(ai.Title, ai);
//mxd. Fill keys list
keynumbers = new List<int>();
if (General.Map.Config.Enums.ContainsKey("keys"))
{
foreach(EnumItem item in General.Map.Config.Enums["keys"])
{
keynumbers.Add(item.GetIntValue());
lockpick.Items.Add(item);
}
}
// Initialize image selectors
fronthigh.Initialize();
@ -314,9 +326,13 @@ namespace CodeImp.DoomBuilder.Windows
fieldslist.SetValues(fl.Fields, true); // Custom fields
renderStyle.SelectedIndex = Array.IndexOf(renderstyles, fl.Fields.GetValue("renderstyle", "translucent"));
alpha.Text = General.Clamp(fl.Fields.GetValue("alpha", 1.0f), 0f, 1f).ToString();
lockNumber.Text = fl.Fields.GetValue("locknumber", 0).ToString();
arg0str = fl.Fields.GetValue("arg0str", string.Empty);
haveArg0Str = !string.IsNullOrEmpty(arg0str);
// Locknumber
int locknumber = fl.Fields.GetValue("locknumber", 0);
lockpick.SelectedIndex = keynumbers.IndexOf(locknumber);
if (lockpick.SelectedIndex == -1) lockpick.Text = locknumber.ToString();
}
// Action/tags
@ -439,8 +455,23 @@ namespace CodeImp.DoomBuilder.Windows
if(!string.IsNullOrEmpty(alpha.Text) && General.Clamp(alpha.GetResultFloat(1.0f), 0f, 1f) != l.Fields.GetValue("alpha", 1.0f))
alpha.Text = string.Empty;
if(!string.IsNullOrEmpty(lockNumber.Text) && lockNumber.GetResult(0) != l.Fields.GetValue("locknumber", 0))
lockNumber.Text = string.Empty;
if (!string.IsNullOrEmpty(lockpick.Text))
{
if (lockpick.SelectedIndex == -1)
{
int locknumber;
if (int.TryParse(lockpick.Text, out locknumber) && locknumber != l.Fields.GetValue("locknumber", 0))
{
lockpick.SelectedIndex = -1;
lockpick.Text = string.Empty;
}
}
else if(keynumbers[lockpick.SelectedIndex] != l.Fields.GetValue("locknumber", 0))
{
lockpick.SelectedIndex = -1;
lockpick.Text = string.Empty;
}
}
if(arg0str != l.Fields.GetValue("arg0str", string.Empty))
{
@ -726,7 +757,20 @@ namespace CodeImp.DoomBuilder.Windows
//mxd
bool hasAcs = !action.Empty && Array.IndexOf(GZBuilder.GZGeneral.ACS_SPECIALS, action.Value) != -1;
int lockNum = lockNumber.GetResult(0);
int locknumber = 0;
bool setlocknumber = false;
if(!string.IsNullOrEmpty(lockpick.Text))
{
if(lockpick.SelectedIndex == -1)
{
setlocknumber = int.TryParse(lockpick.Text, out locknumber);
}
else
{
locknumber = keynumbers[lockpick.SelectedIndex];
setlocknumber = true;
}
}
// Go for all the lines
int tagoffset = 0; //mxd
@ -842,7 +886,7 @@ namespace CodeImp.DoomBuilder.Windows
if(General.Map.FormatInterface.HasCustomFields)
{
fieldslist.Apply(l.Fields);
UDMFTools.SetInteger(l.Fields, "locknumber", lockNum, 0);
if(setlocknumber) UDMFTools.SetInteger(l.Fields, "locknumber", locknumber, 0);
}
}