Skip to content

Commit

Permalink
orbit menu
Browse files Browse the repository at this point in the history
  • Loading branch information
harryob committed Sep 6, 2023
1 parent 9fe9cbc commit 76398af
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
10 changes: 1 addition & 9 deletions code/modules/mob/dead/observer/orbit.dm
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/datum/orbit_menu
var/auto_observe = FALSE
var/mob/dead/observer/owner

/datum/orbit_menu/New(mob/dead/observer/new_owner)
Expand All @@ -24,6 +23,7 @@
switch(action)
if("orbit")
var/ref = params["ref"]
var/auto_observe = params["auto_observe"]
var/atom/movable/poi = locate(ref) in GLOB.mob_list
if (poi == null)
poi = locate(ref) in GLOB.all_multi_vehicles
Expand All @@ -38,19 +38,11 @@
if("refresh")
update_static_data(owner)
. = TRUE
if("toggle_observe")
auto_observe = !auto_observe
if(auto_observe && owner.orbit_target)
owner.do_observe(owner.orbit_target)
else
owner.reset_perspective(null)
. = TRUE



/datum/orbit_menu/ui_data(mob/user)
var/list/data = list()
data["auto_observe"] = auto_observe
return data

/datum/orbit_menu/ui_static_data(mob/user)
Expand Down
24 changes: 22 additions & 2 deletions tgui/packages/tgui/interfaces/Orbit/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { filter, sortBy } from 'common/collections';
import { flow } from 'common/fp';
import { capitalizeFirst } from 'common/string';
import { capitalizeFirst, multiline } from 'common/string';
import { useBackend, useLocalState } from 'tgui/backend';
import { Box, Button, Collapsible, ColorBox, Icon, Input, LabeledList, Section, Stack } from 'tgui/components';
import { Window } from 'tgui/layouts';
Expand Down Expand Up @@ -36,11 +36,18 @@ const ObservableSearch = (props, context) => {
survivors = [],
xenos = [],
} = data;

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

/** Gets a list of Observables, then filters the most relevant to orbit */
const orbitMostRelevant = (searchQuery: string) => {
/** Returns the most orbited observable that matches the search. */
Expand All @@ -56,6 +63,7 @@ const ObservableSearch = (props, context) => {
if (mostRelevant !== undefined) {
act('orbit', {
ref: mostRelevant.ref,
auto_observe: autoObserve,
});
}
};
Expand All @@ -77,6 +85,16 @@ const ObservableSearch = (props, context) => {
/>
</Stack.Item>
<Stack.Divider />
<Stack.Item>
<Button
color={autoObserve ? 'good' : 'transparent'}
icon={autoObserve ? 'toggle-on' : 'toggle-off'}
onClick={() => setAutoObserve(!autoObserve)}
tooltip={multiline`Toggle Auto-Observe. When active, you'll
see the UI / full inventory of whoever you're orbiting. Neat!`}
tooltipPosition="bottom-start"
/>
</Stack.Item>
<Stack.Item>
<Button
color="transparent"
Expand Down Expand Up @@ -199,6 +217,8 @@ const ObservableItem = (
const { health, icon, full_name, nickname, orbiters, ref, background_color } =
item;

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

return (
<Button
color={'transparent'}
Expand All @@ -208,7 +228,7 @@ const ObservableItem = (
'border-width': '1px',
'color': color ? 'white' : 'grey',
}}
onClick={() => act('orbit', { ref: ref })}
onClick={() => act('orbit', { auto_observe: autoObserve, ref: ref })}
tooltip={!!health && <ObservableTooltip item={item} />}
tooltipPosition="bottom-start">
{!!health && (
Expand Down

0 comments on commit 76398af

Please sign in to comment.