From 9ecfd05267420657d6ca6c616a97f5b150ddf258 Mon Sep 17 00:00:00 2001
From: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com>
Date: Sun, 1 Oct 2023 13:06:08 +0200
Subject: [PATCH] Parallax in Darkness (#22136)
* you can now see parallax in darkness
* moved parallax_darkness to toggles2
* uh oh
* one more thing
* total value
* Update code/modules/client/preference/link_processing.dm
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
---------
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
---
code/__DEFINES/preferences_defines.dm | 3 ++-
code/_onclick/hud/parallax.dm | 17 +++++++++++++----
.../client/preference/link_processing.dm | 4 ++++
code/modules/client/preference/preferences.dm | 1 +
.../client/preference/preferences_mysql.dm | 2 +-
.../client/preference/preferences_toggles.dm | 13 +++++++++++++
6 files changed, 34 insertions(+), 6 deletions(-)
diff --git a/code/__DEFINES/preferences_defines.dm b/code/__DEFINES/preferences_defines.dm
index 6c3c55a6ef1..bc4b30df274 100644
--- a/code/__DEFINES/preferences_defines.dm
+++ b/code/__DEFINES/preferences_defines.dm
@@ -62,8 +62,9 @@
#define PREFTOGGLE_2_MC_TABS (1<<15) // 32768
#define PREFTOGGLE_2_DANCE_DISCO (1<<16) // 65536
#define PREFTOGGLE_2_MOD_ACTIVATION_METHOD (1<<17) // 131072
+#define PREFTOGGLE_2_PARALLAX_IN_DARKNESS (1<<18) // 262144
-#define TOGGLES_2_TOTAL 262144 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined.
+#define TOGGLES_2_TOTAL 524287 // If you add or remove a preference toggle above, make sure you update this define with the total value of the toggles combined.
#define TOGGLES_2_DEFAULT (PREFTOGGLE_2_FANCYUI|PREFTOGGLE_2_ITEMATTACK|PREFTOGGLE_2_WINDOWFLASHING|PREFTOGGLE_2_RUNECHAT|PREFTOGGLE_2_DEATHMESSAGE|PREFTOGGLE_2_EMOTE_BUBBLE|PREFTOGGLE_2_SEE_ITEM_OUTLINES|PREFTOGGLE_2_THOUGHT_BUBBLE|PREFTOGGLE_2_DANCE_DISCO|PREFTOGGLE_2_MOD_ACTIVATION_METHOD)
diff --git a/code/_onclick/hud/parallax.dm b/code/_onclick/hud/parallax.dm
index becd36b63ff..91608660609 100644
--- a/code/_onclick/hud/parallax.dm
+++ b/code/_onclick/hud/parallax.dm
@@ -17,10 +17,13 @@
return
// this is needed so it blends properly with the space plane and blackness plane.
var/obj/screen/plane_master/space/S = plane_masters["[PLANE_SPACE]"]
- S.color = list(1, 1, 1, 1,
- 1, 1, 1, 1,
- 1, 1, 1, 1,
- 1, 1, 1, 1,)
+ if(C.prefs.toggles2 & PREFTOGGLE_2_PARALLAX_IN_DARKNESS)
+ S.color = rgb(0, 0, 0, 0)
+ else
+ S.color = list(1, 1, 1, 1,
+ 1, 1, 1, 1,
+ 1, 1, 1, 1,
+ 1, 1, 1, 1,)
S.appearance_flags |= NO_CLIENT_COLOR
if(!length(C.parallax_layers_cached))
C.parallax_layers_cached = list()
@@ -33,6 +36,12 @@
C.parallax_layers = C.parallax_layers_cached.Copy()
+ var/obj/screen/plane_master/parallax/parallax_plane_master = plane_masters["[PLANE_SPACE_PARALLAX]"]
+ if(C.prefs.toggles2 & PREFTOGGLE_2_PARALLAX_IN_DARKNESS)
+ parallax_plane_master.blend_mode = BLEND_ADD
+ else
+ parallax_plane_master.blend_mode = BLEND_MULTIPLY
+
if(length(C.parallax_layers) > C.parallax_layers_max)
C.parallax_layers.len = C.parallax_layers_max
diff --git a/code/modules/client/preference/link_processing.dm b/code/modules/client/preference/link_processing.dm
index 585a9b8d619..9eeda3ef7cd 100644
--- a/code/modules/client/preference/link_processing.dm
+++ b/code/modules/client/preference/link_processing.dm
@@ -1086,6 +1086,10 @@
if(parent && parent.mob && parent.mob.hud_used)
parent.mob.hud_used.update_parallax_pref()
+ if("parallax_darkness")
+ toggles2 ^= PREFTOGGLE_2_PARALLAX_IN_DARKNESS
+ parent.mob?.hud_used?.update_parallax_pref()
+
if("screentip_mode")
var/desired_screentip_mode = clamp(input(user, "Pick a screentip size, pick 0 to disable screentips. (We suggest a number between 8 and 15):", "Screentip Size") as null|num, 0, 20)
if(!isnull(desired_screentip_mode))
diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm
index c627d12d351..a8885ef6521 100644
--- a/code/modules/client/preference/preferences.dm
+++ b/code/modules/client/preference/preferences.dm
@@ -428,6 +428,7 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
else
dat += "High"
dat += "
"
+ dat += "Parallax in darkness: [toggles2 & PREFTOGGLE_2_PARALLAX_IN_DARKNESS ? "Enabled" : "Disabled"]
"
dat += "Set screentip mode: [(screentip_mode == 0) ? "Disabled" : "[screentip_mode]px"]
"
dat += "Screentip color: Change
"
dat += "Play Admin MIDIs: [(sound & SOUND_MIDI) ? "Yes" : "No"]
"
diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm
index 390e37ec465..aafd6f6bce2 100644
--- a/code/modules/client/preference/preferences_mysql.dm
+++ b/code/modules/client/preference/preferences_mysql.dm
@@ -127,7 +127,7 @@
"ckey" = C.ckey,
"server_region" = server_region,
"muted_adminsounds_ckeys" = json_encode(admin_sound_ckey_ignore),
- "viewrange" = viewrange,
+ "viewrange" = viewrange
))
if(!query.warn_execute())
diff --git a/code/modules/client/preference/preferences_toggles.dm b/code/modules/client/preference/preferences_toggles.dm
index 35ce022639b..688b5e7becb 100644
--- a/code/modules/client/preference/preferences_toggles.dm
+++ b/code/modules/client/preference/preferences_toggles.dm
@@ -173,6 +173,19 @@
update_ambience_pref()
SSblackbox.record_feedback("tally", "toggle_verbs", 1, "Toggle Ambience") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
+/client/verb/Toggle_Parallax_Dark() //All new ambience should be added here so it works with this verb until someone better at things comes up with a fix that isn't awful
+ set name = "Show/Hide Parallax in darkness"
+ set category = "Preferences"
+ set desc = "If enabled, drawing parallax if you see in dark instead of black tiles."
+ prefs.toggles2 ^= PREFTOGGLE_2_PARALLAX_IN_DARKNESS
+ prefs.save_preferences(src)
+ if(prefs.toggles2 & PREFTOGGLE_2_PARALLAX_IN_DARKNESS)
+ to_chat(src, "You will now see parallax in dark with nightvisions.")
+ else
+ to_chat(src, "You will no longer see parallax in dark with nightvisions.")
+ usr.hud_used?.update_parallax_pref()
+ SSblackbox.record_feedback("tally", "toggle_verbs", 1, "Toggle Parallax Darkness") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
+
/client/verb/Toggle_Buzz() //No more headaches because headphones bump up shipambience.ogg to insanity levels.
set name = "Hear/Silence White Noise"
set category = "Preferences"