Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
Replace holomap with PDA map program (Aurorastation#17751)
Browse files Browse the repository at this point in the history
* map program, holomap init order

* huh

* programz

* program defines

* hmm.......

* a

* map 😩

* sane code, zoom

* holo_minimaps -> minimaps

* o

* remove station holomap stuff

* changelog, shitcode, mapping

* c

* o

* minus

* generate_all_minimaps()

* holomap init order

* tests rerun please

* tests rerun please

* aurora station_map removal

* legend via labeledlist

* table

* key

* aaaaaaaaaaaaaaaaaaaaaaa

---------

Co-authored-by: DreamySkrell <>
  • Loading branch information
DreamySkrell committed Nov 20, 2023
1 parent 4201960 commit e8cb618
Show file tree
Hide file tree
Showing 26 changed files with 1,042 additions and 1,615 deletions.
8 changes: 6 additions & 2 deletions aurorastation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -816,7 +816,6 @@
#include "code\game\machinery\spaceheater.dm"
#include "code\game\machinery\stargazer.dm"
#include "code\game\machinery\stasis_bed.dm"
#include "code\game\machinery\station_holomap.dm"
#include "code\game\machinery\status_display.dm"
#include "code\game\machinery\status_display_ai.dm"
#include "code\game\machinery\status_display_snowflakes.dm"
Expand Down Expand Up @@ -2645,7 +2644,11 @@
#include "code\modules\modular_computers\file_system\program_events.dm"
#include "code\modules\modular_computers\file_system\script.dm"
#include "code\modules\modular_computers\file_system\programs\_program.dm"
#include "code\modules\modular_computers\file_system\programs\app_presets.dm"
#include "code\modules\modular_computers\file_system\programs\app_presets_.dm"
#include "code\modules\modular_computers\file_system\programs\app_presets_antag.dm"
#include "code\modules\modular_computers\file_system\programs\app_presets_crew.dm"
#include "code\modules\modular_computers\file_system\programs\app_presets_equipment.dm"
#include "code\modules\modular_computers\file_system\programs\app_presets_third_party.dm"
#include "code\modules\modular_computers\file_system\programs\antagonist\hacked_camera.dm"
#include "code\modules\modular_computers\file_system\programs\civilian\cargo_control.dm"
#include "code\modules\modular_computers\file_system\programs\civilian\cargo_delivery.dm"
Expand All @@ -2666,6 +2669,7 @@
#include "code\modules\modular_computers\file_system\programs\games\arcade.dm"
#include "code\modules\modular_computers\file_system\programs\generic\lawmanager.dm"
#include "code\modules\modular_computers\file_system\programs\generic\manifest.dm"
#include "code\modules\modular_computers\file_system\programs\generic\map.dm"
#include "code\modules\modular_computers\file_system\programs\generic\news_browser.dm"
#include "code\modules\modular_computers\file_system\programs\generic\ntnrc_client.dm"
#include "code\modules\modular_computers\file_system\programs\generic\records.dm"
Expand Down
42 changes: 12 additions & 30 deletions code/__defines/minimap.dm
Original file line number Diff line number Diff line change
@@ -1,41 +1,23 @@
//
// Constants and standard colors for the holomap
// Constants and standard colors for the holomap/minimap
//

#define HOLOMAP_ICON 'icons/480x480.dmi' // Icon file to start with when drawing holomaps (to get a 480x480 canvas).
#define HOLOMAP_ICON_SIZE 480 // Pixel width & height of the holomap icon. Used for auto-centering etc.
#define ui_holomap "CENTER-7, CENTER-7" // Screen location of the holomap "hud"

// Holomap colors
#define HOLOMAP_OBSTACLE "#FFFFFFDD" // Color of walls and barriers
#define HOLOMAP_PATH "#66666699" // Color of floors
#define HOLOMAP_OBSTACLE "#FFFFFF" // Color of walls and barriers
#define HOLOMAP_PATH "#666666" // Color of floors
#define HOLOMAP_HOLOFIER "#79FF79" // Whole map is multiplied by this to give it a green holoish look

#define HOLOMAP_AREACOLOR_COMMAND "#386d8099"
#define HOLOMAP_AREACOLOR_SECURITY "#ae121299"
#define HOLOMAP_AREACOLOR_MEDICAL "#6f9e00c2"
#define HOLOMAP_AREACOLOR_SCIENCE "#A154A699"
#define HOLOMAP_AREACOLOR_ENGINEERING "#F1C23199"
#define HOLOMAP_AREACOLOR_OPERATIONS "#E06F0099"
#define HOLOMAP_AREACOLOR_HALLWAYS "#ffffffa5"
#define HOLOMAP_AREACOLOR_DOCK "#0000FFCC"
#define HOLOMAP_AREACOLOR_COMMAND "#386d80"
#define HOLOMAP_AREACOLOR_SECURITY "#ae1212"
#define HOLOMAP_AREACOLOR_MEDICAL "#6f9e00"
#define HOLOMAP_AREACOLOR_SCIENCE "#A154A6"
#define HOLOMAP_AREACOLOR_ENGINEERING "#F1C231"
#define HOLOMAP_AREACOLOR_OPERATIONS "#E06F00"
#define HOLOMAP_AREACOLOR_HALLWAYS "#ffffff"
#define HOLOMAP_AREACOLOR_DOCK "#0000FF"
#define HOLOMAP_AREACOLOR_HANGAR "#777777"
#define HOLOMAP_AREACOLOR_CIVILIAN "#5bc1c199"
#define HOLOMAP_AREACOLOR_CIVILIAN "#5bc1c1"
// If someone can come up with a non-conflicting color for the lifts, please update this.
#define HOLOMAP_AREACOLOR_LIFTS null

// Handy defines to lookup the pixel offsets for this Z-level. Cache these if you use them in a loop tho.
// Commenting these out for now. Replace if we ever datumize our maps.
/*#define HOLOMAP_PIXEL_OFFSET_X(zLevel) ((using_map.holomap_offset_x.len >= zLevel) ? using_map.holomap_offset_x[zLevel] : 0)
#define HOLOMAP_PIXEL_OFFSET_Y(zLevel) ((using_map.holomap_offset_y.len >= zLevel) ? using_map.holomap_offset_y[zLevel] : 0)
#define HOLOMAP_LEGEND_X(zLevel) ((using_map.holomap_legend_x.len >= zLevel) ? using_map.holomap_legend_x[zLevel] : 96)
#define HOLOMAP_LEGEND_Y(zLevel) ((using_map.holomap_legend_y.len >= zLevel) ? using_map.holomap_legend_y[zLevel] : 96)*/

#define HOLOMAP_PIXEL_OFFSET_X(zlevel) ((HOLOMAP_ICON_SIZE - world.maxx) / 2)
#define HOLOMAP_PIXEL_OFFSET_Y(zlevel) ((HOLOMAP_ICON_SIZE - world.maxx) / 2)
#define HOLOMAP_LEGEND_X(zlevel) 96
#define HOLOMAP_LEGEND_Y(zlevel) 96

#define HOLOMAP_EXTRA_STATIONMAP "stationmapformatted"
#define HOLOMAP_EXTRA_STATIONMAPAREAS "stationareas"
#define HOLOMAP_EXTRA_STATIONMAPSMALL "stationmapsmall"
8 changes: 4 additions & 4 deletions code/__defines/subsystem-priority.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#define SS_INIT_JOBS 21
#define SS_INIT_MAPFINALIZE 20 // Asteroid generation.
#define SS_INIT_PARALLAX 19 // Parallax image cache generation. Must run before ghosts are able to join.
#define SS_INIT_HOLOMAP 18
#define SS_INIT_ATOMS 17 // World initialization. Will trigger lighting updates. Observers can join after this loads.
#define SS_INIT_ASSETS 16 // Assets subsystem setup.
#define SS_INIT_POWER 15 // Initial powernet build.
Expand All @@ -26,9 +25,10 @@
#define SS_INIT_LIGHTING 0 // Generation of lighting overlays and pre-bake. May cause openturf updates, should initialize before SSzcopy.
#define SS_INIT_ZCOPY -1 // Z-mimic flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites.
#define SS_INIT_XENOARCH -2 // Xenoarch is this far below because it can infinite loop if placed in SS_INIT_MISC as it was before, due to some subsystems spawning stuff there.
#define SS_INIT_LOBBY -3 // Lobby timer starts here. The lobby timer won't actually start going down until the MC starts ticking, so you probably want this last
#define SS_INIT_PING -4 // Pinger for the clients
#define SS_INIT_CHAT -5 // To ensure chat remains smooth during init.
#define SS_INIT_HOLOMAP -3 // Minimap subsystem. Should be initialized after all maps, away sites, ships, planets, etc.
#define SS_INIT_LOBBY -4 // Lobby timer starts here. The lobby timer won't actually start going down until the MC starts ticking, so you probably want this last
#define SS_INIT_PING -5 // Pinger for the clients
#define SS_INIT_CHAT -6 // To ensure chat remains smooth during init.

// Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND.
// Each group has its own priority bracket.
Expand Down
1 change: 0 additions & 1 deletion code/_helpers/unsorted.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,6 @@ var/list/wall_items = typecacheof(list(
/obj/structure/mirror,
/obj/structure/fireaxecabinet,
/obj/machinery/computer/security/telescreen/entertainment,
/obj/machinery/station_map,
/obj/structure/sign
))

Expand Down
13 changes: 0 additions & 13 deletions code/_onclick/hud/hud.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var/list/global_huds
var/obj/screen/thermal
var/obj/screen/meson
var/obj/screen/science
var/obj/screen/holomap

/datum/global_hud/proc/setup_overlay(var/icon_state, var/color)
var/obj/screen/screen = new /obj/screen()
Expand Down Expand Up @@ -64,18 +63,6 @@ var/list/global_huds
meson = setup_overlay("scanline", "#9fd800")
science = setup_overlay("scanline", "#d600d6")

// The holomap screen object is actually totally invisible.
// Station maps work by setting it as an images location before sending to client, not
// actually changing the icon or icon state of the screen object itself!
// Why do they work this way? I don't know really, that is how /vg/ designed them, but since they DO
// work this way, we can take advantage of their immutability by making them part of
// the global_hud (something we have and /vg/ doesn't) instead of an instance per mob.
holomap = new /obj/screen()
holomap.name = "holomap"
holomap.icon = null
holomap.screen_loc = ui_holomap
holomap.mouse_opacity = MOUSE_OPACITY_TRANSPARENT

var/obj/screen/O
var/i
//that nasty looking dither you get when you're short-sighted
Expand Down
94 changes: 39 additions & 55 deletions code/controllers/subsystems/initialization/holomap.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,39 @@ SUBSYSTEM_DEF(holomap)
flags = SS_NO_FIRE
init_order = SS_INIT_HOLOMAP

var/list/holo_minimaps = list()
var/list/extra_minimaps = list()
var/list/station_holomaps = list()
/// List of images of minimaps, for every z-level, initialized at round start.
/// This is the "base" minimap, shows only the physical structure of walls and paths, and respects `HIDE_FROM_HOLOMAP`.
/// Key of list is the `z` of the z-level, value is the `/icon/`.
/// Every image is 255x255px.
var/list/minimaps = list()

/datum/controller/subsystem/holomap/Initialize()
holo_minimaps.len = world.maxz
for (var/z in 1 to world.maxz)
holo_minimaps[z] = generateHoloMinimap(z)
/// Same as `minimaps`, but images are base64 encoded.
var/list/minimaps_base64 = list()

LOG_DEBUG("SSholomap: [holo_minimaps.len] maps.")

for (var/z in current_map.station_levels)
generateStationMinimap(z)
/// Same as `minimaps_base64`, but the map is colored with `holomap_color` of the `/area/`
var/list/minimaps_area_colored_base64 = list()

/datum/controller/subsystem/holomap/Initialize()
generate_all_minimaps()
LOG_DEBUG("SSholomap: [minimaps.len] maps.")
..()

/datum/controller/subsystem/holomap/proc/generate_all_minimaps()
minimaps.len = world.maxz
minimaps_base64.len = world.maxz
minimaps_area_colored_base64.len = world.maxz

// Generates the "base" holomap for one z-level, showing only the physical structure of walls and paths.
/datum/controller/subsystem/holomap/proc/generateHoloMinimap(zlevel = 1)
// Save these values now to avoid a bazillion array lookups
var/offset_x = HOLOMAP_PIXEL_OFFSET_X(zlevel)
var/offset_y = HOLOMAP_PIXEL_OFFSET_Y(zlevel)
for (var/z in 1 to world.maxz)
generate_minimap(z)
generate_minimap_area_colored(z)

/datum/controller/subsystem/holomap/proc/generate_minimap(zlevel = 1)
// Sanity checks - Better to generate a helpful error message now than have DrawBox() runtime
var/icon/canvas = icon(HOLOMAP_ICON, "blank")
if(world.maxx + offset_x > canvas.Width())
CRASH("Minimap for z=[zlevel] : world.maxx ([world.maxx]) + holomap_offset_x ([offset_x]) must be <= [canvas.Width()]")
if(world.maxy + offset_y > canvas.Height())
CRASH("Minimap for z=[zlevel] : world.maxy ([world.maxy]) + holomap_offset_y ([offset_y]) must be <= [canvas.Height()]")
var/icon/canvas = icon('icons/255x255.dmi', "blank")
if(world.maxx > canvas.Width())
CRASH("Minimap for z=[zlevel] : world.maxx ([world.maxx]) must be <= [canvas.Width()]")
if(world.maxy > canvas.Height())
CRASH("Minimap for z=[zlevel] : world.maxy ([world.maxy]) must be <= [canvas.Height()]")

var/list/rock_tcache = typecacheof(list(
/turf/simulated/mineral,
Expand Down Expand Up @@ -64,56 +68,36 @@ SUBSYSTEM_DEF(holomap)
if (rock_tcache[Ttype])
continue
if (obstacle_tcache[Ttype] || (T.contents.len && locate(/obj/structure/grille, T)))
canvas.DrawBox(HOLOMAP_OBSTACLE, T.x + offset_x, T.y + offset_y)
canvas.DrawBox(HOLOMAP_OBSTACLE + "DD", T.x, T.y)
else if(path_tcache[Ttype] || (T.contents.len && locate(/obj/structure/lattice/catwalk, T)))
canvas.DrawBox(HOLOMAP_PATH, T.x + offset_x, T.y + offset_y)
canvas.DrawBox(HOLOMAP_PATH + "DD", T.x, T.y)

CHECK_TICK

return canvas

/datum/controller/subsystem/holomap/proc/generateStationMinimap(zlevel)
// Save these values now to avoid a bazillion array lookups
var/offset_x = HOLOMAP_PIXEL_OFFSET_X(zlevel)
var/offset_y = HOLOMAP_PIXEL_OFFSET_Y(zlevel)
minimaps[zlevel] = canvas
minimaps_base64[zlevel] = icon2base64(canvas)

/datum/controller/subsystem/holomap/proc/generate_minimap_area_colored(zlevel)
// Sanity checks - Better to generate a helpful error message now than have DrawBox() runtime
var/icon/canvas = icon(HOLOMAP_ICON, "blank")
if(world.maxx + offset_x > canvas.Width())
crash_with("Minimap for z=[zlevel] : world.maxx ([world.maxx]) + holomap_offset_x ([offset_x]) must be <= [canvas.Width()]")
if(world.maxy + offset_y > canvas.Height())
crash_with("Minimap for z=[zlevel] : world.maxy ([world.maxy]) + holomap_offset_y ([offset_y]) must be <= [canvas.Height()]")
var/icon/canvas = icon('icons/255x255.dmi', "blank")
if(world.maxx > canvas.Width())
crash_with("Minimap for z=[zlevel] : world.maxx ([world.maxx]) must be <= [canvas.Width()]")
if(world.maxy > canvas.Height())
crash_with("Minimap for z=[zlevel] : world.maxy ([world.maxy]) must be <= [canvas.Height()]")

var/turf/T
var/area/A
for (var/thing in Z_ALL_TURFS(zlevel))
T = thing
A = T.loc
if (A.holomap_color)
canvas.DrawBox(A.holomap_color, T.x + offset_x, T.y + offset_y)

// Save this nice area-colored canvas in case we want to layer it or something I guess
extra_minimaps["[HOLOMAP_EXTRA_STATIONMAPAREAS]_[zlevel]"] = canvas
canvas.DrawBox(A.holomap_color + "99", T.x, T.y)

var/icon/map_base = icon(holo_minimaps[zlevel])
var/icon/map_base = icon(minimaps[zlevel])
map_base.Blend(HOLOMAP_HOLOFIER, ICON_MULTIPLY)

// Generate the full sized map by blending the base and areas onto the backdrop
var/icon/big_map = icon(HOLOMAP_ICON, "stationmap")
var/icon/big_map = icon('icons/255x255.dmi', "blank")
big_map.Blend(map_base, ICON_OVERLAY)
big_map.Blend(canvas, ICON_OVERLAY)
extra_minimaps["[HOLOMAP_EXTRA_STATIONMAP]_[zlevel]"] = big_map

// Generate the "small" map (I presume for putting on wall map things?)
var/icon/small_map = icon(HOLOMAP_ICON, "blank")
small_map.Blend(map_base, ICON_OVERLAY)
small_map.Blend(canvas, ICON_OVERLAY)
small_map.Scale(WORLD_ICON_SIZE, WORLD_ICON_SIZE)

// And rotate it in every direction of course!
var/icon/actual_small_map = icon(small_map)
actual_small_map.Insert(new_icon = small_map, dir = SOUTH)
actual_small_map.Insert(new_icon = turn(small_map, 90), dir = WEST)
actual_small_map.Insert(new_icon = turn(small_map, 180), dir = NORTH)
actual_small_map.Insert(new_icon = turn(small_map, 270), dir = EAST)
extra_minimaps["[HOLOMAP_EXTRA_STATIONMAPSMALL]_[zlevel]"] = actual_small_map
minimaps_area_colored_base64[zlevel] = icon2base64(big_map)
1 change: 0 additions & 1 deletion code/controllers/subsystems/initialization/misc_early.dm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ SUBSYSTEM_DEF(misc_early)
global_hud.thermal,
global_hud.meson,
global_hud.science,
global_hud.holomap
)

// Populate global list of tips by category
Expand Down
Loading

0 comments on commit e8cb618

Please sign in to comment.