Overhaul and fix destructive analyzer menu

This commit is contained in:
Tad Hardesty
2017-11-28 17:59:42 -08:00
parent 23c0516c87
commit 219328cd7a
6 changed files with 83 additions and 39 deletions
-1
View File
@@ -472,7 +472,6 @@ GLOBAL_LIST_INIT(ghost_others_options, list(GHOST_OTHERS_SIMPLE, GHOST_OTHERS_DE
#define SYRINGE_DRAW 0
#define SYRINGE_INJECT 1
#define RESEARCH_MATERIAL_RECLAMATION_ID "0"
//gold slime core spawning
#define NO_SPAWN 0
+2
View File
@@ -59,3 +59,5 @@
//#define DEPARTMENTAL_FLAG_MINING 128
#define DESIGN_ID_IGNORE "IGNORE_THIS_DESIGN"
#define RESEARCH_MATERIAL_RECLAMATION_ID "__materials"
+17 -9
View File
@@ -44,6 +44,8 @@ Note: Must be placed within 3 tiles of the R&D Console
to_chat(user, "<span class='notice'>You add the [O.name] to the [src.name]!</span>")
flick("d_analyzer_la", src)
addtimer(CALLBACK(src, .proc/finish_loading), 10)
if (linked_console)
linked_console.updateUsrDialog()
/obj/machinery/rnd/destructive_analyzer/proc/finish_loading()
update_icon()
@@ -93,18 +95,22 @@ Note: Must be placed within 3 tiles of the R&D Console
/obj/machinery/rnd/destructive_analyzer/proc/user_try_decon_id(id, mob/user)
if(!istype(loaded_item) || !istype(linked_console))
return FALSE
if(id && !(id == RESEARCH_MATERIAL_RECLAMATION_ID))
if (id && id != RESEARCH_MATERIAL_RECLAMATION_ID)
var/datum/techweb_node/TN = get_techweb_node_by_id(id)
if(!istype(TN))
return FALSE
var/list/pos1 = techweb_item_boost_check(loaded_item)
if(isnull(pos1[id]))
var/list/can_boost = techweb_item_boost_check(loaded_item)
if(isnull(can_boost[id]))
return FALSE
var/dpath = loaded_item.type
if(isnull(TN.boost_item_paths[dpath]))
var/worth = TN.boost_item_paths[dpath]
if(isnull(worth))
return FALSE
var/dboost = TN.boost_item_paths[dpath]
var/choice = input("Are you sure you want to destroy [loaded_item.name] for a boost of [dboost? 0 : dboost] in node [TN.display_name]") in list("Proceed", "Cancel")
var/difference = min(worth, TN.research_cost) - linked_console.stored_research.boosted_nodes[TN.id]
if(worth && difference <= 0)
return FALSE
var/choice = input("Are you sure you want to destroy [loaded_item] to [!worth ? "reveal [TN.display_name]" : "boost [TN.display_name] by [difference] point\s"]?") in list("Proceed", "Cancel")
if(choice == "Cancel")
return FALSE
if(QDELETED(loaded_item) || QDELETED(linked_console) || !user.Adjacent(linked_console) || QDELETED(src))
@@ -112,19 +118,20 @@ Note: Must be placed within 3 tiles of the R&D Console
SSblackbox.record_feedback("nested_tally", "item_deconstructed", 1, list("[TN.id]", "[loaded_item.type]"))
if(destroy_item(loaded_item))
linked_console.stored_research.boost_with_path(SSresearch.techweb_nodes[TN.id], dpath)
else
var/point_value = techweb_item_point_check(loaded_item)
if(linked_console.stored_research.deconstructed_items[loaded_item.type])
point_value = 0
var/choice = input("Are you sure you want to destroy [loaded_item.name] for [point_value? "[point_value] points" : "material reclaimation"]?") in list("Proceed", "Cancel")
var/choice = input("Are you sure you want to destroy [loaded_item] for [point_value ? "[point_value] research points" : "material reclamation"]?") in list("Proceed", "Cancel")
if(choice == "Cancel")
return FALSE
if(QDELETED(loaded_item) || QDELETED(linked_console) || !user.Adjacent(linked_console) || QDELETED(src))
return FALSE
var/dtype = loaded_item.type
if(destroy_item(loaded_item))
linked_console.stored_research.research_points += point_value
linked_console.stored_research.deconstructed_items[dtype] = point_value
linked_console.stored_research.deconstructed_items[loaded_item.type] = point_value
return TRUE
/obj/machinery/rnd/destructive_analyzer/proc/unload_item()
@@ -132,4 +139,5 @@ Note: Must be placed within 3 tiles of the R&D Console
return FALSE
loaded_item.forceMove(get_turf(src))
loaded_item = null
update_icon()
return TRUE
+58 -19
View File
@@ -231,7 +231,7 @@ doesn't have toxins access.
if(t_disk)
l += "<hr><a href='?src=[REF(src)];switch_screen=[RDSCREEN_TECHDISK]'>Tech Disk</a>"
if(linked_destroy)
l += "<hr><a href='?src=[REF(src)];switch_screen=[RDSCREEN_DECONSTRUCT]'>Deconstructive Analyzer</a>"
l += "<hr><a href='?src=[REF(src)];switch_screen=[RDSCREEN_DECONSTRUCT]'>Destructive Analyzer</a>"
if(linked_lathe)
l += "<hr><a href='?src=[REF(src)];switch_screen=[RDSCREEN_PROTOLATHE]'>Protolathe</a>"
if(linked_imprinter)
@@ -529,25 +529,64 @@ doesn't have toxins access.
RDSCREEN_UI_DECONSTRUCT_CHECK
var/list/l = list()
if(!linked_destroy.loaded_item)
l += "<div class='statusDisplay'>No Item Loaded. Standing-by...</div>"
l += "<div class='statusDisplay'>No item loaded. Standing-by...</div>"
else
l += "<div class='statusDisplay'><h3>Deconstruction Menu</h3>"
l += "<A href='?src=[REF(src)];eject_item=1'>Eject Item</A>"
l += "Name: [linked_destroy.loaded_item.name]"
l += "Select a node to boost by deconstructing this item."
l += "This item is able to boost:"
var/list/listin = techweb_item_boost_check(linked_destroy.loaded_item)
for(var/node_id in listin)
var/datum/techweb_node/N = get_techweb_node_by_id(node_id)
var/worth = listin[N.id]
if(!stored_research.researched_nodes[N.id] && !stored_research.boosted_nodes[N.id])
l += "<A href='?src=[REF(src)];deconstruct=[N.id]'>[N.display_name]: [worth] points</A>"
else
l += "<span class='linkOff>[N.display_name]: [worth] points</span>"
l += "<div class='statusDisplay'>[RDSCREEN_NOBREAK]"
l += "<table><tr><td>[icon2html(linked_destroy.loaded_item, usr)]</td><td><b>[linked_destroy.loaded_item.name]</b> <A href='?src=[REF(src)];eject_item=1'>Eject</A></td></tr></table>[RDSCREEN_NOBREAK]"
l += "Select a node to boost by deconstructing this item. This item can boost:"
var/anything = FALSE
var/list/boostable_nodes = techweb_item_boost_check(linked_destroy.loaded_item)
for(var/id in boostable_nodes)
anything = TRUE
var/worth = boostable_nodes[id]
var/datum/techweb_node/N = get_techweb_node_by_id(id)
l += "<div class='statusDisplay'>[RDSCREEN_NOBREAK]"
if (stored_research.researched_nodes[N.id]) // already researched
l += "<span class='linkOff'>[N.display_name]</span>"
l += "This node has already been researched."
else if (worth == 0) // reveal only
if (stored_research.hidden_nodes[N.id])
l += "<A href='?src=[REF(src)];deconstruct=[N.id]'>[N.display_name]</A>"
l += "This node will be revealed."
else
l += "<span class='linkOff'>[N.display_name]</span>"
l += "This node has already been revealed."
else // boost by the difference
var/difference = min(worth, N.research_cost) - stored_research.boosted_nodes[N.id]
if (difference > 0)
l += "<A href='?src=[REF(src)];deconstruct=[N.id]'>[N.display_name]</A>"
l += "This node will be boosted by [difference] points."
else
l += "<span class='linkOff'>[N.display_name]</span>"
l += "This node has already been boosted.</span>"
l += "</div>[RDSCREEN_NOBREAK]"
// point deconstruction and material reclamation use the same ID to prevent accidentally missing the points
var/point_value = techweb_item_point_check(linked_destroy.loaded_item)
if(point_value && isnull(stored_research.deconstructed_items[linked_destroy.loaded_item.type]))
l += "<A href='?src=[REF(src)];deconstruct=[RESEARCH_MATERIAL_RECLAMATION_ID]'>Generic Point Deconstruction - [point_value] points</A>"
l += "<A href='?src=[REF(src)];deconstruct=[RESEARCH_MATERIAL_RECLAMATION_ID]'>Material Reclaimation Deconstruction</A>"
if(point_value)
anything = TRUE
l += "<div class='statusDisplay'>[RDSCREEN_NOBREAK]"
if (stored_research.deconstructed_items[linked_destroy.loaded_item.type])
l += "<span class='linkOff'>Point Deconstruction</span>"
l += "This item's [point_value] point\s have already been claimed."
else
l += "<A href='?src=[REF(src)];deconstruct=[RESEARCH_MATERIAL_RECLAMATION_ID]'>Point Deconstruction</A>"
l += "This item is worth [point_value] point\s!"
l += "</div>[RDSCREEN_NOBREAK]"
var/list/materials = linked_destroy.loaded_item.materials
if (materials.len)
l += "<div class='statusDisplay'><A href='?src=[REF(src)];deconstruct=[RESEARCH_MATERIAL_RECLAMATION_ID]'>Material Reclamation</A>"
for (var/M in materials)
l += "* [CallMaterialName(M)] x [materials[M]]"
l += "</div>[RDSCREEN_NOBREAK]"
anything = TRUE
if (!anything)
l += "Nothing!"
l += "</div>"
return l
@@ -637,7 +676,7 @@ doesn't have toxins access.
RDSCREEN_UI_SDESIGN_CHECK
var/list/l = list()
var/datum/design/D = selected_design
l += "<div>[D.icon_html(usr)] <b>[D.name]</b>"
l += "<div><table><tr><td>[D.icon_html(usr)]</td><td><b>[D.name]</b></td></tr></table>[RDSCREEN_NOBREAK]"
if(D.build_type)
var/lathes = list()
if(D.build_type & IMPRINTER)
+4 -6
View File
@@ -153,13 +153,11 @@
recalculate_nodes(TRUE) //Fully rebuild the tree.
/datum/techweb/proc/boost_with_path(datum/techweb_node/N, itempath)
if(!istype(N)||!ispath(itempath))
if(!istype(N) || !ispath(itempath))
return FALSE
var/boost = N.boost_item_paths[itempath]
if(!boosted_nodes[N])
boosted_nodes[N] = boost
if(N.autounlock_by_boost)
hidden_nodes -= N.id
boosted_nodes[N] = max(boosted_nodes[N], N.boost_item_paths[itempath])
if(N.autounlock_by_boost)
hidden_nodes -= N.id
return TRUE
/datum/techweb/proc/update_tiers(datum/techweb_node/base)
@@ -23,8 +23,6 @@
actual_cost = research_cost
/datum/techweb_node/proc/get_price(datum/techweb/host)
if(!host)
return actual_cost
var/discount = boost_item_paths[host.boosted_nodes[src]]
actual_cost = research_cost - discount
if(host)
actual_cost = research_cost - host.boosted_nodes[src]
return actual_cost