add(colours): Ports matrix/colormate stuff from CHOMP

Original PR: https://github.com/CHOMPStation2/CHOMPStation2/pull/6159
Original Author:
https://github.com/BlackMajor
This commit is contained in:
Runa-Dacino
2024-03-15 17:53:55 +01:00
parent db998502f9
commit 14e1f6abc4
17 changed files with 2321 additions and 143 deletions
+85
View File
@@ -380,3 +380,88 @@
. |= GLOB.bitfields[bitfield][flag]
else
return
/datum/browser/modal/color_matrix_picker
var/color_matrix
/datum/browser/modal/color_matrix_picker/New(mob/user, message, title, button1 = "Ok", button2, button3, stealfocus = TRUE, timeout = 0, list/values)
if(!user)
return
if(!values)
values = list(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)
if(values.len < 12)
values.len = 12
var/list/output = list()
output += "<form><input type='hidden' name='src' value='[REF(src)]'>"
output += "[message]"
#define MATRIX_FIELD(field, default) "<b><label for='[##field]'>[##field]</label></b> <input type='number' step='0.001' name='[field]' value='[default]'>"
output += "<br><br>"
output += MATRIX_FIELD("rr", values[1])
output += MATRIX_FIELD("gr", values[4])
output += MATRIX_FIELD("br", values[7])
output += "<br><br>"
output += MATRIX_FIELD("rg", values[2])
output += MATRIX_FIELD("gg", values[5])
output += MATRIX_FIELD("bg", values[8])
output += "<br><br>"
output += MATRIX_FIELD("rb", values[3])
output += MATRIX_FIELD("gb", values[6])
output += MATRIX_FIELD("bb", values[9])
output += "<br><br>"
output += MATRIX_FIELD("cr", values[10])
output += MATRIX_FIELD("cg", values[11])
output += MATRIX_FIELD("cb", values[12])
output += "<br><br>"
#undef MATRIX_FIELD
output += {"</ul><div style="text-align:center">
<button type="submit" name="button" value="1" style="font-size:large;float:[( button2 ? "left" : "right" )]">[button1]</button>"}
if (button2)
output += {"<button type="submit" name="button" value="2" style="font-size:large;[( button3 ? "" : "float:right" )]">[button2]</button>"}
if (button3)
output += {"<button type="submit" name="button" value="3" style="font-size:large;float:right">[button3]</button>"}
output += {"</form></div>"}
..(user, ckey("[user]-[message]-[title]-[world.time]-[rand(1,10000)]"), title, 800, 400, src, stealfocus, timeout)
set_content(output.Join(""))
/datum/browser/modal/color_matrix_picker/Topic(href, list/href_list)
if(href_list["close"] || !user)
opentime = 0
return
if(href_list["button"])
var/button = text2num(href_list["button"])
if(ISINRANGE(button, 1, 3))
selectedbutton = button
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"])
)
if(cm)
color_matrix = cm
opentime = 0
close()
/proc/color_matrix_picker(mob/user, message, title, button1 = "Ok", button2, button3, stealfocus, timeout = 10 MINUTES, list/values)
if(!istype(user))
if(istype(user, /client))
var/client/C = user
user = C.mob
else
return
var/datum/browser/modal/color_matrix_picker/B = new(user, message, title, button1, button2, button3, stealfocus, timeout, values)
B.open()
B.wait()
return list("button" = B.selectedbutton, "matrix" = B.color_matrix)
+143
View File
@@ -0,0 +1,143 @@
/**
* hey, remember mutable appearance?
*
* only:
* - this isn't a real object rather than a struct
* - i'm making a cast for it so we can VV it
* - this is also used to cast procs that operate on appearance-like things.
*
* Sue me, I need to debug things somehow
*
* DO NOT USE THESE UNLESS YOU KNOW WHAT YOU ARE DOING.
*/
/appearance
var/alpha
var/appearance_flags
var/blend_mode
var/color
var/desc
var/dir
var/gender
var/icon
var/icon_state
var/invisibility
var/infra_luminosity
var/list/filters
var/layer
var/luminosity
var/maptext
var/maptext_width
var/maptext_height
var/maptext_x
var/maptext_y
var/mouse_over_pointer
var/mouse_drag_pointer
var/mouse_drop_pointer
var/mouse_drop_zone
var/mouse_opacity
var/name
var/opacity
var/list/overlays
var/override
var/pixel_x
var/pixel_y
var/pixel_w
var/pixel_z
var/plane
var/render_source
var/render_target
var/suffix
var/text
var/transform
var/list/underlays
// var/vis_flags
//! vis_flags missing even though byond ref says it's there, fuck off why is this possible
GLOBAL_REAL_VAR(_appearance_var_list) = list(
"alpha",
"appearance_flags",
"blend_mode",
"color",
"desc",
"dir",
"gender",
"icon",
"icon_state",
"invisibility",
"infra_luminosity",
"filters",
"layer",
"luminosity",
"maptext",
"maptext_width",
"maptext_height",
"maptext_x",
"maptext_y",
"mouse_over_pointer",
"mouse_drag_pointer",
"mouse_drop_pointer",
"mouse_drop_zone",
"mouse_opacity",
"name",
"opacity",
"overlays",
"override",
"pixel_x",
"pixel_y",
"pixel_w",
"pixel_z",
"plane",
"render_source",
"render_target",
"suffix",
"text",
"transform",
"underlays"
// "vis_flags"
)
/proc/__appearance_v_debug(appearance/A, name)
switch(name)
#define DEBUG_APPEARANCE_VAR(n) if(#n) return debug_variable(name, A.n, 0, null)
DEBUG_APPEARANCE_VAR(alpha)
DEBUG_APPEARANCE_VAR(appearance_flags)
DEBUG_APPEARANCE_VAR(blend_mode)
DEBUG_APPEARANCE_VAR(color)
DEBUG_APPEARANCE_VAR(desc)
DEBUG_APPEARANCE_VAR(dir)
DEBUG_APPEARANCE_VAR(gender)
DEBUG_APPEARANCE_VAR(icon)
DEBUG_APPEARANCE_VAR(icon_state)
DEBUG_APPEARANCE_VAR(invisibility)
DEBUG_APPEARANCE_VAR(infra_luminosity)
DEBUG_APPEARANCE_VAR(filters)
DEBUG_APPEARANCE_VAR(layer)
DEBUG_APPEARANCE_VAR(luminosity)
DEBUG_APPEARANCE_VAR(maptext)
DEBUG_APPEARANCE_VAR(maptext_width)
DEBUG_APPEARANCE_VAR(maptext_height)
DEBUG_APPEARANCE_VAR(maptext_x)
DEBUG_APPEARANCE_VAR(maptext_y)
DEBUG_APPEARANCE_VAR(mouse_over_pointer)
DEBUG_APPEARANCE_VAR(mouse_drag_pointer)
DEBUG_APPEARANCE_VAR(mouse_drop_pointer)
DEBUG_APPEARANCE_VAR(mouse_drop_zone)
DEBUG_APPEARANCE_VAR(mouse_opacity)
DEBUG_APPEARANCE_VAR(name)
DEBUG_APPEARANCE_VAR(opacity)
DEBUG_APPEARANCE_VAR(overlays)
DEBUG_APPEARANCE_VAR(override)
DEBUG_APPEARANCE_VAR(pixel_x)
DEBUG_APPEARANCE_VAR(pixel_y)
DEBUG_APPEARANCE_VAR(pixel_w)
DEBUG_APPEARANCE_VAR(pixel_z)
DEBUG_APPEARANCE_VAR(plane)
DEBUG_APPEARANCE_VAR(render_source)
DEBUG_APPEARANCE_VAR(render_target)
DEBUG_APPEARANCE_VAR(suffix)
DEBUG_APPEARANCE_VAR(text)
DEBUG_APPEARANCE_VAR(transform)
DEBUG_APPEARANCE_VAR(underlays)
// DEBUG_APPEARANCE_VAR(vis_flags)
#undef DEBUG_APPEARANCE_VAR