VoltMod
C++23 framework for CS2 server plugins
Loading...
Searching...
No Matches
VoltMod::ChatColors Namespace Reference

Classes

struct  NamedColor
 

Functions

std::string_view ParseNamed (std::string_view name)
 
std::string Strip (std::string_view text)
 
std::vector< Labeled< std::string > > PaletteChoices (std::function< std::string(std::string_view canonicalName)> labelFor)
 

Variables

constexpr std::string_view Default = "\x01"
 
constexpr std::string_view White = "\x01"
 
constexpr std::string_view DarkRed = "\x02"
 
constexpr std::string_view LightPurple = "\x03"
 
constexpr std::string_view Green = "\x04"
 
constexpr std::string_view Olive = "\x05"
 
constexpr std::string_view Lime = "\x06"
 
constexpr std::string_view Red = "\x07"
 
constexpr std::string_view Gray = "\x08"
 
constexpr std::string_view Grey = "\x08"
 
constexpr std::string_view Yellow = "\x09"
 
constexpr std::string_view LightYellow = "\x09"
 
constexpr std::string_view Silver = "\x0A"
 
constexpr std::string_view BlueGrey = "\x0A"
 
constexpr std::string_view LightBlue = "\x0B"
 
constexpr std::string_view Blue = "\x0B"
 
constexpr std::string_view DarkBlue = "\x0C"
 
constexpr std::string_view Purple = "\x0E"
 
constexpr std::string_view Magenta = "\x0E"
 
constexpr std::string_view LightRed = "\x0F"
 
constexpr std::string_view Gold = "\x10"
 
constexpr std::string_view Orange = "\x10"
 
constexpr std::array< NamedColor, 15 > Palette
 
static const std::unordered_map< std::string, std::string_view > kNameTable
 

Function Documentation

◆ PaletteChoices()

std::vector< Labeled< std::string > > VoltMod::ChatColors::PaletteChoices ( std::function< std::string(std::string_view canonicalName)>  labelFor)

Palette as labeled canonical names, so a colour picker grows as the palette does rather than repeating its contents.

labelFor supplies the localized label for each canonical name; returning "" falls back to the name itself. Shaped for a ChoiceRow<std::string>, but it names no menu type - a caller that wants the list for anything else gets the same answer.

Definition at line 43 of file ChatColors.cpp.

References Palette, and VoltMod::ReadFile().

◆ ParseNamed()

std::string_view VoltMod::ChatColors::ParseNamed ( std::string_view  name)

Map a human color name (case-insensitive) to its escape sequence. Returns Default for unknown names. Empty input also returns Default.

Definition at line 18 of file ChatColors.cpp.

References Default, kNameTable, VoltMod::ReadFile(), and VoltMod::Strings::ToLower().

◆ Strip()

std::string VoltMod::ChatColors::Strip ( std::string_view  text)

Strip all CS2 color escape bytes (0x01..0x10) from text for safe console/log output.

Definition at line 29 of file ChatColors.cpp.

References VoltMod::ReadFile().

Variable Documentation

◆ Blue

constexpr std::string_view VoltMod::ChatColors::Blue = "\x0B"
inlineconstexpr

Definition at line 30 of file ChatColors.hpp.

◆ BlueGrey

constexpr std::string_view VoltMod::ChatColors::BlueGrey = "\x0A"
inlineconstexpr

Definition at line 28 of file ChatColors.hpp.

◆ DarkBlue

constexpr std::string_view VoltMod::ChatColors::DarkBlue = "\x0C"
inlineconstexpr

Definition at line 31 of file ChatColors.hpp.

◆ DarkRed

constexpr std::string_view VoltMod::ChatColors::DarkRed = "\x02"
inlineconstexpr

Definition at line 17 of file ChatColors.hpp.

◆ Default

constexpr std::string_view VoltMod::ChatColors::Default = "\x01"
inlineconstexpr

Definition at line 15 of file ChatColors.hpp.

Referenced by VoltMod::EnsureColorPrefix(), and ParseNamed().

◆ Gold

constexpr std::string_view VoltMod::ChatColors::Gold = "\x10"
inlineconstexpr

Definition at line 35 of file ChatColors.hpp.

◆ Gray

constexpr std::string_view VoltMod::ChatColors::Gray = "\x08"
inlineconstexpr

Definition at line 23 of file ChatColors.hpp.

◆ Green

constexpr std::string_view VoltMod::ChatColors::Green = "\x04"
inlineconstexpr

Definition at line 19 of file ChatColors.hpp.

◆ Grey

constexpr std::string_view VoltMod::ChatColors::Grey = "\x08"
inlineconstexpr

Definition at line 24 of file ChatColors.hpp.

◆ kNameTable

