mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 10:43:20 +00:00
[MIRROR] ByondUI Overmap Navigation (#9267)
Co-authored-by: ShadowLarkens <shadowlarkens@gmail.com> Co-authored-by: Kashargul <144968721+Kashargul@users.noreply.github.com> Co-authored-by: CHOMPStation2 <chompsation2@gmail.com>
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
|
||||
// random cooldowns
|
||||
#define COOLDOWN_VENOM_MILKING "venom_milking"
|
||||
#define COOLDOWN_SHIP_REFRESH "ship_refresh"
|
||||
|
||||
// admin verb cooldowns
|
||||
#define COOLDOWN_INTERNET_SOUND "internet_sound"
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
icon = 'icons/obj/overmap.dmi'
|
||||
icon_state = "object"
|
||||
|
||||
|
||||
/// If set to TRUE will show up on ship sensors for detailed scans
|
||||
var/scannable
|
||||
/// Description for scans
|
||||
@@ -26,14 +25,52 @@
|
||||
//light_system = MOVABLE_LIGHT
|
||||
light_on = FALSE
|
||||
|
||||
///~~If we need to render a map for cameras and helms for this object~~ basically can you look at and use this as a ship or station.
|
||||
var/render_map = FALSE
|
||||
|
||||
// Stuff needed to render the map
|
||||
var/map_name
|
||||
var/obj/screen/map_view/cam_screen
|
||||
/// All the plane masters that need to be applied.
|
||||
var/list/cam_plane_masters
|
||||
var/obj/screen/background/cam_background
|
||||
|
||||
/obj/effect/overmap/Initialize()
|
||||
. = ..()
|
||||
if(!global.using_map.use_overmap)
|
||||
return INITIALIZE_HINT_QDEL
|
||||
|
||||
if(render_map) // Initialize map objects
|
||||
map_name = "overmap_[REF(src)]_map"
|
||||
cam_screen = new
|
||||
cam_screen.name = "screen"
|
||||
cam_screen.assigned_map = map_name
|
||||
cam_screen.del_on_map_removal = FALSE
|
||||
cam_screen.screen_loc = "[map_name]:1,1"
|
||||
|
||||
cam_plane_masters = get_tgui_plane_masters()
|
||||
|
||||
for(var/obj/screen/instance as anything in cam_plane_masters)
|
||||
instance.assigned_map = map_name
|
||||
instance.del_on_map_removal = FALSE
|
||||
instance.screen_loc = "[map_name]:CENTER"
|
||||
|
||||
cam_background = new
|
||||
cam_background.assigned_map = map_name
|
||||
cam_background.del_on_map_removal = FALSE
|
||||
update_screen()
|
||||
|
||||
/obj/effect/overmap/Destroy()
|
||||
real_appearance?.loc = null
|
||||
real_appearance = null
|
||||
|
||||
if(cam_screen)
|
||||
QDEL_NULL(cam_screen)
|
||||
if(cam_plane_masters)
|
||||
QDEL_LIST(cam_plane_masters)
|
||||
if(cam_background)
|
||||
QDEL_NULL(cam_background)
|
||||
|
||||
return ..()
|
||||
|
||||
//Overlay of how this object should look on other skyboxes
|
||||
@@ -78,3 +115,21 @@
|
||||
SSskybox.rebuild_skyboxes(other.map_z)
|
||||
for(var/obj/effect/overmap/visitable/O in loc)
|
||||
SSskybox.rebuild_skyboxes(O.map_z)
|
||||
|
||||
/**
|
||||
* Updates the screen object, which is displayed on all connected helms
|
||||
*/
|
||||
/obj/effect/overmap/proc/update_screen()
|
||||
if(render_map)
|
||||
var/list/visible_turfs = list()
|
||||
for(var/turf/T in view(4, get_turf(src)))
|
||||
visible_turfs += T
|
||||
|
||||
var/list/bbox = get_bbox_of_atoms(visible_turfs)
|
||||
var/size_x = bbox[3] - bbox[1] + 1
|
||||
var/size_y = bbox[4] - bbox[2] + 1
|
||||
|
||||
cam_screen?.vis_contents = visible_turfs
|
||||
cam_background.icon_state = "clear"
|
||||
cam_background.fill_rect(1, 1, size_x, size_y)
|
||||
return TRUE
|
||||
|
||||
@@ -96,8 +96,23 @@ GLOBAL_LIST_EMPTY(all_waypoints)
|
||||
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
user.client.register_map_obj(linked.cam_screen)
|
||||
for(var/plane in linked.cam_plane_masters)
|
||||
user.client.register_map_obj(plane)
|
||||
user.client.register_map_obj(linked.cam_background)
|
||||
|
||||
ui = new(user, src, "OvermapHelm", "[linked.name] Helm Control") // 565, 545
|
||||
ui.open()
|
||||
addtimer(CALLBACK(src, PROC_REF(update_map)), 0.1 SECONDS)
|
||||
|
||||
/obj/machinery/computer/ship/helm/proc/update_map()
|
||||
linked.update_screen()
|
||||
|
||||
/obj/machinery/computer/ship/helm/tgui_close(mob/user)
|
||||
. = ..()
|
||||
|
||||
// Unregister map objects
|
||||
user.client?.clear_map(linked?.map_name)
|
||||
|
||||
/obj/machinery/computer/ship/helm/tgui_data(mob/user)
|
||||
var/list/data = ..()
|
||||
@@ -105,6 +120,7 @@ GLOBAL_LIST_EMPTY(all_waypoints)
|
||||
var/turf/T = get_turf(linked)
|
||||
var/obj/effect/overmap/visitable/sector/current_sector = locate() in T
|
||||
|
||||
data["mapRef"] = linked?.map_name
|
||||
data["sector"] = current_sector ? current_sector.name : "Deep Space"
|
||||
data["sector_info"] = current_sector ? current_sector.desc : "Not Available"
|
||||
data["landed"] = linked.get_landed_info()
|
||||
@@ -157,6 +173,13 @@ GLOBAL_LIST_EMPTY(all_waypoints)
|
||||
return FALSE
|
||||
|
||||
switch(action)
|
||||
if("update_camera_view")
|
||||
if(TIMER_COOLDOWN_RUNNING(src, COOLDOWN_SHIP_REFRESH))
|
||||
to_chat(usr, span_warning("You cannot refresh the map so often."))
|
||||
return
|
||||
update_map()
|
||||
TIMER_COOLDOWN_START(src, COOLDOWN_SHIP_REFRESH, 5 SECONDS)
|
||||
. = TRUE
|
||||
if("add")
|
||||
var/datum/computer_file/data/waypoint/R = new()
|
||||
var/sec_name = tgui_input_text(usr, "Input navigation entry name", "New navigation entry", "Sector #[known_sectors.len]", MAX_NAME_LEN)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
icon_state = "ship_nosprite"
|
||||
appearance_flags = TILE_BOUND|KEEP_TOGETHER|LONG_GLIDE //VOREStation Edit
|
||||
light_power = 4
|
||||
layer = OBJ_LAYER + 0.1 // make movables a little higher than regular sectors
|
||||
|
||||
unknown_name = "unknown ship"
|
||||
unknown_state = "ship"
|
||||
@@ -46,6 +47,7 @@
|
||||
|
||||
/// Vis contents overlay holding the ship's vector when in motion
|
||||
var/obj/effect/overlay/vis/vector
|
||||
render_map = TRUE
|
||||
|
||||
/obj/effect/overmap/visitable/ship/Initialize()
|
||||
. = ..()
|
||||
@@ -217,6 +219,7 @@
|
||||
pixel_y = new_pixel_y
|
||||
return
|
||||
animate(src, pixel_x = new_pixel_x, pixel_y = new_pixel_y, time = wait, flags = ANIMATION_END_NOW)
|
||||
update_screen()
|
||||
|
||||
// If we get moved, update our internal tracking to account for it
|
||||
/obj/effect/overmap/visitable/ship/Moved(atom/old_loc, direction, forced = FALSE)
|
||||
@@ -229,6 +232,7 @@
|
||||
pixel_y = 0
|
||||
position_x = ((loc.x - 1) * WORLD_ICON_SIZE) + MODULUS(position_x, WORLD_ICON_SIZE)
|
||||
position_y = ((loc.y - 1) * WORLD_ICON_SIZE) + MODULUS(position_y, WORLD_ICON_SIZE)
|
||||
update_screen()
|
||||
|
||||
/obj/effect/overmap/visitable/ship/update_icon()
|
||||
if(!is_still())
|
||||
|
||||
@@ -11,6 +11,7 @@ var/global/list/map_sectors = list()
|
||||
icon = 'icons/turf/space.dmi'
|
||||
icon_state = "map"
|
||||
alpha = 200
|
||||
vis_flags = VIS_INHERIT_ID // disable VIS_INHERIT_PLANE
|
||||
|
||||
/turf/unsimulated/map/edge
|
||||
opacity = 1
|
||||
|
||||
@@ -17,6 +17,24 @@
|
||||
unlook(M)
|
||||
. = ..()
|
||||
|
||||
/datum/tgui_module/ship/tgui_interact(mob/user, datum/tgui/ui, datum/tgui/parent_ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
if(linked)
|
||||
user.client.register_map_obj(linked.cam_screen)
|
||||
for(var/plane in linked.cam_plane_masters)
|
||||
user.client.register_map_obj(plane)
|
||||
user.client.register_map_obj(linked.cam_background)
|
||||
linked.update_screen()
|
||||
|
||||
ui = new(user, src, tgui_id, name, parent_ui)
|
||||
ui.open()
|
||||
|
||||
/datum/tgui_module/ship/tgui_data(mob/user, datum/tgui/ui, datum/tgui_state/state)
|
||||
var/list/data = ..()
|
||||
data["mapRef"] = linked?.map_name
|
||||
return data
|
||||
|
||||
/datum/tgui_module/ship/tgui_status(mob/user)
|
||||
. = ..()
|
||||
if(. > STATUS_DISABLED)
|
||||
@@ -30,6 +48,9 @@
|
||||
user.unset_machine()
|
||||
unlook(user)
|
||||
|
||||
// Unregister map objects
|
||||
user.client?.clear_map(linked?.map_name)
|
||||
|
||||
/datum/tgui_module/ship/proc/sync_linked()
|
||||
var/obj/effect/overmap/visitable/ship/sector = get_overmap_sector(get_z(tgui_host()))
|
||||
if(!sector)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { BooleanLike } from 'common/react';
|
||||
import { ByondUi, Stack } from 'tgui-core/components';
|
||||
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, Flex, LabeledList, Section, Table } from '../components';
|
||||
@@ -6,6 +7,7 @@ import { Window } from '../layouts';
|
||||
import { OvermapFlightData, OvermapPanControls } from './common/Overmap';
|
||||
|
||||
type Data = {
|
||||
mapRef: string | null;
|
||||
sector: string;
|
||||
sector_info: string;
|
||||
landed: string;
|
||||
@@ -30,7 +32,7 @@ type Data = {
|
||||
|
||||
export const OvermapHelm = (props) => {
|
||||
return (
|
||||
<Window width={565} height={545}>
|
||||
<Window width={800} height={530}>
|
||||
<Window.Content>
|
||||
<OvermapHelmContent />
|
||||
</Window.Content>
|
||||
@@ -52,7 +54,14 @@ export const OvermapHelmContent = (props) => {
|
||||
<OvermapAutopilot />
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
<Stack>
|
||||
<Stack.Item grow>
|
||||
<OvermapNavComputer />
|
||||
</Stack.Item>
|
||||
<Stack.Item grow>
|
||||
<OvermapMapView />
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -82,23 +91,11 @@ const OvermapManualControl = (props) => {
|
||||
className="Section"
|
||||
>
|
||||
<legend>Manual Control</legend>
|
||||
<Flex align="center" justify="center">
|
||||
<Flex.Item>
|
||||
<Stack fill align="center" justify="center">
|
||||
<Stack.Item fontSize={2}>
|
||||
<OvermapPanControls disabled={!canburn} actToDo="move" />
|
||||
</Flex.Item>
|
||||
</Flex>
|
||||
<Box textAlign="center" mt={1}>
|
||||
<Box bold underline>
|
||||
Direct Control
|
||||
</Box>
|
||||
<Button
|
||||
selected={manual_control}
|
||||
onClick={() => act('manual')}
|
||||
icon="compass"
|
||||
>
|
||||
{manual_control ? 'Enabled' : 'Disabled'}
|
||||
</Button>
|
||||
</Box>
|
||||
</Stack.Item>
|
||||
</Stack>
|
||||
</fieldset>
|
||||
);
|
||||
};
|
||||
@@ -192,6 +189,45 @@ const OvermapAutopilot = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
const OvermapMapView = (props) => {
|
||||
const { act, data } = useBackend<Data>();
|
||||
|
||||
const { mapRef, manual_control } = data;
|
||||
|
||||
return (
|
||||
<Section
|
||||
mt={1}
|
||||
title="Camera View"
|
||||
fill
|
||||
height="97%"
|
||||
buttons={
|
||||
<>
|
||||
<Button
|
||||
selected={manual_control}
|
||||
onClick={() => act('manual')}
|
||||
icon="compass"
|
||||
>
|
||||
Direct Control
|
||||
</Button>
|
||||
<Button
|
||||
icon="refresh"
|
||||
tooltip="Update Camera View"
|
||||
onClick={() => act('update_camera_view')}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<ByondUi
|
||||
height="100%"
|
||||
params={{
|
||||
id: mapRef,
|
||||
type: 'map',
|
||||
}}
|
||||
/>
|
||||
</Section>
|
||||
);
|
||||
};
|
||||
|
||||
const OvermapNavComputer = (props) => {
|
||||
const { act, data } = useBackend<Data>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user