From ecebb594f95e14873655dfcfe93ebf92769ea485 Mon Sep 17 00:00:00 2001
From: Boggart
Date: Sun, 19 Apr 2015 13:40:19 -0600
Subject: [PATCH] Fixes being unable to construct disposal pipes on walls and
fixes changing the RPD settings while already building affecting the
currently building pipes.
Changes the RPD to use the newer datum/browser ui, makes it so that it show's what you have picked and doesn't let you endlessly repick it.
Fixes my wonky check for bins/outlets/chutes on walls, also adds a changelog.
Undefs the defines in RPD.dm at the end of the file.
Changes the "Type:" label to "Category:"
---
code/game/objects/items/weapons/RPD.dm | 176 ++++++++++++------
.../recycling/disposal-construction.dm | 8 +-
html/changelogs/Boggart-PR-9069.yml | 6 +
3 files changed, 129 insertions(+), 61 deletions(-)
create mode 100644 html/changelogs/Boggart-PR-9069.yml
diff --git a/code/game/objects/items/weapons/RPD.dm b/code/game/objects/items/weapons/RPD.dm
index 64185d5d5a0..c9283ab885a 100644
--- a/code/game/objects/items/weapons/RPD.dm
+++ b/code/game/objects/items/weapons/RPD.dm
@@ -17,8 +17,12 @@ RPD
#define METER_MODE 1
#define DISPOSALS_MODE 2
+#define CATEGORY_ATMOS 0
+#define CATEGORY_DISPOSALS 1
+
/datum/pipe_info
var/id=-1
+ var/categoryId = CATEGORY_ATMOS
var/dir=SOUTH
var/dirtype=PIPE_BINARY
var/icon = 'icons/obj/pipe-item.dmi'
@@ -59,6 +63,7 @@ var/global/list/disposalpipeID2State=list(
)
/datum/pipe_info/disposal
+ categoryId = CATEGORY_DISPOSALS
icon = 'icons/obj/pipes/disposal.dmi'
icon_state = "meterX"
@@ -152,6 +157,7 @@ var/global/list/RPD_recipes=list(
"purple" = rgb(130,43,255)
)
var/paint_color="grey"
+ var/screen = CATEGORY_ATMOS //Starts on the atmos tab.
/obj/item/weapon/pipe_dispenser/New()
. = ..()
@@ -163,34 +169,57 @@ var/global/list/RPD_recipes=list(
show_menu(user)
/obj/item/weapon/pipe_dispenser/proc/render_dir_img(var/_dir,var/pic,var/title,var/flipped=0)
- var/selected=""
+ var/selected=" class=\"imglink\""
if(_dir == p_dir)
- selected=" class=\"selected\""
- return "
"
+ selected=" class=\"imglink selected\""
+ return "
"
/obj/item/weapon/pipe_dispenser/proc/show_menu(mob/user as mob)
if(!user || !src) return 0
var/dat = {"Type
Utilities:
-"}
+"}
+ if(p_class != EATING_MODE)
+ dat += "- Eat Pipes
"
+ else
+ dat += "- Eat Pipes
"
+ if(p_class != PAINT_MODE)
+ dat += "- Paint Pipes
"
+ else
+ dat += "- Paint Pipes
"
+ dat += "
"
+
+ dat += "Category:"
+ if(screen == CATEGORY_ATMOS)
+ dat += "Atmospherics Disposals
"
+ else if(screen == CATEGORY_DISPOSALS)
+ dat += "Atmospherics Disposals
"
+ dat += "
"
+
var/icon/preview=null
+ var/datbuild = ""
for(var/category in RPD_recipes)
- dat += "[category]:"
var/list/cat=RPD_recipes[category]
for(var/label in cat)
var/datum/pipe_info/I = cat[label]
var/found=0
if(I.id == p_type)
- if(p_class==ATMOS_MODE && I.type==/datum/pipe_info)
+ if((p_class == ATMOS_MODE || p_class == METER_MODE) && (I.type == /datum/pipe_info || I.type == /datum/pipe_info/meter))
found=1
- else if(p_class==DISPOSALS_MODE && I.type==/datum/pipe_info/disposal)
+ else if(p_class == DISPOSALS_MODE && I.type==/datum/pipe_info/disposal)
found=1
if(found)
preview=new /icon(I.icon,I.icon_state)
- dat += I.Render(src,label)
+ if(screen == I.categoryId)
+ if(I.id == p_type)
+ datbuild += "[label]"
+ else
+ datbuild += I.Render(src,label)
+
+ if(length(datbuild) > 0)
+ dat += "[category]:"
+ dat += datbuild
+ datbuild = ""
dat += "
"
var/color_css=""
@@ -217,7 +246,9 @@ var/global/list/RPD_recipes=list(
switch(p_conntype)
if(-1)
if(p_class==PAINT_MODE)
- dirsel = "Direction
[color_picker]"
+ dirsel = "Color
[color_picker]"
+ else
+ dirsel = ""
if(PIPE_BINARY) // Straight, N-S, W-E
if(preview)
@@ -359,47 +390,52 @@ var/global/list/RPD_recipes=list(
"}
- dat = {"
-
-
- [name]
-
-
-
-[dirsel][dat]
-
-
-"}
- user << browse(dat, "window=pipedispenser")
- onclose(user, "pipedispenser")
+ a.selected img,
+ a:hover {
+ background: #0066cc;
+ color: #ffffff;
+ }
+ [color_css]
+"}
+
+ dat = datsytle + dirsel + dat
+
+ var/datum/browser/popup = new(user, "pipedispenser", name, 300, 550)
+ popup.set_content(dat)
+ popup.open()
return
/obj/item/weapon/pipe_dispenser/Topic(href, href_list)
@@ -408,6 +444,10 @@ var/global/list/RPD_recipes=list(
return
usr.set_machine(src)
src.add_fingerprint(usr)
+ if(href_list["screen"])
+ screen = text2num(href_list["screen"])
+ show_menu(usr)
+
if(href_list["setdir"])
p_dir= text2num(href_list["setdir"])
p_flipped = text2num(href_list["flipped"])
@@ -423,14 +463,14 @@ var/global/list/RPD_recipes=list(
if(href_list["paintpipes"])
p_class = PAINT_MODE
- p_conntype=-1
- p_dir=1
+ p_conntype = -1
+ p_dir = 1
src.spark_system.start()
playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
show_menu(usr)
if(href_list["set_color"])
- paint_color=href_list["set_color"]
+ paint_color = href_list["set_color"]
src.spark_system.start()
playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
show_menu(usr)
@@ -446,8 +486,8 @@ var/global/list/RPD_recipes=list(
if(href_list["makemeter"])
p_class = METER_MODE
- p_conntype=-1
- p_dir=1
+ p_conntype = -1
+ p_dir = 1
src.spark_system.start()
playsound(get_turf(src), 'sound/effects/pop.ogg', 50, 0)
show_menu(usr)
@@ -472,7 +512,12 @@ var/global/list/RPD_recipes=list(
if(istype(A,/area/shuttle)||istype(A,/turf/space/transit))
return 0
-
+
+ //So that changing the menu settings doesn't affect the pipes already being built.
+ var/queued_p_type = p_type
+ var/queued_p_dir = p_dir
+ var/queued_p_flipped = p_flipped
+
switch(p_class)
if(PAINT_MODE) // Paint pipes
if(!istype(A,/obj/machinery/atmospherics/pipe))
@@ -510,8 +555,8 @@ var/global/list/RPD_recipes=list(
playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
if(do_after(user, 20))
activate()
- var/obj/item/pipe/P = new (A, pipe_type=p_type, dir=p_dir)
- P.flipped = p_flipped
+ var/obj/item/pipe/P = new (A, pipe_type=queued_p_type, dir=queued_p_dir)
+ P.flipped = queued_p_flipped
P.update()
P.add_fingerprint(usr)
return 1
@@ -536,7 +581,7 @@ var/global/list/RPD_recipes=list(
user << "Building Pipes..."
playsound(get_turf(src), 'sound/machines/click.ogg', 50, 1)
if(do_after(user, 20))
- var/obj/structure/disposalconstruct/C = new (A,p_type,p_dir)
+ var/obj/structure/disposalconstruct/C = new (A, queued_p_type ,queued_p_dir)
if(!C.can_place())
user << "There's not enough room to build that here!"
@@ -557,3 +602,16 @@ var/global/list/RPD_recipes=list(
/obj/item/weapon/pipe_dispenser/proc/activate()
playsound(get_turf(src), 'sound/items/Deconstruct.ogg', 50, 1)
+#undef PIPE_BINARY
+#undef PIPE_BENT
+#undef PIPE_TRINARY
+#undef PIPE_TRIN_M
+#undef PIPE_UNARY
+#undef PIPE_QUAD
+#undef PAINT_MODE
+#undef EATING_MODE
+#undef ATMOS_MODE
+#undef METER_MODE
+#undef DISPOSALS_MODE
+#undef CATEGORY_ATMOS
+#undef CATEGORY_DISPOSALS
\ No newline at end of file
diff --git a/code/modules/recycling/disposal-construction.dm b/code/modules/recycling/disposal-construction.dm
index 33b1ae0df0f..6759bcd30eb 100644
--- a/code/modules/recycling/disposal-construction.dm
+++ b/code/modules/recycling/disposal-construction.dm
@@ -170,10 +170,14 @@
nicetype = "pipe"
var/turf/T = loc
- if(T.intact)
+ if(T.intact && istype(T, /turf/simulated/floor))
user << "You can only attach the [nicetype] if the floor plating is removed."
return
-
+
+ if(!ispipe && istype(T, /turf/simulated/wall))
+ user << "You can't build [nicetype]s on walls, only disposal pipes."
+ return
+
var/obj/structure/disposalpipe/CP = locate() in T
if(istype(I, /obj/item/weapon/wrench))
diff --git a/html/changelogs/Boggart-PR-9069.yml b/html/changelogs/Boggart-PR-9069.yml
new file mode 100644
index 00000000000..f2d27334cc0
--- /dev/null
+++ b/html/changelogs/Boggart-PR-9069.yml
@@ -0,0 +1,6 @@
+author: Boggart
+
+delete-after: True
+
+changes:
+ - rscadd: "Fixes being unable to build disposal pipes on walls, makes changing the RPD's settings not affect pipes that are currently building, makes the RPD use the datum/browser ui, makes it use categories and makes it show the selected mode."