VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
LanguageTable.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include <
VoltMod/Core/Slots/PerSlot.hpp
>
4
#include <
VoltMod/Core/Slots/Slot.hpp
>
5
#include <
VoltMod/Host/IPluginLanguages.hpp
>
6
#include <string>
7
#include <string_view>
8
9
namespace
VoltMod
10
{
11
12
/** The host's @ref IPluginLanguages. @ref PluginRegistry resets a slot on connect and after disconnect. */
13
class
LanguageTable
final :
public
IPluginLanguages
14
{
15
public
:
16
std::string_view
Language
(
int
slot)
const override
17
{
18
return
IsValidSlot
(slot) ? std::string_view(_languages[slot]) : std::string_view{};
19
}
20
21
void
SetLanguage
(
int
slot, std::string_view lang)
override
22
{
23
if
(
IsValidSlot
(slot))
24
{
25
_languages[slot] = lang;
26
}
27
}
28
29
void
Reset
(
int
slot) { _languages.Reset(slot); }
30
31
private
:
32
PerSlot<std::string>
_languages;
33
};
34
35
}
// namespace VoltMod
IPluginLanguages.hpp
PerSlot.hpp
Slot.hpp
VoltMod::LanguageTable
Definition
LanguageTable.hpp:14
VoltMod::LanguageTable::Language
std::string_view Language(int slot) const override
Definition
LanguageTable.hpp:16
VoltMod::LanguageTable::Reset
void Reset(int slot)
Definition
LanguageTable.hpp:29
VoltMod::LanguageTable::SetLanguage
void SetLanguage(int slot, std::string_view lang) override
Definition
LanguageTable.hpp:21
VoltMod::PerSlot
Per-player-slot value store that never leaks state across occupants.
Definition
PerSlot.hpp:25
VoltMod
Definition
Options.hpp:13
VoltMod::IsValidSlot
constexpr bool IsValidSlot(int slot)
Definition
Slot.hpp:13
VoltMod::IPluginLanguages
Definition
IPluginLanguages.hpp:10
src
Host
Plugins
LanguageTable.hpp
Generated by
1.15.0