From 38fbd28a2eb308760ea79e3345ff717e95295bab Mon Sep 17 00:00:00 2001 From: Tastyfish Date: Fri, 4 Nov 2022 22:25:24 -0400 Subject: [PATCH] [MISSED MIRROR] 71005: Adds a game option to toggle the MultiZ parallax effect for a player (#17375) Missed mirror 71005 --- code/_onclick/hud/hud.dm | 12 +++++++----- .../_onclick/hud/rendering/plane_master_group.dm | 10 +++++++++- .../client/preferences/multiz_parallax.dm | 16 ++++++++++++++++ tgstation.dme | 1 + .../game_preferences/multiz_parallax.tsx | 8 ++++++++ 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 code/modules/client/preferences/multiz_parallax.dm create mode 100644 tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/multiz_parallax.tsx diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index ef531c5d212..65b8f17266b 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -186,8 +186,9 @@ GLOBAL_LIST_INIT(available_erp_ui_styles, list( if(should_sight_scale(new_sight) == should_sight_scale(old_sight)) return - var/datum/plane_master_group/group = get_plane_group(PLANE_GROUP_MAIN) - group.transform_lower_turfs(src, current_plane_offset) + for(var/group_key as anything in master_groups) + var/datum/plane_master_group/group = master_groups[group_key] + group.transform_lower_turfs(src, current_plane_offset) /datum/hud/proc/should_use_scale() return should_sight_scale(mymob.sight) @@ -206,9 +207,10 @@ GLOBAL_LIST_INIT(available_erp_ui_styles, list( current_plane_offset = new_offset SEND_SIGNAL(src, COMSIG_HUD_OFFSET_CHANGED, old_offset, new_offset) - var/datum/plane_master_group/group = get_plane_group(PLANE_GROUP_MAIN) - if(group && should_use_scale()) - group.transform_lower_turfs(src, new_offset) + if(should_use_scale()) + for(var/group_key as anything in master_groups) + var/datum/plane_master_group/group = master_groups[group_key] + group.transform_lower_turfs(src, new_offset) /datum/hud/Destroy() if(mymob.hud_used == src) diff --git a/code/_onclick/hud/rendering/plane_master_group.dm b/code/_onclick/hud/rendering/plane_master_group.dm index 2c091890604..48c3ed00388 100644 --- a/code/_onclick/hud/rendering/plane_master_group.dm +++ b/code/_onclick/hud/rendering/plane_master_group.dm @@ -93,14 +93,19 @@ // So they look nicer. if you can't it's all good, if you think you can sanely look at monster's work // It's hard, and potentially expensive. be careful /datum/plane_master_group/proc/transform_lower_turfs(datum/hud/source, new_offset, use_scale = TRUE) + // Check if this feature is disabled for the client, in which case don't use scale. + if(!our_hud?.mymob?.client?.prefs?.read_preference(/datum/preference/toggle/multiz_parallax)) + use_scale = FALSE + // No offset? piss off if(!SSmapping.max_plane_offset) return + active_offset = new_offset + // Each time we go "down" a visual z level, we'll reduce the scale by this amount // Chosen because mothblocks liked it, didn't cause motion sickness while also giving a sense of height var/scale_by = 0.965 - // If our mob can see through walls if(!use_scale) // This is a workaround for two things // First of all, if a mob can see objects but not turfs, they will not be shown the holder objects we use for @@ -116,6 +121,7 @@ if(offset == 0) offsets += null continue + var/scale = scale_by ** (offset) var/matrix/multiz_shrink = matrix() multiz_shrink.Scale(scale) @@ -128,11 +134,13 @@ var/atom/movable/screen/plane_master/plane = plane_masters[plane_key] if(!plane.multiz_scaled || !plane.allows_offsetting) continue + var/visual_offset = plane.offset - new_offset if(plane.force_hidden || visual_offset < 0) // We don't animate here because it should be invisble, but we do mark because it'll look nice plane.transform = offsets[visual_offset + offset_offset] continue + animate(plane, transform = offsets[visual_offset + offset_offset], 0.05 SECONDS, easing = LINEAR_EASING) /// Holds plane masters for popups, like camera windows diff --git a/code/modules/client/preferences/multiz_parallax.dm b/code/modules/client/preferences/multiz_parallax.dm new file mode 100644 index 00000000000..d4f77e206b2 --- /dev/null +++ b/code/modules/client/preferences/multiz_parallax.dm @@ -0,0 +1,16 @@ +/// Whether or not to toggle multiz parallax, the parallax effect for lower z-levels. +/datum/preference/toggle/multiz_parallax + category = PREFERENCE_CATEGORY_GAME_PREFERENCES + savefile_key = "multiz_parallax" + savefile_identifier = PREFERENCE_PLAYER + +/datum/preference/toggle/multiz_parallax/apply_to_client(client/client, value) + // Update the plane master group's Z transforms. + + var/datum/hud/my_hud = client.mob?.hud_used + if(!my_hud) + return + + for(var/group_key as anything in my_hud.master_groups) + var/datum/plane_master_group/group = my_hud.master_groups[group_key] + group.transform_lower_turfs(my_hud, my_hud.current_plane_offset) diff --git a/tgstation.dme b/tgstation.dme index db5fa047d9e..6fe77adb87b 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2798,6 +2798,7 @@ #include "code\modules\client\preferences\item_outlines.dm" #include "code\modules\client\preferences\jobless_role.dm" #include "code\modules\client\preferences\mod_select.dm" +#include "code\modules\client\preferences\multiz_parallax.dm" #include "code\modules\client\preferences\names.dm" #include "code\modules\client\preferences\ooc.dm" #include "code\modules\client\preferences\parallax.dm" diff --git a/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/multiz_parallax.tsx b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/multiz_parallax.tsx new file mode 100644 index 00000000000..980cc7b47e6 --- /dev/null +++ b/tgui/packages/tgui/interfaces/PreferencesMenu/preferences/features/game_preferences/multiz_parallax.tsx @@ -0,0 +1,8 @@ +import { CheckboxInput, FeatureToggle } from '../base'; + +export const multiz_parallax: FeatureToggle = { + name: 'Enable multi-z parallax', + category: 'GAMEPLAY', + description: 'Enable multi-z parallax, for a 3D effect.', + component: CheckboxInput, +};