import { Component, Fragment, ReactNode } from "react"; import { useSettingWithEvent, IMixinSettingProps, Language } from "@Context/Setting"; import { AttrInput } from "@Input/AttrInput/AttrInput"; import { ObjectID } from "@Model/Model"; import { TogglesInput } from "@Input/TogglesInput/TogglesInput"; import { ObjectPicker } from "@Input/ObjectPicker/ObjectPicker"; import { AllI18nKeys, I18N } from "@Component/Localization/Localization"; import { Message } from "@Input/Message/Message"; import { ColorInput } from "@Input/ColorInput/ColorInput"; import { ComboInput, IDisplayItem } from "@Input/ComboInput/ComboInput"; import { IParameter, IParameterOption, IParameterOptionItem, IParameterValue, IParamValue, isObjectType, isVectorType } from "@Model/Parameter"; import "./Parameter.scss"; interface IParameterProps
{ option: IParameterOption
; value: IParameterValue
;
key: ObjectID;
change: ) => any;
i18n?: (key: string, language: Language) => string;
title?: AllI18nKeys;
titleOption?: Record extends Component , value: IParamValue ): ReactNode {
const language = this.props.setting?.language ?? "EN_US";
const indexKey = `${this.props.key}-${key}`;
const type = option.type;
let keyI18n: string, keyI18nOption: Record );
}}
/>;
}
else if (type === "string") {
return );
}}
/>;
}
else if (type === "boolean") {
return );
}}
/>
}
else if (isObjectType(type)) {
type IObjectParamValue = IParamValue<"G" | "R" | "LG" | "LR">;
const typedValue = value as IObjectParamValue;
return );
}}
cleanValue={() => {
typedValue.picker = undefined as IObjectParamValue["picker"];
this.props.change(key, typedValue as IParamValue );
}}
/>
}
else if (type === "color") {
return );
}}
/>
}
else if (type === "option") {
let allOption: IDisplayItem[] = [];
let focusKey: number = -1;
if (option.allOption) {
for (let i = 0; i < option.allOption.length; i++) {
if (this.props.i18n) {
allOption.push({
i18nOption: { key: this.props.i18n(option.allOption[i].name, language) },
i18n: "Panel.Info.Behavior.Details.Parameter.Key",
key: option.allOption[i].key
})
}
else {
allOption.push({
i18n: option.allOption[i].name,
key: option.allOption[i].key
})
}
if (option.allOption[i].key === value) {
focusKey = i;
}
}
}
return );
}}
/>
}
else if (type === "vec") {
type IObjectParamValue = IParamValue<"vec">;
const typedValue = value as IObjectParamValue;
const i18nVal = I18N(this.props, keyI18n, keyI18nOption);
return );
}}
/>
);
}}
/>
);
}}
/>