Compare commits
	
		
			3 Commits
		
	
	
		
			2cf9a22907
			...
			c10dd6e882
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c10dd6e882 | |||
| 4d818988f9 | |||
| a23b5d62cc | 
| @ -112,7 +112,7 @@ class BehaviorList extends Component<IBehaviorListProps & IMixinSettingProps & I | |||||||
| 		if (behavior instanceof Behavior) { | 		if (behavior instanceof Behavior) { | ||||||
| 			id = behavior.id; | 			id = behavior.id; | ||||||
| 			name = behavior.name; | 			name = behavior.name; | ||||||
| 			color = behavior.color; | 			color = `rgb(${behavior.color.join(",")})`; | ||||||
| 			needLocal = false; | 			needLocal = false; | ||||||
|             info = behavior.behaviorName; |             info = behavior.behaviorName; | ||||||
| 		} | 		} | ||||||
|  | |||||||
| @ -62,7 +62,7 @@ class BehaviorPicker extends Component<IBehaviorPickerProps & IMixinSettingProps | |||||||
| 
 | 
 | ||||||
|             return <> |             return <> | ||||||
|                 <div className="behavior-picker-line-color-view"> |                 <div className="behavior-picker-line-color-view"> | ||||||
|                     <div style={{ borderLeft: `10px solid ${behavior.color}` }}/> |                     <div style={{ borderLeft: `10px solid rgb(${behavior.color.join(",")})` }}/> | ||||||
|                 </div> |                 </div> | ||||||
|                 <div |                 <div | ||||||
|                     className="behavior-picker-line-icon-view" |                     className="behavior-picker-line-icon-view" | ||||||
|  | |||||||
| @ -123,8 +123,7 @@ class BehaviorPopupComponent extends Component< | |||||||
|                 ) + " " + (recorder.nameIndex - 1).toString(); |                 ) + " " + (recorder.nameIndex - 1).toString(); | ||||||
| 
 | 
 | ||||||
|                 // 赋予一个随机颜色
 |                 // 赋予一个随机颜色
 | ||||||
|                 let color = randomColor(true); |                 newBehavior.color = randomColor(true); | ||||||
|                 newBehavior.color = `rgb(${color[0]},${color[1]},${color[2]})`; |  | ||||||
|             } |             } | ||||||
|         }); |         }); | ||||||
|         this.props.onDismiss ? this.props.onDismiss() : undefined; |         this.props.onDismiss ? this.props.onDismiss() : undefined; | ||||||
|  | |||||||
| @ -11,7 +11,7 @@ import { Setting } from "./Setting"; | |||||||
| import { I18N } from "@Component/Localization/Localization"; | import { I18N } from "@Component/Localization/Localization"; | ||||||
| import { superConnectWithEvent, superConnect } from "./Context"; | import { superConnectWithEvent, superConnect } from "./Context"; | ||||||
| import { PopupController } from "./Popups"; | import { PopupController } from "./Popups"; | ||||||
| import { Behavior } from "@Model/Behavior"; | import { Behavior, IBehaviorParameter, IParamValue } from "@Model/Behavior"; | ||||||
| import { Actuator } from "@Model/Actuator"; | import { Actuator } from "@Model/Actuator"; | ||||||
| 
 | 
 | ||||||
