From fa4ada025cf7d8e181ca81e42dbfc02ebd284a88 Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Sun, 11 Feb 2024 08:23:18 -0600 Subject: [PATCH] Client colo(u)r no longer uses Client.color, now coloring the render game plane instead (#81328) ## About The Pull Request Rather than utilizing `client.color`, client color datums now apply their colors to the render game plane. This means 1. The player's HUD is no longer affected by client colors. Being colorblind (in game) no longer makes all hud elements grey as well, only the world. 2. Overall, less harsh colors. ## Why It's Good For The Game 1. The player's HUD, being an OOC concept, should remain unaffected by stuff like glasses and blindness. This is how it worked in the past, before plane cube (IIRC), but it was lost in the transition. 2. Overall just looks a lot better, IMO. Here's what meson goggles with glasses colors active looks like: Before: ![image](https://github.com/tgstation/tgstation/assets/51863163/081b69b2-e545-48f8-9016-071107b2c4c1) After: ![image](https://github.com/tgstation/tgstation/assets/51863163/8a823a82-3953-4889-9594-ccae87843c00) ## Changelog :cl: Melbert qol: Glasses colors should be a lot less harsh, and being blind no longer also blinds your hud. /:cl: --- code/__HELPERS/colors.dm | 25 +++++---- code/_onclick/hud/fullscreen.dm | 1 - code/modules/client/client_colour.dm | 77 +++++++++++++++++----------- 3 files changed, 59 insertions(+), 44 deletions(-) diff --git a/code/__HELPERS/colors.dm b/code/__HELPERS/colors.dm index 4742118bebe..9f17d4c0028 100644 --- a/code/__HELPERS/colors.dm +++ b/code/__HELPERS/colors.dm @@ -47,24 +47,24 @@ var/list/color = rgb2num(HTMLstring) return rgb(255 - color[1], 255 - color[2], 255 - color[3]) -///Flash a color on the client +///Flash a color on the passed mob /proc/flash_color(mob_or_client, flash_color="#960000", flash_time=20) - var/client/flashed_client + var/mob/flashed_mob if(ismob(mob_or_client)) - var/mob/client_mob = mob_or_client - if(client_mob.client) - flashed_client = client_mob.client - else - return + flashed_mob = mob_or_client else if(istype(mob_or_client, /client)) - flashed_client = mob_or_client + var/client/flashed_client = mob_or_client + flashed_mob = flashed_client.mob - if(!istype(flashed_client)) + if(!istype(flashed_mob)) return - var/animate_color = flashed_client.color - flashed_client.color = flash_color - animate(flashed_client, color = animate_color, time = flash_time) + var/datum/client_colour/temp/temp_color = new(flashed_mob) + temp_color.colour = flash_color + temp_color.fade_in = flash_time * 0.25 + temp_color.fade_out = flash_time * 0.25 + QDEL_IN(temp_color, (flash_time * 0.5) + 1) + flashed_mob.add_client_colour(temp_color) /// Blends together two colors (passed as 3 or 4 length lists) using the screen blend mode /// Much like multiply, screen effects the brightness of the resulting color @@ -103,4 +103,3 @@ #define RANDOM_COLOUR (rgb(rand(0,255),rand(0,255),rand(0,255))) - diff --git a/code/_onclick/hud/fullscreen.dm b/code/_onclick/hud/fullscreen.dm index e928a2b8b3e..79f857e8cbe 100644 --- a/code/_onclick/hud/fullscreen.dm +++ b/code/_onclick/hud/fullscreen.dm @@ -223,4 +223,3 @@ icon_state = "noise" color = "#04a8d1" alpha = 80 - diff --git a/code/modules/client/client_colour.dm b/code/modules/client/client_colour.dm index c7ff9a02c6e..6fa3bb36f3f 100644 --- a/code/modules/client/client_colour.dm +++ b/code/modules/client/client_colour.dm @@ -38,35 +38,32 @@ /datum/client_colour/Destroy() if(!QDELETED(owner)) owner.client_colours -= src - if(fade_out) - owner.animate_client_colour(fade_out) - else - owner.update_client_colour() + owner.animate_client_colour(fade_out) owner = null return ..() ///Sets a new colour, then updates the owner's screen colour. /datum/client_colour/proc/update_colour(new_colour, anim_time, easing = 0) colour = new_colour - if(anim_time) - owner.animate_client_colour(anim_time, easing) - else - owner.update_client_colour() + owner.animate_client_colour(anim_time, easing) /** * Adds an instance of colour_type to the mob's client_colours list * colour_type - a typepath (subtyped from /datum/client_colour) */ -/mob/proc/add_client_colour(colour_type) - if(!ispath(colour_type, /datum/client_colour) || QDELING(src)) +/mob/proc/add_client_colour(colour_type_or_datum) + if(QDELING(src)) return - - var/datum/client_colour/colour = new colour_type(src) - BINARY_INSERT(colour, client_colours, /datum/client_colour, colour, priority, COMPARE_KEY) - if(colour.fade_in) - animate_client_colour(colour.fade_in) + var/datum/client_colour/colour + if(istype(colour_type_or_datum, /datum/client_colour)) + colour = colour_type_or_datum + else if(ispath(colour_type_or_datum, /datum/client_colour)) + colour = new colour_type_or_datum(src) else - update_client_colour() + CRASH("Invalid colour type or datum for add_client_color: [colour_type_or_datum || "null"]") + + BINARY_INSERT(colour, client_colours, /datum/client_colour, colour, priority, COMPARE_KEY) + animate_client_colour(colour.fade_in) return colour /** @@ -77,8 +74,7 @@ if(!ispath(colour_type, /datum/client_colour)) return - for(var/cc in client_colours) - var/datum/client_colour/colour = cc + for(var/datum/client_colour/colour as anything in client_colours) if(colour.type == colour_type) qdel(colour) break @@ -123,31 +119,49 @@ };\ target = _our_colour\ +#define CLIENT_COLOR_FILTER_KEY "fake_client_color" /** * Resets the mob's client.color to null, and then reapplies a new color based * on the client_colour datums it currently has. */ /mob/proc/update_client_colour() - if(!client) + if(isnull(hud_used)) return - client.color = "" - if(!client_colours.len) - return - MIX_CLIENT_COLOUR(client.color) + + var/new_color = "" + if(length(client_colours)) + MIX_CLIENT_COLOUR(new_color) + + for(var/atom/movable/screen/plane_master/game_plane as anything in hud_used.get_true_plane_masters(RENDER_PLANE_GAME)) + if(new_color) + game_plane.add_filter(CLIENT_COLOR_FILTER_KEY, 2, color_matrix_filter(new_color)) + else + game_plane.remove_filter(CLIENT_COLOR_FILTER_KEY) ///Works similarly to 'update_client_colour', but animated. -/mob/proc/animate_client_colour(anim_time = 20, anim_easing = 0) - if(!client) +/mob/proc/animate_client_colour(anim_time = 2 SECONDS, anim_easing = NONE) + if(anim_time <= 0) + return update_client_colour() + if(isnull(hud_used)) return - if(!client_colours.len) - animate(client, color = "", time = anim_time, easing = anim_easing) - return - MIX_CLIENT_COLOUR(var/anim_colour) - animate(client, color = anim_colour, time = anim_time, easing = anim_easing) + + var/anim_color = "" + if(length(client_colours)) + MIX_CLIENT_COLOUR(anim_color) + + for(var/atom/movable/screen/plane_master/game_plane as anything in hud_used.get_true_plane_masters(RENDER_PLANE_GAME)) + if(anim_color) + game_plane.add_filter(CLIENT_COLOR_FILTER_KEY, 2, color_matrix_filter()) + game_plane.transition_filter(CLIENT_COLOR_FILTER_KEY, color_matrix_filter(anim_color), anim_time, anim_easing) + else + game_plane.transition_filter(CLIENT_COLOR_FILTER_KEY, color_matrix_filter(), anim_time, anim_easing) + // This leaves a blank color filter on the hud which is, fine I guess? #undef MIX_CLIENT_COLOUR +#undef CLIENT_COLOR_FILTER_KEY + /datum/client_colour/glass_colour priority = PRIORITY_LOW @@ -228,6 +242,9 @@ priority = PRIORITY_ABSOLUTE colour = COLOR_RED +/datum/client_colour/temp + priority = PRIORITY_HIGH + #undef PRIORITY_ABSOLUTE #undef PRIORITY_HIGH #undef PRIORITY_NORMAL