Skip to content

Commit

Permalink
[MIRROR] Fixes bug with high luminosity eyes, & fixes eyes being on t…
Browse files Browse the repository at this point in the history
…he wrong side of the head! [MDB IGNORE] (#716)

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

* Screenshot test

* Merge skew

---------

Co-authored-by: SkyratBot <[email protected]>
Co-authored-by: Bloop <[email protected]>
  • Loading branch information
3 people authored Nov 19, 2023
1 parent 06b0268 commit 18332b4
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 26 deletions.
44 changes: 23 additions & 21 deletions code/modules/surgery/organs/internal/eyes/_eyes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -427,13 +427,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)
. = ..()
Expand All @@ -453,9 +453,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)
. = ..()
Expand All @@ -464,7 +464,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)
Expand Down Expand Up @@ -493,10 +494,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
Expand All @@ -516,7 +517,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"]
Expand Down Expand Up @@ -547,9 +548,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()

/**
Expand Down Expand Up @@ -611,12 +613,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()

Expand Down Expand Up @@ -648,11 +650,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
Expand Down
1 change: 1 addition & 0 deletions code/modules/unit_tests/_unit_tests.dm
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,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"
Expand Down
64 changes: 64 additions & 0 deletions code/modules/unit_tests/screenshot_high_luminosity_eyes.dm
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified icons/mob/human/human_face.dmi
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

if(mob_held_item)

if(check_block(user, charge_damage = 0, name = "[user.name]"))
if(check_block(user, damage = 0, attack_text = "[user.name]"))
playsound(loc, 'sound/weapons/parry.ogg', 25, TRUE, -1) //Audio feedback to the fact you just got blocked
apply_damage(disarm_damage / 2, STAMINA)
visible_message(span_danger("[user] attempts to touch [src]!"), \
Expand Down
8 changes: 4 additions & 4 deletions tgui/packages/tgui/interfaces/HighLuminosityEyesMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 && (
Expand All @@ -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}
Expand Down Expand Up @@ -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}
Expand Down

0 comments on commit 18332b4

Please sign in to comment.