| function randomColor(unNormal: boolean = false) { | function randomColor(unNormal: boolean = false) { | ||||||
| @ -43,6 +43,7 @@ interface IStatusEvent { | |||||||
|     rangeAttrChange: void; |     rangeAttrChange: void; | ||||||
|     labelAttrChange: void; |     labelAttrChange: void; | ||||||
|     groupAttrChange: void; |     groupAttrChange: void; | ||||||
|  |     behaviorAttrChange: void; | ||||||
|     individualChange: void; |     individualChange: void; | ||||||
|     behaviorChange: void; |     behaviorChange: void; | ||||||
|     popupChange: void; |     popupChange: void; | ||||||
| @ -193,6 +194,24 @@ class Status extends Emitter<IStatusEvent> { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     /** | ||||||
|  |      * 修改群属性 | ||||||
|  |      */ | ||||||
|  |     public changeBehaviorAttrib<K extends IBehaviorParameter, P extends keyof K | keyof Behavior<K>> | ||||||
|  |     (id: ObjectID, key: P, val: IParamValue<K[P]>) { | ||||||
|  |         const behavior = this.model.getBehaviorById(id); | ||||||
|  |         if (behavior) { | ||||||
|  |             if (key === "color") { | ||||||
|  |                 behavior.color = val as number[]; | ||||||
|  |             } else if (key === "name") { | ||||||
|  |                 behavior.name = val as string; | ||||||
|  |             } else { | ||||||
|  |                 behavior.parameter[key] = val; | ||||||
|  |             } | ||||||
|  |             this.emit("behaviorAttrChange"); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     public addGroupBehavior(id: ObjectID, val: Behavior) { |     public addGroupBehavior(id: ObjectID, val: Behavior) { | ||||||
|         const group = this.model.getObjectById(id); |         const group = this.model.getObjectById(id); | ||||||
|         if (group && group instanceof Group) { |         if (group && group instanceof Group) { | ||||||
|  | |||||||
| @ -295,7 +295,7 @@ class Behavior< | |||||||
|     /** |     /** | ||||||
|      * 颜色 |      * 颜色 | ||||||
|      */ |      */ | ||||||
|     public color: string = ""; |     public color: number[] = [0, 0, 0]; | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|      * 优先级 |      * 优先级 | ||||||
| @ -397,7 +397,7 @@ class Behavior< | |||||||
| type IRenderBehavior = BehaviorInfo | Behavior; | type IRenderBehavior = BehaviorInfo | Behavior; | ||||||
| 
 | 
 | ||||||
| export { | export { | ||||||
|     Behavior, BehaviorRecorder, IBehaviorParameterOption, IBehaviorParameterOptionItem, |     Behavior, BehaviorRecorder, IBehaviorParameterOption, IBehaviorParameterOptionItem, IParamValue, | ||||||
|     IAnyBehavior, IAnyBehaviorRecorder, BehaviorInfo, IRenderBehavior |     IAnyBehavior, IAnyBehaviorRecorder, BehaviorInfo, IRenderBehavior, IBehaviorParameter | ||||||
| }; | }; | ||||||
| export default { Behavior }; | export default { Behavior }; | ||||||
| @ -56,11 +56,11 @@ class SimulatorWeb extends Component { | |||||||
|             this.status.newLabel().name = "New Label"; |             this.status.newLabel().name = "New Label"; | ||||||
|             this.status.newLabel().name = "Test Label 01"; |             this.status.newLabel().name = "Test Label 01"; | ||||||
|             let dynamic = this.status.model.addBehavior(AllBehaviors[0]); |             let dynamic = this.status.model.addBehavior(AllBehaviors[0]); | ||||||
|             dynamic.name = "Dynamic"; dynamic.color = "rgb(250, 200, 80)"; |             dynamic.name = "Dynamic"; dynamic.color = [250, 200, 80]; | ||||||
|             let brownian = this.status.model.addBehavior(AllBehaviors[1]); |             let brownian = this.status.model.addBehavior(AllBehaviors[1]); | ||||||
|             brownian.name = "Brownian"; brownian.color = "rgb(200, 80, 250)"; |             brownian.name = "Brownian"; brownian.color = [200, 80, 250]; | ||||||
|             let boundary = this.status.model.addBehavior(AllBehaviors[2]); |             let boundary = this.status.model.addBehavior(AllBehaviors[2]); | ||||||
|             boundary.name = "Boundary"; boundary.color = "rgb(80, 200, 250)"; |             boundary.name = "Boundary"; boundary.color = [80, 200, 250]; | ||||||
|             boundary.parameter.range = this.status.model.allRangeLabel; |             boundary.parameter.range = this.status.model.allRangeLabel; | ||||||
|             group.addBehavior(dynamic); |             group.addBehavior(dynamic); | ||||||
|             group.addBehavior(brownian); |             group.addBehavior(brownian); | ||||||
|  | |||||||
| @ -2,15 +2,36 @@ import { Component, ReactNode} from "react"; | |||||||
| import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | ||||||
| import { Behavior } from "@Model/Behavior"; | import { Behavior } from "@Model/Behavior"; | ||||||
| import { Message } from "@Component/Message/Message"; | import { Message } from "@Component/Message/Message"; | ||||||
|  | import { AttrInput } from "@Component/AttrInput/AttrInput"; | ||||||
|  | import { ColorInput } from "@Component/ColorInput/ColorInput"; | ||||||
| import "./BehaviorDetails.scss"; | import "./BehaviorDetails.scss"; | ||||||
| 
 | 
 | ||||||
| interface IBehaviorDetailsProps {} | interface IBehaviorDetailsProps {} | ||||||
| 
 | 
 | ||||||
| @useStatusWithEvent("focusBehaviorChange") | @useStatusWithEvent("focusBehaviorChange", "behaviorAttrChange") | ||||||
| class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProps> { | class BehaviorDetails extends Component<IBehaviorDetailsProps & IMixinStatusProps> { | ||||||
| 
 | 
 | ||||||
| 	private renderFrom(behavior: Behavior): ReactNode { | 	private renderFrom(behavior: Behavior): ReactNode { | ||||||
| 		return <></>; | 		return <> | ||||||
|  |          | ||||||
|  |             <Message i18nKey="Common.Attr.Title.Basic" isTitle first/> | ||||||
|  | 
 | ||||||
|  |             <AttrInput | ||||||
|  |                 id={behavior.id} keyI18n="Common.Attr.Key.Display.Name" value={behavior.name} | ||||||
|  |                 valueChange={(val) => { | ||||||
|  |                     this.props.status?.changeBehaviorAttrib(behavior.id, "name", val); | ||||||
|  |                 }} | ||||||
|  |             /> | ||||||
|  | 
 | ||||||
|  |             <ColorInput | ||||||
|  |                 keyI18n="Common.Attr.Key.Color" | ||||||
|  |                 value={behavior.color} | ||||||
|  |                 valueChange={(color) => { | ||||||
|  |                     this.props.status?.changeBehaviorAttrib(behavior.id, "color", color); | ||||||
|  |                 }} | ||||||
|  |             /> | ||||||
|  | 
 | ||||||
|  |         </>; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public render(): ReactNode { | 	public render(): ReactNode { | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ interface IBehaviorListProps { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @useSetting | @useSetting | ||||||
| @useStatusWithEvent("behaviorChange", "focusBehaviorChange") | @useStatusWithEvent("behaviorChange", "focusBehaviorChange", "behaviorAttrChange") | ||||||
| class BehaviorList extends Component<IBehaviorListProps & IMixinStatusProps & IMixinSettingProps> { | class BehaviorList extends Component<IBehaviorListProps & IMixinStatusProps & IMixinSettingProps> { | ||||||
|      |      | ||||||
|     private labelInnerClick: boolean = false; |     private labelInnerClick: boolean = false; | ||||||
| @ -45,9 +45,9 @@ class BehaviorList extends Component<IBehaviorListProps & IMixinStatusProps & IM | |||||||
|                     if (this.props.status) { |                     if (this.props.status) { | ||||||
|                         this.props.status.setBehaviorObject(behavior as Behavior); |                         this.props.status.setBehaviorObject(behavior as Behavior); | ||||||
|                     } |                     } | ||||||
|                     // if (this.props.setting) {
 |                     if (this.props.setting) { | ||||||
|                     //     this.props.setting.layout.focus("LabelDetails");
 |                         this.props.setting.layout.focus("BehaviorDetails"); | ||||||
|                     // }
 |                     } | ||||||
|                     this.labelInnerClick = true; |                     this.labelInnerClick = true; | ||||||
|                 }} |                 }} | ||||||
|                 onAdd={() => { |                 onAdd={() => { | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| import { Component, ReactNode } from "react"; | import { Component, ReactNode } from "react"; | ||||||
| import { AttrInput } from "@Component/AttrInput/AttrInput"; | import { AttrInput } from "@Component/AttrInput/AttrInput"; | ||||||
| import { useStatusWithEvent, IMixinStatusProps, Status } from "@Context/Status"; | import { useStatusWithEvent, IMixinStatusProps } from "@Context/Status"; | ||||||
|  | import { useSetting, IMixinSettingProps } from "@Context/Setting"; | ||||||
| import { Message } from "@Component/Message/Message"; | import { Message } from "@Component/Message/Message"; | ||||||
| import { ObjectID } from "@Model/Renderer"; | import { ObjectID } from "@Model/Renderer"; | ||||||
| import { ColorInput } from "@Component/ColorInput/ColorInput"; | import { ColorInput } from "@Component/ColorInput/ColorInput"; | ||||||
| @ -25,11 +26,13 @@ const allOption: IDisplayItem[] = [ | |||||||
|     {nameKey: "Common.Attr.Key.Generation.Mod.Range", key: GenMod.Range} |     {nameKey: "Common.Attr.Key.Generation.Mod.Range", key: GenMod.Range} | ||||||
| ]; | ]; | ||||||
| 
 | 
 | ||||||
|  | @useSetting | ||||||
| @useStatusWithEvent( | @useStatusWithEvent( | ||||||
|     "groupAttrChange", "groupLabelChange", "focusObjectChange", |     "groupAttrChange", "groupLabelChange", "focusObjectChange", | ||||||
|     "focusBehaviorChange", "behaviorChange", "groupBehaviorChange" |     "focusBehaviorChange", "behaviorChange", "groupBehaviorChange", | ||||||
|  |     "behaviorAttrChange" | ||||||
| ) | ) | ||||||
| class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> { | class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps & IMixinSettingProps> { | ||||||
| 
 | 
 | ||||||
| 	private renderFrom(group: Group) { | 	private renderFrom(group: Group) { | ||||||
| 		return <> | 		return <> | ||||||
| @ -122,6 +125,9 @@ class GroupDetails extends Component<IGroupDetailsProps & IMixinStatusProps> { | |||||||
|                 }} |                 }} | ||||||
|                 action={(behavior) => { |                 action={(behavior) => { | ||||||
|                     this.props.status?.setBehaviorObject(behavior); |                     this.props.status?.setBehaviorObject(behavior); | ||||||
|  |                     setTimeout(() => { | ||||||
|  |                         this.props.setting?.layout.focus("BehaviorDetails"); | ||||||
|  |                     }); | ||||||
|                 }} |                 }} | ||||||
|                 delete={(behavior) => { |                 delete={(behavior) => { | ||||||
|                     this.props.status?.deleteGroupBehavior(group.id, behavior); |                     this.props.status?.deleteGroupBehavior(group.id, behavior); | ||||||
|  | |||||||
| @ -20,16 +20,19 @@ div.object-list { | |||||||
|             opacity: 0; |             opacity: 0; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         i.checkbox-icon:hover { |  | ||||||
|             color: $lt-green; |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         i.type-icon { |         i.type-icon { | ||||||
|             display: inline-block; |             display: inline-block; | ||||||
|             opacity: 1; |             opacity: 1; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     div.object-list-checkbox:hover { | ||||||
|  | 
 | ||||||
|  |         i.checkbox-icon { | ||||||
|  |             color: $lt-green !important; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|     div.details-list-item:hover { |     div.details-list-item:hover { | ||||||
| 
 | 
 | ||||||
|         div.object-list-checkbox { |         div.object-list-checkbox { | ||||||
|  | |||||||
| @ -51,9 +51,6 @@ class ObjectList extends Component<IMixinStatusProps & IMixinSettingProps> { | |||||||
|                 } |                 } | ||||||
|             }} |             }} | ||||||
|             checkBox={(item) => { |             checkBox={(item) => { | ||||||
|                 if (this.props.setting) { |  | ||||||
|                     this.props.setting.layout.focus("ObjectList"); |  | ||||||
|                 } |  | ||||||
|                 if (this.props.status) { |                 if (this.props.status) { | ||||||
|                     if ( |                     if ( | ||||||
|                         this.props.status.focusObject.has(item.key.toString()) || |                         this.props.status.focusObject.has(item.key.toString()) || | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user