From 8923b7e72d3b9b4d9050569aa3c109fb3e0b1a8b Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Wed, 4 Mar 2020 01:21:16 -0700 Subject: [PATCH 1/7] minimaps --- .../configuration/entries/general.dm | 3 + code/controllers/subsystem/minimaps.dm | 16 ++ code/game/area/areas.dm | 12 +- code/modules/mapping/minimaps.dm | 146 ++++++++++++++++++ html/blank.png | Bin 0 -> 579 bytes tgstation.dme | 2 + 6 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 code/controllers/subsystem/minimaps.dm create mode 100644 code/modules/mapping/minimaps.dm create mode 100644 html/blank.png diff --git a/code/controllers/configuration/entries/general.dm b/code/controllers/configuration/entries/general.dm index 2d9264adf5..5d18337a9f 100644 --- a/code/controllers/configuration/entries/general.dm +++ b/code/controllers/configuration/entries/general.dm @@ -459,3 +459,6 @@ /datum/config_entry/number/max_bunker_days config_entry_value = 7 min_val = 1 + +/datum/config_entry/flag/minimaps_enabled + config_entry_value = TRUE diff --git a/code/controllers/subsystem/minimaps.dm b/code/controllers/subsystem/minimaps.dm new file mode 100644 index 0000000000..c2848f0fd3 --- /dev/null +++ b/code/controllers/subsystem/minimaps.dm @@ -0,0 +1,16 @@ +SUBSYSTEM_DEF(minimaps) + name = "Minimaps" + flags = SS_NO_FIRE + var/list/station_minimaps = list() + +/datum/controller/subsystem/minimaps/Initialize() + if(!CONFIG_GET(flag/minimaps_enabled)) + to_chat(world, "Minimaps disabled! Skipping init.") + return ..() + build_minimaps() + return ..() + +/datum/controller/subsystem/minimaps/proc/build_minimaps() + for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) + var/datum/space_level/SL = SSmapping.get_level(z) + station_minimaps[(SL.name == initial(SL.name))? "[z] - Station" : "[z] - [SL.name]"] = new /datum/minimap(z) diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 99b8165306..b206cda3cc 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -63,6 +63,9 @@ var/xenobiology_compatible = FALSE //Can the Xenobio management console transverse this area by default? var/list/canSmoothWithAreas //typecache to limit the areas that atoms in this area can smooth with + /// Color on minimaps, if it's null (which is default) it makes one at random. + var/minimap_color + /** * These two vars allow for multiple unique areas to be linked to a master area * and share some functionalities such as APC powernet nodes, fire alarms etc, without sacrificing @@ -96,7 +99,14 @@ GLOBAL_LIST_EMPTY(teleportlocs) // === /area/New() - // This interacts with the map loader, so it needs to be set immediately + if(!minimap_color) // goes in New() because otherwise it doesn't fucking work + // generate one using the icon_state + if(icon_state && icon_state != "unknown") + var/icon/I = new(icon, icon_state, dir) + I.Scale(1,1) + minimap_color = I.GetPixel(1,1) + else // no icon state? use random. + minimap_color = rgb(rand(50,70),rand(50,70),rand(50,70)) // This interacts with the map loader, so it needs to be set immediately // rather than waiting for atoms to initialize. if (unique) GLOB.areas_by_type[type] = src diff --git a/code/modules/mapping/minimaps.dm b/code/modules/mapping/minimaps.dm new file mode 100644 index 0000000000..3b4f1e130d --- /dev/null +++ b/code/modules/mapping/minimaps.dm @@ -0,0 +1,146 @@ +/datum/minimap + var/icon/map_icon + var/icon/meta_icon + var/icon/overlay_icon + var/list/color_area_names = list() + var/minx + var/maxx + var/miny + var/maxy + var/z_level + var/id = 0 + var/static/next_id = 0 + +/datum/minimap/New(z, x1 = 1, y1 = 1, x2 = world.maxx, y2 = world.maxy) + id = ++next_id + z_level = z + + var/crop_x1 = x2 + var/crop_x2 = x1 + var/crop_y1 = y2 + var/crop_y2 = y1 + + // do the generating + map_icon = new('html/blank.png') + meta_icon = new('html/blank.png') + map_icon.Scale(x2-x1+1, y2-y1+1) // arrays start at 1 + meta_icon.Scale(x2-x1+1, y2-y1+1) + var/list/area_to_color = list() + for(var/turf/T in block(locate(x1,y1,z),locate(x2,y2,z))) + var/area/A = T.loc + var/img_x = T.x - x1 + 1 // arrays start at 1 + var/img_y = T.y - y1 + 1 + if(!istype(A, /area/space) || istype(T, /turf/closed/wall)) + crop_x1 = min(crop_x1, T.x) + crop_x2 = max(crop_x2, T.x) + crop_y1 = min(crop_y1, T.y) + crop_y2 = max(crop_y2, T.y) + var/meta_color = area_to_color[A] + if(!meta_color) + meta_color = rgb(rand(0,255),rand(0,255),rand(0,255)) // technically conflicts could happen but it's like very unlikely and it's not that big of a deal if one happens + area_to_color[A] = meta_color + color_area_names[meta_color] = A.name + meta_icon.DrawBox(meta_color, img_x, img_y) + if(istype(T, /turf/closed/wall)) + map_icon.DrawBox("#000000", img_x, img_y) + else if(!istype(A, /area/space)) + var/color = A.minimap_color || "#FF00FF" + if(locate(/obj/machinery/power/solar) in T) + color = "#02026a" + if((locate(/obj/effect/spawner/structure/window) in T) || (locate(/obj/structure/grille) in T)) + color = BlendRGB(color, "#000000", 0.5) + map_icon.DrawBox(color, img_x, img_y) + map_icon.Crop(crop_x1, crop_y1, crop_x2, crop_y2) + meta_icon.Crop(crop_x1, crop_y1, crop_x2, crop_y2) + minx = crop_x1 + maxx = crop_x2 + miny = crop_y1 + maxy = crop_y2 + overlay_icon = new(map_icon) + overlay_icon.Scale(16, 16) + +/datum/minimap/proc/send(mob/user) + register_asset("minimap-[id].png", map_icon) + register_asset("minimap-[id]-meta.png", meta_icon) + send_asset_list(user, list("minimap-[id].png" = map_icon, "minimap-[id]-meta.png" = meta_icon), verify=FALSE) + +/datum/minimap_group + var/list/minimaps = list() + var/static/next_id = 0 + var/id = ++next_id + +/datum/minimap_group/proc/show(mob/user) + if(!length(minimaps)) + to_chat(user, "ERROR: Attempted to access an empty datum/minimap_group. This should probably not happen.") + return + var/list/datas = list() + var/list/info = list() + for(var/i in 1 to length(minimaps)) + var/datum/minimap/M = minimaps[i] + M.send(user) + info += "
" + datas += json_encode(map.color_area_names); + info = info.Join() + + var/html = {" + + + + + + +[name] + +[info] +"} + + user << browse(html, "window=minimap_[id];size=768x[round(768 / first_map.map_icon.Width() * first_map.map_icon.Height() + 50)]") diff --git a/html/blank.png b/html/blank.png new file mode 100644 index 0000000000000000000000000000000000000000..86c96304851e938245b5208cc2eccaee3e28550f GIT binary patch literal 579 zcmV-J0=)f+P)EX>4Tx04R}tkv&MmP!xqvQ$^8A5eteqWT;LSL`58>ibb$c+6t{Yn7s54nlvOS zE{=k0!NH%!s)LKOt`4q(Aov5~;_9U6A|>9J6k5di;PO7sd*^W9eSlCeGu7;v094H~ zlCh|m$*ziBujoY(gH-(zGxd0CF%8f4bq^ok?;g44N3P2*zi}=&Ebz>bkxtGNhls^O8_R9XiiS!&O&nHKjq-(z z%L?Z$&T6^Jntk#Y26Ea;itAJ(h+zqFBp^aY6(y8mAws)GiisqhM?L(*jz2*znOr3> zax9<%6_Voz|AXJNHS<%GZc-o$biUa3$0*RX3p8rB{e5iPjT6BC3|wg~f29u0ev)2m zY2hOvxD8xfw={VVxZDATo^;8O9LY~5mH^9Lm zFjk=Kb&q#y{D4^000SaNLh0L z04^f{04^f|c%?sf00007bV*G`2jdGC12zEF{MGUR000?uMObu0Z*6U5Zgc=ca%Ew3 zWn>_CX>@2HM@dakSAh-}0000QNklU@uWm>{0RR91?*$Cs> literal 0 HcmV?d00001 diff --git a/tgstation.dme b/tgstation.dme index 73beef27e5..8dc1544404 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -269,6 +269,7 @@ #include "code\controllers\subsystem\mapping.dm" #include "code\controllers\subsystem\materials.dm" #include "code\controllers\subsystem\medals.dm" +#include "code\controllers\subsystem\minimaps.dm" #include "code\controllers\subsystem\minor_mapping.dm" #include "code\controllers\subsystem\mobs.dm" #include "code\controllers\subsystem\moods.dm" @@ -2046,6 +2047,7 @@ #include "code\modules\lighting\lighting_turf.dm" #include "code\modules\mapping\dmm_suite.dm" #include "code\modules\mapping\map_template.dm" +#include "code\modules\mapping\minimaps.dm" #include "code\modules\mapping\preloader.dm" #include "code\modules\mapping\reader.dm" #include "code\modules\mapping\ruins.dm" From 926fd7963470c91ad84dec9d495c658b8d5ef9ba Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 7 Mar 2020 20:24:51 -0800 Subject: [PATCH 2/7] k --- code/modules/mapping/minimaps.dm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/code/modules/mapping/minimaps.dm b/code/modules/mapping/minimaps.dm index 3b4f1e130d..c21f06c376 100644 --- a/code/modules/mapping/minimaps.dm +++ b/code/modules/mapping/minimaps.dm @@ -67,7 +67,10 @@ /datum/minimap_group var/list/minimaps = list() var/static/next_id = 0 - var/id = ++next_id + var/id + +/datum/minimap_group/New() + id = ++next_id /datum/minimap_group/proc/show(mob/user) if(!length(minimaps)) @@ -75,11 +78,12 @@ return var/list/datas = list() var/list/info = list() + var/datum/minimap/first_map = minimaps[1] for(var/i in 1 to length(minimaps)) var/datum/minimap/M = minimaps[i] M.send(user) - info += "
" - datas += json_encode(map.color_area_names); + info += "
" + datas += json_encode(M.color_area_names); info = info.Join() var/html = {" @@ -144,3 +148,5 @@ window.onload = function() { "} user << browse(html, "window=minimap_[id];size=768x[round(768 / first_map.map_icon.Width() * first_map.map_icon.Height() + 50)]") + +#warn WIP: GRAB COLORS FROM https://github.com/yogstation13/Yogstation/pull/7133/files! From 8a1b57f10bddefe6e289fdb6b3f0c844fe0bccc2 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 9 Mar 2020 21:01:03 -0700 Subject: [PATCH 3/7] k --- code/controllers/subsystem/minimaps.dm | 5 ++++- code/modules/mapping/minimaps.dm | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/code/controllers/subsystem/minimaps.dm b/code/controllers/subsystem/minimaps.dm index c2848f0fd3..9209a3f3ca 100644 --- a/code/controllers/subsystem/minimaps.dm +++ b/code/controllers/subsystem/minimaps.dm @@ -2,6 +2,7 @@ SUBSYSTEM_DEF(minimaps) name = "Minimaps" flags = SS_NO_FIRE var/list/station_minimaps = list() + var/datum/minimap_group/station_minimap /datum/controller/subsystem/minimaps/Initialize() if(!CONFIG_GET(flag/minimaps_enabled)) @@ -13,4 +14,6 @@ SUBSYSTEM_DEF(minimaps) /datum/controller/subsystem/minimaps/proc/build_minimaps() for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) var/datum/space_level/SL = SSmapping.get_level(z) - station_minimaps[(SL.name == initial(SL.name))? "[z] - Station" : "[z] - [SL.name]"] = new /datum/minimap(z) + var/name = (SL.name == initial(SL.name))? "[z] - Station" : "[z] - [SL.name]" + station_minimaps = new /datum/minimap(z, name = name) + station_minimap = new(station_minimaps, "Station") diff --git a/code/modules/mapping/minimaps.dm b/code/modules/mapping/minimaps.dm index c21f06c376..b949f61da2 100644 --- a/code/modules/mapping/minimaps.dm +++ b/code/modules/mapping/minimaps.dm @@ -1,4 +1,5 @@ /datum/minimap + var/name var/icon/map_icon var/icon/meta_icon var/icon/overlay_icon @@ -11,7 +12,8 @@ var/id = 0 var/static/next_id = 0 -/datum/minimap/New(z, x1 = 1, y1 = 1, x2 = world.maxx, y2 = world.maxy) +/datum/minimap/New(z, x1 = 1, y1 = 1, x2 = world.maxx, y2 = world.maxy, name) + src.name = name id = ++next_id z_level = z @@ -68,9 +70,12 @@ var/list/minimaps = list() var/static/next_id = 0 var/id + var/name -/datum/minimap_group/New() +/datum/minimap_group/New(list/maps, name) id = ++next_id + src.name = name + minimaps = SANITIZELIST(maps) /datum/minimap_group/proc/show(mob/user) if(!length(minimaps)) From 269b7c2939609c024ad9e2dc6d1b9ffa458ae07b Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 9 Mar 2020 21:06:00 -0700 Subject: [PATCH 4/7] k --- code/modules/client/verbs/minimap.dm | 10 ++++++++++ code/modules/mapping/minimaps.dm | 4 ++-- tgstation.dme | 1 + 3 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 code/modules/client/verbs/minimap.dm diff --git a/code/modules/client/verbs/minimap.dm b/code/modules/client/verbs/minimap.dm new file mode 100644 index 0000000000..3d213dc210 --- /dev/null +++ b/code/modules/client/verbs/minimap.dm @@ -0,0 +1,10 @@ +/client/verb/show_station_minimap() + set category = "OOC" + set name = "Show Station Minimap" + set desc = "Shows a minimap of the currently loaded station map." + + if(!CONFIG_GET(flag/minimaps_enabled)) + to_chat(usr, "Minimap generation is not enabled in the server's configuration.") + return + + SSminimaps.station_minimap.show(src) diff --git a/code/modules/mapping/minimaps.dm b/code/modules/mapping/minimaps.dm index b949f61da2..647ac4a611 100644 --- a/code/modules/mapping/minimaps.dm +++ b/code/modules/mapping/minimaps.dm @@ -67,7 +67,7 @@ send_asset_list(user, list("minimap-[id].png" = map_icon, "minimap-[id]-meta.png" = meta_icon), verify=FALSE) /datum/minimap_group - var/list/minimaps = list() + var/list/minimaps var/static/next_id = 0 var/id var/name @@ -75,7 +75,7 @@ /datum/minimap_group/New(list/maps, name) id = ++next_id src.name = name - minimaps = SANITIZELIST(maps) + minimaps = maps || list() /datum/minimap_group/proc/show(mob/user) if(!length(minimaps)) diff --git a/tgstation.dme b/tgstation.dme index 8dc1544404..b7efac33fb 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -1651,6 +1651,7 @@ #include "code\modules\client\verbs\aooc.dm" #include "code\modules\client\verbs\etips.dm" #include "code\modules\client\verbs\looc.dm" +#include "code\modules\client\verbs\minimap.dm" #include "code\modules\client\verbs\ooc.dm" #include "code\modules\client\verbs\ping.dm" #include "code\modules\client\verbs\suicide.dm" From 9a9bd2f575779d7ef94ab4d5541949927ea1afd0 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 10 Mar 2020 01:12:58 -0700 Subject: [PATCH 5/7] woops --- code/controllers/subsystem/minimaps.dm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/code/controllers/subsystem/minimaps.dm b/code/controllers/subsystem/minimaps.dm index 9209a3f3ca..75de71ca96 100644 --- a/code/controllers/subsystem/minimaps.dm +++ b/code/controllers/subsystem/minimaps.dm @@ -1,7 +1,7 @@ SUBSYSTEM_DEF(minimaps) name = "Minimaps" flags = SS_NO_FIRE - var/list/station_minimaps = list() + var/list/station_minimaps var/datum/minimap_group/station_minimap /datum/controller/subsystem/minimaps/Initialize() @@ -12,8 +12,9 @@ SUBSYSTEM_DEF(minimaps) return ..() /datum/controller/subsystem/minimaps/proc/build_minimaps() + station_minimaps = list() for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) var/datum/space_level/SL = SSmapping.get_level(z) var/name = (SL.name == initial(SL.name))? "[z] - Station" : "[z] - [SL.name]" - station_minimaps = new /datum/minimap(z, name = name) + station_minimaps += new /datum/minimap(z, name = name) station_minimap = new(station_minimaps, "Station") From 39a949f223b4775c407cb65a9e868eba56b1f905 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 10 Mar 2020 05:50:57 -0700 Subject: [PATCH 6/7] remove that --- code/modules/mapping/minimaps.dm | 2 -- 1 file changed, 2 deletions(-) diff --git a/code/modules/mapping/minimaps.dm b/code/modules/mapping/minimaps.dm index 647ac4a611..c347a8d7a6 100644 --- a/code/modules/mapping/minimaps.dm +++ b/code/modules/mapping/minimaps.dm @@ -153,5 +153,3 @@ window.onload = function() { "} user << browse(html, "window=minimap_[id];size=768x[round(768 / first_map.map_icon.Width() * first_map.map_icon.Height() + 50)]") - -#warn WIP: GRAB COLORS FROM https://github.com/yogstation13/Yogstation/pull/7133/files!