Untitled

From Mungo Cassowary, 2 Weeks ago, written in Plain Text, viewed 6 times. This paste will shuffle off the mortal coil in 1 Week.
URL https://paste.afonso.co/view/48190cb7 Embed
Download Paste or View Raw
  1. # -*- encoding: utf-8 -*-
  2.  
  3. import footballstatshelper
  4. import helper
  5. from System.Threading.Tasks import Task
  6. from System.IO import File, Path
  7.  
  8.  
  9. ######################
  10. Team4Graphic = "Away"
  11. ######################
  12.  
  13.  
  14. def __onStart(graphicOnAirItem, momentExecution, workFlowtype):
  15.     team = __GetTeam()
  16.    
  17.     if GameOnline.IsOnAir:
  18.         momentExecution.Message = "ONLINE IS ON AIR!"
  19.         momentExecution.Cancel = True
  20.         return
  21.  
  22.     if len(team.InPlay) != 11:
  23.         momentExecution.Message = "Lineup must have 11 players InPlay!"
  24.         momentExecution.Cancel = True
  25.         return
  26.        
  27.     if not team.Coach:
  28.         momentExecution.Message = "Team has no coach!"
  29.         momentExecution.Cancel = True
  30.         return
  31.  
  32.     if not team.Coach.RefName:
  33.         momentExecution.Message = "Team has no coach!"
  34.         momentExecution.Cancel = True
  35.         return
  36.        
  37.     ## VALIDATE TACTICS ###
  38.     tacticTeam = __GetTacticTeam()
  39.     tacticPlayers = list(tacticTeam.TacticPlayers)
  40.    
  41.     if list(tacticTeam.TacticPlayers).Count != 11:
  42.         momentExecution.Message = "Please fill the tactic for %s!" % team.ShortName
  43.         momentExecution.Cancel = True
  44.         return
  45.    
  46.     if not __ValidateCaptains(team):
  47.         momentExecution.Message = "Team don´t have captains!"
  48.         momentExecution.Cancel = True
  49.         return
  50.    
  51.     # VALIDATE PLAYER PHOTOS
  52.     imagesFolderPath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "fotos", team.RefName.ToString())
  53.     silhouettePath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "Fotos", "player_default.png")
  54.    
  55.     for player in team.InPlay:
  56.         imageName = "%s.png" % player.RefName.ToString()
  57.         playerPath = Path.Combine(imagesFolderPath, imageName)
  58.        
  59.         if not File.Exists(playerPath):
  60.            
  61.             if not File.Exists(silhouettePath):
  62.                 message = "Player without photo!\n\nName: %s\nNumber: %s\n\nExpected image:\n%s\n\nSilhouette was also not found:\n%s\n\nThe graphic will not be displayed." % (player.ShortName.ToString(), player.Number, playerPath, silhouettePath)
  63.                 UserInteraction.ShowMessageBoxYesNo("Missing Player Photo", message)
  64.                 momentExecution.Message = "Missing player photo and silhouette!"
  65.                 momentExecution.Cancel = True
  66.                 return
  67.            
  68.             message = "Player without photo!\n\nName: %s\nNumber: %s\n\nExpected image:\n%s\n\nDo you want to continue using the silhouette?" % (player.ShortName.ToString(), player.Number, playerPath)
  69.            
  70.             if UserInteraction.ShowMessageBoxYesNo("Missing Player Photo", message).ToString() != "Yes":
  71.                 momentExecution.Message = "Graphic canceled!"
  72.                 momentExecution.Cancel = True
  73.                 return
  74. ######################## FILL DATA ########################
  75. def __getData(viewBag,graphicOnAirItem, momentExecution):
  76.     team = __GetTeam()
  77.     tacticTeam = __GetTacticTeam()
  78.  
  79.     for i in range(1,21):
  80.         viewBag.SetString("tPlayerNumber%02d"%i,"")
  81.         viewBag.SetString("tPlayerName%02d"%i,"")
  82.         viewBag.SetFloat("vYellowCardVisibility%02d"%i,0)
  83.    
  84. #    # Validação das fotos dos jogadores
  85. #    imagesFolderPath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "fotos", team.RefName.ToString())
  86. #    silhouettePath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "Fotos", "player_default.png")
  87. #    missingPlayers = []
  88. #    
  89. #    for player in team.InPlay:
  90. #        imageName = "%s.png" % player.RefName.ToString()
  91. #        playerPath = Path.Combine(imagesFolderPath, imageName)
  92. #        
  93. #        if not File.Exists(playerPath):
  94. #            missingPlayers.append(player)
  95. #    
  96. #    if missingPlayers:
  97. #        if not File.Exists(silhouettePath):
  98. #            UserInteraction.ShowMessageBoxYesNo("Missing Player Photo", "player_default.png was not found.\n\nPath:\n%s\n\nThe graphic will not be displayed." % silhouettePath)
  99. #            return False
  100. #        
  101. #        for player in missingPlayers:
  102. #            imageName = "%s.png" % player.RefName.ToString()
  103. #            playerPath = Path.Combine(imagesFolderPath, imageName)
  104. #            
  105. #            message = "Player without photo!\n\nName: %s\nNumber: %s\n\nExpected image: %sDo you want to continue using the silhouette?" % (player.ShortName.ToString(), player.Number, playerPath)
  106. #            
  107. #            if UserInteraction.ShowMessageBoxYesNo("Missing Player Photo", message).ToString() != "Yes":
  108. #                return False
  109.    
  110.     viewBag.SetTranslatedText("tTeamName", "{{%s}}" % team.ShortName.ToUpper())
  111.     viewBag.SetImage("lgTeamBadge","Images/Equipes/%s.png"%team.RefName)
  112.     viewBag.SetImage("lgTeamColor", "Images\Degrades_Equipes\\%s.png" %team.Initials)
  113.    
  114.     if not __FillTactic(viewBag, team, tacticTeam, graphicOnAirItem): return False
  115.     __FillTacticsLineup(team, tacticTeam,viewBag, graphicOnAirItem)
  116.  
  117. def __FillTactic(viewBag, team, tacticTeam, graphicOnAirItem):
  118.     originalPlayers = list(team.InPlayByKeeperAndShirt)
  119.     tactic = __GetTacticTeam()
  120.     lines = tactic.Name.ToString().split("-")
  121.     viewBag.SetString("tFormation", tactic.Name.ToString())
  122.     lines2Vlines = list(lines)
  123.     tacticName = tactic.Name
  124.    
  125.     while len(lines2Vlines) < 4:
  126.         lines2Vlines.append("0")
  127.    
  128.     for idx, line in enumerate(lines2Vlines,1):
  129.         viewBag.SetFloat("vLines%02d"%idx,line)
  130.    
  131.     tacticPlayers = list(tacticTeam.TacticPlayers)
  132.     gkTactic = None
  133.     fieldPlayers = []
  134.    
  135.     # Separa goleiro dos jogadores de linha
  136.     for tacticPlayer in tacticPlayers:
  137.         if str(tacticPlayer.Player.Position.ToString()).strip().lower() == "gk":
  138.             gkTactic = tacticPlayer
  139.         else:
  140.             fieldPlayers.append(tacticPlayer)
  141.    
  142.     # Ordena primeiro pelos setores do campo
  143.     fieldPlayers.sort(key=lambda x: x.GraphicPosition.Y)
  144.    
  145.     orderedTacticPlayers = []
  146.     startIdx = 0
  147.    
  148.     # Separa cada setor conforme a formação e,
  149.     # dentro do setor, ordena pela posição X
  150.     for line in lines:
  151.         numPlayers = int(line)
  152.         sectorPlayers = fieldPlayers[startIdx:startIdx + numPlayers]
  153.         sectorPlayers.sort(key=lambda x: x.GraphicPosition.X)
  154.         orderedTacticPlayers.extend(sectorPlayers)
  155.         startIdx += numPlayers
  156.    
  157.     # Monta a lista final com os objetos originais
  158.     objTeamSel = []
  159.    
  160.     # Adiciona primeiro o goleiro
  161.     if gkTactic:
  162.         gkRefName = gkTactic.Player.RefName.ToString()
  163.        
  164.         for originalPlayer in originalPlayers:
  165.             if originalPlayer.RefName.ToString() == gkRefName:
  166.                 objTeamSel.append(originalPlayer)
  167.                 break
  168.    
  169.     # Adiciona os jogadores de linha na ordem tática
  170.     for tacticPlayer in orderedTacticPlayers:
  171.         tacticPlayerRefName = tacticPlayer.Player.RefName.ToString()
  172.        
  173.         for originalPlayer in originalPlayers:
  174.             if originalPlayer.RefName.ToString() == tacticPlayerRefName:
  175.                 objTeamSel.append(originalPlayer)
  176.                 break
  177.    
  178.     # Procura o goleiro dentro da lista final
  179.     gk = None
  180.    
  181.     for player in objTeamSel:
  182.         if str(player.Position.ToString()).strip().lower() == "gk":
  183.             gk = player
  184.             break
  185.    
  186.     if not __CheckValidations(objTeamSel, tacticName, gk, lines): return False
  187.    
  188.     totalLines = len(lines)
  189.     totalUsedPlayers = 0
  190.     missedPlayersVideos = []
  191.    
  192.     # Fill goalkeeper
  193.     viewBag.SetString("tPlayerName01", gk.ShortName.ToUpper())
  194.     viewBag.SetString("tPlayerNumberGoalkeeper", gk.Number)
  195.     viewBag.SetVisibility("vIconVisibility01",True)
  196.     imageName = "%s.png"%(gk.RefName.ToString())
  197.     imagesFolderPath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "fotos", team.RefName.ToString())
  198.     playerPath = Path.Combine(imagesFolderPath, imageName)
  199.    
  200.     if not File.Exists(playerPath):
  201.         viewBag.SetImage("lgPlayerPicture01", "Images\Fotos\player_default.png")
  202.     else:
  203.         viewBag.SetImage("lgPlayerPicture01", playerPath)
  204.        
  205.     if gk.AtRisk:
  206.         viewBag.SetFloat("vYellowCardGoalkeeper", 1)
  207.     else:
  208.         viewBag.SetFloat("vYellowCardGoalkeeper", 0)
  209.        
  210.     if gk.IsCaptain:
  211.         viewBag.SetFloat("vCaptainVisibility01", 1)
  212.     else:
  213.         viewBag.SetFloat("vCaptainVisibility01", 0)
  214.    
  215.     objTeamSel.remove(gk)
  216.    
  217.     tagIdx = 2
  218.    
  219.     for lineNum in range(0, totalLines):
  220.         numPlayers = int(lines[lineNum])
  221.         players = list(objTeamSel)[:numPlayers]
  222.  
  223.         totalUsedPlayers += numPlayers
  224.        
  225.         # Fill other players
  226.         for player in range(5):
  227.             try:
  228.                 currentPlayer = players[player]
  229.                
  230.                 viewBag.SetString("tPlayerName%02d" % tagIdx, currentPlayer.ShortName.ToUpper())
  231.                 viewBag.SetString("tPlayerNumber%02d" % tagIdx, currentPlayer.Number)
  232.                
  233.                 imageName = "%s.png"%(currentPlayer.RefName.ToString())
  234.                 imagesFolderPath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "fotos", team.RefName.ToString())
  235.                 playerPath = Path.Combine(imagesFolderPath, imageName)
  236.                
  237.                 if not File.Exists(playerPath):
  238.                     viewBag.SetImage("lgPlayerPicture%02d" % tagIdx, "Images\Fotos\player_default.png")
  239.                 else:
  240.                     viewBag.SetImage("lgPlayerPicture%02d" % tagIdx, playerPath)
  241.                
  242.                 if currentPlayer.AtRisk:
  243.                     viewBag.SetFloat("vYellowCardVisibility%02d"%tagIdx, 1)
  244.                 else:
  245.                     viewBag.SetFloat("vYellowCardVisibility%02d"%tagIdx, 0)
  246.                    
  247.                 if currentPlayer.IsCaptain:
  248.                     viewBag.SetFloat("vCaptainVisibility%02d" % tagIdx, 1)
  249.                 else:
  250.                     viewBag.SetFloat("vCaptainVisibility%02d" % tagIdx, 0)
  251.                
  252.                 objTeamSel.remove(currentPlayer)
  253.                
  254.             except Exception as e:
  255.                 viewBag.SetString("tPlayerName%02d" % tagIdx, "")
  256.                 viewBag.SetString("tPlayerNumber%02d" % tagIdx, "")
  257.                
  258.             tagIdx+=1
  259.    
  260.     if missedPlayersVideos:
  261.         if MsgBox.Show("fhelper", "Missing video files for the following players: \n\r%s\n\rContinue anyway?" % ", ".join(missedPlayersVideos),MsgBox.ButtonsCombo.YesNo).ToString() == "No":
  262.             return False
  263.    
  264.     return True
  265. def __FillTacticsLineup(team, tacticTeam, viewBag, graphicOnAirItem):
  266.         ##Checks
  267.         team = __GetTeam()
  268.        
  269.         tacticTeam = __GetTacticTeam()
  270.         if not tacticTeam.TacticPlayers or list(tacticTeam.TacticPlayers).Count != 11:
  271.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("Refaça a tática. Verifique novamente!", "Alert"))
  272.                 return False
  273.         #objTeamSel = [player for player in tacticTeam.TacticPlayers]
  274.         #print objTeamSel
  275.        
  276.        
  277.         viewBagOld = []
  278.         objTeamSel = [player for player in tacticTeam.TacticPlayers]           
  279.         objTeamSel.sort(__tacticsCompY)
  280.        
  281.         #print([x.Player.RefName.ToString() for x in objTeamSel])
  282.        
  283.         gks = filter(lambda x: str(x.Player.Position.ToString()).strip().lower() == "gk", objTeamSel)
  284.        
  285.         if not tacticTeam.PreTactic:
  286.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("Você não salvou a tática desse time!!", "Alert"))
  287.                 return False
  288.        
  289.         tacticName = tacticTeam.PreTactic.Name
  290.         if tacticName.ToString().strip() == "":
  291.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("Selecione a Formação tática (X-X-X) desse time!!", "Alert"))
  292.                 return False
  293.        
  294.         lines = tacticName.split("-")
  295.         #if not __CheckValidations(objTeamSel, tacticName, gks, lines): return False
  296.        
  297.         totalLines = len(lines)
  298.         missedPlayersPhotos = []
  299.        
  300.         xmax = Tactics.FieldBounds.XMax
  301.         xmin = Tactics.FieldBounds.XMin
  302.         ymax = Tactics.FieldBounds.YMax
  303.         ymin = Tactics.FieldBounds.YMin
  304.  
  305.         Tactics.FieldBounds.XMax = 2
  306.         Tactics.FieldBounds.XMin = 0
  307.         Tactics.FieldBounds.YMax = 2.5
  308.         Tactics.FieldBounds.YMin = 0
  309.        
  310.         #Fill GK
  311.         gk = gks[0]
  312.         objTeamSelWithGk = objTeamSel
  313.         coach = team.Coach#team.Coaches[0]
  314.  
  315.         viewBag.SetString("tFormation", tacticTeam.PreTactic.Name)
  316.         viewBag.SetTranslatedText("tBenchTitle", "BANCO")
  317.         viewBag.SetTranslatedText("tCoachFunction", coach.Function.ToString().ToUpper())
  318.         viewBag.SetTranslatedText("tTeamName", team.ShortName.ToUpper())
  319.         viewBag.SetString("tCoachName", coach.ShortName.ToUpper())
  320.         viewBag.SetBool("vTacticalGoalkeeperVisibility", True)
  321.         ###
  322.         imageName = "%s.png"%(coach.RefName.ToString())
  323.         imagesFolderPath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path, "Images", "fotos", team.RefName.ToString())
  324.         coachPath = Path.Combine(imagesFolderPath, imageName)
  325.        
  326.         if not File.Exists(coachPath):
  327.                 viewBag.SetImage("lgCoachPicture", "Images\Fotos\player_default.png")
  328.         else:
  329.                 viewBag.SetImage("lgCoachPicture", coachPath)
  330.        
  331.         viewBag.SetImage("lgTeamLogo","Images/Equipes/%s.png"%team.RefName)
  332.         viewBag.SetImage("lgTeamColor", "Images\Degrades_Equipes\%s.png" %team.Initials)
  333.        
  334.         Globals["PubVideoAvailable"] = False
  335.         videoFolderPath = Path.Combine(graphicOnAirItem.GraphicsEngine.Options.RootPath, graphicOnAirItem.Scene.Path,"Videos","PUB","Escalacao_tatica")
  336.         pubVideo = Path.Combine(videoFolderPath,"Escalacao_%s.mov"%Team4Graphic)
  337.        
  338.         if not File.Exists(pubVideo):
  339.                 pass
  340.         else:
  341.                 viewBag.SetVideo("vdSponsorVideo", pubVideo)
  342.                 Globals["PubVideoAvailable"] = True
  343.        
  344.        
  345.         objTeamSelWithGkList = objTeamSelWithGk
  346.        
  347.         #----------------------Clear some tags before fill-------------------------------------------
  348.         for i in range(1, 14):
  349.                 viewBag.SetVisibility("vBenchYellowCardVisibility%02d" % i, False)
  350.                 viewBag.SetVisibility("vBenchGoalkeeperIconVisibility%02d" % i, False)
  351.                
  352.        
  353.         #--------------------------------FillTags---------------------------------------
  354.         for tagIdx, player in enumerate(objTeamSelWithGkList):
  355.                 tagIdx+=1
  356.                
  357.                 if player.Player.IsCaptain:
  358.                         viewBag.SetVisibility("vTacticalCaptainVisibility%02d" % tagIdx, True)
  359.                 else:
  360.                         viewBag.SetVisibility("vTacticalCaptainVisibility%02d" % tagIdx, False)
  361.                        
  362.                 if player.Player.AtRisk:
  363.                         viewBag.SetVisibility("vTacticalYellowCardVisibility%02d" % tagIdx, True)
  364.                 else:
  365.                         viewBag.SetVisibility("vTacticalYellowCardVisibility%02d" % tagIdx, False)
  366.                
  367.                 if " " not in player.Player.ShortName:
  368.                         viewBag.SetString("tTacticalPlayerFirstName%02d" % tagIdx, player.Player.ShortName.ToUpper())
  369.                         viewBag.SetString("tTacticalPlayerLastName%02d" % tagIdx, "")
  370.                 else:
  371.                         firstAndLastName = player.Player.ShortName.split(" ")
  372.                         viewBag.SetString("tTacticalPlayerFirstName%02d" % tagIdx, firstAndLastName[0].ToUpper())
  373.                         viewBag.SetString("tTacticalPlayerLastName%02d" % tagIdx, firstAndLastName[1].ToUpper())
  374.                 viewBag.SetString("tTacticalPlayerNumber%02d" % tagIdx, player.Player.Number)
  375.                 viewBag.SetFloat("vTacticalPlayerPositionX%02d" % tagIdx, player.GraphicPosition.X )
  376.                 viewBag.SetFloat("vTacticalPlayerPositionY%02d" % tagIdx, player.GraphicPosition.Y )
  377.                 #print "X: %s" % player.GraphicPosition.X
  378.                 #print "Y: %s" % player.GraphicPosition.Y
  379.                
  380.         benchPlayers = team.InBench
  381.         sortedBench = sorted(benchPlayers, key=lambda player: (str(player.Position).lower() != "gk", int(player.Number)))
  382.         viewBagOld.append({"Name": "vLinesBench", "Value": len(benchPlayers), "Pipe": " ", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": "Tactical"})
  383.         viewBag.SetString("vLinesBench", int(len(benchPlayers)))
  384.         for tagIdx, player in enumerate(sortedBench):
  385.                 tagIdx+=1
  386.                 if player.AtRisk:
  387.                         viewBagOld.append({"Name": "vBenchYellowCardVisibility%02d" % tagIdx, "Value": True, "Pipe": " ", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": "Tactical"})
  388.                         viewBag.SetString("vBenchYellowCardVisibility%02d" % tagIdx, True)
  389.                 else:
  390.                         viewBagOld.append({"Name": "vBenchYellowCardVisibility%02d" % tagIdx, "Value": False, "Pipe": " ", "ToUpper": False, "IsAdvert": False, "Translate": False, "Context": "Tactical"})
  391.                         viewBag.SetString("vBenchYellowCardVisibility%02d" % tagIdx, False)    
  392.                
  393.                 viewBag.SetString("tBenchPlayerName%02d" % tagIdx, player.ShortName.ToUpper())
  394.                 viewBag.SetString("tBenchPlayerNumber%02d" % tagIdx, player.Number)
  395.                
  396.                 if str(player.Position).lower() == "gk":
  397.                         viewBag.SetVisibility("vBenchGoalkeeperIconVisibility{:02d}".format(tagIdx), True)
  398.                 else:
  399.                         viewBag.SetVisibility("vBenchGoalkeeperIconVisibility{:02d}".format(tagIdx), False)
  400.         return True
  401.        
  402.        
  403. def __CheckValidations(objTeamSel, tacticName, gks, lines):
  404.         if gks.Count < 1:
  405.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("%s team tactic has no goalkeeper!"%Team4Graphic, "Alert"))
  406.                 return False
  407.         elif gks.Count > 1:
  408.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("%s team tactic has more than 1 goalkeeper!"%Team4Graphic, "Alert"))
  409.                 return False
  410.                        
  411.         if len(lines) < 3:
  412.                 Core.StatusManager.Add("Fill tactic name (use '-' to separate) Ex: 4-2-3-1")
  413.                 return False
  414.        
  415.         num = 0
  416.         for line in lines:
  417.                 if not line.isdigit():
  418.                         Core.StatusManager.Add("%s is not a valid digit" % line)
  419.                         return False
  420.                 num+=int(line)
  421.                
  422.         if num != 10:
  423.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("Tactic name isn't valid", "Alert"))
  424.                 return False
  425.        
  426.        
  427.         return True
  428.        
  429. def __getColor():
  430.         color = ProjectSettings["GraphicColor"]
  431.         if color == "Amarelo":
  432.                 return "235,174,0"
  433.         elif color == "Azul Escuro":
  434.                 return "15,39,148"
  435.         elif color == "Cian":
  436.                 return "13,133,181"
  437.         elif color == "Laranja":
  438.                 return "203,106,0"
  439.         elif color == "Verde":
  440.                 return "27,125,61"
  441.         elif color == "Vermelho":
  442.                 return "199,0,27"
  443.         elif color == "Violeta":
  444.                 return "142,36,147"
  445.         return "255,255,255"
  446.        
  447. def __tacticsCompY(obj1, obj2):
  448.         return obj1.GraphicPosition.Y > obj2.GraphicPosition.Y
  449.        
  450.        
  451. def __tacticsCompX(obj1, obj2):
  452.         return obj1.GraphicPosition.X > obj2.GraphicPosition.X
  453.        
  454.  
  455. def __afterProgram(graphicOnAirItem, momentExecution):
  456.         graphic = GraphicTemplatesManager.GetGraphicByName(Script.Name)
  457.         graphicOnAirItens = IntelliflowController.GetGraphicOnAirItems(graphic, OutputManager.ActiveChannelOutput)
  458.        
  459.         #Sponsor###################################
  460.         if Globals["PubVideoAvailable"]:
  461.                 if Project.ProjectSettings["PUB Lineup"]:
  462.                         for graphic in graphicOnAirItens:
  463.                                 graphic.Scene.Show("Sponsor_In")
  464.         ###########################################
  465.                
  466.         tactic = __GetTacticTeam()
  467.         lines = tactic.Name.ToString().split("-")
  468.        
  469.         for i in range(1, int(len(lines))+1):
  470.                 if UserInteraction.ShowMessageBoxYesNo("LineUp", "Continue Change?").ToString() != "Yes": return
  471.                 for graphic in graphicOnAirItens:
  472.                         graphic.Scene.Show("Change_%02d"%i)
  473.                        
  474.         if UserInteraction.ShowMessageBoxYesNo("LineUp", "Take Tactical?").ToString() == "Yes":
  475.                 for graphic in graphicOnAirItens:
  476.                         if Project.ProjectSettings["PUB Lineup"]:
  477.                                 graphic.Scene.Show("Sponsor_Out")
  478.                         graphic.Scene.Show("ChangeToTactics")
  479.                 Globals["PubVideoAvailable"] = False
  480.        
  481. def __beforeProgramOut(graphicOnAirItem, momentExecution):
  482.         graphic = GraphicTemplatesManager.GetGraphicByName(Script.Name)
  483.         graphicOnAirItens = IntelliflowController.GetGraphicOnAirItems(graphic, OutputManager.ActiveChannelOutput)
  484.         if Globals["PubVideoAvailable"]:
  485.                 if Project.ProjectSettings["PUB Lineup"]:
  486.                         for graphic in graphicOnAirItens:
  487.                                 graphic.Scene.Show("Sponsor_Out")
  488.                         Globals["PubVideoAvailable"] = False
  489.        
  490.  
  491. def __GetTeam():
  492.         if Team4Graphic == "Home":
  493.                 return Game.HomeTeam
  494.         else:
  495.                 return Game.AwayTeam
  496.        
  497.        
  498. def __GetTacticTeam():
  499.         if Team4Graphic == "Home":
  500.                 return Tactics.HomeTeamConfig
  501.         else:
  502.                 return Tactics.AwayTeamConfig
  503.        
  504.  
  505. def __ValidateCaptains(team):
  506.         captains = footballstatshelper.GetCaptainCount(team.InPlay)
  507.         return captains
  508.  
  509.  
  510. def __CheckValidations(objTeamSel, tacticName, gk, lines):
  511.         if not gk:
  512.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("Esse time não tem goleiro! Reveja e verifique a função!", "Alert"))
  513.                 return False
  514.                
  515.         if len(lines) < 3:
  516.                 Core.StatusManager.Add("Preencha a formação tática (use '-' para separar) Ex: 4-2-3-1")
  517.                 return False
  518.        
  519.         num = 0
  520.         for line in lines:
  521.                 if not line.isdigit():
  522.                         Core.StatusManager.Add("%s não é um dígito válido" % line)
  523.                         return False
  524.                 num+=int(line)
  525.                
  526.         if num != 10:
  527.                 Core.StatusManager.Add(Dictionary.TranslateWithContext("Tática não é válida. Refazer", "Alert"))
  528.                 return False
  529.        
  530.         return True
  531.  

Reply to "Untitled"

Here you can reply to the paste above