-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from ImAvafe/dev
Merge Dev for 0.2.0
- Loading branch information
Showing
68 changed files
with
2,150 additions
and
2,070 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,44 @@ | ||
local OnyxUI = require(script.Parent.Parent) | ||
local Fusion = require(OnyxUI.Packages.Fusion) | ||
local Workspace = game:GetService("Workspace") | ||
local OnyxUI = script.Parent.Parent | ||
local Fusion = require(OnyxUI.Parent.Fusion) | ||
local EnsureValue = require(OnyxUI.Utils.EnsureValue) | ||
local Modifier = require(OnyxUI.Utils.Modifier) | ||
local PubTypes = require(OnyxUI.Utils.PubTypes) | ||
|
||
local Value = Fusion.Value | ||
local Computed = Fusion.Computed | ||
local Out = Fusion.Out | ||
local Hydrate = Fusion.Hydrate | ||
local Children = Fusion.Children | ||
|
||
local Frame = require(OnyxUI.Components.Frame) | ||
local Base = require(script.Parent.Base) | ||
local Frame = require(script.Parent.Frame) | ||
|
||
return function(Props: { [any]: any }) | ||
Props.Name = EnsureValue(Props.Name, "string", "AutoScaleFrame") | ||
export type Props = Base.Props & { | ||
BaseResolution: PubTypes.CanBeState<Vector2>?, | ||
MinScale: PubTypes.CanBeState<number>?, | ||
MaxScale: PubTypes.CanBeState<number>?, | ||
ScaleMultiplier: PubTypes.CanBeState<number>?, | ||
} | ||
|
||
Props.BaseResolution = EnsureValue(Props.BaseResolution, "Vector2", Vector2.new()) | ||
Props.ScaleClamps = EnsureValue(Props.ScaleClamps, "table", { Min = 0.8, Max = math.huge }) | ||
Props.ScaleMultiplier = EnsureValue(Props.ScaleMultiplier, "number", 1) | ||
return function(Props: Props) | ||
local BaseResolution = EnsureValue(Props.BaseResolution, "Vector2", Vector2.new()) | ||
local MinScale = EnsureValue(Props.MinScale, "number", 0.8) | ||
local MaxScale = EnsureValue(Props.MaxScale, "number", math.huge) | ||
local ScaleMultiplier = EnsureValue(Props.ScaleMultiplier, "number", 1) | ||
|
||
local ViewportSize = Value(Vector2.new()) | ||
Hydrate(game.Workspace.CurrentCamera) { | ||
Hydrate(Workspace.CurrentCamera) { | ||
[Out "ViewportSize"] = ViewportSize, | ||
} | ||
|
||
return Frame { | ||
Name = Props.Name, | ||
Parent = Props.Parent, | ||
Position = Props.Position, | ||
Rotation = Props.Rotation, | ||
AnchorPoint = Props.AnchorPoint, | ||
Size = Props.Size, | ||
AutomaticSize = Props.AutomaticSize, | ||
Visible = Props.Visible, | ||
ZIndex = Props.ZIndex, | ||
LayoutOrder = Props.LayoutOrder, | ||
ClipsDescendants = Props.ClipsDescendants, | ||
Active = Props.Active, | ||
Selectable = Props.Selectable, | ||
Interactable = Props.Interactable, | ||
BackgroundColor3 = Props.BackgroundColor3, | ||
BackgroundTransparency = Props.BackgroundTransparency, | ||
|
||
[Children] = { | ||
Modifier.Scale { | ||
Scale = Computed(function() | ||
local Ratio = Props.ScaleMultiplier:get() | ||
/ math.max( | ||
(Props.BaseResolution:get().X / ViewportSize:get().X), | ||
(Props.BaseResolution:get().Y / ViewportSize:get().Y) | ||
) | ||
return math.clamp(Ratio, Props.ScaleClamps:get().Min, Props.ScaleClamps:get().Max) | ||
end), | ||
}, | ||
|
||
Props[Children], | ||
}, | ||
Name = "AutoScaleFrame", | ||
Scale = Computed(function() | ||
local Ratio = ScaleMultiplier:get() | ||
/ math.max( | ||
(BaseResolution:get().X / ViewportSize:get().X), | ||
(BaseResolution:get().Y / ViewportSize:get().Y) | ||
) | ||
return math.clamp(Ratio, MinScale:get(), MaxScale:get()) | ||
end), | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.