Add group details gen attr
This commit is contained in:
parent
a25c8dd789
commit
d7386bce68
@ -68,6 +68,10 @@ const EN_US = {
|
|||||||
"Common.Attr.Key.Generation.Mod.Point": "Point model",
|
"Common.Attr.Key.Generation.Mod.Point": "Point model",
|
||||||
"Common.Attr.Key.Generation.Mod.Range": "Range model",
|
"Common.Attr.Key.Generation.Mod.Range": "Range model",
|
||||||
"Common.Attr.Key.Generation.Use.Range": "Generation range",
|
"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.Not.Range": "Object is not a Range",
|
||||||
"Panel.Info.Range.Details.Attr.Error.Unspecified": "Unspecified range object",
|
"Panel.Info.Range.Details.Attr.Error.Unspecified": "Unspecified range object",
|
||||||
"Panel.Info.Group.Details.Attr.Error.Not.Group": "Object is not a Group",
|
"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.Point": "点生成",
|
||||||
"Common.Attr.Key.Generation.Mod.Range": "范围生成",
|
"Common.Attr.Key.Generation.Mod.Range": "范围生成",
|
||||||
"Common.Attr.Key.Generation.Use.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.Not.Range": "对象不是一个范围",
|
||||||
"Panel.Info.Range.Details.Attr.Error.Unspecified": "未指定范围对象",
|
"Panel.Info.Range.Details.Attr.Error.Unspecified": "未指定范围对象",
|
||||||
"Panel.Info.Group.Details.Attr.Error.Not.Group": "对象不是一个群",
|
"Panel.Info.Group.Details.Attr.Error.Not.Group": "对象不是一个群",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Individual } from "./Individual";
|
import { Individual } from "./Individual";
|
||||||
import { CtrlObject } from "./CtrlObject";
|
import { CtrlObject } from "./CtrlObject";
|
||||||
import type { Behavior } from "./Behavior";
|
import type { Behavior } from "./Behavior";
|
||||||
import type { Model } from "./Model";
|
import type { Label } from "./Label";
|
||||||
|
|
||||||
enum GenMod {
|
enum GenMod {
|
||||||
Point = "p",
|
Point = "p",
|
||||||
@ -23,6 +23,21 @@ class Group extends CtrlObject {
|
|||||||
*/
|
*/
|
||||||
public genMethod: GenMod = GenMod.Point;
|
public genMethod: GenMod = GenMod.Point;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成位置坐标
|
||||||
|
*/
|
||||||
|
public genPoint: number[] = [0, 0, 0];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成范围
|
||||||
|
*/
|
||||||
|
public genRange?: CtrlObject | Label;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成个数
|
||||||
|
*/
|
||||||
|
public genCount?: number = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建个体
|
* 创建个体
|
||||||
* @param count 创建数量
|
* @param count 创建数量
|
||||||
|
@ -26,58 +26,33 @@ const allOption: IDisplayItem[] = [
|
|||||||
@useStatusWithEvent("groupAttrChange", "groupLabelChange", "focusObjectChange")
|
@useStatusWithEvent("groupAttrChange", "groupLabelChange", "focusObjectChange")
|
||||||
class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> {
|
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) {
|
private renderFrom(group: Group) {
|
||||||
return <>
|
return <>
|
||||||
|
|
||||||
<Message i18nKey="Common.Attr.Title.Basic" isTitle first/>
|
<Message i18nKey="Common.Attr.Title.Basic" isTitle first/>
|
||||||
|
|
||||||
{this.renderAttrInput(
|
<AttrInput
|
||||||
group.id, "Common.Attr.Key.Display.Name", group.displayName,
|
id={group.id} keyI18n="Common.Attr.Key.Display.Name" value={group.displayName}
|
||||||
(val, status) => {
|
valueChange={(val) => {
|
||||||
status.changeGroupAttrib(group.id, "displayName", val);
|
this.props.status?.changeGroupAttrib(group.id, "displayName", val);
|
||||||
}
|
}}
|
||||||
)}
|
/>
|
||||||
|
|
||||||
<ColorInput
|
<ColorInput
|
||||||
keyI18n="Common.Attr.Key.Color"
|
keyI18n="Common.Attr.Key.Color"
|
||||||
value={group.color} normal
|
value={group.color} normal
|
||||||
valueChange={(color) => {
|
valueChange={(color) => {
|
||||||
if (this.props.status) {
|
this.props.status?.changeGroupAttrib(group.id, "color", color);
|
||||||
this.props.status.changeGroupAttrib(group.id, "color", color);
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{this.renderAttrInput(
|
<AttrInput
|
||||||
group.id, "Common.Attr.Key.Size", group.size,
|
id={group.id} isNumber={true} step={10} keyI18n="Common.Attr.Key.Size"
|
||||||
(val, status) => {
|
value={group.size} min={0}
|
||||||
status.changeGroupAttrib(group.id, "size", (val as any) / 1);
|
valueChange={(val) => {
|
||||||
}, 10, undefined, 0
|
this.props.status?.changeGroupAttrib(group.id, "size", (val as any) / 1);
|
||||||
)}
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<LabelPicker
|
<LabelPicker
|
||||||
keyI18n="Common.Attr.Key.Label"
|
keyI18n="Common.Attr.Key.Label"
|
||||||
@ -139,6 +114,58 @@ 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
|
<ObjectPicker
|
||||||
keyI18n="Common.Attr.Key.Generation.Use.Range"
|
keyI18n="Common.Attr.Key.Generation.Use.Range"
|
||||||
type={["L", "G", "R"]}
|
type={["L", "G", "R"]}
|
||||||
|
Loading…
Reference in New Issue
Block a user