Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
GigsD4X committed Apr 9, 2017
2 parents f47857c + 055e86d commit 63c5922
Show file tree
Hide file tree
Showing 12 changed files with 5,635 additions and 3,947 deletions.
37 changes: 37 additions & 0 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ function Enable(Mouse)
EnableHotkeys();
Targeting.EnableTargeting();
Selection.EnableOutlines();
Selection.EnableMultiselectionHotkeys();

-- Equip current tool
EquipTool(CurrentTool or require(Tool.Tools.MoveTool));
Expand Down Expand Up @@ -304,6 +305,14 @@ AssignHotkey({ 'RightShift', 'Z' }, History.Undo);
AssignHotkey({ 'LeftShift', 'Y' }, History.Redo);
AssignHotkey({ 'RightShift', 'Y' }, History.Redo);

-- If in-game, enable ctrl hotkeys for undoing and redoing
if Mode == 'Tool' then
AssignHotkey({ 'LeftControl', 'Z' }, History.Undo);
AssignHotkey({ 'RightControl', 'Z' }, History.Undo);
AssignHotkey({ 'LeftControl', 'Y' }, History.Redo);
AssignHotkey({ 'RightControl', 'Y' }, History.Redo);
end;

function CloneSelection()
-- Clones selected parts

Expand Down Expand Up @@ -414,6 +423,14 @@ AssignHotkey({ 'RightShift', 'C' }, CloneSelection);
AssignHotkey({ 'LeftShift', 'X' }, DeleteSelection);
AssignHotkey({ 'RightShift', 'X' }, DeleteSelection);

-- If in-game, enable ctrl hotkeys for cloning and deleting
if Mode == 'Tool' then
AssignHotkey({ 'LeftControl', 'C' }, CloneSelection);
AssignHotkey({ 'RightControl', 'C' }, CloneSelection);
AssignHotkey({ 'LeftControl', 'X' }, DeleteSelection);
AssignHotkey({ 'RightControl', 'X' }, DeleteSelection);
end;

function PrismSelect()
-- Selects parts in the currently selected parts

Expand Down Expand Up @@ -465,6 +482,12 @@ end;
AssignHotkey({ 'LeftShift', 'K' }, PrismSelect);
AssignHotkey({ 'RightShift', 'K' }, PrismSelect);

-- If in-game, enable ctrl hotkeys for prism selection
if Mode == 'Tool' then
AssignHotkey({ 'LeftControl', 'K' }, PrismSelect);
AssignHotkey({ 'RightControl', 'K' }, PrismSelect);
end;

function SelectSiblings(ReplaceSelection)
-- Selects all parts under the same parent as the focused part

Expand Down Expand Up @@ -494,6 +517,14 @@ AssignHotkey({ 'RightShift', 'LeftBracket' }, Support.Call(SelectSiblings, false
AssignHotkey({ 'LeftShift', 'R' }, Support.Call(Selection.Clear, true));
AssignHotkey({ 'RightShift', 'R' }, Support.Call(Selection.Clear, true));

-- If in-game, enable ctrl hotkeys for sibling selection & selection clearing
if Mode == 'Tool' then
AssignHotkey({ 'LeftControl', 'LeftBracket' }, Support.Call(SelectSiblings, false));
AssignHotkey({ 'RightControl', 'LeftBracket' }, Support.Call(SelectSiblings, false));
AssignHotkey({ 'LeftControl', 'R' }, Support.Call(Selection.Clear, true));
AssignHotkey({ 'RightControl', 'R' }, Support.Call(Selection.Clear, true));
end;

function IsSelectable(Object)
-- Returns whether `Object` can be selected

Expand Down Expand Up @@ -563,6 +594,12 @@ end;
AssignHotkey({ 'LeftShift', 'P' }, ExportSelection);
AssignHotkey({ 'RightShift', 'P' }, ExportSelection);

-- If in-game, enable ctrl hotkeys for exporting
if Mode == 'Tool' then
AssignHotkey({ 'LeftControl', 'P' }, ExportSelection);
AssignHotkey({ 'RightControl', 'P' }, ExportSelection);
end;

function IsVersionOutdated()
-- Returns whether this version of Building Tools is out of date

Expand Down
37 changes: 37 additions & 0 deletions SelectionModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Selection = {};
Selection.Items = {};
Selection.Outlines = {};
Selection.Color = BrickColor.new 'Cyan';
Selection.Multiselecting = false;

-- Events to listen to selection changes
Selection.ItemsAdded = RbxUtility.CreateSignal();
Expand Down Expand Up @@ -278,6 +279,42 @@ function Selection.EnableOutlines()

end;

function Selection.EnableMultiselectionHotkeys()
-- Enables hotkeys for multiselecting

-- Determine multiselection hotkeys
local Hotkeys = Support.FlipTable { 'LeftShift', 'RightShift', 'LeftControl', 'RightControl' };

-- Get core API
local Core = GetCore();

-- Listen for matching key presses
Core.Connections.MultiselectionHotkeys = Support.AddUserInputListener('Began', 'Keyboard', false, function (Input)
if Hotkeys[Input.KeyCode.Name] then
Selection.Multiselecting = true;
end;
end);

-- Listen for matching key releases
Core.Connections.MultiselectingReleaseHotkeys = Support.AddUserInputListener('Ended', 'Keyboard', true, function (Input)

-- Get currently pressed keys
local PressedKeys = Support.GetListMembers(Support.GetListMembers(Game:GetService('UserInputService'):GetKeysPressed(), 'KeyCode'), 'Name');

-- Continue multiselection if a hotkey is still pressed
for _, PressedKey in pairs(PressedKeys) do
if Hotkeys[PressedKey] then
return;
end;
end;

-- Disable multiselection if matching key not found
Selection.Multiselecting = false;

end);

end;

function Selection.HideOutlines()
-- Hides selection outlines

Expand Down
23 changes: 11 additions & 12 deletions SnapTracking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,17 @@ end;
function SnapTracking.StopTracking()
-- Stops tracking the current closest snapping point, cleans up

-- Clear the previous tracking target, and callback
SnapTracking.Target = nil;
SnapTracking.Callback = nil;

-- Reset snapping point options
SnapTracking.TrackFaceCentroids = true;
SnapTracking.TrackEdgeMidpoints = true;
SnapTracking.TrackCorners = true;
SnapTracking.TargetFilter = nil;
SnapTracking.TargetBlacklist = {};

-- Make sure we're currently tracking
if not SnapTracking.Enabled then
return;
Expand All @@ -224,18 +235,6 @@ function SnapTracking.StopTracking()
-- Clear the point marker UI from the screen
SnapTracking.ClearUI();

-- Clear the previous tracking target, and callback
SnapTracking.Target = nil;
SnapTracking.Callback = nil;

-- Reset snapping point options
SnapTracking.TrackFaceCentroids = true;
SnapTracking.TrackEdgeMidpoints = true;
SnapTracking.TrackCorners = true;

SnapTracking.TargetFilter = nil;
SnapTracking.TargetBlacklist = {};

-- Indicate that tracking is no longer enabled
SnapTracking.Enabled = false;

Expand Down
Loading

0 comments on commit 63c5922

Please sign in to comment.