diff --git a/code/__DEFINES/observers.dm b/code/__DEFINES/observers.dm index 0bacf223d8c..45ca66c796f 100644 --- a/code/__DEFINES/observers.dm +++ b/code/__DEFINES/observers.dm @@ -10,3 +10,11 @@ #define NOTIFY_CATEGORY_DEFAULT (GHOST_NOTIFY_FLASH_WINDOW | GHOST_NOTIFY_IGNORE_MAPLOAD | GHOST_NOTIFY_NOTIFY_SUICIDERS) /// The default set of flags, without the flash_window flag. #define NOTIFY_CATEGORY_NOFLASH (NOTIFY_CATEGORY_DEFAULT & ~GHOST_NOTIFY_FLASH_WINDOW) + +///Assoc List of types of ghost lightings & the player-facing name. +GLOBAL_LIST_INIT(ghost_lightings, list( + "Normal" = LIGHTING_CUTOFF_VISIBLE, + "Darker" = LIGHTING_CUTOFF_MEDIUM, + "Night Vision" = LIGHTING_CUTOFF_HIGH, + "Fullbright" = LIGHTING_CUTOFF_FULLBRIGHT, +)) diff --git a/code/modules/client/preferences/ghost_lighting.dm b/code/modules/client/preferences/ghost_lighting.dm index a116d3d2f09..fb453b87892 100644 --- a/code/modules/client/preferences/ghost_lighting.dm +++ b/code/modules/client/preferences/ghost_lighting.dm @@ -1,10 +1,3 @@ -GLOBAL_LIST_INIT(ghost_lighting_options, list( - "Fullbright" = LIGHTING_CUTOFF_FULLBRIGHT, - "Night Vision" = LIGHTING_CUTOFF_HIGH, - "Darker" = LIGHTING_CUTOFF_MEDIUM, - "Normal" = LIGHTING_CUTOFF_VISIBLE, -)) - /// How bright a ghost's lighting plane is /datum/preference/choiced/ghost_lighting category = PREFERENCE_CATEGORY_GAME_PREFERENCES @@ -16,7 +9,7 @@ GLOBAL_LIST_INIT(ghost_lighting_options, list( /datum/preference/choiced/ghost_lighting/init_possible_values() var/list/values = list() - for(var/option_name in GLOB.ghost_lighting_options) + for(var/option_name in GLOB.ghost_lightings) values += option_name return values diff --git a/code/modules/mob/dead/observer/ghost_menu.dm b/code/modules/mob/dead/observer/ghost_menu.dm index 7580f844ea9..2c0dd1cd62c 100644 --- a/code/modules/mob/dead/observer/ghost_menu.dm +++ b/code/modules/mob/dead/observer/ghost_menu.dm @@ -1,13 +1,6 @@ GLOBAL_DATUM_INIT(ghost_menu, /datum/ghost_menu, new) /datum/ghost_menu - ///Static assoc list of all types of lightings ghosts can use & names shown in the UI. - var/static/list/ghost_lightings = list( - "[LIGHTING_CUTOFF_VISIBLE]" = "Mob Vision", - "[LIGHTING_CUTOFF_MEDIUM]" = "Slight Night Vision", - "[LIGHTING_CUTOFF_HIGH]" = "Night Vision", - "[LIGHTING_CUTOFF_FULLBRIGHT]" = "Fullbright", - ) /datum/ghost_menu/ui_state(mob/user) return GLOB.observer_state @@ -57,10 +50,13 @@ GLOBAL_DATUM_INIT(ghost_menu, /datum/ghost_menu, new) var/darkness_type = params["darkness_level"] if(isnull(darkness_type)) return FALSE - for(var/lighting_types in ghost_lightings) - if(darkness_type != ghost_lightings[lighting_types]) + for(var/lighting_types in GLOB.ghost_lightings) + if(darkness_type != lighting_types) continue - toggle_darkness(dead_user, lighting_types) + //our selected one is the one we already have enabled. + if(dead_user.lighting_cutoff == GLOB.ghost_lightings[darkness_type]) + return FALSE + toggle_darkness(dead_user, darkness_type) return TRUE if("toggle_visibility") var/to_toggle = params["toggling"] @@ -95,8 +91,10 @@ GLOBAL_DATUM_INIT(ghost_menu, /datum/ghost_menu, new) data["can_boo"] = COOLDOWN_FINISHED(user, bootime) data["has_fun"] = user.fun_verbs - data["body_name"] = user.can_reenter_corpse ? user.mind.current.real_name : FALSE - data["current_darkness"] = ghost_lightings["[user.lighting_cutoff]"] + data["body_name"] = (user.can_reenter_corpse && user?.mind.current) ? user.mind.current.real_name : FALSE + for(var/level in GLOB.ghost_lightings) + if(GLOB.ghost_lightings[level] == user.lighting_cutoff) + data["current_darkness"] = level data["notification_data"] = list() for(var/key in GLOB.poll_ignore_desc) data["notification_data"] += list(list( @@ -144,8 +142,8 @@ GLOBAL_DATUM_INIT(ghost_menu, /datum/ghost_menu, new) var/list/data = list() data["max_extra_view"] = (user.client.prefs.unlock_content ? GHOST_MAX_VIEW_RANGE_MEMBER : GHOST_MAX_VIEW_RANGE_DEFAULT) - GHOST_MIN_VIEW_RANGE data["darkness_levels"] = list() - for(var/level in ghost_lightings) - data["darkness_levels"] += ghost_lightings[level] + for(var/level in GLOB.ghost_lightings) + data["darkness_levels"] += level data["lag_switch_on"] = !!(SSlag_switch.measures[DISABLE_GHOST_ZOOM_TRAY] && !user.client?.holder) return data @@ -156,9 +154,8 @@ GLOBAL_DATUM_INIT(ghost_menu, /datum/ghost_menu, new) t_ray_scan(user) /datum/ghost_menu/proc/toggle_darkness(mob/dead/observer/user, darkness_type) - if(user.lighting_cutoff == darkness_type) - return - user.lighting_cutoff = text2num(darkness_type) + user.client.prefs.write_preference(GLOB.preference_entries[/datum/preference/choiced/ghost_lighting], darkness_type) + user.lighting_cutoff = user.default_lighting_cutoff() user.update_sight() /datum/ghost_menu/proc/toggle_hud_type(mob/dead/observer/user, hud_type) diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 85c8a7f6578..1c4d38a2458 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -986,8 +986,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp var/datum/preferences/prefs = client?.prefs if(!prefs || (client?.combo_hud_enabled && prefs.toggles & COMBOHUD_LIGHTING)) return ..() - return GLOB.ghost_lighting_options[prefs.read_preference(/datum/preference/choiced/ghost_lighting)] - + return GLOB.ghost_lightings[prefs.read_preference(/datum/preference/choiced/ghost_lighting)] /// Called when we exit the orbiting state /mob/dead/observer/proc/on_deorbit(datum/source) diff --git a/code/modules/mob/mob_helpers.dm b/code/modules/mob/mob_helpers.dm index 1465ed9c9a7..d86b739d646 100644 --- a/code/modules/mob/mob_helpers.dm +++ b/code/modules/mob/mob_helpers.dm @@ -429,7 +429,7 @@ /// Returns this mob's default lighting alpha /mob/proc/default_lighting_cutoff() - if(client?.combo_hud_enabled && client?.prefs?.toggles & COMBOHUD_LIGHTING) + if(client?.combo_hud_enabled && (client?.prefs?.toggles & COMBOHUD_LIGHTING)) return LIGHTING_CUTOFF_FULLBRIGHT return initial(lighting_cutoff)