diff --git a/code/game/objects/items/stacks/sheets/sheet_types.dm b/code/game/objects/items/stacks/sheets/sheet_types.dm
index 5eb85379b7..e78ba6b719 100644
--- a/code/game/objects/items/stacks/sheets/sheet_types.dm
+++ b/code/game/objects/items/stacks/sheets/sheet_types.dm
@@ -18,14 +18,24 @@ GLOBAL_LIST_INIT(metal_recipes, list ( \
new/datum/stack_recipe("stool", /obj/structure/chair/stool, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("bar stool", /obj/structure/chair/stool/bar, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("chair", /obj/structure/chair, one_per_turf = TRUE, on_floor = TRUE), \
- new/datum/stack_recipe("swivel chair", /obj/structure/chair/office/dark, 5, one_per_turf = TRUE, on_floor = TRUE), \
- new/datum/stack_recipe("comfy chair", /obj/structure/chair/comfy/beige, 2, one_per_turf = TRUE, on_floor = TRUE), \
new/datum/stack_recipe("bed", /obj/structure/bed, 2, one_per_turf = TRUE, on_floor = TRUE), \
new /datum/stack_recipe("sofa (middle)", /obj/structure/chair/sofa, one_per_turf = TRUE, on_floor = TRUE), \
new /datum/stack_recipe("sofa (left)", /obj/structure/chair/sofa/left, one_per_turf = TRUE, on_floor = TRUE), \
new /datum/stack_recipe("sofa (right)", /obj/structure/chair/sofa/right, one_per_turf = TRUE, on_floor = TRUE), \
new /datum/stack_recipe("sofa (corner)", /obj/structure/chair/sofa/corner, one_per_turf = TRUE, on_floor = TRUE), \
null, \
+ new/datum/stack_recipe_list("office chairs", list( \
+ new/datum/stack_recipe("dark office chair", /obj/structure/chair/office/dark, 5, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("light office chair", /obj/structure/chair/office/light, 5, one_per_turf = TRUE, on_floor = TRUE), \
+ )), \
+ new/datum/stack_recipe_list("comfy chairs", list( \
+ new/datum/stack_recipe("beige comfy chair", /obj/structure/chair/comfy/beige, 2, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("black comfy chair", /obj/structure/chair/comfy/black, 2, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("brown comfy chair", /obj/structure/chair/comfy/brown, 2, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("lime comfy chair", /obj/structure/chair/comfy/lime, 2, one_per_turf = TRUE, on_floor = TRUE), \
+ new/datum/stack_recipe("teal comfy chair", /obj/structure/chair/comfy/teal, 2, one_per_turf = TRUE, on_floor = TRUE), \
+ )), \
+ null, \
new/datum/stack_recipe("rack parts", /obj/item/rack_parts), \
new/datum/stack_recipe("closet", /obj/structure/closet, 2, time = 15, one_per_turf = TRUE, on_floor = TRUE), \
null, \
diff --git a/code/game/objects/items/stacks/stack.dm b/code/game/objects/items/stacks/stack.dm
index b1cb00acab..fca7b6be13 100644
--- a/code/game/objects/items/stacks/stack.dm
+++ b/code/game/objects/items/stacks/stack.dm
@@ -1,7 +1,8 @@
/* Stack type objects!
* Contains:
* Stacks
- * Recipe datum
+ * Recipe datum
+ * Recipe list datum
*/
/*
@@ -88,58 +89,76 @@
/obj/item/stack/attack_self(mob/user)
interact(user)
-/obj/item/stack/interact(mob/user)
+/obj/item/stack/interact(mob/user, recipes_sublist)
if (!recipes)
return
if (!src || get_amount() <= 0)
user << browse(null, "window=stack")
- return
user.set_machine(src) //for correct work of onclose
- var/t1 = text("
Constructions from []Amount Left: []
", src, get_amount())
- for(var/i=1;i<=recipes.len,i++)
- var/datum/stack_recipe/R = recipes[i]
- if (isnull(R))
+ var/list/recipe_list = recipes
+ if (recipes_sublist && recipe_list[recipes_sublist] && istype(recipe_list[recipes_sublist], /datum/stack_recipe_list))
+ var/datum/stack_recipe_list/srl = recipe_list[recipes_sublist]
+ recipe_list = srl.recipes
+ var/t1 = "Amount Left: [amount]
"
+ for(var/i in 1 to length(recipe_list))
+ var/E = recipe_list[i]
+ if (isnull(E))
t1 += "
"
continue
- if (i>1 && !isnull(recipes[i-1]))
+ if (i>1 && !isnull(recipe_list[i-1]))
t1+="
"
- var/max_multiplier = round(get_amount() / R.req_amount)
- var/title as text
- var/can_build = 1
- can_build = can_build && (max_multiplier>0)
- if (R.res_amount>1)
- title+= "[R.res_amount]x [R.title]\s"
- else
- title+= "[R.title]"
- title+= " ([R.req_amount] [singular_name]\s)"
- if (can_build)
- t1 += text("[] ", i, title)
- else
- t1 += text("[]", title)
- continue
- if (R.max_res_amount>1 && max_multiplier>1)
- max_multiplier = min(max_multiplier, round(R.max_res_amount/R.res_amount))
- t1 += " |"
- var/list/multipliers = list(5,10,25)
- for (var/n in multipliers)
- if (max_multiplier>=n)
- t1 += " [n*R.res_amount]x"
- if (!(max_multiplier in multipliers))
- t1 += " [max_multiplier*R.res_amount]x"
- t1 += ""
- user << browse(t1, "window=stack")
+ if (istype(E, /datum/stack_recipe_list))
+ var/datum/stack_recipe_list/srl = E
+ t1 += "[srl.title]"
+
+ if (istype(E, /datum/stack_recipe))
+ var/datum/stack_recipe/R = E
+ var/max_multiplier = round(get_amount() / R.req_amount)
+ var/title as text
+ var/can_build = 1
+ can_build = can_build && (max_multiplier>0)
+
+ if (R.res_amount>1)
+ title+= "[R.res_amount]x [R.title]\s"
+ else
+ title+= "[R.title]"
+ title+= " ([R.req_amount] [singular_name]\s)"
+ if (can_build)
+ t1 += text("[title] ")
+ else
+ t1 += text("[]", title)
+ continue
+ if (R.max_res_amount>1 && max_multiplier>1)
+ max_multiplier = min(max_multiplier, round(R.max_res_amount/R.res_amount))
+ t1 += " |"
+ var/list/multipliers = list(5,10,25)
+ for (var/n in multipliers)
+ if (max_multiplier>=n)
+ t1 += " [n*R.res_amount]x"
+ if (!(max_multiplier in multipliers))
+ t1 += " [max_multiplier*R.res_amount]x"
+
+ var/datum/browser/popup = new(user, "stack", name, 400, 400)
+ popup.set_content(t1)
+ popup.open(0)
onclose(user, "stack")
/obj/item/stack/Topic(href, href_list)
..()
if (usr.restrained() || usr.stat || usr.get_active_held_item() != src)
return
+ if (href_list["sublist"] && !href_list["make"])
+ interact(usr, text2num(href_list["sublist"]))
if (href_list["make"])
if (get_amount() < 1)
qdel(src) //Never should happen
- var/datum/stack_recipe/R = recipes[text2num(href_list["make"])]
+ var/list/recipes_list = recipes
+ if (href_list["sublist"])
+ var/datum/stack_recipe_list/srl = recipes_list[text2num(href_list["sublist"])]
+ recipes_list = srl.recipes
+ var/datum/stack_recipe/R = recipes_list[text2num(href_list["make"])]
var/multiplier = text2num(href_list["multiplier"])
if (!multiplier ||(multiplier <= 0)) //href protection
return
@@ -187,9 +206,6 @@
qdel(I)
//BubbleWrap END
- if (src && usr.machine==src) //do not reopen closed window
- addtimer(CALLBACK(src, /atom/.proc/interact, usr), 0)
-
/obj/item/stack/proc/building_checks(datum/stack_recipe/R, multiplier)
if (get_amount() < R.req_amount*multiplier)
if (R.req_amount*multiplier>1)
@@ -345,3 +361,14 @@
src.one_per_turf = one_per_turf
src.on_floor = on_floor
src.window_checks = window_checks
+
+/*
+ * Recipe list datum
+ */
+/datum/stack_recipe_list
+ var/title = "ERROR"
+ var/list/recipes
+
+/datum/stack_recipe_list/New(title, recipes)
+ src.title = title
+ src.recipes = recipes