Skip to content
This repository has been archived by the owner on Sep 16, 2019. It is now read-only.

Commit

Permalink
0.1.0.4
Browse files Browse the repository at this point in the history
- Added more hotkeys
  • Loading branch information
LogicAndTrick committed Jul 28, 2013
1 parent 777d86d commit 848966e
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 3 deletions.
17 changes: 17 additions & 0 deletions Sledge.Editor/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private void Subscribe()
Mediator.Subscribe(HotkeysMediator.FourViewFocusBottomRight, this);
Mediator.Subscribe(HotkeysMediator.FourViewFocusTopLeft, this);
Mediator.Subscribe(HotkeysMediator.FourViewFocusTopRight, this);
Mediator.Subscribe(HotkeysMediator.FourViewFocusCurrent, this);

Mediator.Subscribe(HotkeysMediator.FileNew, this);
Mediator.Subscribe(HotkeysMediator.FileOpen, this);
Expand Down Expand Up @@ -518,6 +519,22 @@ public void FourViewFocusBottomRight()
tblQuadView.FocusOn(1, 1);
}

public void FourViewFocusCurrent()
{
if (tblQuadView.IsFocusing())
{
tblQuadView.Unfocus();
}
else
{
var focused = ViewportManager.Viewports.FirstOrDefault(x => x.IsFocused);
if (focused != null)
{
tblQuadView.FocusOn(focused);
}
}
}

protected override bool ProcessDialogKey(Keys keyData)
{
// Suppress presses of the alt key if required
Expand Down
4 changes: 2 additions & 2 deletions Sledge.Editor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.1.0.3")]
[assembly: AssemblyFileVersion("0.1.0.3")]
[assembly: AssemblyVersion("0.1.0.4")]
[assembly: AssemblyFileVersion("0.1.0.4")]
53 changes: 53 additions & 0 deletions Sledge.Editor/UI/QuadSplitControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,28 +30,79 @@ public void ResetViews()
foreach (RowStyle rs in RowStyles) rs.Height = 50;
}

public void FocusOn(Control ctrl)
{
if (ctrl == null || !Controls.Contains(ctrl)) return;
var row = GetRow(ctrl);
var col = GetColumn(ctrl);
FocusOn(row, col);
}

public void FocusOn(int rowIndex, int columnIndex)
{
if (rowIndex < 0 || rowIndex > 1 || columnIndex < 0 || columnIndex > 1) return;
RememberFocus();
ColumnStyles[columnIndex].Width = MaximumViewSize;
ColumnStyles[(columnIndex + 1) % 2].Width = MinimumViewSize;
RowStyles[rowIndex].Height = MaximumViewSize;
RowStyles[(rowIndex + 1) % 2].Height = MinimumViewSize;
}

private void RememberFocus()
{
_memoryWidth = new float[ColumnStyles.Count];
_memoryHeight = new float[RowStyles.Count];
for (var i = 0; i < ColumnStyles.Count; i++)
{
_memoryWidth[i] = ColumnStyles[i].Width;
}
for (var i = 0; i < RowStyles.Count; i++)
{
_memoryHeight[i] = RowStyles[i].Height;
}
}

private void ForgetFocus()
{
_memoryWidth = _memoryHeight = null;
}

public void Unfocus()
{
for (var i = 0; i < ColumnStyles.Count; i++)
{
ColumnStyles[i].Width = _memoryWidth[i];
}
for (var i = 0; i < RowStyles.Count; i++)
{
RowStyles[i].Height = _memoryHeight[i];
}
ForgetFocus();
}

public bool IsFocusing()
{
return _memoryWidth != null;
}

private float[] _memoryWidth;
private float[] _memoryHeight;

