Skip to main content

Module name_entry

Module name_entry 

Source
Expand description

Typing a name: a player profile’s, a hero’s, a farm’s.

On a keyboard the player types it (NameBox). While the box is open the game’s keys do nothing (its letters are letters then); the text box’s own fixed keys finish, delete and cancel (text_key). With a controller, or on a device with no keyboard, it is spelled on a letter grid instead (NameEntry) with the cursor and Confirm, like a console’s naming screen.

Name rules for both (NameRules): letters (A-Z, a-z), -, ', digits where the rules allow them, and single spaces between words, at most so many characters, not blank.

Neither decides what Cancel means: they report it (NameEvent::Cancel) and the screen closes the box, or asks first. The name is the screen’s to take only on NameEvent::Done.

The look is a skin: TypingView and GridView say what a box shows, and glyph paints them.

Modules§

glyph
The glyph look of the name boxes: the typing box and the letter grid, each a double-bordered box with its title in the top border and the name so far with a cursor. Everything about the look lives here; nothing here decides what a box shows. Another look is another paint_* of the same views.

Structs§

GridView
The letter grid.
NameBox
The name being typed on the keyboard.
NameEntry
The name grid (a controller, or a device with no keyboard).
NameRules
What a name may hold.
TypingView
The typing box.

Enums§

GridCell
One cell of the name grid.
NameEvent
What a key did in a name box or the name grid.

Constants§

DELETE
The text key of the cell that deletes the last letter.
DONE
The text key of the cell that closes the name grid.
HELP_GRID
The text key of the help line while the name grid is open.
SPACE
The text key of the name grid’s cell that types a space.
TYPE_HINT
The text key of the typing box’s hint.

Functions§

finished
name finished: trimmed, or None if blank.
grid
The name grid’s rows: four rows of letters, a row of digits if rules allow them, then -, ', Blank, Delete and Done.