Skip to content

Commit

Permalink
Merge branch 'TauCetiStation:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
BasiaBelov authored Mar 13, 2024
2 parents cb5b8ff + da2cae7 commit 4bc5e07
Show file tree
Hide file tree
Showing 121 changed files with 1,170 additions and 1,125 deletions.
4 changes: 4 additions & 0 deletions code/__DEFINES/_planes_layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ What is the naming convention for planes or layers?
#define LIGHTING_LAMPS_GLARE 104 // Light glare (optional setting)
#define LIGHTING_LAMPS_RENDER_TARGET "*LIGHTING_LAMPS_RENDER_TARGET"

#define ENVIRONMENT_LIGHTING_PLANE 110
#define ENVIRONMENT_LIGHTING_COLOR_PLANE 111
#define ENVIRONMENT_LIGHTING_LOCAL_PLANE 112

#define ABOVE_LIGHTING_PLANE 120
#define ABOVE_LIGHTING_LAYER 1
#define RUNECHAT_LAYER 2
Expand Down
2 changes: 2 additions & 0 deletions code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@
///from base of obj/allowed(mob/M): (/obj) returns ACCESS_ALLOWED if mob has id access to the obj
#define COMSIG_MOB_TRIED_ACCESS "tried_access"
#define COMSIG_ACCESS_ALLOWED 1
///from base of /mob/proc/update_z: (new_z)
#define COMSIG_MOB_Z_CHANGED "mob_z_changed"

// living signals
///from base of mob/living/rejuvenate(): ()
Expand Down
33 changes: 18 additions & 15 deletions code/__DEFINES/lighting.dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@

#define MINIMUM_USEFUL_LIGHT_RANGE 1.4

#define LIGHTING_FALLOFF 1 // type of falloff to use for lighting; 1 for circular, 2 for square
#define LIGHTING_LAMBERTIAN 0 // use lambertian shading for light sources
#define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone
#define LIGHTING_ROUND_VALUE (1 / 64) //Value used to round lumcounts, values smaller than 1/129 don't matter (if they do, thanks sinking points), greater values will make lighting less precise, but in turn increase performance, VERY SLIGHTLY.

#define LIGHTING_ICON 'icons/effects/lighting_object.dmi' // icon used for lighting shading effects

// If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting objects.
// Set to zero to disable soft lighting. Luminosity changes then work if it's lit at all.
#define LIGHTING_SOFT_THRESHOLD 0
Expand All @@ -33,14 +29,6 @@
#define LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE 128 //For lighting alpha, small amounts lead to big changes. even at 128 its hard to figure out what is dark and what is light, at 64 you almost can't even tell.
#define LIGHTING_PLANE_ALPHA_INVISIBLE 0

//lighting area defines
#define DYNAMIC_LIGHTING_DISABLED 0 //dynamic lighting disabled (area stays at full brightness)
#define DYNAMIC_LIGHTING_ENABLED 1 //dynamic lighting enabled
#define DYNAMIC_LIGHTING_FORCED 2 //dynamic lighting enabled even if the area doesn't require power
#define DYNAMIC_LIGHTING_IFSTARLIGHT 3 //dynamic lighting enabled only if starlight is.
#define IS_DYNAMIC_LIGHTING(A) A.dynamic_lighting


//code assumes higher numbers override lower numbers.
#define LIGHTING_NO_UPDATE 0
#define LIGHTING_VIS_UPDATE 1
Expand All @@ -62,7 +50,6 @@

/// Parse the hexadecimal color into lumcounts of each perspective.
#define PARSE_LIGHT_COLOR(source) \
do { \
if (source.light_color) { \
var/__light_color = source.light_color; \
source.lum_r = GETREDPART(__light_color) / 255; \
Expand All @@ -72,5 +59,21 @@ do { \
source.lum_r = 1; \
source.lum_g = 1; \
source.lum_b = 1; \
}; \
} while (FALSE)
};

#define GET_LUM_FROM_COLOR(color) (GETREDPART(color) + GETGREENPART(color) + GETBLUEPART(color))/3


// this comes from 1 source turf + 1 source cast turf + plane blur that touches another turf
#define LEVEL_LIGHT_LUMINOSITY 3

// adds lighting mask to turf, see more in comments to environment_lighting plane
// we add this to underlays because else it will corrupt turf icon in context menu / other places
// does not cast light around, must be done separately
#define ENABLE_LEVEL_LIGHTING(turf) \
turf.underlays |= list(global.level_light_mask); \
if(turf.level_light_source) turf.luminosity = LEVEL_LIGHT_LUMINOSITY

#define DISABLE_LEVEL_LIGHTING(turf) \
turf.underlays -= global.level_light_mask; \
turf.luminosity = initial(turf.luminosity)
18 changes: 18 additions & 0 deletions code/__HELPERS/hex_colors.dm → code/__HELPERS/colors.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
return rgb(RGB[1],RGB[2],RGB[3])

