R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
room_list_form.hpp
Go to the documentation of this file.
1
4#pragma once
5#include <rtype/rooms.hpp>
6
7#include <cstddef>
8#include <cstdint>
9#include <optional>
10#include <span>
11#include <string>
12#include <variant>
13#include <vector>
14
15namespace rtype {
16
23public:
25 static constexpr std::size_t max_name = 16;
26
31 void update(std::span<const RoomRecord> rooms);
32
35 [[nodiscard]] const std::vector<RoomRecord>& rooms() const noexcept;
36
39 [[nodiscard]] std::size_t row() const noexcept;
40
43 [[nodiscard]] bool creating() const noexcept;
44
46 void up() noexcept;
47
49 void down() noexcept;
50
55 bool type(char character);
56
58 void erase() noexcept;
59
61 void bigger() noexcept;
62
64 void smaller() noexcept;
65
68 [[nodiscard]] const std::string& name() const noexcept;
69
72 [[nodiscard]] std::uint8_t size() const noexcept;
73
77 [[nodiscard]] std::variant<std::uint8_t, CreateRoomRequest, std::string> submit() const;
78
79private:
80 std::vector<RoomRecord> rooms_;
81 std::size_t row_ = 0;
82 std::string name_;
83 std::uint8_t size_ = 4;
84};
85
86} // namespace rtype
What the player does on the room list screen.
Definition room_list_form.hpp:22
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.
std::uint8_t size() const noexcept
Size of the new room.
bool type(char character)
Adds a character to the name of the new room.
void down() noexcept
Selects the row below, the first one after the last.
void erase() noexcept
Removes the last character of the name of the new room, if any.
void smaller() noexcept
One less player in the new room, down to 1.
std::variant< std::uint8_t, CreateRoomRequest, std::string > submit() const
What Enter does on the selected row.
const std::string & name() const noexcept
Name of the new room.
void bigger() noexcept
One more player in the new room, up to 4.
static constexpr std::size_t max_name
Longest room name, in bytes, as CreateRoom allows.
Definition room_list_form.hpp:25
void update(std::span< const RoomRecord > rooms)
Shows the rooms the server listed.
void up() noexcept
Selects the row above, the last one after the first.
const std::vector< RoomRecord > & rooms() const noexcept
The rooms shown.
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
TCP messages of the rooms (RFC sections 3.6 and 3.7): listing them, creating one, joining and leaving...
Content of a CreateRoom.
Definition rooms.hpp:131
A room, as a RoomList describes it.
Definition rooms.hpp:113