MLB-LED-Scoreboard / mlb-led-scoreboard

An LED scoreboard for Major League Baseball :baseball:
GNU General Public License v3.0
582 stars 105 forks source link

Add the ability to truncate team names to a desired length #456

Closed swemoney closed 1 year ago

swemoney commented 1 year ago

Currently working on a 64x32 layout that uses the 5x7 font a lot more. Needed a way to specify a specific number of characters to allow for the team name (instead of just going to the short 3 character names). This will allow you to add a truncate key to the teams.name.home or teams.name.away key-paths in your coordinates file to specify a truncate length. If the key isn't found, it falls back to the previous default of 13 characters.

WardBrian commented 1 year ago

It seems pretty config specific to not have this take effect during the warmup statuses. Not sure if there is a general way to capture that idea however.

How does this end up looking in practice?

swemoney commented 1 year ago

Ya. Maybe I can try and add the warmup key to my teams.name paths and see if I can specify a specific truncate length for that. I only ignored during warmup since the runs/errors/hits leave more room to display a full team name.

swemoney commented 1 year ago

I'll need to wait for tomorrow for another warmup game to test it out

WardBrian commented 1 year ago

I forgot we had warmup as a state (I only use the no hitter/perfect game states in my config) but it should definitely be possible to use that for this and not have that conditional.

swemoney commented 1 year ago

It's been a while since I worked on this codebase and so much has changed. Just needed to brush off some dust to remember how the optional keys worked again.

Removed the conditional. Now you'll need to add a full warmup key in addition to the truncate key to get this to work. But it's completely optional and everything should work exactly like it did before if you don't need to worry about truncating.

Example:

      "away": {
        "font_name": "5x7",
        "x": 2,
        "y": 7,
        "truncate": 8,
        "warmup": {
          "font_name": "5x7",
          "truncate": 13,
          "x": 2,
          "y": 7
        }
      },
      "home": {
        "font_name": "5x7",
        "x": 2,
        "y": 15,
        "truncate": 8,
        "warmup": {
          "font_name": "5x7",
          "truncate": 13,
          "x": 2,
          "y": 15
        }
      }
    },
swemoney commented 1 year ago

I'm not sure if it's too niche of a thing to stick it in all of the examples, but maybe we could document it in the coords wiki? Either one could work though.

WardBrian commented 1 year ago

Maybe you could contribute your eventual layout which uses it to https://github.com/MLB-LED-Scoreboard/mlb-led-scoreboard/wiki/Community-Layouts-and-Colors and that would be enough?

swemoney commented 1 year ago

That could be enough. If we have other users craving a way to truncate team names in the layouts, we could always do more for discoverability then.

swemoney commented 1 year ago

Did these changes get overwritten somewhere? I'm not seeing them in master or dev right now. I know I messed up by branching off of master instead of dev initially. Not sure if that screwed up the merge somewhere.