From 6334809ac266254d28ea2476fabaa8f7f80f60c2 Mon Sep 17 00:00:00 2001 From: Mieszko Jedrzejczak Date: Mon, 5 Jul 2021 00:26:12 +0200 Subject: [PATCH 1/2] blur thy screen take two --- code/__DEFINES/misc.dm | 3 --- code/_onclick/hud/fullscreen.dm | 5 ----- code/_onclick/hud/plane_master.dm | 17 ++++++++++++++++- code/game/atoms.dm | 2 +- code/modules/mob/living/update_status.dm | 9 +++++++-- 5 files changed, 24 insertions(+), 12 deletions(-) diff --git a/code/__DEFINES/misc.dm b/code/__DEFINES/misc.dm index ad182c9f9c4..32c4f44cdee 100644 --- a/code/__DEFINES/misc.dm +++ b/code/__DEFINES/misc.dm @@ -432,9 +432,6 @@ /// Prepares a text to be used for maptext. Use this so it doesn't look hideous. #define MAPTEXT(text) {"[##text]"} -// Filters -#define FILTER_AMBIENT_OCCLUSION filter(type="drop_shadow", x=0, y=-2, size=4, color="#04080FAA") - //Fullscreen overlay resolution in tiles. #define FULLSCREEN_OVERLAY_RESOLUTION_X 15 #define FULLSCREEN_OVERLAY_RESOLUTION_Y 15 diff --git a/code/_onclick/hud/fullscreen.dm b/code/_onclick/hud/fullscreen.dm index 9d00f216eac..f6c8880a485 100644 --- a/code/_onclick/hud/fullscreen.dm +++ b/code/_onclick/hud/fullscreen.dm @@ -99,11 +99,6 @@ /obj/screen/fullscreen/impaired icon_state = "impairedoverlay" -/obj/screen/fullscreen/blurry - icon = 'icons/mob/screen_gen.dmi' - screen_loc = "WEST,SOUTH to EAST,NORTH" - icon_state = "blurry" - /obj/screen/fullscreen/flash icon = 'icons/mob/screen_gen.dmi' screen_loc = "WEST,SOUTH to EAST,NORTH" diff --git a/code/_onclick/hud/plane_master.dm b/code/_onclick/hud/plane_master.dm index d49722e79ee..ec8e67bc08e 100644 --- a/code/_onclick/hud/plane_master.dm +++ b/code/_onclick/hud/plane_master.dm @@ -1,3 +1,7 @@ +#define BLUR_FILTER_NAME "blur" +#define AMBIENT_OCCLUSION_FILTER_NAME "ambient_occlusion" +#define BLUR_ANIMATION_TIME 5 + /obj/screen/plane_master screen_loc = "CENTER" icon_state = "blank" @@ -16,6 +20,17 @@ //Trust me, you need one. Period. If you don't think you do, you're doing something extremely wrong. /obj/screen/plane_master/proc/backdrop(mob/mymob) +/obj/screen/plane_master/proc/add_blur() + add_filter(BLUR_FILTER_NAME, 7, gauss_blur_filter(0)) + transition_filter(BLUR_FILTER_NAME, BLUR_ANIMATION_TIME, list("size" = 1)) + +/obj/screen/plane_master/proc/animate_remove_blur() + transition_filter(BLUR_FILTER_NAME, BLUR_ANIMATION_TIME, list("size" = 0)) + addtimer(CALLBACK(src, .proc/remove_blur), BLUR_ANIMATION_TIME) + +/obj/screen/plane_master/proc/remove_blur() + remove_filter(BLUR_FILTER_NAME) + /obj/screen/plane_master/floor name = "floor plane master" plane = FLOOR_PLANE @@ -31,7 +46,7 @@ /obj/screen/plane_master/game_world/backdrop(mob/mymob) clear_filters() if(istype(mymob) && mymob.client && mymob.client.prefs && (mymob.client.prefs.toggles & PREFTOGGLE_AMBIENT_OCCLUSION)) - add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA")) + add_filter(AMBIENT_OCCLUSION_FILTER_NAME, 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA")) /obj/screen/plane_master/lighting name = "lighting plane master" diff --git a/code/game/atoms.dm b/code/game/atoms.dm index fc5e1d8eb5f..d7223c1209d 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -460,7 +460,7 @@ filters += filter(arglist(arguments)) UNSETEMPTY(filter_data) -/atom/proc/transition_filter(name, time, list/new_params, easing, loop) +/atom/proc/transition_filter(name, time, list/new_params, easing = LINEAR_EASING, loop = 1) var/filter = get_filter(name) if(!filter) return diff --git a/code/modules/mob/living/update_status.dm b/code/modules/mob/living/update_status.dm index b942b0cabe7..eec2cfb5d76 100644 --- a/code/modules/mob/living/update_status.dm +++ b/code/modules/mob/living/update_status.dm @@ -9,11 +9,16 @@ return 0 /mob/living/update_blurry_effects() + var/obj/screen/plane_master/game_world/GW = locate(/obj/screen/plane_master/game_world) in client.screen + var/obj/screen/plane_master/floor/F = locate(/obj/screen/plane_master/floor) in client.screen + if(eyes_blurred()) - overlay_fullscreen("blurry", /obj/screen/fullscreen/blurry) + GW.add_blur() + F.add_blur() return 1 else - clear_fullscreen("blurry") + GW.animate_remove_blur() + F.animate_remove_blur() return 0 /mob/living/update_druggy_effects() From 8f24160317e0691869a84c137b3bcae5b947ab80 Mon Sep 17 00:00:00 2001 From: Mieszko Jedrzejczak Date: Tue, 13 Jul 2021 17:48:58 +0200 Subject: [PATCH 2/2] revert initial eyeblur, add tg's plane master controllers --- code/__DEFINES/layers.dm | 3 + code/__DEFINES/mobs.dm | 3 + code/_onclick/hud/hud.dm | 7 ++ code/_onclick/hud/plane_master.dm | 17 +--- code/_onclick/hud/plane_master_controller.dm | 77 +++++++++++++++++++ code/modules/mob/living/status_procs.dm | 5 +- code/modules/mob/living/update_status.dm | 14 +--- .../reagents/chemistry/reagents/drugs.dm | 14 ++-- paradise.dme | 1 + 9 files changed, 106 insertions(+), 35 deletions(-) create mode 100644 code/_onclick/hud/plane_master_controller.dm diff --git a/code/__DEFINES/layers.dm b/code/__DEFINES/layers.dm index 9286ea2726d..a633ddab5eb 100644 --- a/code/__DEFINES/layers.dm +++ b/code/__DEFINES/layers.dm @@ -117,3 +117,6 @@ #define SPLASHSCREEN_LAYER 23 #define SPLASHSCREEN_PLANE 23 + +///Plane master controller keys +#define PLANE_MASTERS_GAME "plane_masters_game" diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index a023063ca7f..1978f1e9e34 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -282,3 +282,6 @@ #define FLASH_PROTECTION_NONE 0 #define FLASH_PROTECTION_FLASH 1 #define FLASH_PROTECTION_WELDER 2 + +#define MAX_EYE_BLURRY_FILTER_SIZE 2 +#define EYE_BLUR_TO_FILTER_SIZE_MULTIPLIER 0.1 diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index 0cfb6985b8e..9779e306939 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -37,6 +37,8 @@ var/action_buttons_hidden = FALSE var/list/obj/screen/plane_master/plane_masters = list() // see "appearance_flags" in the ref, assoc list of "[plane]" = object + ///Assoc list of controller groups, associated with key string group name with value of the plane master controller ref + var/list/atom/movable/plane_master_controller/plane_master_controllers = list() /mob/proc/create_mob_hud() if(client && !hud_used) @@ -53,6 +55,10 @@ plane_masters["[instance.plane]"] = instance instance.backdrop(mymob) + for(var/mytype in subtypesof(/atom/movable/plane_master_controller)) + var/atom/movable/plane_master_controller/controller_instance = new mytype(src) + plane_master_controllers[controller_instance.name] = controller_instance + /datum/hud/Destroy() if(mymob.hud_used == src) mymob.hud_used = null @@ -89,6 +95,7 @@ nightvisionicon = null QDEL_LIST_ASSOC_VAL(plane_masters) + QDEL_LIST_ASSOC_VAL(plane_master_controllers) mymob = null return ..() diff --git a/code/_onclick/hud/plane_master.dm b/code/_onclick/hud/plane_master.dm index ec8e67bc08e..d49722e79ee 100644 --- a/code/_onclick/hud/plane_master.dm +++ b/code/_onclick/hud/plane_master.dm @@ -1,7 +1,3 @@ -#define BLUR_FILTER_NAME "blur" -#define AMBIENT_OCCLUSION_FILTER_NAME "ambient_occlusion" -#define BLUR_ANIMATION_TIME 5 - /obj/screen/plane_master screen_loc = "CENTER" icon_state = "blank" @@ -20,17 +16,6 @@ //Trust me, you need one. Period. If you don't think you do, you're doing something extremely wrong. /obj/screen/plane_master/proc/backdrop(mob/mymob) -/obj/screen/plane_master/proc/add_blur() - add_filter(BLUR_FILTER_NAME, 7, gauss_blur_filter(0)) - transition_filter(BLUR_FILTER_NAME, BLUR_ANIMATION_TIME, list("size" = 1)) - -/obj/screen/plane_master/proc/animate_remove_blur() - transition_filter(BLUR_FILTER_NAME, BLUR_ANIMATION_TIME, list("size" = 0)) - addtimer(CALLBACK(src, .proc/remove_blur), BLUR_ANIMATION_TIME) - -/obj/screen/plane_master/proc/remove_blur() - remove_filter(BLUR_FILTER_NAME) - /obj/screen/plane_master/floor name = "floor plane master" plane = FLOOR_PLANE @@ -46,7 +31,7 @@ /obj/screen/plane_master/game_world/backdrop(mob/mymob) clear_filters() if(istype(mymob) && mymob.client && mymob.client.prefs && (mymob.client.prefs.toggles & PREFTOGGLE_AMBIENT_OCCLUSION)) - add_filter(AMBIENT_OCCLUSION_FILTER_NAME, 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA")) + add_filter("AO", 1, drop_shadow_filter(x = 0, y = -2, size = 4, color = "#04080FAA")) /obj/screen/plane_master/lighting name = "lighting plane master" diff --git a/code/_onclick/hud/plane_master_controller.dm b/code/_onclick/hud/plane_master_controller.dm new file mode 100644 index 00000000000..b525dfc0ef3 --- /dev/null +++ b/code/_onclick/hud/plane_master_controller.dm @@ -0,0 +1,77 @@ +///Atom that manages and controls multiple planes. It's an atom so we can hook into add_filter etc. Multiple controllers can control one plane. +/atom/movable/plane_master_controller + ///List of planes in this controllers control. Initially this is a normal list, but becomes an assoc list of plane numbers as strings | plane instance + var/list/controlled_planes = list() + ///hud that owns this controller + var/datum/hud/owner_hud + +///Ensures that all the planes are correctly in the controlled_planes list. +/atom/movable/plane_master_controller/New(hud) + . = ..() + owner_hud = hud + var/assoc_controlled_planes = list() + for(var/i in controlled_planes) + var/obj/screen/plane_master/instance = owner_hud.plane_masters["[i]"] + assoc_controlled_planes["[i]"] = instance + controlled_planes = assoc_controlled_planes + +///Full override so we can just use filterrific +/atom/movable/plane_master_controller/add_filter(name, priority, list/params) + . = ..() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.add_filter(name, priority, params) + +///Full override so we can just use filterrific +/atom/movable/plane_master_controller/remove_filter(name_or_names) + . = ..() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.remove_filter(name_or_names) + +/atom/movable/plane_master_controller/update_filters() + . = ..() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.update_filters() + +///Gets all filters for this controllers plane masters +/atom/movable/plane_master_controller/proc/get_filters(name) + . = list() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + . += pm_iterator.get_filter(name) + +///Transitions all filters owned by this plane master controller +/atom/movable/plane_master_controller/transition_filter(name, time, list/new_params, easing, loop) + . = ..() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.transition_filter(name, time, new_params, easing, loop) + +///Full override so we can just use filterrific +/atom/movable/plane_master_controller/add_atom_colour(coloration, colour_priority) + . = ..() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.add_atom_colour(coloration, colour_priority) + + +///Removes an instance of colour_type from the atom's atom_colours list +/atom/movable/plane_master_controller/remove_atom_colour(colour_priority, coloration) + . = ..() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.remove_atom_colour(colour_priority, coloration) + + +///Resets the atom's color to null, and then sets it to the highest priority colour available +/atom/movable/plane_master_controller/update_atom_colour() + for(var/i in controlled_planes) + var/obj/screen/plane_master/pm_iterator = controlled_planes[i] + pm_iterator.update_atom_colour() + + +/atom/movable/plane_master_controller/game + name = PLANE_MASTERS_GAME + controlled_planes = list(FLOOR_PLANE, GAME_PLANE, LIGHTING_PLANE) diff --git a/code/modules/mob/living/status_procs.dm b/code/modules/mob/living/status_procs.dm index fceffecbffc..fab75c91507 100644 --- a/code/modules/mob/living/status_procs.dm +++ b/code/modules/mob/living/status_procs.dm @@ -211,11 +211,12 @@ /mob/living/SetEyeBlurry(amount, updating = TRUE) . = STATUS_UPDATE_BLURRY - if((!!amount) == (!!eye_blurry)) // We're not changing from + to 0 or vice versa + //if they're both above max or equal that means we won't change the blur filter + if(amount > MAX_EYE_BLURRY_FILTER_SIZE / EYE_BLUR_TO_FILTER_SIZE_MULTIPLIER && eye_blurry > MAX_EYE_BLURRY_FILTER_SIZE / EYE_BLUR_TO_FILTER_SIZE_MULTIPLIER || eye_blurry == amount) updating = FALSE . = STATUS_UPDATE_NONE + eye_blurry = max(amount, 0) - // We transitioned to/from 0, so update the eye blur overlays if(updating) update_blurry_effects() diff --git a/code/modules/mob/living/update_status.dm b/code/modules/mob/living/update_status.dm index eec2cfb5d76..73231403d9a 100644 --- a/code/modules/mob/living/update_status.dm +++ b/code/modules/mob/living/update_status.dm @@ -9,17 +9,11 @@ return 0 /mob/living/update_blurry_effects() - var/obj/screen/plane_master/game_world/GW = locate(/obj/screen/plane_master/game_world) in client.screen - var/obj/screen/plane_master/floor/F = locate(/obj/screen/plane_master/floor) in client.screen - - if(eyes_blurred()) - GW.add_blur() - F.add_blur() - return 1 + var/atom/movable/plane_master_controller/game_plane_master_controller = hud_used.plane_master_controllers[PLANE_MASTERS_GAME] + if(eye_blurry) + game_plane_master_controller.add_filter("eye_blur", 1, gauss_blur_filter(clamp(eye_blurry * EYE_BLUR_TO_FILTER_SIZE_MULTIPLIER, 0.6, MAX_EYE_BLURRY_FILTER_SIZE))) else - GW.animate_remove_blur() - F.animate_remove_blur() - return 0 + game_plane_master_controller.remove_filter("eye_blur") /mob/living/update_druggy_effects() if(druggy) diff --git a/code/modules/reagents/chemistry/reagents/drugs.dm b/code/modules/reagents/chemistry/reagents/drugs.dm index 201071745a8..89362dc9166 100644 --- a/code/modules/reagents/chemistry/reagents/drugs.dm +++ b/code/modules/reagents/chemistry/reagents/drugs.dm @@ -640,18 +640,18 @@ /datum/reagent/rotatium/on_mob_life(mob/living/carbon/M) if(M.hud_used) if(current_cycle >= 20 && current_cycle % 20 == 0) - var/list/screens = list(M.hud_used.plane_masters["[FLOOR_PLANE]"], M.hud_used.plane_masters["[GAME_PLANE]"], M.hud_used.plane_masters["[LIGHTING_PLANE]"]) + var/atom/movable/plane_master_controller/pm_controller = M.hud_used.plane_master_controllers[PLANE_MASTERS_GAME] var/rotation = min(round(current_cycle / 20), 89) // By this point the player is probably puking and quitting anyway - for(var/whole_screen in screens) - animate(whole_screen, transform = matrix(rotation, MATRIX_ROTATE), time = 5, easing = QUAD_EASING, loop = -1) + for(var/key in pm_controller.controlled_planes) + animate(pm_controller.controlled_planes[key], transform = matrix(rotation, MATRIX_ROTATE), time = 5, easing = QUAD_EASING, loop = -1) animate(transform = matrix(-rotation, MATRIX_ROTATE), time = 5, easing = QUAD_EASING) return ..() /datum/reagent/rotatium/on_mob_delete(mob/living/M) - if(M && M.hud_used) - var/list/screens = list(M.hud_used.plane_masters["[FLOOR_PLANE]"], M.hud_used.plane_masters["[GAME_PLANE]"], M.hud_used.plane_masters["[LIGHTING_PLANE]"]) - for(var/whole_screen in screens) - animate(whole_screen, transform = matrix(), time = 5, easing = QUAD_EASING) + if(M?.hud_used) + var/atom/movable/plane_master_controller/pm_controller = M.hud_used.plane_master_controllers[PLANE_MASTERS_GAME] + for(var/key in pm_controller.controlled_planes) + animate(pm_controller.controlled_planes[key], transform = matrix(), time = 5, easing = QUAD_EASING) ..() ////////////////////////////// diff --git a/paradise.dme b/paradise.dme index a6b2a53c467..02507d1b917 100644 --- a/paradise.dme +++ b/paradise.dme @@ -173,6 +173,7 @@ #include "code\_onclick\hud\parallax.dm" #include "code\_onclick\hud\picture_in_picture.dm" #include "code\_onclick\hud\plane_master.dm" +#include "code\_onclick\hud\plane_master_controller.dm" #include "code\_onclick\hud\radial.dm" #include "code\_onclick\hud\robot.dm" #include "code\_onclick\hud\screen_objects.dm"