Fixes bug with high luminosity eyes, & fixes eyes being on the wrong side of the head! (#79760)

This commit is contained in:
Bloop
2023-11-18 19:17:00 -08:00
committed by GitHub
parent 6a911914c1
commit 3f63a7133f
7 changed files with 92 additions and 25 deletions
@@ -401,13 +401,13 @@
/// base icon state for eye overlays
var/base_eye_state = "eyes_glow_gs"
/// Whether or not to match the eye color to the light or use a custom selection
var/eye_color_mode = MATCH_LIGHT_COLOR
var/eye_color_mode = USE_CUSTOM_COLOR
/// The selected color for the light beam itself
var/current_color_string = "#ffffff"
var/light_color_string = "#ffffff"
/// The custom selected eye color for the left eye. Defaults to the mob's natural eye color
var/current_left_color_string
var/left_eye_color_string
/// The custom selected eye color for the right eye. Defaults to the mob's natural eye color
var/current_right_color_string
var/right_eye_color_string
/obj/item/organ/internal/eyes/robotic/glow/Initialize(mapload)
. = ..()
@@ -427,9 +427,9 @@
/// Set the initial color of the eyes on insert to be the mob's previous eye color.
/obj/item/organ/internal/eyes/robotic/glow/Insert(mob/living/carbon/eye_recipient, special = FALSE, drop_if_replaced = FALSE)
. = ..()
current_color_string = old_eye_color_left
current_left_color_string = old_eye_color_left
current_right_color_string = old_eye_color_right
left_eye_color_string = old_eye_color_left
right_eye_color_string = old_eye_color_right
update_mob_eye_color(eye_recipient)
/obj/item/organ/internal/eyes/robotic/glow/on_insert(mob/living/carbon/eye_recipient)
. = ..()
@@ -438,7 +438,8 @@
/obj/item/organ/internal/eyes/robotic/glow/on_remove(mob/living/carbon/eye_owner)
deactivate(eye_owner, close_ui = TRUE)
eye.forceMove(src)
if(!QDELETED(eye))
eye.forceMove(src)
return ..()
/obj/item/organ/internal/eyes/robotic/glow/ui_state(mob/user)
@@ -467,10 +468,10 @@
data["eyeColor"] = list(
mode = eye_color_mode,
hasOwner = owner ? TRUE : FALSE,
left = current_left_color_string,
right = current_right_color_string,
left = left_eye_color_string,
right = right_eye_color_string,
)
data["lightColor"] = current_color_string
data["lightColor"] = light_color_string
data["range"] = eye.light_range
return data
@@ -490,7 +491,7 @@
usr,
"Choose eye color color:",
"High Luminosity Eyes Menu",
current_color_string
light_color_string
) as color|null
if(new_color)
var/to_update = params["to_update"]
@@ -521,9 +522,10 @@
* Turns on the attached flashlight object, updates the mob overlay to be added.
*/
/obj/item/organ/internal/eyes/robotic/glow/proc/activate()
eye.light_on = TRUE
if(eye.light_range) // at range 0 we are just going to make the eyes glow emissively, no light overlay
if(eye.light_range)
eye.set_light_on(TRUE)
else
eye.light_on = TRUE // at range 0 we are just going to make the eyes glow emissively, no light overlay
update_mob_eye_color()
/**
@@ -585,12 +587,12 @@
newcolor_string = newcolor
switch(to_update)
if(UPDATE_LIGHT)
current_color_string = newcolor_string
light_color_string = newcolor_string
eye.set_light_color(newcolor_string)
if(UPDATE_EYES_LEFT)
current_left_color_string = newcolor_string
left_eye_color_string = newcolor_string
if(UPDATE_EYES_RIGHT)
current_right_color_string = newcolor_string
right_eye_color_string = newcolor_string
update_mob_eye_color()
@@ -622,11 +624,11 @@
/obj/item/organ/internal/eyes/robotic/glow/proc/update_mob_eye_color(mob/living/carbon/eye_owner = owner)
switch(eye_color_mode)
if(MATCH_LIGHT_COLOR)
eye_color_left = current_color_string
eye_color_right = current_color_string
eye_color_left = light_color_string
eye_color_right = light_color_string
if(USE_CUSTOM_COLOR)
eye_color_left = current_left_color_string
eye_color_right = current_right_color_string
eye_color_left = left_eye_color_string
eye_color_right = right_eye_color_string
if(QDELETED(eye_owner) || !ishuman(eye_owner)) //Other carbon mobs don't have eye color.
return
+1
View File
@@ -223,6 +223,7 @@
#include "screenshot_antag_icons.dm"
#include "screenshot_basic.dm"
#include "screenshot_dynamic_human_icons.dm"
#include "screenshot_high_luminosity_eyes.dm"
#include "screenshot_humanoids.dm"
#include "screenshot_husk.dm"
#include "screenshot_saturnx.dm"
@@ -0,0 +1,64 @@
#define UPDATE_EYES_LEFT 1
#define UPDATE_EYES_RIGHT 2
/// Tests to make sure no punks have broken high luminosity eyes
/datum/unit_test/screenshot_high_luminosity_eyes
var/mob/living/carbon/human/test_subject
var/obj/item/organ/internal/eyes/robotic/glow/test_eyes
/datum/unit_test/screenshot_high_luminosity_eyes/Run()
// Create a mob with red and blue eyes. This is to test that high luminosity eyes properly default to the old eye color.
test_subject = allocate(/mob/living/carbon/human/consistent)
test_subject.equipOutfit(/datum/outfit/job/assistant/consistent)
test_subject.eye_color_left = COLOR_RED
test_subject.eye_color_right = COLOR_BLUE
// Create our eyes, and insert them into the mob
test_eyes = allocate(/obj/item/organ/internal/eyes/robotic/glow)
test_eyes.Insert(test_subject)
// This should be 4, but just in case it ever changes in the future
var/default_light_range = test_eyes.eye.light_range
// Test the normal light on appearance
test_eyes.toggle_active()
var/icon/flat_icon = create_icon()
test_screenshot("light_on", flat_icon)
// Change the eye color to pink and green
test_eyes.set_beam_color(COLOR_SCIENCE_PINK, to_update = UPDATE_EYES_LEFT)
test_eyes.set_beam_color(COLOR_SLIME_GREEN, to_update = UPDATE_EYES_RIGHT)
// Make sure the light overlay goes away (but not the emissive overlays) when we go to light range 0 while still turned on
test_eyes.set_beam_range(0)
TEST_ASSERT_EQUAL(test_eyes.eye.light_on, TRUE, "[src]'s 'eye.light_on' is FALSE after setting range to 0 while on. 'eye.light_on' should = TRUE!")
flat_icon = create_icon()
test_screenshot("light_emissive", flat_icon)
// turn it on and off again, it should look the same afterwards
test_eyes.toggle_active()
TEST_ASSERT_EQUAL(test_eyes.eye.light_on, FALSE, "[src]'s 'eye.light_on' is TRUE after being toggled off at range 0. 'eye.light_on' should = FALSE!")
test_eyes.toggle_active()
TEST_ASSERT_EQUAL(test_eyes.eye.light_on, TRUE, "[src]'s 'eye.light_on' is FALSE after being toggled on at range 0. 'eye.light_on' should = TRUE!")
flat_icon = create_icon()
test_screenshot("light_emissive", flat_icon)
// Make sure the light comes back on when we go from range 0 to 1
// Change left/right eye color back to red/blue. It should match the original screenshot
test_eyes.set_beam_range(default_light_range)
test_eyes.set_beam_color(COLOR_RED, to_update = UPDATE_EYES_LEFT)
test_eyes.set_beam_color(COLOR_BLUE, to_update = UPDATE_EYES_RIGHT)
flat_icon = create_icon()
test_screenshot("light_on", flat_icon)
/// Create the mob icon with light cone underlay
/datum/unit_test/screenshot_high_luminosity_eyes/proc/create_icon()
var/icon/final_icon = get_flat_icon_for_all_directions(test_subject, no_anim = FALSE)
for(var/mutable_appearance/light_underlay as anything in test_subject.underlays)
if(light_underlay.icon == 'icons/effects/light_overlays/light_cone.dmi')
// The light cone icon is 96x96, so we have to shift it over to have it match our sprites. x = 1, y = 1 is the lower left corner so we shift 32 pixels opposite to that.
final_icon.Blend(get_flat_icon_for_all_directions(light_underlay, no_anim = FALSE), ICON_UNDERLAY, -world.icon_size + 1, -world.icon_size + 1)
return final_icon
#undef UPDATE_EYES_LEFT
#undef UPDATE_EYES_RIGHT
Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 103 KiB

After

Width:  |  Height:  |  Size: 103 KiB

@@ -91,11 +91,11 @@ const EyeColorDisplay = (props, context) => {
const { eyeColor } = data;
return (
<>
<LabeledList.Item label="Match Colors">
<LabeledList.Item label="Match Color">
<Button.Checkbox
checked={eyeColor.mode}
onClick={() => act('toggle_eye_color')}
tooltip="Toggle the eye color mode."
tooltip="Toggles whether eyecolor matches the color of the light."
/>
</LabeledList.Item>
{!eyeColor.mode && (
@@ -112,7 +112,7 @@ const EyeColorDisplay = (props, context) => {
onClick={() =>
act('random_color', { to_update: ToUpdate.LeftEye })
}
tooltip="Randomizes the light color."
tooltip="Randomizes the eye color."
/>
<Input
value={eyeColor.left}
@@ -140,7 +140,7 @@ const EyeColorDisplay = (props, context) => {
onClick={() =>
act('random_color', { to_update: ToUpdate.RightEye })
}
tooltip="Randomizes the light color."
tooltip="Randomizes the eye color."
/>
<Input
value={eyeColor.right}