public Song(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { MetadataTags = new List <HKey>(); GenreTags = new List <HKey>(); Labels = new List <FString>(); InstrumentPaths = new List <HKey>(); }
private static void CreateHKeys(string name) { // Creates paths for packagedef + index2 HKey packageFilePath = new HKey("PackageDefs." + name + ".PackageDef"); HKey packageDirectory = packageFilePath.GetParentDirectory(); CreateStringTablePaths(packageDirectory); HKey indexFilePath = new HKey("packages." + name + ".index2"); HKey indexDirectory = indexFilePath.GetParentDirectory(); CreateStringTablePaths(indexDirectory); }
internal HKey Extend(string extension) { if (!IsValidValue(extension)) { throw new Exception(InvalidValueMessage()); } ulong newKey = HKey.GetHash(extension, _key); if (StringKey.ContainsStringKey(_key)) { // Adds new value string newValue = StringKey.GetValue(_key, Localization.English) + extension; StringKey.UpdateValue(newKey, newValue); return(new HKey(newKey)); } return(new HKey(newKey)); }
public void UpdateIndexEntryAsPending(HKey filePath, HKey type, string physicalPath, HKey packageFilePath) { Index2Entry indexEntry = Index.Entries.FirstOrDefault(x => x.FilePath == filePath); if (indexEntry == null) { // Creates new entry indexEntry = new Index2Entry() { FilePath = filePath, Type = type }; Index.Entries.Add(indexEntry); } Index2PackageEntry packageEntry = indexEntry.PackageEntries.FirstOrDefault(x => x.Package == packageFilePath); if (packageEntry == null) { // Creates new entry packageEntry = new Index2PackageEntry() { Package = packageFilePath, ExternalFilePath = physicalPath }; // Inserts at the front indexEntry.PackageEntries.Insert(0, packageEntry); } else { // Updates external file path packageEntry.ExternalFilePath = physicalPath; } }
public Texture(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { }
public Event(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <EventEntry>(); }
private static RiffFile FromStream(Stream stream) { RiffFile riff = new RiffFile(); AwesomeReader ar = new AwesomeReader(stream); // Checks for "RIFF" magic. switch (ar.ReadInt32()) { case MAGIC_RIFF: ar.BigEndian = false; break; case MAGIC_RIFF_R: ar.BigEndian = true; break; default: throw new Exception("Invalid magic. Expected \"RIFF\""); } riff.BigEndian = ar.BigEndian; // Sets endianess ar.BaseStream.Position += 4; // Skips total size int chunkType = GetChunkType(ar); if (chunkType != MAGIC_INDX) { throw new Exception("First chunk was not an Index!"); } Index index = new Index(ar); foreach (IndexEntry entry in index.Entries) { ar.BaseStream.Position = entry.Offset; // Jumps to offset chunkType = GetChunkType(ar); if (chunkType != MAGIC_STBL && chunkType != MAGIC_ZOBJ) { continue; } // Reads header info HKey filePath = new HKey(ar.ReadUInt64()); HKey directoryPath = new HKey(ar.ReadUInt64()); HKey type = new HKey(ar.ReadUInt64()); ar.BaseStream.Position += 8; if (chunkType == MAGIC_STBL) { // Gets localization if (!StringTable.IsValidLocalization(type)) { continue; } // Loads string table StringTable table = new StringTable(filePath, directoryPath, StringTable.GetLocalization(type)); table.ReadData(ar); riff._objects.Add(table); } else if (chunkType == MAGIC_ZOBJ) { if (!Global.ZObjectTypes.ContainsKey(type)) { continue; // Unsupported type } // Loads zobject ZObject obj = Activator.CreateInstance(Global.ZObjectTypes[type], new object[] { filePath, directoryPath }) as ZObject; obj.ReadData(ar); riff._objects.Add(obj); } else { // Unknown chunk continue; } } return(riff); }
public Tone2(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Pedals = new List <Pedal>(); Processors = new List <AudioProcessor>(); }
public AudioEffect(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <AudioEffectEntry>(); }
public Catalog2(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Entries = new List <Catalog2Entry>(); }
public Video(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { }
public Instrument(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { TrackPaths = new List <HKey>(); }
public ZObject this[HKey index] => GetZObject(Index?.Entries.SingleOrDefault(x => x.FilePath == index));
public void SavePendingChanges() { if (!PendingChanges) { return; } // Groups objects by package var packages = _pendingChanges.Select(obj => new { ZObject = obj, PackageEntry = Index.Entries.First(idx => idx.FilePath == obj.FilePath).PackageEntries.First() }).OrderBy(x => x.PackageEntry.ExternalFilePath).GroupBy(x => x.PackageEntry.Package); foreach (var package in packages) { HKey packagePath = package.Key; string physicalPackagePath = _packagePaths[packagePath]; var fusedFiles = package.GroupBy(x => x.PackageEntry.ExternalFilePath); foreach (var fusedFile in fusedFiles) { string fusedFilePath = Path.Combine(physicalPackagePath, fusedFile.Key); RiffFile rif = null; // TODO: Find a better solution (Less ugly) if (File.Exists(fusedFilePath)) { try { // Opens existing file to preserve zobjects rif = RiffFile.FromFile(fusedFilePath); } catch { } finally { if (rif == null) { rif = new RiffFile(); } } } else { rif = new RiffFile(); } foreach (var zobject in fusedFile.Select(x => x.ZObject)) { // Removes existing zobject if present rif.Objects.RemoveAll(x => x.FilePath == zobject.FilePath); // Adds new zobject rif.Objects.Add(zobject); } // Saves new rif file rif.WriteToFile(fusedFilePath); } } // Sorts index entries by file paths Index.Entries.Sort((x, y) => string.Compare(x.FilePath, y.FilePath, true)); // Saves index for current package only RiffFile indexRif = new RiffFile(); indexRif.Objects.Add(Index); indexRif.WriteToFile(Path.Combine(CurrentPackageDirectory, "index2.rif")); _pendingChanges.Clear(); }
// Used mostly for debugging private static List <HKey> CreateStringTablePaths(HKey directory) => Global.StringTableLocalizations.Select(x => (HKey)(directory.Value + "." + x.Value)).ToList();
public Measure(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <MeasureEntry>(); }
public ZObject(HKey filePath, HKey directoryPath) { _filePath = filePath; _directoryPath = directoryPath; }
public Whammy(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <WhammyEntry>(); }
public PackageDef(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Entries = new List <string>(); }
public VoxSpread(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <SpreadEntry>(); }
public VoxPushPhrase(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <TimeEvent>(); }
public Index2(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Entries = new List <Index2Entry>(); }
private List <StringTable> CreateStringTables(List <ZObject> zobjects) { List <StringTable> tables = new List <StringTable>(); var groups = zobjects.Where(x => !(x is StringTable)).GroupBy(x => x.DirectoryPath); foreach (var group in groups) { if (group.Key.Key != 0) { // Creates shared string tables foreach (HKey local in Global.StringTableLocalizationsOnDisc) { List <FString> strings = group.SelectMany(x => x.GetAllStrings()).Distinct().ToList(); HKey localGroupDirectory = group.Key.Extend("." + local); StringTable table = new StringTable(localGroupDirectory, group.Key.GetParentDirectory(), StringTable.GetLocalization(local)); // Adds strings from zobjects foreach (FString str in strings) { table.Strings.Add(str.Key, StringKey.GetValue(str.Key, table.Localization)); } // Adds strings from table (Directory string) foreach (FString str in table.GetAllStrings().Where(x => !table.Strings.ContainsKey(x))) { table.Strings.Add(str, StringKey.GetValue(str.Key, table.Localization)); } tables.Add(table); } continue; } // Creates string table for singular zobject (Uses file path) foreach (ZObject obj in group) { List <FString> strings = obj.GetAllStrings(); foreach (HKey local in Global.StringTableLocalizationsOnDisc) { HKey objectDirectory = obj.FilePath.Extend("." + local); StringTable table = new StringTable(objectDirectory, obj.FilePath.GetParentDirectory(), StringTable.GetLocalization(local)); // Adds strings from zobjects foreach (FString str in strings) { table.Strings.Add(str.Key, StringKey.GetValue(str.Key, table.Localization)); } // Adds strings from table (Directory string) foreach (FString str in table.GetAllStrings().Where(x => !table.Strings.ContainsKey(x))) { table.Strings.Add(str, StringKey.GetValue(str.Key, table.Localization)); } tables.Add(table); } } } return(tables); }
public Section(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <TextEvent>(); }
public TimeSignature(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <TimeSignatureEntry>(); }
public StringTable(HKey filePath, HKey directoryPath, Localization localization = Localization.English) : base(filePath, directoryPath) { _localization = localization; _strings = new Dictionary <ulong, string>(); }
public Audio(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { }
internal static bool IsValidLocalization(HKey key) => LocalizationPair.Localizations.Count(x => x.HashValue == key.Key) != 0;
public Vox(HKey filePath, HKey directoryPath) : base(filePath, directoryPath) { Events = new List <VoxEntry>(); }
internal static Localization GetLocalization(HKey key) => LocalizationPair.Localizations.FirstOrDefault(x => x.HashValue == key).EnumValue;