Viz Scripts


SETY

structure onoffcontainer
 dYDiff as double
 sContainerName as string
end structure
dim sListContainerName = (string) "SET_Y"
dim bMultipages = (boolean) true
dim sPagePrefix = (string) "ONOFF_PAGE_" 
dim sLinesDomain = (string) "LINES"
dim iMaxLine = (Integer) scene.findcontainer(sPagePrefix&"1").findsubcontainer(sLinesDomain).ChildContainerCount
dim iLineNumber = (integer) 4
dim sLinePrefix = (string) "LINE_"
dim arrOnOff as array[onoffcontainer]
'max site differences when elements are “ON”
dim dYBase = 0
'dim dYDiff = scene.findcontainer(sPagePrefix&"1").findsubcontainer("LINE_1").GetBoundingBoxDimensions()[1]
dim dYDiff = (double) 27
sub OnInitParameters() 
RegisterParameterString("linenumber", "Line Number:","10",40,40,"")
RegisterPushButton("sety","Set List Y", 1) 
end sub
sub OnExecAction(buttonId As Integer)
iLineNumber = CInt(GetParameterString("linenumber")) 
VizCommunication.map["iLineNumber"] = CStr(iLineNumber)
TreatLines()
end sub
sub SetNumberOfLines(num As String)
 iLineNumber = CInt(num)
 VizCommunication.map["iLineNumber"] = iLineNumber
 Println "iLineNumber"
 Println iLineNumber
 TreatLines()
end sub
sub TreatLines() 
 VizCommunication.map["iMaxLine"] = CStr(iMaxLine)
 arrOnOff.Clear() 
 'iMaxLine = CInt(GetParameterString("maxline"))
 'dYBase = 0
 'dYDiff = CDbl(GetParameterString("lineheight")) 
 For i = 1 to iLineNumber
 'Println i
 dim sI = (string) i
 dim oLine as onoffcontainer
 'oLine.dYDiff = dYDiff
 'oLine.dOffset = dOffset
 oLine.sContainerName = sLinePrefix&i
 arrOnOff.push(oLine)
 Println "i dYDiff"
 Println dYDiff
 Next
dim cMainContainer = (container) scene.findcontainer(sListContainerName)
 dim cBaseContainer as container 
 dim j = (integer) 0
 for j=1 to iMaxLine
 Println "j = "&j 
 Println "j dYDiff"
 Println dYDiff
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_1").findsubcontainer(sLinePrefix&j)
 cBaseContainer.active = false
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_2").findsubcontainer(sLinePrefix&j)
 cBaseContainer.active = false
 Next 
 dim i = (integer) 0
 for i=1 to iLineNumber 
 Println "sLinePrefix&i = "&sLinePrefix&i
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_1").findsubcontainer(sLinePrefix&i)
 cBaseContainer.active = true
 cBaseContainer = (container) scene.findcontainer("ONOFF_PAGE_2").findsubcontainer(sLinePrefix&i)
 cBaseContainer.active = true
 Next 
 
 'cMainContainer.position.y = 0
 
 dim dYBaseTemp = 0.0
 cMainContainer.position.y = -((iMaxLine-iLineNumber)*dYDiff)
'next
end sub

PAGE

sub OnInitParameters()
 RegisterParameterString("director", "Director:","PAGE_",40,40,"")
 RegisterPushButton("continue","If director is not timed at zero then continue",1)
end sub
sub OnExecAction(buttonId As Integer)
 dim dDirPage=stage.finddirector(getparameterstring("director"))
 if dDirPage.time > 0 then dDirPage.continueanimation()
 
 dim dDirFooter=stage.finddirector(getparameterstring("director")&"_FOOTER")
 if dDirFooter.time > 0 then dDirFooter.continueanimation()
end sub

FOOTER

structure onoffcontainer
 dOffset as double
 sContainerName as string
end structure
structure linecontainer
 dOffset as double
 sLineContainerName as string
end structure
dim iLineNumber = (integer)VizCommunication.map["iLineNumber"]
 dim iLineTotal = (integer)VizCommunication.map["iMaxLine"]
 dim sLinePrefix = (string) "ONOFF_LINE_"
 dim sLine2Prefix = (string) "LINE_"
 dim sLinesDomain = (string) "LINES"
 dim sMainContainerName = (string) "MAIN"
 dim bMultipages = (boolean) false
 dim sPagePrefix = (string) "ONOFF_PAGE_"
 'max site differences when elements are “ON”
 dim dOffset = 0.06
 
 'setter tous les ONOFF qui agissent sur le maxsize
 
 dim arrOnOff as array[onoffcontainer]
 dim arrLines as array[linecontainer]
