- controls configuration now shows only available controls and explains why certain controls can't be used

- fixed some dialogs that could be overlapped when binding the same key to two actions that show a dialog
This commit is contained in:
codeimp 2009-01-06 09:51:14 +00:00
parent c907d9c3f2
commit 14aef55b7c
10 changed files with 192 additions and 112 deletions

View file

@ -362,14 +362,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Linedef> selected = General.Map.Map.GetSelectedLinedefs(true); ICollection<Linedef> selected = General.Map.Map.GetSelectedLinedefs(true);
if(selected.Count > 0) if(selected.Count > 0)
{ {
// Show line edit dialog if(General.Interface.HasFocus)
General.Interface.ShowEditLinedefs(selected); {
// Show line edit dialog
General.Interface.ShowEditLinedefs(selected);
// When a single line was selected, deselect it now // When a single line was selected, deselect it now
if(selected.Count == 1) General.Map.Map.ClearSelectedLinedefs(); if(selected.Count == 1) General.Map.Map.ClearSelectedLinedefs();
// Update entire display // Update entire display
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
}
} }
} }

View file

@ -448,19 +448,22 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true); ICollection<Sector> selected = General.Map.Map.GetSelectedSectors(true);
if(selected.Count > 0) if(selected.Count > 0)
{ {
// Show sector edit dialog if(General.Interface.HasFocus)
General.Interface.ShowEditSectors(selected);
// When a single sector was selected, deselect it now
if(selected.Count == 1)
{ {
orderedselection.Clear(); // Show sector edit dialog
General.Map.Map.ClearSelectedSectors(); General.Interface.ShowEditSectors(selected);
General.Map.Map.ClearSelectedLinedefs();
}
// Update entire display // When a single sector was selected, deselect it now
General.Interface.RedrawDisplay(); if(selected.Count == 1)
{
orderedselection.Clear();
General.Map.Map.ClearSelectedSectors();
General.Map.Map.ClearSelectedLinedefs();
}
// Update entire display
General.Interface.RedrawDisplay();
}
} }
} }

View file

@ -355,17 +355,20 @@ namespace CodeImp.DoomBuilder.BuilderModes
ICollection<Thing> selected = General.Map.Map.GetSelectedThings(true); ICollection<Thing> selected = General.Map.Map.GetSelectedThings(true);
if(selected.Count > 0) if(selected.Count > 0)
{ {
// Show thing edit dialog if(General.Interface.HasFocus)
General.Interface.ShowEditThings(selected); {
// Show thing edit dialog
General.Interface.ShowEditThings(selected);
// When a single thing was selected, deselect it now // When a single thing was selected, deselect it now
if(selected.Count == 1) General.Map.Map.ClearSelectedThings(); if(selected.Count == 1) General.Map.Map.ClearSelectedThings();
// Update things filter // Update things filter
General.Map.ThingsFilter.Update(); General.Map.ThingsFilter.Update();
// Update entire display // Update entire display
General.Interface.RedrawDisplay(); General.Interface.RedrawDisplay();
}
} }
} }

View file

@ -88,12 +88,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Select texture // Select texture
public virtual void OnSelectTexture() public virtual void OnSelectTexture()
{ {
string oldtexture = GetTextureName(); if(General.Interface.HasFocus)
string newtexture = General.Interface.BrowseFlat(General.Interface, oldtexture);
if(newtexture != oldtexture)
{ {
General.Map.UndoRedo.CreateUndo("Change flat " + newtexture); string oldtexture = GetTextureName();
SetTexture(newtexture); string newtexture = General.Interface.BrowseFlat(General.Interface, oldtexture);
if(newtexture != oldtexture)
{
General.Map.UndoRedo.CreateUndo("Change flat " + newtexture);
SetTexture(newtexture);
}
} }
} }
@ -115,10 +118,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Not using any modifier buttons // Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState) if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
{ {
List<Sector> sectors = new List<Sector>(); if(General.Interface.HasFocus)
sectors.Add(this.Sector.Sector); {
DialogResult result = General.Interface.ShowEditSectors(sectors); List<Sector> sectors = new List<Sector>();
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild(); sectors.Add(this.Sector.Sector);
DialogResult result = General.Interface.ShowEditSectors(sectors);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
}
} }
} }

