fix: set color picker alpha on reset (#2173)

* fix: set color picker alpha on reset

Fixes a bug where the colour picker enhancement widget without alpha uses a garbage value for alpha on reset

Co-authored-by: sonoftunk <sonoftunk@gmail.com>

* formatting

Co-authored-by: sonoftunk <sonoftunk@gmail.com>
Co-authored-by: briaguya <briaguya@alice>
This commit is contained in:
briaguya 2022-12-12 23:40:27 -05:00 committed by GitHub
parent 99c1f046a6
commit 9a9b4bd679
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -528,13 +528,13 @@ namespace UIWidgets {
colors->x = defaultcolors.x; colors->x = defaultcolors.x;
colors->y = defaultcolors.y; colors->y = defaultcolors.y;
colors->z = defaultcolors.z; colors->z = defaultcolors.z;
if (has_alpha) { colors->w = defaultcolors.w; }; colors->w = has_alpha ? defaultcolors.w : 255.0f;
Color_RGBA8 colorsRGBA; Color_RGBA8 colorsRGBA;
colorsRGBA.r = defaultcolors.x; colorsRGBA.r = defaultcolors.x;
colorsRGBA.g = defaultcolors.y; colorsRGBA.g = defaultcolors.y;
colorsRGBA.b = defaultcolors.z; colorsRGBA.b = defaultcolors.z;
if (has_alpha) { colorsRGBA.a = defaultcolors.w; }; colorsRGBA.a = has_alpha ? defaultcolors.w : 255.0f;
CVar_SetRGBA(cvarName, colorsRGBA); CVar_SetRGBA(cvarName, colorsRGBA);
CVar_SetS32(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. CVar_SetS32(Cvar_RBM.c_str(), 0); //On click disable rainbow mode.
@ -616,7 +616,7 @@ namespace UIWidgets {
colors.r = ColorRGBA.x * 255.0; colors.r = ColorRGBA.x * 255.0;
colors.g = ColorRGBA.y * 255.0; colors.g = ColorRGBA.y * 255.0;
colors.b = ColorRGBA.z * 255.0; colors.b = ColorRGBA.z * 255.0;
colors.a = ColorRGBA.w * 255.0; colors.a = 255.0;
CVar_SetRGBA(cvarName, colors); CVar_SetRGBA(cvarName, colors);
SohImGui::RequestCvarSaveOnNextTick(); SohImGui::RequestCvarSaveOnNextTick();