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-06 05:16:16 +08:00
committed by GitHub
parent 97eb823d4e
commit e386cfd9bf
28 changed files with 774 additions and 54 deletions
+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