Repository navigation
Expand file tree
/
Copy pathloader.server.lua
More file actions
81 lines (69 loc) · 2.17 KB
/
Copy pathloader.server.lua
File metadata and controls
81 lines (69 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
-- Use the toolbar combiner?
local COMBINE_TOOLBAR = false
local createSharedToolbar = require(script.Parent.Packages.createSharedToolbar)
local Signal = require(script.Parent.Packages.Signal)
local RIBBON_ICON = "rbxassetid://80143782498054"
local TOOLTIP = "Activate RailTypes' fork of the Redupe plugin, opening the settings panel and activating the duplication dragger."
local setButtonActive: (active: boolean) -> () = nil
local buttonClicked = Signal.new()
if COMBINE_TOOLBAR then
local toolbarSettings: createSharedToolbar.SharedToolbarSettings = {
ButtonName = "Redupe-RT",
ButtonTooltip = TOOLTIP,
ButtonIcon = RIBBON_ICON,
ToolbarName = "GeomTools",
CombinerName = "GeomToolsToolbar",
ClickedFn = function()
buttonClicked:Fire()
end,
}
createSharedToolbar(plugin, toolbarSettings)
function setButtonActive(active: boolean)
assert(toolbarSettings.Button):SetActive(active)
end
else
local toolbar = plugin:CreateToolbar("Redupe-RT")
local button = toolbar:CreateButton("openRedupeRT", TOOLTIP, RIBBON_ICON, "Redupe-RT")
local clickCn = button.Click:Connect(function()
buttonClicked:Fire()
end)
function setButtonActive(active: boolean)
button:SetActive(active)
end
plugin.Unloading:Connect(function()
clickCn:Disconnect()
end)
end
-- Create the dockable panel
local params = DockWidgetPluginGuiInfo.new(
Enum.InitialDockState.Float,
false, -- Is it initially enabled
false, -- Override the previous state
240, -- Default width
200, -- Default height
240, -- Minimum width
200 -- Minimum height
)
local panel = plugin:CreateDockWidgetPluginGuiAsync("RedupeRTPanel", params)
local loaded = false
local function doInitialLoad()
loaded = true
require(script.Parent.Src.main)(plugin, panel, buttonClicked, setButtonActive)
end
-- Lazy load the main plugin on first click
local clickedCn = buttonClicked:Connect(function()
if not loaded then
doInitialLoad()
-- Refire event now that the plugin is listening
buttonClicked:Fire()
end
end)
panel.Name = "RedupeRTPanel"
panel.Title = "Redupe-RT"
panel.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
if panel.Enabled then
doInitialLoad()
end
plugin.Deactivation:Connect(function()
clickedCn:Disconnect()
end)