Skip to content

Commit

Permalink
Nametags (#448)
Browse files Browse the repository at this point in the history
## Pull Request Hakkında
Ports Name Tags :
Monkestation/Monkestation2.0#1883

Oyunda ctrl basınca diğer canlıların isimlerini görebilmemizi sağlar,
görebilme alanı karakterimizden bikaç tile yarıçapında bir büyüklükte
![Ekran görüntüsü 2025-02-14
043926](https://github.com/user-attachments/assets/eb2d5cfe-8a3a-4ea7-8833-feaa86e413cb)
## Oyun İçin Neden Gerekli

Oyundaki karakterimiz karşısındaki kişilerin adlarını biliyor ama bizim
mouseyi üstüne götürmemiz lazım, ctrl basıp direkt görebilmemiz bence
daha hoş olucaktır.
## Changelog
:cl: Rengan
add: Basınca etrafımızdaki canlıların isimlerini görebilmemizi sağlayan
bir keybind eklendi, Varsayılan tuş: Ctrl
/:cl:
  • Loading branch information
Seefaaa authored Feb 22, 2025
2 parents 12b69ab + 6a355b3 commit 1b510cc
Show file tree
Hide file tree
Showing 39 changed files with 197 additions and 5 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/keybinding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
#define COMSIG_KB_MOB_TARGETBODYGROIN_DOWN "keybinding_mob_targetbodygroin_down"
#define COMSIG_KB_MOB_TARGETLEFTLEG_DOWN "keybinding_mob_targetleftleg_down"
#define COMSIG_KB_MOB_BLOCKMOVEMENT_DOWN "keybinding_mob_blockmovement_down"
#define COMSIG_KB_MOB_SHOW_NAME_TAGS_DOWN "keybinding_mob_show_name_tags_down"

//Robot
#define COMSIG_KB_SILICON_TOGGLEMODULEONE_DOWN "keybinding_silicon_togglemoduleone_down"
Expand Down
6 changes: 5 additions & 1 deletion code/__DEFINES/layers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
//KEEP THESE IN A NICE ACSCENDING ORDER, PLEASE

//NEVER HAVE ANYTHING BELOW THIS PLANE ADJUST IF YOU NEED MORE SPACE
#define LOWEST_EVER_PLANE -50
#define LOWEST_EVER_PLANE -55

#define PLANE_NAME_TAGS_BLOCKER -50
#define NAME_TAG_RENDER_TARGET "*NAME_TAG_RENDER_TARGET"

// Doesn't really layer, just throwing this in here cause it's the best place imo
#define FIELD_OF_VISION_BLOCKER_PLANE -45
Expand Down Expand Up @@ -37,6 +40,7 @@
#define MASSIVE_OBJ_PLANE 3
#define GHOST_PLANE 4
#define POINT_PLANE 5
#define PLANE_NAME_TAGS 6

//---------- LIGHTING -------------
///Normal 1 per turf dynamic lighting underlays
Expand Down
6 changes: 6 additions & 0 deletions code/_onclick/hud/name_shadow.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/atom/movable/screen/name_shadow
icon = 'icons/psychonaut/effects/covers.dmi'
icon_state = "alpha-blocker"
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
plane = PLANE_NAME_TAGS_BLOCKER
screen_loc = "BOTTOM,LEFT"
23 changes: 23 additions & 0 deletions code/_onclick/hud/rendering/plane_masters/plane_master_subtypes.dm
Original file line number Diff line number Diff line change
Expand Up @@ -446,3 +446,26 @@
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
render_relay_planes = list(RENDER_PLANE_MASTER)
offsetting_flags = BLOCKS_PLANE_OFFSETTING|OFFSET_RELAYS_MATCH_HIGHEST

/atom/movable/screen/plane_master/name_tags
name = "name tag plane"
plane = PLANE_NAME_TAGS
appearance_flags = PLANE_MASTER|NO_CLIENT_COLOR
blend_mode_override = BLEND_ADD
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
critical = PLANE_CRITICAL_DISPLAY
render_relay_planes = list(RENDER_PLANE_GAME_WORLD)
alpha = 0

/atom/movable/screen/plane_master/name_tags/Initialize(mapload)
. = ..()
add_filter("vision_cone", 1, alpha_mask_filter(render_source = OFFSET_RENDER_TARGET(NAME_TAG_RENDER_TARGET, offset), flags = MASK_INVERSE))

/atom/movable/screen/plane_master/name_tag_blocker
name = "name tag blocker blocker"
documentation = "This is one of those planes that's only used as a filter. It masks out things that want to be hidden by fov.\
<br>Literally just contains FOV images, or masks."
plane = PLANE_NAME_TAGS_BLOCKER
render_target = NAME_TAG_RENDER_TARGET
render_relay_planes = list()
multiz_scaled = FALSE
2 changes: 2 additions & 0 deletions code/datums/actions/mobs/assume_form.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
// important: do this at the very end because we might have SIGNAL_ADDTRAIT for this on the mob that's dependent on the above logic
SEND_SIGNAL(owner, COMSIG_ACTION_DISGUISED_APPEARANCE, target_atom)
ADD_TRAIT(owner, TRAIT_DISGUISED, ACTION_TRAIT)
owner.update_name_tag()

/// Resets the appearances of the mob to the default.
/datum/action/cooldown/mob_cooldown/assume_form/proc/reset_appearances()
Expand All @@ -80,6 +81,7 @@
owner.desc = initial(owner.desc)

owner.name = initial(owner.name)
owner.update_name_tag()
owner.icon = initial(owner.icon)
owner.icon_state = initial(owner.icon_state)
owner.cut_overlays()
Expand Down
1 change: 1 addition & 0 deletions code/datums/components/phylactery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@
// Fix their name
lich.dna.real_name = lich_mind.name
lich.real_name = lich_mind.name
lich.update_name_tag()
// Slap the lich mind in and get their ghost
lich_mind.transfer_to(lich)
lich_mind.grab_ghost(force = TRUE)
Expand Down
8 changes: 8 additions & 0 deletions code/datums/components/tactical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@
RegisterSignal(user, COMSIG_HUMAN_GET_FORCED_NAME, PROC_REF(on_name_inquiry))
ADD_TRAIT(user, TRAIT_UNKNOWN, REF(src))

var/obj/effect/abstract/name_tag/name_tag = user.name_tag
name_tag.hiding_references |= REF(src)
name_tag.hide()

current_slot = slot

on_icon_update(source)
Expand Down Expand Up @@ -107,6 +111,10 @@
user.remove_alt_appearance("sneaking_mission[REF(src)]")
REMOVE_TRAIT(user, TRAIT_UNKNOWN, REF(src))

var/obj/effect/abstract/name_tag/name_tag = user.name_tag
name_tag.hiding_references -= REF(src)
name_tag.show()

///Checks if a mob is holding us, and if so we will modify our appearance to properly match w/ the mob.
/datum/component/tactical/proc/tactical_update(obj/item/source)
SIGNAL_HANDLER
Expand Down
1 change: 1 addition & 0 deletions code/datums/dna.dm
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,7 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block())
gender = NEUTER
else
gender = PLURAL
update_name_tag()

/mob/living/carbon/human/updateappearance(icon_update = TRUE, mutcolor_update = FALSE, mutations_overlay_update = FALSE)
..()
Expand Down
2 changes: 2 additions & 0 deletions code/datums/keybinding/_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@
#define WEIGHT_EMOTE 70
#define WEIGHT_AI 80
#define WEIGHT_LOWEST 999

#define NAME_TAG_WIDTH (world.icon_size * 5)
1 change: 1 addition & 0 deletions code/datums/keybinding/_keybindings.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var/category = CATEGORY_MISC
var/weight = WEIGHT_LOWEST
var/keybind_signal
var/can_reuse_keybind = FALSE

/datum/keybinding/New()
if(!keybind_signal)
Expand Down
28 changes: 28 additions & 0 deletions code/datums/keybinding/mob.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,31 @@
full_name = "View Pet Commands"
description = "Hold down to see all the commands you can give your pets!"
keybind_signal = COMSIG_KB_LIVING_VIEW_PET_COMMANDS
can_reuse_keybind = TRUE

/datum/keybinding/mob/show_names
hotkey_keys = list("Shift")
name = "show_name_tags"
full_name = "Show name tags"
description = "Lets you see people's names below their body."
keybind_signal = COMSIG_KB_MOB_SHOW_NAME_TAGS_DOWN
can_reuse_keybind = TRUE

/datum/keybinding/mob/show_names/down(client/user)
. = ..()
if(.)
return
if(COOLDOWN_FINISHED(user, update_nametag_cooldown))
for(var/mob/living/living in view(user.view, user.mob))
living.update_name_tag()
COOLDOWN_START(user, update_nametag_cooldown, 1 SECONDS)

for(var/atom/movable/screen/plane_master/name_tags/name_tag as anything in user.mob?.hud_used.get_true_plane_masters(PLANE_NAME_TAGS))
name_tag.alpha = 255

/datum/keybinding/mob/show_names/up(client/user)
. = ..()
if(.)
return
for(var/atom/movable/screen/plane_master/name_tags/name_tag as anything in user.mob?.hud_used.get_true_plane_masters(PLANE_NAME_TAGS))
name_tag.alpha = 0
1 change: 1 addition & 0 deletions code/datums/status_effects/debuffs/dna_transformation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
new_dna.transfer_identity(transforming)
transforming.real_name = new_dna.real_name
transforming.name = transforming.get_visible_name()
transforming.update_name_tag()
transforming.updateappearance(mutcolor_update = TRUE)
transforming.domutcheck()
return TRUE
Expand Down
49 changes: 49 additions & 0 deletions code/game/objects/effects/name_tag.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/obj/effect/abstract/name_tag
name = ""
icon = null
alpha = 180
plane = PLANE_NAME_TAGS
mouse_opacity = MOUSE_OPACITY_TRANSPARENT
maptext_y = -13 //directly below characters
appearance_flags = PIXEL_SCALE | RESET_COLOR | RESET_TRANSFORM
var/list/hiding_references = list()

/obj/effect/abstract/name_tag/Initialize(mapload)
. = ..()
if(!ismovable(loc) || QDELING(loc))
return INITIALIZE_HINT_QDEL
var/atom/movable/movable_loc = loc
movable_loc.vis_contents += src
var/bound_width = movable_loc.bound_width || world.icon_size
maptext_width = NAME_TAG_WIDTH
maptext_height = world.icon_size * 1.5
maptext_x = ((NAME_TAG_WIDTH - bound_width) * -0.5) - loc.base_pixel_x
maptext_y = src::maptext_y - loc.base_pixel_y
RegisterSignal(movable_loc, COMSIG_MOVABLE_Z_CHANGED, PROC_REF(update_z))

/obj/effect/abstract/name_tag/Destroy(force)
if(QDELETED(loc))
return ..()
if(ismovable(loc))
var/atom/movable/movable_loc = loc
movable_loc.vis_contents -= src
UnregisterSignal(loc, COMSIG_MOVABLE_Z_CHANGED)
return ..()

/obj/effect/abstract/name_tag/forceMove(atom/destination, no_tp = FALSE, harderforce = FALSE)
if(harderforce)
return ..()

/obj/effect/abstract/name_tag/proc/hide(force = FALSE)
if(hiding_references.len || force)
alpha = 0

/obj/effect/abstract/name_tag/proc/show(force = FALSE)
if(!hiding_references.len || force)
alpha = 255

/obj/effect/abstract/name_tag/proc/set_name(incoming_name)
maptext = MAPTEXT_GRAND9K("<span style='text-align: center'>[incoming_name]</span>")

/obj/effect/abstract/name_tag/proc/update_z(datum/source, turf/old_turf, turf/new_turf, same_z_layer)
SET_PLANE(src, PLANE_TO_TRUE(src.plane), new_turf)
1 change: 1 addition & 0 deletions code/modules/antagonists/_common/antag_spawner.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
borg.mmi.brainmob.real_name = brainopsname
borg.mmi.brainmob.name = brainopsname
borg.real_name = borg.name
borg.update_name_tag()

borg.key = C.key

Expand Down
1 change: 1 addition & 0 deletions code/modules/antagonists/blob/overmind.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ GLOBAL_LIST_EMPTY(blob_nodes)
var/new_name = "[initial(name)] ([rand(1, 999)])"
name = new_name
real_name = new_name
update_name_tag()
last_attack = world.time
var/datum/blobstrain/BS = pick(GLOB.valid_blobstrains)
set_strain(BS)
Expand Down
3 changes: 3 additions & 0 deletions code/modules/client/client_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -275,3 +275,6 @@

/// Discord information of the client if they have linked their account and we fetched it
var/list/discord

/// The last name tag update runned by our client
COOLDOWN_DECLARE(update_nametag_cooldown)
4 changes: 2 additions & 2 deletions code/modules/client/preferences_savefile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ SAVEFILE UPDATING/VERSIONING - 'Simplified', or rather, more coder-friendly ~Car
for(var/hotkeytobind in kb.hotkey_keys)
if(hotkeytobind == "Unbound")
addedbind = TRUE
else if(!length(binds_by_key[hotkeytobind])) //Only bind to the key if nothing else is bound
else if(!length(binds_by_key[hotkeytobind]) || kb.can_reuse_keybind) //Only bind to the key if nothing else is bound
key_bindings[kb.name] |= hotkeytobind
addedbind = TRUE
else
for(var/classickeytobind in kb.classic_keys)
if(classickeytobind == "Unbound")
addedbind = TRUE
else if(!length(binds_by_key[classickeytobind])) //Only bind to the key if nothing else is bound
else if(!length(binds_by_key[classickeytobind]) || kb.can_reuse_keybind) //Only bind to the key if nothing else is bound
key_bindings[kb.name] |= classickeytobind
addedbind = TRUE

Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/basic/guardian/guardian_fluff.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
/datum/guardian_fluff/proc/apply(mob/living/basic/guardian/guardian)
guardian.name = name
guardian.real_name = name
guardian.update_name_tag()
guardian.bubble_icon = bubble_icon
guardian.icon_living = icon_state
guardian.icon_state = icon_state
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/basic/slime/slime.dm
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@
var/slime_id = rand(1, 1000)
name = "[slime_type.colour] [life_stage] slime ([slime_id])"
real_name = name
update_name_tag()
return ..()

/mob/living/basic/slime/regenerate_icons()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/alien/alien.dm
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Des: Removes all infected images from the alien.
if(!alien_name_regex.Find(old_name)) // check to make sure there's no admins doing funny stuff with naming these aliens
name = old_name
real_name = old_real_name
update_name_tag()
return

if(!unique_name)
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/human/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

//Update our name based on whether our face is obscured/disfigured
name = get_visible_name()
update_name_tag()

if(stat != DEAD)
return TRUE
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/carbon/life.dm
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@
if(dna.previous["name"])
real_name = dna.previous["name"]
name = real_name
update_name_tag()
dna.previous.Remove("name")
if(dna.previous["UE"])
dna.unique_enzymes = dna.previous["UE"]
Expand Down
7 changes: 6 additions & 1 deletion code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1774,6 +1774,7 @@
SEND_SIGNAL(src, COMSIG_LIVING_ON_WABBAJACKED, new_mob)
new_mob.name = real_name
new_mob.real_name = real_name
new_mob.update_name_tag()

// Transfer mind to the new mob (also handles actions and observers and stuff)
if(mind)
Expand Down Expand Up @@ -2028,6 +2029,7 @@ GLOBAL_LIST_EMPTY(fire_appearances)
identifier = rand(1, 999)
name = "[name] ([identifier])"
real_name = name
update_name_tag()

/mob/living/proc/mob_try_pickup(mob/living/user, instant=FALSE)
if(!ishuman(user))
Expand Down Expand Up @@ -2119,7 +2121,10 @@ GLOBAL_LIST_EMPTY(fire_appearances)
updatehealth()
if(NAMEOF(src, lighting_cutoff))
sync_lighting_plane_cutoff()

if(NAMEOF(src, name))
update_name_tag()
if(NAMEOF(src, real_name))
update_name_tag()

/mob/living/vv_get_header()
. = ..()
Expand Down
1 change: 1 addition & 0 deletions code/modules/mob/living/silicon/ai/freelook/eye.dm
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@
all_eyes += eyeobj
eyeobj.ai = src
eyeobj.name = "[name] (AI Eye)"
eyeobj.update_name_tag()
eyeobj.setLoc(loc, TRUE)
eyeobj.RegisterSignal(src, COMSIG_CLICK_SHIFT, TYPE_PROC_REF(/mob/eye/camera/ai, examinate_check))
set_eyeobj_visible(TRUE)
Expand Down
2 changes: 2 additions & 0 deletions code/modules/mob/living/silicon/robot/robot.dm
Original file line number Diff line number Diff line change
Expand Up @@ -862,6 +862,7 @@
braintype = "AI Shell"
name = "Empty AI Shell-[identifier]"
real_name = name
update_name_tag()
GLOB.available_ai_shells |= src
if(!QDELETED(builtInCamera))
builtInCamera.c_tag = real_name //update the camera name too
Expand All @@ -881,6 +882,7 @@
GLOB.available_ai_shells -= src
name = "Unformatted Cyborg-[identifier]"
real_name = name
update_name_tag()
if(!QDELETED(builtInCamera))
builtInCamera.c_tag = real_name
diag_hud_set_aishell()
Expand Down
6 changes: 6 additions & 0 deletions code/modules/mob/login.dm
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@

SEND_GLOBAL_SIGNAL(COMSIG_GLOB_MOB_LOGGED_IN, src)

if(client && isliving(src) && (!iscyborg(src) && !isAI(src)))
name_tag_shadow = new(src)
SET_PLANE_EXPLICIT(name_tag_shadow, PLANE_NAME_TAGS_BLOCKER, src)
client.screen += name_tag_shadow
hud_used.always_visible_inventory += name_tag_shadow

return TRUE


Expand Down
7 changes: 7 additions & 0 deletions code/modules/mob/logout.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@
SStgui.on_logout(src)
remove_from_player_list()
update_ambience_area(null) // Unset ambience vars so it plays again on login

if(client && isliving(src) && (!iscyborg(src) && !isaicamera(src) && !isAI(src)))
client.screen -= name_tag_shadow
name_tag_shadow.UnregisterSignal(src, COMSIG_MOVABLE_Z_CHANGED)
hud_used?.always_visible_inventory -= name_tag_shadow
QDEL_NULL(name_tag_shadow)

..()

if(loc)
Expand Down
Loading

0 comments on commit 1b510cc

Please sign in to comment.