From 502f2ecdd51466374aa67c7934e6de8b9e054457 Mon Sep 17 00:00:00 2001 From: Anthony Headley <1986602+hossimo@users.noreply.github.com> Date: Sun, 17 May 2020 18:14:26 -0400 Subject: [PATCH 1/3] Now Accepts No Page/Seq Argument --- .../resource/lib_plugins/Fade Master.lua | 57 ++++++++++++------- .../resource/lib_plugins/Fade Master.xml | 2 +- 2 files changed, 38 insertions(+), 21 deletions(-) diff --git a/grandMA3/shared/resource/lib_plugins/Fade Master.lua b/grandMA3/shared/resource/lib_plugins/Fade Master.lua index 36562e0..db5a7e0 100644 --- a/grandMA3/shared/resource/lib_plugins/Fade Master.lua +++ b/grandMA3/shared/resource/lib_plugins/Fade Master.lua @@ -56,28 +56,45 @@ local function Main (display_handle, argument) local v = UserVars() local gVarName = "" - - if argument == nil or #arguments ~= 4 then - ErrPrintf("Incorrect number of arguments") - ErrPrintf("Plugin \"Fade Master\" \", , , \"") - return - end - - faderEnd = Drt.clamp(tonumber(arguments[3]), 0.0, 100.0) - faderTime = Drt.clamp(tonumber(arguments[4]), 0.0, 3600.0) - - if string.lower(arguments[1]):sub(1, 3) == "seq" then -- Operate on a Sequence - op = "Sequence" - destSeq = tonumber(arguments[2]) - elseif string.lower(arguments[1]):sub(1, 3) == "pag" then -- Operate on a Page - op = "Page" - local x = Drt.split(arguments[2], ".") - if #x == 2 then + if argument == nil then + elseif #arguments == 3 then + faderEnd = Drt.clamp(tonumber(arguments[2]), 0.0, 100.0) + faderTime = Drt.clamp(tonumber(arguments[3]), 0.0, 3600.0) + + local x = Drt.split(arguments[1], ".") + if #x == 1 then + op = "Sequence" + destSeq = tonumber(x[1]) + elseif #x == 2 then + op = "Page" destPage = tonumber(x[1]) destExec = tonumber(x[2]) else - ErrPrintf("Incorrect Page Identifier; Page.Ecexutor") + ErrPrintf("Incorrect Sequence/Page Identifier") + return end + elseif #arguments == 4 then + faderEnd = Drt.clamp(tonumber(arguments[3]), 0.0, 100.0) + faderTime = Drt.clamp(tonumber(arguments[4]), 0.0, 3600.0) + + if string.lower(arguments[1]):sub(1, 3) == "seq" then -- Operate on a Sequence + op = "Sequence" + destSeq = tonumber(arguments[2]) + elseif string.lower(arguments[1]):sub(1, 3) == "pag" then -- Operate on a Page + op = "Page" + local x = Drt.split(arguments[2], ".") + if #x == 2 then + destPage = tonumber(x[1]) + destExec = tonumber(x[2]) + else + ErrPrintf("Incorrect Page Identifier; Page.Ecexutor") + return + end + end + else + ErrPrintf("Incorrect number of arguments") + ErrPrintf("Plugin \"Fade Master\" \", , , \"") + return end @@ -122,9 +139,9 @@ local function Main (display_handle, argument) if faderTime > 0 and math.abs(distance) > 0 then if op == "Sequence" then - Printf("Running Fade Master on Sequence %d for %d Seconds. To abort fade execute - DelUserVar \"%s\"", destSeq, faderTime, gVarName) + Printf("Running Fade Master on Sequence %d for %d Seconds. To abort - DelUserVar \"%s\"", destSeq, faderTime, gVarName) elseif op == "Page" then - Printf("Running Fade Master on Page %d.%d for %d Seconds. To abort fade execute - DelUserVar \"%s\"", destPage, destExec, faderTime, gVarName) + Printf("Running Fade Master on Page %d.%d for %d Seconds. To abort - DelUserVar \"%s\"", destPage, destExec, faderTime, gVarName) end local interval = (distance * tick)/faderTime repeat diff --git a/grandMA3/shared/resource/lib_plugins/Fade Master.xml b/grandMA3/shared/resource/lib_plugins/Fade Master.xml index 3f42788..360d10a 100644 --- a/grandMA3/shared/resource/lib_plugins/Fade Master.xml +++ b/grandMA3/shared/resource/lib_plugins/Fade Master.xml @@ -1,6 +1,6 @@ - + From e322d66e6ef0734178c3bc8245fda96e0ec8b2f2 Mon Sep 17 00:00:00 2001 From: Anthony Headley <1986602+hossimo@users.noreply.github.com> Date: Sun, 17 May 2020 19:15:19 -0400 Subject: [PATCH 2/3] Added Dialog, better input checking --- README.md | 2 +- .../resource/lib_plugins/Fade Master.lua | 87 ++++++++++++++++++- .../lib_plugins/Fade Master/README.md | 11 ++- 3 files changed, 92 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5b91f3d..07630c2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Download the latest release [here](https://github.com/hossimo/GMA3Plugins/releas * [Copy Screenshots 1.0.0.3](https://github.com/hossimo/GMA3Plugins/tree/master/grandMA3/shared/resource/lib_plugins/Copy%20Screenshots) * [Assign AutoStart Fix 1.0.0.3](https://github.com/hossimo/GMA3Plugins/tree/master/grandMA3/shared/resource/lib_plugins/Assign%20AutoStart%20Fix) * [Rem Dim 1.1.0.1](https://github.com/hossimo/GMA3Plugins/tree/master/grandMA3/shared/resource/lib_plugins/Rem%20Dim) -* [Fade Master 1.1.0.1](https://github.com/hossimo/GMA3Plugins/tree/master/grandMA3/shared/resource/lib_plugins/Fade%20Master) +* [Fade Master 1.1.0.2](https://github.com/hossimo/GMA3Plugins/tree/master/grandMA3/shared/resource/lib_plugins/Fade%20Master) ### Source not released * [Kinetic Set 1.0.0.1](https://github.com/hossimo/GMA3Plugins/tree/master/grandMA3/shared/resource/lib_plugins/KineticSet) diff --git a/grandMA3/shared/resource/lib_plugins/Fade Master.lua b/grandMA3/shared/resource/lib_plugins/Fade Master.lua index db5a7e0..9bef692 100644 --- a/grandMA3/shared/resource/lib_plugins/Fade Master.lua +++ b/grandMA3/shared/resource/lib_plugins/Fade Master.lua @@ -46,6 +46,8 @@ local my_handle = select(4,...); local function Main (display_handle, argument) local arguments = Drt.split(argument, ",") local tick = 1/30 -- updates / second + local MAXTIME = 3600.0 -- the max number of seconds + local MAXPOOL = 9999 -- the max number of pool items local op = "" -- the object we are operating on local destPage -- the page asked for local destExec -- the executor on the page @@ -56,10 +58,54 @@ local function Main (display_handle, argument) local v = UserVars() local gVarName = "" + -- Grab inputs based on the number of arguments + -- we will validate them later. if argument == nil then + -- ask through dialog + local messageBoxInputs = { + "Page.Exec # or\nSequence #", + "Level (%)", + "Time (S)" + } + + local messageBoxOptions = { + title="Fade Master Options", + message="", + commands = { + {value=0, name="Cancel"}, + {value=1, name="OK"} + }, + inputs = { + {name=messageBoxInputs[1], vkPlugin="TextInputNumOnlyRange"}, + {name=messageBoxInputs[2], vkPlugin="TextInputNumOnlyRange"}, + {name=messageBoxInputs[3], vkPlugin="TextInputNumOnlyRange"} + } + } + local result = MessageBox(messageBoxOptions) + if result.result == 0 then + return + end + + local x = Drt.split(result.inputs[messageBoxInputs[1]], ".") + if #x == 1 then + op = "Sequence" + destSeq = tonumber(x[1]) + elseif #x == 2 then + op = "Page" + destPage = tonumber(x[1]) + destExec = tonumber(x[2]) + else + ErrPrintf("Incorrect Sequence/Page Identifier") + return + end + + faderEnd = result.inputs[messageBoxInputs[2]] + faderTime = result.inputs[messageBoxInputs[3]] + elseif #arguments == 3 then - faderEnd = Drt.clamp(tonumber(arguments[2]), 0.0, 100.0) - faderTime = Drt.clamp(tonumber(arguments[3]), 0.0, 3600.0) + -- [1]page/seq [2]level [3]time + faderEnd = tonumber(arguments[2]) + faderTime = tonumber(arguments[3]) local x = Drt.split(arguments[1], ".") if #x == 1 then @@ -74,8 +120,9 @@ local function Main (display_handle, argument) return end elseif #arguments == 4 then - faderEnd = Drt.clamp(tonumber(arguments[3]), 0.0, 100.0) - faderTime = Drt.clamp(tonumber(arguments[4]), 0.0, 3600.0) + -- [1]"Page"/"Seq" [2]page/seqID [3]level [4]time + faderEnd = tonumber(arguments[3]) + faderTime = tonumber(arguments[4]) if string.lower(arguments[1]):sub(1, 3) == "seq" then -- Operate on a Sequence op = "Sequence" @@ -98,6 +145,38 @@ local function Main (display_handle, argument) end + -- check our inputs + if tonumber(faderEnd) == nil then + ErrPrintf("Incorrect level, Enter a value between 0.0 and 100.0") + return + else + faderEnd = Drt.clamp(tonumber(faderEnd), 0.0, 100.0) + end + if tonumber(faderEnd) == nil then + ErrPrintf("Incorrect time, Enter Seconds between 0.0 and " .. MAXTIME) + return + else + faderTime = Drt.clamp(tonumber(faderTime), 0.0, MAXTIME) + end + + if op == "Sequence" then + if destSeq == nil then + Printf("Invalid Page Number, Enter a number between 1 and " .. MAXPOOL) + else + destSeq = Drt.clamp(destSeq, 1, MAXPOOL) + end + elseif op == "Page" then + if destPage == nil then + Printf("Invalid Sequence Number, Enter a number between 1 and " .. MAXPOOL) + else + destPage = Drt.clamp(destPage, 1, MAXPOOL) + end + if destExec == nil then + Printf("Invalid Executor Number, Enter a Page.Executor, e.g: 1.201") + end + end + + -- setup exec and UserVars if op == "Sequence" then gVarName = "FM".."S"..destSeq execObject = DataPool().sequences:Children()[destSeq] diff --git a/grandMA3/shared/resource/lib_plugins/Fade Master/README.md b/grandMA3/shared/resource/lib_plugins/Fade Master/README.md index f522118..32c80c3 100644 --- a/grandMA3/shared/resource/lib_plugins/Fade Master/README.md +++ b/grandMA3/shared/resource/lib_plugins/Fade Master/README.md @@ -1,5 +1,5 @@ # Fade Master -*v1.1.0.1* +*v1.1.0.2* Please note that this will likly break in future version of the console. and to use at your own risk. ![Fade Master Example](../../../../../Images/FadeMaster.gif) @@ -9,10 +9,14 @@ Allows you to automate a Executor or Sequence Fader movement over time. In grandMA 2 you could do `ExecButton 1.1 At 100 Fade 3` With this plugin you can do: -'Plugin "Fade Master" "Page,1.201,100,3"' Which fade executor 1.201 from its current value to 100% over 3 seconds. +`Plugin "Fade Master" "Page,1.201,100,3"` Which fade executor 1.201 from its current value to 100% over 3 seconds. You also can do the following: -'Plugin "Fade Master" "Sequence,4,100,3"' Which Sequence 4 from its current value to 100% over 3 seconds. The executor does not even need to be assigned to an executor or an executor with a master. +`Plugin "Fade Master" "Sequence,4,100,3"` Which Sequence 4 from its current value to 100% over 3 seconds. The executor does not even need to be assigned to an executor or an executor with a master. + +Added in v1.1.0.2: +* `Plugin "Fade Master"` (without arguments) and a dialog with options will be displayed +* No longer need `Page` or `Sequence` arguments, if you enter a number with a `.` it will be a page and without a sequence. Additionally, if you have a long running fade that you need to abort you can delete the User Vraiable and the fade will stop. @@ -46,3 +50,4 @@ Additionally, if you have a long running fade that you need to abort you can del ### Releases: - 1.1.0.1 - Inital Release +- 1.1.0.2 - Added no argument dialog, and some additional sanity checking. \ No newline at end of file From f363a6e6ffe2338eb2b021f1999e65e05853b853 Mon Sep 17 00:00:00 2001 From: Anthony Headley <1986602+hossimo@users.noreply.github.com> Date: Sat, 23 May 2020 10:31:46 -0400 Subject: [PATCH 3/3] Drt-Utilities cleanup * printClass isn't required for plugins * printClass isn't fully baked * Ignoring default plugins again since the upgrade. --- .gitignore | 7 +- .vscode/settings.json | 3 +- .../resource/lib_plugins/Drt-Utilities.lua | 187 +----------------- 3 files changed, 11 insertions(+), 186 deletions(-) diff --git a/.gitignore b/.gitignore index d3b1027..e63e5ba 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,9 @@ TestBed/ _Template/ grandMA3/shared/resource/lib_plugins/KineticSet/KineticSet.Lua grandMA3/shared/resource/lib_plugins/KineticSet/KineticSet.xml -pvt_* \ No newline at end of file +pvt_* +grandMA3/shared/resource/lib_plugins/hardwaretests +grandMA3/shared/resource/lib_plugins/performance3d +grandMA3/shared/resource/lib_plugins/requirements +grandMA3/shared/resource/lib_plugins/systemtests +grandMA3/shared/resource/lib_plugins/examples diff --git a/.vscode/settings.json b/.vscode/settings.json index 6da91b8..298d6f1 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -107,6 +107,7 @@ "GetDMXUniverse", "Timer", "GetTokenNameByIndex", - "GetAttributeCount" + "GetAttributeCount", + "CurrentExecPage" ] } diff --git a/grandMA3/shared/resource/lib_plugins/Drt-Utilities.lua b/grandMA3/shared/resource/lib_plugins/Drt-Utilities.lua index 26abcb1..e827700 100644 --- a/grandMA3/shared/resource/lib_plugins/Drt-Utilities.lua +++ b/grandMA3/shared/resource/lib_plugins/Drt-Utilities.lua @@ -26,7 +26,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --]] -Drt = {} +if Drt == nil then + Drt = {} +end -- **************************************************************** -- Drt.split(string, string) : table @@ -321,189 +323,6 @@ function Drt.calculateRange(input) end end --- **************************************************************** --- Drt.printClass(userdata) : nil --- **************************************************************** -function Drt.printClass(input, level) - level = math.abs(math.floor(level or 0)) - assert(input ~= nil, "input must not be nil") - assert(level == nil or type(level) == "number", "level must be number or nil") - - if type(input) ~= "userdata" then - if type(input) == "table" then - Echo(Drt.table2String(input)) - elseif type(input) == "string" then - Echo(input) - elseif type(input) == "number" then - Echo(input) - else - Echo ("Not UserData: " .. type(input)) - end - return - end - - local indent = "" - if level > 0 then - for i = 1, level, 1 do - indent = indent .. " " - end - end - - local class = input:GetClass() - Echo(indent .. "Class: " .. class) - Echo(indent .. "Parent: " .. (input:Parent():GetClass())) --TODO: This fails if no parent - local childCount = #input:Children() - Echo(indent .. "ChildCount: " .. childCount) - if childCount > 0 then - for i = 1, childCount, 1 do - Echo(indent .. " " .. i .. " " .. input:Children()[i]:GetClass()) - end - end - local properties = {} - - --Exec - if class == "Exec" then - properties = { - "Lock", - "No", - "Index", - "Name", - "Key", - "Fader", - "Encoder", - "EncoderLeft", - "EncoderRight", - "KeyCmd", - "EncoderClickCMD", - "EncoderRightCMD", - "EncoderLeftCMD", - "MAKey", - "MAFader", - "MAEncoder", - "MAEncoderLeft", - "MAEncoderRight", - "MAKeyCmd", - "MAEncoderClickCMD", - "MAEncoderRightCMD", - "MAEncoderLeftCMD", - "PrimanyAssignmentChanged", - "SecondaryAssignmentChanged", - "Width", - "Height", - "Object", - "Config", - "TotalPrimanyAssignmentChanged", - "TotalSecondaryAssignmentChanged", - } - end - - --Page - if class == "Page" then - properties = { - "Lock", - "No", - "Index", - "Name", - "Scribble", - "Appearance" - } - end - -- Attribute - if class == "Attribute" then - properties = { - "Name", - "Pretty", - "MainAttribute", - "ActivationGroup", - "Feature", - "Special", - "PhysicalUnit", - "GeometryType", - "Color", - "Intensity", - "LogChannels", - "ChannelFunctions" - } - -- Patch - elseif class == "Patch" then - properties = { - "Name", - "Lock" - } - -- AttributeDefinitions - elseif class == "AttributeDefinitions" then - properties = { - "Name", - "Lock", - } - -- Feature - elseif class == "Feature" then - properties = { - "Name", - "Pretty", - "AttribCount", - "LogChannels", - } - -- ActivationGroup - elseif class == "ActivationGroup" then - properties = { - "Name", - "AttribCount" - } - elseif class == "Attributes" then - properties = { - "Name", - "AttribCount" - } - elseif class == "FeatureGroup" then - properties = { - "Name", - "Pretty", - "PresetMode", - "AttribCount", - "LogChannels", - } - elseif class == "UserProfile" then - properties = { - "Name", - "Lock", - "DMXReadout", - "NormalValue", - "ValueReadout", - "SpeedReadout", - "PresetReadout", - "WheelResolution", - "WheelMode", - "PerciseEdit", - "SingleStep", - "Sync", - "Preview", - "ScreenEncoder", - "TimeKeyTarget", - "ProgPart", - "TCSlot", - "OverlayFade", - } - else - Echo("") - end - - for key, value in pairs(properties) do - local i = input[value] - if type(i) == "boolean" then - if i == true then - i = "true" - else - i = "false" - end - end - Echo("%s%s: %s (%s)", indent, value, tostring(i or ""), type(input[value])) - if type(i) == "userdata" then - Drt.printClass(i, level + 1) - end - end -end - function Drt.table2String(input) if type(input) == "boolean" then if input == true then