View file

@ -212,12 +212,15 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Select texture // Select texture
public virtual void OnSelectTexture() public virtual void OnSelectTexture()
{ {
string oldtexture = GetTextureName(); if(General.Interface.HasFocus)
string newtexture = General.Interface.BrowseTexture(General.Interface, oldtexture);
if(newtexture != oldtexture)
{ {
General.Map.UndoRedo.CreateUndo("Change texture " + newtexture); string oldtexture = GetTextureName();
SetTexture(newtexture); string newtexture = General.Interface.BrowseTexture(General.Interface, oldtexture);
if(newtexture != oldtexture)
{
General.Map.UndoRedo.CreateUndo("Change texture " + newtexture);
SetTexture(newtexture);
}
} }
} }
@ -273,10 +276,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Not using any modifier buttons // Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState) if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
{ {
List<Linedef> lines = new List<Linedef>(); if(General.Interface.HasFocus)
lines.Add(this.Sidedef.Line); {
DialogResult result = General.Interface.ShowEditLinedefs(lines); List<Linedef> lines = new List<Linedef>();
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild(); lines.Add(this.Sidedef.Line);
DialogResult result = General.Interface.ShowEditLinedefs(lines);
if(result == DialogResult.OK) (this.Sector as BaseVisualSector).Rebuild();
}
} }
} }

View file

@ -358,10 +358,13 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Not using any modifier buttons // Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState) if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
{ {
List<Thing> things = new List<Thing>(); if(General.Interface.HasFocus)
things.Add(this.Thing); {
DialogResult result = General.Interface.ShowEditThings(things); List<Thing> things = new List<Thing>();
if(result == DialogResult.OK) this.Rebuild(); things.Add(this.Thing);
DialogResult result = General.Interface.ShowEditThings(things);
if(result == DialogResult.OK) this.Rebuild();
}
} }
} }

View file

@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.Windows
bool SnapToGrid { get; } bool SnapToGrid { get; }
bool MouseExclusive { get; } bool MouseExclusive { get; }
MouseButtons MouseButtons { get; } MouseButtons MouseButtons { get; }
bool HasFocus { get; }
// Methods // Methods
void DisplayReady(); void DisplayReady();

View file

@ -147,6 +147,7 @@ namespace CodeImp.DoomBuilder.Windows
public bool MouseExclusive { get { return mouseexclusive; } } public bool MouseExclusive { get { return mouseexclusive; } }
new public IntPtr Handle { get { return windowptr; } } new public IntPtr Handle { get { return windowptr; } }
public bool IsInfoPanelExpanded { get { return (panelinfo.Height == EXPANDED_INFO_HEIGHT); } } public bool IsInfoPanelExpanded { get { return (panelinfo.Height == EXPANDED_INFO_HEIGHT); } }
public bool HasFocus { get { return this.Focused; } }
#endregion #endregion

View file

@ -88,6 +88,8 @@ namespace CodeImp.DoomBuilder.Windows
this.actionkey = new System.Windows.Forms.TextBox(); this.actionkey = new System.Windows.Forms.TextBox();
this.actiondescription = new System.Windows.Forms.Label(); this.actiondescription = new System.Windows.Forms.Label();
this.tabcolors = new System.Windows.Forms.TabPage(); this.tabcolors = new System.Windows.Forms.TabPage();
this.imagebrightness = new Dotnetrix.Controls.TrackBar();
this.doublesidedalpha = new Dotnetrix.Controls.TrackBar();
this.imagebrightnesslabel = new System.Windows.Forms.Label(); this.imagebrightnesslabel = new System.Windows.Forms.Label();
this.doublesidedalphalabel = new System.Windows.Forms.Label(); this.doublesidedalphalabel = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label(); this.label2 = new System.Windows.Forms.Label();
@ -100,8 +102,7 @@ namespace CodeImp.DoomBuilder.Windows
this.colorlinenumbers = new CodeImp.DoomBuilder.Controls.ColorControl(); this.colorlinenumbers = new CodeImp.DoomBuilder.Controls.ColorControl();
this.colorcomments = new CodeImp.DoomBuilder.Controls.ColorControl(); this.colorcomments = new CodeImp.DoomBuilder.Controls.ColorControl();
this.colorplaintext = new CodeImp.DoomBuilder.Controls.ColorControl(); this.colorplaintext = new CodeImp.DoomBuilder.Controls.ColorControl();
this.doublesidedalpha = new Dotnetrix.Controls.TrackBar(); this.disregardshiftlabel = new System.Windows.Forms.Label();
this.imagebrightness = new Dotnetrix.Controls.TrackBar();
label7 = new System.Windows.Forms.Label(); label7 = new System.Windows.Forms.Label();
label6 = new System.Windows.Forms.Label(); label6 = new System.Windows.Forms.Label();
label5 = new System.Windows.Forms.Label(); label5 = new System.Windows.Forms.Label();
@ -121,9 +122,9 @@ namespace CodeImp.DoomBuilder.Windows
this.tabkeys.SuspendLayout(); this.tabkeys.SuspendLayout();
this.actioncontrolpanel.SuspendLayout(); this.actioncontrolpanel.SuspendLayout();
this.tabcolors.SuspendLayout(); this.tabcolors.SuspendLayout();
this.colorsgroup3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.doublesidedalpha)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.imagebrightness)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imagebrightness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.doublesidedalpha)).BeginInit();
this.colorsgroup3.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// label7 // label7
@ -555,7 +556,7 @@ namespace CodeImp.DoomBuilder.Windows
this.viewdistance.Maximum = 15; this.viewdistance.Maximum = 15;
this.viewdistance.Minimum = 1; this.viewdistance.Minimum = 1;
this.viewdistance.Name = "viewdistance"; this.viewdistance.Name = "viewdistance";
this.viewdistance.Size = new System.Drawing.Size(150, 45); this.viewdistance.Size = new System.Drawing.Size(150, 42);
this.viewdistance.TabIndex = 34; this.viewdistance.TabIndex = 34;
this.viewdistance.TickStyle = System.Windows.Forms.TickStyle.Both; this.viewdistance.TickStyle = System.Windows.Forms.TickStyle.Both;
this.viewdistance.Value = 1; this.viewdistance.Value = 1;
@ -567,7 +568,7 @@ namespace CodeImp.DoomBuilder.Windows
this.movespeed.Maximum = 20; this.movespeed.Maximum = 20;
this.movespeed.Minimum = 1; this.movespeed.Minimum = 1;
this.movespeed.Name = "movespeed"; this.movespeed.Name = "movespeed";
this.movespeed.Size = new System.Drawing.Size(150, 45); this.movespeed.Size = new System.Drawing.Size(150, 42);
this.movespeed.TabIndex = 33; this.movespeed.TabIndex = 33;
this.movespeed.TickStyle = System.Windows.Forms.TickStyle.Both; this.movespeed.TickStyle = System.Windows.Forms.TickStyle.Both;
this.movespeed.Value = 1; this.movespeed.Value = 1;
@ -579,7 +580,7 @@ namespace CodeImp.DoomBuilder.Windows
this.mousespeed.Maximum = 20; this.mousespeed.Maximum = 20;
this.mousespeed.Minimum = 1; this.mousespeed.Minimum = 1;
this.mousespeed.Name = "mousespeed"; this.mousespeed.Name = "mousespeed";
this.mousespeed.Size = new System.Drawing.Size(150, 45); this.mousespeed.Size = new System.Drawing.Size(150, 42);
this.mousespeed.TabIndex = 32; this.mousespeed.TabIndex = 32;
this.mousespeed.TickStyle = System.Windows.Forms.TickStyle.Both; this.mousespeed.TickStyle = System.Windows.Forms.TickStyle.Both;
this.mousespeed.Value = 1; this.mousespeed.Value = 1;
@ -592,7 +593,7 @@ namespace CodeImp.DoomBuilder.Windows
this.fieldofview.Maximum = 17; this.fieldofview.Maximum = 17;
this.fieldofview.Minimum = 5; this.fieldofview.Minimum = 5;
this.fieldofview.Name = "fieldofview"; this.fieldofview.Name = "fieldofview";
this.fieldofview.Size = new System.Drawing.Size(150, 45); this.fieldofview.Size = new System.Drawing.Size(150, 42);
this.fieldofview.TabIndex = 31; this.fieldofview.TabIndex = 31;
this.fieldofview.TickStyle = System.Windows.Forms.TickStyle.Both; this.fieldofview.TickStyle = System.Windows.Forms.TickStyle.Both;
this.fieldofview.Value = 5; this.fieldofview.Value = 5;
@ -752,6 +753,7 @@ namespace CodeImp.DoomBuilder.Windows
// //
this.actioncontrolpanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.actioncontrolpanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Right))); | System.Windows.Forms.AnchorStyles.Right)));
this.actioncontrolpanel.Controls.Add(this.disregardshiftlabel);
this.actioncontrolpanel.Controls.Add(this.actioncontrol); this.actioncontrolpanel.Controls.Add(this.actioncontrol);
this.actioncontrolpanel.Controls.Add(label7); this.actioncontrolpanel.Controls.Add(label7);
this.actioncontrolpanel.Controls.Add(this.actiontitle); this.actioncontrolpanel.Controls.Add(this.actiontitle);
@ -842,6 +844,26 @@ namespace CodeImp.DoomBuilder.Windows
this.tabcolors.Text = "Colors"; this.tabcolors.Text = "Colors";
this.tabcolors.UseVisualStyleBackColor = true; this.tabcolors.UseVisualStyleBackColor = true;
// //
// imagebrightness
//
this.imagebrightness.LargeChange = 3;
this.imagebrightness.Location = new System.Drawing.Point(379, 235);
this.imagebrightness.Name = "imagebrightness";
this.imagebrightness.Size = new System.Drawing.Size(154, 42);
this.imagebrightness.TabIndex = 33;
this.imagebrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
this.imagebrightness.ValueChanged += new System.EventHandler(this.imagebrightness_ValueChanged);
//
// doublesidedalpha
//
this.doublesidedalpha.LargeChange = 3;
this.doublesidedalpha.Location = new System.Drawing.Point(379, 180);
this.doublesidedalpha.Name = "doublesidedalpha";
this.doublesidedalpha.Size = new System.Drawing.Size(154, 42);
this.doublesidedalpha.TabIndex = 32;
this.doublesidedalpha.TickStyle = System.Windows.Forms.TickStyle.Both;
this.doublesidedalpha.ValueChanged += new System.EventHandler(this.doublesidedalpha_ValueChanged);
//
// imagebrightnesslabel // imagebrightnesslabel
// //
this.imagebrightnesslabel.AutoSize = true; this.imagebrightnesslabel.AutoSize = true;
@ -980,25 +1002,16 @@ namespace CodeImp.DoomBuilder.Windows
this.colorplaintext.Size = new System.Drawing.Size(150, 23); this.colorplaintext.Size = new System.Drawing.Size(150, 23);
this.colorplaintext.TabIndex = 12; this.colorplaintext.TabIndex = 12;
// //
// doublesidedalpha // disregardshiftlabel
// //
this.doublesidedalpha.LargeChange = 3; this.disregardshiftlabel.Location = new System.Drawing.Point(20, 263);
this.doublesidedalpha.Location = new System.Drawing.Point(379, 180); this.disregardshiftlabel.Name = "disregardshiftlabel";
this.doublesidedalpha.Name = "doublesidedalpha"; this.disregardshiftlabel.Size = new System.Drawing.Size(229, 73);
this.doublesidedalpha.Size = new System.Drawing.Size(154, 45); this.disregardshiftlabel.TabIndex = 9;
this.doublesidedalpha.TabIndex = 32; this.disregardshiftlabel.Text = "The selected actions uses modifier keys (Shift, Alt and Control) to modify it\'s b" +
this.doublesidedalpha.TickStyle = System.Windows.Forms.TickStyle.Both; "ehavior. Therefor, no combination with these modifiers can be used for this acti" +
this.doublesidedalpha.ValueChanged += new System.EventHandler(this.doublesidedalpha_ValueChanged); "on.";
// this.disregardshiftlabel.Visible = false;
// imagebrightness
//
this.imagebrightness.LargeChange = 3;
this.imagebrightness.Location = new System.Drawing.Point(379, 235);
this.imagebrightness.Name = "imagebrightness";
this.imagebrightness.Size = new System.Drawing.Size(154, 45);
this.imagebrightness.TabIndex = 33;
this.imagebrightness.TickStyle = System.Windows.Forms.TickStyle.Both;
this.imagebrightness.ValueChanged += new System.EventHandler(this.imagebrightness_ValueChanged);
// //
// PreferencesForm // PreferencesForm
// //
@ -1039,9 +1052,9 @@ namespace CodeImp.DoomBuilder.Windows
this.actioncontrolpanel.PerformLayout(); this.actioncontrolpanel.PerformLayout();
this.tabcolors.ResumeLayout(false); this.tabcolors.ResumeLayout(false);
this.tabcolors.PerformLayout(); this.tabcolors.PerformLayout();
this.colorsgroup3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.doublesidedalpha)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.imagebrightness)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.imagebrightness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.doublesidedalpha)).EndInit();
this.colorsgroup3.ResumeLayout(false);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@ -1117,5 +1130,6 @@ namespace CodeImp.DoomBuilder.Windows
private Dotnetrix.Controls.TrackBar viewdistance; private Dotnetrix.Controls.TrackBar viewdistance;
private Dotnetrix.Controls.TrackBar doublesidedalpha; private Dotnetrix.Controls.TrackBar doublesidedalpha;
private Dotnetrix.Controls.TrackBar imagebrightness; private Dotnetrix.Controls.TrackBar imagebrightness;
private System.Windows.Forms.Label disregardshiftlabel;
} }
} }

