Skip to content
Open
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# when will this work vro

name: Deploy


on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

workflow_dispatch:

jobs:

deploy:
name: Deploy to wally
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up Aftman
uses: ok-nick/[email protected]
- name: Check wally version
run: wally --version

- name: Authentificate wally
env:
WALLY_AUTH_TOKEN: ${{ secrets.GITH_TOKEN }}
run: wally login --token "$WALLY_AUTH_TOKEN"

- name: Publish to wally

run: wally publish



7 changes: 7 additions & 0 deletions aftman.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This file lists tools managed by Aftman, a cross-platform toolchain manager.
# For more information, see https://github.com/LPGhatguy/aftman

# To add a new tool, add an entry to this table.
[tools]
wally = "Upliftgames/[email protected]"
# rojo = "rojo-rbx/[email protected]"
6 changes: 6 additions & 0 deletions default.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "PludLayout",
"tree": {
"$path": "src"
}
}
9 changes: 9 additions & 0 deletions rotriever.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "PludLayout"
version = "0.1.0"
license = "MIT"
authors = ["22a", "al_ex427 (for rotriever package)"]
content_root = "src"


[dependencies]
117 changes: 0 additions & 117 deletions src/PludLayout.luau

This file was deleted.

169 changes: 169 additions & 0 deletions src/init.luau
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
local tween_service = game:GetService("TweenService")

export type Layout = {
Padding: UDim2;
Size: UDim2;
ConstantUpdates: boolean;
SmoothUpdates: boolean;
TweenSize: boolean;
UpdateTween: TweenInfo; -- only works with constant updates and smooth updates
Linked: Frame;
Whitelisted: {[Object]: {object: Instance, offset: UDim2, size_offset: UDim2, og_pos: UDim2, og_size: UDim2}};
Blacklisted: {[Object]: boolean};
Initialized: {[Object]: boolean};
}

local plud_layout = {}
plud_layout.__index = plud_layout

function plud_layout.create_layout(grid_data: Layout)
local self: Layout = setmetatable({
whitelisted = {};
initialized = {};
}, plud_layout)

for i, v in grid_data do
self[i] = v
end

self.Linked.ChildAdded:Connect(function(child)
print(`New child: {child}`)
self:whitelist(child)
end)

self.Linked.ChildRemoved:Connect(function(child)
print(`Lost child: {child}`)
self:blacklist(child)
end)

for _, child in self.Linked:GetChildren() do
self:whitelist(child)
end

return self
end

function plud_layout:update()
local cleaned = {}
if self.ConstantUpdates then
for _, obj in self.whitelisted do
if obj.object and obj.object.Parent then
table.insert(cleaned, obj)
end
end
self.whitelisted = cleaned
end

local corrected_padding = math.max(.001, self.Padding.X.Scale)
local cols = math.floor((1 + corrected_padding) / (math.max(.001, self.Size.X.Scale) + corrected_padding))
cols = math.max(1, cols)
for i, obj_data in self.whitelisted do
local obj = obj_data.object

local col = (i-1) % cols
local row = math.floor((i-1) / cols)

local cell_w = self.Size.X.Scale
local cell_h = self.Size.Y.Scale
local pad_x = self.Padding.X.Scale
local pad_y = self.Padding.Y.Scale

local size = self.Size + obj_data.size_offset

local pos = UDim2.new(
col * (cell_w + pad_x),
self.Padding.X.Offset + col * (self.Size.X.Offset + self.Padding.X.Offset),
row * (cell_h + pad_y),
self.Padding.Y.Offset + row * (self.Size.Y.Offset + self.Padding.Y.Offset)
)
local halfed_x = obj_data.og_size.X.Scale / 2
local halfed_y = obj_data.og_size.Y.Scale / 2
pos = (pos + obj_data.offset) + UDim2.new(halfed_x, 0, halfed_y, 0)

if obj.Position == pos then continue end

if self.SmoothUpdates and self.UpdateTween then
local data = {Position = pos}
if self.TweenSize then
data.Size = size
end
tween_service:Create(obj, self.UpdateTween, data):Play()
obj.Size = size
else
obj.Position = pos
obj.Size = size
end

self.initialized[obj] = true
end
end

function plud_layout:blacklist(obj: Object)
if not obj then return end
self.whitelisted[obj] = nil
self.initialized[obj] = nil
end


function plud_layout:whitelist(obj: Object, p_offset, s_offset)
p_offset = p_offset or UDim2.new(0, 0, 0, 0)
s_offset = s_offset or UDim2.new(0, 0, 0, 0)
if not obj then return end

local data = {
object = obj;
offset = p_offset;
size_offset = s_offset;
og_pos = obj.Position;
og_size = obj.Size;
}

local slot_found = false
for i = 1, #self.whitelisted do
if self.whitelisted[i] == nil then
self.whitelisted[i] = data
slot_found = true
break
end
end
if not slot_found then
table.insert(self.whitelisted, data)
end
end

--[[
Offsets the position or size of the object by the specified offset and size offset relative to its current position and size
]]
function plud_layout:offset(obj, offset, size_offset)
for i, v in self.whitelisted do
if v.object == obj then
if offset ~= nil then
v.offset = offset
end
if size_offset ~= nil then
v.size_offset = size_offset
end
end
end
end

--[[
offset_type: "position" or "size", default is both
Resets the offset to 0 of the specified type
]]
function plud_layout:remove_offset(obj, offset_type: string)
for i, v in self.whitelisted do
if v.object == obj then
if offset_type == "position" then
v.offset = UDim2.new(0, 0, 0, 0)
elseif offset_type == "size" then
v.size_offset = UDim2.new(0, 0, 0, 0)
else
v.offset = UDim2.new(0, 0, 0, 0)
v.size_offset = UDim2.new(0, 0, 0, 0)
end
end
end
end

return plud_layout
12 changes: 12 additions & 0 deletions wally.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[package]
name = "al-ex427/pludlayout"
description = "A better version and more customizable version of roblox's ui grid layouts"
license = "MIT"
authors = ["22a", "al_ex427 (for wally package)"]
version = "0.1.0"
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"
exclude = ["aftman.toml"]


[dependencies]