// make hex color brighter before one value is #ff
// todo: replace with color_lightness_max
/proc/adjust_to_white(color)
var/list/RGB[3]
RGB[1] = HEX_VAL_RED(color)
Expand All @@ -66,3 +67,20 @@
RGB[i] += min_diff

return rgb(RGB[1],RGB[2],RGB[3])

/// Ensures that the lightness value of a color must be greater than the provided minimum.
/proc/color_lightness_max(color, min_lightness)
var/list/rgb = rgb2num(color)
var/list/hsl = rgb2hsl(rgb[1], rgb[2], rgb[3])
hsl[3] = max(hsl[3], min_lightness)
var/list/transformed_rgb = hsl2rgb(hsl[1], hsl[2], hsl[3])
return rgb(transformed_rgb[1], transformed_rgb[2], transformed_rgb[3])

/// Ensures that the lightness value of a color must be less than the provided maximum.
/proc/color_lightness_min(color, max_lightness)
var/list/rgb = rgb2num(color)
var/list/hsl = rgb2hsl(rgb[1], rgb[2], rgb[3])
// Ensure high lightness (Minimum of 90%)
hsl[3] = min(hsl[3], max_lightness)
var/list/transformed_rgb = hsl2rgb(hsl[1], hsl[2], hsl[3])
return rgb(transformed_rgb[1], transformed_rgb[2], transformed_rgb[3])
4 changes: 4 additions & 0 deletions code/__HELPERS/global_lists.dm
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@
for(var/datum/smartlight_preset/type as anything in subtypesof(/datum/smartlight_preset))
smartlight_presets[initial(type.name)] = type

global.lighting_effects = list()
for(var/datum/level_lighting_effect/type as anything in subtypesof(/datum/level_lighting_effect))
lighting_effects[initial(type.name)] = type

global.virus_types_by_pool = list()
for(var/e in subtypesof(/datum/disease2/effect))
var/datum/disease2/effect/f = new e
Expand Down
75 changes: 70 additions & 5 deletions code/__HELPERS/type2type.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/

//Returns an integer given a hex input
//todo: replace with macro from tg
/proc/hex2num(hex)
if (!( istext(hex) ))
return
Expand Down Expand Up @@ -43,6 +44,7 @@
return num

//Returns the hex value of a number given a value assumed to be a base-ten value
//todo: replace with macro from tg
/proc/num2hex(num, placeholder)

if (placeholder == null)
Expand Down Expand Up @@ -107,8 +109,7 @@
return splittext(trim(return_file_text(filename)),seperator)


//Turns a direction into text

//Turns a direction into text (what?)
/proc/num2dir(direction)
switch(direction)
if(1.0) return NORTH
Expand All @@ -118,8 +119,6 @@
else
world.log << "UNKNOWN DIRECTION: [direction]"



//Turns a direction into text
/proc/dir2text(direction)
switch(direction)
Expand Down Expand Up @@ -177,7 +176,6 @@
return NORTH|WEST

//returns the north-zero clockwise angle in degrees, given a direction

/proc/dir2angle(D)
switch(D)
if(NORTH) return 0
Expand Down Expand Up @@ -277,3 +275,70 @@
else
return /datum
return text2path(copytext(string_type, 1, last_slash))

/// Converts an RGB color to an HSL color
/proc/rgb2hsl(red, green, blue)
red /= 255;green /= 255;blue /= 255;
var/max = max(red,green,blue)
var/min = min(red,green,blue)
var/range = max-min

var/hue=0;var/saturation=0;var/lightness=0;
lightness = (max + min)/2
if(range != 0)
if(lightness < 0.5)
saturation = range/(max+min)
else
saturation = range/(2-max-min)

var/dred = ((max-red)/(6*max)) + 0.5
var/dgreen = ((max-green)/(6*max)) + 0.5
var/dblue = ((max-blue)/(6*max)) + 0.5

if(max==red)
hue = dblue - dgreen
else if(max==green)
hue = dred - dblue + (1/3)
else
hue = dgreen - dred + (2/3)
if(hue < 0)
hue++
else if(hue > 1)
hue--

return list(hue, saturation, lightness)

/// Converts an HSL color to an RGB color
/proc/hsl2rgb(hue, saturation, lightness)
var/red;var/green;var/blue;
if(saturation == 0)
red = lightness * 255
green = red
blue = red
else
var/a;var/b;
if(lightness < 0.5)
b = lightness*(1+saturation)
else
b = (lightness+saturation) - (saturation*lightness)
a = 2*lightness - b

red = round(255 * hue2rgb(a, b, hue+(1/3)))
green = round(255 * hue2rgb(a, b, hue))
blue = round(255 * hue2rgb(a, b, hue-(1/3)))

return list(red, green, blue)

