From 7b07d8f2e05d7e7315b1d717c04a3c024585e6c8 Mon Sep 17 00:00:00 2001 From: Mykhailo Bykhovtsev Date: Mon, 27 Jan 2020 12:51:49 -0800 Subject: [PATCH] Adding admin verb to load templates(maps) during runtime. (#7674) --- code/datums/supplypacks.dm | 8 +- code/modules/admin/verbs/buildmode.dm | 263 +- code/modules/maps/map_template.dm | 20 +- config/example/templates_list.json | 11 + html/changelogs/Sindorman-templates.yml | 42 + icons/misc/buildmode.dmi | Bin 1151 -> 1209 bytes maps/templates/asteroid_outpost.dmm | 3377 ++++++ maps/templates/backup/asteroid_outpost.dmm | 3377 ++++++ maps/templates/backup/syndicate_base.dmm | 9884 ++++++++++++++++++ maps/templates/pra.dmm | 3864 +++++++ maps/templates/sol.dmm | 2791 +++++ maps/templates/syndicate_base.dmm | 9884 ++++++++++++++++++ maps/templates/syndicate_shuttle.dmm | 402 + tools/mapmerge2/Prepare Maps - Templates.bat | 12 + tools/mapmerge2/PrepareMaps-Templates.sh | 11 + tools/mapmerge2/requirements.txt | 2 +- 16 files changed, 33829 insertions(+), 119 deletions(-) create mode 100644 config/example/templates_list.json create mode 100644 html/changelogs/Sindorman-templates.yml create mode 100644 maps/templates/asteroid_outpost.dmm create mode 100644 maps/templates/backup/asteroid_outpost.dmm create mode 100644 maps/templates/backup/syndicate_base.dmm create mode 100644 maps/templates/pra.dmm create mode 100644 maps/templates/sol.dmm create mode 100644 maps/templates/syndicate_base.dmm create mode 100644 maps/templates/syndicate_shuttle.dmm create mode 100644 tools/mapmerge2/Prepare Maps - Templates.bat create mode 100644 tools/mapmerge2/PrepareMaps-Templates.sh diff --git a/code/datums/supplypacks.dm b/code/datums/supplypacks.dm index 9544259172b..c03b3215122 100644 --- a/code/datums/supplypacks.dm +++ b/code/datums/supplypacks.dm @@ -244,10 +244,10 @@ var/list/all_supply_groups = list("Operations","Security","Hospitality","Enginee name = "Janitorial supplies" contains = list(/obj/item/reagent_containers/glass/bucket, /obj/item/mop, - /obj/item/caution, - /obj/item/caution, - /obj/item/caution, - /obj/item/caution, + /obj/item/clothing/suit/caution, + /obj/item/clothing/suit/caution, + /obj/item/clothing/suit/caution, + /obj/item/clothing/suit/caution, /obj/item/storage/bag/trash, /obj/item/device/lightreplacer, /obj/item/reagent_containers/spray/cleaner, diff --git a/code/modules/admin/verbs/buildmode.dm b/code/modules/admin/verbs/buildmode.dm index 50b6fa07845..7e72b0c9c26 100644 --- a/code/modules/admin/verbs/buildmode.dm +++ b/code/modules/admin/verbs/buildmode.dm @@ -6,6 +6,7 @@ log_admin("[key_name(usr)] has left build mode.",admin_key=key_name(usr)) M.client.buildmode = 0 M.client.show_popup_menus = 1 + M.verbs -= /verb/load_template_verb for(var/obj/effect/bmode/buildholder/H) if(H.cl == M.client) qdel(H) @@ -13,7 +14,7 @@ log_admin("[key_name(usr)] has entered build mode.",admin_key=key_name(usr)) M.client.buildmode = 1 M.client.show_popup_menus = 0 - + M.verbs += /verb/load_template_verb var/obj/effect/bmode/buildholder/H = new/obj/effect/bmode/buildholder() var/obj/effect/bmode/builddir/A = new/obj/effect/bmode/builddir(H) A.master = H @@ -23,15 +24,19 @@ C.master = H var/obj/effect/bmode/buildquit/D = new/obj/effect/bmode/buildquit(H) D.master = H + var/obj/effect/bmode/template/E = new/obj/effect/bmode/template(H) + E.master = H H.builddir = A H.buildhelp = B H.buildmode = C H.buildquit = D + H.load_template = E M.client.screen += A M.client.screen += B M.client.screen += C M.client.screen += D + M.client.screen += E H.cl = M.client /obj/effect/bmode//Cleaning up the tree a bit @@ -51,67 +56,69 @@ /obj/effect/bmode/builddir icon_state = "build" screen_loc = "NORTH,WEST" - Click() - switch(dir) - if(NORTH) - set_dir(EAST) - if(EAST) - set_dir(SOUTH) - if(SOUTH) - set_dir(WEST) - if(WEST) - set_dir(NORTHWEST) - if(NORTHWEST) - set_dir(NORTH) - return 1 + +/obj/effect/bmode/builddir/Click() + switch(dir) + if(NORTH) + set_dir(EAST) + if(EAST) + set_dir(SOUTH) + if(SOUTH) + set_dir(WEST) + if(WEST) + set_dir(NORTHWEST) + if(NORTHWEST) + set_dir(NORTH) + return 1 /obj/effect/bmode/buildhelp icon = 'icons/misc/buildmode.dmi' icon_state = "buildhelp" screen_loc = "NORTH,WEST+1" - Click() - switch(master.cl.buildmode) - if(1) - to_chat(usr, "***********************************************************") - to_chat(usr, "Left Mouse Button = Construct / Upgrade") - to_chat(usr, "Right Mouse Button = Deconstruct / Delete / Downgrade") - to_chat(usr, "Left Mouse Button + ctrl = R-Window") - to_chat(usr, "Left Mouse Button + alt = Airlock") - to_chat(usr, "") - to_chat(usr, "Use the button in the upper left corner to") - to_chat(usr, "change the direction of built objects.") - to_chat(usr, "***********************************************************") - if(2) - to_chat(usr, "***********************************************************") - to_chat(usr, "Right Mouse Button on buildmode button = Set object type") - to_chat(usr, "Middle Mouse Button on buildmode button= On/Off object type saying") - to_chat(usr, "Middle Mouse Button on turf/obj = Capture object type") - to_chat(usr, "Left Mouse Button on turf/obj = Place objects") - to_chat(usr, "Right Mouse Button = Delete objects") - to_chat(usr, "") - to_chat(usr, "Use the button in the upper left corner to") - to_chat(usr, "change the direction of built objects.") - to_chat(usr, "***********************************************************") - if(3) - to_chat(usr, "***********************************************************") - to_chat(usr, "Right Mouse Button on buildmode button = Select var(type) & value") - to_chat(usr, "Left Mouse Button on turf/obj/mob = Set var(type) & value") - to_chat(usr, "Right Mouse Button on turf/obj/mob = Reset var's value") - to_chat(usr, "***********************************************************") - if(4) - to_chat(usr, "***********************************************************") - to_chat(usr, "Left Mouse Button on turf/obj/mob = Select") - to_chat(usr, "Right Mouse Button on turf/obj/mob = Throw") - to_chat(usr, "***********************************************************") - return 1 + +/obj/effect/bmode/buildhelp/Click() + switch(master.cl.buildmode) + if(1) + to_chat(usr, "***********************************************************") + to_chat(usr, "Left Mouse Button = Construct / Upgrade") + to_chat(usr, "Right Mouse Button = Deconstruct / Delete / Downgrade") + to_chat(usr, "Left Mouse Button + ctrl = R-Window") + to_chat(usr, "Left Mouse Button + alt = Airlock") + to_chat(usr, "") + to_chat(usr, "Use the button in the upper left corner to") + to_chat(usr, "change the direction of built objects.") + to_chat(usr, "***********************************************************") + if(2) + to_chat(usr, "***********************************************************") + to_chat(usr, "Right Mouse Button on buildmode button = Set object type") + to_chat(usr, "Middle Mouse Button on buildmode button= On/Off object type saying") + to_chat(usr, "Middle Mouse Button on turf/obj = Capture object type") + to_chat(usr, "Left Mouse Button on turf/obj = Place objects") + to_chat(usr, "Right Mouse Button = Delete objects") + to_chat(usr, "") + to_chat(usr, "Use the button in the upper left corner to") + to_chat(usr, "change the direction of built objects.") + to_chat(usr, "***********************************************************") + if(3) + to_chat(usr, "***********************************************************") + to_chat(usr, "Right Mouse Button on buildmode button = Select var(type) & value") + to_chat(usr, "Left Mouse Button on turf/obj/mob = Set var(type) & value") + to_chat(usr, "Right Mouse Button on turf/obj/mob = Reset var's value") + to_chat(usr, "***********************************************************") + if(4) + to_chat(usr, "***********************************************************") + to_chat(usr, "Left Mouse Button on turf/obj/mob = Select") + to_chat(usr, "Right Mouse Button on turf/obj/mob = Throw") + to_chat(usr, "***********************************************************") + return 1 /obj/effect/bmode/buildquit icon_state = "buildquit" - screen_loc = "NORTH,WEST+3" + screen_loc = "NORTH,WEST+4" - Click() - togglebuildmode(master.cl.mob) - return 1 +/obj/effect/bmode/buildquit/Click() + togglebuildmode(master.cl.mob) + return 1 /obj/effect/bmode/buildholder density = 0 @@ -121,6 +128,7 @@ var/obj/effect/bmode/buildhelp/buildhelp = null var/obj/effect/bmode/buildmode/buildmode = null var/obj/effect/bmode/buildquit/buildquit = null + var/obj/effect/bmode/template/load_template = null var/atom/movable/throw_atom = null /obj/effect/bmode/buildholder/Destroy() @@ -136,70 +144,78 @@ cl = null return ..() +/obj/effect/bmode/template + icon_state = "load_template" + screen_loc = "NORTH,WEST+2" + +/obj/effect/bmode/template/Click() + load_template(usr) + return 1 + /obj/effect/bmode/buildmode icon_state = "buildmode1" - screen_loc = "NORTH,WEST+2" + screen_loc = "NORTH,WEST+3" var/varholder = "name" var/valueholder = "derp" var/objholder = /obj/structure/closet var/objsay = 1 - Click(location, control, params) - var/list/pa = params2list(params) +/obj/effect/bmode/buildmode/Click(location, control, params) + var/list/pa = params2list(params) - if(pa.Find("middle")) - switch(master.cl.buildmode) - if(2) - objsay=!objsay + if(pa.Find("middle")) + switch(master.cl.buildmode) + if(2) + objsay=!objsay - if(pa.Find("left")) - switch(master.cl.buildmode) - if(1) - master.cl.buildmode = 2 - src.icon_state = "buildmode2" - if(2) - master.cl.buildmode = 3 - src.icon_state = "buildmode3" - if(3) - master.cl.buildmode = 4 - src.icon_state = "buildmode4" - if(4) - master.cl.buildmode = 1 - src.icon_state = "buildmode1" + if(pa.Find("left")) + switch(master.cl.buildmode) + if(1) + master.cl.buildmode = 2 + src.icon_state = "buildmode2" + if(2) + master.cl.buildmode = 3 + src.icon_state = "buildmode3" + if(3) + master.cl.buildmode = 4 + src.icon_state = "buildmode4" + if(4) + master.cl.buildmode = 1 + src.icon_state = "buildmode1" - else if(pa.Find("right")) - switch(master.cl.buildmode) - if(1) - return 1 - if(2) - objholder = text2path(input(usr,"Enter typepath:" ,"Typepath","/obj/structure/closet")) - if(!ispath(objholder)) + else if(pa.Find("right")) + switch(master.cl.buildmode) + if(1) + return 1 + if(2) + objholder = text2path(input(usr,"Enter typepath:" ,"Typepath","/obj/structure/closet")) + if(!ispath(objholder)) + objholder = /obj/structure/closet + alert("That path is not allowed.") + else + if(ispath(objholder,/mob) && !check_rights(R_DEBUG,0)) objholder = /obj/structure/closet - alert("That path is not allowed.") - else - if(ispath(objholder,/mob) && !check_rights(R_DEBUG,0)) - objholder = /obj/structure/closet - if(3) - var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "xray", "virus", "viruses", "cuffed", "ka", "last_eaten", "urine") + if(3) + var/list/locked = list("vars", "key", "ckey", "client", "firemut", "ishulk", "xray", "virus", "viruses", "cuffed", "ka", "last_eaten", "urine") - master.buildmode.varholder = input(usr,"Enter variable name:" ,"Name", "name") - if(master.buildmode.varholder in locked && !check_rights(R_DEBUG,0)) - return 1 - var/thetype = input(usr,"Select variable type:" ,"Type") in list("text","number","mob-reference","obj-reference","turf-reference") - if(!thetype) return 1 - switch(thetype) - if("text") - master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value", "value") as text - if("number") - master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value", 123) as num - if("mob-reference") - master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value") as mob in mob_list - if("obj-reference") - master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value") as obj in world - if("turf-reference") - master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value") as turf in world - return 1 + master.buildmode.varholder = input(usr,"Enter variable name:" ,"Name", "name") + if(master.buildmode.varholder in locked && !check_rights(R_DEBUG,0)) + return 1 + var/thetype = input(usr,"Select variable type:" ,"Type") in list("text","number","mob-reference","obj-reference","turf-reference") + if(!thetype) return 1 + switch(thetype) + if("text") + master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value", "value") as text + if("number") + master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value", 123) as num + if("mob-reference") + master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value") as mob in mob_list + if("obj-reference") + master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value") as obj in world + if("turf-reference") + master.buildmode.valueholder = input(usr,"Enter variable value:" ,"Value") as turf in world + return 1 /proc/build_click(var/mob/user, buildmode, params, var/obj/object) var/obj/effect/bmode/buildholder/holder = null @@ -297,3 +313,42 @@ if(holder.throw_atom) holder.throw_atom.throw_at(object, 10, 1) log_admin("[key_name(usr)] threw [holder.throw_atom] at [object]",admin_key=key_name(usr)) + +/verb/load_template_verb() + set name = "Load Template" + set category = "Special Verbs" + if(!usr) + return + load_template(usr) + +/proc/load_template(var/mob/user) + if(!user) + return + + if(!check_rights(R_SPAWN)) + return + + var/list/templates + try + templates = json_decode(return_file_text("config/templates_list.json")) + catch(var/exception/ej) + log_debug("Warning: Could not load the templates config as templates_list.json is missing - [ej]") + return + + if(!templates || !templates["templates_list"] || templates["templates_folder"] == "") + return + + var/turf/T = get_turf(user) + var/name = input(user, "Which template would you like to load?", "Load Template", null) as null|anything in templates["templates_list"] + + if (!name || !T) + return + + var/datum/map_template/maploader = new (templates["templates_folder"] + name, name) + if (!maploader) + log_debug("Error, unable to load maploader in proc load_template!") + return + + var/centered = input(user, "Do you want template to load as center or Edge?", "Load Template", null) as null|anything in list("Center", "Edge") + maploader.load(T, centered == "Center" ? TRUE : FALSE) + log_and_message_admins("[key_name_admin(user)] has loaded template [name].", user, T) diff --git a/code/modules/maps/map_template.dm b/code/modules/maps/map_template.dm index 2c23e1f36ea..047f71306d4 100644 --- a/code/modules/maps/map_template.dm +++ b/code/modules/maps/map_template.dm @@ -48,8 +48,8 @@ SSmachinery.setup_template_powernets(cables) /datum/map_template/proc/load_new_z() - var/x = round(world.maxx/2) - var/y = round(world.maxy/2) + var/x = round(world.maxx / 2) + var/y = round(world.maxy / 2) var/list/bounds = maploader.load_map(file(mappath), x, y, no_changeturf = TRUE) if(!bounds) @@ -60,32 +60,32 @@ //initialize things that are normally initialized after map load initTemplateBounds(bounds) - log_game("Z-level [name] loaded at at [x],[y],[world.maxz]") + log_game("Z-level [name] loaded at [x], [y], [world.maxz]") /datum/map_template/proc/load(turf/T, centered = FALSE) if(centered) - T = locate(T.x - round(width/2) , T.y - round(height/2) , T.z) + T = locate(T.x - round(width / 2) , T.y - round(height / 2) , T.z) if(!T) return - if(T.x+width > world.maxx) + if(T.x + width > world.maxx) return - if(T.y+height > world.maxy) + if(T.y + height > world.maxy) return - var/list/bounds = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE) + var/list/bounds = maploader.load_map(file(mappath), T.x, T.y, T.z, cropMap=TRUE, no_changeturf = TRUE) if(!bounds) return //initialize things that are normally initialized after map load initTemplateBounds(bounds) - log_game("[name] loaded at at [T.x],[T.y],[T.z]") + log_game("[name] loaded at [T.x], [T.y], [T.z]") return TRUE /datum/map_template/proc/get_affected_turfs(turf/T, centered = FALSE) var/turf/placement = T if(centered) - var/turf/corner = locate(placement.x - round(width/2), placement.y - round(height/2), placement.z) + var/turf/corner = locate(placement.x - round(width / 2), placement.y - round(height / 2), placement.z) if(corner) placement = corner - return block(placement, locate(placement.x+width-1, placement.y+height-1, placement.z)) + return block(placement, locate(placement.x + width-1, placement.y + height-1, placement.z)) diff --git a/config/example/templates_list.json b/config/example/templates_list.json new file mode 100644 index 00000000000..aa9ae35cdbf --- /dev/null +++ b/config/example/templates_list.json @@ -0,0 +1,11 @@ +{ + "templates_folder": "maps/templates/", + "templates_list": + [ + "sol.dmm", + "syndicate_base.dmm", + "syndicate_shuttle.dmm", + "asteroid_outpost.dmm", + "pra.dmm" + ] +} \ No newline at end of file diff --git a/html/changelogs/Sindorman-templates.yml b/html/changelogs/Sindorman-templates.yml new file mode 100644 index 00000000000..0c1667dca8f --- /dev/null +++ b/html/changelogs/Sindorman-templates.yml @@ -0,0 +1,42 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: PoZe + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added new admin verb inside of Special Verbs called Load Template. It appears when you press Toggle Build Mode. This verb allows admins to load template maps into their current coordinates." + - rscadd: "Added button to Build Mode buttons UI for load template." diff --git a/icons/misc/buildmode.dmi b/icons/misc/buildmode.dmi index a9374db34083bd731aba9713a78d8dfa4e0e8dc1..269b266e858fe1402f96d567de2b2c633a630a7f 100644 GIT binary patch delta 1002 zcmVM<17K))wcc%;e~eDJ-d}(HLC(ZfjZ3D@W64C?2o5yU448MLm$Zs`w^=YVkbQ7>*@6WV z1E2LEiUkuU1|j>@i3Jlz2D~Csq(~NQ7#TPXt5hBn&J0A6)WS4I2DBvL_uY{N8%72( z1(yDj1sf&?&N2RHSyWKi!Y~VNc9IQAUK4*Xm zk3VS9C(Uc|IRk&l7L(?6_%ATP8q@fo!{-bDtG%aJib97Ud{pn2G}xX-|QUbyzc zxI+8`le-ZYjMiEPKoxL46XPS+Q8>wqp22A*o-wdl{1XiRxhlW<1M>t+Kg^Uj6Ih+L znZVi)Y$ix2S<{)fnILtZdXnYz*;s31IqBMAzy#z;G*_lHR3G&FhJ6N36fosFNuM zsST7djzY_Tui5R4b%H|%l@DsK69eUVz@Umk6L(@z^5Td=cdA=|(?!P>rqy4^>YD72>_y1bK={rn9TqH19C}3K~!jg?U`AU z)G!Q&!wnz<2M9Od2vl{IpLrQhKzspXT^}vp;%<+ngzcf-Jxu=U!TKW0lHy+8eK?Hw zR=upB4`Z|HW!>5d*UhSz_2t%#FPl{_>!;Vfj33{&qczzvTn9*GH?MUiVQPJPBx-!)XG}vH=R!ZZ2D}Xd>`AA4IWW(nJulPn}pW zX(Zq~l8h9|f=wfVtIH~t$D}iXWTa|At&xCk3HW_;WWlD9Af|<--(r5b(sajC$ zrR{n89!R5UH@ZAyklkj|oRMOlFl8Kz=8Tl~SI8O1q9rR+iuF*lu0anv6uo}-2haZC zt@8u59zC_GHDx4Bu-*e_TFy9~ZX@quw~jeB@Edy$&N!W(6JUnNAGGLG&O7Qk0c49Q z=XLro5MYft_@IB&a{|C>@9C9Rq0>8GL8R7DK1V+M8?22{7YEGZYEC4+G{)x#t!8id z+9yVjI8>a61eo;6WbO+cuuFyn(s1FV_)2--qx7W?+!K&_{0m!$XUY3A}&j8?U`E-XZ=1 zkUGzLlI7~NF=gF30RzaBXs%3YP=3%6ILUx1)*+t{P)5=bPzHpu-!lT&LKOiYhp=7Q zZGzyqE~tM9xHhrfbVdRRKuaKFa7v@{!G0v*Yd$El5Hvm@!2lM5W)=4KdnPqOcdA>y z>CzJT8i^7ES!)TpQ{CpNOiOS)*~az*t`N`?q*Xabke^J?5=ab4hjNNQVt^1#d!Y~r z03%rTLM4EFJ^<%@kO2rmMbLlC`@No#{5