/* * Organizer Method */ public override void AddOrganization(GroupNode group, InterfaceNode currentNode) { VerticallyNonOverlappingPanelsNode non = new VerticallyNonOverlappingPanelsNode(); OverlappingPanelsNode over = new OverlappingPanelsNode(); currentNode.InsertAsParent(non); non.AddPanel(over); Hashtable deps = new Hashtable(_dependencies.Count); IEnumerator e = _dependencies.Keys.GetEnumerator(); PanelNode newP = null; while (e.MoveNext()) { GroupNode g = (GroupNode)e.Current; ArrayList aryDeps = (ArrayList)_dependencies[g]; newP = new PanelNode(g); over.AddPanel(newP); deps[aryDeps] = newP; g.Decorations.Add(PanelDecision.DECISION_KEY, new PanelDecision(this, newP)); } _activePanel = newP; _dependencies = deps; _uiValid = true; this.ValueChanged(_state); }
public IActionResult Panel(string id) { if (engine == null) { return(BadRequest()); } if (id == null || id == MAIN_PANEL_ID) { id = MAIN_PANEL_ID; ViewBag.panelName = "Main Panel"; } else { PanelNode panel = engine.GetPanel(id); if (panel == null) { return(NotFound()); } ViewBag.panelName = panel.Settings["Name"].Value; } ViewBag.panelId = id; return(View("Index")); }
private void _LoadRootPanel(XElement ele) { var rootNode = new PanelNode(null); rootNode.Load(ele); rootNode.ApplyLayout(this); rootNode.Dispose(); }
/* * Process Method */ public override PanelNode Process(GroupNode g, PanelNode p) { if (g.Decorations[PanelDecision.DECISION_KEY] != null) { return(((PanelDecision)g.Decorations[PanelDecision.DECISION_KEY]).Panel); } return(p); }
/// <summary> /// Uses A* to find a path from the starting panel to the end panel /// </summary> /// <param name="startPanel">The panel where the path will start</param> /// <param name="endPanel">The panel where the path will end</param> /// <param name="allowOccupiedPanels">Whether or not the path should avoid panels that are occupied</param> /// <param name="alignment">The grid alignment this path can go through</param> /// <returns>A list containing the constructed path</returns> public List <PanelBehaviour> GetPath(PanelBehaviour startPanel, PanelBehaviour endPanel, bool allowOccupiedPanels = false, GridAlignment alignment = GridAlignment.ANY) { PanelNode panelNode; List <PanelNode> openList = new List <PanelNode>(); PanelNode start = new PanelNode { panel = startPanel }; PanelNode end = new PanelNode { panel = endPanel }; openList.Add(start); List <PanelNode> closedList = new List <PanelNode>(); start.fScore = CustomHeuristic(startPanel, endPanel); while (openList.Count > 0) { openList = SortNodes(openList); panelNode = openList[0]; if (panelNode.panel == end.panel) { return(ReconstructPath(start, panelNode)); } openList.Remove(panelNode); closedList.Add(panelNode); foreach (PanelBehaviour neighbor in BlackBoardBehaviour.Instance.Grid.GetPanelNeighbors(panelNode.panel.Position)) { if (ContainsPanel(closedList, neighbor) || ContainsPanel(openList, neighbor)) { continue; } else if (neighbor.Occupied && !allowOccupiedPanels) { continue; } else { PanelNode newNode = new PanelNode { panel = neighbor }; newNode.gScore += panelNode.gScore; newNode.fScore = newNode.gScore + CustomHeuristic(neighbor, endPanel); newNode.parent = panelNode; openList.Add(newNode); } } } return(new List <PanelBehaviour>()); }
protected PanelNode invokeRules(GroupNode g, PanelNode p) { PanelNode output = p; for (int i = 0; i < _rules.Count; i++) { output = ((TreeBuildingRule)_rules[i]).Process(g, output); } return(output); }
/* * Process Method */ public override object Process(object o, UIGenerator ui) { Appliance a = (Appliance)o; PanelNode panel = (PanelNode)ui.InterfaceRoot; GroupNode group = a.GetRoot(); phaseHelper(group, panel); ui.InterfaceRoot = recoverRoot(panel); return(ui.InterfaceRoot); }
/* * Process Method */ public override PanelNode Process(GroupNode g, PanelNode p) { if (g.Decorations[OrganizationDecision.DECISION_KEY] != null) { OrganizationDecision d = (OrganizationDecision)g.Decorations[OrganizationDecision.DECISION_KEY]; // determine which groups belong with which panels, and // create the appropriate nodes in the interface tree d.AddOrganization(g, p); } return(p); }
public IActionResult Panel(string id, bool split) { if (engine == null) { return(View("Error", "Nodes Engine is not started.<br/><br/> <a href='/Config'>Check settings</a>")); } ViewBag.split = split; if (id == null || id == MAIN_PANEL_ID) { return(RedirectToAction("Index")); } PanelNode panel = engine.GetPanelNode(id); if (panel == null) { return(HttpNotFound()); } ViewBag.panelId = panel.Id; ViewBag.ownerPanelId = panel.PanelId; //create menu stack List <PanelNode> panelsStack = new List <PanelNode>(); bool findNext = true; while (findNext) { panelsStack.Add(panel); if (panel.PanelId == MAIN_PANEL_ID) { findNext = false; } else { panel = engine.GetPanelNode(panel.PanelId); } } panelsStack.Reverse(); ViewBag.panelsStack = panelsStack; ViewBag.Theme = SystemController.nodeEditorConfig.Theme; return(View("Index")); }
public async Task <string> GetNameForPanel(string id) { return(await Task.Run(() => { if (engine == null) { return null; } PanelNode panel = engine.GetPanel(id); return panel?.Settings["Name"].Value; })); }
private static void CreatePanel(PanelNode panelRoot, RectTransform layerRoot) { for (int i = 0; i < panelRoot.childNodeList.Count; i++) { if (panelRoot.childNodeList [i].isGroup) { RectTransform panelRectTrans = GameObjectPanel(panelRoot.childNodeList [i].Name, layerRoot); CreatePanel(panelRoot.childNodeList [i], panelRectTrans); } else { CreatePanel(panelRoot.childNodeList [i], layerRoot); } } }
/// <summary> /// Creates a list of panels that represent the path found /// </summary> /// <param name="startPanel">The panel the path starts from</param> /// <param name="endPanel">The panel the path ends with</param> private List <PanelBehaviour> ReconstructPath(PanelNode startPanel, PanelNode endPanel) { List <PanelBehaviour> currentPath = new List <PanelBehaviour>(); //Travels backwards from goal node using the node parent until it reaches the starting node PanelNode temp = endPanel; while (temp != null) { //Insert each panel at the beginning of the list so that the path is in the correct order currentPath.Insert(0, temp.panel); temp = temp.parent; } return(currentPath); }
/* * Process Method */ public override PanelNode Process(GroupNode g, PanelNode p) { if (g.Decorations[UnitDecision.DECISION_KEY] != null) { UnitDecision unitDecision = (UnitDecision)g.Decorations[UnitDecision.DECISION_KEY]; ConcreteInteractionObject cio = unitDecision.CIO; if (((ControlBasedCIO)cio).PrefersFullWidth() && !unitDecision.Handled) { p.AddRow(new FullWidthRow(p, cio)); unitDecision.Handled = true; } } return(p); }
/* * Process Method */ public override PanelNode Process(GroupNode g, PanelNode p) { if (g.Decorations[UnitDecision.DECISION_KEY] != null) { UnitDecision unitDecision = (UnitDecision)g.Decorations[UnitDecision.DECISION_KEY]; ConcreteInteractionObject cio = unitDecision.CIO; if (!unitDecision.Handled) { p.AddRow(new OneColumnRow(g, p, cio)); unitDecision.Handled = true; } } return(p); }
/* * Organizer Method */ public override void AddOrganization(GroupNode group, InterfaceNode currentNode) { TabbedOverlappingPanelsNode tab = new TabbedOverlappingPanelsNode(_state); MultiplePanelNode non = null; if (_vertical) { non = new HorizontallyNonOverlappingPanelsNode((PanelNode)currentNode, tab); } else { non = new VerticallyNonOverlappingPanelsNode(); currentNode.InsertAsParent(non); non.AddPanel(tab); } Hashtable deps = new Hashtable(_dependencies.Count); IEnumerator e = _dependencies.Keys.GetEnumerator(); PanelNode newP = null; while (e.MoveNext()) { GroupNode g = (GroupNode)e.Current; ArrayList aryDeps = (ArrayList)_dependencies[g]; EqualsDependency eqDep = (EqualsDependency)aryDeps[0]; try { newP = (PanelNode)tab.GetNodeByValue((int)eqDep.Value).GetChildNode(); newP.Group = g; } catch (Exception) { Globals.GetFrame(eqDep.State.Appliance).AddLogLine("Error in TabbedControlPanelOrganizer... Line 82"); } deps[aryDeps] = newP; g.Decorations.Add(PanelDecision.DECISION_KEY, new PanelDecision(this, newP)); } _activePanel = newP; _dependencies = deps; _uiValid = true; this.ValueChanged(_state); }
public async Task <string> SerializePanel(string id) { return(await Task.Run(() => { if (engine == null) { return null; } PanelNode node = engine.GetPanelNode(id); if (node == null) { return null; } return NodesEngineSerializer.SerializePanel(id, engine); })); }
private static void ImportPsdWindow() { Texture2D psdImg = (Texture2D)Selection.objects [0]; if (psdImg == null) { Debug.LogError("请选取一个PSD文件"); return; } RectTransform parentCanvas = GameObject.FindObjectOfType <Canvas> ().GetComponent <RectTransform> (); string RootName = Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(psdImg.GetInstanceID())); PanelNode panelNodeRoot = GetPanelNodeRoot(psdImg); RectTransform layerRoot = GameObjectPanel(panelNodeRoot.Name, parentCanvas); CreatePanel(panelNodeRoot, layerRoot); }
internal override List <KeyValuePair <string, Node> > OnDragAccept(UnityEngine.Object[] objectReferences) { var nodeList = new List <KeyValuePair <string, Node> >(); foreach (UnityEngine.Object obj in DragAndDrop.objectReferences) { var path = AssetDatabase.GetAssetPath(obj); if (string.IsNullOrEmpty(path) && obj is GameObject) { path = GetInstenceObjectPath(obj as GameObject); } if (!string.IsNullOrEmpty(path)) { FileAttributes attr = File.GetAttributes(path); PanelNode panelNode = null; if ((attr & FileAttributes.Directory) == FileAttributes.Directory) { var files = System.IO.Directory.GetFiles(path, "*.prefab", SearchOption.AllDirectories); foreach (var item in files) { panelNode = ScriptableObject.CreateInstance <PanelNode>(); panelNode.Info.guid = AssetDatabase.AssetPathToGUID(item); panelNode.name = typeof(PanelNode).FullName; nodeList.Add(new KeyValuePair <string, Node>(Path.GetFileNameWithoutExtension(item), panelNode)); } } else if (obj is GameObject) { panelNode = ScriptableObject.CreateInstance <PanelNode>(); var prefab = PrefabUtility.GetPrefabParent(obj); if (prefab == null) { prefab = obj; } panelNode.Info.guid = AssetDatabase.AssetPathToGUID(AssetDatabase.GetAssetPath(prefab as GameObject)); panelNode.name = typeof(PanelNode).FullName; nodeList.Add(new KeyValuePair <string, Node>(prefab.name, panelNode)); } } } return(nodeList); }
private static List <PanelNode> GetLayer(Texture2D psdFile, string filter = "") { List <PanelNode> PanelNodeList = new List <PanelNode> (); PsdExportSettings settings = new PsdExportSettings(psdFile); PsdFileInfo fileInfo = new PsdFileInfo(settings.Psd); bool valid = (settings.Psd != null); if (valid) { settings.LoadLayers(fileInfo); PsdFile psd = settings.Psd; int layerIndexMin = 0; int layerIndexMax = 0; for (int i = 0; i < psd.Layers.Count; i++) { PSDLayerGroupInfo groupInfo = fileInfo.GetGroupByLayerIndex(i); //Debug.Log (groupInfo.start + "-" + groupInfo.end + ":" + groupInfo.name); if (groupInfo != null && !PanelNodeList.Exists(a => a.Name.Equals(groupInfo.name))) { PanelNode panelNode = new PanelNode(groupInfo.name); panelNode.visible = groupInfo.visible; panelNode.idxStart = groupInfo.start; panelNode.idxEnd = groupInfo.end; panelNode.isGroup = true; PanelNodeList.Add(panelNode); } } for (int i = 0; i < fileInfo.LayerIndices.Length; i++) { int layerIndex = fileInfo.LayerIndices [i]; Layer layer = psd.Layers [layerIndex]; PanelNode panelNode = new PanelNode(layer.Name); panelNode.visible = layer.Visible; panelNode.Index = layerIndex; panelNode.isGroup = false; panelNode.layer = layer; PanelNodeList.Add(panelNode); } ArrangementNode(PanelNodeList); } return(PanelNodeList); }
/* * Process Method */ public override PanelNode Process(GroupNode g, PanelNode p) { if (g is BranchGroupNode) { BranchGroupNode bg = (BranchGroupNode)g; if (bg.Children.Count == 2 && !g.ContainsGroups()) { IEnumerator child = bg.Children.GetEnumerator(); while (child.MoveNext()) { if (((ObjectGroupNode)child.Current).Decorations[UnitDecision.DECISION_KEY] == null || ((UnitDecision)((ObjectGroupNode)child.Current).Decorations[UnitDecision.DECISION_KEY]).Handled || ((UnitDecision)((ObjectGroupNode)child.Current).Decorations[UnitDecision.DECISION_KEY]).CIO.HasLabel()) { return(p); } } LabelCIO labelCIO = null; if (g.Labels != null) { labelCIO = new LabelCIO(g.Labels); } UnitDecision d = (UnitDecision)((ObjectGroupNode)bg.Children[0]).Decorations[UnitDecision.DECISION_KEY]; ConcreteInteractionObject cio1 = d.CIO; d.Handled = true; d = (UnitDecision)((ObjectGroupNode)bg.Children[1]).Decorations[UnitDecision.DECISION_KEY]; ConcreteInteractionObject cio2 = d.CIO; d.Handled = true; LabeledTwoCompRow r = new LabeledTwoCompRow(g, p, labelCIO, cio1, cio2); p.AddRow(r); } } return(p); }
public async Task <IActionResult> SerializePanelToFile(string id) { return(await Task.Run(() => { if (engine == null) { return null; } PanelNode node = engine.GetPanelNode(id); if (node == null) { return null; } string json = NodesEngineSerializer.SerializePanel(id, engine); return File(Encoding.UTF8.GetBytes(json), "text/plain", node.Settings["Name"].Value + ".json"); })); }
private void _LoadFloatWindows(XElement ele) { foreach (var item in ele.Elements()) { var node = item.Element("Panel"); if (node != null) { var panelNode = new PanelNode(null); panelNode.Load(node); panelNode.ApplyLayout(this, true); panelNode.Dispose(); } else { node = item.Element("Group"); var groupNode = new GroupNode(null); groupNode.Load(node); groupNode.ApplyLayout(this, true); groupNode.Dispose(); } } }
protected void phaseHelper(GroupNode g, PanelNode p) { PanelNode panel = p; if (g == null) { return; } panel = invokeRules(g, panel); if (g.IsObject()) { return; } BranchGroupNode bg = (BranchGroupNode)g; for (int i = 0; i < bg.Children.Count; i++) { phaseHelper((GroupNode)bg.Children[i], panel); } }
private static void ArrangementNode(List <PanelNode> PanelNodeList) { for (int i = 0; i < PanelNodeList.Count; i++) { PanelNode panelNode = PanelNodeList [i]; List <PanelNode> parentNodeList; if (panelNode.isGroup) { parentNodeList = PanelNodeList.FindAll(a => (a.idxStart <panelNode.idxStart && a.idxEnd> panelNode.idxEnd)); } else { parentNodeList = PanelNodeList.FindAll(a => (a.idxStart <panelNode.Index && a.idxEnd> panelNode.Index)); } if (parentNodeList.Count > 0) { parentNodeList.Sort((left, right) => left.idxStart.CompareTo(right.idxStart)); PanelNode parentNode = parentNodeList [parentNodeList.Count - 1]; panelNode.Parent = parentNode; parentNode.AddChild(panelNode); } } }
/* * Member Methods */ public void ValueChanged(ApplianceState state) { if (!_uiValid) { return; } IEnumerator en = _dependencies.Keys.GetEnumerator(); while (en.MoveNext()) { ArrayList deps = (ArrayList)en.Current; IEnumerator en2 = deps.GetEnumerator(); bool cont = true; while (en2.MoveNext()) { if (!((Dependency)en2.Current).IsSatisfied()) { cont = false; break; } } if (cont) { PanelNode c = (PanelNode)_dependencies[deps]; _activePanel.GetContainerCIO().GetControl().Visible = false; _activePanel = c; _activePanel.GetContainerCIO().GetControl().Visible = true; _activePanel.GetContainerCIO().GetControl().BringToFront(); break; } } }
static void dfs_traverse(Transform trans, string path, List <PanelNode> nodes) { //transName@varName, 例如Container_hairstyle@style_tab1 string[] names = trans.name.Split('@'); string transName = names[0]; //只导出带@的节点 if (names.Length > 1) { string userName = names[1]; var node = new PanelNode() { varName = userName.Length > 0 ? userName : transName.ToLower(), path = path, }; nodes.Add(node); } for (int i = 0; i < trans.childCount; i++) { Transform child = trans.GetChild(i); dfs_traverse(child, string.Format("{0}{1}", (string.IsNullOrEmpty(path) ? "" : path + "/"), GetTransName(child)), nodes); } }
public PanelDecision(Decision baseDecision, PanelNode p) : base(baseDecision) { _panel = p; }
/* * Constructor */ public PanelDecision(PanelNode p) : this((Decision)null, p) { }
public void AddChild(PanelNode panelNode) { panelNode.Parent = this; childNodeList.Add(panelNode); }
/* * Member Variables */ /* * Constructor */ /* * Process Rule Method */ public abstract PanelNode Process(GroupNode g, PanelNode p);