Human being with feelings
Join Date: Jun 2012
Posts: 2,173
|
This one is for setting fader color without changing main layout type. It uses an input box and some hotkeys to be capable of doing all the colors in one action. You can put a ? in the box to get a reminder message of what the hotkeys are. By default it will do both TCP and MCP at once. If you put one space before the hotkey it will skip the TCP, one at the end it will skip the MCP. Weird? Unregistered characters (including blank box+ENTER key) will cause reset to no color. Cancel button will abort script.
Code:
-- layout - set selected tracks fader colors by input.lua
clear_defaults = true -- reset layout matching screenset default to "" or no layout
skip_TCP_Separator = true -- skip if tcp is this
skip_Long_Name = true -- skip if tcp is this
skip_Shy_Meter = true -- skip if tcp is this
skip_Tracking = true -- skip if tcp is this
skip_MCP_Separator = true -- skip if mcp is this
skip_FX_Racks = true -- skip if mcp is this
skip_Sidebars = true -- skip if mcp is this
-- You can edit the first string in "" in each line below to provide shortcuts to enter in the input box.
-- Anything else (including empty box) will reset track to no fader color
-- Use Cancel button to abort script.
function Fn_Hotkeys(hotkey) -- << Don't edit this line
if hotkey == "?" then help = true -- show message box
elseif hotkey == "dc" then fader_color = "DC" -- default (colorless) fader
elseif hotkey == "b" then fader_color = "Blue"
elseif hotkey == "gr" then fader_color = "Green"
elseif hotkey == "g" then fader_color = "Gold"
elseif hotkey == "red" then fader_color = "Red"
elseif hotkey == "r" then fader_color = "Rose"
elseif hotkey == "w" then fader_color = "White"
else
fader_color = ""
end
end
-- Edit only between "". Leave back slash after each line
help_msg = "One space at start to prevent TCP change\
One space at end to prevent MCP change\
Undefined characters reset to no color\
For example: asdf[SPACE] resets TCP only\
\
HOTKEYS (Edit script thru action list)\
---------------\
dc = default colorless\
b = Blue\
gr = Green\
g = Gold\
red = Red\
r = Rose\
w = White\
" -- end of help message
-- END OF EDITABLE PART ---------------------------------------------------------
function Fn_Get_Default_Layouts()
local inipath = reaper.get_ini_file()
r1, def_tcp = reaper.BR_Win32_GetPrivateProfileString("reaper", "layout_tcp", "Error", inipath)
def_tcp_color = string.find(def_tcp," - ",1,true)
if def_tcp_color then
def_tcp_panel = string.sub(def_tcp, 1, def_tcp_color-1)
def_tcp_color = string.sub(def_tcp, def_tcp_color, #def_tcp)
else
def_tcp_panel = def_tcp
def_tcp_color = ""
end
r2, def_mcp = reaper.BR_Win32_GetPrivateProfileString("reaper", "layout_mcp", "Error", inipath)
def_mcp_color = string.find(def_mcp," - ",1,true)
if def_mcp_color then
def_mcp_panel = string.sub(def_mcp, 1, def_mcp_color-1)
def_mcp_color = string.sub(def_mcp, def_mcp_color, #def_mcp)
else
def_mcp_panel = def_mcp
def_mcp_color = ""
end
--return def_tcp_panel, def_tcp_color, def_mcp_panel, def_mcp_color
end
function Fn_Set_Layouts()
Fn_Get_Default_Layouts()
reaper.Undo_BeginBlock2(0)
reaper.PreventUIRefresh(1)
local cst = reaper.CountSelectedTracks(0)
for c=1,cst do
local trk = reaper.GetSelectedTrack(0, c-1)
r1,tcp = reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", "", false)
r2,mcp = reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", "", false)
ok = true
if skip_TCP_Separator == true and string.find(tcp,"Separator",1,true) then ok = nil
elseif skip_Long_Name == true and string.find(tcp,"Long Name",1,true) then ok = nil
elseif skip_Shy_Meter == true and string.find(tcp,"Shy Meter",1,true) then ok = nil
elseif skip_Tracking == true and string.find(tcp,"Tracking",1,true) then ok = nil
elseif skip_MCP_Separator == true and string.find(mcp,"Separator",1,true) then ok = nil
elseif skip_FX_Racks == true and string.find(mcp,"FX Rack",1,true) then ok = nil
elseif skip_Sidebars == true and string.find(mcp,"Sidebar",1,true) then ok = nil
end
if ok then
if not skip_tcp then
tcp_color = string.find(tcp," - ",1,true)
if tcp_color then tcp = string.sub(tcp, 1, tcp_color-1) end
if fader_color ~= "" then
if tcp == "" then tcp = def_tcp_panel end
if fader_color ~= "DC" then
tcp = tcp.." - "..fader_color.." Fader"
end
else
if tcp == "" then tcp = def_tcp_panel end
tcp = tcp..def_tcp_color
end
if tcp == def_tcp and clear_defaults == true then tcp = "" end
reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", tcp, true)
end
if not skip_mcp then
mcp_color = string.find(mcp," - ",1,true)
if mcp_color then mcp = string.sub(mcp, 1, mcp_color-1) end
if fader_color ~= "" then
if mcp == "" then mcp = def_mcp_panel end
if fader_color ~= "DC" then
mcp = mcp.." - "..fader_color.." Fader"
end
else
if mcp == "" then mcp = def_mcp_panel end
mcp = mcp..def_mcp_color
end
if mcp == def_mcp and clear_defaults == true then mcp = "" end
reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", mcp, true)
end
end
end
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock2(0, "set layout", -1)
end
-------------------------------------------------------------------------
gui, s = reaper.GetUserInputs("Fader Colors (?=Help)", 1, "Hotkey", "")
s = string.gsub(s, ",", "")
if string.sub(s, 1, 1) == " " then
skip_tcp = true
s = string.sub(s, 2, #s)
end
if string.sub(s, #s, #s) == " " then
skip_mcp = true
s = string.sub(s, 1, #s-1)
end
if gui then
Fn_Hotkeys(s)
if not help then
Fn_Set_Layouts()
else
reaper.MB(help_msg,"Set Fader Colors",0)
end
end
I will probably put the selection in here too eventually.
Next ones are templates for set main layout keeping fader color. One for TCP. One for MCP.
Code:
-- layout - set selected tracks TCP layout to Condensed - keep fader color.lua
main_layout = "Condensed" -- this script for TCP layouts only
clear_defaults = true -- reset layout matching screenset default to "" or no layout
skip_Separator = true -- these check TCP layout only
skip_Long_Name = true
skip_Shy_Meter = true
skip_Tracking = true
---------------------------------------------------------------------------------------------------------------
function Fn_Get_Default_Layouts()
local inipath = reaper.get_ini_file()
local r, s = reaper.BR_Win32_GetPrivateProfileString("reaper", "layout_tcp", "Error", inipath)
return s
end
function Fn_Set_TCP_Layout()
def_tcp = Fn_Get_Default_Layouts()
reaper.Undo_BeginBlock2(0)
reaper.PreventUIRefresh(1)
local cst = reaper.CountSelectedTracks(0)
for c=1,cst do
local ok = true
local trk = reaper.GetSelectedTrack(0, c-1)
local r,s = reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", "", false)
if skip_Separator == true and string.find(s,"Separator",1,true) then ok = nil
elseif skip_Long_Name == true and string.find(s,"Long Name",1,true) then ok = nil
elseif skip_Shy_Meter == true and string.find(s,"Shy Meter",1,true) then ok = nil
elseif skip_Tracking == true and string.find(s,"Tracking",1,true) then ok = nil
end
if ok then
local tcp_color = string.find(s," - ",1,true)
if tcp_color then s = string.sub(s, tcp_color, #s) else s = "" end
s = main_layout..s
if s == def_tcp and clear_defaults == true then s = "" end
reaper.GetSetMediaTrackInfo_String(trk, "P_TCP_LAYOUT", s, true)
end
end
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock2(0, "set TCP layout", -1)
end
Fn_Set_TCP_Layout()
Code:
-- layout - set selected tracks MCP layout to Narrow - keep fader color.lua
main_layout = "Narrow" -- this script for MCP layouts only
clear_defaults = true -- reset layout matching screenset default to "" or no layout
skip_MCP_Separator = true -- skip if mcp is this
skip_FX_Racks = true -- skip if mcp is this
skip_Sidebars = true -- skip if mcp is this
---------------------------------------------------------------------------------------------------------------
function Fn_Get_Default_Layouts()
local inipath = reaper.get_ini_file()
local r, s = reaper.BR_Win32_GetPrivateProfileString("reaper", "layout_mcp", "Error", inipath)
return s
end
function Fn_Set_MCP_Layout()
def_mcp = Fn_Get_Default_Layouts()
reaper.Undo_BeginBlock2(0)
reaper.PreventUIRefresh(1)
local cst = reaper.CountSelectedTracks(0)
for c=1,cst do
local ok = true
local trk = reaper.GetSelectedTrack(0, c-1)
local r,s = reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", "", false)
if skip_MCP_Separator == true and string.find(s,"Separator",1,true) then ok = nil
elseif skip_FX_Racks == true and string.find(s,"FX Rack",1,true) then ok = nil
elseif skip_Sidebars == true and string.find(s,"Sidebar",1,true) then ok = nil
end
if ok then
local mcp_color = string.find(s," - ",1,true)
if mcp_color then s = string.sub(s, mcp_color, #s) else s = "" end
s = main_layout..s
if s == def_mcp and clear_defaults == true then s = "" end
reaper.GetSetMediaTrackInfo_String(trk, "P_MCP_LAYOUT", s, true)
end
end
reaper.PreventUIRefresh(-1)
reaper.Undo_EndBlock2(0, "set MCP layout", -1)
end
Fn_Set_MCP_Layout()
Last edited by FnA; 04-10-2016 at 09:39 PM.
|