Ejemplo n.º 1
0
        /// <summary>
        /// Loads and manages Index2, Catalog2, PackageDef objects
        /// </summary>
        /// <param name="workingDirectory"></param>
        public SongManager(string workingDirectory)
        {
            // Returns if directory doesn't exist
            if (!Directory.Exists(workingDirectory))
            {
                return;
            }
            _workingDirectory = workingDirectory;

            string[] rifFiles = Directory.GetFiles(_workingDirectory, "*.rif", SearchOption.TopDirectoryOnly);

            // Loads objects from riff files
            foreach (string rifFile in rifFiles)
            {
                RiffFile rif = new RiffFile();
                rif.Import(rifFile);

                foreach (ZObject zobj in rif.Objects)
                {
                    if (zobj is Index2)
                    {
                        _index2 = zobj as Index2;
                        LoadStringTablePaths();
                    }
                    else if (zobj is Catalog2)
                    {
                        _catalog2 = zobj as Catalog2;
                    }
                    else if (zobj is PackageDef)
                    {
                        _packageDef = zobj as PackageDef;
                    }
                }
            }

            // Look for PackageDef
            string[] packageDefs = Directory.GetFiles(Path.Combine(_workingDirectory, "packagedefs"), "packagedef.rif", SearchOption.AllDirectories);
            //packageDefs = packageDefs.OrderBy(x => x).ToArray();
            if (packageDefs.Length <= 0)
            {
                return;
            }

            RiffFile packageDef = new RiffFile();

            packageDef.Import(packageDefs[0]);

            foreach (ZObject zobj in packageDef.Objects)
            {
                if (zobj is PackageDef)
                {
                    _packageDef = zobj as PackageDef;
                    break;
                }
            }

            UpdateStringTableFromHKey(_index2.IndexKey);
            UpdateStringTableFromHKey(_catalog2.IndexKey);
            UpdateStringTableFromHKey(_packageDef.IndexKey);
        }
Ejemplo n.º 2
0
 public Boolean ChildrenContainsCatalog(Int32 child)
 {
     return(Catalog2.Count(c => c.Cat_Id == child) > 0 ||
            Catalog2.ToList().Count(c => c.ChildrenContainsCatalog(child)) > 0);
 }
Ejemplo n.º 3
0
 public Boolean ChildrenContainsCatalog(List <Int32> childs)
 {
     return(Catalog2.Count(c => childs.Count(cd => cd == c.Cat_Id) > 0) > 0 ||
            Catalog2.ToList().Count(c => c.ChildrenContainsCatalog(childs)) > 0);
 }
Ejemplo n.º 4
0
        private void AddToCatalog(Song song, InstrumentTuning leadGtr, InstrumentTuning rhythmGtr, InstrumentTuning bass)
        {
            // Add song to catalog2 entries
            Catalog2 catalog = _packageManager["catalog2"] as Catalog2;

            Catalog2Entry entry = new Catalog2Entry()
            {
                Identifier = song.DirectoryPath + ".MediaEntry2",
                SongType   = 1,

                Title       = song.Title,
                Artist      = song.Artist,
                Album       = song.Album,
                Description = song.Description,
                LegendTag   = song.LegendTag,

                SongLength      = song.SongLength,
                GuitarIntensity = song.GuitarIntensity,
                BassIntensity   = song.BassIntensity,
                VoxIntensity    = song.VoxIntensity,

                EraTag = song.EraTag,
                Year   = song.Year,

                LeadGuitarTuning   = leadGtr,
                RhythmGuitarTuning = rhythmGtr,
                BassTuning         = bass,

                Labels      = song.Labels,
                SongPath    = song.FilePath,
                TexturePath = song.TexturePath,
                PreviewPath = song.PreviewPath,

                MetadataTags = song.MetadataTags,
                GenreTags    = song.GenreTags
            };

            // Removes previous entry and adds to pending change
            catalog.Entries.RemoveAll(x => x.Identifier == entry.Identifier);
            catalog.Entries.Add(entry);

            // Sorts alphabetically and ensures "ShredUs" entries are first
            catalog.Entries.Sort((x, y) =>
            {
                string a = x.Identifier, b = y.Identifier;
                if (a.StartsWith("ShredUs", StringComparison.CurrentCultureIgnoreCase) && b.StartsWith("ShredUs", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(string.Compare(a, b));
                }
                else if (a.StartsWith("ShredUs", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(-1);
                }
                else if (b.StartsWith("ShredUs", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(1);
                }
                else
                {
                    return(string.Compare(a, b));
                }
            });

            _packageManager.AddZObjectAsPending(catalog);
        }