Upload files
This commit is contained in:
+145
-116
@@ -23,6 +23,8 @@
|
||||
/obj/item/storage/backpack,
|
||||
/obj/item/storage/belt
|
||||
)
|
||||
/// Temporary messages
|
||||
var/temp
|
||||
|
||||
/obj/machinery/gear_painter/Initialize(mapload)
|
||||
. = ..()
|
||||
@@ -69,6 +71,8 @@
|
||||
if(!QDELETED(H))
|
||||
H.release()
|
||||
insert_mob(victim, user)
|
||||
temp = "[victim] has been inserted."
|
||||
SStgui.update_uis(src)
|
||||
|
||||
if(is_type_in_list(I, allowed_types) && is_operational())
|
||||
if(!user.transferItemToLoc(I, src))
|
||||
@@ -80,6 +84,9 @@
|
||||
|
||||
inserted = I
|
||||
update_icon()
|
||||
temp = "[I] has been inserted."
|
||||
SStgui.update_uis(src)
|
||||
|
||||
else
|
||||
return ..()
|
||||
|
||||
@@ -101,137 +108,159 @@
|
||||
|
||||
/obj/machinery/gear_painter/AltClick(mob/user)
|
||||
. = ..()
|
||||
if(!user.CanReach(src))
|
||||
drop_item()
|
||||
|
||||
/obj/machinery/gear_painter/proc/drop_item()
|
||||
if(!usr.CanReach(src))
|
||||
return
|
||||
if(!inserted)
|
||||
return
|
||||
to_chat(user, "<span class='notice'>You remove [inserted] from [src]")
|
||||
to_chat(usr, "<span class='notice'>You remove [inserted] from [src]")
|
||||
inserted.forceMove(drop_location())
|
||||
var/mob/living/user = usr
|
||||
if(istype(user))
|
||||
user.put_in_hands(inserted)
|
||||
inserted = null
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
SStgui.update_uis(src)
|
||||
|
||||
/obj/machinery/gear_painter/ui_interact(mob/user)
|
||||
if(!is_operational())
|
||||
return
|
||||
user.set_machine(src)
|
||||
var/list/dat = list("<TITLE>Color Mate Control Panel</TITLE><BR>")
|
||||
if(!inserted)
|
||||
dat += "No item inserted."
|
||||
/obj/machinery/gear_painter/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
if(!ui)
|
||||
ui = new(user, src, "Colormate", src.name)
|
||||
ui.set_autoupdate(FALSE) //This might be a bit intensive, better to not update it every few ticks
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/gear_painter/ui_data(mob/user)
|
||||
. = list()
|
||||
.["matrixactive"] = matrix_mode
|
||||
.["matrixcolors"] = list(
|
||||
"rr" = color_matrix_last[1],
|
||||
"rg" = color_matrix_last[2],
|
||||
"rb" = color_matrix_last[3],
|
||||
"gr" = color_matrix_last[4],
|
||||
"gg" = color_matrix_last[5],
|
||||
"gb" = color_matrix_last[6],
|
||||
"br" = color_matrix_last[7],
|
||||
"bg" = color_matrix_last[8],
|
||||
"bb" = color_matrix_last[9],
|
||||
"cr" = color_matrix_last[10],
|
||||
"cg" = color_matrix_last[11],
|
||||
"cb" = color_matrix_last[12]
|
||||
)
|
||||
if(temp)
|
||||
.["temp"] = temp
|
||||
if(inserted)
|
||||
.["item"] = list()
|
||||
.["item"]["name"] = inserted.name
|
||||
.["item"]["sprite"] = icon2base64(getFlatIcon(inserted,defdir=SOUTH,no_anim=TRUE))
|
||||
.["item"]["preview"] = icon2base64(build_preview())
|
||||
else
|
||||
dat += "Item inserted: [inserted]<HR>"
|
||||
dat += "<a href='?src=[REF(src)];toggle_matrix_mode=1'>Matrix mode: [matrix_mode? "On" : "Off"]</a>"
|
||||
if(!matrix_mode)
|
||||
dat += "<A href='?src=\ref[src];select=1'>Select new color.</A><BR>"
|
||||
dat += "Color: <font color='[activecolor]'>⚫</font>"
|
||||
dat += "<A href='?src=\ref[src];paint=1'>Apply new color.</A><BR><BR>"
|
||||
.["item"] = null
|
||||
|
||||
/obj/machinery/gear_painter/ui_act(action, params)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
if(inserted)
|
||||
switch(action)
|
||||
if("switch_modes")
|
||||
matrix_mode = text2num(params["mode"])
|
||||
return TRUE
|
||||
if("choose_color")
|
||||
var/chosen_color = input(usr, "Choose a color: ", "Colormate color picking", activecolor) as color|null
|
||||
if(chosen_color)
|
||||
activecolor = chosen_color
|
||||
return TRUE
|
||||
if("paint")
|
||||
if(!check_valid_color(activecolor, usr))
|
||||
return TRUE
|
||||
inserted.add_atom_colour(activecolor, FIXED_COLOUR_PRIORITY)
|
||||
playsound(src, 'sound/effects/spray3.ogg', 50, 1)
|
||||
temp = "Painted Successfully!"
|
||||
return TRUE
|
||||
if("drop")
|
||||
temp = "Ejected \the [inserted]!"
|
||||
drop_item()
|
||||
return TRUE
|
||||
if("clear")
|
||||
inserted.remove_atom_colour(FIXED_COLOUR_PRIORITY)
|
||||
playsound(src, 'sound/effects/spray3.ogg', 50, 1)
|
||||
temp = "Cleared Successfully!"
|
||||
return TRUE
|
||||
if("set_matrix_color")
|
||||
color_matrix_last[params["color"]] = params["value"]
|
||||
return TRUE
|
||||
if("matrix_paint")
|
||||
var/list/cm = rgb_construct_color_matrix(
|
||||
text2num(color_matrix_last[1]),
|
||||
text2num(color_matrix_last[2]),
|
||||
text2num(color_matrix_last[3]),
|
||||
text2num(color_matrix_last[4]),
|
||||
text2num(color_matrix_last[5]),
|
||||
text2num(color_matrix_last[6]),
|
||||
text2num(color_matrix_last[7]),
|
||||
text2num(color_matrix_last[8]),
|
||||
text2num(color_matrix_last[9]),
|
||||
text2num(color_matrix_last[10]),
|
||||
text2num(color_matrix_last[11]),
|
||||
text2num(color_matrix_last[12])
|
||||
)
|
||||
if(!check_valid_color(cm, usr))
|
||||
return TRUE
|
||||
inserted.add_atom_colour(cm, FIXED_COLOUR_PRIORITY)
|
||||
playsound(src, 'sound/effects/spray3.ogg', 50, 1)
|
||||
temp = "Matrix Painted Successfully!"
|
||||
return TRUE
|
||||
|
||||
/// Produces the preview image of the item, used in the UI, the way the color is not stacking is a sin.
|
||||
/obj/machinery/gear_painter/proc/build_preview()
|
||||
if(inserted) //sanity
|
||||
if(matrix_mode)
|
||||
var/list/cm = rgb_construct_color_matrix(
|
||||
text2num(color_matrix_last[1]),
|
||||
text2num(color_matrix_last[2]),
|
||||
text2num(color_matrix_last[3]),
|
||||
text2num(color_matrix_last[4]),
|
||||
text2num(color_matrix_last[5]),
|
||||
text2num(color_matrix_last[6]),
|
||||
text2num(color_matrix_last[7]),
|
||||
text2num(color_matrix_last[8]),
|
||||
text2num(color_matrix_last[9]),
|
||||
text2num(color_matrix_last[10]),
|
||||
text2num(color_matrix_last[11]),
|
||||
text2num(color_matrix_last[12])
|
||||
)
|
||||
if(!check_valid_color(cm, usr))
|
||||
temp = "Failed to generate preview: Invalid color!"
|
||||
return getFlatIcon(inserted, defdir=SOUTH, no_anim=TRUE)
|
||||
|
||||
var/cur_color = inserted.color
|
||||
inserted.color = null
|
||||
inserted.color = cm
|
||||
var/icon/preview = getFlatIcon(inserted, defdir=SOUTH, no_anim=TRUE)
|
||||
inserted.color = cur_color
|
||||
|
||||
. = preview
|
||||
|
||||
else
|
||||
// POGGERS
|
||||
#define MATRIX_FIELD(field, default) "<b><label for='[##field]'>[##field]</label></b> <input type='number' step='0.001' name='[field]' value='[default]'>"
|
||||
dat += "<br><form name='matrix paint' action='?src=[REF(src)]'>"
|
||||
dat += "<input type='hidden' name='src' value='[REF(src)]'>"
|
||||
dat += "<input type='hidden' name='matrix_paint' value='1'"
|
||||
dat += "<br><br>"
|
||||
dat += MATRIX_FIELD("rr", color_matrix_last[1])
|
||||
dat += MATRIX_FIELD("gr", color_matrix_last[4])
|
||||
dat += MATRIX_FIELD("br", color_matrix_last[7])
|
||||
dat += "<br><br>"
|
||||
dat += MATRIX_FIELD("rg", color_matrix_last[2])
|
||||
dat += MATRIX_FIELD("gg", color_matrix_last[5])
|
||||
dat += MATRIX_FIELD("bg", color_matrix_last[8])
|
||||
dat += "<br><br>"
|
||||
dat += MATRIX_FIELD("rb", color_matrix_last[3])
|
||||
dat += MATRIX_FIELD("gb", color_matrix_last[6])
|
||||
dat += MATRIX_FIELD("bb", color_matrix_last[9])
|
||||
dat += "<br><br>"
|
||||
dat += MATRIX_FIELD("cr", color_matrix_last[10])
|
||||
dat += MATRIX_FIELD("cg", color_matrix_last[11])
|
||||
dat += MATRIX_FIELD("cb", color_matrix_last[12])
|
||||
dat += "<br><br>"
|
||||
dat += "<input type='submit' value='Matrix Paint'>"
|
||||
dat += "</form><br>"
|
||||
#undef MATRIX_FIELD
|
||||
dat += "<A href='?src=\ref[src];clear=1'>Remove paintjob.</A><BR><BR>"
|
||||
dat += "<A href='?src=\ref[src];eject=1'>Eject item.</A><BR><BR>"
|
||||
if(!check_valid_color(activecolor, usr))
|
||||
temp = "Failed to generate preview: Invalid color!"
|
||||
return getFlatIcon(inserted, defdir=SOUTH, no_anim=TRUE)
|
||||
|
||||
var/datum/browser/menu = new(user, "colormate","Color Mate Control Panel", 800, 600, src)
|
||||
menu.set_content(dat.Join(""))
|
||||
menu.open()
|
||||
var/cur_color = inserted.color
|
||||
inserted.color = null
|
||||
inserted.color = activecolor
|
||||
var/icon/preview = getFlatIcon(inserted, defdir=SOUTH, no_anim=TRUE)
|
||||
inserted.color = cur_color
|
||||
|
||||
/obj/machinery/gear_painter/Topic(href, href_list)
|
||||
if((. = ..()))
|
||||
return
|
||||
|
||||
add_fingerprint(usr)
|
||||
|
||||
if(href_list["close"])
|
||||
usr << browse(null, "window=colormate")
|
||||
return
|
||||
|
||||
if(href_list["select"])
|
||||
var/newcolor = input(usr, "Choose a color.", "", activecolor) as color|null
|
||||
if(newcolor)
|
||||
activecolor = newcolor
|
||||
updateUsrDialog()
|
||||
|
||||
if(href_list["paint"])
|
||||
if(!inserted)
|
||||
return
|
||||
if(!check_valid_color(activecolor, usr))
|
||||
return
|
||||
inserted.add_atom_colour(activecolor, FIXED_COLOUR_PRIORITY)
|
||||
playsound(src, 'sound/effects/spray3.ogg', 50, 1)
|
||||
updateUsrDialog()
|
||||
|
||||
if(href_list["toggle_matrix_mode"])
|
||||
matrix_mode = !matrix_mode
|
||||
updateUsrDialog()
|
||||
|
||||
if(href_list["matrix_paint"])
|
||||
if(!inserted)
|
||||
return
|
||||
// assemble matrix
|
||||
var/list/cm = rgb_construct_color_matrix(
|
||||
text2num(href_list["rr"]),
|
||||
text2num(href_list["rg"]),
|
||||
text2num(href_list["rb"]),
|
||||
text2num(href_list["gr"]),
|
||||
text2num(href_list["gg"]),
|
||||
text2num(href_list["gb"]),
|
||||
text2num(href_list["br"]),
|
||||
text2num(href_list["bg"]),
|
||||
text2num(href_list["bb"]),
|
||||
text2num(href_list["cr"]),
|
||||
text2num(href_list["cg"]),
|
||||
text2num(href_list["cb"])
|
||||
)
|
||||
color_matrix_last = cm.Copy()
|
||||
if(!check_valid_color(cm, usr))
|
||||
return
|
||||
inserted.add_atom_colour(cm, FIXED_COLOUR_PRIORITY)
|
||||
playsound(src, 'sound/effects/spray3.ogg', 50, 1)
|
||||
updateUsrDialog()
|
||||
|
||||
if(href_list["clear"])
|
||||
if(!inserted)
|
||||
return
|
||||
inserted.remove_atom_colour(FIXED_COLOUR_PRIORITY)
|
||||
playsound(src, 'sound/effects/spray3.ogg', 50, 1)
|
||||
updateUsrDialog()
|
||||
|
||||
if(href_list["eject"])
|
||||
if(!inserted)
|
||||
return
|
||||
inserted.forceMove(drop_location())
|
||||
inserted = null
|
||||
update_icon()
|
||||
updateUsrDialog()
|
||||
. = preview
|
||||
|
||||
/obj/machinery/gear_painter/proc/check_valid_color(list/cm, mob/user)
|
||||
if(!islist(cm)) // normal
|
||||
var/list/HSV = ReadHSV(RGBtoHSV(cm))
|
||||
if(HSV[3] < minimum_normal_lightness)
|
||||
to_chat(user, "<span class='warning'>[cm] is far too dark (min lightness [minimum_normal_lightness]!</span>")
|
||||
temp = "[cm] is far too dark (min lightness [minimum_normal_lightness]!"
|
||||
return FALSE
|
||||
return TRUE
|
||||
else // matrix
|
||||
@@ -245,6 +274,6 @@
|
||||
COLORTEST("FFFFFF", cm)
|
||||
#undef COLORTEST
|
||||
if(passed < minimum_matrix_tests)
|
||||
to_chat(user, "<span class='warning'>[english_list(color)] is not allowed (pased [passed] out of 4, minimum [minimum_matrix_tests], minimum lightness [minimum_matrix_lightness]).</span>")
|
||||
temp = "[english_list(color)] is not allowed (passed [passed] out of 4, minimum [minimum_matrix_tests], minimum lightness [minimum_matrix_lightness])."
|
||||
return FALSE
|
||||
return TRUE
|
||||
|
||||
@@ -200,6 +200,9 @@ GLOBAL_DATUM_INIT(crewmonitor, /datum/crewmonitor, new)
|
||||
return b["totaldam"] - a["totaldam"]
|
||||
|
||||
/datum/crewmonitor/ui_act(action,params)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
var/mob/living/silicon/ai/AI = usr
|
||||
if(!istype(AI))
|
||||
return
|
||||
|
||||
@@ -86,6 +86,9 @@
|
||||
.["machine"]["chang_freq_value"] = change_freq_value
|
||||
|
||||
/obj/machinery/telecomms/ui_act(action, params, datum/tgui/ui)
|
||||
. = ..()
|
||||
if(.)
|
||||
return
|
||||
if(!canInteract(usr))
|
||||
if(ui)
|
||||
ui.close() //haha no.
|
||||
|
||||
Reference in New Issue
Block a user