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

Restores holomap functionality #3010

Merged
merged 1 commit into from
Aug 27, 2024
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
52 changes: 33 additions & 19 deletions monkestation/code/modules/holomaps/base_datum.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,31 @@
var/list/disabled_overlays = list()
var/total_legend_y

var/map_x
var/map_y
/// This set to TRUE when the station map is initialized on a zLevel that doesn't have its own icon formatted for use by station holomaps.
var/bogus = TRUE
var/turf/location_turf
var/map_z

/datum/station_holomap/New()
. = ..()
cursor = image('monkestation/code/modules/holomaps/icons/8x8.dmi', "you")

/datum/station_holomap/proc/initialize_holomap(map_x, map_y, map_z, var/mob/user = null, var/reinit_base_map = FALSE, extra_overlays = list())
src.map_x = map_x
src.map_y = map_y
src.map_z = map_z
/datum/station_holomap/proc/initialize_holomap(turf/T, current_z_level, mob/user = null, reinit_base_map = FALSE, extra_overlays = list())
bogus = FALSE
location_turf = T
map_z = current_z_level

if(!("[HOLOMAP_EXTRA_STATIONMAP]_[map_z]" in SSholomaps.extra_holomaps))
initialize_holomap_bogus()
return

if(!base_map || reinit_base_map)
base_map = image(SSholomaps.extra_holomaps["[HOLOMAP_EXTRA_STATIONMAP]_[map_z]"])

if(isAI(user) || isaicamera(user))
var/turf/eye_turf = get_turf(user?.client?.eye)
if(!eye_turf)
return
src.map_x = eye_turf.x
src.map_y = eye_turf.y
if(eye_turf)
location_turf = eye_turf

update_map(extra_overlays)

Expand All @@ -39,7 +42,7 @@

overlay_icon.pixel_x = HOLOMAP_LEGEND_X
overlay_icon.pixel_y = legend_y
overlay_icon.maptext = "<span class='maptext' style='font-size: 6px'>[overlay_name]</span>"
overlay_icon.maptext = MAPTEXT("<span style='font-size: 6px'>[overlay_name]</span>")
overlay_icon.maptext_x = 10
overlay_icon.maptext_width = 64
base_map.add_overlay(overlay_icon)
Expand All @@ -63,11 +66,22 @@
/datum/station_holomap/proc/update_map(list/overlays_to_use = list())
base_map.cut_overlays()

if(map_x && map_y && SSmapping.level_has_all_traits(map_z, ZTRAIT_STATION))
cursor.pixel_x = map_x - 3 + HOLOMAP_CENTER_X
cursor.pixel_y = map_y - 3 + HOLOMAP_CENTER_Y
if(bogus)
var/image/legend = image('monkestation/code/modules/holomaps/icons/64x64.dmi', "notfound")
legend.pixel_x = 192
legend.pixel_y = 224
base_map.add_overlay(legend)
return

if(location_turf && location_turf.z == map_z && SSmapping.level_has_all_traits(location_turf.z, list(ZTRAIT_STATION)))
cursor.pixel_x = location_turf.x - 3 + HOLOMAP_CENTER_X
cursor.pixel_y = location_turf.y - 3 + HOLOMAP_CENTER_Y

base_map.add_overlay(cursor)
overlays_to_use["You are here"] = list(
"icon" = image('monkestation/code/modules/holomaps/icons/8x8.dmi', "you"),
"markers" = list()
)

for(var/overlay as anything in overlays_to_use)
if(overlay in disabled_overlays)
Expand All @@ -78,11 +92,11 @@

generate_legend(overlays_to_use)

/datum/station_holomap/proc/reset_map()
disabled_overlays = list()

/datum/station_holomap/proc/initialize_holomap_bogus()
bogus = TRUE
base_map = image('monkestation/code/modules/holomaps/icons/480x480.dmi', "stationmap")

var/image/legend = image('monkestation/code/modules/holomaps/icons/64x64.dmi', "notfound")
legend.pixel_x = 192
legend.pixel_y = 224

update_map(overlays_to_use = list(legend))
update_map()
10 changes: 6 additions & 4 deletions monkestation/code/modules/holomaps/huds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/atom/movable/screen/holomap
/// The owner. Used to get z-level data.
var/obj/machinery/station_map/used_station_map
var/image/used_base_map

