Skip to content

Commit

Permalink
Re-add PointingEnabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNexusAvenger committed Jan 15, 2023
1 parent 393541e commit a76864c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
5 changes: 4 additions & 1 deletion src/Container/BaseScreenGui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type BaseScreenGui = {
FieldOfView: number,
CanvasSize: Vector2,
Easing: number,
PointingEnabled: boolean,
GetContainer: (self: BaseScreenGui) -> (LayerCollector),
DisableChangeReplication: (self: BaseScreenGui, Name: string) -> (),
Destroy: (self: BaseScreenGui) -> (),
Expand Down Expand Up @@ -46,10 +47,10 @@ function BaseScreenGui:__new(Container: LayerCollector): ()
return (Container :: any)[Index]
end
Metatable.__newindex = function(self, Index: string, Value): ()
BaseNewIndex(self, Index, Value)
if not NonReplicatedProperties[Index] then
(Container :: any)[Index] = Value
end
BaseNewIndex(self, Index, Value)
end

--Set the properties.
Expand All @@ -65,6 +66,8 @@ function BaseScreenGui:__new(Container: LayerCollector): ()
self.CanvasSize = Vector2.new(1000, 1000)
self:DisableChangeReplication("Easing")
self.Easing = 0
self:DisableChangeReplication("PointingEnabled")
self.PointingEnabled = true
end

--[[
Expand Down
16 changes: 11 additions & 5 deletions src/Container/ScreenGui3D.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ function ScreenGui3D:__new()

--Set the properties.
self.AlwaysOnTop = true
self:AddPropertyFinalizer("PointingEnabled", function()
self.Adornee.CanQuery = self.Enabled and self.PointingEnabled
end)
self:AddPropertyFinalizer("Enabled", function()
self.Adornee.CanQuery = self.Enabled and self.PointingEnabled
end)

--Disable replication of ScreenGui properties.
self:DisableChangeReplication("DisplayOrder")
Expand All @@ -51,13 +57,13 @@ function ScreenGui3D:__new()
self.LastRotation = CFrame.new(Workspace.CurrentCamera:GetRenderCFrame().Position):Inverse() * Workspace.CurrentCamera:GetRenderCFrame()

--Connect updating the size.
self:AddPropertyFinalizer("Depth",function()
self:AddPropertyFinalizer("Depth", function()
self:UpdateSize()
end)
self:AddPropertyFinalizer("FieldOfView",function()
self:AddPropertyFinalizer("FieldOfView", function()
self:UpdateSize()
end)
self:AddPropertyFinalizer("CanvasSize",function()
self:AddPropertyFinalizer("CanvasSize", function(Value)
self:UpdateSize()
end)

Expand All @@ -77,9 +83,9 @@ Updates the size of the part.
function ScreenGui3D:UpdateSize(): ()
local Width = 2 * math.tan(self.FieldOfView/2) * self.Depth
if self.CanvasSize.Y <= self.CanvasSize.X then
self.Adornee.Size = Vector3.new(Width,Width * (self.CanvasSize.Y/self.CanvasSize.X),0)
self.Adornee.Size = Vector3.new(Width, Width * (self.CanvasSize.Y / self.CanvasSize.X), 0)
else
self.Adornee.Size = Vector3.new(Width * (self.CanvasSize.X/self.CanvasSize.Y),Width,0)
self.Adornee.Size = Vector3.new(Width * (self.CanvasSize.X / self.CanvasSize.Y), Width, 0)
end
self.CanvasSize = self.CanvasSize
end
Expand Down
16 changes: 16 additions & 0 deletions test/Container/ScreenGui3D.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,21 @@ return function()
expect(TestScreenGui3D.LastRotation).to.be.near(ExpectedCFrame, 0.05)
end
end)

it("should change CanQuery.", function()
TestScreenGui3D.PointingEnabled = false
task.wait()
expect(TestScreenGui3D.Adornee.CanQuery).to.equal(false)
TestScreenGui3D.PointingEnabled = true
task.wait()
expect(TestScreenGui3D.Adornee.CanQuery).to.equal(true)
TestScreenGui3D.PointingEnabled = true
TestScreenGui3D.Enabled = false
task.wait()
expect(TestScreenGui3D.Adornee.CanQuery).to.equal(false)
TestScreenGui3D.Enabled = true
task.wait()
expect(TestScreenGui3D.Adornee.CanQuery).to.equal(true)
end)
end)
end

0 comments on commit a76864c

Please sign in to comment.