Beispiel #1
0
        private void InitializeTab()
        {
            try
            {
                mControl = new TmxEditor.TmxEditorControl();
            }
            catch (System.NotSupportedException exc)
            {
                GlueCommands.PrintError("Could not find a graphics device that supports XNA hi-def. Attempting to load Tiled plugin without the control tab");
            }

            if (mControl != null)
            {
                mControl.AnyTileMapChange += HandleUserChangeTmx;
                mControl.LoadEntities     += OnLoadEntities;


                EntityCreationManager.Self.AddEntityCreationView(mControl);


                var commandLineArgumentsView = new TileGraphicsPlugin.Views.CommandLineArgumentsView();
                mCommandLineViewModel = new CommandLineViewModel();
                mCommandLineViewModel.CommandLineChanged += HandleCommandLinePropertyChanged;
                commandLineArgumentsView.DataContext      = mCommandLineViewModel;
                mControl.AddTab("Command Line", commandLineArgumentsView);

                mTilesetXnaRightClickController = new TilesetXnaRightClickController();
                mTilesetXnaRightClickController.Initialize(mControl.TilesetXnaContextMenu);
                mControl.TilesetDisplayRightClick += (o, s) => mTilesetXnaRightClickController.RefreshMenuItems();
            }
        }
Beispiel #2
0
        private void AddAdditionalTextureFilesToDropDown()
        {
            var currentElement = GlueState.CurrentElement;

            if (currentElement != null)
            {
                // add any files here from
                // the entity or global content
                // if they're not already added.
                var viewModel =
                    mAchxControl.WireframeEditControlsViewModel;

                var pngFiles = currentElement.ReferencedFiles.Concat(GlueState.CurrentGlueProject.GlobalFiles)
                               .Select(item => new ToolsUtilities.FilePath(GlueCommands.GetAbsoluteFileName(item)))
                               .Where(item => item.Extension == "png")
                               .Distinct()
                               .Except(viewModel.AvailableTextures)
                               .ToArray();

                foreach (var file in pngFiles)
                {
                    viewModel.AvailableTextures.Add(file);
                }

                if (viewModel.SelectedTextureFilePath == null && viewModel.AvailableTextures.Any())
                {
                    viewModel.SelectedTextureFilePath = viewModel.AvailableTextures.First();
                }
            }
        }
Beispiel #3
0
        private void ReactToNewFile(ReferencedFileSave newFile)
        {
            var isTmx = FileManager.GetExtension(newFile.Name) == "tmx";

            if (isTmx)
            {
                var isRequired = GlueCommands.GluxCommands.GetPluginRequirement(this);

                if (!isRequired)
                {
                    GlueCommands.GluxCommands.SetPluginRequirement(this, true);
                    GlueCommands.PrintOutput("Added Tiled Plugin as a required plugin because TMX's are used");
                    GlueCommands.GluxCommands.SaveGluxTask();
                }
            }
        }
Beispiel #4
0
        private void AddFilesReferenced(string fileName, List <string> allFiles, TopLevelOrRecursive topLevelOrRecursive, ProjectOrDisk projectOrFile)
        {
            // The project may have been unloaded:
            if (GlueState.CurrentMainContentProject != null)
            {
                string absoluteFileName = GlueCommands.GetAbsoluteFileName(fileName, isContent: true);

                if (File.Exists(absoluteFileName))
                {
#if GLUE
                    List <string> referencedFiles = null;

                    if (projectOrFile == ProjectOrDisk.Project)
                    {
                        referencedFiles = FlatRedBall.Glue.Managers.FileReferenceManager.Self.GetFilesReferencedBy(absoluteFileName, topLevelOrRecursive);
                    }
                    else
                    {
                        referencedFiles = FlatRedBall.Glue.Managers.FileReferenceManager.Self.GetFilesNeededOnDiskBy(absoluteFileName, topLevelOrRecursive);
                    }
#else
                    List <string> referencedFiles =
                        ContentParser.GetFilesReferencedByAsset(absoluteFileName, topLevelOrRecursive);
#endif
                    // 12/14/2010
                    // The referencedFiles
                    // instance may be null
                    // if the absoluteFileName
                    // references a file that doesn't
                    // exist on the file system.  This
                    // happens if someone checks in a GLUX
                    // file but forgets to check in a newly-
                    // created file.  Not deadly, so Glue shouldn't
                    // crash.  Also, Glue displays warning messages in
                    // a different part of the code, so we shouldn't pester
                    // the user here with another one.
                    if (referencedFiles != null)
                    {
                        allFiles.AddRange(referencedFiles);
                    }
                }
                else
                {
                    // Do nothing?
                }
            }
        }
        public static string[] GetReferencedPngs()
        {
            List <string> referencedFileNames = new List <string>();

            var referencedFiles = EditorObjects.IoC.Container.Get <IGlueState>().GetAllReferencedFiles();

            foreach (var rfs in referencedFiles)
            {
                string absolute = null;
                try
                {
                    absolute = GlueCommands.GetAbsoluteFileName(rfs);
                }
                catch (Exception e)
                {
                    // See if the project has been unloaded:
                    if (GlueState.CurrentGlueProject == null)
                    {
                        break;
                    }
                    else
                    {
                        throw e;
                    }
                }

                if (referencedFileNames.Any(item => Match(item, absolute)) == false)
                {
                    referencedFileNames.Add(absolute);
                    AddReferencedFilesRecursively(absolute, referencedFileNames);
                }
            }

            string[] referencedPngs = new string[0];
            if (GlueState.CurrentGlueProject != null)
            {
                referencedPngs = referencedFileNames
                                 .Where(item => FileManager.GetExtension(item) == "png")
                                 .Distinct()
                                 .Select(item => FileManager.Standardize(item))
                                 // Alphabetize for debugging, can get rid of this once this feature works well and I don't need to look at the list anymore:
                                 .OrderBy(item => item)
                                 .ToArray();
            }
            // only get the PNGs:
            return(referencedPngs);
        }
