mirror of
https://github.com/vgstation-coders/vgstation13.git
synced 2025-12-09 16:14:13 +00:00
Chemmaster autism (#13612)
This commit is contained in:
@@ -213,6 +213,17 @@ trans_to_atmos(var/datum/gas_mixture/target, var/amount=1, var/multiplier=1, var
|
||||
return amount
|
||||
*/
|
||||
|
||||
//Pretty straightforward, remove from all of our chemicals at once, as if transfering to a nonexistant container or something.
|
||||
/datum/reagents/proc/remove_all(var/amount=1)
|
||||
amount = min(amount, src.total_volume)
|
||||
var/part = amount / src.total_volume
|
||||
for (var/datum/reagent/current_reagent in src.reagent_list)
|
||||
if (!current_reagent)
|
||||
continue
|
||||
if(src.remove_reagent(current_reagent.id, current_reagent.volume * part))
|
||||
. = 1 //We removed SOMETHING.
|
||||
src.handle_reactions()
|
||||
|
||||
/datum/reagents/proc/copy_to(var/obj/target, var/amount=1, var/multiplier=1, var/preserve_data=1)
|
||||
if(!target)
|
||||
return
|
||||
|
||||
@@ -206,46 +206,82 @@ var/global/list/pillIcon2Name = list("oblong purple-pink", "oblong green-white",
|
||||
return 1
|
||||
|
||||
else if(href_list["add"])
|
||||
|
||||
var/id = href_list["add"]
|
||||
var/amount
|
||||
if(href_list["amount"])
|
||||
var/id = href_list["add"]
|
||||
var/amount = text2num(href_list["amount"])
|
||||
if(amount < 0)
|
||||
return
|
||||
R.trans_id_to(src, id, amount)
|
||||
amount = text2num(href_list["amount"])
|
||||
else if(href_list["percent"])
|
||||
amount = R.get_reagent_amount(id) * text2num(href_list["percent"]) / 100
|
||||
if(isnull(amount) || amount < 0)
|
||||
return
|
||||
R.trans_id_to(src, id, amount)
|
||||
src.updateUsrDialog()
|
||||
return 1
|
||||
|
||||
else if(href_list["addcustom"])
|
||||
|
||||
var/id = href_list["addcustom"]
|
||||
useramount = input("Select the amount to transfer.", 30, useramount) as num
|
||||
useramount = isgoodnumber(useramount)
|
||||
src.Topic(null, list("amount" = "[useramount]", "add" = "[id]"))
|
||||
else if(href_list["addall"])
|
||||
var/amount
|
||||
if(href_list["amount"])
|
||||
amount = text2num(href_list["amount"])
|
||||
else if(href_list["percent"])
|
||||
amount = R.total_volume * text2num(href_list["percent"]) / 100
|
||||
if(isnull(amount) || amount < 0)
|
||||
return
|
||||
R.trans_to(src, amount)
|
||||
src.updateUsrDialog()
|
||||
return 1
|
||||
|
||||
else if(href_list["remove"])
|
||||
|
||||
var/id = href_list["remove"]
|
||||
var/amount
|
||||
if(href_list["amount"])
|
||||
var/id = href_list["remove"]
|
||||
var/amount = text2num(href_list["amount"])
|
||||
if(amount < 0)
|
||||
return
|
||||
if(mode)
|
||||
reagents.trans_id_to(beaker, id, amount)
|
||||
else
|
||||
reagents.remove_reagent(id, amount)
|
||||
amount = text2num(href_list["amount"])
|
||||
else if(href_list["percent"])
|
||||
amount = R.get_reagent_amount(id) * text2num(href_list["percent"]) / 100
|
||||
if(isnull(amount) || amount < 0)
|
||||
return
|
||||
if(mode)
|
||||
reagents.trans_id_to(beaker, id, amount)
|
||||
else
|
||||
reagents.remove_reagent(id, amount)
|
||||
src.updateUsrDialog()
|
||||
return 1
|
||||
|
||||
else if(href_list["removecustom"])
|
||||
else if(href_list["removeall"])
|
||||
var/amount
|
||||
if(href_list["amount"])
|
||||
amount = text2num(href_list["amount"])
|
||||
else if(href_list["percent"])
|
||||
amount = R.total_volume * text2num(href_list["percent"]) / 100
|
||||
if(isnull(amount) || amount < 0)
|
||||
return
|
||||
if(mode)
|
||||
reagents.trans_to(beaker, amount)
|
||||
else
|
||||
reagents.remove_all(amount)
|
||||
src.updateUsrDialog()
|
||||
return 1
|
||||
|
||||
else if(href_list["addcustom"])
|
||||
var/id = href_list["addcustom"]
|
||||
useramount = input("Select the amount to transfer.", 30, useramount) as num
|
||||
useramount = isgoodnumber(useramount)
|
||||
src.Topic(null, list("amount" = "[useramount]", "add" = "[id]"))
|
||||
return 1
|
||||
else if(href_list["addallcustom"])
|
||||
useramount = input("Select the amount to transfer.", 30, useramount) as num
|
||||
useramount = isgoodnumber(useramount)
|
||||
src.Topic(null, list("amount" = "[useramount]", "addall" = "1"))
|
||||
return 1
|
||||
else if(href_list["removecustom"])
|
||||
var/id = href_list["removecustom"]
|
||||
useramount = input("Select the amount to transfer.", 30, useramount) as num
|
||||
useramount = isgoodnumber(useramount)
|
||||
src.Topic(null, list("amount" = "[useramount]", "remove" = "[id]"))
|
||||
src.updateUsrDialog()
|
||||
return 1
|
||||
else if(href_list["removeallcustom"])
|
||||
useramount = input("Select the amount to transfer.", 30, useramount) as num
|
||||
useramount = isgoodnumber(useramount)
|
||||
src.Topic(null, list("amount" = "[useramount]", "removeall" = "1"))
|
||||
return 1
|
||||
|
||||
else if(href_list["toggle"])
|
||||
@@ -390,12 +426,10 @@ var/global/list/pillIcon2Name = list("oblong purple-pink", "oblong green-white",
|
||||
/obj/machinery/chem_master/attack_paw(mob/user as mob)
|
||||
return src.attack_hand(user)
|
||||
|
||||
|
||||
/obj/machinery/chem_master/proc/generate_pill_icon_cache()
|
||||
pill_icon_cache = list()
|
||||
for(var/i = 1 to MAX_PILL_SPRITE)
|
||||
pill_icon_cache += "<img src='data:image/png;base64,[icon2base64(icon('icons/obj/chemical.dmi', "pill" + num2text(i)))]'>"
|
||||
//This is essentially just bicon(). Ideally we WOULD use just bicon(), but right now it's fucked up when used on icons because it goes by their \ref.
|
||||
pill_icon_cache += bicon(icon('icons/obj/chemical.dmi', "pill" + num2text(i)))
|
||||
|
||||
/obj/machinery/chem_master/attack_hand(mob/user as mob)
|
||||
. = ..()
|
||||
@@ -412,46 +446,102 @@ var/global/list/pillIcon2Name = list("oblong purple-pink", "oblong green-white",
|
||||
dat += "<A href='?src=\ref[src];ejectp=1'>Eject Pill Bottle \[[loaded_pill_bottle.contents.len]/[loaded_pill_bottle.storage_slots]\]</A><BR><BR>"
|
||||
else
|
||||
dat += "No pill bottle inserted.<BR><BR>"
|
||||
//dat += "<A href='?src=\ref[src];close=1'>Close</A>"
|
||||
else
|
||||
var/datum/reagents/R = beaker.reagents
|
||||
dat += "<A href='?src=\ref[src];eject=1'>Eject beaker and Clear Buffer</A><BR>"
|
||||
|
||||
if(src.loaded_pill_bottle)
|
||||
dat += "<A href='?src=\ref[src];ejectp=1'>Eject Pill Bottle \[[loaded_pill_bottle.contents.len]/[loaded_pill_bottle.storage_slots]\]</A><BR><BR>"
|
||||
else if(windowtype == "chem_master")
|
||||
dat += "No pill bottle inserted.<BR><BR>"
|
||||
|
||||
//
|
||||
// BEAKER
|
||||
//
|
||||
|
||||
if(!R.total_volume)
|
||||
dat += "Beaker is empty."
|
||||
else
|
||||
dat += "Add to buffer:<BR>"
|
||||
dat += {"
|
||||
<table>
|
||||
<td class="column1">
|
||||
Add to buffer:
|
||||
</td>
|
||||
<td class="column2">
|
||||
<A href='?src=\ref[src];addall=1;percent=[100/3]'>33%</A>
|
||||
<A href='?src=\ref[src];addall=1;percent=50'>50%</A>
|
||||
<A href='?src=\ref[src];addallcustom=1'>Custom</A>
|
||||
<A href='?src=\ref[src];addall=1;amount=[R.total_volume]'>All</A>
|
||||
</td>
|
||||
</table>
|
||||
"}
|
||||
|
||||
dat += "<table>"
|
||||
for(var/datum/reagent/G in R.reagent_list)
|
||||
dat += "<tr>"
|
||||
dat += {"
|
||||
<td class="column1">
|
||||
[G.name] , [round(G.volume, 0.01)] Units - <A href='?src=\ref[src];analyze=1;desc=[G.description];name=[G.name]'>(?)</A>
|
||||
</td>
|
||||
<td class="column2">
|
||||
<A href='?src=\ref[src];add=[G.id];amount=1'>1u</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=5'>5u</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=10'>10u</A>
|
||||
<A href='?src=\ref[src];addcustom=[G.id]'>Custom</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=[G.volume]'>All</A>
|
||||
</td>
|
||||
"}
|
||||
dat += "</tr>"
|
||||
dat += "</table>"
|
||||
|
||||
dat += {"[G.name] , [G.volume] Units -
|
||||
<A href='?src=\ref[src];analyze=1;desc=[G.description];name=[G.name]'>(Analyze)</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=1'>(1)</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=5'>(5)</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=10'>(10)</A>
|
||||
<A href='?src=\ref[src];add=[G.id];amount=[G.volume]'>(All)</A>
|
||||
<A href='?src=\ref[src];addcustom=[G.id]'>(Custom)</A><BR>"}
|
||||
//
|
||||
// BUFFER
|
||||
//
|
||||
|
||||
dat += "<HR>Transfer to <A href='?src=\ref[src];toggle=1'>[(!mode ? "disposal" : "beaker")]:</A><BR>"
|
||||
dat += "<HR>"
|
||||
if(reagents.total_volume)
|
||||
for(var/datum/reagent/N in reagents.reagent_list)
|
||||
dat += {"
|
||||
<table>
|
||||
<td class="column1">
|
||||
Transfer to <A href='?src=\ref[src];toggle=1'>[(!mode ? "disposal" : "beaker")]:</A>
|
||||
</td>
|
||||
<td class="column2">
|
||||
<A href='?src=\ref[src];removeall=1;percent=[100/3]'>33%</A>
|
||||
<A href='?src=\ref[src];removeall=1;percent=50'>50%</A>
|
||||
<A href='?src=\ref[src];removeallcustom=1'>Custom</A>
|
||||
<A href='?src=\ref[src];removeall=1;amount=[reagents.total_volume]'>All</A>
|
||||
</td>
|
||||
</table>
|
||||
"}
|
||||
|
||||
dat += {"[N.name] , [N.volume] Units -
|
||||
<A href='?src=\ref[src];analyze=1;desc=[N.description];name=[N.name]'>(Analyze)</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=1'>(1)</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=5'>(5)</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=10'>(10)</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=[N.volume]'>(All)</A>
|
||||
<A href='?src=\ref[src];removecustom=[N.id]'>(Custom)</A><BR>"}
|
||||
dat += "<table>"
|
||||
for(var/datum/reagent/N in reagents.reagent_list)
|
||||
dat += "<tr>"
|
||||
dat += {"
|
||||
<td class="column1">
|
||||
[N.name] , [round(N.volume, 0.01)] Units - <A href='?src=\ref[src];analyze=1;desc=[N.description];name=[N.name]'>(?)</A>
|
||||
</td>
|
||||
<td class="column2">
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=1'>1u</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=5'>5u</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=10'>10u</A>
|
||||
<A href='?src=\ref[src];removecustom=[N.id]'>Custom</A>
|
||||
<A href='?src=\ref[src];remove=[N.id];amount=[N.volume]'>All</A>
|
||||
</td>
|
||||
"}
|
||||
dat += "</tr>"
|
||||
dat += "</table>"
|
||||
else
|
||||
dat += "Buffer is empty.<BR>"
|
||||
if(!condi)
|
||||
//dat += {"<a href=\"?src=\ref[src]&change_pill=1\"><img src=\"pill[pillsprite].png\" /></a><a href=\"?src=\ref[src]&change_bottle=1\"><img src=\"bottle[bottlesprite].png\" /></a><BR>"}
|
||||
//dat += {"<a href=\"?src=\ref[src]&change_pill=1\"><img src=\"pill[pillsprite].png\" /></a><BR>"}
|
||||
|
||||
dat += {"<div class="li"></div>"}
|
||||
if(condi)
|
||||
dat += "<A href='?src=\ref[src];createbottle=1'>Create bottle (50 units max)</A>"
|
||||
else
|
||||
//
|
||||
// PILL ICONS
|
||||
//
|
||||
dat += "<HR>"
|
||||
dat += "<div class='pillIconsContainer'>"
|
||||
for(var/i = 1 to MAX_PILL_SPRITE)
|
||||
dat += {"<a href="?src=\ref[src]&pill_sprite=[i]" class="pillIconWrapper[i == text2num(pillsprite) ? " linkOnMinimal" : ""]">
|
||||
<div class="pillIcon">
|
||||
@@ -460,16 +550,18 @@ var/global/list/pillIcon2Name = list("oblong purple-pink", "oblong green-white",
|
||||
</a>"}
|
||||
if (i%10 == 0)
|
||||
dat +="<br>"
|
||||
|
||||
dat += "</div>"
|
||||
//
|
||||
// BUTTONS
|
||||
//
|
||||
dat += {"<HR><A href='?src=\ref[src];createpill=1'>Create single pill (50 units max)</A><BR>
|
||||
<A href='?src=\ref[src];createpill_multiple=1'>Create multiple pills (50 units max each; [max_pill_count] max)</A><BR>
|
||||
<A href='?src=\ref[src];createpill_multiple=1;createempty=1'>Create empty pills</A><BR>
|
||||
<A href='?src=\ref[src];createbottle=1'>Create bottle ([max_bottle_size] units max)</A><BR>
|
||||
<A href='?src=\ref[src];createbottle_multiple=1'>Create multiple bottles ([max_bottle_size] units max each; 4 max)</A><BR>"}
|
||||
else
|
||||
dat += "<A href='?src=\ref[src];createbottle=1'>Create bottle (50 units max)</A>"
|
||||
|
||||
dat = jointext(dat,"")
|
||||
var/datum/browser/popup = new(user, "[windowtype]", "[name]", 575, 500, src)
|
||||
var/datum/browser/popup = new(user, "[windowtype]", "[name]", 475, 500, src)
|
||||
popup.add_stylesheet("chemmaster", 'html/browser/chem_master.css')
|
||||
popup.set_content(dat)
|
||||
popup.open()
|
||||
|
||||
@@ -1,7 +1,23 @@
|
||||
table{
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
.column1{
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
.column2{
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.li{
|
||||
padding: 0px 0px 4px;
|
||||
}
|
||||
|
||||
.pillIconsContainer {
|
||||
text-align: center
|
||||
}
|
||||
|
||||
.pillIconWrapper{
|
||||
display: inline-block;
|
||||
padding:0px 4px 0px 4px;
|
||||
@@ -24,4 +40,4 @@
|
||||
margin: -16px -16px -16px -16px;
|
||||
/* Remove antialias to prevent cataracts */
|
||||
-ms-interpolation-mode: nearest-neighbor;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user