protected override void OnMouseMove(MouseEventArgs e)
{
if (_resizing)
{
if (_inH && Width > 0)
{
ForgetFocus();
var mp = e.Y / (float)Height * 100;
mp = Math.Min(MaximumViewSize, Math.Max(MinimumViewSize, mp));
RowStyles[0].Height = mp;
RowStyles[1].Height = 100 - mp;
}
if (_inV && Height > 0)
{
ForgetFocus();
var mp = e.X / (float)Width * 100;
mp = Math.Min(MaximumViewSize, Math.Max(MinimumViewSize, mp));
ColumnStyles[0].Width = mp;
Expand Down Expand Up @@ -101,10 +152,12 @@ protected override void OnMouseDoubleClick(MouseEventArgs e)
{
if (_inH)
{
ForgetFocus();
RowStyles[0].Height = RowStyles[1].Height = 50;
}
if (_inV)
{
ForgetFocus();
ColumnStyles[0].Width = ColumnStyles[1].Width = 50;
}
}
Expand Down
9 changes: 9 additions & 0 deletions Sledge.Settings/HotkeyDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class HotkeyDefinition
public string Name { get; set; }
public string Description { get; set; }
public HotkeysMediator Action { get; set; }
public object Parameter { get; set; }
public string DefaultHotkey { get; set; }

public HotkeyDefinition(string name, string description, HotkeysMediator action, string defaultHotkey)
Expand All @@ -19,5 +20,13 @@ public HotkeyDefinition(string name, string description, HotkeysMediator action,
Action = action;
DefaultHotkey = defaultHotkey;
}

public HotkeyDefinition(string name, string description, HotkeysMediator action, object parameter, string defaultHotkey)
{
Name = name;
Description = description;
Action = action;
DefaultHotkey = defaultHotkey;
}
}
}
31 changes: 30 additions & 1 deletion Sledge.Settings/Hotkeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,60 @@ static Hotkeys()
new HotkeyDefinition("Focus View Top Right", "Focus on the XY View", HotkeysMediator.FourViewFocusTopRight, "F2"),
new HotkeyDefinition("Focus View Bottom Left", "Focus on the YZ View", HotkeysMediator.FourViewFocusBottomLeft, "F4"),
new HotkeyDefinition("Focus View Bottom Right", "Focus on the XZ View", HotkeysMediator.FourViewFocusBottomRight, "F3"),
new HotkeyDefinition("Focus Current View", "Focus on the currently active view", HotkeysMediator.FourViewFocusCurrent, "Shift+Z"),

new HotkeyDefinition("New File", "Create a new map", HotkeysMediator.FileNew, "Ctrl+N"),
new HotkeyDefinition("Open File", "Open an existing map", HotkeysMediator.FileOpen, "Ctrl+O"),
new HotkeyDefinition("Save File", "Save the currently opened map", HotkeysMediator.FileSave, "Ctrl+S"),
new HotkeyDefinition("Save File As...", "Save the currently opened map", HotkeysMediator.FileSave, "Ctrl+Alt+S"),
new HotkeyDefinition("Compile Map", "Compile the currently opened map", HotkeysMediator.FileCompile, "F9"),

new HotkeyDefinition("Increase Grid Size", "Increase the current grid size", HotkeysMediator.GridIncrease, "]"),
new HotkeyDefinition("Decrease Grid Size", "Decrease the current grid size", HotkeysMediator.GridDecrease, "["),
new HotkeyDefinition("Toggle 2D Grid", "Toggle the 2D viewport grid on and off", HotkeysMediator.ToggleShow2DGrid, "Shift+R"),
new HotkeyDefinition("Toggle 3D Grid", "Toggle the 3D viewport grid on and off", HotkeysMediator.ToggleShow3DGrid, "P"),
new HotkeyDefinition("Toggle Snap to Grid", "Toggle grid snapping on and off", HotkeysMediator.ToggleSnapToGrid, "Shift+W"),
new HotkeyDefinition("Snap Selection to Grid", "Snap current selection to the grid based on the selection bounding box", HotkeysMediator.SnapSelectionToGrid, "Ctrl+B"),
new HotkeyDefinition("Snap Selection to Grid Individually", "Snap each selected object to the grid based on their individual bounding boxes", HotkeysMediator.SnapSelectionToGridIndividually, "Ctrl+Shift+B"),

new HotkeyDefinition("Undo", "Undo the last action", HotkeysMediator.HistoryUndo, "Ctrl+Z"),
new HotkeyDefinition("Redo", "Redo the last undone action", HotkeysMediator.HistoryRedo, "Ctrl+Y"),

new HotkeyDefinition("Show Object Properties", "Open the object properties dialog for the currently selected items", HotkeysMediator.ObjectProperties, "Alt+Enter"),

new HotkeyDefinition("Copy", "Copy the current selection", HotkeysMediator.OperationsCopy, "Ctrl+C"),
new HotkeyDefinition("Copy", "Copy the current selection", HotkeysMediator.OperationsCopy, "Ctrl+Ins"),
new HotkeyDefinition("Cut", "Cut the current selection", HotkeysMediator.OperationsCut, "Ctrl+X"),
new HotkeyDefinition("Cut", "Cut the current selection", HotkeysMediator.OperationsCut, "Shift+Del"),
new HotkeyDefinition("Paste", "Paste the clipboard contents", HotkeysMediator.OperationsPaste, "Ctrl+V"),
new HotkeyDefinition("Paste", "Paste the clipboard contents", HotkeysMediator.OperationsPaste, "Shift+Ins"),
new HotkeyDefinition("Paste Special", "Paste special the clipboard contents", HotkeysMediator.OperationsPasteSpecial, "Ctrl+B"),
new HotkeyDefinition("Delete", "Delete the current selection", HotkeysMediator.OperationsDelete, "Del"),

new HotkeyDefinition("Group", "Group the selected objects", HotkeysMediator.GroupingGroup, "Ctrl+G"),
new HotkeyDefinition("Ungroup", "Ungroup the selected objects", HotkeysMediator.GroupingUngroup, "Ctrl+U"),

new HotkeyDefinition("Hide Selected", "Hide the selected objects", HotkeysMediator.QuickHideSelected, "H"),
new HotkeyDefinition("Hide Unselected", "Hide the unselected objects", HotkeysMediator.QuickHideUnselected, "Ctrl+H"),
new HotkeyDefinition("Unhide All", "Show all hidden objects", HotkeysMediator.QuickHideShowAll, "U"),

new HotkeyDefinition("Tie To Entity", "Tie the selected objects to an entity", HotkeysMediator.TieToEntity, "Ctrl+T"),
new HotkeyDefinition("Move To World", "Move the selected objects to the world", HotkeysMediator.TieToWorld, "Ctrl+W"),
new HotkeyDefinition("Ungroup", "Ungroup the selected objects", HotkeysMediator.GroupingUngroup, "Ctrl+H"),

new HotkeyDefinition("Center 2D View on Selection", "Center the 2D viewports on the current selection", HotkeysMediator.Center2DViewsOnSelection, "Ctrl+E"),
new HotkeyDefinition("Center 3D View on Selection", "Center the 3D viewport on the current selection", HotkeysMediator.Center3DViewsOnSelection, "Ctrl+Shift+E"),

new HotkeyDefinition("Deselect All", "Deselect all currently selected objects", HotkeysMediator.SelectionClear, "Shift+Q"),
new HotkeyDefinition("Deselect All", "Deselect all currently selected objects", HotkeysMediator.SelectionClear, "Esc"),

new HotkeyDefinition("Tie to Entity", "Tie the selected objects to an entity", HotkeysMediator.TieToEntity, "Ctrl+T"),
new HotkeyDefinition("Move to World", "Move the selected entities to the world", HotkeysMediator.TieToWorld, "Ctrl+Shift+W"),

new HotkeyDefinition("Toggle Texture Lock", "Toggles texture locking on and off", HotkeysMediator.ToggleTextureLock, "Shift+L"),
new HotkeyDefinition("Transform", "Open the 'Transform' dialog", HotkeysMediator.Transform, "Ctrl+M"),
new HotkeyDefinition("Check for Problems", "Open the 'Check for Problems' dialog", HotkeysMediator.CheckForProblems, "Alt+P"),
new HotkeyDefinition("Go to Brush ID", "Open the 'Go to Brush ID' dialog", HotkeysMediator.GoToBrushID, "Ctrl+Shift+G"),

};
}

Expand Down
1 change: 1 addition & 0 deletions Sledge.Settings/HotkeysMediator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public enum HotkeysMediator
FourViewFocusTopRight,
FourViewFocusBottomLeft,
FourViewFocusBottomRight,
FourViewFocusCurrent,

FileNew,
FileOpen,
Expand Down
1 change: 1 addition & 0 deletions Sledge.UI/ViewportBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ protected override void OnMouseEnter(EventArgs e)

protected override void OnMouseLeave(EventArgs e)
{
IsFocused = false;
ListenerDoEvent(new ViewportEvent(this, e), (l, v) => l.MouseLeave(v));
}

Expand Down

0 comments on commit 848966e

Please sign in to comment.