/atom/movable/screen/holomap/Click(location, control, params)
. = ..()
Expand Down Expand Up @@ -64,7 +65,8 @@

var/text_for_screentip = position_to_name["[icon_x]:[icon_y]"]

maptext = "<span class='maptext' style='text-align: center; font-size: 32px'>[text_for_screentip]</span>"
maptext_x = icon_x
maptext_y = icon_y
maptext_width = 96
used_base_map.maptext = MAPTEXT_TINY_UNICODE("<span style='text-align: center'>[text_for_screentip]</span>")
used_base_map.maptext_x = icon_x
used_base_map.maptext_y = icon_y
used_base_map.maptext_width = 96
used_base_map.maptext_height = 96
55 changes: 24 additions & 31 deletions monkestation/code/modules/holomaps/machinery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// Credit to polaris for the code which this current map was originally based off of, and credit to VG for making it in the first place.

/obj/machinery/station_map
name = "\improper ship holomap"
desc = "A virtual map of the surrounding ship."
name = "\improper station holomap"
desc = "A virtual map of the surrounding station."
icon = 'monkestation/code/modules/holomaps/icons/stationmap.dmi'
icon_state = "station_map"
layer = ABOVE_WINDOW_LAYER
Expand All @@ -24,16 +24,16 @@
/// The little "map" floor painting.
var/image/floor_markings

// zLevel which the map is a map for.
// zLevel which the map is a map for. Change this to have mapload holomaps look at other zlevels.
var/current_z_level
/// This set to FALSE when the station map is initialized on a zLevel that has its own icon formatted for use by station holomaps.
var/bogus = TRUE

/// The various images and icons for the map are stored in here, as well as the actual big map itself.
var/datum/station_holomap/holomap_datum

/obj/machinery/station_map/Initialize()
. = ..()
current_z_level = loc.z
if(!current_z_level)
current_z_level = loc.z
SSholomaps.station_holomaps += src
return INITIALIZE_HINT_LATELOAD

Expand All @@ -50,33 +50,28 @@

/obj/machinery/station_map/proc/setup_holomap()
holomap_datum = new()
bogus = FALSE
var/turf/current_turf = get_turf(src)
if(!("[HOLOMAP_EXTRA_STATIONMAP]_[current_z_level]" in SSholomaps.extra_holomaps))
bogus = TRUE
holomap_datum.initialize_holomap_bogus()
update_icon()
return

holomap_datum.initialize_holomap(current_turf.x, current_turf.y, current_z_level, reinit_base_map = TRUE, extra_overlays = handle_overlays())
holomap_datum.initialize_holomap(current_turf, current_z_level, reinit_base_map = TRUE, extra_overlays = handle_overlays())

floor_markings = image('monkestation/code/modules/holomaps/icons/stationmap.dmi', "decal_station_map")
floor_markings.dir = src.dir

update_icon()

/obj/machinery/station_map/attack_hand(var/mob/user)
/obj/machinery/station_map/attack_hand(mob/user)
if(user == watching_mob)
close_map(user)
return

if(watching_mob && watching_mob != user)
to_chat(user, span_warning("Someone else is currently watching the holomap."))
return

open_map(user)

/// Tries to open the map for the given mob. Returns FALSE if it doesn't meet the criteria, TRUE if the map successfully opened with no runtimes.
/obj/machinery/station_map/proc/open_map(var/mob/user)
/obj/machinery/station_map/proc/open_map(mob/user)
if(!anchored || (machine_stat & (NOPOWER | BROKEN)) || !user?.client || panel_open || user.hud_used.holomap.used_station_map)
return FALSE

Expand All @@ -99,21 +94,22 @@
set_light(HOLOMAP_HIGH_LIGHT)

user.hud_used.holomap.used_station_map = src
user.hud_used.holomap.used_base_map = holomap_datum.base_map
user.hud_used.holomap.mouse_opacity = MOUSE_OPACITY_ICON
user.client.screen |= user.hud_used.holomap
user.client.images |= holomap_datum.base_map

watching_mob = user
use_power = ACTIVE_POWER_USE

