Commit ff367e4a authored by Pieter Van Houte's avatar Pieter Van Houte

Adding Alexey Bogomolov's Saver Tools

com.AlexBogomolov.LoaderFromSaver and com.AlexBogomolov.SaverManager
parent c040f433
local ctrls = table.ordered()
comp:Lock()
saver_plus = comp:AddTool('Saver', -32768, -32768)
ctrls.ML = {
LINKID_DataType = "Number",
INP_Default = 0,
INPID_InputControl = "ButtonControl",
BTNCS_Execute = [[ tool = comp.ActiveTool; comp:RunScript("Scripts:Comp/Saver Tools/LoaderFromSaver.lua", tool) ]],
LINKS_Name = "Make Loader",
ICS_ControlPage = "File",
}
saver_plus.UserControls = ctrls
comp:Unlock()
refresh = saver_plus:Refresh()
savers = comp:GetToolList(true, 'Saver')
function Set(list)
local set = {}
for _, element in ipairs(list) do
set[element] = true
end
return set
end
function set_loader(name, tool)
local flow = comp.CurrentFrame.FlowView
x, y = flow:GetPos(tool)
local loader = comp:Loader({ Clip = name })
flow:SetPos(loader, x+1, y)
end
if (#savers) == 0 then
print('select some savers')
else
comp:Lock()
-- comp:StartUndo('loader from saver script')
for _, tool in ipairs(savers) do
selected_clipname = tool:GetAttrs()["TOOLST_Clip_Name"][1]
seq = string.match(selected_clipname, '(%d+)%..+$')
-- if pattern 0000.ext$ is found set selected name
-- otherwice replace extention with 0000-extention
if seq then
set_loader(selected_clipname, tool)
else
name, ext = string.match(selected_clipname,'([^/]-([^.]+))$')
local file_exts = Set{'mp4', 'mov', 'avi', 'mxf'}
-- if saver file format is container, use original name
if file_exts[ext] then
set_loader(selected_clipname, tool)
-- append zero padding for sequence filename
else
local new_name = selected_clipname:gsub('.'..ext, '0000.'..ext)
set_loader(new_name, tool)
end
end
end
-- comp:EndUndo()
comp:Unlock()
end
Atom {
Name = "Loader from Saver",
Category = "Scripts/Comp",
Author = "Alexey Bogomolov",
Version = 1.2,
Date = {2019, 3, 29},
Description = [[<p>Literally create Loader from Saver. Works with multiple savers. Loader is created next to the Saver's position.</p>
<p><i>Features:</i></p>
<ul>
<li>If the Saver has image sequence with no number padding &#91; <code>0000</code> &#93;, default padding is created.
</li>
<li>If the file is a container (mov, avi, mp4, mxf) — original name is used. </li>
<li>Launch this scripts with Saver Manager UI tool (available in Reactor)</li>
</ul>
<p>Thanks @Egert#6282 from PoC for the idea and initial algorithm.</p>
]],
Deploy = {
"Scripts/Comp/Saver Tools/LoaderFromSaver.lua",
"Scripts/Comp/Saver Tools/CreateSaverPlus.lua",
},
}
local ui = fu.UIManager
local disp = bmd.UIDispatcher(ui)
local width,height = 250,110
app:AddConfig("SManager", {
Target {
ID = "SManager",
},
Hotkeys {
Target = "SManager",
Defaults = true,
ESCAPE = "Execute{cmd = [[app.UIManager:QueueEvent(obj, 'Close', {})]]}",
},
})
win = disp:AddWindow({
ID = 'SManage',
TargetID = 'SManager',
WindowTitle = 'Manage Savers',
Geometry = {100, 400, width, height},
Spacing = 5,
ui:VGroup{
ID = 'root',
-- Add your GUI elements here:
ui:HGroup{VMargin = 10,
ui:Button{ID = 'Disable', Text = 'Solo Selected',},
ui:Button{ID = 'Enable', Text = 'Enable All',},
},
ui:VGroup{
ui.Button{ID= 'SelectAll', Text = 'Select All Savers'}
},
ui:VGroup{
ui.Button{ID= 'CreateLoaders', Text = 'Create Loaders'}
}
},
})
-- The window was closed
function win.On.SManage.Close(ev)
disp:ExitLoop()
end
-- Add your GUI element based event functions here:
-- itm = win:GetItems()
function check_selected(tool)
return tool:GetAttrs('TOOLB_Selected')
end
function check_enabled(tool)
return tool:GetAttrs('TOOLB_PassThrough')
end
function win.On.Disable.Clicked(ev)
local cmp = fu:GetCurrentComp()
local selectedSavers = cmp:GetToolList(true, "Saver")
local allSavers = cmp:GetToolList(false, "Saver")
for _, currentSaver in pairs(allSavers) do
if not check_selected(currentSaver) then
currentSaver:SetAttrs( { TOOLB_PassThrough = true } )
end
end
for _, sel in pairs(selectedSavers) do
if check_enabled(sel) then
sel:SetAttrs({ TOOLB_PassThrough = false})
end
end
end
function win.On.Enable.Clicked(ev)
local cmp = fu:GetCurrentComp()
local allSavers = cmp:GetToolList(false, "Saver")
for i, currentSaver in pairs(allSavers) do
currentSaver:SetAttrs( { TOOLB_PassThrough = false } )
end
end
function win.On.SelectAll.Clicked(ev)
local cmp = fu:GetCurrentComp()
local allSavers = cmp:GetToolList(false, "Saver")
flow = cmp.CurrentFrame.FlowView
for _, sav in pairs(allSavers) do
flow:Select(sav)
end
end
function win.On.CreateLoaders.Clicked(ev)
local cmp = fu:GetCurrentComp()
cmp:RunScript('Scripts:Comp/Saver Tools/LoaderFromSaver.lua')
end
win:Show()
disp:RunLoop()
win:Hide()
Atom {
Name = "Saver Manager",
Category = "Scripts/Comp",
Author = "Alexey Bogomolov",
Version = 1,
Date = {2019, 3, 26},
Description = [[<p>UI script for basic saver management:</p>
<p><i>Features:</i></p>
<ul>
<li>disable unselected savers</li>
<li>enable all</li>
<li>select all savers</li>
<li>create loaders from savers button</li>
</ul>
]],
Deploy = {
"Scripts/Comp/Saver Tools/Saver_Manager.lua",
},
Dependencies = {
"com.AlexBogomolov.LoaderFromSaver",
},
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment