-
Notifications
You must be signed in to change notification settings - Fork 2.6k
[ALL] Allow the Color class to accept hex code strings and Color1 variables as colors + Basic KeyValues support. #1288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
The newest version of this PR now supports wchar_t strings and also deals with syntax The above example can now work with proper hex code strings!
|
The latest version now adds KeyValues support, allowing for the use of hex color values in KeyValues scripts! |
Due to the new null pointer check, "4D7455FF" is no longer considered a valid value The original post will be updated. |
additional note: this modification doesn't work for schemes as the override for IScheme::GetColor needs to be modified to support it in-engine. |
UPDATE: this PR now supports Color1 by the request of people in the Source Modding Community. You may now enter in the above value as the following:
|
Fixed an issue where 3 digit hex codes didn't work as expected. |
Currently, Color1 values don't work with the current keyvalues implementation and would require a rewrite of how colors are handled in KeyValues. i'll probably be leaving it alone in case this gets implemented as it is. hex values still work though. |
Description
This PR aims to implement a constructor to the Color class that allows users to define hex code strings for colors instead of RGB(A) values. This implementation is similar to hud_basechat's, and as such supports alpha channels.
Due to the nature of the Color class, the default alpha is set to 0, so passing in any normal hex code will result in a transparent color if whatever we put this in uses the full RGBA values.
Usage:
This example defines a color macro named COLOR_GENUINE with a hex code of #4D7455, the TF2 Genuine color hex code provided by the TF2 Wiki (https://wiki.teamfortress.com/wiki/Item_quality). FF was added to ensure the color is opaque.
The COLOR_GENUINE color macro, but it is transparent
UPDATE: this PR now supports Color1 by the request of people in the Source Modding Community. You may now enter in the above value as the following:
Shout out to @KaleiAlma for suggesting I do hex codes 😄