From 9fa1f4bfbbe72bebe91cff22a65de72ab801a9b5 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Wed, 15 Apr 2020 00:47:21 -0700 Subject: [PATCH] ok --- .../configuration/entries/general.dm | 2 + code/controllers/subsystems/minimaps.dm | 26 +++ code/game/area/areas.dm | 3 + code/modules/mapping/minimaps.dm | 156 ++++++++++++++++++ config/config.txt | 4 + html/blank.png | Bin 0 -> 579 bytes vorestation.dme | 3 + 7 files changed, 194 insertions(+) create mode 100644 code/controllers/configuration/entries/general.dm create mode 100644 code/controllers/subsystems/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 new file mode 100644 index 00000000000..e08c96c775c --- /dev/null +++ b/code/controllers/configuration/entries/general.dm @@ -0,0 +1,2 @@ +/datum/config_entry/flag/minimaps_enabled + config_entry_value = TRUE diff --git a/code/controllers/subsystems/minimaps.dm b/code/controllers/subsystems/minimaps.dm new file mode 100644 index 00000000000..c4a8c4708d3 --- /dev/null +++ b/code/controllers/subsystems/minimaps.dm @@ -0,0 +1,26 @@ +SUBSYSTEM_DEF(minimaps) + name = "Minimaps" + flags = SS_NO_FIRE + var/list/station_minimaps + var/datum/minimap_group/station_minimap + +/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() + station_minimaps = list() +/* + for(var/z in SSmapping.levels_by_trait(ZTRAIT_STATION)) +*/ + for(var/z in using_maps.station_levels) + /* + var/datum/space_level/SL = SSmapping.get_level(z) + var/name = (SL.name == initial(SL.name))? "[z] - Station" : "[z] - [SL.name]" + */ + var/name = "[z] - Station" + station_minimaps += new /datum/minimap(z, name = name) + station_minimap = new(station_minimaps, "Station") diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index ce761f35aac..cac1c10b565 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -42,6 +42,9 @@ var/global/global_uid = 0 var/uid + /// Color on minimaps, if it's null (which is default) it makes one at random. + var/minimap_color + /area/New() icon_state = "" uid = ++global_uid diff --git a/code/modules/mapping/minimaps.dm b/code/modules/mapping/minimaps.dm new file mode 100644 index 00000000000..dcef74d0018 --- /dev/null +++ b/code/modules/mapping/minimaps.dm @@ -0,0 +1,156 @@ +/datum/minimap + var/name + 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, name) + src.name = name + 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) || T.density)) + 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 + var/static/next_id = 0 + var/id + var/name + +/datum/minimap_group/New(list/maps, name) + id = ++next_id + src.name = name + minimaps = maps || list() + +/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() + 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(M.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/config/config.txt b/config/config.txt index e0aaefa336b..b934e50ff34 100644 --- a/config/config.txt +++ b/config/config.txt @@ -14,3 +14,7 @@ $include entries/fail2topic.txt # @LOG_TWITTER 0 # Which explicitly disables LOG_TWITTER, as well as locking it. # There are various options which are hard-locked for security reasons. + +## Uncomment to enable minimap generation +MINIMAPS_ENABLED + 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/vorestation.dme b/vorestation.dme index 59dda749232..d8ed6e08532 100644 --- a/vorestation.dme +++ b/vorestation.dme @@ -200,6 +200,7 @@ #include "code\controllers\configuration\config_entry.dm" #include "code\controllers\configuration\configuration.dm" #include "code\controllers\configuration\entries\fail2topic.dm" +#include "code\controllers\configuration\entries\general.dm" #include "code\controllers\configuration\entries\urls.dm" #include "code\controllers\configuration_old\configuration.dm" #include "code\controllers\configuration_old\configuration_vr.dm" @@ -225,6 +226,7 @@ #include "code\controllers\subsystems\lighting.dm" #include "code\controllers\subsystems\machines.dm" #include "code\controllers\subsystems\mapping_vr.dm" +#include "code\controllers\subsystems\minimaps.dm" #include "code\controllers\subsystems\mobs.dm" #include "code\controllers\subsystems\nanoui.dm" #include "code\controllers\subsystems\openspace.dm" @@ -2134,6 +2136,7 @@ #include "code\modules\lore_codex\robutt_data\bybrand.dm" #include "code\modules\lore_codex\robutt_data\main_robutts.dm" #include "code\modules\lore_codex\robutt_data\more.dm" +#include "code\modules\mapping\minimaps.dm" #include "code\modules\mapping\preloader.dm" #include "code\modules\maps\tg\dmm_suite.dm" #include "code\modules\maps\tg\map_template.dm"