Skip to content

Commit

Permalink
fixes orbit menu for 0 health and admins refreshing (#5032)
Browse files Browse the repository at this point in the history
closes #5031

🆑
fix: the health indicator in the tooltip and colorbox is still present
when a POI has 0 health
fix: admins can refresh the orbit menu without runtimes
/🆑
  • Loading branch information
harryob authored Nov 29, 2023
1 parent 5e3e04e commit ddc6c67
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion code/modules/mob/dead/observer/orbit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

var/is_admin = FALSE
if(user && user.client)
is_admin = check_other_rights(user.client, R_ADMIN, FALSE)
is_admin = check_client_rights(user.client, R_ADMIN, FALSE)
var/list/pois = getpois(skip_mindless = !is_admin, specify_dead_role = FALSE)
for(var/name in pois)
var/list/serialized = list()
Expand Down
4 changes: 3 additions & 1 deletion tgui/packages/tgui/interfaces/Orbit/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ export const getDisplayName = (full_name: string, nickname?: string) => {
};

/** Returns the display color for certain health percentages */
export const getHealthColor = (health: number) => {
export const getHealthColor = (health?: number) => {
if (!health) return 'bad';

switch (true) {
case health > HEALTH.Good:
return 'good';
Expand Down
14 changes: 9 additions & 5 deletions tgui/packages/tgui/interfaces/Orbit/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ const ObservableItem = (

const [autoObserve] = useLocalState<boolean>(context, 'autoObserve', false);

const displayHealth = typeof health === 'number';

return (
<Button
color={'transparent'}
Expand All @@ -225,9 +227,9 @@ const ObservableItem = (
'color': color ? 'white' : 'grey',
}}
onClick={() => act('orbit', { ref: ref })}
tooltip={!!health && <ObservableTooltip item={item} />}
tooltip={displayHealth && <ObservableTooltip item={item} />}
tooltipPosition="bottom-start">
{!!health && (
{displayHealth && (
<ColorBox
color={getHealthColor(health)}
style={{ 'margin-right': '0.5em' }}
Expand All @@ -250,7 +252,9 @@ const ObservableTooltip = (props: { item: Observable }) => {
const {
item: { caste, health, job, full_name, icon, background_color },
} = props;
const displayHealth = !!health && health >= 0 ? `${health}%` : 'Critical';

const displayHealth = typeof health === 'number';
const healthText = !!health && health >= 0 ? `${health}%` : 'Critical';

return (
<LabeledList>
Expand All @@ -273,8 +277,8 @@ const ObservableTooltip = (props: { item: Observable }) => {
{job}
</LabeledList.Item>
)}
{!!health && (
<LabeledList.Item label="Health">{displayHealth}</LabeledList.Item>
{displayHealth && (
<LabeledList.Item label="Health">{healthText}</LabeledList.Item>
)}
</LabeledList>
);
Expand Down

0 comments on commit ddc6c67

Please sign in to comment.