diff options
author | Emma Miler <emma.pi@protonmail.com> | 2022-11-12 15:39:39 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 14:39:39 +0000 |
commit | bf09852285941e20a04731443d03c693e3f8ba2d (patch) | |
tree | a254973af94d819ab18b969e23045a309cbd15f7 /NorthstarDLL/color.h | |
parent | ab5db7fde23ef6cd87fa8a7e07973179a80e02d4 (diff) | |
download | NorthstarLauncher-bf09852285941e20a04731443d03c693e3f8ba2d.tar.gz NorthstarLauncher-bf09852285941e20a04731443d03c693e3f8ba2d.zip |
Logging improvements + Colours (new) (#320)
* log colours :)
* commend the freopen stuff (it causes problems)
* formatting
* add explanatory comment
* gaming maybe
* move set pattern
* ok this works now i think
* trailing space :)
* Revert "Merge branch 'main' into log-colours"
This reverts commit d40b6496b7bd3b3f20f51cc2311b0369aeabe735, reversing
changes made to a98bcc22e8961b325806f6a9ca85e64353fd574c.
* Revert "Revert "Merge branch 'main' into log-colours""
This reverts commit da792245b1cd7d0ac9e22d5633770142a43ce10c.
* fix shit maybe
* fix shit but better
* initial, still WIP
* Add GetContextName_Short
* colours for in game console
* working, time to improve code
* rename var + add a colour or two
* whoops
* change rpak filesystem to RP NATIVE
* add RP NATIVE and NORTHSTAR tags
* clang-format off because formatting
* formatting 2
* formatting 3: the formattening
* bruh
* revert unnecessary change
* improve comment
* Set console title to show profile
* pain
* Made code not shit
* Formatting and remove warning box
* Update main.cpp
* Formatting
* More format changes
* Again
* Fix small things from code review
* Remove empty line
* renamed NATIVE_EN -> NATIVE_ENGINE
* Update logging.cpp
* Update sourceconsole.cpp
Co-authored-by: ASpoonPlaysGames <66967891+ASpoonPlaysGames@users.noreply.github.com>
Diffstat (limited to 'NorthstarDLL/color.h')
-rw-r--r-- | NorthstarDLL/color.h | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/NorthstarDLL/color.h b/NorthstarDLL/color.h index e2c1ebba..4dc9b36e 100644 --- a/NorthstarDLL/color.h +++ b/NorthstarDLL/color.h @@ -27,6 +27,30 @@ typedef struct color32_s uint8_t r, g, b, a; } color32; +struct SourceColor +{ + unsigned char R; + unsigned char G; + unsigned char B; + unsigned char A; + + SourceColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a) + { + R = r; + G = g; + B = b; + A = a; + } + + SourceColor() + { + R = 0; + G = 0; + B = 0; + A = 0; + } +}; + //----------------------------------------------------------------------------- // Purpose: Basic handler for an rgb set of colors // This class is fully inline @@ -34,7 +58,7 @@ typedef struct color32_s class Color { public: - Color(int r, int g, int b, int a) + Color(int r, int g, int b, int a = 255) { _color[0] = (unsigned char)r; _color[1] = (unsigned char)g; @@ -130,6 +154,44 @@ class Color return newColor; } + std::string ToANSIColor() + { + std::string out = "\033[38;2;"; + out += std::to_string(_color[0]) + ";"; + out += std::to_string(_color[1]) + ";"; + out += std::to_string(_color[2]) + ";"; + out += "49m"; + return out; + } + + SourceColor ToSourceColor() + { + return SourceColor(_color[0], _color[1], _color[2], _color[3]); + } + private: unsigned char _color[4]; }; + +namespace NS::Colors +{ + extern Color SCRIPT_UI; + extern Color SCRIPT_CL; + extern Color SCRIPT_SV; + extern Color NATIVE_UI; + extern Color NATIVE_CL; + extern Color NATIVE_SV; + extern Color NATIVE_ENGINE; + extern Color FILESYSTEM; + extern Color RPAK; + extern Color NORTHSTAR; + extern Color ECHO; + + extern Color TRACE; + extern Color DEBUG; + extern Color INFO; + extern Color WARN; + extern Color ERR; + extern Color CRIT; + extern Color OFF; +}; // namespace NS::Colors |