private void AddSyncTargetFile(string platformName, MOG_DBSyncTargetInfo info, string startingPath) { // Create a string for our gamedata Node's Path string gamedataFullpath = startingPath; // Don't bother if we haven't been initialized if (mSyncTargetFileManager != null) { // If we have a directory, add a separator and replace any backslashes with separators if (info.Path.Length > 0) { gamedataFullpath += PathSeparator + info.Path.Replace("~", PathSeparator); } // Get the gamedata files for this platform SyncTargetPlatform platform = mSyncTargetFileManager.GetPlatform(platformName); //Make sure the platform knows about this folder if (!platform.HasFolder(gamedataFullpath)) { platform.AddFolder(gamedataFullpath); } SyncTargetFolder folder = platform.GetFolder(gamedataFullpath); folder.AddFile(info); } }
/// <summary> /// Parses through our mSyncTargetFiles to figure out what should be added where /// </summary> private void ExpandSyncTargetSubNodes(TreeNode node, string platformName) { SyncTargetPlatform platform = mSyncTargetFileManager.GetPlatform(platformName); ArrayList fileNodes = new ArrayList(); int baseFolderIndex = MogUtil_AssetIcons.GetClassIconIndex(BaseFolder_ImageText); // Go through each entry we created when we initialized foreach (KeyValuePair <string, SyncTargetFolder> entry in platform.Folders) { SyncTargetFolder folder = entry.Value as SyncTargetFolder; string relativePath = folder.Path; string nodePath = node.FullPath; if (String.Compare(relativePath, node.FullPath, true) == 0) { //This is the folder that matches the node we're expanding //Go through and get all the files from the folder so we can add nodes for them //We will add these to the current node after we finish going through and adding all the folders foreach (MOG_DBSyncTargetInfo info in folder.Files) { TreeNode fileNode = CreateSyncTargetTreeNode(info, platformName); fileNodes.Add(fileNode); } } else if (relativePath.StartsWith(nodePath + PathSeparator, StringComparison.CurrentCultureIgnoreCase)) { // We found a node with a path that is a parent to us in the hiererchy // Get rid of our current node's path (preparatory to using relativePath as a node.Text) relativePath = relativePath.Substring(nodePath.Length + PathSeparator.Length); if (relativePath.Length > 0) { //If there's a path separator we only want the first part before the separator if (relativePath.Contains(PathSeparator)) { //Just grab the first part of the string, everything before the ~ relativePath = relativePath.Substring(0, relativePath.IndexOf(PathSeparator)); } if (!SyncTargetSubNodeExists(node, relativePath)) { // create a new subnode to represent this folder TreeNode temp = new TreeNode(relativePath, new TreeNode[] { new TreeNode(Blank_Node_Text) }); temp.Tag = new Mog_BaseTag(temp, temp.Text); node.Nodes.Add(temp); temp.ImageIndex = baseFolderIndex; temp.SelectedImageIndex = temp.ImageIndex; } } } } // Add all the file nodes we found above... foreach (TreeNode fileNode in fileNodes) { // Add each node and set its icon node.Nodes.Add(fileNode); Mog_BaseTag tag = fileNode.Tag as Mog_BaseTag; if (tag != null) { string assetFullFilename = tag.FullFilename; string foundFilename = FindAssetsFile(fileNode.Text, assetFullFilename); //Set the image for this node if (foundFilename.Length > 0 || (new MOG_Filename(assetFullFilename)).GetFilenameType() == MOG_FILENAME_TYPE.MOG_FILENAME_Asset) { //This is either a file or an asset SetImageIndices(fileNode, GetAssetFileImageIndex(foundFilename)); } else { //This is a folder fileNode.ImageIndex = baseFolderIndex; fileNode.SelectedImageIndex = fileNode.ImageIndex; } } } }