Untitled

From Chunky Motmot, 4 Days ago, written in Plain Text, viewed 3 times. This paste will hop the perch in 3 Weeks.
URL https://paste.afonso.co/view/274515e4 Embed
Download Paste or View Raw
  1. # -*- encoding: utf-8 -*-
  2. import time
  3. from System.Threading import *
  4. from os import path
  5.  
  6. test = False
  7.  
  8. def Show():
  9.         if not __Checking(): return
  10.         Globals["ScorebugApiResultsOnAir"] = False
  11.         ToProgram()
  12.  
  13. def __Checking():
  14.         return True
  15.  
  16.  
  17. def __FillTags():
  18.         competitionColor = ProjectSettings["CompetitionColor"]
  19.         viewbag = []
  20.         sets = Globals["API"].data["Results"]["CurrentSet"]
  21.         backhand, drive = Globals["PadelHelper"].GetPlayers(ActiveObjects.HomeTeam)
  22.         listHomeTeam = []
  23.         listHomeTeam.append(drive.Names.OtherNames.ToUpper())
  24.         listHomeTeam.append(backhand.Names.OtherNames.ToUpper())
  25.         viewbag.append({"Name": "tHomeTeamName", "Value":  '/'.join(listHomeTeam), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  26.         color = ActiveObjects.HomeTeam.Attributes["RGB"].Value.ToString() if ActiveObjects.HomeTeam.Attributes["RGB"] else "255, 255, 255"
  27.         viewbag.append({"Name": "vHomeTeamColor", "Value": color, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  28.  
  29.         #24PT_FIP_WORLD PADEL CHAMPIONSHIP
  30.         _, homeCountryInitials, _, awayCountryInitials = Globals["PadelHelper"].GetCountryNameAndInitials()
  31.  
  32.         homeFlag = Globals["PadelHelper"].GetCountryFlag(homeCountryInitials if homeCountryInitials != None else "")
  33.         awayFlag = Globals["PadelHelper"].GetCountryFlag(awayCountryInitials if awayCountryInitials != None else "")
  34.         viewbag.append({"Name": "lgHomeTeamFlag", "Value": homeFlag, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  35.         viewbag.append({"Name": "lgAwayTeamFlag", "Value": awayFlag, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  36.  
  37.         ##
  38.  
  39.         # Tags: Away Players
  40.         backhand, drive = Globals["PadelHelper"].GetPlayers(ActiveObjects.AwayTeam)
  41.         listAwayTeam = []
  42.         listAwayTeam.append(drive.Names.OtherNames.ToUpper())
  43.         listAwayTeam.append(backhand.Names.OtherNames.ToUpper())
  44.         viewbag.append({"Name": "tAwayTeamName", "Value": '/'.join(listAwayTeam), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  45.         color = ActiveObjects.AwayTeam.Attributes["RGB"].Value.ToString() if ActiveObjects.AwayTeam.Attributes["RGB"] else "255, 255, 255"
  46.         viewbag.append({"Name": "vAwayTeamColor", "Value": color, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  47.         viewbag.append({"Name": "lgSponsor", "Value": Globals["PadelHelper"].GetOnlineSponsor(), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  48.         viewbag.append({"Name": "vColor", "Value": competitionColor, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  49.         viewbag.append({"Name": "vSets", "Value": str(sets), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  50.  
  51.         #New Online Type 2 players service
  52.         viewbag.append({"Name": "vType", "Value": "2", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  53.         #New tags PlayersNames
  54.         viewbag.append({"Name": "tHomePlayerName01", "Value": listHomeTeam[0], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  55.         viewbag.append({"Name": "tHomePlayerName02", "Value": listHomeTeam[1], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  56.         viewbag.append({"Name": "tAwayPlayerName01", "Value": listAwayTeam[0], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  57.         viewbag.append({"Name": "tAwayPlayerName02", "Value": listAwayTeam[1], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  58.  
  59.         if Globals["ConfigForm"].data["HashtagImage"] == True:
  60.                 viewbag.append({"Name": "vSponsor", "Value": "1", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  61.         else:
  62.                 viewbag.append({"Name": "tSponsor", "Value": Globals["ConfigForm"].data["HashtagText"], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  63.                 viewbag.append({"Name": "vSponsor", "Value": "2", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  64.  
  65.         return viewbag
  66.  
  67.  
  68. def ToProgram():
  69.         if test: print "Chamei toProgram"
  70.         Globals["ScorebugApiResultsOnAir"] = True
  71.         viewbag = __FillTags()
  72.         popupTitle = Update()
  73.         UpdatePosition()
  74.         Globals["R3_Manager"].DoTransition("Scorebug")
  75.         Globals["R3_Manager"].ShowAnimation("Program", Script, "In", viewbag, "Scorebug")
  76.         partialHome = Globals["API"].data["Results"]["HomeTeam"]["CurrentGame"]
  77.         partialAway = Globals["API"].data["Results"]["AwayTeam"]["CurrentGame"]
  78.         currentSet = Globals["API"].data["Results"]["CurrentSet"]
  79.  
  80.         if (partialHome == "0" and partialAway == "0") or (partialHome == "" and partialAway == "") or (Globals["API"].data["Match Finished"]) or (Globals["API"].data["Results"]["Sets Finished"][int(currentSet)-1]):
  81.                 if test: print "Chamei ScoreZeroOut"
  82.                 ScoreZeroOut()
  83.         else:
  84.                 if not Globals["API"].data["Match Finished"]:
  85.                         ScoreZeroIn()
  86.  
  87.         Globals["R3_Manager"].OnAirScorebug = Script.RefName
  88.         Globals["R3_Manager"].OnAirScorebugStatus = None
  89.         if popupTitle:
  90.                 PopupIn(popupTitle)
  91.  
  92.         #timeSleep = int(ProjectSettings["SponsorTimeIn"])* 1000
  93.         #Thread.Sleep(timeSleep)
  94.  
  95.  
  96. def Update():
  97.         #print "Online API - Update"
  98.  
  99.         viewbag = []
  100.  
  101.         # Totais agregados definidos nos controlos numéricos do frmPadelScoreBoard.
  102.         frm = Globals["frmPadelScoreboard"]
  103.         homeAggregate = int(frm.Controls["btnHomeTotal"].Value)
  104.         awayAggregate = int(frm.Controls["btnAwayTotal"].Value)
  105.  
  106.         viewbag.append({"Name": "tHomeAggregate", "Value": str(homeAggregate), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  107.         viewbag.append({"Name": "tAwayAggregate", "Value": str(awayAggregate), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  108.  
  109.         aggregateVisibility = homeAggregate != 0 or awayAggregate != 0
  110.         viewbag.append({"Name": "vAggregateVisibility", "Value": aggregateVisibility, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  111.  
  112.         #24PT_FIP_WORLD PADEL CHAMPIONSHIP
  113.         _, homeCountryInitials, _, awayCountryInitials = Globals["PadelHelper"].GetCountryNameAndInitials()
  114.  
  115.         homeFlag = Globals["PadelHelper"].GetCountryFlag(homeCountryInitials if homeCountryInitials != None else "")
  116.         awayFlag = Globals["PadelHelper"].GetCountryFlag(awayCountryInitials if awayCountryInitials != None else "")
  117.         viewbag.append({"Name": "lgHomeTeamFlag", "Value": homeFlag, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  118.         viewbag.append({"Name": "lgAwayTeamFlag", "Value": awayFlag, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  119.  
  120.         ##
  121.  
  122.         # Points and popup title come from the same controller update.
  123.         partialHome, partialAway, popupTitle = Globals["API"].scorebugPoints
  124.         updatePopup = Globals["R3_Manager"].OnAirScorebug == Script.RefName
  125.         if updatePopup:
  126.                 if not popupTitle:
  127.                         PopupOut()
  128.                 elif Globals["R3_Manager"].OnAirScorebugPopup:
  129.                         viewbag.append(__PopupTitleTag(popupTitle))
  130.  
  131.         viewbag.append({"Name": "tHomeTeamPoints", "Value": partialHome, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  132.         viewbag.append({"Name": "tAwayTeamPoints", "Value": partialAway, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  133.  
  134.         # SETS
  135.         sets = Globals["API"].data["Results"]["CurrentSet"]
  136.  
  137.         if (partialHome == "0" and partialAway == "0") or (partialHome == "" and partialAway == "") or (Globals["API"].data["Match Finished"]) or (Globals["API"].data["Results"]["Sets Finished"][int(sets)-1]):
  138.                 ScoreZeroOut()
  139.         else:
  140.                 if not Globals["API"].data["Match Finished"]:
  141.                         ScoreZeroIn()
  142.  
  143.         #lastWinner = "home" if lastGame == None or lastGame["Results"]["HomeTeam"]["CurrentGame"] > lastGame["Results"]["AwayTeam"]["CurrentGame"] else "away"
  144.  
  145.         setFinished = 0
  146.         for i in range(3):
  147.                 setValueHome = Globals["API"].data["Results"]["HomeTeam"]["Sets"][i]
  148.                 setValueAway = Globals["API"].data["Results"]["AwayTeam"]["Sets"][i]
  149.                 currentSet = Globals["API"].data["Results"]["CurrentSet"]
  150.  
  151.                 if not Globals["API"].data["Results"]["Sets Finished"][i]:
  152.                         #Todo: Graphic Neutral
  153.                         viewbag.append({"Name": "vSetWinner" + str(i+1).zfill(2), "Value": "3", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  154.                 else:
  155.                         #Todo: Graphic Painting
  156.                         if setValueHome > setValueAway:
  157.                                 viewbag.append({"Name": "vSetWinner" + str(i+1).zfill(2), "Value": "1", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  158.                         elif setValueHome < setValueAway:
  159.                                 viewbag.append({"Name": "vSetWinner" + str(i+1).zfill(2), "Value": "2", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  160.                         elif setValueHome == 0 and setValueAway == 0:
  161.                                 viewbag.append({"Name": "vSetWinner" + str(i+1).zfill(2), "Value": "1", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  162.  
  163.                 viewbag.append({"Name": "tHomeTeamSetPoints" + str(i+1).zfill(2), "Value": str(setValueHome), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  164.                 viewbag.append({"Name": "tAwayTeamSetPoints" + str(i+1).zfill(2), "Value": str(setValueAway), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  165.  
  166.                 if Globals["API"].data["Results"]["Sets Finished"][i]:
  167.                         viewbag.append({"Name": "vHomeTeamTextColor" + str(i+1).zfill(2), "Value": "255, 255, 255", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  168.                         viewbag.append({"Name": "vAwayTeamTextColor" + str(i+1).zfill(2), "Value": "255, 255, 255", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  169.                         setFinished += 1
  170.                 else:
  171.                         viewbag.append({"Name": "vHomeTeamTextColor" + str(i+1).zfill(2), "Value": "199, 165, 110", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  172.                         viewbag.append({"Name": "vAwayTeamTextColor" + str(i+1).zfill(2), "Value": "199, 165, 110", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  173.  
  174.         if Globals["ConfigForm"].data["ZeroOnNewSet"] or sets == 1:
  175.                 viewbag.append({"Name": "vSets", "Value": str(sets), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  176.  
  177.         # SERVICE
  178.         if test: print "Data Match: %s " % Globals["API"].data["Match Finished"]
  179.         if Globals["API"].data["Match Finished"]:
  180.                 if test: print "Cai no match finish"
  181.                 ServiceOut()
  182.                 SetFinished()
  183.                 viewbag.append({"Name": "tHomeTeamPoints", "Value": "", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  184.                 viewbag.append({"Name": "tAwayTeamPoints", "Value": "", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  185.                 viewbag.append({"Name": "vPoints", "Value": "0", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  186.                 viewbag.append({"Name": "vHomePlayerService", "Value": 0, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  187.                 viewbag.append({"Name": "vAwayPlayerService", "Value": 0, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  188.  
  189.         else:
  190.                 #print "Home Service: %s " % Globals["API"].data["Results"]["HomeTeam"]["Service"]
  191.                 #print "Away Service: %s " % Globals["API"].data["Results"]["AwayTeam"]["Service"]
  192.                 #if Globals["API"].data["Results"]["HomeTeam"]["Service"] > 0:
  193.                         #viewbag.append({"Name": "vService", "Value": "1", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  194.                 #elif Globals["API"].data["Results"]["AwayTeam"]["Service"] > 0:
  195.                         #viewbag.append({"Name": "vService", "Value": "2", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  196.                 #else:
  197.                         #viewbag.append({"Name": "vService", "Value": "0", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  198.                 #newService
  199.  
  200.                 #NewService:
  201.                 viewbag.append({"Name": "vHomePlayerService", "Value": Globals["API"].data["Results"]["HomeTeam"]["Service"], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  202.                 viewbag.append({"Name": "vAwayPlayerService", "Value": Globals["API"].data["Results"]["AwayTeam"]["Service"], "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  203.  
  204.         # Filling Tags...
  205.         if "R3_Manager" in Globals:
  206.                 for server in R3Servers:
  207.                         if server.Type.ToString() == "Program":
  208.                                 scene = server.GetGraphicScene(Script.Scene.Name)
  209.                                 scene.Slot = Globals["R3_Manager"].GetSlot("Scorebug")
  210.                                 language = server.Metadata["Language"]
  211.  
  212.                                 Globals["R3_Manager"].FillTags(server, scene, language, server.Name, viewbag)
  213.         if updatePopup and popupTitle:
  214.                 if Globals["R3_Manager"].OnAirScorebugPopup:
  215.                         __SetPopupTitleFlags(popupTitle)
  216.                 else:
  217.                         PopupIn(popupTitle)
  218.         HashTagAuto()
  219.         return popupTitle
  220.  
  221.  
  222. def UpdatePosition():
  223.         viewbag = []
  224.  
  225.         # Scene Positions & Scales
  226.         data = Globals["ScenesPositions"].GetScene(Script.RefName)
  227.         if data:
  228.                 viewbag.append({"Name": "vPosX", "Value": str(data["X"]), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  229.                 viewbag.append({"Name": "vPosY", "Value": str(data["Y"]), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  230.                 viewbag.append({"Name": "vScaleX", "Value": str(data["ScaleX"]), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  231.                 viewbag.append({"Name": "vScaleY", "Value": str(data["ScaleY"]), "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  232.  
  233.         # Filling Tags...
  234.         if "R3_Manager" in Globals:
  235.                 for server in R3Servers:
  236.                         if server.Type.ToString() == "Program":
  237.                                 scene = server.GetGraphicScene(Script.Scene.Name)
  238.                                 scene.Slot = Globals["R3_Manager"].GetSlot("Online")
  239.                                 language = server.Metadata["Language"]
  240.  
  241.                                 Globals["R3_Manager"].FillTags(server, scene, language, server.Name, viewbag)
  242.  
  243.  
  244. def SetFinished():
  245.         if test: print "Chamei o set finished"
  246.         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  247.                 return
  248.         if not Globals["ConfigForm"].data["ZeroOnNewSet"]:
  249.                 return
  250.         if not Globals["API"].data["Match Finished"]:
  251.                 viewbag = []
  252.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Sets_Out", viewbag, "Scorebug", 500)
  253.                 Update()
  254.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Sets_In", viewbag, "Scorebug", 500)
  255.         else:
  256.                 if test: print "ScorebugApiResultsOnAir %s " % Globals["ScorebugApiResultsOnAir"]
  257.                 if Globals["ScorebugApiResultsOnAir"]:
  258.                         Globals["R3_Manager"].ShowAnimation("Program", Script, "Result_Out", [], "Scorebug")
  259.                         Globals["ScorebugApiResultsOnAir"] = False
  260.  
  261.  
  262. def __PopupTitleTag(msg):
  263.         return {"Name": "tTitle", "Value": msg, "Pipe": "", "ToUpper": True, "IsAdvert": False, "Translate": True, "Context": "Online Scene"}
  264.  
  265.  
  266. def __SetPopupTitleFlags(title):
  267.         Globals["OnlineAPIIsAdvantageTitleOnAir"] = title in ("Advantage 1", "Advantage 2")
  268.         Globals["OnlineAPIIsDeucesTitleOnAir"] = bool(title and (title == "Deuce 2" or title.endswith("Star Point")))
  269.  
  270.  
  271. def PopupIn(msg):
  272.         if not Globals["R3_Manager"].OnAirScorebugPopup and Globals["R3_Manager"].OnAirScorebug == Script.RefName:
  273.                 viewbag = [__PopupTitleTag(msg)]
  274.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Title_In", viewbag, "Scorebug")
  275.                 Globals["R3_Manager"].OnAirScorebugPopup = True
  276.                 __SetPopupTitleFlags(msg)
  277.  
  278.  
  279. def PopupOut():
  280.         if Globals["R3_Manager"].OnAirScorebugPopup:
  281.                 viewbag = []
  282.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Title_Out", viewbag, "Scorebug", 250)
  283.                 Globals["R3_Manager"].OnAirScorebugPopup = False
  284.         __SetPopupTitleFlags(None)
  285.  
  286.  
  287. def GoldPointIn():
  288.         if not Globals["R3_Manager"].OnAirScorebugGoldPoint and Globals["R3_Manager"].OnAirScorebug == Script.RefName:
  289.                 viewbag = []
  290.                 viewbag.append({"Name": "tGoldPointTitle", "Value": "Golden Point", "Pipe": "", "ToUpper": True, "IsAdvert": False, "Translate": True, "Context": "Online Scene"})
  291.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "GoldPoint_In", viewbag, "Scorebug")
  292.                 Globals["R3_Manager"].OnAirScorebugGoldPoint = True
  293.  
  294.  
  295. def GoldPointOut():
  296.         if Globals["R3_Manager"].OnAirScorebugGoldPoint:
  297.                 viewbag = []
  298.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "GoldPoint_Out", viewbag, "Scorebug")
  299.                 Globals["R3_Manager"].OnAirScorebugGoldPoint = False
  300.  
  301.  
  302. def ServiceIn():
  303.         viewbag = []
  304.         viewbag.append({"Name": "vServiceBall", "Value": "1", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  305.         for server in R3Servers:
  306.                 if server.Type.ToString() == "Program":
  307.                         scene = server.GetGraphicScene(Script.Scene.Name)
  308.                         scene.Slot = Globals["R3_Manager"].GetSlot("Scorebug")
  309.                         language = server.Metadata["Language"]
  310.                         Globals["R3_Manager"].FillTags(server, scene, language, server.Name, viewbag)
  311.  
  312.  
  313. def ServiceOut():
  314.         viewbag = []
  315.         viewbag.append({"Name": "vService", "Value": "0", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  316.         for server in R3Servers:
  317.                 if server.Type.ToString() == "Program":
  318.                         scene = server.GetGraphicScene(Script.Scene.Name)
  319.                         scene.Slot = Globals["R3_Manager"].GetSlot("Scorebug")
  320.                         language = server.Metadata["Language"]
  321.                         Globals["R3_Manager"].FillTags(server, scene, language, server.Name, viewbag)
  322.  
  323.  
  324. def ScoreZeroIn():
  325.         if test: print "Executei ScoreZeroIn"
  326.         if test: print 'Globals[ScorebugApiResultsOnAir"]: %s' % Globals["ScorebugApiResultsOnAir"]
  327.  
  328.         if Globals["ScorebugApiResultsOnAir"] == False:
  329.                 if test: print "Chamei result_in"
  330.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Result_In", [], "Scorebug")
  331.                 Globals["ScorebugApiResultsOnAir"] = True
  332.  
  333.  
  334. def ScoreZeroOut():
  335.         if test: print "Executei ScoreZeroOut"
  336.         if Globals["ScorebugApiResultsOnAir"]:
  337.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Result_Out", [], "Scorebug")
  338.                 if test: print 'Setei Globals["ScorebugApiResultsOnAir"] = False'
  339.                 Globals["ScorebugApiResultsOnAir"] = False
  340.  
  341.  
  342. def Out(wait=False):
  343.         if Globals["R3_Manager"].OnAirScorebug == Script.RefName:
  344.                 w = 1500 if wait else 0
  345.                 Scheduler.ClearScheduler("Online_API")
  346.                 PopupOut()
  347.                 GoldPointOut()
  348.                 HashtagOut()
  349.                 SponsorOnlineOut()
  350.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Out", [], "Scorebug", w)
  351.                 Globals["R3_Manager"].OnAirScorebug = None
  352.                 Globals["R3_Manager"].OnAirScorebugSponsor = False
  353.  
  354.  
  355. def __SecondsToString(sec):
  356.         hour = sec/3600
  357.         minutes = (sec - (hour*3600))/60
  358.         seconds = sec - (hour*3600) - (minutes*60)
  359.  
  360.         hourStr = (str(hour) + "h") if hour > 0 else ""
  361.         minStr = (str(minutes).zfill(2) + "min") if minutes > 0 else "00min"
  362.         return hourStr + " " + minStr # + ":" + str(seconds).zfill(2)
  363.  
  364.  
  365. #def SponsorIn():
  366.         #if Globals["API"].status == True:
  367.                 #if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  368.                         #return
  369.         #else:
  370.                 #if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  371.                         #return
  372.         #if not Globals["R3_Manager"].OnAirScorebugHashtag:
  373.                 #Globals["R3_Manager"].OnAirScorebugHashtag = True
  374.                 #viewbag = []
  375.                 #folderName = ProjectSettings["ImagesFolderPath"]
  376.                 #viewbag.append({"Name": "lgSponsor", "Value": folderName + "\Sponsors\sponsor_online.png", "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  377.                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", viewbag, "Scorebug")
  378.  
  379. #def Sponsor2setsIn():
  380.         #print "Sponsor2setsIn"
  381.         #print Globals["R3_Manager"].OnAirScorebug
  382.         #print "OnAirScorebugSponsor: %s " %Globals["R3_Manager"].OnAirScorebugSponsor
  383.         #Globals["SponsorOnAnimantion"] = True
  384.         #print "OnAir ScroreBug: %s" %Globals["R3_Manager"].OnAirScorebug
  385.         #print "Script Ref Name: %s" % Script.RefName
  386.  
  387.         #if Globals["API"]:
  388.                 #if Globals["API"].status == True:
  389.                         #if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  390.                                 #return
  391.                 #else:
  392.                         #if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  393.                                 #return
  394.         #else:
  395.                 #if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  396.                         #return
  397.  
  398.         #if not Globals["R3_Manager"].OnAirScorebugSponsor:
  399.                 #Globals["R3_Manager"].OnAirScorebugSponsor = True
  400.                 #viewbag = []
  401.                 #folderName = ProjectSettings["ImagesFolderPath"]
  402.                 ##logo = ProjectSettings["Sponsor2SetsLogo"]
  403.                 ##fullLogoPath = path.join(folderName,logo)
  404.                 #fullLogoPath = Globals["ConfigForm"].data["ImageSponsor"]
  405.  
  406.                 ##print fullLogoPath
  407.                 #viewbag.append({"Name": "lgSponsor", "Value": fullLogoPath, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  408.                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", viewbag, "Online_API")
  409.                 #print "Setei scheduller para tirar em 5...."
  410.                 #Scheduler.Add("Online_API", "Sponsor2SetsOut", Project.Name, None, 5 * 1000, "Online_API")
  411.  
  412. #def SponsorOut():
  413.         #if Globals["R3_Manager"].OnAirScorebugHashtag:
  414.                 #Globals["R3_Manager"].OnAirScorebugHashtag = False
  415.                 #viewbag = []
  416.                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API")
  417.                 ##Scheduler.Add("Online_API", "SponsorIn", Project.Name, None, 1 * 1000, "API")
  418.                 ##Globals["SponsorOnAnimantion"] = False
  419.  
  420.         #if Globals["R3_Manager"].OnAirScorebugSponsor:
  421.                 #Globals["R3_Manager"].OnAirScorebugSponsor = False
  422.                 #viewbag = []
  423.                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API")
  424.  
  425. #def Sponsor2SetsOut():
  426.         #print "OnAirScorebugHashtag: %s OnAirScorebugSponsor: %s" % (Globals["R3_Manager"].OnAirScorebugHashtag,Globals["R3_Manager"].OnAirScorebugSponsor)
  427.         #if Globals["R3_Manager"].OnAirScorebugHashtag:
  428.                 #Globals["R3_Manager"].OnAirScorebugHashtag = False
  429.                 #viewbag = []
  430.                 #Script.Scene.Show("SponsorOut")
  431.                 #Script.Scene.Wait("SponsorOut")
  432.                 #Script.Scene.Show("SponsorIn")
  433.  
  434.                 ###Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API")
  435.                 ##Thread.Sleep(6)
  436.                 ##Script.Scene.Show("SponsorIn")
  437.                 ###Scheduler.Add("Online_API", "SponsorIn", Project.Name, None, 6 * 1000, "API")
  438.         ##else:
  439.                 ##Scheduler.Add("Online_API", "SponsorOut", Project.Name, None, 1 * 1000, "Online_API")
  440.  
  441.         #elif Globals["R3_Manager"].OnAirScorebugSponsor:
  442.                 #Globals["R3_Manager"].OnAirScorebugSponsor = False
  443.                 #viewbag = []
  444.                 ##Script.Scene.Show("SponsorOut")
  445.                 ##Script.Scene.Wait("SponsorOut")
  446.                 ##Script.Scene.Show("SponsorIn")
  447.  
  448.                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API")
  449.  
  450.                 ###Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API")
  451.                 ##Script.Scene.Show("Sponsor_Out")
  452.  
  453.                 ###Scheduler.Add("Online_API", "SponsorIn", Project.Name, None, 6 * 1000, "Online_API")
  454.                 ##Thread.Sleep(6)
  455.                 ##Script.Scene.Show("SponsorIn")
  456.         ##else:
  457.                 ##Scheduler.Add("Online_API", "SponsorOut", Project.Name, None, 1 * 1000, "Online_API")
  458.         #Globals["SponsorOnAnimantion"] = False
  459.  
  460. #self.OnAirScorebugHashtag = None
  461. #self.OnAirScorebugSponsor = None
  462.  
  463. def HashtagIn():
  464.         #Verificação se os gráficos estão no ar: Online ou online da API
  465.         if Globals["API"]:
  466.                 if Globals["API"].status == True:
  467.                         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  468.                                 return
  469.                 else:
  470.                         if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  471.                                 return
  472.         else:
  473.                 if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  474.                         return
  475.  
  476.         #Verifica se não está no ar
  477.         if not Globals["R3_Manager"].OnAirScorebugHashtag:
  478.                 #Seta o controle do hashtag para True
  479.                 Globals["R3_Manager"].OnAirScorebugHashtag = True
  480.                 #Cria uma viewBag Vazia
  481.                 viewbag = []
  482.                 #Pega o path da folder de imagens
  483.                 folderName = ProjectSettings["ImagesFolderPath"]
  484.                 imageName = "sponsor_online.png"
  485.                 #Preenche os dados da viewbag
  486.                 viewbag.append({
  487.                         "Name": "lgSponsor",
  488.                         "Value": Globals["ConfigForm"].data["ImageHashtag"],
  489.                         "Pipe": "",
  490.                         "ToUpper": False,
  491.                         "IsAdvert": False,
  492.                         "Translate": False,
  493.                         "Context": ""
  494.                 })
  495.                 #Chama a Timeline Sponsor_In desse script passando a viewbag
  496.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", viewbag, "Scorebug")
  497.                 Globals["R3_Manager"].OnAirScorebugHashtag = True
  498.         #else:
  499.                 #print "Hashtag já está no ar!!!"
  500.  
  501.  
  502. def AggregateIn():
  503.         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  504.                 return
  505.  
  506.         viewbag = []
  507.         Globals["R3_Manager"].ShowAnimation(
  508.                 "Program", Script, "Aggregate_In", viewbag, "Scorebug"
  509.         )
  510.  
  511.  
  512. def AggregateOut():
  513.         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  514.                 return
  515.  
  516.         viewbag = []
  517.         Globals["R3_Manager"].ShowAnimation(
  518.                 "Program", Script, "Aggregate_Out", viewbag, "Scorebug"
  519.         )
  520.  
  521.  
  522. def HashtagOut():
  523.         #Verificação se os gráficos estão no ar: Online ou online da API
  524.         if Globals["API"]:
  525.                 if Globals["API"].status == True:
  526.                         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  527.                                 return
  528.                 else:
  529.                         if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  530.                                 return
  531.         else:
  532.                 if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  533.                         return
  534.  
  535.         #Verifica se a Hastag está no ar
  536.         if Globals["R3_Manager"].OnAirScorebugHashtag:
  537.                 #Cria uma viewBag Vazia
  538.                 viewbag = []
  539.                 #Chama a timeline Sponsor_Out do gráfico
  540.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API", 500)
  541.                 #Seta a variável de controle da Hashtag como False
  542.                 Globals["R3_Manager"].OnAirScorebugHashtag = False
  543.         #else:
  544.                 #print "Hashtag não está no ar!!!"
  545.  
  546.  
  547. def HashtagChange(Number):
  548.         #Script.Scene.Show("Sponsor_Out")
  549.         #Script.Scene.Wait("Sponsor_Out")
  550.         #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", [], "Online_API",2)
  551.         #Globals["R3_Manager"].OnAirScorebugHashtag = False
  552.         Globals["R3_Manager"].OnAirScorebugSponsor = True
  553.         HashtagOut()
  554.         fullLogoPath = ""
  555.         if "R3_Manager" in Globals:
  556.                 for server in R3Servers:
  557.                         if server.Type.ToString() == "Program":
  558.                                 scene = server.GetGraphicScene(Script.Scene.Name)
  559.                                 scene.Slot = Globals["R3_Manager"].GetSlot("Lowerthird")
  560.                                 language = server.Metadata["Language"]
  561.                                 if server.Name == "GLOBAL":
  562.                                         fullLogoPath = Globals["ConfigForm"].data["ImageSponsorGlobal%s" % Number]
  563.                                 elif server.Name == "RESTRICTED":
  564.                                         fullLogoPath = Globals["ConfigForm"].data["ImageSponsorRestricted%s" % Number]
  565.                                 viewbag = []
  566.                                 viewbag.append({"Name": "lgSponsor", "Value": fullLogoPath, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  567.                                 Globals["R3_Manager"].FillTags(server, scene, language, server.Name, viewbag)
  568.                                 #Script.Scene.Show("Sponsor_In")
  569.                         Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", [], "Online_API")
  570.                                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", [], "Online_API")
  571.  
  572.  
  573. def SponsorOnlineIn(Number):
  574.         #Tempo para o sponsor sair do ar
  575.         timeToOut = 5
  576.         #Verificação se os gráficos estão no ar: Online ou online da API
  577.         if Globals["API"]:
  578.                 if Globals["API"].status == True:
  579.                         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  580.                                 return
  581.                 else:
  582.                         if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  583.                                 return
  584.         else:
  585.                 if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  586.                         return
  587.  
  588.         if Globals["R3_Manager"].OnAirScorebugSponsor:
  589.                 #print "Sponsor já está no ar!"
  590.                 return
  591.  
  592.         Globals["R3_Manager"].OnAirScorebugSponsor = True
  593.  
  594.         #Cria uma viewBag Vazia
  595.         viewbag = []
  596.         #Pega o path da imagem
  597.         fullLogoPath = Globals["ConfigForm"].data["ImageHashtag"]
  598.         #Verifica se a Hastag está no ar
  599.         if Globals["R3_Manager"].OnAirScorebugHashtag:
  600.                 HashtagChange(Number)
  601.         else:
  602.                 #Preenche a viewbag
  603.                 #viewbag.append({"Name": "lgSponsor", "Value": fullLogoPath, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  604.                 #Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", viewbag, "Online_API")
  605.                 if "R3_Manager" in Globals:
  606.                         for server in R3Servers:
  607.                                 if server.Type.ToString() == "Program":
  608.                                         scene = server.GetGraphicScene(Script.Scene.Name)
  609.                                         scene.Slot = Globals["R3_Manager"].GetSlot("Lowerthird")
  610.                                         language = server.Metadata["Language"]
  611.                                         if server.Name == "GLOBAL":
  612.                                                 fullLogoPath = Globals["ConfigForm"].data["ImageSponsorGlobal%s" % Number]
  613.                                         elif server.Name == "RESTRICTED":
  614.                                                 fullLogoPath = Globals["ConfigForm"].data["ImageSponsorRestricted%s" % Number]
  615.                                         viewbag = []
  616.                                         viewbag.append({"Name": "lgSponsor", "Value": fullLogoPath, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  617.                                         Globals["R3_Manager"].FillTags(server, scene, language, server.Name, viewbag)
  618.                                 #Script.Scene.Show("Sponsor_In")
  619.                                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", [], "Online_API")
  620.  
  621.         if timeToOut != 0:
  622.                 Scheduler.Add("Online_API", "SponsorOnlineOut", Project.Name, None, timeToOut * 1000, "Online_API")
  623.  
  624.  
  625. def SponsorWTOnlineIn():
  626.         #Tempo para o sponsor sair do ar
  627.         timeToOut = 5
  628.  
  629.         #Cria uma viewBag Vazia
  630.         viewbag = []
  631.         #Pega o path da imagem
  632.         fullLogoPath = Globals["ConfigForm"].data["ImageSponsor"]
  633.  
  634.         #Preenche a viewbag
  635.         viewbag.append({"Name": "lgSponsor", "Value": fullLogoPath, "Pipe": "", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": ""})
  636.         Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_In", viewbag, "Online_API")
  637.  
  638.  
  639. def SponsorWTOnlineOut():
  640.         Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", [], "Online_API")
  641.  
  642.  
  643. def SponsorOnlineOut():
  644.         #print "SponsorOnlineOut"
  645.         #Verificação se os gráficos estão no ar: Online ou online da API
  646.         if Globals["API"]:
  647.                 if Globals["API"].status == True:
  648.                         if Globals["R3_Manager"].OnAirScorebug != Script.RefName:
  649.                                 return
  650.                 else:
  651.                         if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  652.                                 return
  653.         else:
  654.                 if Globals["R3_Manager"].OnAirScorebug != "OnlineScore":
  655.                         return
  656.  
  657.         #verifica se Sponsor está no ar
  658.         if Globals["R3_Manager"].OnAirScorebugSponsor:
  659.                 #Cria uma viewBag Vazia
  660.                 viewbag = []
  661.                 Globals["R3_Manager"].ShowAnimation("Program", Script, "Sponsor_Out", viewbag, "Online_API")
  662.                 Globals["R3_Manager"].OnAirScorebugSponsor = False
  663.  
  664.         #else:
  665.                 #print "Sponsor não está no ar!!!"
  666.  
  667.  
  668. def HashTagAuto():
  669.         if not Globals["ConfigForm"] and Globals["ConfigForm"].data["HashtagTimeIn"] or int(Globals["ConfigForm"].data["HashtagTimeIn"]) * 1000 == 0:
  670.                 return
  671.  
  672.         timeSleep = int(Globals["ConfigForm"].data["HashtagTimeIn"]) * 1000
  673.         #Verify if Scorebug is onair
  674.         if Globals["R3_Manager"].OnAirScorebug == "OnlineScore" or Globals["R3_Manager"].OnAirScorebug == "Online_API":
  675.                 if not Globals["R3_Manager"].OnAirScorebugHashtag and not Globals["R3_Manager"].OnAirScorebugSponsor:
  676.                         Scheduler.Add("Online_API", "HashtagIn", Project.Name, None, timeSleep, "Online_API_Hashtag")

Reply to "Untitled"

Here you can reply to the paste above