Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes orbit menu for 0 health and admins refreshing #5032

Merged
merged 2 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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