What the player types on the connect screen, checked before joining.
More...
#include </__w/project-rtype/project-rtype/client/network/include/rtype/connect_form.hpp>
|
| | ConnectForm (const ClientSettings &settings) |
| | Creates the form, filled with settings (the command line's, or the last ones used), the name focused.
|
| |
| ConnectField | focused () const noexcept |
| | The focused field, which type() and erase() change.
|
| |
| void | focus (ConnectField field) noexcept |
| | Focuses a field.
|
| |
| void | next () noexcept |
| | Focuses the next field, the first after the last one.
|
| |
| void | previous () noexcept |
| | Focuses the previous field, the last before the first one.
|
| |
| bool | type (char character) |
| | Adds an ASCII character at the end of the focused field.
|
| |
| void | erase () noexcept |
| | Removes the last character of the focused field, if any.
|
| |
| bool | set_text (ConnectField field, std::string_view text) |
| | Replaces the text of a field, as edited in a text field.
|
| |
| const std::string & | text (ConnectField field) const |
| | Text of a field.
|
| |
| std::variant< ClientSettings, std::string > | submit () const |
| | Checks the fields and gives the settings to join with.
|
| |
|
| static bool | accepts (ConnectField field, char character) noexcept |
| | Tells whether a field takes a character, or a byte of a UTF-8 character.
|
| |
| static std::size_t | max_length (ConnectField field) noexcept |
| | Longest text of a field.
|
| |
|
| static constexpr std::size_t | max_host = 45 |
| | Longest address: an IPv6 address with its brackets fits.
|
| |
| static constexpr std::size_t | max_port = 5 |
| | Longest port: five digits.
|
| |
| static constexpr std::size_t | max_name = 16 |
| | Longest name, in bytes of UTF-8, as LoginRequest allows.
|
| |
What the player types on the connect screen, checked before joining.
The form only keeps text and its rules: accepts() and max_length() tell what each field holds, type() and set_text() refuse the rest (a letter in the port, a field already full). submit() checks the fields and gives the settings of ClientSession, or a sentence for the player. Nothing here draws or reads the keyboard, so the form is the same with any window; the client edits it through ConnectFields.
◆ ConnectForm()
Creates the form, filled with settings (the command line's, or the last ones used), the name focused.
- Parameters
-
| settings | Server and player name shown at first. |
◆ accepts()
| static bool rtype::ConnectForm::accepts |
( |
ConnectField |
field, |
|
|
char |
character |
|
) |
| |
|
staticnoexcept |
Tells whether a field takes a character, or a byte of a UTF-8 character.
The address takes letters, digits, ., :, -, [ and ]; the port takes digits; the name takes printable ASCII characters (space included) and the bytes of longer UTF-8 characters, such as accented letters, as the login does.
- Parameters
-
| field | Field to type in. |
| character | Character, or a byte of a longer UTF-8 character. |
- Returns
true if the field takes it.
◆ erase()
| void rtype::ConnectForm::erase |
( |
| ) |
|
|
noexcept |
Removes the last character of the focused field, if any.
◆ focus()
Focuses a field.
- Parameters
-
◆ focused()
The focused field, which type() and erase() change.
- Returns
- The field.
◆ max_length()
| static std::size_t rtype::ConnectForm::max_length |
( |
ConnectField |
field | ) |
|
|
staticnoexcept |
Longest text of a field.
- Parameters
-
- Returns
- max_host, max_port or max_name, in bytes (characters, but for a name with longer UTF-8 characters).
◆ next()
| void rtype::ConnectForm::next |
( |
| ) |
|
|
noexcept |
Focuses the next field, the first after the last one.
◆ previous()
| void rtype::ConnectForm::previous |
( |
| ) |
|
|
noexcept |
Focuses the previous field, the last before the first one.
◆ set_text()
| bool rtype::ConnectForm::set_text |
( |
ConnectField |
field, |
|
|
std::string_view |
text |
|
) |
| |
Replaces the text of a field, as edited in a text field.
- Parameters
-
| field | Field to set. |
| text | New text in UTF-8; characters the field does not take are left out, and the text is cut to the field's length, never inside a character. |
- Returns
true if the whole of text was kept.
◆ submit()
| std::variant< ClientSettings, std::string > rtype::ConnectForm::submit |
( |
| ) |
const |
Checks the fields and gives the settings to join with.
The address must not be empty, the port must be a number from 1 to 65535, and the name 1 to max_name characters. Whether the address is one the client can reach is only known when it joins: ClientSession::start() says so.
- Returns
- The settings, or a sentence telling the player what to fix.
◆ text()
| const std::string & rtype::ConnectForm::text |
( |
ConnectField |
field | ) |
const |
Text of a field.
- Parameters
-
- Returns
- Its text.
◆ type()
| bool rtype::ConnectForm::type |
( |
char |
character | ) |
|
Adds an ASCII character at the end of the focused field.
As accepts() says; a byte of a longer UTF-8 character is refused, those characters coming whole through set_text().
- Parameters
-
| character | Character typed. |
- Returns
false if the field does not take it or is full; the field is unchanged.
◆ max_host
| constexpr std::size_t rtype::ConnectForm::max_host = 45 |
|
staticconstexpr |
Longest address: an IPv6 address with its brackets fits.
◆ max_name
| constexpr std::size_t rtype::ConnectForm::max_name = 16 |
|
staticconstexpr |
◆ max_port
| constexpr std::size_t rtype::ConnectForm::max_port = 5 |
|
staticconstexpr |
Longest port: five digits.
The documentation for this class was generated from the following file: