private void SelectParentDirectory(object eventArgs)
        {
            if (eventArgs != null && CanRemoveDirectory(eventArgs))
            {
                var folder = eventArgs as AssetFolder;
                _logger.Debug($"Select parent for: {folder?.Path}");
                if (folder != null)
                {
                    var parentDir = new DirectoryInfo(folder.Path).Parent;
                    if (parentDir != null)
                    {
                        var existing = AssetDirectories.FirstOrDefault(assetDir => assetDir.Path.Equals(parentDir.FullName, StringComparison.InvariantCultureIgnoreCase));
                        if (existing != null)
                        {
                            // the parent dir is already in the list so just remove this one.
                            Status.Text = "Parent already exists, removing folder.";
                            folder.RemoveItem(folder.Path);
                            return;
                        }

                        Status.Text = "Selecting parent directory";
                        folder.Path = parentDir.FullName;
                    }
                }
            }
        }
        /// <summary>
        /// Handler to remove a selected directory from the list
        /// </summary>
        /// <param name="sender">display name of the file</param>
        /// <param name="args"></param>
        private void OnRemoveDirectory(object sender, EventArgs args)
        {
            var folderPath = sender as string;
            var item       = AssetDirectories.FirstOrDefault(file => file.Path == folderPath);

            if (item != null)
            {
                AssetDirectories.Remove(item);
                _logger.Debug($"Removed {folderPath} from folder list");
                Status.Text = "Removed folder from list";
            }
        }
Ejemplo n.º 3
0
    public static AssetDirectories FindAssetPaths(GameObject asset)
    {
        AssetDirectories paths = new AssetDirectories();
        var mesh = asset.GetComponentInChildren <MeshFilter>().sharedMesh;

        paths.name      = asset.name;
        paths.assetpath = AssetDatabase.GetAssetPath(mesh);
        paths.directory = Path.GetDirectoryName(paths.assetpath);
        paths.filename  = asset.name; // Path.GetFileNameWithoutExtension(AssetDatabase.GetAssetPath(mesh));
        paths.file      = Path.Combine(paths.directory, paths.filename);
        return(paths);
    }
        private bool SafeAddAssetFolder(string folderPath)
        {
            var existing = AssetDirectories.FirstOrDefault(file => file.Path.Equals(folderPath, StringComparison.InvariantCultureIgnoreCase));

            if (existing == null)
            {
                AssetDirectories.Add(new AssetFolder(folderPath));
                _logger.Debug($"Added folder to list: {folderPath}");

                return(true);
            }

            return(false);
        }
Ejemplo n.º 5
0
        public ArrayList LocateAssetBinary(MOG_Filename filename, AssetDirectories AssetDirectoryType)
        {
            string    targetDir   = "";
            ArrayList binaryFiles = new ArrayList();

            MOG_Properties assetProperties = new MOG_Properties(filename);

            switch (AssetDirectoryType)
            {
            case AssetDirectories.IMPORTED:
                targetDir = MOG_ControllerAsset.GetAssetImportedDirectory(assetProperties);
                break;

            case AssetDirectories.PROCESSED:
                string platformName = "";
                // If we have a valid gameDataController?
                if (MOG_ControllerProject.GetCurrentSyncDataController() != null)
                {
                    platformName = MOG_ControllerProject.GetCurrentSyncDataController().GetPlatformName();
                }
                targetDir = MOG_ControllerAsset.GetAssetProcessedDirectory(assetProperties, platformName);
                break;
            }
            if (targetDir.Length != 0 && DosUtils.Exist(targetDir))
            {
                FileInfo [] files = DosUtils.FileGetList(targetDir, "*.*");
                foreach (FileInfo file in files)
                {
                    binaryFiles.Add(file.FullName);
                }
            }
            else
            {
                MOG_Prompt.PromptMessage("Asset View", "Asset (" + targetDir + ") does not exist or is a zero length file! Cannot View.", Environment.StackTrace);
            }

            return(binaryFiles);
        }
Ejemplo n.º 6
0
        public void View(MOG_Filename filename, AssetDirectories AssetDirectoryType, string viewer)
        {
            viewer = viewer.ToLower();

            // Onlcy create viewer processes for real viewers, not none
            if (viewer.Length > 0)
            {
                try
                {
                    viewer = MOG_Tokens.GetFormattedString(viewer, MOG_Tokens.GetProjectTokenSeeds(MOG_ControllerProject.GetProject()));

                    // Does this viewer have an extension
                    if (Path.GetExtension(viewer).Length == 0)
                    {
                        // Try tacking on an exe just for good measure
                        viewer += ".exe";
                    }

                    // Check to see if we can find the tool with the path provided
                    if (!DosUtils.Exist(viewer))
                    {
                        try
                        {
                            string locatedViewer = MOG_ControllerSystem.LocateTool(Path.GetDirectoryName(viewer), Path.GetFileName(viewer));
                            if (!String.IsNullOrEmpty(locatedViewer))
                            {
                                viewer = locatedViewer;
                            }
                        }
                        catch (Exception e)
                        {
                            MOG_Report.ReportMessage("Located Viewer", e.Message, e.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                        }
                    }
                }
                catch (Exception e2)
                {
                    MOG_Report.ReportMessage("Located Viewer", e2.Message, e2.StackTrace, MOG.PROMPT.MOG_ALERT_LEVEL.CRITICAL);
                }

                // Get the binary files for this asset
                ArrayList binaryFiles = LocateAssetBinary(filename, AssetDirectoryType);

                if (binaryFiles.Count > 5)
                {
                    if (MOG_Prompt.PromptResponse("Asset View", "There are (" + binaryFiles.Count.ToString() + ") files to be viewed in this asset.\n\nShould we continue and launch one viewer per file?", MOGPromptButtons.OKCancel) == MOGPromptResult.Cancel)
                    {
                        return;
                    }
                }

                // Make sure viewer exists
                foreach (string binary in binaryFiles)
                {
                    AssetView assetViewer = new AssetView();
                    assetViewer.Asset = filename;

                    // If we have a viewer, we need to put quotes around our binary so that its arguments line up
                    if (viewer.Length > 0)
                    {
                        assetViewer.Binary = "\"" + binary + "\"";
                        assetViewer.Viewer = viewer;
                        //}
                        //else
                        //{
                        //    // If we don't have a viewer, we will be launching the biniary its self.
                        //    // Therefore, set the binary without quotes
                        //    assetViewer.Binary = binary;
                        //    assetViewer.Viewer = "";
                    }

                    Thread viewerThread = new Thread(new ThreadStart(assetViewer.ShellSpawnWithLock));
                    viewerThread.Start();
                }
            }
            else
            {
                MOG_Report.ReportMessage("View", "No viewer defined for this asset!", "", MOG_ALERT_LEVEL.ALERT);
            }
        }