Lamp Bloom, Exposure and Glare (#24534)

* Light Update

* Not failing tests I hope

* Whitespace Removal

* Tweaking here and there

* Merge Conflict Fix

* Rebuild TGUI Bundle to Fix Merge Conflict

* Settings are now in "Game Preferences" too

* ColorMatrix formatting and removal of unused procs

* A little mistake on matrices

* A little mistake x2 (last I hope)

* Moving Glare under every other effect, tweaking values, playing with blending

* Update TGUI Bundle for Merge Conflict

* Apply suggestions from code reviews

* Fuck it, it just works

* No tabs cool

* Remove unused

* Am I retarded

* We better return

* Whitespace we need

* oh

* New SQL update version

* Missing comma fix and recompiled tgui.bundle

* Updating SQL version in misc_defines and config

* Remove datum in holder

* BloomEdit empty lines removal

* No more unneeded functions calls

* Tgui.bundle rebuild

* SQL Changes

* SQL Version = 56 now

* Documentation and some formatting

* tgui.bundle.js rebuild

* Remove unused layers and variables

* Allow cameras to render backdrops

* Possible runtime issue fix

* Remove "baked" bloom from the lamps

* Revert the "remove". Make it low on alpha channel

* Shuttle rotation light update fix

* We don't need this

* Possible runtime issue fix x2

* tgui.bundle.js update

* tgui.bundle.js update

* tgui.bundle.js update

* Revert config.toml changes

* Revert the revertion of config.toml changes

* Bring that config changes back!

* Entry added

* tgui.bundle.js update

* Prettier possible fix (?)

* Runtime fix (and broken tubes now have light after reinstalling them)

* config update

---------

Co-authored-by: Mikhail Dzianishchyts <mikhail.dzianishchyts@gmail.com>
This commit is contained in:
RomainzZ
2024-07-05 21:16:16 +00:00
committed by GitHub
co-authored by Mikhail Dzianishchyts
parent 97eb823d4e
commit e386cfd9bf
28 changed files with 774 additions and 54 deletions
+29 -22
View File
@@ -110,37 +110,44 @@
#define LIGHTING_PLANE 15
#define LIGHTING_LAYER 15
#define RAD_TEXT_LAYER 15.1
#define LIGHTING_LAMPS_GLARE 16 // Light glare (optional setting)
#define LIGHTING_EXPOSURE_PLANE 17 // Light sources "cones"
#define LIGHTING_LAMPS_SELFGLOW 18 // Light sources glow (lamps, doors overlay, etc.)
#define LIGHTING_LAMPS_PLANE 19 // Light sources themselves (lamps, screens, etc.)
#define ABOVE_LIGHTING_PLANE 16
#define ABOVE_LIGHTING_LAYER 16
#define LIGHTING_LAMPS_RENDER_TARGET "*LIGHTING_LAMPS_RENDER_TARGET"
#define FLOOR_OPENSPACE_PLANE 17
#define OPENSPACE_LAYER 17
#define RAD_TEXT_LAYER 19.1
#define BYOND_LIGHTING_PLANE 18
#define BYOND_LIGHTING_LAYER 18
#define ABOVE_LIGHTING_PLANE 20
#define ABOVE_LIGHTING_LAYER 20
#define CAMERA_STATIC_PLANE 19
#define CAMERA_STATIC_LAYER 19
#define FLOOR_OPENSPACE_PLANE 21
#define OPENSPACE_LAYER 21
#define BYOND_LIGHTING_PLANE 22
#define BYOND_LIGHTING_LAYER 22
#define CAMERA_STATIC_PLANE 23
#define CAMERA_STATIC_LAYER 23
//HUD layer defines
#define FULLSCREEN_PLANE 20
#define FLASH_LAYER 20
#define FULLSCREEN_LAYER 20.1
#define UI_DAMAGE_LAYER 20.2
#define BLIND_LAYER 20.3
#define CRIT_LAYER 20.4
#define CURSE_LAYER 20.5
#define FULLSCREEN_PLANE 24
#define FLASH_LAYER 24
#define FULLSCREEN_LAYER 24.1
#define UI_DAMAGE_LAYER 24.2
#define BLIND_LAYER 24.3
#define CRIT_LAYER 24.4
#define CURSE_LAYER 24.5
#define HUD_PLANE 21
#define HUD_LAYER 21
#define ABOVE_HUD_PLANE 22
#define ABOVE_HUD_LAYER 22
#define HUD_PLANE 25
#define HUD_LAYER 25
#define ABOVE_HUD_PLANE 26
#define ABOVE_HUD_LAYER 26
#define SPLASHSCREEN_LAYER 23
#define SPLASHSCREEN_PLANE 23
#define SPLASHSCREEN_LAYER 27
#define SPLASHSCREEN_PLANE 27
#define HUD_PLANE_BUILDMODE 30
+16 -2
View File
@@ -13,6 +13,12 @@
#define SOUND_DEFAULT (SOUND_ADMINHELP|SOUND_MIDI|SOUND_AMBIENCE|SOUND_LOBBY|SOUND_HEARTBEAT|SOUND_BUZZ|SOUND_INSTRUMENTS|SOUND_MENTORHELP|SOUND_DISCO|SOUND_AI_VOICE|SOUND_PRAYERNOTIFY)
#define LIGHT_NEW_LIGHTING (1<<0)
#define LIGHT_EXPOSURE (1<<1)
#define LIGHT_GLARE (1<<2)
#define LIGHT_DEFAULT (LIGHT_NEW_LIGHTING|LIGHT_EXPOSURE|LIGHT_GLARE)
#define PREFTOGGLE_CHAT_OOC (1<<0)
#define PREFTOGGLE_CHAT_DEAD (1<<1)
#define PREFTOGGLE_CHAT_GHOSTEARS (1<<2)
@@ -92,10 +98,12 @@
#define PREFTOGGLE_SPECIAL 0
/// Interacts with the sound bitflag
#define PREFTOGGLE_SOUND 1
/// Interacts with the light bitflag
#define PREFTOGGLE_LIGHT 2
/// Interacts with the toggles bitflag
#define PREFTOGGLE_TOGGLE1 2
#define PREFTOGGLE_TOGGLE1 3
/// Interacts with the toggles2 bitflag
#define PREFTOGGLE_TOGGLE2 3
#define PREFTOGGLE_TOGGLE2 4
// Admin attack logs filter system, see /proc/add_attack_logs and /proc/msg_admin_attack
@@ -121,6 +129,12 @@
#define EXP_DEPT_TYPE_LIST list(EXP_TYPE_SUPPLY, EXP_TYPE_SERVICE, EXP_TYPE_MEDICAL, EXP_TYPE_ENGINEERING, EXP_TYPE_SCIENCE, EXP_TYPE_SECURITY, EXP_TYPE_COMMAND, EXP_TYPE_SILICON, EXP_TYPE_SPECIAL, EXP_TYPE_GHOST)
// Defines for the glow level preference for the lighting.
#define GLOW_HIGH 0
#define GLOW_MED 1 // Default.
#define GLOW_LOW 2
#define GLOW_DISABLE 3
// Defines just for parallax because its levels make storing it in the regular prefs a pain in the ass
// These dont need to be bitflags because there isnt going to be more than one at a time of these active
// But its gonna piss off my OCD if it isnt bitflags, so deal with it, -affected
+10
View File
@@ -321,3 +321,13 @@ GLOBAL_LIST_INIT(master_filter_info, list(
/atom/proc/ray_filter_helper(_priority = 1, _size = 40, _color = "#FFFFFF", _factor = 6, _density = 20, _y = 0)
add_filter(name = "ray", priority = _priority, params = list(type = "rays", size = _size, color = _color , factor = _factor, density = _density, y = _y))
/proc/bloom_filter(threshold, size, offset, alpha)
. = list("type" = "bloom")
if(!isnull(threshold))
.["threshold"] = threshold
if(!isnull(size))
.["size"] = size
if(!isnull(offset))
.["offset"] = offset
if(!isnull(alpha))
.["alpha"] = alpha
+1 -1
View File
@@ -142,7 +142,7 @@
for(var/path in subtypesof(/datum/preference_toggle))
var/datum/preference_toggle/pref_toggle = path
if(initial(pref_toggle.name))
GLOB.preference_toggles += new path()
GLOB.preference_toggles[path] = new path()
for(var/path in subtypesof(/datum/objective))
var/datum/objective/O = path
+113
View File
@@ -1,3 +1,8 @@
// Brightness (Luminance) of RGB on grayscale. Used for saturation matrix
#define LUM_R 0.3086 // or 0.2125
#define LUM_G 0.6094 // or 0.7154
#define LUM_B 0.0820 // or 0.0721
/matrix/proc/TurnTo(old_angle, new_angle)
. = new_angle - old_angle
Turn(.) //BYOND handles cases such as -270, 360, 540 etc. DOES NOT HANDLE 180 TURNS WELL, THEY TWEEN AND LOOK LIKE SHIT
@@ -63,3 +68,111 @@
//The Y pixel offset of this matrix
/matrix/proc/get_y_shift()
. = f
/// A color matrix allows us to set the color of an atom in a list form, thus allowing us to change color in more flexible ways. For example, we can set the brightness and contrast of the bloom and exposure of lamps
/datum/color_matrix
var/list/matrix
/// Value can be color as text (e.g. "#735184") that will set matrix to be the same color / number that will set the saturation of matrix / the color list itself, contrast as number, brightness as number
/datum/color_matrix/New(value, contrast = 1, brightness = null)
..()
if(istext(value))
set_color(value, contrast, brightness)
else if(isnum(value))
set_saturation(value, contrast, brightness)
else
matrix = value
/datum/color_matrix/proc/reset()
matrix = list(1, 0, 0,
0, 1, 0,
0, 0, 1)
/datum/color_matrix/proc/get(contrast = 1)
var/list/mat = matrix
mat = mat.Copy()
for(var/i = 1 to min(length(mat), 12))
mat[i] *= contrast
return mat
/datum/color_matrix/proc/set_saturation(saturation, contrast = 1, brightness = null)
var/r_adjustment = (1 - saturation) * LUM_R
var/g_adjustment = (1 - saturation) * LUM_G
var/b_adjustment = (1 - saturation) * LUM_B
matrix = list(contrast * (r_adjustment + saturation), contrast * (r_adjustment), contrast * (r_adjustment),
contrast * (g_adjustment), contrast * (g_adjustment + saturation), contrast * (g_adjustment),
contrast * (b_adjustment), contrast * (b_adjustment), contrast * (b_adjustment + saturation))
set_brightness(brightness)
/datum/color_matrix/proc/set_brightness(brightness)
if(isnull(brightness))
return
if(!matrix)
reset()
var/matrix_length = length(matrix)
// Here we have CCM matrix of type:
// | rr rg rb |
// | gr gg gb |
// | br bg bb |
// with no brightness row, just append it.
if(matrix_length == 9)
matrix += list(brightness, brightness, brightness)
return
// Here we have CCM matrix of type:
// | rr rg rb ra |
// | gr gg gb ga |
// | br bg bb ba |
// | ar ag ab aa |
// with no brightness row, just append it.
if(matrix_length == 16)
matrix += list(brightness, brightness, brightness, 0)
return
// We already have brightness row, just override.
if(matrix_length == 12)
for(var/i = matrix_length to matrix_length - 3 step -1)
matrix[i] = brightness
return
// Just brightness matrix, override.
if(matrix_length == 3)
for(var/i = 1 to matrix_length)
matrix[i] = brightness
return
CRASH("Couldn't figure out how to apply brightness to a matrix of length: [matrix_length]")
/// Handles values from 00 to FF.
/datum/color_matrix/proc/hex2value(hex)
var/const/radix = 16
var/num1 = text2num(hex[1], radix)
var/num2 = text2num(hex[2], radix)
if(!isnum(num1) || !isnum(num2))
CRASH("Invalid hex value: [hex]")
return num1 * radix + num2
/datum/color_matrix/proc/set_color(color_hex, contrast = 1, brightness = null)
var/rr = hex2value(copytext(color_hex, 2, 4)) / 255
var/gg = hex2value(copytext(color_hex, 4, 6)) / 255
var/bb = hex2value(copytext(color_hex, 6, 8)) / 255
rr = round(rr * 1000) / 1000 * contrast
gg = round(gg * 1000) / 1000 * contrast
bb = round(bb * 1000) / 1000 * contrast
matrix = list(rr, gg, bb,
rr, gg, bb,
rr, gg, bb)
set_brightness(brightness)
#undef LUM_R
#undef LUM_G
#undef LUM_B
+79
View File
@@ -110,3 +110,82 @@
plane = SMOKE_PLANE
appearance_flags = PLANE_MASTER
blend_mode = BLEND_OVERLAY
/atom/movable/screen/plane_master/lamps
name = "lamps plane master"
plane = LIGHTING_LAMPS_PLANE
blend_mode = BLEND_OVERLAY
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
render_target = LIGHTING_LAMPS_RENDER_TARGET
/atom/movable/screen/plane_master/exposure
name = "exposure plane master"
plane = LIGHTING_EXPOSURE_PLANE
appearance_flags = parent_type::appearance_flags | PIXEL_SCALE //should use client color
blend_mode = BLEND_ADD
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/exposure/backdrop(mob/mymob)
remove_filter("blur_exposure")
if(!istype(mymob) || !(mymob?.client?.prefs?.light & LIGHT_NEW_LIGHTING))
return
var/enabled = mymob?.client?.prefs?.light & LIGHT_EXPOSURE
if(enabled)
alpha = 255
add_filter("blur_exposure", 1, gauss_blur_filter(size = 20)) // by refs such blur is heavy, but tests were okay and this allow us more flexibility with setup. Possible point for improvements
else
alpha = 0
/atom/movable/screen/plane_master/lamps_selfglow
name = "lamps selfglow plane master"
plane = LIGHTING_LAMPS_SELFGLOW
appearance_flags = PLANE_MASTER //should use client color
blend_mode = BLEND_ADD
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/lamps_selfglow/backdrop(mob/mymob)
remove_filter("add_lamps_to_selfglow")
remove_filter("lamps_selfglow_bloom")
if(!istype(mymob) || !(mymob?.client?.prefs?.light & LIGHT_NEW_LIGHTING))
return
var/level = mymob?.client?.prefs?.glowlevel
if(isnull(level))
return
var/bloomsize = 0
var/bloomoffset = 0
switch(level)
if(GLOW_LOW)
bloomsize = 2
bloomoffset = 1
if(GLOW_MED)
bloomsize = 3
bloomoffset = 2
if(GLOW_HIGH)
bloomsize = 5
bloomoffset = 3
else
return
add_filter("add_lamps_to_selfglow", 1, layering_filter(render_source = LIGHTING_LAMPS_RENDER_TARGET, blend_mode = BLEND_OVERLAY))
add_filter("lamps_selfglow_bloom", 1, bloom_filter(threshold = "#777777", size = bloomsize, offset = bloomoffset, alpha = 80))
/atom/movable/screen/plane_master/lamps_glare
name = "lamps glare plane master"
plane = LIGHTING_LAMPS_GLARE
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
/atom/movable/screen/plane_master/lamps_glare/backdrop(mob/mymob)
remove_filter("add_lamps_to_glare")
remove_filter("lamps_glare")
if(!istype(mymob) || !(mymob?.client?.prefs?.light & LIGHT_NEW_LIGHTING))
return
var/enabled = mymob?.client?.prefs?.light & LIGHT_GLARE
if(enabled)
add_filter("add_lamps_to_glare", 1, layering_filter(render_source = LIGHTING_LAMPS_RENDER_TARGET, blend_mode = BLEND_ADD))
add_filter("lamps_glare", 1, radial_blur_filter(size = 0.035))
+11 -1
View File
@@ -74,4 +74,14 @@
/atom/movable/plane_master_controller/game
name = PLANE_MASTERS_GAME
controlled_planes = list(FLOOR_PLANE, GAME_PLANE, LIGHTING_PLANE, PLANE_SPACE_PARALLAX, PLANE_SPACE)
controlled_planes = list(
FLOOR_PLANE,
GAME_PLANE,
LIGHTING_PLANE,
PLANE_SPACE_PARALLAX,
PLANE_SPACE,
LIGHTING_EXPOSURE_PLANE,
LIGHTING_LAMPS_SELFGLOW,
LIGHTING_LAMPS_PLANE,
LIGHTING_LAMPS_GLARE
)
@@ -22,6 +22,8 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new())
var/datum/configuration_section/gamemode_configuration/gamemode
/// Holder for the general configuration datum
var/datum/configuration_section/general_configuration/general
/// Holder for the lighting effects configuration datum
var/datum/configuration_section/lighting_effects_configuration/lighting_effects
/// Holder for the IPIntel configuration datum
var/datum/configuration_section/ipintel_configuration/ipintel
/// Holder for the job configuration datum
@@ -82,6 +84,7 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new())
event = new()
gamemode = new()
general = new()
lighting_effects = new()
ipintel = new()
jobs = new()
logging = new()
@@ -120,6 +123,7 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new())
safe_load(event, "event_configuration")
safe_load(gamemode, "gamemode_configuration")
safe_load(general, "general_configuration")
safe_load(lighting_effects, "lighting_effects_configuration")
safe_load(ipintel, "ipintel_configuration")
safe_load(jobs, "job_configuration")
safe_load(logging, "logging_configuration")
@@ -0,0 +1,29 @@
/// Config holder for all ligting effect related things
/datum/configuration_section/lighting_effects_configuration
/// Brightness of bloom effect independent of light_power
var/glow_brightness_base = 0
/// Brightness of bloom effect that depends on light_power
var/glow_brightness_power = -0.25
/// Contrast of bloom effect independent of light_power
var/glow_contrast_base = 0
/// Contrast of bloom effect that depends on light_power
var/glow_contrast_power = 0.5
/// Brightness of exposure effect independent of light_power
var/exposure_brightness_base = 0.01
/// Brightness of exposure effect that depends on light_power
var/exposure_brightness_power = 0
/// Contrast of exposure effect independent of light_power
var/exposure_contrast_base = 9.5
/// Contrast of exposure effect that depends on light_power
var/exposure_contrast_power = 0
/datum/configuration_section/lighting_effects_configuration/load_data(list/data)
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
CONFIG_LOAD_NUM(glow_brightness_base, data["glow_brightness_base"])
CONFIG_LOAD_NUM(glow_brightness_power, data["glow_brightness_power"])
CONFIG_LOAD_NUM(glow_contrast_base, data["glow_contrast_base"])
CONFIG_LOAD_NUM(glow_contrast_power, data["glow_contrast_power"])
CONFIG_LOAD_NUM(exposure_brightness_base, data["exposure_brightness_base"])
CONFIG_LOAD_NUM(exposure_brightness_power, data["exposure_brightness_power"])
CONFIG_LOAD_NUM(exposure_contrast_base, data["exposure_contrast_base"])
CONFIG_LOAD_NUM(exposure_contrast_power, data["exposure_contrast_power"])
+11
View File
@@ -104,6 +104,17 @@
var/tmp/datum/light_source/light
// Any light sources that are "inside" of us, for example, if src here was a mob that's carrying a flashlight, that flashlight's light source would be part of this list.
var/tmp/list/light_sources
// Variables for bloom and exposure
var/glow_icon = 'icons/obj/lamps.dmi'
var/exposure_icon = 'icons/effects/exposures.dmi'
var/glow_icon_state
var/glow_colored = TRUE
var/exposure_icon_state
var/exposure_colored = TRUE
var/image/glow_overlay
var/image/exposure_overlay
/// The alternate appearances we own. Lazylist
var/list/alternate_appearances
/// The alternate appearances we're viewing, stored here to reestablish them after Logout()s. Lazylist
@@ -40,11 +40,7 @@
cam_screen.screen_loc = "[map_name]:1,1"
cam_plane_masters = list()
for(var/plane in subtypesof(/atom/movable/screen/plane_master))
var/atom/movable/screen/instance = new plane()
instance.assigned_map = map_name
instance.del_on_map_removal = FALSE
instance.screen_loc = "[map_name]:CENTER"
cam_plane_masters += instance
cam_plane_masters += plane
cam_background = new
cam_background.assigned_map = map_name
cam_background.del_on_map_removal = FALSE
@@ -79,7 +75,13 @@
// Register map objects
user.client.register_map_obj(cam_screen)
for(var/plane in cam_plane_masters)
user.client.register_map_obj(plane)
var/atom/movable/screen/plane_master/instance = new plane()
instance.assigned_map = map_name
instance.del_on_map_removal = FALSE
instance.screen_loc = "[map_name]:CENTER"
instance.backdrop(user)
user.client.register_map_obj(instance)
user.client.register_map_obj(cam_background)
// Open UI
ui = new(user, src, "CameraConsole", name)
+2 -1
View File
@@ -176,7 +176,8 @@ GLOBAL_LIST_INIT(admin_verbs_debug, list(
/client/proc/teleport_interesting_turf,
/client/proc/visualize_interesting_turfs,
/client/proc/profile_code,
/client/proc/debug_atom_init
/client/proc/debug_atom_init,
/client/proc/debug_bloom
))
GLOBAL_LIST_INIT(admin_verbs_possess, list(
/proc/possess,
+71
View File
@@ -0,0 +1,71 @@
/client/proc/debug_bloom()
set name = "Bloom Edit"
set category = "Debug"
if(!check_rights(R_DEBUG))
return
var/datum/bloom_edit/editor = new()
editor.ui_interact(usr)
message_admins("[key_name(src)] opened Bloom Edit panel.")
log_admin("[key_name(src)] opened Bloom Edit panel.")
/datum/bloom_edit
/datum/bloom_edit/ui_interact(mob/user, datum/tgui/ui = null)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "BloomEdit", "Bloom Edit")
ui.open()
/datum/bloom_edit/ui_data(mob/user)
var/list/data = list()
data["glow_brightness_base"] = GLOB.configuration.lighting_effects.glow_brightness_base
data["glow_brightness_power"] = GLOB.configuration.lighting_effects.glow_brightness_power
data["glow_contrast_base"] = GLOB.configuration.lighting_effects.glow_contrast_base
data["glow_contrast_power"] = GLOB.configuration.lighting_effects.glow_contrast_power
data["exposure_brightness_base"] = GLOB.configuration.lighting_effects.exposure_brightness_base
data["exposure_brightness_power"] = GLOB.configuration.lighting_effects.exposure_brightness_power
data["exposure_contrast_base"] = GLOB.configuration.lighting_effects.exposure_contrast_base
data["exposure_contrast_power"] = GLOB.configuration.lighting_effects.exposure_contrast_power
return data
/datum/bloom_edit/ui_act(action, list/params, datum/tgui/ui, datum/ui_state/state)
. = ..()
if(.)
return
switch(action)
if("glow_brightness_base")
GLOB.configuration.lighting_effects.glow_brightness_base = clamp(params["value"], -10, 10)
if("glow_brightness_power")
GLOB.configuration.lighting_effects.glow_brightness_power = clamp(params["value"], -10, 10)
if("glow_contrast_base")
GLOB.configuration.lighting_effects.glow_contrast_base = clamp(params["value"], -10, 10)
if("glow_contrast_power")
GLOB.configuration.lighting_effects.glow_contrast_power = clamp(params["value"], -10, 10)
if("exposure_brightness_base")
GLOB.configuration.lighting_effects.exposure_brightness_base = clamp(params["value"], -10, 10)
if("exposure_brightness_power")
GLOB.configuration.lighting_effects.exposure_brightness_power = clamp(params["value"], -10, 10)
if("exposure_contrast_base")
GLOB.configuration.lighting_effects.exposure_contrast_base = clamp(params["value"], -10, 10)
if("exposure_contrast_power")
GLOB.configuration.lighting_effects.exposure_contrast_power = clamp(params["value"], -10, 10)
if("default")
GLOB.configuration.lighting_effects.glow_brightness_base = initial(GLOB.configuration.lighting_effects.glow_brightness_base)
GLOB.configuration.lighting_effects.glow_brightness_power = initial(GLOB.configuration.lighting_effects.glow_brightness_power)
GLOB.configuration.lighting_effects.glow_contrast_base = initial(GLOB.configuration.lighting_effects.glow_contrast_base)
GLOB.configuration.lighting_effects.glow_contrast_power = initial(GLOB.configuration.lighting_effects.glow_contrast_power)
GLOB.configuration.lighting_effects.exposure_brightness_base = initial(GLOB.configuration.lighting_effects.exposure_brightness_base)
GLOB.configuration.lighting_effects.exposure_brightness_power = initial(GLOB.configuration.lighting_effects.exposure_brightness_power)
GLOB.configuration.lighting_effects.exposure_contrast_base = initial(GLOB.configuration.lighting_effects.exposure_contrast_base)
GLOB.configuration.lighting_effects.exposure_contrast_power = initial(GLOB.configuration.lighting_effects.exposure_contrast_power)
if("update_lamps")
for(var/obj/machinery/light/L in GLOB.machines)
if(L.glow_overlay || L.exposure_overlay)
L.update_bloom()
return TRUE
/datum/bloom_edit/ui_state(mob/user)
return GLOB.admin_state
@@ -14,6 +14,8 @@
toggles,
toggles_2,
sound,
light,
glowlevel,
volume_mixer,
lastchangelog,
exp,
@@ -896,7 +896,6 @@
return
switch(newgender)
if("Male")
active_character.gender = MALE
if("Female")
active_character.gender = FEMALE
@@ -954,6 +953,22 @@
if("ghost_att_anim")
toggles2 ^= PREFTOGGLE_2_ITEMATTACK
if("enablelighting")
var/datum/preference_toggle/special_toggle/toggle = GLOB.preference_toggles[/datum/preference_toggle/toggle_new_lighting]
toggle.set_toggles(user.client)
if("glowlevel")
var/datum/preference_toggle/special_toggle/toggle = GLOB.preference_toggles[/datum/preference_toggle/special_toggle/set_glow_level]
toggle.set_toggles(user.client)
if("exposure")
var/datum/preference_toggle/special_toggle/toggle = GLOB.preference_toggles[/datum/preference_toggle/toggle_lamp_exposure]
toggle.set_toggles(user.client)
if("glare")
var/datum/preference_toggle/special_toggle/toggle = GLOB.preference_toggles[/datum/preference_toggle/toggle_lamps_glare]
toggle.set_toggles(user.client)
if("winflash")
toggles2 ^= PREFTOGGLE_2_WINDOWFLASHING
+26 -2
View File
@@ -63,11 +63,15 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/toggles = TOGGLES_DEFAULT
var/toggles2 = TOGGLES_2_DEFAULT // Created because 1 column has a bitflag limit of 24 (BYOND limitation not MySQL)
var/sound = SOUND_DEFAULT
var/light = LIGHT_DEFAULT
/// Glow level for the lighting. Takes values from GLOW_HIGH to GLOW_DISABLE.
var/glowlevel = GLOW_MED
var/UI_style_color = "#ffffff"
var/UI_style_alpha = 255
var/clientfps = 63
var/atklog = ATKLOG_ALL
var/fuid // forum userid
/// Forum userid
var/fuid
/// Volume mixer, indexed by channel as TEXT (numerical indexes will not work). Volume goes from 0 to 100.
var/list/volume_mixer = list(
@@ -437,6 +441,23 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<b>View Range:</b> <a href='byond://?_src_=prefs;preference=setviewrange'>[viewrange]</a><br>"
dat += "<b>Window Flashing:</b> <a href='byond://?_src_=prefs;preference=winflash'>[(toggles2 & PREFTOGGLE_2_WINDOWFLASHING) ? "Yes" : "No"]</a><br>"
dat += "<b>Modsuit Activation Method:</b> <a href='byond://?_src_=prefs;preference=mam'>[(toggles2 & PREFTOGGLE_2_MOD_ACTIVATION_METHOD) ? "Middle Click" : "Alt Click"]</a><br>"
dat += "<b>Lighting settings:</b><br>"
dat += "<b> - New Lighting:</b> <a href='byond://?_src_=prefs;preference=enablelighting'>[(light & LIGHT_NEW_LIGHTING) ? "Yes" : "No"]</a><br>"
dat += "<b> - Glow Level:</b> <a href='byond://?_src_=prefs;preference=glowlevel'>"
switch(glowlevel)
if(GLOW_LOW)
dat += "Low"
if(GLOW_MED)
dat += "Medium"
if(GLOW_HIGH)
dat += "High"
if(GLOW_DISABLE)
dat += "Disabled"
else
dat += "Medium"
dat += "</a><br>"
dat += "<b> - Lamp Exposure:</b> <a href='byond://?_src_=prefs;preference=exposure'>[(light & LIGHT_EXPOSURE) ? "Yes" : "No"]</a><br>"
dat += "<b> - Lamp Glare:</b> <a href='byond://?_src_=prefs;preference=glare'>[(light & LIGHT_GLARE) ? "Yes" : "No"]</a><br>"
// RIGHT SIDE OF THE PAGE
dat += "</td><td width='405px' height='300px' valign='top'>"
dat += "<h2>Interface Settings</h2>"
@@ -603,7 +624,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
var/static/list/pref_toggles_by_category
if(!pref_toggles_by_category)
pref_toggles_by_category = list()
for(var/datum/preference_toggle/toggle as anything in GLOB.preference_toggles)
for(var/toggle_type in GLOB.preference_toggles)
var/datum/preference_toggle/toggle = GLOB.preference_toggles[toggle_type]
pref_toggles_by_category["[toggle.preftoggle_category]"] += list(toggle)
for(var/category in GLOB.preference_toggle_groups)
@@ -627,6 +649,8 @@ GLOBAL_LIST_INIT(special_role_times, list( //minimum age (in days) for accounts
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(toggles2 & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
if(PREFTOGGLE_SOUND)
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(sound & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
if(PREFTOGGLE_LIGHT)
dat += "<td style='width: 20%'><a href='byond://?_src_=prefs;preference=preference_toggles;toggle=[toggle.UID()];'>[(light & toggle.preftoggle_bitflag) ? "<span class='good'>Enabled</span>" : "<span class='bad'>Disabled</span>"]</a></td>"
dat += "</tr>"
dat += "<tr><td colspan=4><br></td></tr>"
@@ -14,22 +14,24 @@
toggles = text2num(query.item[7])
toggles2 = text2num(query.item[8])
sound = text2num(query.item[9])
volume_mixer = deserialize_volume_mixer(query.item[10])
lastchangelog = query.item[11]
exp = query.item[12]
clientfps = text2num(query.item[13])
atklog = text2num(query.item[14])
fuid = text2num(query.item[15])
parallax = text2num(query.item[16])
_2fa_status = query.item[17]
screentip_mode = query.item[18]
screentip_color = query.item[19]
ghost_darkness_level = query.item[20]
colourblind_mode = query.item[21]
keybindings = init_keybindings(raw = query.item[22])
server_region = query.item[23]
raw_muted_admins = query.item[24]
viewrange = query.item[25]
light = text2num(query.item[10])
glowlevel = query.item[11]
volume_mixer = deserialize_volume_mixer(query.item[12])
lastchangelog = query.item[13]
exp = query.item[14]
clientfps = text2num(query.item[15])
atklog = text2num(query.item[16])
fuid = text2num(query.item[17])
parallax = text2num(query.item[18])
_2fa_status = query.item[19]
screentip_mode = query.item[20]
screentip_color = query.item[21]
ghost_darkness_level = query.item[22]
colourblind_mode = query.item[23]
keybindings = init_keybindings(raw = query.item[24])
server_region = query.item[25]
raw_muted_admins = query.item[26]
viewrange = query.item[27]
lastchangelog_2 = lastchangelog // Clone please
@@ -88,6 +90,8 @@
toggles_2=:toggles2,
atklog=:atklog,
sound=:sound,
light=:light,
glowlevel=:glowlevel,
volume_mixer=:volume_mixer,
lastchangelog=:lastchangelog,
clientfps=:clientfps,
@@ -114,6 +118,8 @@
"toggles2" = num2text(toggles2, CEILING(log(10, (TOGGLES_2_TOTAL)), 1)),
"atklog" = atklog,
"sound" = sound,
"light" = light,
"glowlevel" = glowlevel,
"volume_mixer" = serialize_volume_mixer(volume_mixer),
"lastchangelog" = lastchangelog,
"clientfps" = clientfps,
@@ -39,6 +39,9 @@
if(PREFTOGGLE_SOUND)
our_prefs.sound ^= preftoggle_bitflag
to_chat(user, "<span class='notice'>[(our_prefs.sound & preftoggle_bitflag) ? enable_message : disable_message]</span>")
if(PREFTOGGLE_LIGHT)
our_prefs.light ^= preftoggle_bitflag
to_chat(user, "<span class='notice'>[(our_prefs.light & preftoggle_bitflag) ? enable_message : disable_message]</span>")
SSblackbox.record_feedback("tally", "toggle_verbs", 1, blackbox_message)
our_prefs.save_preferences(user)
@@ -516,3 +519,80 @@
user.prefs.atklog = ATKLOG_NONE
to_chat(usr, "Your attack logs preference is now: show NO attack logs")
return ..()
/datum/preference_toggle/toggle_new_lighting
name = "Toggle New Lighting"
description = "Toggles new lighting"
preftoggle_bitflag = LIGHT_NEW_LIGHTING
preftoggle_toggle = PREFTOGGLE_LIGHT
preftoggle_category = PREFTOGGLE_CATEGORY_GENERAL
enable_message = "You've enabled new lighting."
disable_message = "You've disabled new lighting."
blackbox_message = "New lighting toggled"
/datum/preference_toggle/toggle_new_lighting/set_toggles(client/user)
. = ..()
if(length(user.screen))
var/atom/movable/screen/plane_master/exposure/exposure_master = locate() in user.screen
var/atom/movable/screen/plane_master/lamps_selfglow/glow_master = locate() in user.screen
var/atom/movable/screen/plane_master/lamps_glare/glare_master = locate() in user.screen
exposure_master.alpha = user.prefs.light & LIGHT_NEW_LIGHTING ? 255 : 0
exposure_master.backdrop(user.mob)
glow_master.backdrop(user.mob)
glare_master.backdrop(user.mob)
/datum/preference_toggle/special_toggle/set_glow_level
name = "Set Glow Level"
description = "Changes glow level of light sources"
preftoggle_category = PREFTOGGLE_CATEGORY_GENERAL
blackbox_message = "Changed glow level of light sources"
/datum/preference_toggle/special_toggle/set_glow_level/set_toggles(client/user)
var/glow_levels = list(
"Disable" = GLOW_DISABLE,
"Low" = GLOW_LOW,
"Medium (Default)" = GLOW_MED,
"High" = GLOW_HIGH,
)
var/new_level = tgui_input_list(user, "Set glow level of light sources", "Glow Level", glow_levels)
if(!new_level)
return
user.prefs.glowlevel = glow_levels[new_level]
to_chat(usr, "Glow level: [new_level].")
if(length(user.screen))
var/atom/movable/screen/plane_master/lamps_selfglow/glow_master = locate() in user.screen
glow_master.backdrop(user.mob)
return ..()
/datum/preference_toggle/toggle_lamp_exposure
name = "Toggle Lamp Exposure"
description = "Toggles lamp exposure"
preftoggle_bitflag = LIGHT_EXPOSURE
preftoggle_toggle = PREFTOGGLE_LIGHT
preftoggle_category = PREFTOGGLE_CATEGORY_GENERAL
enable_message = "You've enabled lamp exposure."
disable_message = "You've disabled lamp exposure."
blackbox_message = "Lamp exposure toggled"
/datum/preference_toggle/toggle_lamp_exposure/set_toggles(client/user)
. = ..()
if(length(user.screen))
var/atom/movable/screen/plane_master/exposure/exposure_master = locate() in user.screen
exposure_master.backdrop(user.mob)
/datum/preference_toggle/toggle_lamps_glare
name = "Toggle Lamp Glare"
description = "Toggles lamp glare"
preftoggle_bitflag = LIGHT_GLARE
preftoggle_toggle = PREFTOGGLE_LIGHT
preftoggle_category = PREFTOGGLE_CATEGORY_GENERAL
enable_message = "You've enabled lamp glare."
disable_message = "You've disabled lamp glare."
blackbox_message = "Lamp glare toggled"
/datum/preference_toggle/toggle_lamps_glare/set_toggles(client/user)
. = ..()
if(length(user.screen))
var/atom/movable/screen/plane_master/lamps_glare/glare_master = locate() in user.screen
glare_master.backdrop(user.mob)
+45
View File
@@ -120,3 +120,48 @@
/mob/living/proc/mob_light(_color, _range, _power, _duration)
var/obj/effect/dummy/lighting_obj/moblight/mob_light_obj = new (src, _color, _range, _power, _duration)
return mob_light_obj
/atom/proc/update_bloom()
cut_overlay(glow_overlay)
cut_overlay(exposure_overlay)
if(glow_icon && glow_icon_state)
glow_overlay = image(icon = glow_icon, icon_state = glow_icon_state, dir = dir, layer = 1)
glow_overlay.plane = LIGHTING_LAMPS_PLANE
glow_overlay.blend_mode = BLEND_ADD
if(glow_colored)
var/datum/color_matrix/mat = new(
light_color,
GLOB.configuration.lighting_effects.glow_contrast_base + GLOB.configuration.lighting_effects.glow_contrast_power * light_power,
GLOB.configuration.lighting_effects.glow_brightness_base + GLOB.configuration.lighting_effects.glow_brightness_power * light_power)
glow_overlay.color = mat.get()
add_overlay(glow_overlay)
if(exposure_icon && exposure_icon_state)
exposure_overlay = image(icon = exposure_icon, icon_state = exposure_icon_state, dir = dir, layer = -1)
exposure_overlay.plane = LIGHTING_EXPOSURE_PLANE
exposure_overlay.blend_mode = BLEND_ADD
exposure_overlay.appearance_flags = RESET_ALPHA | RESET_COLOR | KEEP_APART
var/datum/color_matrix/mat = new(
1,
GLOB.configuration.lighting_effects.exposure_contrast_base + GLOB.configuration.lighting_effects.exposure_contrast_power * light_power,
GLOB.configuration.lighting_effects.exposure_brightness_base + GLOB.configuration.lighting_effects.exposure_brightness_power * light_power)
if(exposure_colored)
mat.set_color(
light_color,
GLOB.configuration.lighting_effects.exposure_contrast_base + GLOB.configuration.lighting_effects.exposure_contrast_power * light_power,
GLOB.configuration.lighting_effects.exposure_brightness_base + GLOB.configuration.lighting_effects.exposure_brightness_power * light_power)
exposure_overlay.color = mat.get()
var/icon/EX = icon(icon = exposure_icon, icon_state = exposure_icon_state)
exposure_overlay.pixel_x = 16 - EX.Width() / 2
exposure_overlay.pixel_y = 16 - EX.Height() / 2
add_overlay(exposure_overlay)
/atom/proc/delete_lights()
cut_overlay(glow_overlay)
cut_overlay(exposure_overlay)
QDEL_NULL(glow_overlay)
QDEL_NULL(exposure_overlay)
+3
View File
@@ -57,6 +57,7 @@
/datum/light_source/Destroy(force)
remove_lum()
if(source_atom)
source_atom.delete_lights()
LAZYREMOVE(source_atom.light_sources, src)
if(top_atom)
@@ -217,6 +218,8 @@
if(update)
needs_update = LIGHTING_CHECK_UPDATE
applied = TRUE
if(source_atom)
source_atom.update_bloom()
else if(needs_update == LIGHTING_CHECK_UPDATE)
return //nothing's changed
+5
View File
@@ -167,6 +167,8 @@
desc = "Industrial-grade light fixture for brightening up dark corners of the station."
icon = 'icons/obj/lighting.dmi'
icon_state = "tube1"
glow_icon_state = "tube"
exposure_icon_state = "cone"
anchored = TRUE
layer = 5
max_integrity = 100
@@ -233,6 +235,8 @@
icon_state = "bulb1"
desc = "A compact and cheap light fixture, perfect for keeping maintenance tunnels appropriately spooky."
fitting = "bulb"
glow_icon_state = "bulb"
exposure_icon_state = "circle"
base_state = "bulb"
brightness_range = 4
brightness_color = "#a0a080"
@@ -887,6 +891,7 @@
base_state = "ltube"
item_state = "c_tube"
brightness_range = 8
brightness_color = "#ffffff"
/obj/item/light/tube/large
w_class = WEIGHT_CLASS_SMALL