Ghost "Toggle Darkness" value is now remembered (#17206)

This commit is contained in:
S34N
2022-01-11 23:20:53 +01:00
committed by GitHub
parent 0e24c24f52
commit d273e9db9a
9 changed files with 35 additions and 17 deletions
+1
View File
@@ -286,6 +286,7 @@ CREATE TABLE `player` (
`2fa_status` ENUM('DISABLED','ENABLED_IP','ENABLED_ALWAYS') NOT NULL DEFAULT 'DISABLED' COLLATE 'utf8mb4_general_ci',
`screentip_mode` tinyint(1) DEFAULT '8',
`screentip_color` varchar(7) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '#ffd391',
`ghost_darkness_level` tinyint(1) UNSIGNED NOT NULL DEFAULT '255',
PRIMARY KEY (`id`),
UNIQUE KEY `ckey` (`ckey`),
KEY `lastseen` (`lastseen`),
+2
View File
@@ -0,0 +1,2 @@
# Adds support for persistent ghost darkness
ALTER TABLE `player` ADD COLUMN `ghost_darkness_level` tinyint(1) UNSIGNED NOT NULL DEFAULT '255'
+1 -1
View File
@@ -365,7 +365,7 @@
#define INVESTIGATE_BOMB "bombs"
// The SQL version required by this version of the code
#define SQL_VERSION 29
#define SQL_VERSION 30
// Vending machine stuff
#define CAT_NORMAL 1
+1
View File
@@ -1,6 +1,7 @@
/mob/dead/observer/create_mob_hud()
if(client && !hud_used)
hud_used = new /datum/hud/ghost(src)
SEND_SIGNAL(src, COMSIG_MOB_HUD_CREATED)
/obj/screen/ghost
icon = 'icons/mob/screen_ghost.dmi'
@@ -21,7 +21,8 @@
parallax,
2fa_status,
screentip_mode,
screentip_color
screentip_color,
ghost_darkness_level
FROM player
WHERE ckey=:ckey"}, list(
"ckey" = C.ckey
@@ -114,6 +114,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/list/datum/character_save/character_saves = list()
/// The current active character
var/datum/character_save/active_character
/// How dark things are if client is a ghost, 0-255
var/ghost_darkness_level = LIGHTING_PLANE_ALPHA_VISIBLE
/datum/preferences/New(client/C, datum/db_query/Q) // Process our query
parent = C
@@ -23,6 +23,7 @@
_2fa_status = query.item[17]
screentip_mode = query.item[18]
screentip_color = query.item[19]
ghost_darkness_level = query.item[20]
//Sanitize
ooccolor = sanitize_hexcolor(ooccolor, initial(ooccolor))
@@ -41,6 +42,7 @@
parallax = sanitize_integer(parallax, 0, 16, initial(parallax))
screentip_mode = sanitize_integer(screentip_mode, 0, 20, initial(screentip_mode))
screentip_color = sanitize_hexcolor(screentip_color, initial(screentip_color))
ghost_darkness_level = sanitize_integer(ghost_darkness_level, 0, 255, initial(ghost_darkness_level))
return TRUE
/datum/preferences/proc/save_preferences(client/C)
@@ -74,7 +76,8 @@
parallax=:parallax,
2fa_status=:_2fa_status,
screentip_mode=:screentip_mode,
screentip_color=:screentip_color
screentip_color=:screentip_color,
ghost_darkness_level=:ghost_darkness_level
WHERE ckey=:ckey"}, list(
// OH GOD THE PARAMETERS
"ooccolour" = ooccolor,
@@ -95,6 +98,7 @@
"_2fa_status" = _2fa_status,
"screentip_mode" = screentip_mode,
"screentip_color" = screentip_color,
"ghost_darkness_level" = ghost_darkness_level,
"ckey" = C.ckey,
)
)
+20 -13
View File
@@ -89,10 +89,12 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
//starts ghosts off with all HUDs.
toggle_all_huds_on(body)
RegisterSignal(src, COMSIG_MOB_HUD_CREATED, .proc/set_ghost_darkness_level) //something something don't call this until we have a HUD
..()
/mob/dead/observer/Destroy()
toggle_all_huds_off()
UnregisterSignal(src, COMSIG_MOB_HUD_CREATED)
if(ghostimage)
GLOB.ghost_images -= ghostimage
QDEL_NULL(ghostimage)
@@ -100,7 +102,7 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
if(orbit_menu)
SStgui.close_uis(orbit_menu)
QDEL_NULL(orbit_menu)
if (seerads)
if(seerads)
STOP_PROCESSING(SSobj, src)
return ..()
@@ -113,6 +115,13 @@ GLOBAL_VAR_INIT(observer_default_invisibility, INVISIBILITY_OBSERVER)
if(seerads)
show_rads(5)
/mob/dead/observer/proc/set_ghost_darkness_level()
if(!client)
return
UnregisterSignal(src, COMSIG_MOB_HUD_CREATED)
lighting_alpha = client.prefs.ghost_darkness_level //Remembers ghost lighting pref
update_sight()
// This seems stupid, but it's the easiest way to avoid absolutely ridiculous shit from happening
// Copying an appearance directly from a mob includes it's verb list, it's invisibility, it's alpha, and it's density
// You might recognize these things as "fucking ridiculous to put in an appearance"
@@ -663,19 +672,17 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
update_sight()
to_chat(usr, "You [(ghostvision?"now":"no longer")] have ghost vision.")
/mob/dead/observer/verb/toggle_darkness()
set name = "Toggle Darkness"
/mob/dead/observer/verb/pick_darkness()
set name = "Pick Darkness"
set category = "Ghost"
switch(lighting_alpha)
if (LIGHTING_PLANE_ALPHA_VISIBLE)
lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE
if (LIGHTING_PLANE_ALPHA_MOSTLY_VISIBLE)
lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE
if (LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE)
lighting_alpha = LIGHTING_PLANE_ALPHA_INVISIBLE
else
lighting_alpha = LIGHTING_PLANE_ALPHA_VISIBLE
var/desired_dark = input(src, "Choose how much darkness you want to see, (0 - 255). Higher numbers being darker.", "Pick Darkness", null) as null|num
if(isnull(desired_dark))
return
if(!client)
return
client.prefs.ghost_darkness_level = clamp(desired_dark, 0, 255)
client.prefs.save_preferences(src)
lighting_alpha = client.prefs.ghost_darkness_level
update_sight()
/mob/dead/observer/update_sight()
+1 -1
View File
@@ -141,7 +141,7 @@ ipc_screens = [
# Enable/disable the database on a whole
sql_enabled = false
# SQL version. If this is a mismatch, round start will be delayed
sql_version = 29
sql_version = 30
# SQL server address. Can be an IP or DNS name
sql_address = "127.0.0.1"
# SQL server port