Skip to content

Commit

Permalink
Added Dialog, better input checking
Browse files Browse the repository at this point in the history
  • Loading branch information
hossimo committed May 17, 2020
1 parent 502f2ec commit e322d66
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
87 changes: 83 additions & 4 deletions grandMA3/shared/resource/lib_plugins/Fade Master.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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"
Expand All @@ -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]
Expand Down
11 changes: 8 additions & 3 deletions grandMA3/shared/resource/lib_plugins/Fade Master/README.md
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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.
Expand Down Expand Up @@ -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.

0 comments on commit e322d66

Please sign in to comment.