if(bogus)
to_chat(user, "<span class='warning'>The holomap failed to initialize. This area of space cannot be mapped.</span>")
if(holomap_datum.bogus)
to_chat(user, span_warning("The holomap failed to initialize. This area of space cannot be mapped."))
else
to_chat(user, "<span class='warning'>A hologram of the station appears before your eyes.</span>")
to_chat(user, span_warning("A hologram of the station appears before your eyes."))

return TRUE

/obj/machinery/station_map/attack_ai(var/mob/living/silicon/robot/user)
/obj/machinery/station_map/attack_ai(mob/living/silicon/robot/user)
attack_hand(user)

/obj/machinery/station_map/attack_robot(mob/user)
Expand All @@ -125,11 +121,9 @@

/obj/machinery/station_map/proc/check_position()
SIGNAL_HANDLER
if(!watching_mob)
return

if(!Adjacent(watching_mob))
close_map(watching_mob)
if(!watching_mob || (watching_mob.loc != loc) || (dir != watching_mob.dir))
close_map()

/obj/machinery/station_map/proc/close_map()
if(!watching_mob)
Expand All @@ -144,10 +138,12 @@
watching_mob.client?.screen -= watching_mob.hud_used.holomap
watching_mob.client?.images -= holomap_datum.base_map
watching_mob.hud_used.holomap.used_station_map = null
watching_mob.hud_used.holomap.used_base_map = null
watching_mob = null
set_light(HOLOMAP_LOW_LIGHT)

use_power = IDLE_POWER_USE
holomap_datum.reset_map()

/obj/machinery/station_map/power_change()
. = ..()
Expand Down Expand Up @@ -177,9 +173,7 @@
else
icon_state = initial(icon_state)

if(bogus)
holomap_datum.initialize_holomap_bogus()
else
if(!holomap_datum.bogus)
small_station_map = image(SSholomaps.extra_holomaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[current_z_level]"], dir = src.dir)
add_overlay(small_station_map)

Expand All @@ -204,10 +198,10 @@

/obj/machinery/station_map/multitool_act(mob/living/user, obj/item/tool)
if(!panel_open)
to_chat(user, "<span class='warning'>You need to open the panel to change the [src]'[p_s()] settings!</span")
to_chat(user, span_warning("You need to open the panel to change the [src]'[p_s()] settings!"))
return FALSE
if(!SSholomaps.valid_map_indexes.len > 1)
to_chat(user, "<span class='warning'>There are no other maps available for [src]!</span>")
to_chat(user, span_warning("There are no other maps available for [src]!"))
return FALSE

tool.play_tool_sound(user, 50)
Expand All @@ -217,7 +211,7 @@
else
current_z_level = SSholomaps.valid_map_indexes[current_index + 1]

to_chat(user, "<span class='info'>You set the [src]'[p_s()] database index to [current_z_level].</span>")
to_chat(user, span_info("You set the [src]'[p_s()] database index to [current_z_level]."))
return TRUE

/obj/machinery/station_map/crowbar_act(mob/living/user, obj/item/tool)
Expand Down Expand Up @@ -278,7 +272,6 @@
z_has_coverage = TRUE
if(z_has_coverage)
legend["Meteor Shield"] = list("icon" = image('monkestation/code/modules/holomaps/icons/8x8.dmi', icon_state = "meteor_shield"), "markers" = list(image(canvas)))

return legend

/obj/machinery/station_map/engineering
Expand All @@ -297,7 +290,7 @@

/obj/machinery/station_map/engineering/handle_overlays()
var/list/extra_overlays = ..()
if(bogus)
if(holomap_datum.bogus)
return extra_overlays

var/list/fire_alarms = list()
Expand Down
2 changes: 1 addition & 1 deletion monkestation/code/modules/holomaps/subsystem.dm
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SUBSYSTEM_DEF(holomaps)
return TRUE

/// Generates the base holomap and the area holomap, before passing the latter to setup_station_map to tidy it up for viewing.
/datum/controller/subsystem/holomaps/proc/generate_holomap(var/z_level = 1)
/datum/controller/subsystem/holomaps/proc/generate_holomap(z_level = 1)
// Sanity checks - Better to generate a helpful error message now than have DrawBox() runtime
var/icon/canvas = icon(HOLOMAP_ICON, "blank")
var/icon/area_canvas = icon(HOLOMAP_ICON, "blank")
Expand Down
Loading