/** 强制设置某些节点为Root节点,删掉被依赖 */ public static void ForcedSetRoots(Dictionary <string, AssetNode> nodeDict, List <string> forceRootList) { int count = forceRootList.Count; int index = 0; foreach (string path in forceRootList) { if (index % progressNumOnce == 0) { EditorUtility.DisplayProgressBar("强制设置某些节点为Root节点,删掉被依赖", index + "/" + count, 1f * (index++) / count); } if (nodeDict.ContainsKey(path)) { AssetNode node = nodeDict[path]; node.ForcedSetRoot(); } } if (isLog) { AssetNode.PrintNodeDict(nodeDict, "强制设置某些节点为Root节点,删掉被依赖"); } EditorUtility.ClearProgressBar(); }
/// <summary> /// Adds a new archetype node given the archetype object and the parent node. /// </summary> public void AddActorType( ActorTypeEd actorType, AssetNode parent ) { if( parent == null ) parent = _mainNode; if( parent.NodeType != NodeType.Folder ) parent = parent.Parent; actorType.FilePath = Global.World.WorldFolderPath + parent.FullPath + "\\" + actorType.Name + Consts.Files.ACTORTYPE_EXTENSION; AssetNode newNode = new AssetNode( actorType.Name ); newNode.ActorType = actorType; newNode.NodeType = NodeType.ActorType; newNode.ImageIndex = newNode.SelectedImageIndex = 1; //if ( this == Global.Assets.AssetsTree ) // newNode.ContextMenuStrip = Global.Assets.NodeContextMenu; parent.Nodes.Add( newNode ); //_actorTypesPool.Add( newNode.ActorType.ID, newNode ); Sort( ); SelectedNode = newNode; _lastCreatedNode = newNode; parent.Expand( ); }
static void CollectDependcy() { for (int i = 0; i < abResourcePath.Count; i++) { string path = Application.dataPath + "/" + abResourcePath[i]; if (!Directory.Exists(path)) { Debug.LogError(string.Format("abResourcePath {0} not exist", abResourcePath[i])); } else { DirectoryInfo dir = new DirectoryInfo(path); FileInfo[] files = dir.GetFiles("*", SearchOption.AllDirectories); for (int j = 0; j < files.Length; j++) { string fileName = files[j].FullName; if (fileName.EndsWith(".meta") || fileName.EndsWith(".DS_Store") || fileName.EndsWith(".cs")) { continue; } string fileRelativePath = GetRelativeToAssets(fileName); AssetNode root = null; if (!_allAssetNodes.ContainsKey(fileRelativePath)) { root = new AssetNode(); root.path = fileRelativePath; _allAssetNodes[root.path] = root; GetDependcyRecursive(fileRelativePath, root); } } } } }
/** 寻找入度为0的节点 */ public static List <AssetNode> FindRoots(Dictionary <string, AssetNode> nodeDict) { int count = nodeDict.Count; int index = 0; // 寻找入度为0的节点 List <AssetNode> roots = new List <AssetNode>(); foreach (var kvp in nodeDict) { if (index % progressNumOnce == 0) { EditorUtility.DisplayProgressBar("寻找入度为0的节点", index + "/" + count, 1f * (index++) / count); } AssetNode node = kvp.Value; if (node.isRoot) { roots.Add(node); } } if (isLog) { AssetNode.PrintNodeTree(roots, "寻找入度为0的节点"); } EditorUtility.ClearProgressBar(); return(roots); }
/// <summary> /// /// </summary> void DrawAssets() { GUILayout.Space(3f); GUILayout.BeginHorizontal(GUI.skin.FindStyle("flow background")); float width = this.position.size.x - 200f; GUILayout.BeginVertical(GUILayout.Width(width)); AssetNode.DrawAssetTitle(width); gui_multi_select_.Draw(width, false, true); GUILayout.EndVertical(); GUILayout.BeginVertical(GUILayout.Width(200f)); emAssetBundleNameRule rule; bool is_compress; bool is_native; bool is_permanent; bool is_startup_load; bool is_modify_rule = DrawSelectAssetNodeInfo(out rule, out is_compress , out is_native, out is_permanent, out is_startup_load); GUILayout.EndVertical(); GUILayout.EndHorizontal(); if (is_modify_rule) { ModifyRuleForSelectTreeNodes(rule, is_compress, is_native, is_permanent, is_startup_load); } }
static void CollectDependcy() { for (int i = 0; i < abResourcePath.Count; i++) { string path = Application.dataPath + "/" + abResourcePath[i]; if (!Directory.Exists(path)) { Debug.LogError(string.Format("abResourcePath {0} not exist", abResourcePath[i])); } else { DirectoryInfo dir = new DirectoryInfo(path); FileInfo [] files = dir.GetFiles("*", SearchOption.AllDirectories); for (int j = 0; j < files.Length; j++) { if (files[j].Name.EndsWith(".meta") || files[j].Name.EndsWith(".DS_Store")) { continue; } //获得在文件在Assets下的目录,类似于Assets/Prefab/UI/xx.prefab string fileRelativePath = GetReleativeToAssets(files[j].FullName); AssetNode root = new AssetNode(); root.path = fileRelativePath; GetDependcyRecursive(fileRelativePath, root); } } } //PrintDependcy(); }
static GUILayoutMultiSelectGroup.OperateResult DrawAssetNode(AssetNode node, int space) { if (node.Element == null) { return(null); } GUILayoutMultiSelectGroup.OperateResult result = null; if (node.Element.IsFolder) { result = DrawAssetNodeFolder(node, space); } else { result = DrawAssetNodeFile(node, space); } //绘制子节点 if (node.Expand) { if (node.Children != null) { foreach (var c in node.Children) { if (result == null) { result = DrawAssetNode(c, space + ASSET_NODE_LAYER_SPACE); } } } } return(result); }
public gameEditorMainForm() { InitializeComponent(); Map map = new Map(@"P:\Code\Git\EntityEngine\Maps\Testing"); var assetts0 = map.GetAssetsFromHierarchy("generic"); var assetts1 = map.GetAssetsFromHierarchy("instruments.guitar"); var assetts2 = map.GetAssetsFromHierarchy("instruments"); var assetts3 = map.GetAssetsFromHierarchy("generic", AssetType.Model); var assetts4 = map.GetAssetsFromHierarchy("generic", AssetType.Shader); var assetts5 = map.GetAssetsFromHierarchy("generic", AssetType.Component); AssetNode hNode = map.HierarchyNodes; this.hierarchyTreeView.Nodes.Add(hNode.name); TreeNode root = this.hierarchyTreeView.Nodes[0]; this.TreeViewTabs.TabPages[0].Text = root.Text; foreach (AssetNode node in hNode.children) { root.PopulateWithAssettNodes(node, root); } hNode = map.TypeNodes; this.typeTreeView.Nodes.Add(hNode.name); root = this.typeTreeView.Nodes[0]; this.TreeViewTabs.TabPages[1].Text = root.Text; foreach (AssetNode node in hNode.children) { root.PopulateWithAssettNodes(node, root); } }
static void GetDependcyRecursive(string path, AssetNode parentNode) { string [] dependcy = AssetDatabase.GetDependencies(path, false); for (int i = 0; i < dependcy.Length; i++) { AssetNode node = null; _allAssetNodes.TryGetValue(dependcy[i], out node); if (node == null) { node = new AssetNode(); node.path = dependcy[i]; node.depth = parentNode.depth + 1; node.parents.Add(parentNode); _allAssetNodes[node.path] = node; } else { if (node.depth < parentNode.depth + 1) { node.depth = parentNode.depth + 1; } node.parents.Add(parentNode); } //Debug.Log("dependcy path is " +dependcy[i] + " parent is " + parentNode.path); GetDependcyRecursive(dependcy[i], node); } if (dependcy.Length == 0) { if (!_leafNodes.Contains(parentNode)) { _leafNodes.Add(parentNode); } } }
public IActionResult SaveProcesses([FromBody] Process process) { if (process == null) { return(BadRequest("Error, make sure process form is filled correctly.")); } Process processChecker = _context.Processes.FirstOrDefault(id => (id.AssetNodeId == process.AssetNodeId) && (id.ProcessName == process.ProcessName) && (id.ProcessDate.Year == process.ProcessDate.Year) && (id.ProcessDate.Month == process.ProcessDate.Month)); if (processChecker != null) { return(BadRequest("Error, There is already an existing process. Choose a different process name or edit an existing one.")); } try { AssetNode parentAssetNode = _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == process.AssetNodeId).ParentAssetNodeId); Process p = _context.Processes.FirstOrDefault(id => (id.parentAssetNodeId == parentAssetNode.AssetNodeId) && (id.IsSummary == true)); var pr = process; Process tempProcess = new Process(); tempProcess.AssetNodeId = process.AssetNodeId; tempProcess.BackgroundColor = process.BackgroundColor; tempProcess.Color = process.Color; tempProcess.ProcessDate = process.ProcessDate; tempProcess.ProcessName = process.ProcessName; tempProcess.Reference = process.Reference; tempProcess.DateStamp = DateTime.Now; if (p == null) { Process proc = process; proc.parentAssetNodeId = parentAssetNode.AssetNodeId; proc.IsSummary = true; proc.ProcessName = "Summary/Overall Production"; proc.DateStamp = DateTime.Now; proc.Color = "white"; proc.BackgroundColor = "navy"; proc.Reference = process.Reference; _context.Processes.Add(proc); _context.SaveChanges(); } _context.Processes.Add(tempProcess); _context.SaveChanges(); return(Ok()); } catch (Exception Ex) { return(BadRequest("Something bad happened. " + Ex.Message)); } }
private AssetNode SpawnNode(Guid assetId) { _nodesAssets.Add(assetId); var node = new AssetNode((uint)_nodes.Count + 1, _surface.Context, GraphNodes[0], GraphGroups[0], assetId); _nodes.Add(node); return(node); }
public void ForcedSetRoot() { for (int i = parents.Count - 1; i >= 0; i--) { AssetNode parent = parents[i]; parent.RemoveDependencie(this); } }
public void AddAsset(AssetNode node) { if (!assets.Contains(node)) { assets.Add(node); node.parents.Add(this); } }
public void AddDependencie(AssetNode node) { if (!childs.Contains(node)) { childs.Add(node); node.parents.Add(this); } }
public List <AssetNodeVM> GetAssetNodeVMs(string reference) { List <UserGroup> userGroups = _context.UserGroups.Where(id => id.UserId == reference).ToList(); List <int> userGroupIds = new List <int>(); foreach (var item in userGroups) { userGroupIds.Add(item.GroupId); } List <Group> groups = new List <Group>(); foreach (var gId in userGroupIds) { groups.Add(_context.Groups.FirstOrDefault(id => id.GroupId == gId)); } List <AssetNode> lAssetNodes = new List <AssetNode>(); foreach (var g in groups) { AssetNode assetNode = _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == g.AssetNodeId /*) && (id.ParentAssetNodeId != 0)*/); lAssetNodes.Add(assetNode); } List <AssetNode> assetNodes = new List <AssetNode>(); foreach (var item in lAssetNodes) { assetNodes.AddRange(_context.AssetNodes.Where(id => id.AssetNodeId == item.AssetNodeId).ToList()); //Add First Node as well //assetNodes.AddRange(_context.AssetNodes.Where(id => id.AssetNodeId == item.AssetNodeId).ToList()); } assetNodes.OrderBy(a => a.Height); //var assetNodes = _context.AssetNodes.Where(a => a.Reference.Equals(reference)).OrderBy(a => a.Height).ToList(); List <AssetNodeVM> assetNodesVM = new List <AssetNodeVM>(); foreach (var item in assetNodes) { assetNodesVM.Add(new AssetNodeVM() { Code = item.Code, RootAssetNodeId = item.RootAssetNodeId, DateStamp = item.DateStamp, Name = item.Name + " (" + _context.AssetNodeTypes.FirstOrDefault(id => id.AssetNodeTypeId == item.AssetNodeTypeId).AssetNodeTypeName + ")", AssetNodeId = item.AssetNodeId, ParentAssetNodeId = item.ParentAssetNodeId, Reference = item.Reference, Height = item.Height, NodeId = item.AssetNodeId, NodeType = item.AssetNodeTypeId /*Type = 1 if organization*/ }); } List <AssetNodeVM> assetNodesVMOrdered = assetNodesVM.OrderBy(id => id.AssetNodeId).ToList(); return(assetNodesVMOrdered); }
/// <summary> /// 渲染文件 /// </summary> static GUILayoutMultiSelectGroup.OperateResult DrawAssetNodeFile(AssetNode tree, int space) { GUILayout.BeginHorizontal(); GUILayout.Space(space); var result = DrawAssetNodContent(tree); GUILayout.EndHorizontal(); return(result); }
/** 包含的资源 合并到 父亲节点 */ public void MergeAssetToParent(AssetNode pnode) { foreach (AssetNode node in assets) { pnode.assets.Add(node); node.parents.Remove(this); if (!node.parents.Contains(pnode)) { node.parents.Add(pnode); } } }
public void RemoveDependencie(AssetNode node) { if (childs.Contains(node)) { childs.Remove(node); } if (node.parents.Contains(this)) { node.parents.Remove(this); } }
public static void PopulateWithAssettNodes(this TreeNode nu, AssetNode hNode, TreeNode tNode) { tNode.Nodes.Add(hNode.name); if (hNode.children.Count > 0) foreach (AssetNode node in hNode.children) tNode.PopulateWithAssettNodes(node, tNode.Nodes[tNode.Nodes.Count - 1]); else foreach (Asset assett in hNode.assetts) { var nodes = tNode.Nodes[tNode.Nodes.Count - 1].Nodes; nodes.Add(assett.Name + assett.Extension); nodes[nodes.Count - 1].Tag = assett; } }
public static void PrintNodeDict(Dictionary <string, AssetNode> dict, string destr = "") { // 打印信息树 string str = "[" + destr + "]\n"; foreach (var kvp in dict) { AssetNode node = kvp.Value; str += node + "\n"; } Debug.Log(str); }
private static void AddAsset(string name, BundleNode bundle, Object asset) { AssetNode asset_node; if (assets_.TryGetValue(name, out asset_node) == true) { asset_node.Asset = asset; } else { asset_node = new AssetNode(name, bundle, asset); assets_.Add(name, asset_node); bundle.loadedAsset_count_++; } }
public static void PrintNodeTree(List <AssetNode> roots, string destr = "") { // 打印信息树 string str = "[" + destr + "]\n"; for (int i = 0; i < roots.Count; i++) { AssetNode node = roots[i]; str += node.GetTreeInfo(0, "-- "); str += "========================\n\n"; } Debug.Log(str); }
public void ConnectTo(AssetNode target, bool reverse) { var outputNode = reverse ? target : this; var inputNode = reverse ? this : target; var output = new OutputBox(outputNode, NodeElementArchetype.Factory.Output(outputNode._outputs, string.Empty, ScriptType.Void, outputNode._outputs, true)); outputNode.AddElement(output); outputNode._outputs++; var input = new InputBox(inputNode, NodeElementArchetype.Factory.Input(inputNode._inputs, string.Empty, true, ScriptType.Void, inputNode._outputs)); inputNode.AddElement(input); inputNode._inputs++; output.Connect(input); }
/// <summary> /// 绘制节点内容 /// </summary> static GUILayoutMultiSelectGroup.OperateResult DrawAssetNodeContent(AssetNode tree, float width) { EditorGUILayout.BeginHorizontal(); string style = tree.IsSelect ? "PreToolbar" : "PreToolbar2"; bool toggle = GUILayout.Button(tree.Element.Name, style, GUILayout.MaxWidth(width - 480f)); GUILayout.Label(((emAssetBundleNameRule)tree.Element.Rule).ToString(), style, GUILayout.Width(80f)); if (tree.Element.Rule == (int)emAssetBundleNameRule.SingleFile || tree.Element.Rule == (int)emAssetBundleNameRule.Folder) { var config = AssetBundleBuildWindow.Instance.asset_bundle_build_.Data; if (config.IsAllCompress) { tree.Element.IsCompress = true; } if (config.IsAllNative) { tree.Element.IsNative = true; } GUILayout.Label(tree.Element.IsCompress ? "√" : "✗", style, GUILayout.Width(80f)); GUILayout.Label(tree.Element.IsNative ? "√" : "✗", style, GUILayout.Width(80f)); GUILayout.Label(tree.Element.IsPermanent ? "√" : "✗", style, GUILayout.Width(80f)); GUILayout.Label(tree.Element.IsStartupLoad ? "√" : "✗", style, GUILayout.Width(80f)); } else { GUILayout.Label("", style, GUILayout.Width(320f)); } GUILayout.Label(tree.Granularity > 0 ? tree.Granularity.ToString() : "", style, GUILayout.Width(80f)); EditorGUILayout.EndHorizontal(); if (toggle) { return(new GUILayoutMultiSelectGroup.OperateResult() { SelectNode = tree, Status = null, }); } return(null); }
public List <int> GetAssetNodesIdsByUser(string userId) { List <UserGroup> userGroups = _context.UserGroups.Where(id => id.UserId == userId).ToList(); List <int> assetNodes = new List <int>(); foreach (var bma in userGroups) { Group group = _context.Groups.FirstOrDefault(id => id.GroupId == bma.GroupId); if (group == null) { return(null); } AssetNode assetNode = _context.AssetNodes.FirstOrDefault(id => id.AssetNodeId == group.AssetNodeId); assetNodes.Add(assetNode.AssetNodeId); } return(assetNodes); }
/** 入度为1的节点自动打包到上一级节点 */ public void MergeParentCountOnce() { for (int i = childs.Count - 1; i >= 0; i--) { AssetNode cnode = childs[i]; cnode.MergeParentCountOnce(); if (cnode.parentCount == 1) { // 子节点 变为 包含资源 assets.Add(cnode); childs.Remove(cnode); // 包含的资源 合并到 父亲节点 cnode.MergeAssetToParent(this); } } }
public void GetNeedParentNodeList(Dictionary <string, AssetNode> needDict, Dictionary <string, AssetNode> needParentDict) { for (int i = parents.Count - 1; i >= 0; i--) { AssetNode parent = parents[i]; if (needDict.ContainsKey(parent.path)) { if (!needParentDict.ContainsKey(parent.path)) { needParentDict.Add(parent.path, parent); } } else { parent.GetNeedParentNodeList(needDict, needParentDict); } } }
public ScriptTabPage( AssetNode scriptNode ) { script = new RichTextBox( ); script.AcceptsTab = true; script.AutoWordSelection = true; script.DetectUrls = false; script.WordWrap = false; script.Location = new Point( 0, 0 ); script.Size = new Size( this.Width, this.Height ); script.Font = new Font( "Courier New", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ( (byte)( 0 ) ) ); script.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom; script.TextChanged += new EventHandler( ScriptTextChanged ); this.Controls.Add( script ); this.Text = scriptNode.Script.Name; this.scriptNode = scriptNode; script.Text = scriptNode.Script.ScriptText; }
/// <summary> /// 渲染文件夹 /// </summary> static GUILayoutMultiSelectGroup.OperateResult DrawAssetNodeFolder(AssetNode tree, int space) { GUILayout.BeginHorizontal(); GUILayout.Space(space); //设置箭头 string title = (tree.Expand ? "\u25BC" : "\u25BA") + (char)0x200a; bool toggleTxt = GUILayout.Toggle(true, title, "PreToolbar2", GUILayout.Width(10f)); if (!toggleTxt) { tree.Expand = !tree.Expand; } //绘制标题 var result = DrawAssetNodContent(tree); GUILayout.EndHorizontal(); return(result); }
/** 过滤不需要打包的节点 */ public static void FilterDotNeedNode(Dictionary <string, AssetNode> needDict, List <AssetNode> needRoots) { int count = needRoots.Count; for (int i = 0; i < needRoots.Count; i++) { if (i % progressNumOnce == 0) { EditorUtility.DisplayProgressBar("过滤不需要打包的节点", i + "/" + count, 1f * i / count); } needRoots[i].FilterDotNeedNode(needDict); } if (isLog) { AssetNode.PrintNodeTree(needRoots, "过滤不需要打包的节点"); } EditorUtility.ClearProgressBar(); }
static GUILayoutMultiSelectGroup.OperateResult DrawAssetNode(AssetNode node, int space) { if (node.Element == null) { return(null); } if (node.Element.Name == ".DS_Store") { return(null); } bool is_ignore = node.Element != null && node.Element.Rule == (int)emAssetBundleNameRule.Ignore; GUI.color = is_ignore ? Color.grey : Color.white; GUILayoutMultiSelectGroup.OperateResult result = null; if (node.Element.IsFolder) { result = DrawAssetNodeFolder(node, space); } else { result = DrawAssetNodeFile(node, space); } //绘制子节点 if (!is_ignore && node.Expand) { if (node.Children != null) { foreach (var c in node.Children) { if (result == null) { result = DrawAssetNode(c, space + ASSET_NODE_LAYER_SPACE); } } } } GUI.color = Color.white; return(result); }
public static void PopulateWithAssettNodes(this TreeNode nu, AssetNode hNode, TreeNode tNode) { tNode.Nodes.Add(hNode.name); if (hNode.children.Count > 0) { foreach (AssetNode node in hNode.children) { tNode.PopulateWithAssettNodes(node, tNode.Nodes[tNode.Nodes.Count - 1]); } } else { foreach (Asset assett in hNode.assetts) { var nodes = tNode.Nodes[tNode.Nodes.Count - 1].Nodes; nodes.Add(assett.Name + assett.Extension); nodes[nodes.Count - 1].Tag = assett; } } }
/// <summary> /// 刷新资源的粒度信息 /// </summary> static void RefreshGranularity(Dictionary <string, int> table , Dictionary <string, string> details , string relative_path, AssetNode node , Action <string> progress_report) { if (progress_report != null) { progress_report(relative_path); } if (node.Element.IsFolder) { if (node.Children.Count > 0) { for (int i = 0; i < node.Children.Count; ++i) { string child_path = relative_path + "/" + node.Children[i].Element.Name.ToLower(); RefreshGranularity(table, details, child_path, node.Children[i], progress_report); } } } else { if (table.ContainsKey(relative_path)) { node.Granularity = table[relative_path]; } else { node.Granularity = 0; } if (details != null && details.ContainsKey(relative_path)) { node.GranularityDetails = details[relative_path]; } else { node.GranularityDetails = null; } } }
public void Initialization( ) { this.ImageList = Global.AssetsTreeViewImages; this.Nodes.Clear( ); _spritesPool.Clear( ); _actorTypesPool.Clear( ); _scriptsPool.Clear( ); _mainNode = new AssetNode( "Assets" ); _mainNode.FilePath = Global.World.AssetsFolderPath; _mainNode.ImageIndex = _mainNode.SelectedImageIndex = 3; _mainNode.NodeType = NodeType.Folder; this.Nodes.Add( _mainNode ); AssetNode node = new AssetNode( ); node.CreateFile = false; node.Sprite = Helper.GetSpriteFromImage( Global.GraphicsDevice, LunarDevKit.Properties.Resources.NoSprite ); node.Sprite.Bitmap = LunarDevKit.Properties.Resources.NoSprite; _spritesPool.Add( 0, node ); LoadAssets( Global.World.AssetsFolderPath, _mainNode ); SetReferences( ); _tempArchetypePool.Clear( ); _tempScriptPool.Clear( ); CollapseAll( ); SelectedNode = null; }
/// <summary> /// Adds a new folder node given the folder's name, the parent and a value indicating whether it will create a physical folder. /// </summary> public void AddFolder( string folderName, AssetNode parent, bool createPhysicalFolder ) { if( parent != null ) { AssetNode node = parent; AssetNode newNode = new AssetNode( folderName ); if( node.NodeType == NodeType.Folder ) newNode.FilePath = node.FilePath + folderName + @"\"; else { node = parent.Parent; newNode.FilePath = node.FilePath + folderName + @"\"; } if( createPhysicalFolder && Directory.Exists( newNode.FilePath ) ) MessageBox.Show( "This folder already exists!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); else { if( createPhysicalFolder ) Directory.CreateDirectory( newNode.FilePath ); newNode.ImageIndex = newNode.SelectedImageIndex = 3; //if( this == Global.Assets.AssetsTree ) // newNode.ContextMenuStrip = Global.Assets.NodeContextMenu; node.Nodes.Add( newNode ); Sort( ); SelectedNode = newNode; _lastCreatedNode = newNode; node.Expand( ); } } //AssetNode newNode = new AssetNode( folderName ); //newNode.ImageIndex = newNode.SelectedImageIndex = 3; //if( this == Properties.Assets.AssetsTree ) // newNode.ContextMenuStrip = Properties.Assets.NodeContextMenu; //if( parent == null ) //{ // newNode.FilePath = Properties.World.AssetsFolderPath + folderName + "\\"; // this.Nodes.Add( newNode ); //} //else //{ // if( parent.NodeType == NodeType.Folder ) // { // parent.Nodes.Add( newNode ); // } // else // { // parent.Parent.Nodes.Add( newNode ); // } // newNode.FilePath = Properties.World.AssetsFolderPath + parent.FullPath + "\\" + folderName + "\\"; // parent.Expand( ); //} //if( createPhysicalFolder && !Directory.Exists( newNode.FilePath ) ) //{ // Directory.CreateDirectory( newNode.FilePath ); //} //else //{ // MessageBox.Show( "This folder already exists!", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation ); // return; //} //Sort( ); //SelectedNode = newNode; //lastCreatedNode = newNode; }
public void AddScript( Script script, AssetNode parent ) { if( parent == null ) parent = _mainNode; if ( parent.NodeType != NodeType.Folder ) parent = parent.Parent; //script.FilePath = Global.World.WorldFolderPath + parent.FullPath + "\\" + script.Name + Consts.Files.LUASSEMBLY_EXTENSION; AssetNode newNode = new AssetNode( script.Name ); newNode.Script = script; newNode.NodeType = NodeType.Script; newNode.ImageIndex = newNode.SelectedImageIndex = 4; //if ( this == Global.Assets.AssetsTree ) // newNode.ContextMenuStrip = Global.Assets.NodeContextMenu; parent.Nodes.Add( newNode ); //_scriptsPool.Add( newNode.Script.ID, newNode ); Sort( ); SelectedNode = newNode; _lastCreatedNode = newNode; parent.Expand( ); }
/// <summary> /// Adds a new sprite node given the sprite and the parent node. /// </summary> public void AddSprite( SpriteEd sprite, AssetNode parent ) { if( parent == null ) parent = _mainNode; if( parent.NodeType != NodeType.Folder ) parent = parent.Parent; sprite.FilePath = Global.World.WorldFolderPath + parent.FullPath + "\\" + sprite.Name + Consts.Files.SPRITE_EXTENSION; AssetNode newNode = new AssetNode( sprite.Name ); newNode.Sprite = sprite; newNode.NodeType = NodeType.Sprite; newNode.ImageIndex = newNode.SelectedImageIndex = 0; //if ( this == Global.Assets.AssetsTree ) // newNode.ContextMenuStrip = Global.Assets.NodeContextMenu; if( parent == null ) this.Nodes.Add( newNode ); else parent.Nodes.Add( newNode ); //_spritesPool.Add( newNode.Sprite.ID, newNode ); Sort( ); SelectedNode = newNode; _lastCreatedNode = newNode; parent.Expand( ); }
private void LoadAssets( string path, AssetNode parent ) { //DirectoryInfo mainDir = new DirectoryInfo( path ); //DirectoryInfo[] dirs = mainDir.GetDirectories( ); //FileInfo[] files = mainDir.GetFiles( ); //foreach( FileInfo file in files ) //{ // if( Helper.IsFileSprite( file.Name ) ) // { // SpriteEd sprite = FileManager.LoadSpriteFile( file.FullName ); // sprite.Name = file.Name.Substring( 0, file.Name.Length - Consts.Files.SPRITE_EXTENSION.Length ); // AddSprite( sprite, parent ); // } // else if( Helper.IsFileArchetype( file.Name ) ) // { // _tempArchetypePool.Add( FileManager.LoadActorTypeFile( file.FullName ), parent ); // } // else if( Helper.IsFileScript( file.Name ) ) // { // _tempScriptPool.Add( FileManager.LoadScriptFile( file.FullName ), parent ); // } //} //if( dirs.Length != 0 ) //{ // foreach( DirectoryInfo dir in dirs ) // { // AddFolder( dir.Name, parent, false ); // LoadAssets( dir.FullName, _lastCreatedNode ); // } //} }