This commit is contained in:
BlackMajor
2023-04-30 21:39:18 +12:00
parent 8730bd6b0f
commit 65a5644b02
13 changed files with 601 additions and 90 deletions

View File

@@ -642,4 +642,20 @@ world
//Images have dir without being an atom, so they get their own definition.
//Lame.
/image/proc/setDir(newdir)
dir = newdir
dir = newdir
/* Gives the result RGB of a RGB string after a matrix transformation. No alpha.
* Input: rr, rg, rb, gr, gg, gb, br, bg, bb, cr, cg, cb
* Output: RGB string
*/
/proc/RGBMatrixTransform(list/color, list/cm)
ASSERT(cm.len >= 9)
if(cm.len < 12) // fill in the rest
for(var/i in 1 to (12 - cm.len))
cm += 0
if(!islist(color))
color = ReadRGB(color)
color[1] = color[1] * cm[1] + color[2] * cm[2] + color[3] * cm[3] + cm[10] * 255
color[2] = color[1] * cm[4] + color[2] * cm[5] + color[3] * cm[6] + cm[11] * 255
color[3] = color[1] * cm[7] + color[2] * cm[8] + color[3] * cm[9] + cm[12] * 255
return rgb(color[1], color[2], color[3])

View File

@@ -40,7 +40,14 @@
/datum/gear_tweak/color/tweak_item(var/obj/item/I, var/metadata)
if(valid_colors && !(metadata in valid_colors))
return
I.color = metadata
//CHOMPEdit start
if(!metadata || (metadata == "#ffffff"))
return
if(istype(I))
I.add_atom_colour(metadata, FIXED_COLOUR_PRIORITY)
else
I.color = metadata // fuck off underwear
//CHOMPEdit end
/*
* Path adjustment

View File

@@ -264,7 +264,7 @@ var/list/gear_datums = list()
if(!description)
var/obj/O = path
description = initial(O.desc)
gear_tweaks = list(gear_tweak_free_name, gear_tweak_free_desc, gear_tweak_item_tf_spawn) //CHOMPEdit - Item TF spawnpoints
gear_tweaks = list(gear_tweak_free_name, gear_tweak_free_desc, gear_tweak_item_tf_spawn, GLOB.gear_tweak_free_matrix_recolor) //CHOMPEdit - Item TF spawnpoints
/datum/gear_data
var/path

View File

@@ -27,7 +27,7 @@
var/icon/west = get_flat_icon(N, WEST, no_anim = no_anim)
qdel(N)
//Starts with a blank icon because of byond bugs.
var/icon/full = icon('icons/system/blank_32x32.dmi', "")
var/icon/full = icon('modular_chomp/icons/system/blank_32x32.dmi', "")
full.Insert(north, dir = NORTH)
full.Insert(south, dir = SOUTH)
full.Insert(east, dir = EAST)
@@ -45,7 +45,7 @@
/proc/_get_flat_icon(image/A, defdir, no_anim, deficon, start)
// start with blank image
var/static/icon/template = icon('icons/system/blank_32x32.dmi', "")
var/static/icon/template = icon('modular_chomp/icons/system/blank_32x32.dmi', "")
#define BLANK icon(template)

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

View File

@@ -5,7 +5,7 @@
/obj/machinery/gear_painter
name = "Color Mate"
desc = "A machine to give your apparel a fresh new color!"
icon = 'icons/obj/vending.dmi'
icon = 'icons/obj/vending_vr.dmi'
icon_state = "colormate"
density = TRUE
anchored = TRUE
@@ -71,31 +71,27 @@
if(default_unfasten_wrench(user, I, 40))
return
if(allow_mobs && istype(I, /obj/item/weapon/holder))
var/obj/item/holder/H = I
var/mob/victim = H.held_mob
if(!user.attempt_insert_item_for_installation(I, src))
return
if(!QDELETED(H))
H.drop_items()
insert_mob(victim, user)
SStgui.update_uis(src)
if(is_type_in_list(I, allowed_types) && !inoperable())
if(!user.attempt_insert_item_for_installation(I, src))
return
if(QDELETED(I))
return
user.visible_message(SPAN_NOTICE("[user] inserts [I] into [src]'s receptable."))
user.visible_message("<span class='notice'>[user] inserts \the [I] into the Color Mate receptable.</span>")
user.drop_from_inventory(I)
I.forceMove(src)
inserted = I
update_icon()
SStgui.update_uis(src)
else
return ..()
/obj/machinery/gear_painter/attack_hand(mob/user)
if(..())
return
tgui_interact(user)
/obj/machinery/gear_painter/tgui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "ColorMate", name)
ui.open()
/obj/machinery/gear_painter/proc/insert_mob(mob/victim, mob/user)
if(inserted)
return
@@ -137,7 +133,7 @@
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)
/obj/machinery/gear_painter/tgui_data(mob/user)
. = list()
.["activemode"] = active_mode
.["matrixcolors"] = list(
@@ -167,7 +163,7 @@
else
.["item"] = null
/obj/machinery/gear_painter/ui_act(action, params)
/obj/machinery/gear_painter/tgui_act(action, params)
. = ..()
if(.)
return

View File

@@ -63,3 +63,39 @@ var/datum/gear_tweak/item_tf_spawn/gear_tweak_item_tf_spawn = new()
return
I.spawn_mob_type = simplemob_list[metadata]
I.spawn_mob_name = metadata
GLOBAL_DATUM_INIT(gear_tweak_free_matrix_recolor, /datum/gear_tweak/matrix_recolor, new)
/datum/gear_tweak/matrix_recolor
/datum/gear_tweak/matrix_recolor/get_contents(var/metadata)
if(islist(metadata) && length(metadata))
return "Matrix Recolor: [english_list(metadata)]"
return "Matrix Recolor"
/datum/gear_tweak/matrix_recolor/get_default()
return null
/datum/gear_tweak/matrix_recolor/get_metadata(user, metadata)
var/list/returned = color_matrix_picker(user, "Pick a color matrix for this item", "Matrix Recolor", "Ok", "Erase", "Cancel", TRUE, 10 MINUTES, islist(metadata) && metadata)
var/list/L = returned["matrix"]
if(returned["button"] == 3)
return metadata
if((returned["button"] == 2) || !islist(L) || !ISINRANGE(L.len, 9, 20))
return list()
var/identity = TRUE
var/static/list/ones = list(1, 5, 9)
for(var/i in 1 to L.len)
if(L[i] != ((i in ones)? 1 : 0))
identity = FALSE
break
return identity? list() : L
/datum/gear_tweak/matrix_recolor/tweak_item(obj/item/I, metadata)
. = ..()
if(!islist(metadata) || (length(metadata) < 12))
return
if(istype(I))
I.add_atom_colour(metadata, FIXED_COLOUR_PRIORITY)
else
I.color = metadata // fuck off underwear

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

View File

@@ -0,0 +1,371 @@
import { useBackend } from '../backend';
import { Button, Icon, NoticeBox, NumberInput, Section, Table, Tabs, Slider } from '../components';
import { Window } from '../layouts';
export const ColorMate = (props, context) => {
const { act, data } = useBackend(context);
const { activemode, temp } = data;
const item = data.item || [];
return (
<Window width="980" height="720" resizable>
<Window.Content overflow="auto">
<Section>
{temp ? <NoticeBox>{temp}</NoticeBox> : null}
{Object.keys(item).length ? (
<>
<Table>
<Table.Cell width="50%">
<Section>
<center>Item:</center>
<img
src={'data:image/jpeg;base64, ' + item.sprite}
width="100%"
height="100%"
style={{
'-ms-interpolation-mode': 'nearest-neighbor',
}}
/>
</Section>
</Table.Cell>
<Table.Cell>
<Section>
<center>Preview:</center>
<img
src={'data:image/jpeg;base64, ' + item.preview}
width="100%"
height="100%"
style={{
'-ms-interpolation-mode': 'nearest-neighbor',
}}
/>
</Section>
</Table.Cell>
</Table>
<Tabs fluid>
<Tabs.Tab
key="1"
selected={activemode === 1}
onClick={() =>
act('switch_modes', {
mode: 1,
})
}>
Tint coloring (Simple)
</Tabs.Tab>
<Tabs.Tab
key="2"
selected={activemode === 2}
onClick={() =>
act('switch_modes', {
mode: 2,
})
}>
HSV coloring (Normal)
</Tabs.Tab>
<Tabs.Tab
key="3"
selected={activemode === 3}
onClick={() =>
act('switch_modes', {
mode: 3,
})
}>
Matrix coloring (Advanced)
</Tabs.Tab>
</Tabs>
<center>Coloring: {item.name}</center>
<Table mt={1}>
<Table.Cell width="33%">
<Button fluid content="Paint" icon="fill" onClick={() => act('paint')} />
<Button fluid content="Clear" icon="eraser" onClick={() => act('clear')} />
<Button fluid content="Eject" icon="eject" onClick={() => act('drop')} />
</Table.Cell>
<Table.Cell width="66%">
{activemode === 1 ? <ColorMateTint /> : activemode === 2 ? <ColorMateHSV /> : <ColorMateMatrix />}
</Table.Cell>
</Table>
</>
) : (
<center>No item inserted.</center>
)}
</Section>
</Window.Content>
</Window>
);
};
export const ColorMateTint = (props, context) => {
const { act, data } = useBackend(context);
return <Button fluid content="Select new color" icon="paint-brush" onClick={() => act('choose_color')} />;
};
export const ColorMateMatrix = (props, context) => {
const { act, data } = useBackend(context);
const matrixcolors = data.matrixcolors || [];
return (
<Table>
<Table.Cell>
<Table.Row>
RR:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.rr}
onChange={(e, value) =>
act('set_matrix_color', {
color: 1,
value,
})
}
/>
</Table.Row>
<Table.Row>
GR:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.gr}
onChange={(e, value) =>
act('set_matrix_color', {
color: 4,
value,
})
}
/>
</Table.Row>
<Table.Row>
BR:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.br}
onChange={(e, value) =>
act('set_matrix_color', {
color: 7,
value,
})
}
/>
</Table.Row>
</Table.Cell>
<Table.Cell>
<Table.Row>
RG:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.rg}
onChange={(e, value) =>
act('set_matrix_color', {
color: 2,
value,
})
}
/>
</Table.Row>
<Table.Row>
GG:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.gg}
onChange={(e, value) =>
act('set_matrix_color', {
color: 5,
value,
})
}
/>
</Table.Row>
<Table.Row>
BG:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.bg}
onChange={(e, value) =>
act('set_matrix_color', {
color: 8,
value,
})
}
/>
</Table.Row>
</Table.Cell>
<Table.Cell>
<Table.Row>
RB:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.rb}
onChange={(e, value) =>
act('set_matrix_color', {
color: 3,
value,
})
}
/>
</Table.Row>
<Table.Row>
GB:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.gb}
onChange={(e, value) =>
act('set_matrix_color', {
color: 6,
value,
})
}
/>
</Table.Row>
<Table.Row>
BB:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.bb}
onChange={(e, value) =>
act('set_matrix_color', {
color: 9,
value,
})
}
/>
</Table.Row>
</Table.Cell>
<Table.Cell>
<Table.Row>
CR:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.cr}
onChange={(e, value) =>
act('set_matrix_color', {
color: 10,
value,
})
}
/>
</Table.Row>
<Table.Row>
CG:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.cg}
onChange={(e, value) =>
act('set_matrix_color', {
color: 11,
value,
})
}
/>
</Table.Row>
<Table.Row>
CB:{' '}
<NumberInput
width="50px"
minValue={-10}
maxValue={10}
step={0.01}
value={matrixcolors.cb}
onChange={(e, value) =>
act('set_matrix_color', {
color: 12,
value,
})
}
/>
</Table.Row>
</Table.Cell>
<Table.Cell width="40%">
<Icon name="question-circle" color="blue" /> RG means red will become this much green.
<br />
<Icon name="question-circle" color="blue" /> CR means this much red will be added.
</Table.Cell>
</Table>
);
};
export const ColorMateHSV = (props, context) => {
const { act, data } = useBackend(context);
const { buildhue, buildsat, buildval } = data;
return (
<Table>
<Table.Row>
<center>Hue:</center>
<Table.Cell width="85%">
<Slider
minValue={0}
maxValue={360}
step={1}
value={buildhue}
onDrag={(e, value) =>
act('set_hue', {
buildhue: value,
})
}
/>
</Table.Cell>
</Table.Row>
<Table.Row>
<center>Saturation:</center>
<Table.Cell>
<Slider
minValue={-10}
maxValue={10}
step={0.01}
value={buildsat}
onDrag={(e, value) =>
act('set_sat', {
buildsat: value,
})
}
/>
</Table.Cell>
</Table.Row>
<Table.Row>
<center>Value:</center>
<Table.Cell>
<Slider
minValue={-10}
maxValue={10}
step={0.01}
value={buildval}
onDrag={(e, value) =>
act('set_val', {
buildval: value,
})
}
/>
</Table.Cell>
</Table.Row>
</Table>
);
};

View File

@@ -1,60 +0,0 @@
import { Fragment } from 'inferno';
import { useBackend } from '../backend';
import { Box, Button, Flex, Section } from '../components';
import { Window } from '../layouts';
type Data = {
items;
activecolor: string;
};
export const ColorMate = (props, context) => {
const { act, data } = useBackend<Data>(context);
const { items, activecolor } = data;
let height = Math.min(270 + items.length * 15, 600);
return (
<Window width={300} height={height} resizable>
<Window.Content>
{(items.length && (
<Fragment>
<Section title="Paint">
<Flex justify="center" align="center">
<Flex.Item basis="50%">
<Box backgroundColor={activecolor} width="120px" height="120px" />
</Flex.Item>
<Flex.Item basis="50% ">
<Button fluid icon="eye-dropper" onClick={() => act('select')}>
Select Color
</Button>
<Button fluid icon="fill-drip" onClick={() => act('paint')}>
Paint Items
</Button>
<Button fluid icon="tint-slash" onClick={() => act('clear')}>
Remove Paintjob
</Button>
<Button fluid icon="eject" onClick={() => act('eject')}>
Eject Items
</Button>
</Flex.Item>
</Flex>
</Section>
<Section title="Items">
{items.map((item, i) => (
<Box key={i}>
#{i + 1}: {item}
</Box>
))}
</Section>
</Fragment>
)) || (
<Section>
<Box color="bad">No items inserted.</Box>
</Section>
)}
</Window.Content>
</Window>
);
};

File diff suppressed because one or more lines are too long

View File

@@ -43,6 +43,7 @@
#include "code\__defines\chemistry.dm"
#include "code\__defines\chemistry_vr.dm"
#include "code\__defines\color.dm"
#include "code\__defines\color_priority.dm"
#include "code\__defines\construction.dm"
#include "code\__defines\cooldowns.dm"
#include "code\__defines\crafting.dm"
@@ -2021,7 +2022,6 @@
#include "code\modules\client\preference_setup\global\04_ooc.dm"
#include "code\modules\client\preference_setup\global\setting_datums.dm"
#include "code\modules\client\preference_setup\loadout\gear_tweaks.dm"
#include "code\modules\client\preference_setup\loadout\gear_tweaks_ch.dm"
#include "code\modules\client\preference_setup\loadout\gear_tweaks_vr.dm"
#include "code\modules\client\preference_setup\loadout\loadout.dm"
#include "code\modules\client\preference_setup\loadout\loadout_accessories.dm"
@@ -4488,6 +4488,7 @@
#include "code\ZAS\Zone.dm"
#include "interface\interface.dm"
#include "interface\skin.dmf"
#include "maps\runtime_station.dm"
#include "maps\atoll\atoll_decals.dm"
#include "maps\atoll\atoll_objs.dm"
#include "maps\atoll\atoll_turfs.dm"
@@ -4524,7 +4525,6 @@
#include "maps\~map_system\maps.dm"
#include "modular_chomp\code\coalesce_ch.dm"
#include "modular_chomp\code\global.dm"
#include "modular_chomp\code\_DEFINES\color_priority.dm"
#include "modular_chomp\code\_HELPERS\icons\flatten.dm"
#include "modular_chomp\code\_HELPERS\type2type\color.dm"
#include "modular_chomp\code\ATMOSPHERICS\atmospherics.dm"
@@ -4533,10 +4533,11 @@
#include "modular_chomp\code\datums\autolathe\general_ch.dm"
#include "modular_chomp\code\datums\browser\color_matrix_picker.dm"
#include "modular_chomp\code\datums\components\gargoyle.dm"
#include "modular_chomp\code\datums\interfaces\appearance.dm"
#include "modular_chomp\code\datums\outfits\jobs\noncrew.dm"
#include "modular_chomp\code\datums\supplypacks\medical.dm"
#include "modular_chomp\code\game\atoms\atoms.dm"
#include "modular_chomp\code\datums\underwear\socks.dm"
#include "modular_chomp\code\game\atoms\atoms.dm"
#include "modular_chomp\code\game\dna\dna2.dm"
#include "modular_chomp\code\game\jobs\job\department.dm"
#include "modular_chomp\code\game\jobs\job\noncrew.dm"
@@ -4565,6 +4566,7 @@
#include "modular_chomp\code\modules\client\preferences_spawnpoints.dm"
#include "modular_chomp\code\modules\client\preference_setup\general\03_body.dm"
#include "modular_chomp\code\modules\client\preference_setup\global\setting_datums.dm"
#include "modular_chomp\code\modules\client\preference_setup\loadout\gear_tweaks.dm"
#include "modular_chomp\code\modules\client\preference_setup\loadout\loadout_general.dm"
#include "modular_chomp\code\modules\client\preference_setup\loadout\loadout_shoes.dm"
#include "modular_chomp\code\modules\client\preference_setup\loadout\loadout_suit.dm"