Beispiel #6
0
        private void FillAllFilesWithFilesInList(List <string> allFiles, ReferencedFileSave[] referencedFileList,
                                                 TopLevelOrRecursive topLevelOrRecursive, ProjectOrDisk projectOrFile)
        {
            foreach (var rfs in referencedFileList)
            {
                allFiles.Add(GlueCommands.GetAbsoluteFileName(rfs));

                AddFilesReferenced(rfs.Name, allFiles, topLevelOrRecursive, projectOrFile);

                for (int i = 0; i < rfs.ProjectSpecificFiles.Count; i++)
                {
                    ProjectSpecificFile psf = rfs.ProjectSpecificFiles[i];

                    allFiles.Add(psf.FilePath);

                    AddFilesReferenced(psf.FilePath, allFiles, topLevelOrRecursive, projectOrFile);
                }
            }
        }
Beispiel #7
0
        public IEnumerable <FilePath> GetFilePathsReferencedBy(ReferencedFileSave file, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
            var absolute = GlueCommands.GetAbsoluteFileName(file);

            return(GetFilesReferencedBy(absolute, topLevelOrRecursive).Select(item => new FilePath(item)));
        }
Beispiel #8
0
        public IEnumerable <string> GetFilesReferencedBy(ReferencedFileSave file, EditorObjects.Parsing.TopLevelOrRecursive topLevelOrRecursive)
        {
            var absolute = GlueCommands.GetAbsoluteFileName(file);

            return(GetFilesReferencedBy(absolute, topLevelOrRecursive));
        }
Beispiel #9
0
        // This replaces ObjectFinder.GetReferencedFileSaveFromFile - if any changes are made here, make the changes there too
        public ReferencedFileSave GetReferencedFile(string fileName)
        {
            ////////////////Early Out//////////////////////////////////
            var invalidPathChars = Path.GetInvalidPathChars();

            if (invalidPathChars.Any(item => fileName.Contains(item)))
            {
                // This isn't a RFS, because it's got a bad path. Early out here so that FileManager.IsRelative doesn't throw an exception
                return(null);
            }

            //////////////End Early Out////////////////////////////////


            fileName = fileName.ToLower();

            if (FileManager.IsRelative(fileName))
            {
                fileName = GlueCommands.GetAbsoluteFileName(fileName, isContent: true);
            }

            fileName = FileManager.Standardize(fileName).ToLower();


            if (GlueProject != null)
            {
                foreach (ScreenSave screenSave in GlueProject.Screens)
                {
                    foreach (ReferencedFileSave rfs in screenSave.ReferencedFiles)
                    {
                        string absoluteRfsFile = FileManager.Standardize(GlueCommands.GetAbsoluteFileName(rfs)).ToLower();

                        if (absoluteRfsFile == fileName)
                        {
                            return(rfs);
                        }
                    }
                }

                lock (GlueProject.Entities)
                {
                    foreach (EntitySave entitySave in GlueProject.Entities)
                    {
                        foreach (ReferencedFileSave rfs in entitySave.ReferencedFiles)
                        {
                            string absoluteRfsFile = FileManager.Standardize(GlueCommands.GetAbsoluteFileName(rfs)).ToLower();

                            if (absoluteRfsFile == fileName)
                            {
                                return(rfs);
                            }
                        }
                    }
                }

                foreach (ReferencedFileSave rfs in GlueProject.GlobalFiles)
                {
                    string absoluteRfsFile = FileManager.Standardize(GlueCommands.GetAbsoluteFileName(rfs)).ToLower();

                    if (absoluteRfsFile == fileName)
                    {
                        return(rfs);
                    }
                }
            }

            return(null);
        }