R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
rtype::RoomListForm Class Reference

What the player does on the room list screen. More...

#include </__w/project-rtype/project-rtype/client/network/include/rtype/room_list_form.hpp>

Public Member Functions

void update (std::span< const RoomRecord > rooms)
 Shows the rooms the server listed.
 
const std::vector< RoomRecord > & rooms () const noexcept
 The rooms shown.
 
std::size_t row () const noexcept
 The selected row: a room, or rooms().size() for the row of a new room.
 
bool creating () const noexcept
 Tells whether the row of a new room is selected.
 
void up () noexcept
 Selects the row above, the last one after the first.
 
void down () noexcept
 Selects the row below, the first one after the last.
 
bool type (char character)
 Adds a character to the name of the new room.
 
void erase () noexcept
 Removes the last character of the name of the new room, if any.
 
void bigger () noexcept
 One more player in the new room, up to 4.
 
void smaller () noexcept
 One less player in the new room, down to 1.
 
const std::string & name () const noexcept
 Name of the new room.
 
std::uint8_t size () const noexcept
 Size of the new room.
 
std::variant< std::uint8_t, CreateRoomRequest, std::string > submit () const
 What Enter does on the selected row.
 

Static Public Attributes

static constexpr std::size_t max_name = 16
 Longest room name, in bytes, as CreateRoom allows.
 

Detailed Description

What the player does on the room list screen.

The rows are the rooms of the last update(), by number, then the row of a new room, whose name the player types and whose size (1 to 4 players) it chooses. submit() gives the room to join on a room row, or the room to create on the last row. Nothing here draws or reads the keyboard, so the screen is the same with any window.

Member Function Documentation

◆ bigger()

void rtype::RoomListForm::bigger ( )
noexcept

One more player in the new room, up to 4.

◆ creating()

bool rtype::RoomListForm::creating ( ) const
noexcept

Tells whether the row of a new room is selected.

Returns
true on the last row.

◆ down()

void rtype::RoomListForm::down ( )
noexcept

Selects the row below, the first one after the last.

◆ erase()

void rtype::RoomListForm::erase ( )
noexcept

Removes the last character of the name of the new room, if any.

◆ name()

const std::string & rtype::RoomListForm::name ( ) const
noexcept

Name of the new room.

Returns
The text typed.

◆ rooms()

const std::vector< RoomRecord > & rtype::RoomListForm::rooms ( ) const
noexcept

The rooms shown.

Returns
Them, by number.

◆ row()

std::size_t rtype::RoomListForm::row ( ) const
noexcept

The selected row: a room, or rooms().size() for the row of a new room.

Returns
The row.

◆ size()

std::uint8_t rtype::RoomListForm::size ( ) const
noexcept

Size of the new room.

Returns
1 to 4, 4 at first.

◆ smaller()

void rtype::RoomListForm::smaller ( )
noexcept

One less player in the new room, down to 1.

◆ submit()

std::variant< std::uint8_t, CreateRoomRequest, std::string > rtype::RoomListForm::submit ( ) const

What Enter does on the selected row.

Returns
The number of the room to join, the room to create, or a sentence telling the player why neither: a full room, or a new room without a name.

◆ type()

bool rtype::RoomListForm::type ( char  character)

Adds a character to the name of the new room.

Parameters
characterCharacter typed: printable ASCII, space included.
Returns
false if the row of a new room is not selected, the name is full or the character is not printable; the name is unchanged.

◆ up()

void rtype::RoomListForm::up ( )
noexcept

Selects the row above, the last one after the first.

◆ update()

void rtype::RoomListForm::update ( std::span< const RoomRecord >  rooms)

Shows the rooms the server listed.

The selected room stays selected while it is listed; the row of a new room stays the last one.

Parameters
roomsRooms of the last RoomList, by number.

Member Data Documentation

◆ max_name

constexpr std::size_t rtype::RoomListForm::max_name = 16
staticconstexpr

Longest room name, in bytes, as CreateRoom allows.


The documentation for this class was generated from the following file: