@ This should fix a problem with actions in combination with the Control key. Also removed the modifier keys check in the BaseVisual* classes OnEditEnd events, because I don't know why it is there and it prevents the user from assigning a key combination for that action.

This commit is contained in:
codeimp 2010-08-14 18:07:38 +00:00
parent 916f529b56
commit 14415a7767
9 changed files with 79 additions and 95 deletions

View file

@ -49,6 +49,7 @@ namespace CodeImp.DoomBuilder.Actions
private bool allowmouse;
private bool allowscroll;
private bool disregardshift;
private bool disregardcontrol;
private bool repeat;
// Delegate
@ -71,6 +72,7 @@ namespace CodeImp.DoomBuilder.Actions
public bool AllowMouse { get { return allowmouse; } }
public bool AllowScroll { get { return allowscroll; } }
public bool DisregardShift { get { return disregardshift; } }
public bool DisregardControl { get { return disregardcontrol; } }
public bool Repeat { get { return repeat; } }
public bool BeginBound { get { return (begindelegates.Count > 0); } }
public bool EndBound { get { return (enddelegates.Count > 0); } }
@ -92,20 +94,21 @@ namespace CodeImp.DoomBuilder.Actions
this.allowmouse = cfg.ReadSetting(shortname + ".allowmouse", true);
this.allowscroll = cfg.ReadSetting(shortname + ".allowscroll", false);
this.disregardshift = cfg.ReadSetting(shortname + ".disregardshift", false);
this.disregardcontrol = cfg.ReadSetting(shortname + ".disregardcontrol", false);
this.repeat = cfg.ReadSetting(shortname + ".repeat", false);
this.defaultkey = cfg.ReadSetting(shortname + ".default", 0);
this.begindelegates = new List<ActionDelegate>();
this.enddelegates = new List<ActionDelegate>();
if(disregardshift)
{
keymask = (int)Keys.Shift; // | (int)Keys.Control;
keymask = ~keymask;
}
keymask = (int)Keys.Shift;
else
{
keymask = ~0;
}
keymask = 0;
if(disregardcontrol)
keymask |= (int)Keys.Control;
keymask = ~keymask;
if(key == -1)
{

View file

@ -26,7 +26,8 @@ categories
// allowkeys: Allows the user to bind standard keys to this action.
// allowmouse: Allows the user to bind mouse buttons to this action.
// allowscroll: Allows the user to bind the scrollwheel to this action.
// disregardshift: This action will trigger regardless if Shift or Control is used.
// disregardshift: This action will trigger regardless if Shift is used.
// disregardcontrol: This action will be triggered regardless if Control is used.
// repeat: BeginAction will be called for automatic key repetition.
// default: Default key is only used when the action is loaded for the first
// time and the default key is not used by any other action.
@ -170,7 +171,7 @@ classicselect
{
title = "Select";
category = "classic";
description = "Selects the highlighted item. Also allows selection by drawing a rectangle.";
description = "Selects the highlighted item. Also allows selection by dragging a rectangle. Hold shift while dragging a rectangle to toggle additive or normal selection.";
allowkeys = true;
allowmouse = true;
allowscroll = false;
@ -181,11 +182,12 @@ classicedit
{
title = "Edit";
category = "classic";
description = "Edits the properties of the selected items or drags the selected items. Also initiates drawing or inserts new things when no selection is made.";
description = "Edits the properties of the selected items or drags the selected items. Also initiates drawing or inserts new things when no selection is made. Can be used in combination with Control and Shift for the first drawn vertex.";
allowkeys = true;
allowmouse = true;
allowscroll = false;
disregardshift = true;
disregardcontrol = true;
}
scrollwest
@ -379,7 +381,7 @@ moveforward
{
title = "Move Forward";
category = "visual";
description = "Moves the camera forward in 3D Visual Mode.";
description = "Moves the camera forward in 3D Visual Mode. Use in combination with Shift for double the speed.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -390,7 +392,7 @@ movebackward
{
title = "Move Backward";
category = "visual";
description = "Moves the camera backward in 3D Visual Mode.";
description = "Moves the camera backward in 3D Visual Mode. Use in combination with Shift for double the speed.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -401,7 +403,7 @@ moveleft
{
title = "Move Left (strafe)";
category = "visual";
description = "Strafes the camera left in 3D Visual Mode.";
description = "Strafes the camera left in 3D Visual Mode. Use in combination with Shift for double the speed.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -412,7 +414,7 @@ moveright
{
title = "Move Right (strafe)";
category = "visual";
description = "Strafes the camera right in 3D Visual Mode.";
description = "Strafes the camera right in 3D Visual Mode. Use in combination with Shift for double the speed.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -423,7 +425,7 @@ moveup
{
title = "Move Up";
category = "visual";
description = "Moves the camera up in 3D Visual Mode.";
description = "Moves the camera up in 3D Visual Mode. Use in combination with Shift for double the speed.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -434,18 +436,7 @@ movedown
{
title = "Move Down";
category = "visual";
description = "Moves the camera down in 3D Visual Mode.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
disregardshift = true;
}
movedoublespeed
{
title = "Double Speed";
category = "visual";
description = "Double the movement speed for the Move actions in visual mode while holding this button.";
description = "Moves the camera down in 3D Visual Mode. Use in combination with Shift for double the speed.";
allowkeys = true;
allowmouse = true;
allowscroll = true;
@ -770,7 +761,6 @@ visualselect
allowkeys = true;
allowmouse = true;
allowscroll = false;
disregardshift = true;
}
visualedit
@ -781,7 +771,6 @@ visualedit
allowkeys = true;
allowmouse = true;
allowscroll = false;
disregardshift = true;
}
createprefab

View file

@ -69,7 +69,6 @@ namespace CodeImp.DoomBuilder.VisualModes
private bool keyright;
private bool keyup;
private bool keydown;
private bool doublespeed;
// Map
protected VisualBlockMap blockmap;
@ -299,18 +298,6 @@ namespace CodeImp.DoomBuilder.VisualModes
{
keydown = false;
}
[BeginAction("movedoublespeed", BaseAction = true)]
public virtual void BeginDoubleSpeed()
{
doublespeed = true;
}
[EndAction("movedoublespeed", BaseAction = true)]
public virtual void EndDoubleSpeed()
{
doublespeed = false;
}
#endregion
@ -824,7 +811,7 @@ namespace CodeImp.DoomBuilder.VisualModes
Vector3D upvec = new Vector3D(0.0f, 0.0f, 1.0f);
// Move the camera
if(doublespeed) multiplier = MOVE_SPEED_MULTIPLIER * 2.0f; else multiplier = MOVE_SPEED_MULTIPLIER;
if(General.Interface.ShiftState) multiplier = MOVE_SPEED_MULTIPLIER * 2.0f; else multiplier = MOVE_SPEED_MULTIPLIER;
if(keyforward) camdeltapos += camvec * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime);
if(keybackward) camdeltapos -= camvec * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime);
if(keyleft) camdeltapos -= camvecstrafe * cammovemul * (float)((double)General.Settings.MoveSpeed * multiplier * deltatime);

View file

@ -976,6 +976,8 @@ namespace CodeImp.DoomBuilder.Windows
this.disregardshiftlabel.Name = "disregardshiftlabel";
this.disregardshiftlabel.Size = new System.Drawing.Size(245, 47);
this.disregardshiftlabel.TabIndex = 9;
this.disregardshiftlabel.Tag = "The selected actions uses %s to modify its behavior. These modifiers can not be u" +
"sed in a key combination for this action.";
this.disregardshiftlabel.Text = "The selected actions uses Shift, Alt and Control to modify its behavior. These mo" +
"difiers can not be used in a key combination for this action.";
this.disregardshiftlabel.Visible = false;

View file

@ -41,6 +41,7 @@ namespace CodeImp.DoomBuilder.Windows
private PreferencesController controller;
private bool allowapplycontrol = false;
private bool disregardshift = false;
private bool disregardcontrol = false;
private bool reloadresources = false;
@ -466,7 +467,7 @@ namespace CodeImp.DoomBuilder.Windows
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)
if(a.AllowMouse && !a.DisregardControl)
{
actioncontrol.Items.Add(new KeyControl(Keys.LButton | Keys.Control, "Ctrl+LButton"));
actioncontrol.Items.Add(new KeyControl(Keys.MButton | Keys.Control, "Ctrl+MButton"));
@ -474,12 +475,12 @@ namespace CodeImp.DoomBuilder.Windows
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)
if(a.AllowScroll && !a.DisregardControl)
{
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)
if(a.AllowMouse && !a.DisregardShift && !a.DisregardControl)
{
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"));
@ -487,7 +488,7 @@ namespace CodeImp.DoomBuilder.Windows
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)
if(a.AllowScroll && !a.DisregardShift && !a.DisregardControl)
{
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"));
@ -499,6 +500,7 @@ namespace CodeImp.DoomBuilder.Windows
{
Actions.Action action;
KeyControl keycontrol;
string disregardkeys = "";
int key;
// Anything selected?
@ -511,6 +513,7 @@ namespace CodeImp.DoomBuilder.Windows
action = General.Actions[listactions.SelectedItems[0].Name];
key = (int)listactions.SelectedItems[0].SubItems[1].Tag;
disregardshift = action.DisregardShift;
disregardcontrol = action.DisregardControl;
// Enable panel
actioncontrolpanel.Enabled = true;
@ -518,7 +521,16 @@ namespace CodeImp.DoomBuilder.Windows
actiondescription.Text = action.Description;
actioncontrol.SelectedIndex = -1;
actionkey.Text = "";
disregardshiftlabel.Visible = disregardshift;
if(disregardshift && disregardcontrol)
disregardkeys = "Shift and Control";
else if(disregardshift)
disregardkeys = "Shift";
else if(disregardcontrol)
disregardkeys = "Control";
disregardshiftlabel.Text = disregardshiftlabel.Tag.ToString().Replace("%s", disregardkeys);
disregardshiftlabel.Visible = disregardshift | disregardcontrol;
// Fill special controls list
FillControlsList(action);
@ -590,7 +602,8 @@ namespace CodeImp.DoomBuilder.Windows
allowapplycontrol = false;
// Remove modifier keys from the key if needed
if(disregardshift) key &= ~(int)Keys.Modifiers;
if(disregardshift) key &= ~(int)Keys.Shift;
if(disregardcontrol) key &= ~(int)Keys.Control;
// Deselect anything from the combobox
actioncontrol.SelectedIndex = -1;

View file

@ -20,7 +20,8 @@ categories
// allowkeys: Allows the user to bind standard keys to this action.
// allowmouse: Allows the user to bind mouse buttons to this action.
// allowscroll: Allows the user to bind the scrollwheel to this action.
// disregardshift: This action will be triggered regardless if Shift or Control are used.
// disregardshift: This action will be triggered regardless if Shift is used.
// disregardcontrol: This action will be triggered regardless if Control is used.
// repeat: BeginAction will be called for automatic key repetition.
//
// allowkeys and allowmouse are true by default, the others are false by default.
@ -107,6 +108,7 @@ drawpoint
allowmouse = true;
allowscroll = true;
disregardshift = true;
disregardcontrol = true;
}
removepoint

View file

@ -258,22 +258,18 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit button released
public virtual void OnEditEnd()
{
// Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
if(General.Interface.IsActiveWindow)
{
if(General.Interface.IsActiveWindow)
List<Sector> sectors = mode.GetSelectedSectors();
DialogResult result = General.Interface.ShowEditSectors(sectors);
if(result == DialogResult.OK)
{
List<Sector> sectors = mode.GetSelectedSectors();
DialogResult result = General.Interface.ShowEditSectors(sectors);
if(result == DialogResult.OK)
// Rebuild sector
foreach(Sector s in sectors)
{
// Rebuild sector
foreach(Sector s in sectors)
{
VisualSector vs = mode.GetVisualSector(s);
if(vs != null)
(vs as BaseVisualSector).UpdateSectorGeometry(true);
}
VisualSector vs = mode.GetVisualSector(s);
if(vs != null)
(vs as BaseVisualSector).UpdateSectorGeometry(true);
}
}
}

View file

@ -542,30 +542,26 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit button released
public virtual void OnEditEnd()
{
// Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
if(General.Interface.IsActiveWindow)
{
if(General.Interface.IsActiveWindow)
List<Linedef> linedefs = mode.GetSelectedLinedefs();
DialogResult result = General.Interface.ShowEditLinedefs(linedefs);
if(result == DialogResult.OK)
{
List<Linedef> linedefs = mode.GetSelectedLinedefs();
DialogResult result = General.Interface.ShowEditLinedefs(linedefs);
if(result == DialogResult.OK)
foreach(Linedef l in linedefs)
{
foreach(Linedef l in linedefs)
if(l.Front != null)
{
if(l.Front != null)
{
VisualSector vs = mode.GetVisualSector(l.Front.Sector);
if(vs != null)
(vs as BaseVisualSector).Changed = true;
}
if(l.Back != null)
{
VisualSector vs = mode.GetVisualSector(l.Back.Sector);
if(vs != null)
(vs as BaseVisualSector).Changed = true;
}
VisualSector vs = mode.GetVisualSector(l.Front.Sector);
if(vs != null)
(vs as BaseVisualSector).Changed = true;
}
if(l.Back != null)
{
VisualSector vs = mode.GetVisualSector(l.Back.Sector);
if(vs != null)
(vs as BaseVisualSector).Changed = true;
}
}
}

View file

@ -425,21 +425,17 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Edit button released
public virtual void OnEditEnd()
{
// Not using any modifier buttons
if(!General.Interface.ShiftState && !General.Interface.CtrlState && !General.Interface.AltState)
if(General.Interface.IsActiveWindow)
{
if(General.Interface.IsActiveWindow)
List<Thing> things = mode.GetSelectedThings();
DialogResult result = General.Interface.ShowEditThings(things);
if(result == DialogResult.OK)
{
List<Thing> things = mode.GetSelectedThings();
DialogResult result = General.Interface.ShowEditThings(things);
if(result == DialogResult.OK)
foreach(Thing t in things)
{
foreach(Thing t in things)
{
VisualThing vt = mode.GetVisualThing(t);
if(vt != null)
(vt as BaseVisualThing).Changed = true;
}
VisualThing vt = mode.GetVisualThing(t);
if(vt != null)
(vt as BaseVisualThing).Changed = true;
}
}
}