Exemple #1
0
        /// <summary>
        /// Updates the status bar.
        /// </summary>
        public void UpdateStatusBar()
        {
            if (StatusBar == null)
            {
                return;
            }
            var contentStats = FlaxEngine.Content.Stats;

            Color color;

            if (Editor.StateMachine.IsPlayMode)
            {
                color = Color.OrangeRed;
            }
            else
            {
                color = Style.Current.BackgroundSelected;
            }

            string text;

            if (_statusMessages != null && _statusMessages.Count != 0)
            {
                text = _statusMessages[0].Key;
            }
            else if (Editor.StateMachine.CurrentState.Status != null)
            {
                text = Editor.StateMachine.CurrentState.Status;
            }
            else if (contentStats.LoadingAssetsCount != 0)
            {
                text = string.Format("Loading {0}/{1}", contentStats.LoadingAssetsCount, contentStats.AssetsCount);
            }
            else
            {
                text = "Ready";
            }

            StatusBar.Text        = text;
            StatusBar.StatusColor = color;
            _contentStats         = contentStats;
        }
Exemple #2
0
        private async Task BuildContent(
            PipelineBuildEvent pipelineEvent,
            PipelineBuildEvent cachedEvent,
            string eventFilepath)
        {
            if (!File.Exists(pipelineEvent.SourceFile))
            {
                Logger.LogMessage("{0}", pipelineEvent.SourceFile);
                throw new PipelineException("The source file '{0}' does not exist!", pipelineEvent.SourceFile);
            }

            Logger.PushFile(pipelineEvent.SourceFile);

            // Keep track of all build events. (Required to resolve automatic names "AssetName_n".)
            TrackPipelineBuildEvent(pipelineEvent);

            var rebuild = pipelineEvent.NeedsRebuild(this, cachedEvent);

            if (rebuild)
            {
                Logger.LogMessage("{0}", pipelineEvent.SourceFile);
            }
            else
            {
                Logger.LogMessage("Skipping {0}", pipelineEvent.SourceFile);
            }

            Logger.Indent();
            try
            {
                if (!rebuild)
                {
                    // While this asset doesn't need to be rebuilt the dependent assets might.
                    foreach (var asset in cachedEvent.BuildAsset)
                    {
                        string assetEventFilepath;
                        var    assetCachedEvent = LoadBuildEvent(asset, out assetEventFilepath);

                        // If we cannot find the cached event for the dependancy
                        // then we have to trigger a rebuild of the parent content.
                        if (assetCachedEvent == null)
                        {
                            rebuild = true;
                            break;
                        }

                        var depEvent = new PipelineBuildEvent
                        {
                            SourceFile = assetCachedEvent.SourceFile,
                            DestFile   = assetCachedEvent.DestFile,
                            Importer   = assetCachedEvent.Importer,
                            Processor  = assetCachedEvent.Processor,
                            Parameters = assetCachedEvent.Parameters,
                        };

                        // Give the asset a chance to rebuild.
                        await BuildContent(depEvent, assetCachedEvent, assetEventFilepath);
                    }
                }

                // Do we need to rebuild?
                if (rebuild)
                {
                    var startTime = DateTime.UtcNow;

                    // Import and process the content.
                    var processedObject = ProcessContent(pipelineEvent);

                    // Write the content to disk.
                    await WriteXnb(processedObject, pipelineEvent);

                    // Store the timestamp of the DLLs containing the importer and processor.
                    pipelineEvent.ImporterTime  = GetImporterAssemblyTimestamp(pipelineEvent.Importer);
                    pipelineEvent.ProcessorTime = GetProcessorAssemblyTimestamp(pipelineEvent.Processor);

                    // Store the new event into the intermediate folder.
                    pipelineEvent.Save(eventFilepath);

                    var buildTime = DateTime.UtcNow - startTime;

                    // Record stat for this file.
                    ContentStats.RecordStats(pipelineEvent.SourceFile, pipelineEvent.DestFile, pipelineEvent.Processor, processedObject.GetType(), (float)buildTime.TotalSeconds);
                }
                else
                {
                    // Copy the stats from the previous build.
                    ContentStats.CopyPreviousStats(pipelineEvent.SourceFile);
                }
            }
            finally
            {
                Logger.Unindent();
                Logger.PopFile();
            }
        }