Compare commits
	
		
			No commits in common. "c3d4c13c1042c264450ce48a271c3f629f9a0fdd" and "3351769106aa1bf8eef8e4ff61c19c8ac928e5a3" have entirely different histories.
		
	
	
		
			c3d4c13c10
			...
			3351769106
		
	
		
| @ -1,13 +1,13 @@ | |||||||
| import { BehaviorRecorder, IAnyBehaviorRecorder } from "@Model/Behavior"; | import { BehaviorRecorder, IAnyBehaviorRecorder } from "@Model/Behavior"; | ||||||
| import { Template } from "@Behavior/Template"; | import { Template } from "@Behavior/Template"; | ||||||
| import { PhysicsDynamics } from "@Behavior/PhysicsDynamics"; | import { Dynamics } from "@Behavior/Dynamics"; | ||||||
| import { Brownian } from "@Behavior/Brownian"; | import { Brownian } from "@Behavior/Brownian"; | ||||||
| import { BoundaryConstraint } from "@Behavior/BoundaryConstraint"; | import { BoundaryConstraint } from "@Behavior/BoundaryConstraint"; | ||||||
| import { Tracking } from "@Behavior/Tracking"; | import { Tracking } from "@Behavior/Tracking"; | ||||||
| 
 | 
 | ||||||
