[MIRROR] Adds config Input to the colorMatrix (#8922)

Co-authored-by: Heroman3003 <31296024+Heroman3003@users.noreply.github.com>
Co-authored-by: CHOMPStation2 <chompsation2@gmail.com>
This commit is contained in:
CHOMPStation2
2024-09-07 13:50:23 -07:00
committed by GitHub
parent f368c0af3b
commit 1e8be29c71
3 changed files with 264 additions and 222 deletions

View File

@@ -108,6 +108,16 @@
if("set_matrix_color")
color_matrix_last[params["color"]] = params["value"]
return TRUE
if("set_matrix_string")
if(params["value"])
var/list/colours = splittext(params["value"], ",")
if(colours.len > 12)
colours.Cut(13)
for(var/i = 1, i <= colours.len, i++)
var/number = text2num(colours[i])
if(isnum(number))
color_matrix_last[i] = clamp(number, -10, 10)
return TRUE
if("set_hue")
build_hue = clamp(text2num(params["buildhue"]), 0, 360)
return TRUE

View File

@@ -189,6 +189,16 @@
if("set_matrix_color")
color_matrix_last[params["color"]] = params["value"]
return TRUE
if("set_matrix_string")
if(params["value"])
var/list/colours = splittext(params["value"], ",")
if(colours.len > 12)
colours.Cut(13)
for(var/i = 1, i <= colours.len, i++)
var/number = text2num(colours[i])
if(isnum(number))
color_matrix_last[i] = clamp(number, -10, 10)
return TRUE
if("set_hue")
build_hue = clamp(text2num(params["buildhue"]), 0, 360)
return TRUE

View File

@@ -1,7 +1,14 @@
import { toFixed } from 'common/math';
import { useBackend } from '../../backend';
import { Icon, NumberInput, Table } from '../../components';
import {
Box,
Icon,
Input,
LabeledList,
NumberInput,
Table,
} from '../../components';
import { Data } from './types';
export const ColorMateMatrix = (props) => {
@@ -10,6 +17,7 @@ export const ColorMateMatrix = (props) => {
const { matrixcolors } = data;
return (
<>
<Table>
<Table.Cell>
<Table.Row>
@@ -227,9 +235,23 @@ export const ColorMateMatrix = (props) => {
<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.
<Icon name="question-circle" color="blue" /> CR means this much red
will be added.
</Table.Cell>
</Table>
<Box mt={3}>
<LabeledList>
<LabeledList.Item label="Config">
<Input
fluid
value={Object.values(matrixcolors).toString()}
onChange={(e, value: string) =>
act('set_matrix_string', { value })
}
/>
</LabeledList.Item>
</LabeledList>
</Box>
</>
);
};