mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-29 06:57:42 +01:00
Merge pull request #299 from Artorp/canisterUI
Canister label system UI
This commit is contained in:
@@ -5,55 +5,24 @@
|
||||
density = 1
|
||||
var/health = 100.0
|
||||
flags = FPRINT | CONDUCT
|
||||
|
||||
|
||||
var/menu = 0
|
||||
//used by nanoui: 0 = main menu, 1 = relabel
|
||||
|
||||
var/valve_open = 0
|
||||
var/release_pressure = ONE_ATMOSPHERE
|
||||
|
||||
var/list/_color = list("yellow", null, null, null)//variable that stores colours
|
||||
var/list/decals = list() // var that stores the decals, NOTE: Not the actual POSSIBLE decals, but the ones currently used
|
||||
var/list/oldcolor = list()//lists for check_change()
|
||||
var/list/olddecals = list()
|
||||
var/list/possibledecals = list( //var that stores all possible decals, here for adminbus I guess? NOTE: LEAVE "done" IN HERE
|
||||
"Low temperature canister" = "cold",
|
||||
"High temperature canister" = "hot",
|
||||
"Plasma containing canister" = "plasma",
|
||||
"Done" = "DONE"
|
||||
)
|
||||
var/list/possiblemaincolor = list( //these lists contain the possible colors of a canister, here for adminbus
|
||||
"\[N2O\]" = "redws",
|
||||
"\[N2\]" = "red",
|
||||
"\[O2\]" = "blue",
|
||||
"\[Toxin (Bio)\]" = "orange",
|
||||
"\[CO2\]" = "black",
|
||||
"\[Air\]" = "grey",
|
||||
"\[CAUTION\]" = "yellow",
|
||||
"\[SPECIAL\]" = "whiters"
|
||||
)
|
||||
var/list/possibleseccolor = list( // no point in having the N2O and "whiters" ones in these lists
|
||||
"\[N2\]" = "red-c",
|
||||
"\[O2\]" = "blue-c",
|
||||
"\[Toxin (Bio)\]" = "orange-c",
|
||||
"\[CO2\]" = "black-c",
|
||||
"\[Air\]" = "grey-c",
|
||||
"\[CAUTION\]" = "yellow-c"
|
||||
)
|
||||
var/list/possibletertcolor = list(
|
||||
"\[N2\]" = "red-c-1",
|
||||
"\[O2\]" = "blue-c-1",
|
||||
"\[Toxin (Bio)\]" = "orange-c-1",
|
||||
"\[CO2\]" = "black-c-1",
|
||||
"\[Air\]" = "grey-c-1",
|
||||
"\[CAUTION\]" = "yellow-c-1"
|
||||
)
|
||||
var/list/possiblequartcolor = list(
|
||||
"\[N2\]" = "red-c-2",
|
||||
"\[O2\]" = "blue-c-2",
|
||||
"\[Toxin (Bio)\]" = "orange-c-2",
|
||||
"\[CO2\]" = "black-c-2",
|
||||
"\[Air\]" = "grey-c-2",
|
||||
"\[CAUTION\]" = "yellow-c-2"
|
||||
)
|
||||
|
||||
|
||||
var/list/_color //variable that stores colours
|
||||
var/list/decals // list that stores the decals
|
||||
var/list/possibledecals
|
||||
var/list/oldcolor//lists for check_change()
|
||||
var/list/olddecals
|
||||
var/list/possiblemaincolor //these lists contain the possible colors of a canister
|
||||
var/list/possibleseccolor
|
||||
var/list/possibletertcolor
|
||||
var/list/possiblequartcolor
|
||||
var/list/colorcontainer //passed to the ui to render the color lists
|
||||
|
||||
var/can_label = 1
|
||||
var/filled = 0.5
|
||||
pressure_resistance = 7*ONE_ATMOSPHERE
|
||||
@@ -63,43 +32,79 @@
|
||||
var/release_log = ""
|
||||
var/busy = 0
|
||||
var/update_flag = 0
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/sleeping_agent
|
||||
name = "Canister: \[N2O\]"
|
||||
icon_state = "redws"
|
||||
_color = list("redws", null, null, null)
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/nitrogen
|
||||
name = "Canister: \[N2\]"
|
||||
icon_state = "red"
|
||||
_color = list("red", null, null, null)
|
||||
decals = list("plasma")
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/oxygen
|
||||
name = "Canister: \[O2\]"
|
||||
icon_state = "blue"
|
||||
_color = list("blue", null, null, null)
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/toxins
|
||||
name = "Canister \[Toxin (Plasma)\]"
|
||||
icon_state = "orange"
|
||||
_color = list("orange", null, null, null)
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/carbon_dioxide
|
||||
name = "Canister \[CO2\]"
|
||||
icon_state = "black"
|
||||
_color = list("black", null, null, null)
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/air
|
||||
name = "Canister \[Air\]"
|
||||
icon_state = "grey"
|
||||
_color = list("grey", null, null, null)
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/custom_mix
|
||||
name = "Canister \[Custom\]"
|
||||
icon_state = "whiters"
|
||||
_color = list("whiters", null, null, null)
|
||||
can_label = 0
|
||||
|
||||
New()
|
||||
..()
|
||||
_color = list(
|
||||
"prim" = "yellow",
|
||||
"sec" = null,
|
||||
"ter" = null,
|
||||
"quart" = null)
|
||||
oldcolor = list()
|
||||
decals = list()
|
||||
olddecals = list()
|
||||
possibledecals = list( //var that stores all possible decals, used by ui
|
||||
list("name" = "Low temperature canister", "icon" = "cold", "active" = 0),
|
||||
list("name" = "High temperature canister", "icon" = "hot", "active" = 0),
|
||||
list("name" = "Plasma containing canister", "icon" = "plasma", "active" = 0)
|
||||
)
|
||||
possiblemaincolor = list( //these lists contain the possible colors of a canister
|
||||
list("name" = "\[N2O\]", "icon" = "redws"),
|
||||
list("name" = "\[N2\]", "icon" = "red"),
|
||||
list("name" = "\[O2\]", "icon" = "blue"),
|
||||
list("name" = "\[Toxin (Bio)\]", "icon" = "orange"),
|
||||
list("name" = "\[CO2\]", "icon" = "black"),
|
||||
list("name" = "\[Air\]", "icon" = "grey"),
|
||||
list("name" = "\[CAUTION\]", "icon" = "yellow"),
|
||||
list("name" = "\[SPECIAL\]", "icon" = "whiters")
|
||||
)
|
||||
possibleseccolor = list( // no point in having the N2O and "whiters" ones in these lists
|
||||
list("name" = "\[N2\]", "icon" = "red-c"),
|
||||
list("name" = "\[O2\]", "icon" = "blue-c"),
|
||||
list("name" = "\[Toxin (Bio)\]", "icon" = "orange-c"),
|
||||
list("name" = "\[CO2\]", "icon" = "black-c"),
|
||||
list("name" = "\[Air\]", "icon" = "grey-c"),
|
||||
list("name" = "\[CAUTION\]", "icon" = "yellow-c")
|
||||
)
|
||||
possibletertcolor = list(
|
||||
list("name" = "\[N2\]", "icon" = "red-c-1"),
|
||||
list("name" = "\[O2\]", "icon" = "blue-c-1"),
|
||||
list("name" = "\[Toxin (Bio)\]", "icon" = "orange-c-1"),
|
||||
list("name" = "\[CO2\]", "icon" = "black-c-1"),
|
||||
list("name" = "\[Air\]", "icon" = "grey-c-1"),
|
||||
list("name" = "\[CAUTION\]", "icon" = "yellow-c-1")
|
||||
)
|
||||
possiblequartcolor = list(
|
||||
list("name" = "\[N2\]", "icon" = "red-c-2"),
|
||||
list("name" = "\[O2\]", "icon" = "blue-c-2"),
|
||||
list("name" = "\[Toxin (Bio)\]", "icon" = "orange-c-2"),
|
||||
list("name" = "\[CO2\]", "icon" = "black-c-2"),
|
||||
list("name" = "\[Air\]", "icon" = "grey-c-2"),
|
||||
list("name" = "\[CAUTION\]", "icon" = "yellow-c-2")
|
||||
)
|
||||
colorcontainer = list(//passed to the ui to render the color lists
|
||||
"prim" = list(
|
||||
"options" = possiblemaincolor,
|
||||
"name" = "Primary color",
|
||||
"anycolor" = -1,//0: no color applied. 1: color selected. Not used for primary color.
|
||||
),
|
||||
"sec" = list(
|
||||
"options" = possibleseccolor,
|
||||
"name" = "Secondary color",
|
||||
"anycolor" = 0,
|
||||
),
|
||||
"ter" = list(
|
||||
"options" = possibletertcolor,
|
||||
"name" = "Tertiary color",
|
||||
"anycolor" = 0,
|
||||
),
|
||||
"quart" = list(
|
||||
"options" = possiblequartcolor,
|
||||
"name" = "Quaternary color",
|
||||
"anycolor" = 0,
|
||||
)
|
||||
)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/proc/check_change()
|
||||
var/old_flag = update_flag
|
||||
@@ -119,16 +124,14 @@
|
||||
else
|
||||
update_flag |= 32
|
||||
|
||||
if(list2params(oldcolor) == list2params(_color))
|
||||
if(list2params(oldcolor) != list2params(_color))
|
||||
update_flag |= 64
|
||||
else
|
||||
oldcolor = _color
|
||||
|
||||
if(list2params(olddecals) == list2params(decals))
|
||||
oldcolor = _color.Copy()
|
||||
|
||||
if(list2params(olddecals) != list2params(decals))
|
||||
update_flag |= 128
|
||||
else
|
||||
olddecals = decals
|
||||
|
||||
olddecals = decals.Copy()
|
||||
|
||||
if(update_flag == old_flag)
|
||||
return 1
|
||||
else
|
||||
@@ -145,29 +148,30 @@ update_flag
|
||||
32 = tank_pressure go boom.
|
||||
64 = colors
|
||||
128 = decals
|
||||
(note: colors and decals has to be applied every icon update)
|
||||
*/
|
||||
|
||||
if (src.destroyed)
|
||||
src.overlays = 0
|
||||
src.icon_state = text("[]-1", src._color[1])//yes, I KNOW the colours don't reflect when the can's borked, whatever.
|
||||
src.icon_state = text("[]-1", src._color["prim"])//yes, I KNOW the colours don't reflect when the can's borked, whatever.
|
||||
|
||||
if(icon_state != src._color[1])
|
||||
icon_state = src._color[1]
|
||||
if(icon_state != src._color["prim"])
|
||||
icon_state = src._color["prim"]
|
||||
|
||||
if(check_change()) //Returns 1 if no change needed to icons.
|
||||
return
|
||||
|
||||
src.overlays = 0
|
||||
|
||||
if (_color["sec"])//COLORS!
|
||||
overlays.Add(_color["sec"])
|
||||
|
||||
if (_color[2])//COLORS!
|
||||
overlays.Add(_color[2])
|
||||
|
||||
if (_color[3])
|
||||
overlays.Add(_color[3])
|
||||
|
||||
if (_color[4])
|
||||
overlays.Add(_color[4])
|
||||
if (_color["ter"])
|
||||
overlays.Add(_color["ter"])
|
||||
|
||||
if (_color["quart"])
|
||||
overlays.Add(_color["quart"])
|
||||
|
||||
for(var/D in decals)
|
||||
overlays.Add("decal-" + D)
|
||||
|
||||
@@ -183,9 +187,36 @@ update_flag
|
||||
overlays += "can-o2"
|
||||
else if(update_flag & 32)
|
||||
overlays += "can-o3"
|
||||
check_change()//call this here to update the bitflag, incase the canister gets relabeled instantly after again
|
||||
|
||||
update_flag &= ~196 //the flags 128 and 64 represent change, not states. As such, we have to reset them to be able to detect a change on the next go.
|
||||
return
|
||||
|
||||
//template modification exploit prevention, used in Topic()
|
||||
/obj/machinery/portable_atmospherics/canister/proc/is_a_color(var/inputVar, var/checkColor = "all")
|
||||
if (checkColor == "prim" || checkColor == "all")
|
||||
for(var/list/L in possiblemaincolor)
|
||||
if (L["icon"] == inputVar)
|
||||
return 1
|
||||
if (checkColor == "sec" || checkColor == "all")
|
||||
for(var/list/L in possibleseccolor)
|
||||
if (L["icon"] == inputVar)
|
||||
return 1
|
||||
if (checkColor == "ter" || checkColor == "all")
|
||||
for(var/list/L in possibletertcolor)
|
||||
if (L["icon"] == inputVar)
|
||||
return 1
|
||||
if (checkColor == "quart" || checkColor == "all")
|
||||
for(var/list/L in possiblequartcolor)
|
||||
if (L["icon"] == inputVar)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/proc/is_a_decal(var/inputVar)
|
||||
for(var/list/L in possibledecals)
|
||||
if (L["icon"] == inputVar)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/fire_act(datum/gas_mixture/air, exposed_temperature, exposed_volume)
|
||||
if(exposed_temperature > temperature_resistance)
|
||||
health -= 5
|
||||
@@ -337,7 +368,11 @@ update_flag
|
||||
// this is the data which will be sent to the ui
|
||||
var/data[0]
|
||||
data["name"] = name
|
||||
data["menu"] = menu ? 1 : 0
|
||||
data["canLabel"] = can_label ? 1 : 0
|
||||
data["_color"] = _color
|
||||
data["colorContainer"] = colorcontainer
|
||||
data["possibleDecals"] = possibledecals
|
||||
data["portConnected"] = connected_port ? 1 : 0
|
||||
data["tankPressure"] = round(air_contents.return_pressure() ? air_contents.return_pressure() : 0)
|
||||
data["releasePressure"] = round(release_pressure ? release_pressure : 0)
|
||||
@@ -372,6 +407,9 @@ update_flag
|
||||
usr << browse(null, "window=canister")
|
||||
onclose(usr, "canister")
|
||||
return
|
||||
|
||||
if (href_list["choice"] == "menu")
|
||||
menu = text2num(href_list["mode_target"])
|
||||
|
||||
if(href_list["toggle"])
|
||||
if (valve_open)
|
||||
@@ -400,54 +438,97 @@ update_flag
|
||||
release_pressure = min(10*ONE_ATMOSPHERE, release_pressure+diff)
|
||||
else
|
||||
release_pressure = max(ONE_ATMOSPHERE/10, release_pressure+diff)
|
||||
|
||||
if (href_list["relabel"])
|
||||
|
||||
if (href_list["rename"])
|
||||
if (can_label)
|
||||
var/T = copytext(sanitize(input("Choose canister label", "Name", name) as text|null),1,MAX_NAME_LEN)
|
||||
if (can_label) //Exploit prevention
|
||||
if (T)
|
||||
name = T
|
||||
else
|
||||
name = "canister"
|
||||
else
|
||||
usr << "\red As you attempted to rename it the pressure rose!"
|
||||
|
||||
var/label1 = input("Choose canister label", "Primary color") as null|anything in possiblemaincolor
|
||||
|
||||
var/label2 = input("Choose canister label", "Secondary color") as null|anything in possibleseccolor
|
||||
|
||||
var/label3 = input("Choose canister label", "Tertiary color") as null|anything in possibletertcolor
|
||||
|
||||
var/label4 = input("Choose canister label", "Quaternary color") as null|anything in possiblequartcolor
|
||||
|
||||
decals = list()
|
||||
|
||||
_color = list(
|
||||
(label1 ? possiblemaincolor[label1] : color[1]),//if the user didn't specify a primary colour, keep the current one.
|
||||
possibleseccolor[label2],
|
||||
possibletertcolor[label3],
|
||||
possiblequartcolor[label4]
|
||||
)
|
||||
|
||||
decals = list()
|
||||
|
||||
var/list/tempposdecals = list()
|
||||
|
||||
for(var/d in possibledecals)//populate the temp list
|
||||
tempposdecals.Add(d)
|
||||
tempposdecals[d] = possibledecals[d]
|
||||
|
||||
while (src && !src.gc_destroyed && usr)//allow the user to select (theoretically) INFINITE DECALS!!!
|
||||
var/newdecal = input("Choose canister label", "Decal") as anything in tempposdecals
|
||||
if (newdecal == "Done")
|
||||
if (href_list["choice"] == "Primary color")
|
||||
if (is_a_color(href_list["icon"],"prim"))
|
||||
_color["prim"] = href_list["icon"]
|
||||
if (href_list["choice"] == "Secondary color")
|
||||
if (href_list["icon"] == "none")
|
||||
_color["sec"] = ""
|
||||
colorcontainer["sec"]["anycolor"] = 0
|
||||
else if (is_a_color(href_list["icon"],"sec"))
|
||||
_color["sec"] = href_list["icon"]
|
||||
colorcontainer["sec"]["anycolor"] = 1
|
||||
if (href_list["choice"] == "Tertiary color")
|
||||
if (href_list["icon"] == "none")
|
||||
_color["ter"] = ""
|
||||
colorcontainer["ter"]["anycolor"] = 0
|
||||
else if (is_a_color(href_list["icon"],"ter"))
|
||||
_color["ter"] = href_list["icon"]
|
||||
colorcontainer["ter"]["anycolor"] = 1
|
||||
if (href_list["choice"] == "Quaternary color")
|
||||
if (href_list["icon"] == "none")
|
||||
_color["quart"] = ""
|
||||
colorcontainer["quart"]["anycolor"] = 0
|
||||
else if (is_a_color(href_list["icon"],"quart"))
|
||||
_color["quart"] = href_list["icon"]
|
||||
colorcontainer["quart"]["anycolor"] = 1
|
||||
|
||||
if (href_list["choice"] == "decals")
|
||||
if (is_a_decal(href_list["icon"]))
|
||||
for (var/list/L in possibledecals)
|
||||
if (L["icon"] == href_list["icon"])
|
||||
L["active"] = (L["active"] == 0)
|
||||
break
|
||||
decals.Add(tempposdecals[newdecal])
|
||||
tempposdecals.Remove(newdecal)
|
||||
|
||||
src.name = (input("Choose canister label", "Name") as text) + " canister"
|
||||
|
||||
|
||||
|
||||
decals = list()
|
||||
|
||||
for (var/list/L in possibledecals)
|
||||
if (L["active"])
|
||||
if (!(L["icon"] in decals))
|
||||
decals.Add(L["icon"])
|
||||
|
||||
src.add_fingerprint(usr)
|
||||
update_icon()
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/toxins
|
||||
name = "Canister \[Toxin (Plasma)\]"
|
||||
icon_state = "orange" //See New()
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/oxygen
|
||||
name = "Canister: \[O2\]"
|
||||
icon_state = "blue" //See New()
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/sleeping_agent
|
||||
name = "Canister: \[N2O\]"
|
||||
icon_state = "redws" //See New()
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/nitrogen
|
||||
name = "Canister: \[N2\]"
|
||||
icon_state = "red" //See New()
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/carbon_dioxide
|
||||
name = "Canister \[CO2\]"
|
||||
icon_state = "black" //See New()
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/air
|
||||
name = "Canister \[Air\]"
|
||||
icon_state = "grey" //See New()
|
||||
can_label = 0
|
||||
/obj/machinery/portable_atmospherics/canister/custom_mix
|
||||
name = "Canister \[Custom\]"
|
||||
icon_state = "whiters" //See New()
|
||||
can_label = 0
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/toxins/New()
|
||||
|
||||
..()
|
||||
|
||||
|
||||
_color["prim"] = "orange"
|
||||
src.air_contents.toxins = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
air_contents.update_values()
|
||||
|
||||
@@ -455,18 +536,18 @@ update_flag
|
||||
return 1
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/oxygen/New()
|
||||
|
||||
..()
|
||||
|
||||
_color["prim"] = "blue"
|
||||
src.air_contents.oxygen = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
air_contents.update_values()
|
||||
src.update_icon()
|
||||
return 1
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/sleeping_agent/New()
|
||||
|
||||
..()
|
||||
|
||||
|
||||
_color["prim"] = "redws"
|
||||
var/datum/gas/sleeping_agent/trace_gas = new
|
||||
air_contents.trace_gases += trace_gas
|
||||
trace_gas.moles = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
@@ -492,9 +573,11 @@ update_flag
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/nitrogen/New()
|
||||
|
||||
..()
|
||||
|
||||
_color["prim"] = "red"
|
||||
decals = list("plasma")
|
||||
possibledecals[3]["active"] = 1
|
||||
src.air_contents.nitrogen = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
air_contents.update_values()
|
||||
|
||||
@@ -502,8 +585,9 @@ update_flag
|
||||
return 1
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/carbon_dioxide/New()
|
||||
|
||||
..()
|
||||
|
||||
_color["prim"] = "black"
|
||||
src.air_contents.carbon_dioxide = (src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
air_contents.update_values()
|
||||
|
||||
@@ -512,8 +596,9 @@ update_flag
|
||||
|
||||
|
||||
/obj/machinery/portable_atmospherics/canister/air/New()
|
||||
|
||||
..()
|
||||
|
||||
_color["prim"] = "grey"
|
||||
src.air_contents.oxygen = (O2STANDARD*src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
src.air_contents.nitrogen = (N2STANDARD*src.maximum_pressure*filled)*air_contents.volume/(R_IDEAL_GAS_EQUATION*air_contents.temperature)
|
||||
air_contents.update_values()
|
||||
@@ -524,6 +609,7 @@ update_flag
|
||||
/obj/machinery/portable_atmospherics/canister/custom_mix/New()
|
||||
..()
|
||||
|
||||
_color["prim"] = "whiters"
|
||||
src.update_icon() // Otherwise new canisters do not have their icon updated with the pressure light, likely want to add this to the canister class constructor, avoiding at current time to refrain from screwing up code for other canisters. --DZD
|
||||
return 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user