[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:
CHOMPStation2
2024-10-20 08:51:20 -07:00
committed by GitHub
parent 8d5165360f
commit 7a24e79ea4
7 changed files with 160 additions and 19 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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())

View File

@@ -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