From d7386bce688f63dad836c52eaea66d90a03394d9 Mon Sep 17 00:00:00 2001 From: MrKBear Date: Tue, 15 Mar 2022 17:34:50 +0800 Subject: [PATCH] Add group details gen attr --- source/Localization/EN-US.ts | 4 + source/Localization/ZH-CN.ts | 4 + source/Model/Group.ts | 17 +++- source/Panel/GroupDetails/GroupDetails.tsx | 109 +++++++++++++-------- 4 files changed, 92 insertions(+), 42 deletions(-) diff --git a/source/Localization/EN-US.ts b/source/Localization/EN-US.ts index 013675c..8625bf1 100644 --- a/source/Localization/EN-US.ts +++ b/source/Localization/EN-US.ts @@ -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", diff --git a/source/Localization/ZH-CN.ts b/source/Localization/ZH-CN.ts index 1207dbf..b212256 100644 --- a/source/Localization/ZH-CN.ts +++ b/source/Localization/ZH-CN.ts @@ -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": "对象不是一个群", diff --git a/source/Model/Group.ts b/source/Model/Group.ts index db0087e..0e427f4 100644 --- a/source/Model/Group.ts +++ b/source/Model/Group.ts @@ -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 创建数量 diff --git a/source/Panel/GroupDetails/GroupDetails.tsx b/source/Panel/GroupDetails/GroupDetails.tsx index ff2be79..8e71176 100644 --- a/source/Panel/GroupDetails/GroupDetails.tsx +++ b/source/Panel/GroupDetails/GroupDetails.tsx @@ -26,58 +26,33 @@ const allOption: IDisplayItem[] = [ @useStatusWithEvent("groupAttrChange", "groupLabelChange", "focusObjectChange") class GroupDetails extends Component { - 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 - } else { - return - } - } - private renderFrom(group: Group) { return <> - {this.renderAttrInput( - group.id, "Common.Attr.Key.Display.Name", group.displayName, - (val, status) => { - status.changeGroupAttrib(group.id, "displayName", val); - } - )} + { + this.props.status?.changeGroupAttrib(group.id, "displayName", val); + }} + /> { - 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 - )} + { + this.props.status?.changeGroupAttrib(group.id, "size", (val as any) / 1); + }} + /> { }} /> + { + 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 <> + + { + group.genPoint[0] = (val as any) / 1; + this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint); + }} + /> + + { + group.genPoint[1] = (val as any) / 1; + this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint); + }} + /> + + { + group.genPoint[2] = (val as any) / 1; + this.props.status?.changeGroupAttrib(group.id, "genPoint", group.genPoint); + }} + /> + + } + + private renderRangeGenOption(group: Group) { + + return <> + - - } + + } public render(): ReactNode { if (this.props.status) {