Skip to content

Commit

Permalink
first commit - port from studio to rojo project
Browse files Browse the repository at this point in the history
  • Loading branch information
devsarim committed Nov 30, 2023
1 parent 8056871 commit 41aadb9
Show file tree
Hide file tree
Showing 20 changed files with 560 additions and 3 deletions.
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Plugin model files
/quickfix-roblox-plugin.rbxmx
/quickfix-roblox-plugin.rbxm
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# quickfix-roblox-plugin
A plugin for streamlining asset optimization.

A plugin for streamlining asset optimization.
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]
rojo = "rojo-rbx/rojo@7.4.0-rc3"
# rojo = "rojo-rbx/rojo@6.2.0"
12 changes: 12 additions & 0 deletions default.project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"name": "quickfix-roblox-plugin",
"tree": {
"$className": "DataModel",

"ServerScriptService": {
"QuickFix": {
"$path": "src"
}
}
}
}
1 change: 1 addition & 0 deletions selene.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
std = "roblox"
43 changes: 43 additions & 0 deletions src/Actions/AnchoredAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local Roact = require(script.Parent.Parent.Roact)

local DualAction = require(script.Parent.DualAction)

return function()
return Roact.createElement(DualAction, {
text = "Anchored",

predicate = function(object)
return object:IsA("BasePart")
end,

onDisable = function(objects)
local count = 0

for _, descendant in objects do
if not descendant.Anchored then
continue
end

descendant.Anchored = false
count += 1
end

warn("[Asset Optimizer] Anchored set to false for " .. count .. " objects")
end,

onEnable = function(objects)
local count = 0

for _, descendant in objects do
if descendant.Anchored then
continue
end

descendant.Anchored = true
count += 1
end

warn("[Asset Optimizer] Anchored set to true for " .. count .. " objects")
end,
})
end
43 changes: 43 additions & 0 deletions src/Actions/CanCollideAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local Roact = require(script.Parent.Parent.Roact)

local DualAction = require(script.Parent.DualAction)

return function()
return Roact.createElement(DualAction, {
text = "CanCollide",

predicate = function(object)
return object:IsA("BasePart")
end,

onDisable = function(objects)
local count = 0

for _, descendant in objects do
if not descendant.CanCollide then
continue
end

descendant.CanCollide = false
count += 1
end

warn("[Asset Optimizer] CanCollide set to false for " .. count .. " objects")
end,

onEnable = function(objects)
local count = 0

for _, descendant in objects do
if descendant.CanCollide then
continue
end

descendant.CanCollide = true
count += 1
end

warn("[Asset Optimizer] CanCollide set to true for " .. count .. " objects")
end,
})
end
43 changes: 43 additions & 0 deletions src/Actions/CanQueryAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local Roact = require(script.Parent.Parent.Roact)

local DualAction = require(script.Parent.DualAction)

return function()
return Roact.createElement(DualAction, {
text = "CanQuery",

predicate = function(object)
return object:IsA("BasePart")
end,

onDisable = function(objects)
local count = 0

for _, descendant in objects do
if not descendant.CanQuery then
continue
end

descendant.CanQuery = false
count += 1
end

warn("[Asset Optimizer] CanQuery set to false for " .. count .. " objects")
end,

onEnable = function(objects)
local count = 0

for _, descendant in objects do
if descendant.CanQuery then
continue
end

descendant.CanQuery = true
count += 1
end

warn("[Asset Optimizer] CanQuery set to true for " .. count .. " objects")
end,
})
end
43 changes: 43 additions & 0 deletions src/Actions/CanTouchAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local Roact = require(script.Parent.Parent.Roact)

local DualAction = require(script.Parent.DualAction)

return function()
return Roact.createElement(DualAction, {
text = "CanTouch",

predicate = function(object)
return object:IsA("BasePart")
end,

onDisable = function(objects)
local count = 0

for _, descendant in objects do
if not descendant.CanTouch then
continue
end

descendant.CanTouch = false
count += 1
end

warn("[Asset Optimizer] CanTouch set to false for " .. count .. " objects")
end,

onEnable = function(objects)
local count = 0

for _, descendant in objects do
if descendant.CanTouch then
continue
end

descendant.CanTouch = true
count += 1
end

warn("[Asset Optimizer] CanTouch set to true for " .. count .. " objects")
end,
})
end
43 changes: 43 additions & 0 deletions src/Actions/CastShadowAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
local Roact = require(script.Parent.Parent.Roact)