/// Converts an ABH color to an RGB color
/proc/hue2rgb(a, b, hue)
if(hue < 0)
hue++
else if(hue > 1)
hue--
if(6*hue < 1)
return (a+(b-a)*6*hue)
if(2*hue < 1)
return b
if(3*hue < 2)
return (a+(b-a)*((2/3)-hue)*6)
return a
29 changes: 16 additions & 13 deletions code/__HELPERS/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -683,9 +683,11 @@ Turf and target are seperate in case you want to teleport some distance from a t
areas += N
return areas

//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all turfs in areas of that type of that type in the world.
/proc/get_area_turfs(areatype, subtypes=TRUE, target_z = 0, list/black_list)
// Takes: Area type as text string or as typepath OR an instance of the area.
// Returns: A list of all turfs in areas of that type of that type in the world.
// Please note that because of (loop in area) this is not really optimal,
// but you probably have no choice
/proc/get_area_turfs(areatype, subtypes=TRUE, filter_by_z = 0, ignore_blocked = FALSE)
if(istext(areatype))
areatype = text2path(areatype)
else if(isarea(areatype))
Expand All @@ -697,25 +699,26 @@ Turf and target are seperate in case you want to teleport some distance from a t
var/list/turfs = list()
if(subtypes)
var/list/cache = typecacheof(areatype)
for(var/V in global.all_areas)
var/area/A = V
for(var/area/A as anything in global.all_areas)
if(!cache[A.type])
continue
for(var/turf/T in A)
if(black_list && (T.type in black_list))
if(filter_by_z && filter_by_z != T.z)
continue
if(ignore_blocked && is_blocked_turf(T))
continue
if(target_z == 0 || target_z == T.z)
turfs += T
turfs += T
else
for(var/V in global.all_areas)
var/area/A = V
for(var/area/A as anything in global.all_areas)
if(A.type != areatype)
continue
for(var/turf/T in A)
if(black_list && (T.type in black_list))
if(filter_by_z && filter_by_z != T.z)
continue
if(target_z == 0 || target_z == T.z)
turfs += T
if(ignore_blocked && is_blocked_turf(T))
continue
turfs += T

return turfs

//Takes: Area type as text string or as typepath OR an instance of the area.
Expand Down
1 change: 1 addition & 0 deletions code/_globalvars/lists/misc.dm
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ var/global/static/list/radial_question = list(
var/global/list/hex_by_color

// Use /hex2color(hex) for find color
// what palette are these colors from? why we need it?
var/global/static/list/color_by_hex = list(
"black" = "#000000",
"navy_blue" = "#000080",
Expand Down
57 changes: 57 additions & 0 deletions code/_onclick/hud/fullscreen.dm
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,63 @@
screen_loc = "WEST,SOUTH to EAST,NORTH"
icon_state = "druggy"

/atom/movable/screen/fullscreen/meta/darkness
icon = 'icons/hud/screen1_full.dmi'
screen_loc = "CENTER-7,CENTER-7"
icon_state = "white"
color = "#000000"
plane = LIGHTING_PLANE
blend_mode = BLEND_ADD

/atom/movable/screen/fullscreen/meta/environment_lighting_color
icon = 'icons/hud/screen1_full.dmi'
screen_loc = "CENTER-7,CENTER-7"
icon_state = "white"
plane = ENVIRONMENT_LIGHTING_PLANE
blend_mode = BLEND_MULTIPLY

var/obj/effect/level_color_holder/current_holder

// changes z-level color masks when moving between levels
/atom/movable/screen/fullscreen/meta/environment_lighting_color/proc/attach_to_level(new_z)
SIGNAL_HANDLER

if(!SSmapping.initialized)
return

var/datum/space_level/L = SSmapping.get_level(new_z)
var/obj/effect/level_color_holder/new_holder = L.color_holder

if(!current_holder)
end_transition(new_holder)
return

if(current_holder == new_holder)
return

var/obj/effect/level_color_holder/old_holder = current_holder
vis_contents.Cut()
current_holder = null

// same color - we don't need animation
if(old_holder.color == new_holder.color)
end_transition(new_holder)
return

// should be possible to do it with just animation and without callback, but it's already too complicated
// ...
// also this looks bad when there is already animation on the holder (aurora),
// maybe i should just remove it completely or do some opacity transaction between two holders
animate(src, time = 0, color = old_holder.color)
animate(time = 1 SECONDS, color = new_holder.color)
addtimer(CALLBACK(src, PROC_REF(end_transition), new_holder), 1 SECONDS)

/atom/movable/screen/fullscreen/meta/environment_lighting_color/proc/end_transition(obj/effect/level_color_holder/new_holder)
if(!current_holder)
color = null
vis_contents += new_holder
current_holder = new_holder

#undef FULLSCREEN_LAYER
#undef SCREEN_BLIND_LAYER
#undef SCREEN_DAMAGE_LAYER
Expand Down
Loading

0 comments on commit 4bc5e07

Please sign in to comment.