VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
LayoutPath.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <string>
5#include <string_view>
6
7namespace VoltMod
8{
9
10/**
11 * @brief A layout resource the client will accept, checked before anything is spawned.
12 *
13 * `welcome` and `welcome.xml` both become `panorama/layout/custom_game/welcome.xml`; a full path
14 * must already be under @ref Directory and name the source `.xml`. A bad name renders nothing and
15 * says so only on the client console, so it is refused here instead. SDK-free for its tests.
16 */
18{
19public:
20 /** The only directory gameinfo.gi's addon whitelist allows Panorama layouts in. */
21 static constexpr std::string_view Directory = "panorama/layout/custom_game/";
22
23 static Result<LayoutPath> Parse(std::string_view layout);
24
25 /** The resource name that goes on the entity. */
26 const std::string& Resource() const noexcept { return _resource; }
27
28 /** The file name without directory or extension: the layout's root element id. */
29 std::string_view Name() const noexcept;
30
32 explicit LayoutPath(std::string resource) : _resource(std::move(resource)) {}
33
34 std::string _resource;
35};
36
37} // namespace VoltMod
A layout resource the client will accept, checked before anything is spawned.
static Result< LayoutPath > Parse(std::string_view layout)
static constexpr std::string_view Directory
std::string_view Name() const noexcept
const std::string & Resource() const noexcept
static std::string ReadFile(const std::filesystem::path &path)
Definition Loader.cpp:56
std::expected< T, Error > Result
Definition Result.hpp:64