local DualAction = require(script.Parent.DualAction)

return function()
return Roact.createElement(DualAction, {
text = "CastShadow",

predicate = function(object)
return object:IsA("BasePart")
end,

onDisable = function(objects)
local count = 0

for _, descendant in objects do
if not descendant.CastShadow then
continue
end

descendant.CastShadow = false
count += 1
end

warn("[Asset Optimizer] CastShadow set to false for " .. count .. " objects")
end,

onEnable = function(objects)
local count = 0

for _, descendant in objects do
if descendant.CastShadow then
continue
end

descendant.CastShadow = true
count += 1
end

warn("[Asset Optimizer] CastShadow set to true for " .. count .. " objects")
end,
})
end
74 changes: 74 additions & 0 deletions src/Actions/DualAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
local ChangeHistoryService = game:GetService("ChangeHistoryService")

local Roact = require(script.Parent.Parent.Roact)

local GetAffectedObjects = require(script.Parent.GetAffectedObjects)

return function(props)
return Roact.createElement("Frame", {
Size = UDim2.new(1, 0, 0, 32),

BackgroundTransparency = 1,
}, {
Off = Roact.createElement("TextButton", {
Size = UDim2.new(0.5, -5, 0, 32),
LayoutOrder = 1,

FontFace = Font.new(
"rbxasset://fonts/families/SourceSansPro.json",
Enum.FontWeight.Bold,
Enum.FontStyle.Normal
),
Text = props.text,
TextColor3 = Color3.fromRGB(255, 255, 255),
TextSize = 28,

BackgroundColor3 = Color3.fromRGB(255, 102, 102),
BorderSizePixel = 0,

[Roact.Event.MouseButton1Click] = function()
props.onDisable(GetAffectedObjects(props.predicate))
ChangeHistoryService:SetWaypoint("Asset Optimizer Action: " .. props.text)
end,
}, {
UICorner = Roact.createElement("UICorner"),

UIFlexItem = Roact.createElement("UIFlexItem", {
FlexMode = Enum.UIFlexMode.Fill,
}),
}),

On = Roact.createElement("TextButton", {
Size = UDim2.new(0.5, -5, 0, 32),

FontFace = Font.new(
"rbxasset://fonts/families/SourceSansPro.json",
Enum.FontWeight.Bold,
Enum.FontStyle.Normal
),
Text = props.text,
TextColor3 = Color3.fromRGB(255, 255, 255),
TextSize = 28,

BackgroundColor3 = Color3.fromRGB(38, 217, 100),
BorderSizePixel = 0,

[Roact.Event.MouseButton1Click] = function()
props.onEnable(GetAffectedObjects(props.predicate))
ChangeHistoryService:SetWaypoint("Asset Optimizer Action: " .. props.text)
end,
}, {
UICorner = Roact.createElement("UICorner"),

UIFlexItem = Roact.createElement("UIFlexItem", {
FlexMode = Enum.UIFlexMode.Fill,
}),
}),

UIListLayout = Roact.createElement("UIListLayout", {
Padding = UDim.new(0, 5),
FillDirection = Enum.FillDirection.Horizontal,
SortOrder = Enum.SortOrder.LayoutOrder,
}),
})
end
28 changes: 28 additions & 0 deletions src/Actions/GetAffectedObjects.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local Selection = game:GetService("Selection")

return function(predicate: (object: Instance) -> boolean)
local arrSelection = Selection:Get()
local nSelection = #arrSelection

local objects = {}

if nSelection == 1 then
for _, object in arrSelection[1]:GetDescendants() do
if not predicate(object) then
continue
end

table.insert(objects, object)
end
elseif nSelection > 1 then
for _, object in arrSelection do
if not predicate(object) then
continue
end

table.insert(objects, object)
end
end

return objects
end
21 changes: 21 additions & 0 deletions src/Actions/SelectMeshPartsAction.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
local Selection = game:GetService("Selection")

local Roact = require(script.Parent.Parent.Roact)

local SingleAction = require(script.Parent.SingleAction)

return function()
return Roact.createElement(SingleAction, {
text = "Select MeshParts",

predicate = function(object)
return object:IsA("MeshPart")
end,

onEnable = function(objects)
if #objects > 0 then
Selection:Set(objects)
end
end,
})
end
Loading

0 comments on commit 41aadb9

Please sign in to comment.