feat: added operator color to wallpaper engine

This commit is contained in:
Haoyu Xu
2025-08-03 17:27:07 +08:00
parent e5fc7d3a00
commit 44eaecde83
2 changed files with 21 additions and 2 deletions

View File

@@ -83,6 +83,7 @@ const process = ({
data: ProjectJSON data: ProjectJSON
template: TemplateYAML template: TemplateYAML
}) => { }) => {
const { r, g, b } = getRGBfromHEXColor(operators[name].color)
return { return {
...data, ...data,
description: template.description, description: template.description,
@@ -92,11 +93,29 @@ const process = ({
localization: template.localization, localization: template.localization,
properties: { properties: {
...getProperties(template), ...getProperties(template),
schemecolor: {
order: 0,
text: 'ui_browse_properties_scheme_color',
type: 'color',
value: `${r / 255} ${g / 255} ${b / 255}`,
},
}, },
}, },
} as ProjectJSON } as ProjectJSON
} }
const getRGBfromHEXColor = (hex: string) => {
const hexNo = parseInt(hex.replace('#', ''), 16)
const r = (hexNo >> 16) & 255
const g = (hexNo >> 8) & 255
const b = hexNo & 255
return {
r,
g,
b,
}
}
const getProperties = (template: TemplateYAML) => { const getProperties = (template: TemplateYAML) => {
const properties = template.properties const properties = template.properties
const output = {} as { const output = {} as {

View File

@@ -7,7 +7,7 @@ export type Assets = {
export interface Property { export interface Property {
text: string text: string
type?: 'bool' | 'file' | 'slider' | 'combo' | 'textinput' type?: 'bool' | 'file' | 'slider' | 'combo' | 'textinput' | 'color'
value?: boolean | string value?: boolean | string
condition?: string condition?: string
fraction?: boolean fraction?: boolean
@@ -20,7 +20,7 @@ export interface Property {
} }
export interface ProjectJSONProperty extends Property { export interface ProjectJSONProperty extends Property {
index: number index?: number
order: number order: number
} }