sub OnInitParameters()
 'RegisterParameterString("linenumber", "Line Number:","4",40,40,"")
 RegisterParameterString("pagenum", "Page Number:","1",40,40,"")
RegisterPushButton("footeroffset","Footer Offset", 1) 
end sub
sub OnExecAction(buttonId As Integer)
 arrOnOff.Clear()
 arrLines.Clear()
 
 iLineNumber = CInt(VizCommunication.map["iLineNumber"])
 iLineTotal = CInt(VizCommunication.map["iMaxLine"])
 
 For i = 1 to iLineNumber
 dim sI = (string) i
 dim oLine as onoffcontainer
 oLine.dOffset = dOffset
 oLine.sContainerName = sLinePrefix&i
 arrOnOff.push(oLine)
 Next
 
 For j = 1 to iLineTotal
 'Println j
 dim sJ = (string) j
 dim oLine2 as linecontainer
 'oLine.dYDiff = dYDiff
 oLine2.dOffset = dOffset
 oLine2.sLineContainerName = sLine2Prefix&j
 arrLines.push(oLine2)
 'Println dYDiff
 Next
TreatFooter()
end sub
sub TreatFooter()
 Println "iLineNumber"
 Println iLineNumber
 Println "iLineTotal"
 Println iLineTotal
 dim i = (integer) 0
 for i=1 to iLineTotal
 
 'dim cMainContainer = (container) scene.findcontainer(sMainContainerName)
 dim pagedir = "PAGE_"&CStr(GetParameterString("pagenum"))
 dim cPageContainer = scene.findcontainer("ONOFF_PAGE_"&CStr(GetParameterString("pagenum")))
 dim cBaseContainer = (container) cPageContainer.findsubcontainer(sLinePrefix&i)
 'cMainContainer.position.y = 0
 
 'dim dYBaseTemp = 0.0
 dim dOffsetTemp = dOffset*iLineTotal 
 Println "!!!!!!!!!!!!!!!!!!!dOffsettemp"
 Println dOffsettemp
 For Each j In arrOnOff
 if cPageContainer.findsubcontainer(j.sContainerName).active == false then
 'Println "________"&j.sContainerName&"not active"
 'dYBaseTemp = dYBaseTemp-j.dYDiff
 dOffsetTemp = dOffsetTemp-j.dOffset
 'Println "dYBaseTemp = "&dYBaseTemp 
 end if
 Next
 'dOffsetTemp = dOffset*iLineTotal
 For Each k In arrLines
 if cPageContainer.findsubcontainer(k.sLineContainerName).active == false then 
 dOffsetTemp = dOffsetTemp-k.dOffset 
 end if
 Next
 Println "dOffsettemp"
 Println dOffsettemp
 pagedir = "PAGE_"&CStr(GetParameterString("pagenum"))
 dim footerdir = pagedir&"_FOOTER"
 'cMainContainer.position.y = dYBaseTemp
 'stage.finddirector("PAGE_1_FOOTER").offset = dOffsettemp
 stage.finddirector(footerdir).offset = dOffsettemp 
 
 dim time as Double = 1.080
 dim dir1 as Director = stage.finddirector(footerdir)
 dim ec1 as Channel = dir1.EventChannel
 dim key1 as Keyframe = ec1.FindKeyFrame("FooterIn")
 key1.time = time - dOffsettemp
 'dim dir2 as Director = stage.finddirector("PAGE_2").findsubdirector("PAGE_2_FOOTER")
 'dim ec2 as Channel = dir2.EventChannel
 'dim key2 as Keyframe = ec2.FindKeyFrame("FooterIn2")
 'key2.time = time - dOffsettemp
next
end sub

GAP

