示例#1
0
        public void LoadContentItems()
        {
            using (new AutoCursor(Cursors.Wait))
            {
                string infoPath = InfoFilePathResolved;

                if (System.IO.File.Exists(infoPath))
                {
                    AK.Wwise.InfoFile.SoundBanksInfo soundBankInfo = null;
                    try
                    {
                        soundBankInfo = AK.Wwise.InfoFile.InfoFileHelpers.LoadInfoFile(infoPath);
                    }
                    catch (Exception e)
                    {
                        if (e.Message.Contains("xsd"))
                        {
                            MainViewModel.Instance.Application.ShowMessage(
                                string.Format(Properties.Resources.CouldNotFindXmlSchema, e.Message),
                                Severity.Error);
                        }
                        else
                        {
                            string    message = string.Empty;
                            Exception current = e;
                            while (current != null)
                            {
                                message += current.Message + " ";
                                current  = current.InnerException;
                            }
                            MainViewModel.Instance.Application.ShowMessage(
                                string.Format(Properties.Resources.CouldNotLoadInfoFile, message),
                                Severity.Error);
                        }
                    }

                    if (soundBankInfo != null)
                    {
                        try
                        {
                            BasePlatform               = soundBankInfo.BasePlatform;
                            _sourceFilesRoot           = soundBankInfo.RootPaths.SourceFilesRoot;
                            _soundBanksRoot            = soundBankInfo.RootPaths.SoundBanksRoot;
                            _externalSourcesOutputRoot = soundBankInfo.RootPaths.ExternalSourcesOutputRoot;

                            IEnumerable <AK.Wwise.InfoFile.FileDescriptorType> fileDescriptors =
                                soundBankInfo.SoundBanks.SoundBank.Cast <AK.Wwise.InfoFile.FileDescriptorType>()
                                .Concat(soundBankInfo.StreamedFiles.File.Cast <AK.Wwise.InfoFile.FileDescriptorType>()
                                        .Union(soundBankInfo.MediaFilesNotInAnyBank.File.Cast <AK.Wwise.InfoFile.FileDescriptorType>()));

                            List <FilePackageGenerator.Context.ExternalSourceInfo> externalSources = new List <FilePackageGenerator.Context.ExternalSourceInfo>();

                            // Load External Sources
                            if (File.Exists(soundBankInfo.RootPaths.ExternalSourcesInputFile))
                            {
                                XElement root = XElement.Load(soundBankInfo.RootPaths.ExternalSourcesInputFile);
                                IEnumerable <XElement> sources = root.Elements("Source");

                                foreach (XElement source in sources)
                                {
                                    FilePackageGenerator.Context.ExternalSourceInfo info = new FilePackageGenerator.Context.ExternalSourceInfo();

                                    string     sourcePath      = source.Attribute("Path").Value;
                                    string     destinationPath = string.Empty;
                                    XAttribute destination     = source.Attribute("Destination");
                                    if (destination != null)
                                    {
                                        destinationPath = Path.Combine(_externalSourcesOutputRoot, destination.Value);
                                    }
                                    else
                                    {
                                        destinationPath = Path.Combine(_externalSourcesOutputRoot, sourcePath);
                                        destinationPath = FilePackager.Base.Extensions.PathCanonicalize(destinationPath);
                                    }

                                    destinationPath = Path.ChangeExtension(destinationPath, ".wem");

                                    info.Path = destinationPath;

                                    string name = FilePackager.Base.Extensions.PathRelativePathTo(_externalSourcesOutputRoot, true, destinationPath, false);
                                    info.Name = FilePackager.Base.Extensions.PathCanonicalize(name);

                                    externalSources.Add(info);
                                }
                            }

                            SetContentItems(fileDescriptors, externalSources);
                        }
                        catch (Exception e)
                        {
                            MainViewModel.Instance.Application.ShowMessage(
                                string.Format(Properties.Resources.GenericError, e.Message),
                                Severity.Error);
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(infoPath))
                    {
                        MainViewModel.Instance.Application.ShowMessage(
                            string.Format(Properties.Resources.CouldNotFindInfoFile, infoPath),
                            Severity.Error);
                    }

                    SetContentItems(null, null);
                }
            }

            // Clear the reference manager
            ManualPackagingInfo.Packages.ForEach(p => p.ResultingItems.RemoveAll());
            ReferenceManager.Clear();

            ManualPackagingInfo.InvalidateResultingItems();

            ManualPackagingInfo.Packages.SelectMany(p => p.Items).ForEach(i => i.OnIsMissingChanged());
            ManualPackagingInfo.Packages.SelectMany(p => p.LayoutItems).ForEach(i => i.OnIsMissingChanged());

            ManualPackagingInfo.Packages.ForEach(p => p.OnMissingItemsChanged());
        }
示例#2
0
 public ContentItemViewModel(FilePackageGenerator.Context.ExternalSourceInfo externalSourceInfo)
 {
     _externalSourceInfo = externalSourceInfo;
     _id = _externalSourceInfo.Id;
 }