Make tweaks to sponsor/player avatar exporting to replace invalid characters with underscores (#870)

* Make tweaks to sponsor/player avatar exporting to replace invalid characters with underscores
- Also tweaked export to cascade down sponsors to find any valid sponsors over just checking once
- In addition to cascading, we also now export all found sponsor logos in order for a potential rotating sponsor feature in layouts
- Tweaked info files in sponsor_logo and player_avatar folders to identify what will get replaced when checking

* Remove replacing spaces and update README files for folders to be correct
This commit is contained in:
Eion Dailey
2025-08-03 12:04:38 -04:00
committed by GitHub
parent 62bfed5742
commit af4e1f0d0d
3 changed files with 29 additions and 11 deletions

View File

@@ -280,8 +280,7 @@ class TSHScoreboardPlayerWidget(QGroupBox):
merged += name
merged = merged.replace("/", " ")
merged = merged.replace(":", " ")
merged = re.sub(r"[,/|;:<>\\?*]", "_", merged)
# Online avatar
StateManager.Set(
@@ -294,14 +293,29 @@ class TSHScoreboardPlayerWidget(QGroupBox):
else:
StateManager.Set(
f"{self.path}.avatar", None)
sponsor_logo = None
# Sponsor logo
if os.path.exists(f"./user_data/sponsor_logo/{team.upper()}.png"):
StateManager.Set(
f"{self.path}.sponsor_logo", f"./user_data/sponsor_logo/{team.upper()}.png")
cleaned_sponsor = re.sub(r"[,/|;:<>\\?*]", "_", team)
if os.path.exists(f"./user_data/sponsor_logo/{cleaned_sponsor.upper()}.png"):
sponsor_logo = f"./user_data/sponsor_logo/{cleaned_sponsor.upper()}.png"
StateManager.Unset(f"{self.path}.sponsor_logos")
else:
StateManager.Set(
f"{self.path}.sponsor_logo", None)
split_sponsor = re.split(r"[,/|;: <>\\?*]", team)
for i, sponsor in enumerate(split_sponsor):
if os.path.exists(f"./user_data/sponsor_logo/{sponsor.upper()}.png"):
if sponsor_logo is None:
sponsor_logo = f"./user_data/sponsor_logo/{sponsor.upper()}.png"
StateManager.Set(
f"{self.path}.sponsor_logos.{int(i+1)}", f"./user_data/sponsor_logo/{sponsor.upper()}.png")
if sponsor_logo is not None:
StateManager.Set(f"{self.path}.sponsor_logo", sponsor_logo)
else:
StateManager.Unset(f"{self.path}.sponsor_logo")
if sponsor_logo is None:
StateManager.Unset(f"{self.path}.sponsor_logos")
def ExportPlayerId(self, id=None):
with self.dataLock:

View File

@@ -1,4 +1,4 @@
Since "/", ":" and "|" cannot be used in file names, change any ocurrence of those to a space " ".
As the following characters (,/|;:<>\?*) are not able to be used in (Windows) file names,
all invalid characters will need to be replaced with an underscore (_) to be recognized as valid for TSH.
The image will only be exported once you open the program and select the player.
Adding the image here after the player is set or with the program closed will have no effect.
The image will only be exported once you open the program and select the player.

View File

@@ -0,0 +1,4 @@
As the following characters (,/|;:<>\?*) are not able to be used in (Windows) file names,
all invalid characters will need to be replaced with an underscore (_) to be recognized as valid for TSH.
The image will only be exported once you open the program and select the player.