Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion src/gamescalingutils/src/Client/GameScalingUtils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ function GameScalingUtils.renderUIScale(props)
}
end

--[=[
Mount version of renderUIScale.
Garbage is given to the passed maid.
With no parent instance, defaults to parenting to the passed screen.

@param maid Maid
@param screen ScreenGui
@param parent Instance?
]=]
function GameScalingUtils.mountUIScale(maid, screenGui: ScreenGui, parent: Instance?)
local scale = Instance.new("UIScale")
scale.Archivable = false
scale.Name = "UIScale (GameScaling)"
maid:GiveTask(GameScalingUtils.observeUIScale(screenGui):Subscribe(function(scaleFac: number)
scale.Scale = scaleFac
end))
scale.Parent = parent or screenGui
maid:GiveTask(scale)
end

--[=[
Blend equivalent of rendering the dialog padding

Expand All @@ -102,6 +122,29 @@ function GameScalingUtils.renderDialogPadding(props)
}
end

--[=[
Mount version of renderDialogPadding.
Garbage is given to the passed maid.
With no parent instance, defaults to parenting to the passed screen.

@param maid Maid
@param screen ScreenGui
@param parent Instance?
]=]
function GameScalingUtils.mountDialogPadding(maid, screenGui: ScreenGui, parent: Instance?)
local padding = Instance.new("UIPadding")
padding.Archivable = false
padding.Name = "DialogPadding (GameScaling)"
maid:GiveTask(GameScalingUtils.observeDialogPadding(screenGui):Subscribe(function(px: number)
padding.PaddingTop = px
padding.PaddingBottom = px
padding.PaddingLeft = px
padding.PaddingRight = px
end))
padding.Parent = parent or screenGui
maid:GiveTask(padding)
end

--[=[
Observes a smoothed out UI scale for a given screenGui
@param screenGui ScreenGui
Expand Down Expand Up @@ -138,4 +181,4 @@ function GameScalingUtils.getDialogPadding(screenAbsoluteSize)
end
end

return GameScalingUtils
return GameScalingUtils