Skip to content

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
GigsD4X committed Jun 23, 2017
2 parents 5b67556 + 03ec869 commit 9871378
Show file tree
Hide file tree
Showing 18 changed files with 55,841 additions and 53,536 deletions.
48 changes: 42 additions & 6 deletions Components/HSVColorPicker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local Component = Cheer.CreateComponent('BTHSVColorPicker', View);

local Connections = {};

function Component.Start(InitialColor, Callback)
function Component.Start(InitialColor, Callback, SelectionPreventionCallback, PreviewCallback)

-- Show the UI
View.Visible = true;
Expand Down Expand Up @@ -40,9 +40,28 @@ function Component.Start(InitialColor, Callback)
Connections.TrackBrightness = Support.AddGuiInputListener(View.Brightness, 'Began', 'MouseButton1', true, Support.Call(StartTrackingMouse, 'B'));
Connections.StopTrackingMouse = Support.AddUserInputListener('Ended', 'MouseButton1', true, StopTrackingMouse);

-- Connect OK/Cancel buttons
Cheer.Bind(View.OkButton, { function () View:Destroy(); return Color3.fromHSV(#Hue, #Saturation, #Brightness) end }, Callback);
Cheer.Bind(View.CancelButton, function () View:Destroy() end);
-- Connect OK button to finish color picking
Cheer.Bind(View.OkButton, function ()

-- Clear any preview
if PreviewCallback then
PreviewCallback();
end;

-- Remove the UI
View:Destroy();

-- Return the selected color
Callback(Color3.fromHSV(#Hue, #Saturation, #Brightness));

end);

-- Connect cancel button to clear preview and remove UI
Cheer.Bind(View.CancelButton, function () if PreviewCallback then PreviewCallback() end; View:Destroy(); end);

-- Store reference to callbacks
Component.SelectionPreventionCallback = SelectionPreventionCallback;
Component.PreviewCallback = PreviewCallback;

-- Clear connections when the component is removed
Cheer.Bind(Component.OnRemove, ClearConnections);
Expand All @@ -56,6 +75,7 @@ function StartTrackingMouse(TrackingType)
return;
end;

-- Watch mouse movement and adjust current color
Connections.MouseTracking = Support.AddUserInputListener('Changed', 'MouseMovement', true, function (Input)

-- Track for hue-saturation
Expand All @@ -70,6 +90,11 @@ function StartTrackingMouse(TrackingType)

end);

-- Prevent selection if a callback to do so is provided
if Component.SelectionPreventionCallback then
Component.SelectionPreventionCallback();
end;

end;

function StopTrackingMouse()
Expand All @@ -89,8 +114,14 @@ end;
function UpdateDisplay()
-- Updates the display based on the current color

-- Get current color
local CurrentColor = Color3.fromHSV(#Hue, #Saturation, #Brightness);

-- Update the color display
View.ColorDisplay.BackgroundColor3 = Color3.fromHSV(#Hue, #Saturation, #Brightness);
View.ColorDisplay.BackgroundColor3 = CurrentColor;
View.HueOption.Bar.BackgroundColor3 = CurrentColor;
View.SaturationOption.Bar.BackgroundColor3 = CurrentColor;
View.BrightnessOption.Bar.BackgroundColor3 = CurrentColor;

-- Update the interactive color picker
View.HueSaturation.Cursor.Position = UDim2.new(
Expand All @@ -99,12 +130,17 @@ function UpdateDisplay()
);

-- Update the interactive brightness picker
View.Brightness.ColorBG.BackgroundColor3 = Color3.fromHSV(#Hue, #Saturation, 1);
View.Brightness.ColorBG.BackgroundColor3 = CurrentColor;
View.Brightness.Cursor.Position = UDim2.new(
View.Brightness.Cursor.Position.X.Scale, View.Brightness.Cursor.Position.X.Offset,
1 - #Brightness, View.Brightness.Cursor.Position.Y.Offset
);

-- Update the preview if enabled
if Component.PreviewCallback then
Component.PreviewCallback(CurrentColor);
end;

end;

function ClearConnections()
Expand Down
50 changes: 38 additions & 12 deletions Components/ToolInformationManager.lua
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,46 @@ function Component.StartFadeTimer(Override)

end;

function Component.StartShowTimer(SectionName)
-- Creates timer to show content after hovering for over half a second

-- Only override current section if also triggered by hover
if Component.LastTrigger == 'Click' then
return;
end;

-- Generate unique trigger ID
local TriggerId = HttpService:GenerateGUID();

-- Register timer
Component.CurrentShowTimer = TriggerId;

-- Start timer
Delay(0.25, function ()
if Component.CurrentShowTimer == TriggerId then
Component.ShowSection(SectionName, 'Hover');
Component.StartFadeTimer();
end;
end);

end;

function Component.ProcessHover(Tool, SectionName)

-- Only override current section if also triggered by hover
if Component.LastTrigger == 'Click' then
return;
end;

wait();

-- Start a show timer
Component.StartShowTimer(SectionName);

end;

function Component.ShowSection(SectionName, TriggerType)

-- Hide any current section
Component.HideCurrentSection();

Expand All @@ -80,7 +113,7 @@ function Component.ProcessHover(Tool, SectionName)

-- Set new current section
Component.CurrentSection = Section;
Component.LastTrigger = 'Hover';
Component.LastTrigger = TriggerType;

-- Show the new section
Section.Visible = true;
Expand All @@ -89,6 +122,9 @@ end;

function Component.ProcessUnhover(Tool, SectionName)

-- Clear any other show timer
Component.CurrentShowTimer = nil;

-- Only override current section if triggered by a hover
if Component.LastTrigger == 'Click' then
return;
Expand All @@ -106,18 +142,8 @@ end;

function Component.ProcessClick(Tool, SectionName)

-- Hide any current section
Component.HideCurrentSection();

-- Get section
local Section = Component.GetSection(SectionName);

-- Set new current section
Component.CurrentSection = Section;
Component.LastTrigger = 'Click';

-- Show the new section
Section.Visible = true;
Component.ShowSection(SectionName, 'Click');

-- Disappear after 2 seconds unless overridden
Component.StartFadeTimer();
Expand Down
85 changes: 9 additions & 76 deletions Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -499,96 +499,29 @@ if Mode == 'Tool' then
AssignHotkey({ 'RightControl', 'X' }, DeleteSelection);
end;

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

-- Ensure parts are selected
if #Selection.Items == 0 then
return;
end;

-- Get region for selection items and find potential parts
local Extents = require(Tool.BoundingBoxModule).CalculateExtents(Selection.Items, nil, true);
local Region = Region3.new(Extents.Min, Extents.Max);
local PotentialParts = Workspace:FindPartsInRegion3WithIgnoreList(Region, Selection.Items, math.huge);

-- Enable collision on all potential parts
local OriginalState = {};
for _, PotentialPart in pairs(PotentialParts) do
OriginalState[PotentialPart] = { Anchored = PotentialPart.Anchored, CanCollide = PotentialPart.CanCollide };
PotentialPart.Anchored = true;
PotentialPart.CanCollide = true;
end;

local Parts = {};

-- Find all parts intersecting with selection
for _, Part in pairs(Selection.Items) do
local TouchingParts = Part:GetTouchingParts();
for _, TouchingPart in pairs(TouchingParts) do
if not Selection.IsSelected(TouchingPart) then
Parts[TouchingPart] = true;
end;
end;
end;

-- Restore all potential parts' original states
for PotentialPart, State in pairs(OriginalState) do
PotentialPart.CanCollide = State.CanCollide;
PotentialPart.Anchored = State.Anchored;
end;

-- Delete the selection parts
DeleteSelection();

-- Select all found parts
Selection.Replace(Support.Keys(Parts), true);

end;

-- Assign hotkeys for prism selection
AssignHotkey({ 'LeftShift', 'K' }, PrismSelect);
AssignHotkey({ 'RightShift', 'K' }, PrismSelect);
AssignHotkey({ 'LeftShift', 'K' }, Targeting.PrismSelect);
AssignHotkey({ 'RightShift', 'K' }, Targeting.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

-- Ensure there is a focused item and its parent is not Workspace
if not Selection.Focus or Selection.Focus.Parent == Workspace then
return;
end;

-- Get the focused item's siblings
local Siblings = Support.GetAllDescendants(Selection.Focus.Parent);

-- Add to or replace selection
if ReplaceSelection then
Selection.Replace(Siblings, true);
else
Selection.Add(Siblings, true);
end;

AssignHotkey({ 'LeftControl', 'K' }, Targeting.PrismSelect);
AssignHotkey({ 'RightControl', 'K' }, Targeting.PrismSelect);
end;

-- Assign hotkeys for sibling selection
AssignHotkey({ 'LeftBracket' }, Support.Call(SelectSiblings, true));
AssignHotkey({ 'LeftShift', 'LeftBracket' }, Support.Call(SelectSiblings, false));
AssignHotkey({ 'RightShift', 'LeftBracket' }, Support.Call(SelectSiblings, false));
AssignHotkey({ 'LeftBracket' }, Support.Call(Targeting.SelectSiblings, false, true));
AssignHotkey({ 'LeftShift', 'LeftBracket' }, Support.Call(Targeting.SelectSiblings, false, false));
AssignHotkey({ 'RightShift', 'LeftBracket' }, Support.Call(Targeting.SelectSiblings, false, false));

-- Assign hotkeys for selection clearing
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', 'LeftBracket' }, Support.Call(Targeting.SelectSiblings, false, false));
AssignHotkey({ 'RightControl', 'LeftBracket' }, Support.Call(Targeting.SelectSiblings, false, false));
AssignHotkey({ 'LeftControl', 'R' }, Support.Call(Selection.Clear, true));
AssignHotkey({ 'RightControl', 'R' }, Support.Call(Selection.Clear, true));
end;
Expand Down
20 changes: 18 additions & 2 deletions ImportPlugin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ local GUI;
------------------------------------------
RbxUtility = LoadLibrary( 'RbxUtility' );
Services.ContentProvider:Preload( bt_logo );
Serialization = require(script.SerializationModule);
SerializationV2 = require(script.SerializationModule2);
SerializationV3 = require(script.SerializationModule3);

------------------------------------------
-- Define functions that are depended-upon
Expand Down Expand Up @@ -595,7 +596,22 @@ end;]];
elseif creation_data.Version == 2 then

-- Inflate the build data
local Parts = Serialization.InflateBuildData(creation_data);
local Parts = SerializationV2.InflateBuildData(creation_data);

-- Parent the build into the export container
for _, Part in pairs(Parts) do
Part.Parent = Container;
end;

-- Finalize the import
Container:MakeJoints();
Services.Selection:Set { Container };

-- Parse builds with serialization format version 3
elseif creation_data.Version == 3 then

-- Inflate the build data
local Parts = SerializationV3.InflateBuildData(creation_data);

-- Parent the build into the export container
for _, Part in pairs(Parts) do
Expand Down
14 changes: 10 additions & 4 deletions SelectionModule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,17 @@ end;
function Selection.Replace(Items, RegisterHistory)
-- Replaces the current selection with the given new items

-- Clear current selection
Selection.Clear(RegisterHistory);
-- Save old selection reference for history
local OldSelection = Selection.Items;

-- Clear current selection and select new items
Selection.Clear(false);
Selection.Add(Items, false);

-- Select new items
Selection.Add(Items, RegisterHistory);
-- Create a history record for this selection change, if requested
if RegisterHistory then
TrackSelectionChange(OldSelection);
end;

end;

Expand Down
File renamed without changes.
Loading

0 comments on commit 9871378

Please sign in to comment.