public void InspectObject(AgentType agentType, string agentFullname, Nodes.Node node) { _agentFullname = agentFullname; preLayout(); deleteAllRowControls(); if (agentType != null) { IList<PropertyDef> properties = agentType.GetProperties(); foreach (PropertyDef p in properties) { addRowControl(p, null); } } else if (node != null) { List<ParInfo> allPars = node.Pars; foreach (ParInfo par in allPars) { addRowControl(null, par); } } postLayout(); }
public MetaMethodDialog(AgentType agent, MethodDef method, MemberType memberType) { InitializeComponent(); this.Owner = MainWindow.Instance; this.metaMethodPanel.Initialize(true, agent, method, memberType); }
public MetaPropertyDialog(bool canBeEdited, AgentType agent, CustomizedStruct customizedStruct, PropertyDef prop, bool canBePar) { InitializeComponent(); this.Owner = MainWindow.Instance; this.metaPropertyPanel.Initialize(canBeEdited, agent, customizedStruct, prop, canBePar); }
internal static void Inspect(AgentType agentType, string agentName, string agentFullName, FrameStatePool.PlanningState nodeState) { ParametersDock dock = findParametersDock(agentType, agentName); if (dock == null) { dock = new ParametersDock(); dock.Show(MainWindow.Instance.DockPanel, WeifenLuo.WinFormsUI.Docking.DockState.DockBottom); } dock.InspectObject(agentType, agentName, agentFullName, nodeState); }
public override bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method = null, PropertyDef property = null) { bool bReset = false; if (this._frames != null) { bReset |= this._frames.ResetMembers(check, agentType, clear, method, property); } bReset |= base.ResetMembers(check, agentType, clear, method, property); return bReset; }
public void Initialize(bool canBeEdit, AgentType agent, CustomizedStruct customizedStruct, PropertyDef prop, bool canBePar) { Debug.Check(agent != null || customizedStruct != null); _initialized = false; _isModified = false; _isNew = (prop == null); _agent = agent; _customizedStruct = customizedStruct; _originalProperty = prop; setTypes(); if (_isNew) { this.Text = canBeEdit ? Resources.AddProperty : Resources.ViewProperty; if (customizedStruct == null) _property = new PropertyDef(agent, null, agent.AgentTypeName, "", "", ""); else _property = new PropertyDef(null, null, customizedStruct.Name, "", "", ""); } else { this.Text = canBeEdit ? Resources.EditProperty : Resources.ViewProperty; resetProperty(prop, prop.IsPar); } this.isStaticCheckBox.Visible = (agent != null); this.isPublicCheckBox.Visible = !canBeEdit && (agent != null); this.isConstcheckBox.Visible = (agent != null); this.customizedCheckBox.Visible = !canBeEdit && !_property.IsInherited; this.isLocalCheckBox.Checked = customizedStruct == null && _property.IsPar; this.isLocalCheckBox.Visible = canBePar && customizedStruct == null && !_property.IsMember; this.nameTextBox.Enabled = canBeEdit; this.arrayCheckBox.Enabled = canBeEdit || _property.IsChangeableType; this.typeComboBox.Enabled = canBeEdit || _property.IsChangeableType; this.isStaticCheckBox.Enabled = canBeEdit; this.isConstcheckBox.Enabled = canBeEdit; this.dispTextBox.Enabled = canBeEdit; this.descTextBox.Enabled = canBeEdit; _initialized = true; }
public void InspectObject(AgentType agentType, string agentFullname) { _agentFullname = agentFullname; preLayout(); deleteAllRowControls(); if (agentType != null) { IList<PropertyDef> properties = agentType.GetProperties(); foreach(PropertyDef p in properties) { if (!p.IsAddedAutomatically) { addRowControl(p); } } } postLayout(); }
private static void LoadCustomMembers(List<Nodes.Node.ErrorCheck> result, XmlNode rootNode) { if (rootNode == null) { return; } // Set the default base agent. if (Plugin.AgentTypes.Count == 0) { AgentType agent = new AgentType(typeof(Agent), "Agent", false, "Agent", ""); Plugin.AgentTypes.Add(agent); } foreach(XmlNode xmlNode in rootNode.ChildNodes) { if (xmlNode.Name == "agent") { string agentName = GetAttribute(xmlNode, "type"); string agentBase = GetAttribute(xmlNode, "base"); int baseIndex = -1; for (int i = 0; i < Plugin.AgentTypes.Count; ++i) { if (Plugin.AgentTypes[i].AgentTypeName == agentBase) { baseIndex = i; break; } } string agentDisp = GetAttribute(xmlNode, "disp"); string agentDesc = GetAttribute(xmlNode, "desc"); if (string.IsNullOrEmpty(agentDisp)) { agentDisp = agentName; } AgentType agent = Plugin.GetAgentType(agentName); if (agent == null) { agent = new AgentType(agentName, (baseIndex > -1) ? Plugin.AgentTypes[baseIndex] : null, agentDisp, agentDesc); Plugin.AgentTypes.Add(agent); } foreach(XmlNode bbNode in xmlNode) { if (bbNode.Name == "properties") { foreach(XmlNode propNode in bbNode) { if (propNode.Name == "property") { string propName = GetAttribute(propNode, "name"); string isStatic = GetAttribute(propNode, "static"); bool bStatic = false; if (!string.IsNullOrEmpty(isStatic) && isStatic == "true") { bStatic = true; } string isPublic = GetAttribute(propNode, "public"); bool bPublic = false; if (string.IsNullOrEmpty(isPublic) || isPublic == "true") { bPublic = true; } string isReadonly = GetAttribute(propNode, "readonly"); bool bReadonly = false; if (!string.IsNullOrEmpty(isReadonly) && isReadonly == "true") { bReadonly = true; } string propType = GetAttribute(propNode, "type"); Type type = Plugin.GetTypeFromName(propType); string classname = GetAttribute(propNode, "classname"); if (string.IsNullOrEmpty(classname)) { classname = agent.AgentTypeName; } string propDisp = GetAttribute(propNode, "disp"); if (string.IsNullOrEmpty(propDisp)) { propDisp = propName; } string propDesc = GetAttribute(propNode, "desc"); PropertyDef prop = new PropertyDef(agent, type, classname, propName, propDisp, propDesc); prop.IsStatic = bStatic; prop.IsPublic = bPublic; prop.IsReadonly = bReadonly; string defaultValue = GetAttribute(propNode, "defaultvalue"); if (!string.IsNullOrEmpty(defaultValue)) { prop.Variable = new VariableDef(null); Plugin.InvokeTypeParser(result, type, defaultValue, (object value) => prop.Variable.Value = value, null); } agent.AddProperty(prop); } } } else if (bbNode.Name == "methods") { foreach(XmlNode methodNode in bbNode) { if (methodNode.Name == "method") { string methodName = GetAttribute(methodNode, "name"); Type returnType = Plugin.GetTypeFromName(GetAttribute(methodNode, "returntype")); string isStatic = GetAttribute(methodNode, "static"); bool bStatic = false; if (!string.IsNullOrEmpty(isStatic) && isStatic == "true") { bStatic = true; } string isPublic = GetAttribute(methodNode, "public"); bool bPublic = false; if (string.IsNullOrEmpty(isPublic) || isPublic == "true") { bPublic = true; } string classname = GetAttribute(methodNode, "classname"); if (string.IsNullOrEmpty(classname)) { classname = agent.AgentTypeName; } string methodDisp = GetAttribute(methodNode, "disp"); if (string.IsNullOrEmpty(methodDisp)) { methodDisp = methodName; } string methodDesc = GetAttribute(methodNode, "desc"); bool istask = (GetAttribute(methodNode, "istask") == "true"); //bool isevent = (GetAttribute(methodNode, "isevent") == "true"); MemberType memberType = MemberType.Method; if (istask) { memberType = MemberType.Task; } methodName = string.Format("{0}::{1}", agent.AgentTypeName, methodName); MethodDef method = new MethodDef(agent, memberType, classname, methodName, methodDisp, methodDesc, "", returnType); method.IsStatic = bStatic; method.IsPublic = bPublic; agent.AddMethod(method); foreach(XmlNode paramNode in methodNode) { string paramName = GetAttribute(paramNode, "name"); Type paramType = Plugin.GetTypeFromName(GetAttribute(paramNode, "type")); bool isOut = (GetAttribute(paramNode, "isout") == "true"); bool isRef = (GetAttribute(paramNode, "isref") == "true"); string nativeType = Plugin.GetNativeTypeName(paramType); string paramDisp = GetAttribute(paramNode, "disp"); if (string.IsNullOrEmpty(paramDisp)) { paramDisp = paramName; } string paramDesc = GetAttribute(paramNode, "desc"); MethodDef.Param param = new MethodDef.Param(paramName, paramType, nativeType, paramDisp, paramDesc); param.IsOut = isOut; param.IsRef = isRef; method.Params.Add(param); } } } } } } } }
private void agentTypeChanged(AgentType agentType) { //CheckErrors(_rootNode.RootBehavior, true); //PropertiesDock.UpdatePropertyGrids(); this.Redraw(); }
public MethodDef(AgentType agentType, MemberType memberType, bool isChangeableType, bool isPublic, bool isStatic, string classname, string owner, string name, string displayName, string description, string nativeReturnType, Type returnType, bool isActionMethodOnly, List<Param> pars) { _agentType = agentType; _isChangeableType = isChangeableType; _isPublic = isPublic; _isStatic = isStatic; _classname = classname; _owner = owner; _name = name; _displayName = displayName; _description = description; _nativeReturnType = string.IsNullOrEmpty(nativeReturnType) ? Plugin.GetNativeTypeName(returnType) : nativeReturnType; _returnType = returnType; _isActionMethodOnly = isActionMethodOnly; _params = pars; _memberType = memberType; _isCustomized = (memberType == Design.MemberType.Task); }
public bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method, PropertyDef property) { if (this.IsMethod && this.Method != null) { if (method != null && method.OldName == this.Method.Name) { if (!check) { if (clear || this.Method.ShouldBeCleared(agentType)) { this.m_method = null; } else { this.Method.CopyFrom(method); } } return true; } return this.Method.ResetMembers(check, agentType, clear, method, property); } else if (this.Var != null) { return this.Var.ResetMembers(check, agentType, clear, property); } return false; }
public bool ResetMembers(bool check, AgentType agentType, bool clear, PropertyDef property) { if (property != null && this._property != null && (property.OldName == this._property.Name || !property.IsArrayElement && this._property.IsArrayElement && (property.OldName + "[]") == this._property.Name)) { if (!check) { if (clear || this._property.ShouldBeCleared(agentType)) { this._property = null; } else { bool isArrayElement = this._property.IsArrayElement; this._property.CopyFrom(property); if (isArrayElement) { this._property.SetArrayElement(property); } } } return true; } return false; }
public bool ShouldBeCleared(AgentType agentType) { return (this.Owner == VariableDef.kSelf && !Plugin.IsAgentDerived(this.AgentType.AgentTypeName, agentType.AgentTypeName)); }
// Meta Property public PropertyDef(AgentType agentType, FieldInfo pi, bool isChangeableType, bool isStatic, bool isPublic, bool isProperty, bool isReadonly, string classname, string owner, string name, string nativeType, string displayName, string description) { _agentType = agentType; _propertyInfo = pi; _isChangeableType = isChangeableType; _isStatic = isStatic; _isPublic = isPublic; _isProperty = isProperty; _isReadonly = isReadonly; _classname = classname; _owner = owner; _name = name; _nativeType = nativeType; _displayName = displayName; _description = description; }
public override bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method = null, PropertyDef property = null) { bool bReset = false; if (this._task != null && method != null && this._task.Name == method.OldName) { if (method != null && this._task.Name == method.OldName && (clear || this._task.ShouldBeCleared(agentType))) { bReset = true; if (!check) { this._task = null; } } else { bReset |= this._task.ResetMembers(check, agentType, clear, method, property); } } bReset |= base.ResetMembers(check, agentType, clear, method, property); return bReset; }
private void setText(AgentType agentType, string agentName) { // Par if (agentType == null) { Text = TabText = string.IsNullOrEmpty(agentName) ? Resources.Pars : string.Format(Resources.ParsOf, agentName); } // Global else if (Plugin.IsGlobalInstanceAgentType(agentType)) { Text = TabText = string.Format(Resources.PropertiesOf, agentType.ToString()); } // Agent else { Text = TabText = string.Format(Resources.PropertiesOf + "::{1}", agentType.ToString(), agentName); } }
public void InspectObject(AgentType agentType, string agentFullName) { this.parametersPanel.InspectObject(agentType, agentFullName); }
private void InspectObject(AgentType agentType, string agentName, string agentFullName, FrameStatePool.PlanningState nodeState) { Nodes.Node node = null; if (agentType == null && !string.IsNullOrEmpty(agentFullName)) { int frame = AgentDataPool.CurrentFrame > -1 ? AgentDataPool.CurrentFrame : 0; string behaviorFilename = FrameStatePool.GetBehaviorFilename(agentFullName, frame); List<string> transitionIds = FrameStatePool.GetHighlightTransitionIds(agentFullName, frame, behaviorFilename); List<string> highlightNodeIds = FrameStatePool.GetHighlightNodeIds(agentFullName, frame, behaviorFilename); List<string> updatedNodeIds = FrameStatePool.GetUpdatedNodeIds(agentFullName, frame, behaviorFilename); Dictionary<string, FrameStatePool.NodeProfileInfos.ProfileInfo> profileInfos = FrameStatePool.GetProfileInfos(frame, behaviorFilename); BehaviorNode behavior = UIUtilities.ShowBehaviorTree(agentFullName, frame, transitionIds, highlightNodeIds, updatedNodeIds, HighlightBreakPoint.Instance, profileInfos); node = behavior as Nodes.Node; } _agentType = agentType; _agentName = agentName; Hide(); setText(agentType, agentName); if (nodeState != null) { foreach(string agentFullName1 in nodeState._agents.Keys) { string[] tokens = agentFullName1.Split('#'); Debug.Check(tokens.Length == 2); string at = tokens[0]; string an = tokens[1]; AgentType agentType1 = Plugin.GetAgentType(at); ParametersDock dock = findParametersDock(agentType1, an); dock.InspectObject(agentType1, agentFullName1); dock.setProperty(nodeState, agentFullName1); } } else if (AgentDataPool.CurrentFrame > -1 && !string.IsNullOrEmpty(agentName)) { ParametersDock dock = findParametersDock(agentType, agentName); dock.InspectObject(agentType, agentFullName); List<AgentDataPool.ValueMark> valueSet = AgentDataPool.GetValidValues(agentType, agentFullName, AgentDataPool.CurrentFrame); foreach(AgentDataPool.ValueMark value in valueSet) { dock.setProperty(value.Name, value.Value); } } lostAnyFocus(); Show(); }
public bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method, PropertyDef property) { bool bReset = false; if (method != null) { if (method.OldName == this.Name) { bReset = true; if (!check) { this.CopyFrom(method); } } } else if (property != null) { foreach (MethodDef.Param param in this.Params) { if (param.Value is VariableDef) { VariableDef var = param.Value as VariableDef; bReset |= var.ResetMembers(check, agentType, clear, property); } else if (param.Value is ParInfo) { ParInfo par = param.Value as ParInfo; if (property.IsPar && (property.OldName == par.Name || !property.IsArrayElement && par.IsArrayElement && (property.OldName + "[]") == par.Name)) { if (clear || this.ShouldBeCleared(agentType)) { bReset = true; if (!check) { param.Value = Plugin.DefaultValue(param.Type); } } else { bReset = true; if (!check) { bool isArrayElement = par.IsArrayElement; par.CopyFrom(property); if (isArrayElement) { par.SetArrayElement(property); } } } } } } } return bReset; }
private static ParametersDock findParametersDock(AgentType agentType, string agentName) { foreach(ParametersDock dock in _parameterDocks) { if (dock.AgentType == agentType && (string.IsNullOrEmpty(dock.AgentName) || dock.AgentName == agentName)) { return dock; } } return null; }
// Customized Property public PropertyDef(AgentType agentType, Type type, string classname, string name, string displayName, string description) { _agentType = agentType; _propertyInfo = null; _type = type; _isChangeableType = false; _isStatic = false; _isPublic = true; _isProperty = false; _classname = classname; _owner = VariableDef.kSelf; _name = name; _nativeType = Plugin.GetNativeTypeName(type); _displayName = displayName; _description = description; }
public override bool ResetMembers(bool check, AgentType agentType, bool clear, MethodDef method = null, PropertyDef property = null) { bool bReset = false; if (this.Opl != null) { bReset |= this.Opl.ResetMembers(check, agentType, clear, method, property); } if (this.Opr1 != null) { bReset |= this.Opr1.ResetMembers(check, agentType, clear, method, property); } if (this.Opr2 != null) { bReset |= this.Opr2.ResetMembers(check, agentType, clear, method, property); } bReset |= base.ResetMembers(check, agentType, clear, method, property); if (!check && bReset) { OnPropertyValueChanged(false); } return bReset; }
public bool ShouldBeCleared(AgentType agentType) { if (this.IsProperty && this.Property != null) { return this.Property.ShouldBeCleared(agentType); } return false; }
private void updateParameters(AgentType agentType, string agentName, int frame) { if (string.IsNullOrEmpty(agentName)) { return; } string typeName = (agentType == null) ? agentName : agentType.ToString(); string agentFullname = (agentType == null) ? agentName : agentType.ToString() + "#" + agentName; List<AgentDataPool.ValueMark> values = AgentDataPool.GetValidValues(agentType, agentFullname, frame); foreach(AgentDataPool.ValueMark value in values) { ParametersDock.SetProperty(typeName, agentName, value.Name, value.Value); } }
public bool ShouldBeCleared(AgentType agentType) { if (this.IsMethod && this.Method != null) { return this.Method.ShouldBeCleared(agentType); } if (this.Var != null) { return this.Var.ShouldBeCleared(agentType); } return false; }
private void resetMembersInWorkspace(AgentType agentType, bool clear, MethodDef method, PropertyDef property) { foreach(Nodes.BehaviorNode behavior in getAllBehaviors(property)) { if (behavior != null && behavior is Nodes.Node) { bool bReset = ((Nodes.Node)behavior).ResetMembers(false, agentType, clear, method, property); if (bReset) UndoManager.Save(behavior); } } }
public ParInfo(Nodes.Node node, AgentType agent) : base(agent, null, (agent != null) ? agent.AgentTypeName : "", "", "", "") { _node = node; }
private void typeListBox_SelectedIndexChanged(object sender, EventArgs e) { this.addMemberButton.Enabled = true; this.removeTypeButton.Enabled = false; int typeIndex = this.typeListBox.SelectedIndex; if (typeIndex >= 0) { _previousSelectedMemberIndex = -1; if (_previousSelectedTypeIndex != typeIndex) { apply(false, _previousSelectedTypeIndex, -1, false); _previousSelectedTypeIndex = typeIndex; } this.removeTypeButton.Enabled = true; this.instanceComboBox.Items.Clear(); if (this.typeListBox.SelectedIndex < Plugin.AgentTypes.Count) { _lastAgent = Plugin.AgentTypes[this.typeListBox.SelectedIndex]; AgentType currentViewAgentType = getCurrentViewAgentType(); // set all instance names if (currentViewAgentType != null && currentViewAgentType == _lastAgent) { this.instanceComboBox.Items.Add(VariableDef.kSelf); } foreach(Plugin.InstanceName_t instanceName in Plugin.InstanceNames) { if (instanceName.agentType_ == _lastAgent && _lastAgent != currentViewAgentType) { this.instanceComboBox.Items.Add(instanceName.displayName_); } } if (this.instanceComboBox.Items.Count > 0) { this.instanceComboBox.SelectedIndex = 0; } if (!Plugin.AgentTypes[this.typeListBox.SelectedIndex].IsCustomized) { this.removeTypeButton.Enabled = false; } } this.metaTypePanel.Initialize(this.getSelectedType()); setMembers(); if (this.typeListBox.SelectedIndex == 0) { this.addMemberButton.Enabled = false; } } if (this._metaPropertyPanel != null) { this._metaPropertyPanel.Hide(); } if (this._metaMethodPanel != null) { this._metaMethodPanel.Hide(); } if (this._editEnumMemberPanel != null) { this._editEnumMemberPanel.Hide(); } initMetaPanel(); }
// Customized Method public MethodDef(AgentType agentType, MemberType memberType, string classname, string name, string displayName, string description, string nativeReturnType, Type returnType) { _agentType = agentType; _isChangeableType = false; _isCustomized = true; _memberType = memberType; _isPublic = true; _isStatic = false; _classname = classname; _owner = classname; _name = name; _displayName = displayName; _description = description; _nativeReturnType = string.IsNullOrEmpty(nativeReturnType) ? Plugin.GetNativeTypeName(returnType) : nativeReturnType; _returnType = returnType; _isActionMethodOnly = false; }
private bool checkMembersInWorkspace(AgentType agentType, bool clear, MethodDef method, PropertyDef property) { foreach(Nodes.BehaviorNode behavior in getAllBehaviors(property)) { if (behavior != null && behavior is Nodes.Node) { bool bReset = ((Nodes.Node)behavior).ResetMembers(true, agentType, clear, method, property); if (bReset) return DialogResult.Yes == MessageBox.Show(Resources.ModifyMemberWarning, Resources.Warning, MessageBoxButtons.YesNo); } } return true; }