Skip to content

Commit

Permalink
Adds universal NV color preferences (#7543)
Browse files Browse the repository at this point in the history
# About the pull request

-Nvgs colors can be set on player preferences , this works for all NVGs
except CAS
 
 
# Explain why it's good for the game

funny colors

# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
qol: Adds universal Night Vision color preferences (green by default)
/:cl:
  • Loading branch information
Diegoflores31 authored Jan 25, 2025
1 parent e932463 commit 0cd4fe6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 8 deletions.
7 changes: 7 additions & 0 deletions code/__DEFINES/mode.dm
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,13 @@
#define FLASH_OVERLAY_DARK 1 //Flashes your screen a dark grey.
//=================================================

#define NV_COLOR_GREEN "#39FF14"
#define NV_COLOR_WHITE "#D3D3D3"
#define NV_COLOR_ORANGE "#FFCC66"
#define NV_COLOR_YELLOW "#FFFF66" //crazy ? i was crazy once
#define NV_COLOR_RED "#FF3333"
#define NV_COLOR_BLUE "#66CCFF"

//=================================================
#define CRIT_OVERLAY_WHITE 0 //Overlays your screen white.
#define CRIT_OVERLAY_DARK 1 //Overlays your screen a dark grey.
Expand Down
3 changes: 3 additions & 0 deletions code/_globalvars/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ GLOBAL_REFERENCE_LIST_INDEXED(yautja_hair_styles_list, /datum/sprite_accessory/y

//Backpacks
GLOBAL_LIST_INIT(backbaglist, list("Backpack", "Satchel"))

//NVG colors
GLOBAL_LIST_INIT(nvg_color_list, list("Green", "White", "Yellow", "Orange", "Red", "Blue"))
//Armor styles
GLOBAL_LIST_INIT(armor_style_list, list("Padded" = 1, "Padless" = 2, "Ridged" = 3, "Carrier" = 4, "Skull" = 5, "Smooth" = 6, "Random"))

Expand Down
2 changes: 1 addition & 1 deletion code/game/cas_manager/datums/cas_fire_envelope.dm
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@
var/mob/M = user
if(linked_console.upgraded == MATRIX_NVG)
if(linked_console.power <= 8)
M.add_client_color_matrix("matrix_nvg", 99, color_matrix_multiply(color_matrix_saturation(1), color_matrix_rotate_x(-1*(20.8571-1.57143*linked_console.power)), color_matrix_from_string(linked_console.matrixcol))) // (20.8571-1.57143*linked_console.power) is an equation so we can make low level properties look bad
M.add_client_color_matrix("matrix_nvg", 99, color_matrix_multiply(color_matrix_saturation(0), color_matrix_from_string(linked_console.matrix_color)))
M.overlay_fullscreen("matrix_blur", /atom/movable/screen/fullscreen/brute/nvg, 3)
M.overlay_fullscreen("matrix", /atom/movable/screen/fullscreen/flash/noise/nvg)
M.lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE
Expand Down
7 changes: 4 additions & 3 deletions code/game/machinery/computer/dropship_weapons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
var/firemission_signal //id of the signal
var/in_firemission_mode = FALSE
var/upgraded = MATRIX_DEFAULT // we transport upgrade var from matrixdm
var/matrixcol //color of matrix, only used when we upgrade to nv
var/matrix_color = NV_COLOR_GREEN //color of matrix, only used when we upgrade to nv
var/power //level of the property
var/datum/cas_signal/selected_cas_signal
var/datum/simulator/simulation
Expand Down Expand Up @@ -92,7 +92,6 @@
W.forceMove(src)
to_chat(user, SPAN_NOTICE("You swap the matrix in the dropship guidance camera system, destroying the older part in the process"))
upgraded = matrix.upgrade
matrixcol = matrix.matrixcol
power = matrix.power

else
Expand Down Expand Up @@ -441,7 +440,9 @@
if(upgraded != MATRIX_NVG)
to_chat(user, SPAN_WARNING("The matrix is not upgraded with night vision."))
return FALSE
SEND_SIGNAL(src, COMSIG_CAMERA_SET_NVG, 5, "#7aff7a")
if(user.client?.prefs?.night_vision_preference)
matrix_color = user.client.prefs.nv_color_list[user.client.prefs.night_vision_preference]
SEND_SIGNAL(src, COMSIG_CAMERA_SET_NVG, 5, matrix_color)
return TRUE

if("nvg-disable")
Expand Down
6 changes: 4 additions & 2 deletions code/game/objects/items/devices/helmet_visors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@
helmet_overlay = "nvg_sight_right"
toggle_on_sound = 'sound/handling/toggle_nv1.ogg'
toggle_off_sound = 'sound/handling/toggle_nv2.ogg'
var/matrix_color = NV_COLOR_GREEN

/// The internal battery for the visor
var/obj/item/cell/super/power_cell
Expand Down Expand Up @@ -228,8 +229,9 @@

/obj/item/device/helmet_visor/night_vision/activate_visor(obj/item/clothing/head/helmet/marine/attached_helmet, mob/living/carbon/human/user)
RegisterSignal(user, COMSIG_HUMAN_POST_UPDATE_SIGHT, PROC_REF(on_update_sight))

user.add_client_color_matrix("nvg_visor", 99, color_matrix_multiply(color_matrix_saturation(0), color_matrix_from_string("#7aff7a")))
if(user.client?.prefs?.night_vision_preference)
matrix_color = user.client.prefs.nv_color_list[user.client.prefs.night_vision_preference]
user.add_client_color_matrix("nvg_visor", 99, color_matrix_multiply(color_matrix_saturation(0), color_matrix_from_string(matrix_color)))
user.overlay_fullscreen("nvg_visor", /atom/movable/screen/fullscreen/flash/noise/nvg)
user.overlay_fullscreen("nvg_visor_blur", /atom/movable/screen/fullscreen/brute/nvg, 3)
user.update_sight()
Expand Down
5 changes: 4 additions & 1 deletion code/game/objects/items/props/helmetgarb.dm
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@
var/obj/item/clothing/head/attached_item
var/mob/living/attached_mob
var/lighting_alpha = 100
var/matrix_color = NV_COLOR_GREEN

/obj/item/prop/helmetgarb/helmet_nvg/Initialize(mapload, ...)
. = ..()
Expand Down Expand Up @@ -330,7 +331,9 @@

RegisterSignal(user, COMSIG_HUMAN_POST_UPDATE_SIGHT, PROC_REF(update_sight))

user.add_client_color_matrix("nvg", 99, color_matrix_multiply(color_matrix_saturation(0), color_matrix_from_string("#7aff7a")))
if(user.client?.prefs?.night_vision_preference)
matrix_color = user.client.prefs.nv_color_list[user.client.prefs.night_vision_preference]
user.add_client_color_matrix("nvg", 99, color_matrix_multiply(color_matrix_saturation(0), color_matrix_from_string(matrix_color)))
user.overlay_fullscreen("nvg", /atom/movable/screen/fullscreen/flash/noise/nvg)
user.overlay_fullscreen("nvg_blur", /atom/movable/screen/fullscreen/brute/nvg, 3)
playsound(user, 'sound/handling/toggle_nv1.ogg', 25)
Expand Down
17 changes: 16 additions & 1 deletion code/modules/client/preferences.dm
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ GLOBAL_LIST_INIT(bgstate_options, list(
var/language = "None" //Secondary language
var/list/gear //Custom/fluff item loadout.
var/preferred_squad = "None"

var/night_vision_preference = "Green"
var/list/nv_color_list = list(
"Green" = NV_COLOR_GREEN,
"White" = NV_COLOR_WHITE,
"Yellow" = NV_COLOR_YELLOW,
"Orange" = NV_COLOR_ORANGE,
"Red" = NV_COLOR_RED,
"Blue" = NV_COLOR_BLUE
)
//Some faction information.
var/origin = ORIGIN_USCM
var/faction = "None" //Antag faction/general associated faction.
Expand Down Expand Up @@ -415,6 +423,7 @@ GLOBAL_LIST_INIT(bgstate_options, list(

dat += "<b>Show Job Gear:</b> <a href='byond://?_src_=prefs;preference=toggle_job_gear'><b>[show_job_gear ? "True" : "False"]</b></a><br>"
dat += "<b>Background:</b> <a href='byond://?_src_=prefs;preference=cycle_bg'><b>Cycle Background</b></a><br><br>"
dat += "<b>Night Vision Color:</b> <a href='byond://?_src_=prefs;preference=prefnvg;task=input'><b>[night_vision_preference]</b></a><br>"

dat += "<b>Custom Loadout:</b> "
var/total_cost = 0
Expand Down Expand Up @@ -1550,6 +1559,12 @@ GLOBAL_LIST_INIT(bgstate_options, list(
if(new_pref_squad)
preferred_squad = new_pref_squad

if("prefnvg")
var/new_nvg_color = tgui_input_list(user, "Choose the color of your night-vision", "Character Preferences", GLOB.nvg_color_list)
if(!new_nvg_color)
return
night_vision_preference = new_nvg_color

if("prefarmor")
var/new_pref_armor = tgui_input_list(user, "Choose your character's default style of armor:", "Character Preferences", GLOB.armor_style_list)
if(new_pref_armor)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@

S["preferred_squad"] >> preferred_squad
S["preferred_armor"] >> preferred_armor
S["night_vision_preference"] >> night_vision_preference
S["weyland_yutani_relation"] >> weyland_yutani_relation
//S["skin_style"] >> skin_style

Expand Down Expand Up @@ -695,6 +696,7 @@
undershirt = sanitize_inlist(undershirt, gender == MALE ? GLOB.undershirt_m : GLOB.undershirt_f, initial(undershirt))
backbag = sanitize_integer(backbag, 1, length(GLOB.backbaglist), initial(backbag))
preferred_armor = sanitize_inlist(preferred_armor, GLOB.armor_style_list, "Random")
night_vision_preference = sanitize_inlist(night_vision_preference, GLOB.nvg_color_list, "Green")
//b_type = sanitize_text(b_type, initial(b_type))

alternate_option = sanitize_integer(alternate_option, 0, 3, initial(alternate_option))
Expand Down Expand Up @@ -794,6 +796,7 @@
S["weyland_yutani_relation"] << weyland_yutani_relation
S["preferred_squad"] << preferred_squad
S["preferred_armor"] << preferred_armor
S["night_vision_preference"] << night_vision_preference
//S["skin_style"] << skin_style

S["uplinklocation"] << uplinklocation
Expand Down

0 comments on commit 0cd4fe6

Please sign in to comment.