R-Type
Networked shoot'em up built on Aegis2D
Loading...
Searching...
No Matches
client_options.hpp
Go to the documentation of this file.
1
3#pragma once
5
6#include <cstdint>
7#include <filesystem>
8#include <optional>
9#include <span>
10#include <string>
11#include <string_view>
12#include <variant>
13
14namespace rtype {
15
17inline constexpr std::string_view client_usage =
18 "usage: r-type_client [--host <address>] [--port <tcp port>] [--name <player name>]\n"
19 " [--join] [--settings <file>] [--frames <count>]\n"
20 " [--screenshot <png file>] [--metrics] [--edit <waves file>]\n"
21 " [--help] [--version]\n";
22
24enum class ClientCommand : std::uint8_t {
26 Run,
28 Help,
30 Version,
31};
32
41 bool join = false;
44 std::optional<std::filesystem::path> settings_file;
46 std::uint64_t frames = 0;
49 std::optional<std::filesystem::path> screenshot;
51 bool metrics = false;
53 std::optional<std::filesystem::path> edit;
54};
55
59[[nodiscard]] std::optional<std::uint16_t> parse_port(std::string_view text) noexcept;
60
68[[nodiscard]] std::variant<ClientOptions, std::string>
69parse_client_options(std::span<const std::string_view> args);
70
71} // namespace rtype
The client's session with the server: TCP login, then UDP binding (RFC section 3).
R-Type game code, built on the Aegis2D engine.
Definition enemy_scripts.hpp:16
@ Version
Print the version and exit.
@ Help
Print the usage and exit.
@ Run
Start the game and listen on the ports.
std::optional< std::uint16_t > parse_port(std::string_view text) noexcept
Reads a TCP port, as --port and the connect screen take it.
std::variant< ClientOptions, std::string > parse_client_options(std::span< const std::string_view > args)
Reads the command line of r-type_client.
constexpr std::string_view client_usage
Usage line printed by --help and after a command line error.
Definition client_options.hpp:17
ClientCommand
What the client was asked to do.
Definition client_options.hpp:24
@ Run
Join the server.
Settings of a client run, read from the command line.
Definition client_options.hpp:34
std::optional< std::filesystem::path > screenshot
--screenshot: saves the frame before the last one as a PNG file (after --frames, or 300 frames by def...
Definition client_options.hpp:49
std::optional< std::filesystem::path > edit
--edit: a waves file opened in the level editor instead of the connect screen.
Definition client_options.hpp:53
bool join
--join: join the server at once, without waiting on the connect screen.
Definition client_options.hpp:41
bool metrics
--metrics: shows the frame metrics from the start, as F12 does.
Definition client_options.hpp:51
ClientSettings settings
Server and player name; ClientSettings gives the defaults (127.0.0.1, port 4242, player)....
Definition client_options.hpp:39
std::uint64_t frames
--frames: quit after this many frames; 0 runs until the window closes.
Definition client_options.hpp:46
ClientCommand command
What to do; the settings only matter for ClientCommand::Run.
Definition client_options.hpp:36
std::optional< std::filesystem::path > settings_file
--settings: the player's settings file (keys, auto-fire, text size, effects), instead of the one of t...
Definition client_options.hpp:44
What the client needs to join a server.
Definition client_session.hpp:70