View file

@ -37,6 +37,7 @@ namespace CodeImp.DoomBuilder.Windows
#region ================== Variables #region ================== Variables
private bool allowapplycontrol = false; private bool allowapplycontrol = false;
private bool disregardshift = false;
#endregion #endregion
@ -105,36 +106,6 @@ namespace CodeImp.DoomBuilder.Windows
item.Group = listactions.Groups[a.Category]; item.Group = listactions.Groups[a.Category];
} }
// Fill combobox with special controls
actioncontrol.Items.Add(new KeyControl(Keys.LButton, "LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton, "MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton, "RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1, "XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2, "XButton2"));
actioncontrol.Items.Add(new KeyControl(SpecialKeys.MScrollUp, "ScrollUp"));
actioncontrol.Items.Add(new KeyControl(SpecialKeys.MScrollDown, "ScrollDown"));
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Shift, "Shift+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Shift, "Shift+MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Shift, "Shift+RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Shift, "Shift+XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Shift, "Shift+XButton2"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Shift, "Shift+ScrollUp"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Shift, "Shift+ScrollDown"));
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Control, "Ctrl+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Control, "Ctrl+MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Control, "Ctrl+RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Control, "Ctrl+XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Control, "Ctrl+XButton2"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Control, "Ctrl+ScrollUp"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Control, "Ctrl+ScrollDown"));
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Shift | Keys.Control, "Ctrl+Shift+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Shift | Keys.Control, "Ctrl+Shift+MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Shift | Keys.Control, "Ctrl+Shift+RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Shift | Keys.Control, "Ctrl+Shift+XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Shift | Keys.Control, "Ctrl+Shift+XButton2"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Shift | (int)Keys.Control, "Ctrl+Shift+ScrollUp"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Shift | (int)Keys.Control, "Ctrl+Shift+ScrollDown"));
// Set the colors // Set the colors
// TODO: Make this automated by using the collection // TODO: Make this automated by using the collection
colorbackcolor.Color = General.Colors.Background; colorbackcolor.Color = General.Colors.Background;
@ -335,7 +306,67 @@ namespace CodeImp.DoomBuilder.Windows
#endregion #endregion
#region ================== Controls Panel #region ================== Controls Panel
// This fills the list of available controls for the specified action
private void FillControlsList(Action a)
{
actioncontrol.Items.Clear();
// Fill combobox with special controls
if(a.AllowMouse)
{
actioncontrol.Items.Add(new KeyControl(Keys.LButton, "LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton, "MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton, "RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1, "XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2, "XButton2"));
}
if(a.AllowScroll)
{
actioncontrol.Items.Add(new KeyControl(SpecialKeys.MScrollUp, "ScrollUp"));
actioncontrol.Items.Add(new KeyControl(SpecialKeys.MScrollDown, "ScrollDown"));
}
if(a.AllowMouse && !a.DisregardShift)
{
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Shift, "Shift+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Shift, "Shift+MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Shift, "Shift+RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Shift, "Shift+XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Shift, "Shift+XButton2"));
}
if(a.AllowScroll && !a.DisregardShift)
{
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Shift, "Shift+ScrollUp"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Shift, "Shift+ScrollDown"));
}
if(a.AllowMouse && !a.DisregardShift)
{
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Control, "Ctrl+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Control, "Ctrl+MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Control, "Ctrl+RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Control, "Ctrl+XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Control, "Ctrl+XButton2"));
}
if(a.AllowScroll && !a.DisregardShift)
{
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Control, "Ctrl+ScrollUp"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Control, "Ctrl+ScrollDown"));
}
if(a.AllowMouse && !a.DisregardShift)
{
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Shift | Keys.Control, "Ctrl+Shift+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Shift | Keys.Control, "Ctrl+Shift+MButton"));
actioncontrol.Items.Add(new KeyControl(Keys.RButton | Keys.Shift | Keys.Control, "Ctrl+Shift+RButton"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton1 | Keys.Shift | Keys.Control, "Ctrl+Shift+XButton1"));
actioncontrol.Items.Add(new KeyControl(Keys.XButton2 | Keys.Shift | Keys.Control, "Ctrl+Shift+XButton2"));
}
if(a.AllowScroll && !a.DisregardShift)
{
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollUp | (int)Keys.Shift | (int)Keys.Control, "Ctrl+Shift+ScrollUp"));
actioncontrol.Items.Add(new KeyControl((int)SpecialKeys.MScrollDown | (int)Keys.Shift | (int)Keys.Control, "Ctrl+Shift+ScrollDown"));
}
}
// Item selected // Item selected
private void listactions_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e) private void listactions_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{ {
@ -352,14 +383,19 @@ namespace CodeImp.DoomBuilder.Windows
// Get the selected action // Get the selected action
action = General.Actions[listactions.SelectedItems[0].Name]; action = General.Actions[listactions.SelectedItems[0].Name];
key = (int)listactions.SelectedItems[0].SubItems[1].Tag; key = (int)listactions.SelectedItems[0].SubItems[1].Tag;
disregardshift = action.DisregardShift;
// Enable panel // Enable panel
actioncontrolpanel.Enabled = true; actioncontrolpanel.Enabled = true;
actiontitle.Text = action.Title; actiontitle.Text = action.Title;
actiondescription.Text = action.Description; actiondescription.Text = action.Description;
actioncontrol.SelectedIndex = -1; actioncontrol.SelectedIndex = -1;
actionkey.Text = ""; actionkey.Text = "";
disregardshiftlabel.Visible = disregardshift;
// Fill special controls list
FillControlsList(action);
// See if the key is in the combobox // See if the key is in the combobox
for(int i = 0; i < actioncontrol.Items.Count; i++) for(int i = 0; i < actioncontrol.Items.Count; i++)
{ {
@ -392,6 +428,7 @@ namespace CodeImp.DoomBuilder.Windows
actiondescription.Text = ""; actiondescription.Text = "";
actionkey.Text = ""; actionkey.Text = "";
actioncontrol.SelectedIndex = -1; actioncontrol.SelectedIndex = -1;
disregardshiftlabel.Visible = false;
} }
} }
@ -418,15 +455,18 @@ namespace CodeImp.DoomBuilder.Windows
{ {
// Begin updating // Begin updating
allowapplycontrol = false; allowapplycontrol = false;
// Remove modifier keys from the key if needed
if(disregardshift) key &= ~(int)Keys.Modifiers;
// Deselect anything from the combobox // Deselect anything from the combobox
actioncontrol.SelectedIndex = -1; actioncontrol.SelectedIndex = -1;
// Apply the key combination // Apply the key combination
listactions.SelectedItems[0].SubItems[1].Text = Action.GetShortcutKeyDesc(key); listactions.SelectedItems[0].SubItems[1].Text = Action.GetShortcutKeyDesc(key);
listactions.SelectedItems[0].SubItems[1].Tag = key; listactions.SelectedItems[0].SubItems[1].Tag = key;
actionkey.Text = Action.GetShortcutKeyDesc(key); actionkey.Text = Action.GetShortcutKeyDesc(key);
// Done // Done
allowapplycontrol = true; allowapplycontrol = true;
} }