From 482ea7b85b162bd8024a641ed0c63926b309744e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ribeiro=20Bezerra?= Date: Mon, 27 Nov 2023 20:02:52 +0000 Subject: [PATCH] Fixes after merges --- assets/characters.json | 48 ++++++------ src/TSHScoreboardWidget.py | 37 +++++---- .../StartGGDataProvider.py | 34 ++++---- src/TournamentStreamHelper.py | 77 +++++++++++-------- 4 files changed, 111 insertions(+), 85 deletions(-) diff --git a/assets/characters.json b/assets/characters.json index 96c2173cf..caa242d59 100644 --- a/assets/characters.json +++ b/assets/characters.json @@ -93123,12 +93123,12 @@ "externalIdMap": null, "images": [ { - "id": 5295601, - "width": 128, - "height": 128, + "id": 6351567, + "width": 100, + "height": 100, "ratio": 1, "type": "icon", - "url": "https://images.start.gg/images/character/2117/image-9af30f4cdea6380c8248d54c6a72cb16.png?ehk=DeLexla292Wtzl%2FDCa3PY21LPuOsOvZNlzZOpFWnGPU%3D&ehkOptimized=3t8w4oaCI%2FnF5E2e%2F7szsN%2Frp5oAg8VZ25q7S8MMfbA%3D", + "url": "https://images.start.gg/images/character/2117/image-00fa448ef27bac5460f70a8b3e31fe70.png?ehk=um5v6YI62BSnKvlib18EFQXh5d5hrp%2F4KtZch5Jldbo%3D&ehkOptimized=0PS69uvM2HWV4j1vet4ubcfv%2F0yxX5vQGo%2B9ZylCJZw%3D", "isOriginal": true, "entity": null, "entityId": null, @@ -93137,12 +93137,12 @@ "updatedAt": null }, { - "id": 5295602, - "width": 128, - "height": 128, + "id": 6351568, + "width": 30, + "height": 30, "ratio": 1, "type": "stockIcon", - "url": "https://images.start.gg/images/character/2117/image-b811b89cb9663f25bb83b2b3e2a82fd0.png?ehk=dJ2vho4msi2VafhGy6mbaQqSIJkgCggr%2FlwCvxM%2BqAo%3D&ehkOptimized=YO2snlEDm7YZ3anQC7WUpZZVWI8%2BWag19XAJ24sgjgI%3D", + "url": "https://images.start.gg/images/character/2117/image-1ea13bc59a2560f244cf5a791903a9ae.png?ehk=iQ9MU6cI4hn9E3d6mf%2BYXMD8vDfL8etUv5Tqb0YaWCc%3D&ehkOptimized=rwpmd%2F6OH80hQUPiiQ81SLu8cYEi7nBXEczjDf%2BQug4%3D", "isOriginal": true, "entity": null, "entityId": null, @@ -93162,12 +93162,12 @@ "externalIdMap": null, "images": [ { - "id": 5295761, - "width": 128, - "height": 128, + "id": 6351571, + "width": 100, + "height": 100, "ratio": 1, "type": "icon", - "url": "https://images.start.gg/images/character/2118/image-21f66acf28049f077cbe05db1f6c7477.png?ehk=6xPqosSx53LaVshjJQx9lW0SQBa4D%2B0KKShMau8dLuU%3D&ehkOptimized=BG81LZgdU1Pl2FFn7dE%2BvCZrxPAQ5uV%2Fjhh5QipW3wQ%3D", + "url": "https://images.start.gg/images/character/2118/image-630519f54510cde54c5d62963981a298.png?ehk=Fto92Wj9F5PGYZagI41hIwZEfRpeUX5Bk3p9povAFE0%3D&ehkOptimized=L9yP3nr0UmQkrfcZRsQVqSpGYmvx1%2BUPR%2Fr87uNd5MQ%3D", "isOriginal": true, "entity": null, "entityId": null, @@ -93176,12 +93176,12 @@ "updatedAt": null }, { - "id": 5295762, - "width": 128, - "height": 128, + "id": 6351572, + "width": 30, + "height": 30, "ratio": 1, "type": "stockIcon", - "url": "https://images.start.gg/images/character/2118/image-21f66acf28049f077cbe05db1f6c7477.png?ehk=6xPqosSx53LaVshjJQx9lW0SQBa4D%2B0KKShMau8dLuU%3D&ehkOptimized=BG81LZgdU1Pl2FFn7dE%2BvCZrxPAQ5uV%2Fjhh5QipW3wQ%3D", + "url": "https://images.start.gg/images/character/2118/image-4aa1d65938df744131b2588a6e3affe0.png?ehk=wtePkJbQNsMxW2z7FqGRS11XoWpBDJowO4BSBtuoimM%3D&ehkOptimized=MeZOZgOySIGlhamJ3c%2BHKJRVtl7Pc%2B43fucYk1o6Ehg%3D", "isOriginal": true, "entity": null, "entityId": null, @@ -93201,12 +93201,12 @@ "externalIdMap": null, "images": [ { - "id": 5295763, - "width": 128, - "height": 128, + "id": 6351573, + "width": 100, + "height": 100, "ratio": 1, "type": "icon", - "url": "https://images.start.gg/images/character/2119/image-4c3aeab45ad55742de29613b43b06568.png?ehk=%2FIMC8t%2F35X9hTzzzNAeHgTq3nhPVOEDzt0VIGXxYT%2BY%3D&ehkOptimized=z3Ah%2FMXKxY5fDvuU6S50N6R3d8fhVLOqx0pIpwZhhg0%3D", + "url": "https://images.start.gg/images/character/2119/image-274d8c41ec8098afb01fe80e06ac106e.png?ehk=SzBOvNKjna3O%2Fvw1HzTqTcmdC7CzQaFbnZTxZoOfaK0%3D&ehkOptimized=f0Z0Bhx4UCsQiQmJbZ7b5Uc5cQMary3AMJMQxYp0tNg%3D", "isOriginal": true, "entity": null, "entityId": null, @@ -93215,12 +93215,12 @@ "updatedAt": null }, { - "id": 5295764, - "width": 128, - "height": 128, + "id": 6351574, + "width": 30, + "height": 30, "ratio": 1, "type": "stockIcon", - "url": "https://images.start.gg/images/character/2119/image-5ba945181147868f0277523ab8910264.png?ehk=CUOPOKjZc8EGMOH4%2BpttM9puSMVrk5LekhRixYBmGFY%3D&ehkOptimized=3JRZP8MJK3uVnyh6pwECIiqwsRmhHL9rcZf%2BkY3zNjU%3D", + "url": "https://images.start.gg/images/character/2119/image-0cb5231e1123ac87583d91456bbe86ff.png?ehk=LJZzAE5SQG45gOPLpkW44QmmIBnTvQNDc78zBhoCHcg%3D&ehkOptimized=EF2QPPNrznYoiUTMjeQTBdyOZC%2Brz0RK7GBNdVwuKh4%3D", "isOriginal": true, "entity": null, "entityId": null, diff --git a/src/TSHScoreboardWidget.py b/src/TSHScoreboardWidget.py index 4fbf188e9..51679e609 100644 --- a/src/TSHScoreboardWidget.py +++ b/src/TSHScoreboardWidget.py @@ -270,19 +270,20 @@ def __init__(self, scoreboardNumber=1, *args): self.columns.layout().addWidget(self.team1column) self.team1column.findChild(QLabel, "teamLabel").setText( QApplication.translate("app", "TEAM {0}").format(1)) - + DEFAULT_TEAM1_COLOR = 'rgb(254, 54, 54)' - + self.colorButton1 = TSHColorButton(color=DEFAULT_TEAM1_COLOR) # self.colorButton1.setText(QApplication.translate("app", "COLOR")) self.colorButton1.colorChanged.connect( - lambda color: [ - self.CommandTeamColor(0, color) - ]) + lambda color: [ + self.CommandTeamColor(0, color) + ]) self.CommandTeamColor(0, DEFAULT_TEAM1_COLOR) - - self.team1column.findChild(QHBoxLayout, "horizontalLayout_2").layout().insertWidget(0, self.colorButton1) - self.team1column.findChild(QScrollArea).setWidget(QWidget()) + + self.team1column.findChild(QHBoxLayout, "horizontalLayout_2").layout( + ).insertWidget(0, self.colorButton1) + self.team1column.findChild(QScrollArea).setWidget(QWidget()) self.team1column.findChild( QScrollArea).widget().setLayout(QVBoxLayout()) @@ -309,18 +310,19 @@ def __init__(self, scoreboardNumber=1, *args): self.columns.layout().addWidget(self.team2column) self.team2column.findChild(QLabel, "teamLabel").setText( QApplication.translate("app", "TEAM {0}").format(2)) - + DEFAULT_TEAM2_COLOR = 'rgb(46, 137, 255)' - + self.colorButton2 = TSHColorButton(color=DEFAULT_TEAM2_COLOR) self.colorButton2.colorChanged.connect( - lambda color: [ - self.CommandTeamColor(1, color) - ]) + lambda color: [ + self.CommandTeamColor(1, color) + ]) # self.colorButton2.setText(QApplication.translate("app", "COLOR")) self.CommandTeamColor(1, DEFAULT_TEAM2_COLOR) - self.team2column.findChild(QHBoxLayout, "horizontalLayout_2").layout().insertWidget(0, self.colorButton2) - + self.team2column.findChild(QHBoxLayout, "horizontalLayout_2").layout( + ).insertWidget(0, self.colorButton2) + self.team2column.findChild(QScrollArea).setWidget(QWidget()) self.team2column.findChild( QScrollArea).widget().setLayout(QVBoxLayout()) @@ -805,11 +807,12 @@ def ClearScore(self): self.team1column.findChild(QCheckBox, "losers").setChecked(False) self.team2column.findChild(QCheckBox, "losers").setChecked(False) - + def CommandTeamColor(self, team: int, color): if team in (0, 1): StateManager.BlockSaving() - StateManager.Set(f"score.{self.scoreboardNumber}.team.{team + 1}.color", color) + StateManager.Set( + f"score.{self.scoreboardNumber}.team.{team + 1}.color", color) StateManager.ReleaseSaving() # Modifies the current set data. Does not check for id, so do not call this with data that may lead to another hbox incident diff --git a/src/TournamentDataProvider/StartGGDataProvider.py b/src/TournamentDataProvider/StartGGDataProvider.py index da127658d..534b1afe5 100644 --- a/src/TournamentDataProvider/StartGGDataProvider.py +++ b/src/TournamentDataProvider/StartGGDataProvider.py @@ -474,23 +474,31 @@ def GetStations(self, progress_callback=None): stations = deep_get(data, "data.event.stations.nodes", []) queues = deep_get(data, "data.event.tournament.streamQueue", []) - for station in stations: - final_data.append({ - "id": station.get("id"), - "identifier": station.get("number"), - "type": "station", - "stream": next((deep_get(s, "stream.streamName", None) for s in queues if str(deep_get(s, "stream.id", None)) == str(station.get("streamId"))), "") - }) + if stations is not None: + for station in stations: + stream = "" + + if queues is not None: + stream = next((deep_get(s, "stream.streamName", None) for s in queues if str( + deep_get(s, "stream.id", None)) == str(station.get("streamId"))), "") - for queue in queues: - if queue.get("stream") is not None: - stream = queue.get("stream") final_data.append({ - "id": stream.get("id"), - "identifier": stream.get("streamName"), - "type": "stream" + "id": station.get("id"), + "identifier": station.get("number"), + "type": "station", + "stream": stream }) + if queues is not None: + for queue in queues: + if queue.get("stream") is not None: + stream = queue.get("stream") + final_data.append({ + "id": stream.get("id"), + "identifier": stream.get("streamName"), + "type": "stream" + }) + return (final_data) except Exception as e: logger.error(traceback.format_exc()) diff --git a/src/TournamentStreamHelper.py b/src/TournamentStreamHelper.py index be3ffb77b..27a6c0a5b 100755 --- a/src/TournamentStreamHelper.py +++ b/src/TournamentStreamHelper.py @@ -49,7 +49,8 @@ def handle_exception(exc_type, exc_value, exc_traceback): sys.__excepthook__(exc_type, exc_value, exc_traceback) return - logger.critical("Uncaught exception", exc_info=(exc_type, exc_value, exc_traceback)) + logger.critical("Uncaught exception", exc_info=( + exc_type, exc_value, exc_traceback)) sys.excepthook = handle_exception @@ -152,7 +153,7 @@ def UpdateProcedure(): messagebox.exec() except Exception as e: # Layout folder backups failed - logger.error(traceback.format_exc()) + logger.error(traceback.format_exc()) buttonReply = QDialog() buttonReply.setWindowTitle( @@ -323,7 +324,8 @@ def __init__(self, loop): self.addDockWidget( Qt.DockWidgetArea.BottomDockWidgetArea, self.scoreboard) self.dockWidgets.append(self.scoreboard) - TSHScoreboardManager.instance.setWindowTitle(QApplication.translate("app", "Scoreboard Manager")) + TSHScoreboardManager.instance.setWindowTitle( + QApplication.translate("app", "Scoreboard Manager")) self.stageWidget = TSHScoreboardStageWidget() self.stageWidget.setObjectName( @@ -658,17 +660,21 @@ def __init__(self, loop): self.scoreboardAmount.setMaximum(10) self.scoreboardAmount.valueChanged.connect( - lambda val: - TSHScoreboardManager.instance.signals.ScoreboardAmountChanged.emit(val) + lambda val: + TSHScoreboardManager.instance.signals.ScoreboardAmountChanged.emit( + val) ) label_margin = " "*18 - label = QLabel(label_margin + QApplication.translate("app", "Number of Scoreboards")) - label.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) + label = QLabel( + label_margin + QApplication.translate("app", "Number of Scoreboards")) + label.setSizePolicy(QSizePolicy.Policy.Fixed, + QSizePolicy.Policy.Minimum) self.btLoadModifyTabName = QPushButton( QApplication.translate("app", "Modify Tab Name")) - self.btLoadModifyTabName.setSizePolicy(QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) + self.btLoadModifyTabName.setSizePolicy( + QSizePolicy.Policy.Fixed, QSizePolicy.Policy.Minimum) self.btLoadModifyTabName.clicked.connect(self.ChangeTab) hbox.addWidget(label) @@ -702,7 +708,8 @@ def __init__(self, loop): StateManager.ReleaseSaving() - TSHScoreboardManager.instance.signals.ScoreboardAmountChanged.connect(self.ToggleTopOption) + TSHScoreboardManager.instance.signals.ScoreboardAmountChanged.connect( + self.ToggleTopOption) def SetGame(self): index = next((i for i in range(self.gameSelect.model().rowCount()) if self.gameSelect.itemText(i) == TSHGameAssetManager.instance.selectedGame.get( @@ -941,7 +948,7 @@ def ToggleTopOption(self): else: self.btLoadPlayerSet.setHidden(False) self.btLoadPlayerSetOptions.setHidden(False) - + def ChangeTab(self): tabNameWindow = QDialog(self) tabNameWindow.setWindowTitle( @@ -960,17 +967,20 @@ def ChangeTab(self): name = QLineEdit() vbox.addWidget(name) - setSelection = QPushButton(text=QApplication.translate("app", "Set Tab Title")) + setSelection = QPushButton( + text=QApplication.translate("app", "Set Tab Title")) + def UpdateTabName(): - TSHScoreboardManager.instance.SetTabName(number.value(), name.text()) + TSHScoreboardManager.instance.SetTabName( + number.value(), name.text()) tabNameWindow.close() - + setSelection.clicked.connect(UpdateTabName) vbox.addWidget(setSelection) tabNameWindow.show() - + def MigrateWindow(self): migrateWindow = QDialog(self) migrateWindow.setWindowTitle( @@ -981,13 +991,15 @@ def MigrateWindow(self): hbox = QHBoxLayout() label = QLabel(QApplication.translate("app", "File Path")) filePath = QLineEdit() - fileExplorer = QPushButton(text=QApplication.translate("app", "Find File...")) + fileExplorer = QPushButton( + text=QApplication.translate("app", "Find File...")) hbox.addWidget(label) hbox.addWidget(filePath) hbox.addWidget(fileExplorer) vbox.addLayout(hbox) - migrate = QPushButton(text=QApplication.translate("app", "Migrate Layout")) + migrate = QPushButton( + text=QApplication.translate("app", "Migrate Layout")) def open_dialog(): fname, _ok = QFileDialog.getOpenFileName( @@ -998,43 +1010,46 @@ def open_dialog(): ) if fname: filePath.setText(str(fname)) - + fileExplorer.clicked.connect(open_dialog) def MigrateLayout(): data = None with open(filePath.text(), 'r') as file: data = file.read() - + data = data.replace("data.score.", "data.score[1].") data = data.replace("oldData.score.", "oldData.score[1].") - data = data.replace("_.get(data, \"score.stage_strike." - , "_.get(data, \"score.1.stage_strike.") - data = data.replace("_.get(oldData, \"score.stage_strike." - , "_.get(oldData, \"score.1.stage_strike.") - data = data.replace("source: `score.team.${t + 1}`" - , "source: `score.1.team.${t + 1}`") - data = data.replace("data.score[1].ruleset", "data.score.ruleset") - + data = data.replace( + "_.get(data, \"score.stage_strike.", "_.get(data, \"score.1.stage_strike.") + data = data.replace( + "_.get(oldData, \"score.stage_strike.", "_.get(oldData, \"score.1.stage_strike.") + data = data.replace( + "source: `score.team.${t + 1}`", "source: `score.1.team.${t + 1}`") + data = data.replace( + "data.score[1].ruleset", "data.score.ruleset") + with open(filePath.text(), 'w') as file: file.write(data) - + logger.info("Completed Layout Migration at: " + filePath.text()) completeDialog = QDialog(migrateWindow) completeDialog.setWindowTitle( - QApplication.translate("app", "Migration Complete")) + QApplication.translate("app", "Migration Complete")) completeDialog.setMinimumWidth(500) vbox2 = QVBoxLayout() completeDialog.setLayout(vbox2) - completeText = QLabel(QApplication.translate("app", "Layout Migration has completed!")) + completeText = QLabel(QApplication.translate( + "app", "Layout Migration has completed!")) completeText.setAlignment(Qt.AlignmentFlag.AlignCenter) - closeButton = QPushButton(text=QApplication.translate("app", "Close Window")) + closeButton = QPushButton( + text=QApplication.translate("app", "Close Window")) vbox2.addWidget(completeText) vbox2.addWidget(closeButton) closeButton.clicked.connect(completeDialog.close) completeDialog.show() - + migrate.clicked.connect(MigrateLayout) vbox.addWidget(migrate)