diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-22 06:07:59 +1000 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-04-22 06:07:59 +1000 |
commit | ca1426eabc873f781eb0dd389d45634b7d183250 (patch) | |
tree | 15ea83658ca3824232f14fe4b32ec714e0aa05c6 /source/core/StarText.cpp | |
parent | d5f5fb5ddf0d4a9f0b0e6ac012121926d2fcd949 (diff) |
Lua chat callbacks + better font styling
golly gee whiz!! i hope i didn't fuck something up
Diffstat (limited to 'source/core/StarText.cpp')
-rw-r--r-- | source/core/StarText.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/core/StarText.cpp b/source/core/StarText.cpp index 11fca27..86c9f25 100644 --- a/source/core/StarText.cpp +++ b/source/core/StarText.cpp @@ -1,9 +1,35 @@ #include "StarText.hpp" - +#include "StarJsonExtra.hpp" #include <regex> namespace Star { +TextStyle::TextStyle(Json const& config) : TextStyle() { + if (config.isType(Json::Type::String)) + font = config.toString(); + else + loadJson(config); +} +TextStyle& TextStyle::loadJson(Json const& config) { + if (!config) + return *this; + + lineSpacing = config.getFloat("lineSpacing", lineSpacing); + if (auto jColor = config.opt("color")) + color = jsonToColor(*jColor).toRgba(); + if (auto jShadow = config.opt("shadow")) + shadow = jsonToColor(*jShadow).toRgba(); + fontSize = config.getUInt("fontSize", fontSize); + if (auto jFont = config.optString("font")) + font = *jFont; + if (auto jDirectives = config.optString("directives")) + directives = *jDirectives; + if (auto jBackDirectives = config.optString("backDirectives")) + backDirectives = *jBackDirectives; + + return *this; +} + namespace Text { static auto stripEscapeRegex = std::regex(strf("\\{:c}[^;]*{:c}", CmdEsc, EndEsc)); String stripEscapeCodes(String const& s) { |