Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Player name has no length limit #2124

Open
tobylane opened this issue Apr 6, 2022 · 6 comments
Open

[Bug] Player name has no length limit #2124

tobylane opened this issue Apr 6, 2022 · 6 comments
Labels
bug issue type

Comments

@tobylane
Copy link
Member

tobylane commented Apr 6, 2022

Describe the issue

Names that are too long are accepted and used

Steps to Reproduce

  1. In the New Game screen enter a long name (over 15 characters)

  2. Start game

  3. Look at name, eg Progress Report. The name isn't clipped and may continue beyond the space for it.

Expected Behavior

It's refused, or clipped.

System Information

3e7b389 current master

Additional Info

--[[persistable:new_game_abort_name]]function() self.name_textbox:setText(self.player_name) end)
:allowedInput({"alpha", "numbers", "misc"}):characterLimit(15):setText(self.player_name)
has the character limit
if not self.char_limit or string.len(line) < self.char_limit then
has the text input check

@tobylane tobylane added the bug issue type label Apr 6, 2022
@lewri
Copy link
Member

lewri commented Apr 6, 2022

For info: Original game only allowed 8 characters.
We also allow numbers (I'm ok with that) when original doesnt

@lewri
Copy link
Member

lewri commented May 7, 2022

Can confirm now.
Character limit should probably actually be 14, as 15 starts to go outside the boundaries on "Status" window.

@lewri
Copy link
Member

lewri commented May 25, 2022

I'm not exactly sure why this bug happens. The actual check made works properly but the keypress is still registered and added to the textbox.

@SilPho
Copy link
Contributor

SilPho commented Aug 22, 2022

This is an age-old problem when dealing with variable-width fonts. The biggest problem comes from the extremes such as "WWWWWWWW" (8 characters) or "iiiiiiiiiiiiiiiiiiiiiiiii" (25 characters) that take up roughly the same width in fonts used by the game. Both actually fit very neatly into the status and end-of-year dialogues.

This means that there are a few options, which all have their own drawbacks:

  • Limit the player to 8 characters for a very-safe approach
  • Limit the player to 14 or so characters to avoid clipping for the majority of usernames
  • Paint everything and allow overlapped text (Current behaviour)

Or, if we're able to calculate the width of a string before painting it:

  • Limit dynamically based on the width of the chosen characters (Minecraft uses this for sign text)
  • Shrink the font to fit in any screen where it would otherwise overlap
  • Only paint as much as the string as will fit, hiding the rest (Which is what the main menu text-entry box does)
  • Scroll the text back and forth inside its bounding box if it's too big to otherwise fit

This is mainly just food for thought on a low priority issue.

@lewri
Copy link
Member

lewri commented Sep 12, 2022

  • Limit dynamically based on the width of the chosen characters (Minecraft uses this for sign text)

I actually think we have have some code somewhere that already checks the pixel length of a line, for text-wrapping.

@TheCycoONE
Copy link
Member

We do yes, though I can't say it's an intuitive approach. Regardless of what we do with the dialog we'll have config.txt files that violate the length limit.

Regardless of the limit we pick here for entry we should work on hiding overflow. That's particularly necessary because the user can pick their own fonts and change them at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug issue type
Projects
None yet
Development

No branches or pull requests

4 participants