Skip to content

Commit

Permalink
Update examine panel a bit (#625)
Browse files Browse the repository at this point in the history
## About The Pull Request
fixes #494
  • Loading branch information
larentoun authored Oct 26, 2024
1 parent f488e58 commit 8cceefd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 28 deletions.
34 changes: 17 additions & 17 deletions modular_bandastation/examine_panel/code/examine_panel_component.dm
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
/datum/component/examine_panel
dupe_mode = COMPONENT_DUPE_UNIQUE
/// Mob that the examine panel belongs to.
var/mob/living/holder
/// The screen containing the appearance of the mob
var/atom/movable/screen/map_view/examine_panel_screen/examine_panel_screen
/// Flavor text
var/flavor_text

/datum/component/examine_panel/Initialize(use_prefs = FALSE)
. = ..()
if(!isliving(parent))
/datum/component/examine_panel/Initialize(flavor_override)
if(!iscarbon(parent) && !issilicon(parent))
return COMPONENT_INCOMPATIBLE
holder = parent
if(!use_prefs)
if(flavor_override)
flavor_text = flavor_override
return
if(iscarbon(parent))
flavor_text = holder.client?.prefs.read_preference(/datum/preference/text/flavor_text)
var/mob/living/carbon/carbon = parent
flavor_text = carbon.dna.features["flavor_text"]
return
if(issilicon(parent))
flavor_text = holder.client?.prefs.read_preference(/datum/preference/text/silicon_flavor_text)
var/mob/living/silicon/silicon = parent
flavor_text = silicon.flavor_text

/datum/component/examine_panel/RegisterWithParent()
RegisterSignal(parent, COMSIG_ATOM_EXAMINE, PROC_REF(on_examine))
Expand All @@ -30,6 +29,7 @@

if(iscarbon(source))
examine_list += get_carbon_flavor_text(source)
return
if(issilicon(source))
examine_list += get_silicon_flavor_text(source)

Expand All @@ -41,9 +41,9 @@
var/face_obscured = (source.wear_mask && (source.wear_mask.flags_inv & HIDEFACE)) || (source.head && (source.head.flags_inv & HIDEFACE))

if (!(face_obscured))
flavor_text_link = span_notice("[preview_text]... <a href='?src=[REF(src)];lookup_info=open_examine_panel'>Look closer?</a>")
flavor_text_link = span_notice("[preview_text]... <a href='?src=[REF(src)];lookup_info=open_examine_panel'>Раскрыть описание</a>")
else
flavor_text_link = span_notice("<a href='?src=[REF(src)];lookup_info=open_examine_panel'>Examine closely...</a>")
flavor_text_link = span_notice("<a href='?src=[REF(src)];lookup_info=open_examine_panel'>Раскрыть описание</a>")
if (flavor_text_link)
return flavor_text_link

Expand All @@ -52,7 +52,7 @@
/// The first 1-FLAVOR_PREVIEW_LIMIT characters in the mob's client's silicon_flavor_text preference datum. FLAVOR_PREVIEW_LIMIT is defined in flavor_defines.dm.
var/preview_text = copytext_char(flavor_text, 1, FLAVOR_PREVIEW_LIMIT)

flavor_text_link = span_notice("[preview_text]... <a href='?src=[REF(src)];lookup_info=open_examine_panel'>Look closer?</a>")
flavor_text_link = span_notice("[preview_text]... <a href='?src=[REF(src)];lookup_info=open_examine_panel'>Раскрыть описание</a>")

if (flavor_text_link)
return flavor_text_link
Expand All @@ -78,11 +78,11 @@
if(!examine_panel_screen)
examine_panel_screen = new
examine_panel_screen.name = "screen"
examine_panel_screen.assigned_map = "examine_panel_[REF(holder)]_map"
examine_panel_screen.assigned_map = "examine_panel_[REF(parent)]_map"
examine_panel_screen.del_on_map_removal = FALSE
examine_panel_screen.screen_loc = "[examine_panel_screen.assigned_map]:1,1"

var/mutable_appearance/current_mob_appearance = new(holder)
var/mutable_appearance/current_mob_appearance = new(parent)
current_mob_appearance.setDir(SOUTH)
current_mob_appearance.transform = matrix() // We reset their rotation, in case they're lying down.

Expand Down Expand Up @@ -110,9 +110,9 @@
if(ishuman(parent))
var/mob/living/carbon/human/holder_human = parent
obscured = (holder_human.wear_mask && (holder_human.wear_mask.flags_inv & HIDEFACE)) || (holder_human.head && (holder_human.head.flags_inv & HIDEFACE))
tgui_flavor_text = obscured ? "Obscured" : flavor_text
tgui_flavor_text = obscured ? "Скрывает лицо" : flavor_text

var/name = obscured ? "Unknown" : holder
var/name = obscured ? "Неизвестный" : parent

data["obscured"] = obscured ? TRUE : FALSE
data["character_name"] = name
Expand Down
35 changes: 27 additions & 8 deletions modular_bandastation/examine_panel/code/examine_panel_mob.dm
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
// TODO: Don't use prefs when spawned via admins
/mob/living/carbon/human/Login()
. = ..()
AddComponent(/datum/component/examine_panel, use_prefs = TRUE)
AddComponent(/datum/component/examine_panel)

/datum/dna/transfer_identity(mob/living/carbon/destination, transfer_SE, transfer_species)
if(!istype(destination))
return
. = ..()
destination.AddComponent(/datum/component/examine_panel)

/mob/living/silicon
var/flavor_text

/mob/living/silicon/Login()
. = ..()
AddComponent(/datum/component/examine_panel, use_prefs = TRUE)
if(!flavor_text)
flavor_text = client?.prefs.read_preference(/datum/preference/text/silicon_flavor_text)
AddComponent(/datum/component/examine_panel)

/mob/living/verb/change_flavor_text()
set name = "Change flavor text"
set name = "Изменить описание"
set category = "IC"

var/datum/component/examine_panel/examine_panel = GetComponent(/datum/component/examine_panel)
if(!examine_panel)
examine_panel = AddComponent(/datum/component/examine_panel)
var/new_flavor_text = tgui_input_text(usr, "Enter new flavor text", "Changing Flavor Text", examine_panel.flavor_text)
var/new_flavor_text = tgui_input_text(usr, "Введите новое описание", "Изменение описания")
if(new_flavor_text)
examine_panel.flavor_text = new_flavor_text
DEFAULT_QUEUE_OR_CALL_VERB(VERB_CALLBACK(src, PROC_REF(save_new_flavor_text), new_flavor_text))

/mob/living/proc/save_new_flavor_text(new_flavor_text)
return

/mob/living/carbon/save_new_flavor_text(new_flavor_text)
dna.features["flavor_text"] = new_flavor_text
AddComponent(/datum/component/examine_panel)

/mob/living/silicon/save_new_flavor_text(new_flavor_text)
flavor_text = new_flavor_text
AddComponent(/datum/component/examine_panel)
6 changes: 3 additions & 3 deletions tgui/packages/tgui/interfaces/ExaminePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export const ExaminePanel = (props) => {
const { act, data } = useBackend<Data>();
const { character_name, obscured, assigned_map, flavor_text } = data;
return (
<Window title="Examine Panel" width={900} height={670} theme="admin">
<Window title="Подробное описание" width={900} height={670} theme="admin">
<Window.Content>
<Stack fill>
<Stack.Item width="30%">
<Section fill title="Character Preview">
<Section fill title="Превью персонажа">
{!obscured && (
<CharacterPreview id={assigned_map} height="100%" />
)}
Expand All @@ -31,7 +31,7 @@ export const ExaminePanel = (props) => {
<Section
scrollable
fill
title={character_name + "'s Flavor Text:"}
title={character_name + ', описание:'}
preserveWhitespace
>
{flavor_text}
Expand Down

0 comments on commit 8cceefd

Please sign in to comment.