Add group details gen & recode input with text field component #22
@ -68,6 +68,10 @@ const EN_US = {
|
||||
"Common.Attr.Key.Generation.Mod.Point": "Point model",
|
||||
"Common.Attr.Key.Generation.Mod.Range": "Range model",
|
||||
"Common.Attr.Key.Generation.Use.Range": "Generation range",
|
||||
"Common.Attr.Key.Generation.Count": "Generation count",
|
||||
"Common.Attr.Key.Generation.Point.X": "Generation Point X",
|
||||
"Common.Attr.Key.Generation.Point.Y": "Generation Point Y",
|
||||
"Common.Attr.Key.Generation.Point.Z": "Generation Point Z",
|
||||
"Panel.Info.Range.Details.Attr.Error.Not.Range": "Object is not a Range",
|
||||
"Panel.Info.Range.Details.Attr.Error.Unspecified": "Unspecified range object",
|
||||
"Panel.Info.Group.Details.Attr.Error.Not.Group": "Object is not a Group",
|
||||
|
@ -68,6 +68,10 @@ const ZH_CN = {
|
||||
"Common.Attr.Key.Generation.Mod.Point": "点生成",
|
||||
"Common.Attr.Key.Generation.Mod.Range": "范围生成",
|
||||
"Common.Attr.Key.Generation.Use.Range": "生成范围",
|
||||
"Common.Attr.Key.Generation.Count": "生成个数",
|
||||
"Common.Attr.Key.Generation.Point.X": "生成位置 X 坐标",
|
||||
"Common.Attr.Key.Generation.Point.Y": "生成位置 Y 坐标",
|
||||
"Common.Attr.Key.Generation.Point.Z": "生成位置 Z 坐标",
|
||||
"Panel.Info.Range.Details.Attr.Error.Not.Range": "对象不是一个范围",
|
||||
"Panel.Info.Range.Details.Attr.Error.Unspecified": "未指定范围对象",
|
||||
"Panel.Info.Group.Details.Attr.Error.Not.Group": "对象不是一个群",
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Individual } from "./Individual";
|
||||
import { CtrlObject } from "./CtrlObject";
|
||||
import type { Behavior } from "./Behavior";
|
||||
import type { Model } from "./Model";
|
||||
import type { Label } from "./Label";
|
||||
|
||||
enum GenMod {
|
||||
Point = "p",
|
||||
@ -23,6 +23,21 @@ class Group extends CtrlObject {
|
||||
*/
|
||||
public genMethod: GenMod = GenMod.Point;
|
||||
|
||||
/**
|
||||
* 生成位置坐标
|
||||
*/
|
||||
public genPoint: number[] = [0, 0, 0];
|
||||
|
||||
/**
|
||||
* 生成范围
|
||||
*/
|
||||
public genRange?: CtrlObject | Label;
|
||||
|
||||
/**
|
||||
* 生成个数
|
||||
*/
|
||||
public genCount?: number = 0;
|
||||
|
||||
/**
|
||||
* 创建个体
|
||||
* @param count 创建数量
|
||||
|
@ -26,58 +26,33 @@ const allOption: IDisplayItem[] = [
|
||||
@useStatusWithEvent("groupAttrChange", "groupLabelChange", "focusObjectChange")
|
||||
class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> {
|
||||
|
||||
private renderAttrInput(
|
||||
id: ObjectID, key: AllI18nKeys, val: string | number | undefined,
|
||||
change: (val: string, status: Status) => any,
|
||||
step?: number, max?: number, min?: number
|
||||
) {
|
||||
const handelFunc = (e: string) => {
|
||||
if (this.props.status) {
|
||||
change(e, this.props.status);
|
||||
}
|
||||
}
|
||||
if (step) {
|
||||
return <AttrInput
|
||||
id={id} isNumber={true} step={step} keyI18n={key}
|
||||
value={val} max={max} min={min}
|
||||
valueChange={handelFunc}
|
||||
/>
|
||||
} else {
|
||||
return <AttrInput
|
||||
id={id} keyI18n={key} value={val}
|
||||
valueChange={handelFunc}
|
||||
/>
|
||||
}
|
||||
}
|
||||
|
||||
private renderFrom(group: Group) {
|
||||
return <>
|
||||
|
||||
<Message i18nKey="Common.Attr.Title.Basic" isTitle first/>
|
||||
|
||||
{this.renderAttrInput(
|
||||
group.id, "Common.Attr.Key.Display.Name", group.displayName,
|
||||
(val, status) => {
|
||||
status.changeGroupAttrib(group.id, "displayName", val);
|
||||
}
|
||||
)}
|
||||
<AttrInput
|
||||
id={group.id} keyI18n="Common.Attr.Key.Display.Name" value={group.displayName}
|
||||
valueChange={(val) => {
|
||||
this.props.status?.changeGroupAttrib(group.id, "displayName", val);
|
||||
}}
|
||||
/>
|
||||
|
||||
<ColorInput
|
||||
keyI18n="Common.Attr.Key.Color"
|
||||
value={group.color} normal
|
||||
valueChange={(color) => {
|
||||
if (this.props.status) {
|
||||
this.props.status.changeGroupAttrib(group.id, "color", color);
|
||||
}
|
||||
this.props.status?.changeGroupAttrib(group.id, "color", color);
|
||||
}}
|
||||
/>
|
||||
|
||||
{this.renderAttrInput(
|
||||
group.id, "Common.Attr.Key.Size", group.size,
|
||||
(val, status) => {
|
||||
status.changeGroupAttrib(group.id, "size", (val as any) / 1);
|
||||
}, 10, undefined, 0
|
||||
)}
|
||||
<AttrInput
|
||||
id={group.id} isNumber={true} step={10} keyI18n="Common.Attr.Key.Size"
|
||||
value={group.size} min={0}
|
||||
valueChange={(val) => {
|
||||
this.props.status?.changeGroupAttrib(group.id, "size", (val as any) / 1);
|
||||
}}
|
||||
/>
|
||||
|
||||
<LabelPicker
|
||||
keyI18n="Common.Attr.Key.Label"
|
||||
@ -139,12 +114,64 @@ class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> {
|
||||
}}
|
||||
/>
|
||||
|
||||
<AttrInput
|
||||
id={group.id} isNumber={true} step={1} keyI18n="Common.Attr.Key.Generation.Count"
|
||||
value={group.genCount} min={0} max={1000}
|
||||
valueChange={(val) => {
|
||||
this.props.status?.changeGroupAttrib(group.id, "genCount", (val as any) / 1);
|
||||
}}
|
||||
/>
|
||||
|
||||
{group.genMethod === GenMod.Point ? this.renderPointGenOption(group) : null}
|
||||
|
||||
{group.genMethod === GenMod.Range ? this.renderRangeGenOption(group) : null}
|
||||
|
||||
</>
|
||||
}
|
||||
|
||||
private renderPointGenOption(group: Group) {
|
||||
|
||||
return <>
|
||||
|
||||
<AttrInput
|
||||
id={group.id} isNumber={true} step={0.1} keyI18n="Common.Attr.Key.Generation.Point.X"
|
||||
value={group.genPoint[0] ?? 0}
|
||||
valueChange={(val) => {
|
||||
group.genPoint[0] = (val as any) / 1;
|
||||
this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint);
|
||||
}}
|
||||
/>
|
||||
|
||||
<AttrInput
|
||||
id={group.id} isNumber={true} step={0.1} keyI18n="Common.Attr.Key.Generation.Point.Y"
|
||||
value={group.genPoint[1] ?? 0}
|
||||
valueChange={(val) => {
|
||||
group.genPoint[1] = (val as any) / 1;
|
||||
this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint);
|
||||
}}
|
||||
/>
|
||||
|
||||
<AttrInput
|
||||
id={group.id} isNumber={true} step={0.1} keyI18n="Common.Attr.Key.Generation.Point.Z"
|
||||
value={group.genPoint[2] ?? 0}
|
||||
valueChange={(val) => {
|
||||
group.genPoint[2] = (val as any) / 1;
|
||||
this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint);
|
||||
}}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
|
||||
private renderRangeGenOption(group: Group) {
|
||||
|
||||
return <>
|
||||
|
||||
<ObjectPicker
|
||||
keyI18n="Common.Attr.Key.Generation.Use.Range"
|
||||
type={["L", "G", "R"]}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
</>
|
||||
}
|
||||
|
||||
public render(): ReactNode {
|
||||
if (this.props.status) {
|
||||
|
Loading…
Reference in New Issue
Block a user