dim dAthleteResult1 = (double) 00.00
dim dAthleteResult2 = (double) 00.00
dim dMaxValue as double
dim dResultAthlete1 as double
dim dResultAthlete2 as double
dim sMaxValueContainerName = (string) "txt_result_max"
dim sResultAthlete1 = (string) "txt_result_athlete_left"
dim sResultAthlete2 = (string) "txt_result_athlete_right"
dim sDelay1 = (string) "txt_delay_left"
dim sDelay2 = (string) "txt_delay_right"
dim cBar1 = (string) "SCORE_BAR_1"
dim cBar2 = (string) "SCORE_BAR_2"
dim cLeft = (string) "LEFT"
dim cRight = (string) "RIGHT"
dim cFull = (string) "FULL"
dim cFill = (string) "fill"
dim dPercent1 = (double) 60.00
dim dPercent2 = (double) 30.00
dim dDiff as double
dim dPercentage as double
dim dFill1 = (double) CDbl(scene.findcontainer(sResultAthlete1).geometry.text)
dim dFill2 = (double) CDbl(scene.findcontainer(sResultAthlete2).geometry.text)
dim dDelay1 = (double) CDbl(scene.findcontainer(sDelay1).geometry.text)
dim dDelay2 = (double) CDbl(scene.findcontainer(sDelay2).geometry.text)
dim cResultFill1 as container
dim cResultFill2 as container
'dim dir1 as Director
'dim ec1 as Channel
'dim key1 as Keyframe
'dim sResultGapMaskContainerName = (string) "result_progress_bar"
dim sBaseContainerName = (string) "ONOFF_RESULT_GAP"
dim sBaseLineContainerPrefix = (string) "RESULT_GAP"
sub OnInit()
 
end sub
sub OnInitParameters()
 RegisterPushButton("SetDelay", "Set Delays", 0)
 RegisterPushButton("Anim1", "Animation 1", 1)
 RegisterPushButton("Anim2", "Animation 2", 2)
 RegisterPushButton("SetColor", "Set Gap Color", 3)
 RegisterPushButton("ShowRank", "Show Rank", 4)
end sub
sub OnExecAction(buttonId As Integer)
dDelay1 = (double) CDbl(scene.findcontainer(sDelay1).geometry.text)
 dDelay2 = (double) CDbl(scene.findcontainer(sDelay2).geometry.text) 
 dMaxValue = CDbl(scene.findcontainer(sMaxValueContainerName).geometry.text)
 dResultAthlete1 = (double) CDbl(scene.findcontainer(sResultAthlete1).geometry.text)
 dResultAthlete2 = (double) CDbl(scene.findcontainer(sResultAthlete2).geometry.text)
 cResultFill1 = (container) scene.findcontainer(cLeft).findsubcontainer(cFill)
 cResultFill2 = (container) scene.findcontainer(cRight).findsubcontainer(cFill)
SELECT CASE buttonId
 CASE 0
 SetDelay
 CASE 1
 Anim1
 CASE 2
 Anim2
 CASE 3
 SetColor
 CASE 4
 ShowRank
 END SELECT
end sub
sub Anim1()
 dPercentage = (double) dResultAthlete1/dMaxValue
 'Println "Anim1() Yeah"
 'Println dPercentage
 cResultFill1.scaling.y = dPercentage
end sub
sub Anim2()
 dPercentage = (double) dResultAthlete2/dMaxValue
 'Println "Anim2() Yeah"
 'Println dResultAthlete2
 cResultFill2.scaling.y = dPercentage
end sub
sub SetColor()
 dDiff = (double) dResultAthlete2/dResultAthlete1
 dim dKeyFrame = scene.findcontainer("RIGHT").findsubcontainer("fill").FindKeyFrame("mat")
 if dDiff = 1 then
 dKeyFrame.MaterialValue.Color.SetRGB(cdbl(81)/255, cdbl(156)/255, cdbl(211)/255)
 println("Bleu")
 else 
 if dDiff > 1 then
 dKeyFrame.MaterialValue.Color.SetRGB(cdbl(31)/255, cdbl(190)/255, cdbl(27)/255)
 println("Vert")
 else
 dKeyFrame.MaterialValue.Color.SetRGB(cdbl(255)/255, cdbl(18)/255, cdbl(0)/255)
 println("Rouge")
 end if 
 end if 
end sub
sub ShowRank()
 Println "ShowRank() Yeah"
