diff --git a/code/game/machinery/autolathe.dm b/code/game/machinery/autolathe.dm
index df7e75bc1c4..a6154a21379 100644
--- a/code/game/machinery/autolathe.dm
+++ b/code/game/machinery/autolathe.dm
@@ -1,3 +1,7 @@
+#define AUTOLATHE_MAIN_MENU 1
+#define AUTOLATHE_CATEGORY_MENU 2
+#define AUTOLATHE_SEARCH_MENU 3
+
/obj/machinery/autolathe
name = "autolathe"
desc = "It produces items using metal and glass."
@@ -29,6 +33,7 @@
var/datum/design/being_built
var/datum/research/files
+ var/list/datum/design/matching_designs
var/selected_category
var/screen = 1
@@ -55,6 +60,7 @@
wires = new(src)
files = new /datum/research/autolathe(src)
+ matching_designs = list()
/obj/machinery/autolathe/upgraded/New()
..()
@@ -78,10 +84,13 @@
dat = wires.GetInteractWindow()
else
- if(screen == 1)
- dat = main_win(user)
- else
- dat += category_win(user,selected_category)
+ switch(screen)
+ if(AUTOLATHE_MAIN_MENU)
+ dat = main_win(user)
+ if(AUTOLATHE_CATEGORY_MENU)
+ dat = category_win(user,selected_category)
+ if(AUTOLATHE_SEARCH_MENU)
+ dat = search_win(user)
var/datum/browser/popup = new(user, "autolathe", name, 500, 500)
popup.set_content(dat)
@@ -225,6 +234,14 @@
g_amount = 0
busy = 0
src.updateUsrDialog()
+
+ if(href_list["search"])
+ matching_designs.Cut()
+
+ for(var/datum/design/D in files.known_designs)
+ if(findtext(D.name,href_list["to_search"]))
+ matching_designs.Add(D)
+
else
usr << "The autolathe is busy. Please wait for completion of previous operation."
@@ -246,7 +263,15 @@
/obj/machinery/autolathe/proc/main_win(mob/user)
var/dat = "
Autolathe Menu:
"
dat += "
Metal amount: [src.m_amount] / [max_m_amount] cm
3"
- dat += "
Glass amount: [src.g_amount] / [max_g_amount] cm
3
"
+ dat += "
Glass amount: [src.g_amount] / [max_g_amount] cm
3"
+
+ dat += "
"
var/line_length = 1
dat += "
"
@@ -256,14 +281,14 @@
dat += "
"
line_length = 1
- dat += "| [C] | "
+ dat += "[C] | "
line_length++
dat += "
"
return dat
/obj/machinery/autolathe/proc/category_win(mob/user,var/selected_category)
- var/dat = "Return to category screen"
+ var/dat = "Return to main menu"
dat += "Browsing [selected_category]:
"
dat += "Metal amount: [src.m_amount] / [max_m_amount] cm3
"
dat += "Glass amount: [src.g_amount] / [max_g_amount] cm3
"
@@ -290,6 +315,32 @@
dat += ""
return dat
+
+/obj/machinery/autolathe/proc/search_win(mob/user)
+ var/dat = "Return to main menu"
+ dat += "Search results:
"
+ dat += "
Metal amount: [src.m_amount] / [max_m_amount] cm
3"
+ dat += "
Glass amount: [src.g_amount] / [max_g_amount] cm
3
"
+
+ for(var/datum/design/D in matching_designs)
+ if(disabled || !can_build(D))
+ dat += "
[D.name]"
+ else
+ dat += "
[D.name]"
+
+ if(ispath(D.build_path, /obj/item/stack))
+ var/max_multiplier = min(50, D.materials["$metal"] ?round(m_amount/D.materials["$metal"]):INFINITY,D.materials["$glass"]?round(g_amount/D.materials["$glass"]):INFINITY)
+ if (max_multiplier>10 && !disabled)
+ dat += "
x10"
+ if (max_multiplier>25 && !disabled)
+ dat += "
x25"
+ if(max_multiplier > 0 && !disabled)
+ dat += "
x[max_multiplier]"
+
+ dat += "[get_design_cost(D)]
"
+
+ dat += "
"
+ return dat
/obj/machinery/autolathe/proc/can_build(var/datum/design/D)
var/coeff = (ispath(D.build_path,/obj/item/stack) ? 1 : 2 ** prod_coeff)
diff --git a/code/modules/research/designs/autolathe_designs.dm b/code/modules/research/designs/autolathe_designs.dm
index 541518016b9..a129dde7472 100644
--- a/code/modules/research/designs/autolathe_designs.dm
+++ b/code/modules/research/designs/autolathe_designs.dm
@@ -19,7 +19,7 @@
category = list("initial","Tools")
/datum/design/crowbar
- name = "Pocket crowbar"
+ name = "Pocket Crowbar"
id = "crowbar"
build_type = AUTOLATHE
materials = list("$metal" = 50)
diff --git a/code/modules/research/rdconsole.dm b/code/modules/research/rdconsole.dm
index 6cd7c7471b1..90e7ff47ace 100644
--- a/code/modules/research/rdconsole.dm
+++ b/code/modules/research/rdconsole.dm
@@ -50,7 +50,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
req_access = list(access_research) //Data and setting manipulation requires scientist access.
var/selected_category
-
+ var/list/datum/design/matching_designs = list() //for the search function
/obj/machinery/computer/rdconsole/proc/CallTechName(var/ID) //A simple helper proc to find the name of a tech with a given ID.
var/datum/tech/check_tech
@@ -135,6 +135,7 @@ won't update every console in existence) but it's more of a hassle to do. Also,
/obj/machinery/computer/rdconsole/New()
..()
files = new /datum/research(src) //Setup the research data holder.
+ matching_designs = list()
if(!id)
for(var/obj/machinery/r_n_d/server/centcom/S in world)
S.initialize()
@@ -589,6 +590,25 @@ won't update every console in existence) but it's more of a hassle to do. Also,
spawn(20)
screen = 1.6
updateUsrDialog()
+
+ else if(href_list["search"]) //Search for designs with name matching pattern
+ var/compare
+
+ matching_designs.Cut()
+
+ if(href_list["type"] == "proto")
+ compare = PROTOLATHE
+ screen = 3.17
+ else
+ compare = IMPRINTER
+ screen = 4.17
+
+ for(var/datum/design/D in files.known_designs)
+ if(!(D.build_type & compare))
+ continue
+ if(findtext(D.name,href_list["to_search"]))
+ matching_designs.Add(D)
+
updateUsrDialog()
return
@@ -801,7 +821,15 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "Chemical Storage"
dat += "
Protolathe Menu:
"
dat += "Material Amount: [linked_lathe.TotalMaterials()] / [linked_lathe.max_material_storage]
"
- dat += "Chemical Volume: [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]
"
+ dat += "Chemical Volume: [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]
"
+
+ dat += "
"
dat += list_categories(linked_lathe.categories, 3.15)
@@ -842,6 +870,39 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += " | LOCKED"
dat += "
"
dat += ""
+
+ if(3.17) //Display search result
+ dat += "Main Menu"
+ dat += "Protolathe Menu"
+ dat += "Search results:
"
+ dat += "
Material Amount: [linked_lathe.TotalMaterials()] / [linked_lathe.max_material_storage]
"
+ dat += "
Chemical Volume: [linked_lathe.reagents.total_volume] / [linked_lathe.reagents.maximum_volume]
"
+
+ var/coeff = linked_lathe.efficiency_coeff
+ for(var/datum/design/D in matching_designs)
+ var/temp_material
+ var/c = 50
+ var/t
+ for(var/M in D.materials)
+ t = linked_lathe.check_mat(D, M)
+ temp_material += " | "
+ if (!t)
+ temp_material += "
[D.materials[M]/coeff] [CallMaterialName(M)]"
+ else
+ temp_material += " [D.materials[M]/coeff] [CallMaterialName(M)]"
+ c = min(c,t)
+
+ if (c)
+ dat += "
[D.name]"
+ if(c >= 5.0)
+ dat += "
x5"
+ if(c >= 10.0)
+ dat += "
x10"
+ dat += "[temp_material]"
+ else
+ dat += "
[D.name][temp_material]"
+ dat += "
"
+ dat += "
"
if(3.2) //Protolathe Material Storage Sub-menu
dat += "Main Menu"
@@ -917,6 +978,14 @@ won't update every console in existence) but it's more of a hassle to do. Also,
dat += "Circuit Imprinter Menu:
"
dat += "Material Amount: [linked_imprinter.TotalMaterials()]
"
dat += "Chemical Volume: [linked_imprinter.reagents.total_volume]
"
+
+ dat += "
"
dat += list_categories(linked_imprinter.categories, 4.15)
@@ -947,6 +1016,30 @@ won't update every console in existence) but it's more of a hassle to do. Also,
if(D.locked)
dat += " | LOCKED"
dat += ""
+
+ if(4.17)
+ dat += "Main Menu"
+ dat += "Circuit Imprinter Menu"
+ dat += "Search results:
"
+ dat += "Material Amount: [linked_imprinter.TotalMaterials()]
"
+ dat += "Chemical Volume: [linked_imprinter.reagents.total_volume]
"
+
+ var/coeff = linked_imprinter.efficiency_coeff
+ for(var/datum/design/D in matching_designs)
+ var/temp_materials
+ var/check_materials = 1
+ for(var/M in D.materials)
+ temp_materials += " | "
+ if (!linked_imprinter.check_mat(D, M))
+ check_materials = 0
+ temp_materials += "
[D.materials[M]/coeff] [CallMaterialName(M)]"
+ else
+ temp_materials += " [D.materials[M]/coeff] [CallMaterialName(M)]"
+ if (check_materials)
+ dat += "
[D.name][temp_materials]
"
+ else
+ dat += "
[D.name][temp_materials]
"
+ dat += "
"
if(4.2)
dat += "Main Menu"