mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-02 13:02:38 +00:00
Converts most spans into span procs. Mostly used regex for this and sorted out any compile time errors afterwards so there could be some bugs. Was initially going to do defines, but ninja said to make it into a proc, and if there's any overhead, they can easily be changed to defines. Makes it easier to control the formatting and prevents typos when creating spans as it'll runtime if you misspell instead of silently failing. Reduces the code you need to write when writing spans, as you don't need to close the span as that's automatically handled by the proc. (Note from Lemon: This should be converted to defines once we update the minimum version to 514. Didn't do it now because byond pain and such)
84 lines
3.1 KiB
Plaintext
84 lines
3.1 KiB
Plaintext
/client/proc/map_template_load()
|
|
set category = "Debug"
|
|
set name = "Map template - Place"
|
|
|
|
var/datum/map_template/template
|
|
|
|
var/map = input(src, "Choose a Map Template to place at your CURRENT LOCATION","Place Map Template") as null|anything in sortList(SSmapping.map_templates)
|
|
if(!map)
|
|
return
|
|
template = SSmapping.map_templates[map]
|
|
|
|
var/turf/T = get_turf(mob)
|
|
if(!T)
|
|
return
|
|
|
|
var/list/preview = list()
|
|
var/center
|
|
var/centeralert = tgui_alert(usr,"Center Template.","Template Centering",list("Yes","No"))
|
|
switch(centeralert)
|
|
if("Yes")
|
|
center = TRUE
|
|
if("No")
|
|
center = FALSE
|
|
else
|
|
return
|
|
for(var/S in template.get_affected_turfs(T,centered = center))
|
|
var/image/item = image('icons/turf/overlays.dmi',S,"greenOverlay")
|
|
item.plane = ABOVE_LIGHTING_PLANE
|
|
preview += item
|
|
images += preview
|
|
if(tgui_alert(usr,"Confirm location.","Template Confirm",list("Yes","No")) == "Yes")
|
|
if(template.load(T, centered = center))
|
|
var/affected = template.get_affected_turfs(T, centered = center)
|
|
for(var/AT in affected)
|
|
for(var/obj/docking_port/mobile/P in AT)
|
|
if(istype(P, /obj/docking_port/mobile))
|
|
template.post_load(P)
|
|
break
|
|
|
|
message_admins(span_adminnotice("[key_name_admin(src)] has placed a map template ([template.name]) at [ADMIN_COORDJMP(T)]"))
|
|
else
|
|
to_chat(src, "Failed to place map", confidential = TRUE)
|
|
images -= preview
|
|
|
|
/client/proc/map_template_upload()
|
|
set category = "Debug"
|
|
set name = "Map Template - Upload"
|
|
|
|
var/map = input(src, "Choose a Map Template to upload to template storage","Upload Map Template") as null|file
|
|
if(!map)
|
|
return
|
|
if(copytext("[map]", -4) != ".dmm")//4 == length(".dmm")
|
|
to_chat(src, span_warning("Filename must end in '.dmm': [map]"), confidential = TRUE)
|
|
return
|
|
var/datum/map_template/M
|
|
switch(tgui_alert(usr, "What kind of map is this?", "Map type", list("Normal", "Shuttle", "Cancel")))
|
|
if("Normal")
|
|
M = new /datum/map_template(map, "[map]", TRUE)
|
|
if("Shuttle")
|
|
M = new /datum/map_template/shuttle(map, "[map]", TRUE)
|
|
else
|
|
return
|
|
if(!M.cached_map)
|
|
to_chat(src, span_warning("Map template '[map]' failed to parse properly."), confidential = TRUE)
|
|
return
|
|
|
|
var/datum/map_report/report = M.cached_map.check_for_errors()
|
|
var/report_link
|
|
if(report)
|
|
report.show_to(src)
|
|
report_link = " - <a href='?src=[REF(report)];[HrefToken(TRUE)];show=1'>validation report</a>"
|
|
to_chat(src, span_warning("Map template '[map]' <a href='?src=[REF(report)];[HrefToken()];show=1'>failed validation</a>."), confidential = TRUE)
|
|
if(report.loadable)
|
|
var/response = tgui_alert(usr, "The map failed validation, would you like to load it anyways?", "Map Errors", list("Cancel", "Upload Anyways"))
|
|
if(response != "Upload Anyways")
|
|
return
|
|
else
|
|
tgui_alert(usr, "The map failed validation and cannot be loaded.", "Map Errors", list("Oh Darn"))
|
|
return
|
|
|
|
SSmapping.map_templates[M.name] = M
|
|
message_admins(span_adminnotice("[key_name_admin(src)] has uploaded a map template '[map]' ([M.width]x[M.height])[report_link]."))
|
|
to_chat(src, span_notice("Map template '[map]' ready to place ([M.width]x[M.height])"), confidential = TRUE)
|