end sub
sub SetDelay()
dim dir as Director = Stage.FindDirector("ANI_INOUT")
 dim eve as Channel = dir.EventChannel
 dim dDelayKeyFrame1 as Keyframe = eve.FindKeyframe("Anim1")
 dim dDelayKeyFrame2 as Keyframe = eve.FindKeyframe("Anim2")
 dDelayKeyFrame1.EventDuration = dDelay1
 dDelayKeyFrame2.EventDuration = dDelay2
 'key.EventValue = ET_TAG
 'key.Name = name
'dim dDelayKeyFrame1 = FindKeyFrame("delay1")
'dim dDelayKeyFrame2 = FindKeyFrame("delay2")
Println "dDelayKeyFrame1"
Println dDelayKeyFrame1.EventDuration
Println "dDelayKeyFrame2"
Println dDelayKeyFrame2.EventDuration
end sub

PROGRESS

dim cMovingItems = (container) Scene.findcontainer("MOVING_ITEMS")
dim cProgressbarCont = (container) cMovingItems.findsubcontainer("ONOFF_PROGRESSBAR")

dim cGoldCont = (container) cMovingItems.findsubcontainer("ONOFF_GOLD_MEDAL")
dim cSilverCont = (container) cMovingItems.findsubcontainer("ONOFF_SILVER_MEDAL")
dim cBronzeCont = (container) cMovingItems.findsubcontainer("ONOFF_BRONZE_MEDAL")

dim sMove = (string) "MOVE"
dim cMoveProgressbar = (container) cProgressbarCont.findsubcontainer("COLORED_PROGRESSBAR")

dim cMoveGoldResult = (container) cGoldCont.findsubcontainer(sMove)
dim cMoveSilverResult = (container) cSilverCont.findsubcontainer(sMove)
dim cMoveBronzeResult = (container) cBronzeCont.findsubcontainer(sMove)

sub OnInitParameters()
RegisterPushButton("SetValues", "Set result values", 1)
end sub

sub OnExecAction(buttonId As Integer)
SetResultValues()
end sub

sub SetResultValues()
SetDelay()
dim vBoundingBoxDimensions = (vertex) cProgressbarCont.findsubcontainer("back_reference").GetBoundingBoxDimensions()
dim vWidth = (double) vBoundingBoxDimensions[0]
dim vMax = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_score_max").geometry.text)
dim vProgress = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_score").geometry.text)

dim vGold = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_score_gold").geometry.text)
dim vSilver = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_score_silver").geometry.text)
dim vBronze = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_score_bronze").geometry.text)


dim dKeyFrame1 = Stage.FindDirector("ANI_INOUT").FindKeyFrame("GoldScore")
dim dKeyFrame2 = Stage.FindDirector("ANI_INOUT").FindKeyFrame("SilverScore")
dim dKeyFrame3 = Stage.FindDirector("ANI_INOUT").FindKeyFrame("BronzeScore")

dim vProgressPercent = (double) (vProgress/vMax)*100

dim vGoldPercent = (double) (vGold/vMax)*100
dim vSilverPercent = (double) (vSilver/vMax)*100
dim vBronzePercent = (double) (vBronze/vMax)*100

'println("vGoldPercent: " & vGoldPercent & ", vSilverPercent: " & vSilverPercent & ", vBronzePercent: " & vBronzePercent)

dim vGoldX = (vWidth/100)*vGoldPercent
dim vSilverX = (vWidth/100)*vSilverPercent
dim vBronzeX = (vWidth/100)*vBronzePercent


dKeyFrame1.XyzValue.x = vGoldX
dKeyFrame2.XyzValue.x = vSilverX
dKeyFrame3.XyzValue.x = vBronzeX

cMoveProgressbar.Scaling.x = vProgressPercent/100


end sub

sub SetDelay()

dim sDelay1 = (string) "txt_delay_1"
dim sDelay2 = (string) "txt_delay_2"
dim sDelay3 = (string) "txt_delay_3"
dim vDelay1 = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_delay_1").geometry.text)
dim vDelay2 = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_delay_2").geometry.text)
dim vDelay3 = (double) CDbl(scene.findcontainer("VARIABLES").findsubcontainer("txt_delay_3").geometry.text)

dim dir as Director = Stage.FindDirector("ANI_INOUT")
dim eve as Channel = dir.EventChannel
dim dDelayKeyFrame1 as Keyframe = eve.FindKeyframe("delay1")
dim dDelayKeyFrame2 as Keyframe = eve.FindKeyframe("delay2")
dim dDelayKeyFrame3 as Keyframe = eve.FindKeyframe("delay3")
dDelayKeyFrame1.EventDuration = vDelay1
dDelayKeyFrame2.EventDuration = vDelay2
dDelayKeyFrame3.EventDuration = vDelay3