| const AllBehaviors: IAnyBehaviorRecorder[] = [ | const AllBehaviors: IAnyBehaviorRecorder[] = [ | ||||||
|     new BehaviorRecorder(Template), |     new BehaviorRecorder(Template), | ||||||
|     new BehaviorRecorder(PhysicsDynamics), |     new BehaviorRecorder(Dynamics), | ||||||
|     new BehaviorRecorder(Brownian), |     new BehaviorRecorder(Brownian), | ||||||
|     new BehaviorRecorder(BoundaryConstraint), |     new BehaviorRecorder(BoundaryConstraint), | ||||||
|     new BehaviorRecorder(Tracking), |     new BehaviorRecorder(Tracking), | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ class BoundaryConstraint extends Behavior<IBoundaryConstraintBehaviorParameter, | |||||||
| 
 | 
 | ||||||
|     public override behaviorName: string = "$Title"; |     public override behaviorName: string = "$Title"; | ||||||
| 
 | 
 | ||||||
|     public override iconName: string = "Quantity"; |     public override iconName: string = "Running"; | ||||||
| 
 | 
 | ||||||
|     public override describe: string = "$Intro"; |     public override describe: string = "$Intro"; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -18,7 +18,7 @@ class Brownian extends Behavior<IBrownianBehaviorParameter, IBrownianBehaviorEve | |||||||
| 
 | 
 | ||||||
|     public override behaviorName: string = "$Title"; |     public override behaviorName: string = "$Title"; | ||||||
| 
 | 
 | ||||||
|     public override iconName: string = "ScatterChart"; |     public override iconName: string = "Running"; | ||||||
| 
 | 
 | ||||||
|     public override describe: string = "$Intro"; |     public override describe: string = "$Intro"; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -3,23 +3,22 @@ import Group from "@Model/Group"; | |||||||
| import Individual from "@Model/Individual"; | import Individual from "@Model/Individual"; | ||||||
| import { Model } from "@Model/Model"; | import { Model } from "@Model/Model"; | ||||||
| 
 | 
 | ||||||
| type IPhysicsDynamicsBehaviorParameter = { | type IDynamicsBehaviorParameter = { | ||||||
|     mass: "number", |     mass: "number", | ||||||
| 	maxAcceleration: "number", | 	maxAcceleration: "number", | ||||||
| 	maxVelocity: "number", | 	maxVelocity: "number", | ||||||
| 	resistance: "number", | 	resistance: "number" | ||||||
| 	limit: "boolean" |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| type IPhysicsDynamicsBehaviorEvent = {} | type IDynamicsBehaviorEvent = {} | ||||||
| 
 | 
 | ||||||
| class PhysicsDynamics extends Behavior<IPhysicsDynamicsBehaviorParameter, IPhysicsDynamicsBehaviorEvent> { | class Dynamics extends Behavior<IDynamicsBehaviorParameter, IDynamicsBehaviorEvent> { | ||||||
| 
 | 
 | ||||||
|     public override behaviorId: string = "PhysicsDynamics"; |     public override behaviorId: string = "Dynamics"; | ||||||
| 
 | 
 | ||||||
|     public override behaviorName: string = "$Title"; |     public override behaviorName: string = "$Title"; | ||||||
| 
 | 
 | ||||||
|     public override iconName: string = "SliderHandleSize"; |     public override iconName: string = "Running"; | ||||||
| 
 | 
 | ||||||
|     public override describe: string = "$Intro"; |     public override describe: string = "$Intro"; | ||||||
| 
 | 
 | ||||||
| @ -27,16 +26,9 @@ class PhysicsDynamics extends Behavior<IPhysicsDynamicsBehaviorParameter, IPhysi | |||||||
| 
 | 
 | ||||||
| 	public override parameterOption = { | 	public override parameterOption = { | ||||||
| 		mass: { name: "$Mass", type: "number", defaultValue: 1, numberStep: .01, numberMin: .001 }, | 		mass: { name: "$Mass", type: "number", defaultValue: 1, numberStep: .01, numberMin: .001 }, | ||||||
| 		resistance: { name: "$Resistance", type: "number", defaultValue: 0.5, numberStep: .1, numberMin: 0 }, | 		maxAcceleration: { name: "$Max.Acceleration", type: "number", defaultValue: 5, numberStep: .1, numberMin: 0 }, | ||||||
| 		limit: { name: "$Limit", type: "boolean", defaultValue: true }, | 		maxVelocity: { name: "$Max.Velocity", type: "number", defaultValue: 10, numberStep: .1, numberMin: 0 }, | ||||||
| 		maxAcceleration: { | 		resistance: { name: "$Resistance", type: "number", defaultValue: 0.5, numberStep: .1, numberMin: 0 } | ||||||
| 			name: "$Max.Acceleration", type: "number", defaultValue: 5,  |  | ||||||
| 			numberStep: .1, numberMin: 0, condition: { key: "limit", value: true } |  | ||||||
| 		}, |  | ||||||
| 		maxVelocity: { |  | ||||||
| 			name: "$Max.Velocity", type: "number", defaultValue: 10, |  | ||||||
| 			numberStep: .1, numberMin: 0, condition: { key: "limit", value: true } |  | ||||||
| 		}, |  | ||||||
| 	}; | 	}; | ||||||
| 
 | 
 | ||||||
| 	public override finalEffect = (individual: Individual, group: Group, model: Model, t: number): void => { | 	public override finalEffect = (individual: Individual, group: Group, model: Model, t: number): void => { | ||||||
| @ -62,14 +54,12 @@ class PhysicsDynamics extends Behavior<IPhysicsDynamicsBehaviorParameter, IPhysi | |||||||
| 		individual.acceleration[2] = individual.force[2] / this.parameter.mass; | 		individual.acceleration[2] = individual.force[2] / this.parameter.mass; | ||||||
| 
 | 
 | ||||||
| 		// 加速度约束
 | 		// 加速度约束
 | ||||||
| 		if (this.parameter.limit) { |  | ||||||
| 		const lengthA = individual.vectorLength(individual.acceleration); | 		const lengthA = individual.vectorLength(individual.acceleration); | ||||||
| 		if (lengthA > this.parameter.maxAcceleration) { | 		if (lengthA > this.parameter.maxAcceleration) { | ||||||
| 			individual.acceleration[0] = individual.acceleration[0] * this.parameter.maxAcceleration / lengthA; | 			individual.acceleration[0] = individual.acceleration[0] * this.parameter.maxAcceleration / lengthA; | ||||||
| 			individual.acceleration[1] = individual.acceleration[1] * this.parameter.maxAcceleration / lengthA; | 			individual.acceleration[1] = individual.acceleration[1] * this.parameter.maxAcceleration / lengthA; | ||||||
| 			individual.acceleration[2] = individual.acceleration[2] * this.parameter.maxAcceleration / lengthA; | 			individual.acceleration[2] = individual.acceleration[2] * this.parameter.maxAcceleration / lengthA; | ||||||
| 		} | 		} | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		// 计算速度
 | 		// 计算速度
 | ||||||
| 		individual.velocity[0] = individual.velocity[0] + individual.acceleration[0] * t; | 		individual.velocity[0] = individual.velocity[0] + individual.acceleration[0] * t; | ||||||
| @ -77,14 +67,12 @@ class PhysicsDynamics extends Behavior<IPhysicsDynamicsBehaviorParameter, IPhysi | |||||||
| 		individual.velocity[2] = individual.velocity[2] + individual.acceleration[2] * t; | 		individual.velocity[2] = individual.velocity[2] + individual.acceleration[2] * t; | ||||||
| 
 | 
 | ||||||
| 		// 速度约束
 | 		// 速度约束
 | ||||||
| 		if (this.parameter.limit) { |  | ||||||
| 		const lengthV = individual.vectorLength(individual.velocity); | 		const lengthV = individual.vectorLength(individual.velocity); | ||||||
| 		if (lengthV > this.parameter.maxVelocity) { | 		if (lengthV > this.parameter.maxVelocity) { | ||||||
| 			individual.velocity[0] = individual.velocity[0] * this.parameter.maxVelocity / lengthV; | 			individual.velocity[0] = individual.velocity[0] * this.parameter.maxVelocity / lengthV; | ||||||
| 			individual.velocity[1] = individual.velocity[1] * this.parameter.maxVelocity / lengthV; | 			individual.velocity[1] = individual.velocity[1] * this.parameter.maxVelocity / lengthV; | ||||||
| 			individual.velocity[2] = individual.velocity[2] * this.parameter.maxVelocity / lengthV; | 			individual.velocity[2] = individual.velocity[2] * this.parameter.maxVelocity / lengthV; | ||||||
| 		} | 		} | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		// 应用速度
 | 		// 应用速度
 | ||||||
| 		individual.position[0] = individual.position[0] + individual.velocity[0] * t; | 		individual.position[0] = individual.position[0] + individual.velocity[0] * t; | ||||||
| @ -99,16 +87,12 @@ class PhysicsDynamics extends Behavior<IPhysicsDynamicsBehaviorParameter, IPhysi | |||||||
| 	 | 	 | ||||||
|     public override terms: Record<string, Record<string, string>> = { |     public override terms: Record<string, Record<string, string>> = { | ||||||
|         "$Title": { |         "$Title": { | ||||||
|             "ZH_CN": "物理动力学", |             "ZH_CN": "动力学", | ||||||
|             "EN_US": "Physics dynamics" |             "EN_US": "Dynamics" | ||||||
|         }, |         }, | ||||||
|         "$Intro": { |         "$Intro": { | ||||||
|             "ZH_CN": "一切按照物理规则运动物体的行为, 按照牛顿经典物理运动公式执行。", |             "ZH_CN": "一切可以运动物体的必要行为,执行物理法则。", | ||||||
|             "EN_US": "The behavior of all moving objects according to physical rules is carried out according to Newton's classical physical motion formula." |             "EN_US": "All necessary behaviors that can move objects and implement the laws of physics." | ||||||
|         }, |  | ||||||
| 		"$Limit": { |  | ||||||
| 			"ZH_CN": "开启限制", |  | ||||||
|             "EN_US": "Enable limit" |  | ||||||
|         }, |         }, | ||||||
| 		"$Mass": { | 		"$Mass": { | ||||||
| 			"ZH_CN": "质量 (Kg)", | 			"ZH_CN": "质量 (Kg)", | ||||||
| @ -133,4 +117,4 @@ class PhysicsDynamics extends Behavior<IPhysicsDynamicsBehaviorParameter, IPhysi | |||||||
|     }; |     }; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| export { PhysicsDynamics }; | export { Dynamics }; | ||||||
| @ -16,7 +16,7 @@ class Tracking extends Behavior<ITrackingBehaviorParameter, ITrackingBehaviorEve | |||||||
| 
 | 
 | ||||||
|     public override behaviorName: string = "$Title"; |     public override behaviorName: string = "$Title"; | ||||||
| 
 | 
 | ||||||
|     public override iconName: string = "Bullseye"; |     public override iconName: string = "BullseyeTarget"; | ||||||
| 
 | 
 | ||||||
|     public override describe: string = "$Intro"; |     public override describe: string = "$Intro"; | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -32,15 +32,9 @@ class Parameter<P extends IParameter> extends Component<IParameterProps<P> & IMi | |||||||
|     private renderParameter<K extends keyof P> |     private renderParameter<K extends keyof P> | ||||||
|     (key: K, option: IParameterOptionItem<P[K]>, value: IParamValue<P[K]>): ReactNode { |     (key: K, option: IParameterOptionItem<P[K]>, value: IParamValue<P[K]>): ReactNode { | ||||||
| 
 | 
 | ||||||
|         const indexKey = `${this.props.key}-${key}`; |  | ||||||
| 
 |  | ||||||
|         // 条件检测
 |  | ||||||
|         if (option.condition && this.props.value[option.condition.key] !==  option.condition.value) { |  | ||||||
|             return <Fragment key={indexKey}/>; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         const type = option.type; |  | ||||||
|         const language = this.props.setting?.language ?? "EN_US"; |         const language = this.props.setting?.language ?? "EN_US"; | ||||||
|  |         const indexKey = `${this.props.key}-${key}`; | ||||||
|  |         const type = option.type; | ||||||
|         let keyI18n: string, keyI18nOption: Record<string, string> | undefined; |         let keyI18n: string, keyI18nOption: Record<string, string> | undefined; | ||||||
| 
 | 
 | ||||||
|         // Custom I18N
 |         // Custom I18N
 | ||||||
|  | |||||||
| @ -57,11 +57,8 @@ const EN_US = { | |||||||
|     "Popup.Action.No": "Cancel", |     "Popup.Action.No": "Cancel", | ||||||
|     "Popup.Action.Objects.Confirm.Title": "Confirm Delete", |     "Popup.Action.Objects.Confirm.Title": "Confirm Delete", | ||||||
|     "Popup.Action.Objects.Confirm.Delete": "Delete", |     "Popup.Action.Objects.Confirm.Delete": "Delete", | ||||||
|     "Popup.Action.Objects.Confirm.Restore.Title": "Confirm Restore", |  | ||||||
|     "Popup.Action.Objects.Confirm.Restore": "Restore", |  | ||||||
|     "Popup.Delete.Objects.Confirm": "Are you sure you want to delete this object(s)? The object is deleted and cannot be recalled.", |     "Popup.Delete.Objects.Confirm": "Are you sure you want to delete this object(s)? The object is deleted and cannot be recalled.", | ||||||
|     "Popup.Delete.Behavior.Confirm": "Are you sure you want to delete this behavior? The behavior is deleted and cannot be recalled.", |     "Popup.Delete.Behavior.Confirm": "Are you sure you want to delete this behavior? The behavior is deleted and cannot be recalled.", | ||||||
|     "Popup.Restore.Behavior.Confirm": "Are you sure you want to reset all parameters of this behavior? This operation cannot be recalled.", |  | ||||||
|     "Popup.Setting.Title": "Preferences setting", |     "Popup.Setting.Title": "Preferences setting", | ||||||
|     "Popup.Add.Behavior.Title": "Add behavior", |     "Popup.Add.Behavior.Title": "Add behavior", | ||||||
|     "Popup.Add.Behavior.Action.Add": "Add all select behavior", |     "Popup.Add.Behavior.Action.Add": "Add all select behavior", | ||||||
| @ -111,7 +108,6 @@ const EN_US = { | |||||||
|     "Common.Attr.Key.Generation.Error.Invalid.Label": "The specified label has expired", |     "Common.Attr.Key.Generation.Error.Invalid.Label": "The specified label has expired", | ||||||
|     "Common.Attr.Key.Kill.Random": "Random kill", |     "Common.Attr.Key.Kill.Random": "Random kill", | ||||||
|     "Common.Attr.Key.Kill.Count": "Kill count", |     "Common.Attr.Key.Kill.Count": "Kill count", | ||||||
|     "Common.Attr.Key.Behavior.Restore": "Restore default parameters", |  | ||||||
|     "Common.Render.Attr.Key.Display.Shape": "Display Shape", |     "Common.Render.Attr.Key.Display.Shape": "Display Shape", | ||||||
|     "Common.Render.Attr.Key.Display.Shape.Square": "Square", |     "Common.Render.Attr.Key.Display.Shape.Square": "Square", | ||||||
|     "Common.Render.Attr.Key.Display.Shape.Hollow.Square": "Hollow square", |     "Common.Render.Attr.Key.Display.Shape.Hollow.Square": "Hollow square", | ||||||
|  | |||||||
| @ -57,16 +57,13 @@ const ZH_CN = { | |||||||
|     "Popup.Action.No": "取消", |     "Popup.Action.No": "取消", | ||||||
|     "Popup.Action.Objects.Confirm.Title": "删除确认", |     "Popup.Action.Objects.Confirm.Title": "删除确认", | ||||||
|     "Popup.Action.Objects.Confirm.Delete": "删除", |     "Popup.Action.Objects.Confirm.Delete": "删除", | ||||||
|     "Popup.Action.Objects.Confirm.Restore.Title": "重置确认", |  | ||||||
|     "Popup.Action.Objects.Confirm.Restore": "重置", |  | ||||||
|     "Popup.Delete.Objects.Confirm": "你确定要删除这个(些)对象吗?对象被删除将无法撤回。", |     "Popup.Delete.Objects.Confirm": "你确定要删除这个(些)对象吗?对象被删除将无法撤回。", | ||||||
|     "Popup.Delete.Behavior.Confirm": "你确定要删除这个行为吗?行为被删除将无法撤回。", |     "Popup.Delete.Behavior.Confirm": "你确定要删除这个行为吗?行为被删除将无法撤回。", | ||||||
|     "Popup.Restore.Behavior.Confirm": "你确定要重置此行为的全部参数吗?此操作无法撤回。", |  | ||||||
|     "Popup.Setting.Title": "首选项设置", |     "Popup.Setting.Title": "首选项设置", | ||||||
|     "Popup.Add.Behavior.Title": "添加行为", |     "Popup.Add.Behavior.Title": "添加行为", | ||||||
|     "Popup.Add.Behavior.Action.Add": "添加全部选中行为", |     "Popup.Add.Behavior.Action.Add": "添加全部选中行为", | ||||||
|     "Popup.Add.Behavior.Select.Counter": "已选择 {count} 个行为", |     "Popup.Add.Behavior.Select.Counter": "找不到名为 \"{name}\" 的行为", | ||||||
|     "Popup.Add.Behavior.Select.Nodata": "找不到名为 \"{name}\" 的行为", |     "Popup.Add.Behavior.Select.Nodata": "Could not find behavior named \"{name}\"", | ||||||
|     "Popup.Behavior.Info.Title": "行为详情: {behavior}", |     "Popup.Behavior.Info.Title": "行为详情: {behavior}", | ||||||
|     "Popup.Behavior.Info.Confirm": "好的, 我知道了", |     "Popup.Behavior.Info.Confirm": "好的, 我知道了", | ||||||
|     "Build.In.Label.Name.All.Group": "全部群", |     "Build.In.Label.Name.All.Group": "全部群", | ||||||
| @ -111,7 +108,6 @@ const ZH_CN = { | |||||||
|     "Common.Attr.Key.Generation.Error.Invalid.Label": "指定的标签已失效", |     "Common.Attr.Key.Generation.Error.Invalid.Label": "指定的标签已失效", | ||||||
|     "Common.Attr.Key.Kill.Random": "随机消除", |     "Common.Attr.Key.Kill.Random": "随机消除", | ||||||
|     "Common.Attr.Key.Kill.Count": "消除数量", |     "Common.Attr.Key.Kill.Count": "消除数量", | ||||||
|     "Common.Attr.Key.Behavior.Restore": "还原默认参数", |  | ||||||
|     "Common.Render.Attr.Key.Display.Shape": "显示形状", |     "Common.Render.Attr.Key.Display.Shape": "显示形状", | ||||||
|     "Common.Render.Attr.Key.Display.Shape.Square": "方形", |     "Common.Render.Attr.Key.Display.Shape.Square": "方形", | ||||||
|     "Common.Render.Attr.Key.Display.Shape.Hollow.Square": "空心方形", |     "Common.Render.Attr.Key.Display.Shape.Hollow.Square": "空心方形", | ||||||
|  | |||||||
| @ -115,11 +115,6 @@ interface IParameterOptionItem<T extends IParamType = IParamType> { | |||||||
|      */ |      */ | ||||||
|     colorNormal?: boolean; |     colorNormal?: boolean; | ||||||
| 
 | 
 | ||||||
|     /** |  | ||||||
|      * 显示条件 |  | ||||||
|      */ |  | ||||||
|     condition?: {key: string, value: any}; |  | ||||||
| 
 |  | ||||||
|     /** |     /** | ||||||
|      * 全部选项 |      * 全部选项 | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -111,10 +111,10 @@ class SimulatorWeb extends Component { | |||||||
|             let template = this.status.model.addBehavior(getBehaviorById("Template")); |             let template = this.status.model.addBehavior(getBehaviorById("Template")); | ||||||
|             template.name = "Template"; template.color = [150, 20, 220]; |             template.name = "Template"; template.color = [150, 20, 220]; | ||||||
| 
 | 
 | ||||||
|             let dynamicFish = this.status.model.addBehavior(getBehaviorById("PhysicsDynamics")); |             let dynamicFish = this.status.model.addBehavior(getBehaviorById("Dynamics")); | ||||||
|             dynamicFish.name = "Dynamic Fish"; dynamicFish.color = [250, 200, 80]; |             dynamicFish.name = "Dynamic Fish"; dynamicFish.color = [250, 200, 80]; | ||||||
| 
 | 
 | ||||||
|             let dynamicShark = this.status.model.addBehavior(getBehaviorById("PhysicsDynamics")); |             let dynamicShark = this.status.model.addBehavior(getBehaviorById("Dynamics")); | ||||||
|             dynamicShark.name = "Dynamic Shark"; dynamicShark.color = [250, 200, 80]; |             dynamicShark.name = "Dynamic Shark"; dynamicShark.color = [250, 200, 80]; | ||||||
| 
 | 
 | ||||||
|             let brownian = this.status.model.addBehavior(getBehaviorById("Brownian")); |             let brownian = this.status.model.addBehavior(getBehaviorById("Brownian")); | ||||||
|  | |||||||
| @ -1,7 +1,6 @@ | |||||||
| import { Component, ReactNode} from "react"; | import { Component, ReactNode} from "react"; | ||||||
| import { useSettingWithEvent, IMixinSettingProps } from "@Context/Setting"; | import { useSettingWithEvent, IMixinSettingProps } from "@Context/Setting"; | ||||||
| import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | ||||||
| import { getDefaultValue } from "@Model/Parameter"; |  | ||||||
| import { IAnyBehavior } from "@Model/Behavior"; | import { IAnyBehavior } from "@Model/Behavior"; | ||||||
| import { Message } from "@Input/Message/Message"; | import { Message } from "@Input/Message/Message"; | ||||||
| import { AttrInput } from "@Input/AttrInput/AttrInput"; | import { AttrInput } from "@Input/AttrInput/AttrInput"; | ||||||
| @ -13,17 +12,9 @@ import "./BehaviorDetails.scss"; | |||||||
| 
 | 
 | ||||||
| interface IBehaviorDetailsProps {} | interface IBehaviorDetailsProps {} | ||||||
| 
 | 
 | ||||||
| interface IBehaviorDetailsState { |  | ||||||
|     updateId: number; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| @useSettingWithEvent("language") | @useSettingWithEvent("language") | ||||||
| @useStatusWithEvent("focusBehaviorChange", "behaviorAttrChange") | @useStatusWithEvent("focusBehaviorChange", "behaviorAttrChange") | ||||||
| class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProps & IMixinSettingProps, IBehaviorDetailsState> { | class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProps & IMixinSettingProps> { | ||||||
| 
 |  | ||||||
|     public state: Readonly<IBehaviorDetailsState> = { |  | ||||||
|         updateId: 1 |  | ||||||
|     }; |  | ||||||
| 
 | 
 | ||||||
|     private handelDeleteBehavior = (behavior: IAnyBehavior) => { |     private handelDeleteBehavior = (behavior: IAnyBehavior) => { | ||||||
|         if (this.props.status) { |         if (this.props.status) { | ||||||
| @ -41,28 +32,6 @@ class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProp | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private handelRestoreBehavior = (behavior: IAnyBehavior) => { |  | ||||||
|         if (this.props.status) { |  | ||||||
|             const status = this.props.status; |  | ||||||
|             status.popup.showPopup(ConfirmPopup, { |  | ||||||
|                 infoI18n: "Popup.Restore.Behavior.Confirm", |  | ||||||
|                 titleI18N: "Popup.Action.Objects.Confirm.Restore.Title", |  | ||||||
|                 yesI18n: "Popup.Action.Objects.Confirm.Restore", |  | ||||||
|                 red: "yes", |  | ||||||
|                 yes: () => { |  | ||||||
|                     status.changeBehaviorAttrib( |  | ||||||
|                         behavior.id, "parameter", |  | ||||||
|                         getDefaultValue(behavior.parameterOption) as any, |  | ||||||
|                         true |  | ||||||
|                     ); |  | ||||||
|                     this.setState({ |  | ||||||
|                         updateId: this.state.updateId + 1 |  | ||||||
|                     }); |  | ||||||
|                 } |  | ||||||
|             }) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
| 	private renderFrom(behavior: IAnyBehavior): ReactNode { | 	private renderFrom(behavior: IAnyBehavior): ReactNode { | ||||||
|          |          | ||||||
| 		return <> | 		return <> | ||||||
| @ -92,16 +61,8 @@ class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProp | |||||||
| 				}} | 				}} | ||||||
| 			/> | 			/> | ||||||
|              |              | ||||||
|             <TogglesInput |  | ||||||
| 				keyI18n="Common.Attr.Key.Behavior.Restore" red |  | ||||||
| 				onIconName="ReplyAll" offIconName="ReplyAll" |  | ||||||
| 				valueChange={() => { |  | ||||||
| 					this.handelRestoreBehavior(behavior) |  | ||||||
| 				}} |  | ||||||
| 			/> |  | ||||||
|              |  | ||||||
|             <Parameter |             <Parameter | ||||||
|                 key={`${behavior.id}-${this.state.updateId}`} |                 key={behavior.id} | ||||||
|                 option={behavior.parameterOption} |                 option={behavior.parameterOption} | ||||||
|                 value={behavior.parameter} |                 value={behavior.parameter} | ||||||
|                 i18n={(name, language) => behavior.getTerms(name, language)} |                 i18n={(name, language) => behavior.getTerms(name, language)} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user