const std::unordered_map<std::string, std::string_view> VoltMod::ChatColors::kNameTable
static
Initial value:
= {
{"default", Default}, {"white", White}, {"darkred", DarkRed}, {"lightpurple", LightPurple},
{"green", Green}, {"olive", Olive}, {"lime", Lime}, {"red", Red},
{"gray", Gray}, {"grey", Grey}, {"yellow", Yellow}, {"lightyellow", LightYellow},
{"silver", Silver}, {"bluegrey", BlueGrey}, {"lightblue", LightBlue}, {"blue", Blue},
{"darkblue", DarkBlue}, {"purple", Purple}, {"magenta", Magenta}, {"lightred", LightRed},
{"gold", Gold}, {"orange", Orange},
}
constexpr std::string_view Orange
constexpr std::string_view Blue
constexpr std::string_view Magenta
constexpr std::string_view Olive
constexpr std::string_view Gray
constexpr std::string_view Silver
constexpr std::string_view White
constexpr std::string_view Default
constexpr std::string_view Yellow
constexpr std::string_view LightYellow
constexpr std::string_view Green
constexpr std::string_view LightRed
constexpr std::string_view DarkBlue
constexpr std::string_view Red
constexpr std::string_view Gold
constexpr std::string_view LightBlue
constexpr std::string_view Grey
constexpr std::string_view Lime
constexpr std::string_view BlueGrey
constexpr std::string_view Purple

Definition at line 9 of file ChatColors.cpp.

Referenced by ParseNamed().

◆ LightBlue

constexpr std::string_view VoltMod::ChatColors::LightBlue = "\x0B"
inlineconstexpr

Definition at line 29 of file ChatColors.hpp.

◆ LightPurple

constexpr std::string_view VoltMod::ChatColors::LightPurple = "\x03"
inlineconstexpr

Definition at line 18 of file ChatColors.hpp.

◆ LightRed

constexpr std::string_view VoltMod::ChatColors::LightRed = "\x0F"
inlineconstexpr

Definition at line 34 of file ChatColors.hpp.

◆ LightYellow

constexpr std::string_view VoltMod::ChatColors::LightYellow = "\x09"
inlineconstexpr

Definition at line 26 of file ChatColors.hpp.

◆ Lime

constexpr std::string_view VoltMod::ChatColors::Lime = "\x06"
inlineconstexpr

Definition at line 21 of file ChatColors.hpp.

◆ Magenta

constexpr std::string_view VoltMod::ChatColors::Magenta = "\x0E"
inlineconstexpr

Definition at line 33 of file ChatColors.hpp.

◆ Olive

constexpr std::string_view VoltMod::ChatColors::Olive = "\x05"
inlineconstexpr

Definition at line 20 of file ChatColors.hpp.

◆ Orange

constexpr std::string_view VoltMod::ChatColors::Orange = "\x10"
inlineconstexpr

Definition at line 36 of file ChatColors.hpp.

◆ Palette

constexpr std::array<NamedColor, 15> VoltMod::ChatColors::Palette
inlineconstexpr
Initial value:
= {{
{"default", Default},
{"darkred", DarkRed},
{"lightpurple", LightPurple},
{"green", Green},
{"olive", Olive},
{"lime", Lime},
{"red", Red},
{"gray", Gray},
{"yellow", Yellow},
{"silver", Silver},
{"lightblue", LightBlue},
{"darkblue", DarkBlue},
{"purple", Purple},
{"lightred", LightRed},
{"gold", Gold},
}}
constexpr std::string_view DarkRed

Canonical, deduplicated list of every named color recognized by ParseNamed, one entry per distinct escape byte. Aliases (e.g. grey/gray, magenta/purple) collapse to a single canonical name. Useful for building color-picker UIs that stay in sync with the framework as new colors are added.

Definition at line 51 of file ChatColors.hpp.

Referenced by PaletteChoices().

◆ Purple

constexpr std::string_view VoltMod::ChatColors::Purple = "\x0E"
inlineconstexpr

Definition at line 32 of file ChatColors.hpp.

◆ Red

constexpr std::string_view VoltMod::ChatColors::Red = "\x07"
inlineconstexpr

Definition at line 22 of file ChatColors.hpp.

◆ Silver

constexpr std::string_view VoltMod::ChatColors::Silver = "\x0A"
inlineconstexpr

Definition at line 27 of file ChatColors.hpp.

◆ White

constexpr std::string_view VoltMod::ChatColors::White = "\x01"
inlineconstexpr

Definition at line 16 of file ChatColors.hpp.

◆ Yellow

constexpr std::string_view VoltMod::ChatColors::Yellow = "\x09"
inlineconstexpr

Definition at line 25 of file ChatColors.hpp.