Println "dDelayKeyFrame1"
Println dDelayKeyFrame1.EventDuration
Println "dDelayKeyFrame2"
Println dDelayKeyFrame2.EventDuration
Println "dDelayKeyFrame3"
Println dDelayKeyFrame3.EventDuration
end sub

ONOFF

structure onoffcontainer
 dMSDifference as double
 sContainerName as string
end structure
dim iLineNumber = (integer) 1
'dim sLinePrefix = (string) "LINE_"
'dim sLinesDomain = (string) "ANI_DATA"
dim sNameTextName = (string) "txt_name"
' max site differences when elements are "ON"
dim dMSBase = (double) 1150
' setter tous les ONOFF qui agissent sur le maxsize
dim oNoc as onoffcontainer
oNoc.dMSDifference = -85
oNoc.sContainerName = "ONOFF_NOC"
dim oBib as onoffcontainer
oBib.dMSDifference = -125
oBib.sContainerName = "ONOFF_BIB"
dim oQt as onoffcontainer
oQt.dMSDifference = -85
oQt.sContainerName = "ONOFF_QUALIFICATION_TIME"
dim arrOnOff as array[onoffcontainer]
arrOnOff.push(oNoc)
arrOnOff.push(oBib)
arrOnOff.push(oQt)
sub OnInitParameters()
 RegisterPushButton("checkonoff","Check on/offs", 1)
end sub
sub OnExecAction(buttonId As Integer)
 TreatLine()
end sub
sub TreatLine() dim i = (integer) 0 for i=1 to iLineNumber dim cBaseContainer = (container) scene.findcontainer("MAINLINE").findsubcontainer("DATA") dim cTextContainer = (container) cBaseContainer.findsubcontainer(sNameTextName) dim dMSBaseTemp = (double) dMSBase For Each j In arrOnOff if cBaseContainer.findsubcontainer(j.sContainerName).active == true then dMSBaseTemp = dMSBaseTemp+j.dMSDifference end if Next cTextContainer.GetFunctionPluginInstance("Maxsize").SetParameterDouble("WIDTH_X",dMSBaseTemp) next end sub

ACCELERATION

sub OnInit() Scene.FindContainer("txt_percent").geometry.RegisterTextChangedCallback() end sub sub OnGeometryChanged(geom As Geometry) stage.finddirector("ACCELERATION_MOVE").time = cDbl(geom.text)/100 end sub

TIME TO 100

sub OnInit()
Scene.FindContainer("txt_speed_current_value_0_100").geometry.RegisterTextChangedCallback()
end sub
dim sLinesDomain = (string) "ANI"
dim sCurrentSpeed = (string) "SPEED_CURRENT_0_100"
dim sBackground = (string) "BACKGROUND_0_100"

dim sCurrentSpeedValue = (string) "txt_speed_current_value_0_100"
dim sMaxSpeedValue = (string) "txt_speed_max_value_0_100"

dim cCurrentSpeedContainer = (container) scene.findcontainer(sCurrentSpeed)
dim cBackgroundContainer = (container) scene.findcontainer(sBackground)

sub onGeometryChanged(geom as geometry)
SetSpeed()
end sub
sub SetSpeed()

dim cBackgroundBB = (vertex) cBackgroundContainer.getBoundingBoxDimensions()
dim dCurrentVal = CDbl(scene.findcontainer(sCurrentSpeedValue).geometry.text)
dim dMaxVal = CDbl(scene.findcontainer(sMaxSpeedValue).geometry.text)

dim dCurrentPercent = (double) (dCurrentVal/dMaxVal)*100

if dCurrentPercent >= 100 then
dCurrentPercent = 100
end if

dim cursorPos = (double) ((cBackgroundBB[1]-25)/100)*dCurrentPercent

cCurrentSpeedContainer.position.y = cursorPos

'println("*SETSPEED* dCurrentPercent:"&dCurrentPercent&", dCurrentVal:"&dCurrentVal&", cBackgroundBB[1]:"&cBackgroundBB[1]&", dMaxVal:"&dMaxVal&",cursorPos:"&cursorPos)

end sub