Skip to content

Commit

Permalink
Add api links to articles
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBoxyBear committed Jan 18, 2024
1 parent 12de03e commit 553ff99
Show file tree
Hide file tree
Showing 9 changed files with 77 additions and 74 deletions.
4 changes: 2 additions & 2 deletions ChartTools/Song.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ public static async Task<Song> FromDirectoryAsync(string directory, ReadingConfi
/// <exception cref="UnauthorizedAccessException"/>
/// <exception cref="NotSupportedException"/>
/// <exception cref="System.Security.SecurityException"/>
public void ToFile(string path, ChartWritingConfiguration? config = default) => ExtensionHandler.Write(path, this, (".chart", (path, song) => ChartFile.WriteSong(path, song, config)));
public async Task ToFileAsync(string path, ChartWritingConfiguration? config = default, CancellationToken cancellationToken = default) => await ExtensionHandler.WriteAsync(path, this, (".chart", (path, song) => ChartFile.WriteSongAsync(path, song, config, cancellationToken)));
public void ToFile(string path, WritingConfiguration? config = default) => ExtensionHandler.Write(path, this, (".chart", (path, song) => ChartFile.WriteSong(path, song, config?.Chart)));
public async Task ToFileAsync(string path, WritingConfiguration? config = default, CancellationToken cancellationToken = default) => await ExtensionHandler.WriteAsync(path, this, (".chart", (path, song) => ChartFile.WriteSongAsync(path, song, config?.Chart, cancellationToken)));

/// <summary>
/// Retrieves the lyrics from the global events.
Expand Down
2 changes: 1 addition & 1 deletion Docs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Console.WriteLine("------- Building site with DocFx -------");

// TODO Only build api if the assembly is more recent than the last site build
await DotnetApiCatalog.GenerateManagedReferenceYamlFiles(config);
//await DotnetApiCatalog.GenerateManagedReferenceYamlFiles(config);

await Docset.Build(config);

Expand Down
16 changes: 8 additions & 8 deletions Docs/articles/dynamic-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ Track easyBass = bass.GetTrack(Difficulty.Easy);

The dynamic syntax uses three enums to get instruments:

- `StandardInstrumentIdentity` - Instruments using standard chords
- `GHLInstrumentIdentity` - Instruments using Guitar Hero Live chords
- `InstrumentIdentity` - All instruments including drums and vocals
- [StandardInstrumentIdentity](~/api/ChartTools.StandardInstrumentIdentity.yml) - Instruments using standard chords
- [GHLInstrumentIdentity](~/api/ChartTools.GHLInstrumentIdentity.yml) - Instruments using Guitar Hero Live chords
- [InstrumentIdentity](~/api/ChartTools.InstrumentIdentity.yml) - All instruments including drums and vocals

Drums and vocals do not have an enum for their chord types as they are the only instrument using their respective chords.

## Generic vs. non-generic
When an instrument is obtained dynamically using the `InstrumentIdentity` enum, the returned object is of type `Instrument`. When a track is obtained from a non-generic instrument, either dynamically or explicitly through a property, the track will be of type `Track`. This concept extends to chords and notes.
When an instrument is obtained dynamically using the [InstrumentIdentity](~/api/ChartTools.InstrumentIdentity.yml) enum, the returned object is of type [Instrument](~/api/ChartTools.Instrument.yml). When a track is obtained from a non-generic instrument, either dynamically or explicitly through a property, the track will be of type [Track](~/api/ChartTools.Track.yml). This concept extends to chords and notes.

When working with a non-generic track, the following rules apply:
- Chords cannot be added or removed. The position of existing chords can be modified.
- Local events and special phrases have no restrictions.
- A note's identity can be obtaines through the read-only `NoteIndex` property. In a future version, notes will be able to be added from a non-generic track.
- A note's identity can be obtained through the read-only [Index](~/api/ChartTools.INote.yml#ChartTools_INote_Index) property.

Being the base types of the generic counterparts, non-generic instruments, tracks, chords and notes can be cast to a generic version.

The dynamic syntax can also be used to set amd read instruments and tracks.
The dynamic syntax can also be used to set and read instruments and tracks.

```C#
// Setting components
Expand All @@ -47,6 +47,6 @@ Track<StandardChord> easyCoop = Track.FromFile(path, StandardInstrumentIdentity.
Track easyKeys = Track.FromFile(path, InsturmentIdentity.Keys, Difficulty.Easy, <ReadingConfiguration>, metadata.Formatting);
```

When setting an instrument, the target is determined by the `InstrumentIdentity` property of the new instrument, which can be overridden using a `with` statement. Similarly, the target difficulty when setting a track is determined by the track's `Difficulty` property, also overridable through `with`.
When setting an instrument, the target is determined by the [InstrumentIdentity](~/api/ChartTools.Instrument.yml#ChartTools_Instrument_InstrumentIdentity) property of the new instrument, which can be overridden using a `with` statement. Similarly, the target difficulty when setting a track is determined by the track's [Difficulty](~/api/ChartTools.Track.html#ChartTools_Track_Difficulty) property, also overridable through `with`.

> **NOTE**: Unlike when setting an instrument explicitely, the existing identity is used when setting dynamically. This makes it safe to reuse the previous reference after the assignement unless a `with` statement is used. Tracks still need to be re-obtained when using the dynamic syntax as a copy is created to assign its `ParentInstrument`. In cases where a reference to an instrument or track needs to be re-obtained, this reference is passed through as the return of `InstrumentSet.Set` and `Instrument.SetTrack`.
> **NOTE**: Unlike when setting an instrument explicitely, the existing identity is used when setting dynamically. This makes it safe to reuse the previous reference after the assignement unless a `with` statement is used. Tracks still need to be re-obtained when using the dynamic syntax as a copy is created to assign its [ParentInstrument](~/api/ChartTools.Track.ymll#ChartTools_Track_ParentInstrument). In cases where a reference to an instrument or track needs to be re-obtained, this reference is passed through as the return of [InstrumentSet.Set](~/api/ChartTools.InstrumentSet.yml#ChartTools_InstrumentSet_Set_ChartTools_StandardInstrument_) and `Instrument.SetTrack`.
10 changes: 5 additions & 5 deletions Docs/articles/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
Events are track objects with custom data that drive various elements of gameplay. This guide will cover how to use events as well as the helpers provided by ChartTools.

## Class structure
Events are stored using `Event` as a base class, containing the position, event type and an optional argument. The type and argument can also be set simultaneously through the `EventData` property.
Events are stored using [Event](~/api/ChartTools.Events.Event.yml) as a base class, containing the position, event type and an optional argument. The type and argument can also be set simultaneously through the [EventData](~/api/ChartTools.Events.Event.yml#ChartTools_Events_Event_EventData) property.

ChartTools distinguishes between global events (stored under `Song`) and local events (stored under `Track`) using the respective `GlobalEvent` and `LocalEvent` classes, both deriving from `Event`. This allows for better type safety and for the classes to provide helper properties for some complex event types.
ChartTools distinguishes between global events (stored under [Song](~/api/ChartTools.Song.yml)) and local events (stored under [Track](~/api/ChartTools.Track.yml)) using the respective [GlobalEvent](~/api/ChartTools.Events.GlobalEvent.yml) and [LocalEvent](~/api/ChartTools.Events.LocalEvent.yml) classes, both deriving from [Event](~/api/ChartTools.Events.Event.yml). This allows for better type safety and for the classes to provide helper properties for some complex event types.

## Event helpers
Event types and arguments are stored as `string`, allowing for future-proofing and supporting custom events from sources that are not officially supported.

For event types which are supported, CharTools provides helpers in the form of string constants under the static `EventTypeHelper.Global` and `EventTypeHelper.Local` classes. In a future version, usage details of helpers will be accessible from the documentation included with the assembly.
For event types which are supported, CharTools provides helpers in the form of string constants under the static [EventTypeHelper.Global](~/api/ChartTools.Events.EventTypeHeaderHelper.Global.yml) and [EventTypeHelper.Local](~/api/ChartTools.Events.EventTypeHeaderHelper.Local.yml) classes. In a future version, usage details of helpers will be accessible from the documentation included with the assembly.

```c#
var globalEvent = new GlobalEvent(0, EventTypeHelper.Global.MusicStart, null);
```

Some event types are part of a category defined by a prefix to the type. Helpers are provided for these groups under the static `EventTypeHeaderHelper` class. Helper properties are also defined for groups from supported sources.
Some event types are part of a category defined by a prefix to the type. Helpers are provided for these groups under the static [EventTypeHeaderHelper](~/api/ChartTools.Events.EventTypeHeaderHelper.yml) class. Helper properties are also defined for groups from supported sources.

```c#
bool isCrowd = globalEvent.EventType.StartsWith(EventTypeHeaderHelper.Global.Crowd);
bool isCrowd2 = globalEvent.IsCrowdEvent;
```

Some event types can be modified using predefined arguments. For such values, helpers are provided under the static `EventArgumentHelper` class.
Some event types can be modified using predefined arguments. For such values, helpers are provided under the static [EventArgumentHelper](~/api/ChartTools.Events.EventArgumentHelper.html) class.

```c#
var globalEvent = new GlobalEvent(0, EventTypeHelper.Global.Lighting, EventArgumentHelper.Global.Lighting.Strobe);
Expand Down
33 changes: 15 additions & 18 deletions Docs/articles/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ To add ChartTools to your project, you must first build the ChartTools project.
Visual Studio: Right-click on your project from the solution explorer and select "Add Project References...". Click on "Browse" and select `ChartTools.dll` that was generated. If the dll file is moved, also move `ChartTools.xml` to the new directory for XML documentation.

## Supported file formats
ChartTools supports the parsing of .chart and .ini files, with .mid parsing in the works. [mdsitton's BChart](https://github.com/mdsitton/bchart) format is planned as a post-launch update. Unless written as `.chart`, the term "chart" refers to songs supported by ChartTools regardless of the file format.
ChartTools supports the parsing of .chart and .ini files, with .mid parsing in the works. Unless written as `.chart`, the term "chart" refers to songs supported by ChartTools regardless of the file format.

For documentation on the formats themselves, refer to the [GuitarGame_ChartFormats](https://github.com/TheNathannator/GuitarGame_ChartFormats) repository.

## Working with charts

### Song
Every component of a chart is stored in an instance of the Song class. It can be initialized by reading a file that will be parsed based on the extension.
Every component of a chart is stored in an instance of the [Song](~/api/ChartTools.Song.yml) class. It can be initialized by reading a file that will be parsed based on the extension.

```csharp
Song song = Song.FromFile(path);
Expand All @@ -26,7 +26,7 @@ A configuration object may also be used to customize the error handling behavior
Song song = Song.FromFile(path, new ReadingConfiguration());
```

Note: Some MIDI files may contain formatting information in the song.ini file. In order to account for custom formatting when reading, it is recommended to read from a directory instead.
Note: Some Midi files may contain formatting information in the song.ini file. In order to account for custom formatting when reading, it is recommended to read from a directory instead.

```csharp
Song song = Song.FromDirectory(path, <ReadingConfiguration>);
Expand All @@ -36,10 +36,10 @@ When reading from a directory, the metadata will be read from `song.ini`, follow

A song contains four main components:

- Metadata - Miscellaneous info about the song, such as title, album, charter etc.
- Sync track - Markers that define time signature and tempo
- [Metadata](~/api/ChartTools.Metadata.yml) - Miscellaneous info about the song, such as title, album, charter etc.
- [Sync track](~/api/ChartTools.SyncTrack.yml) - Markers that define time signature and tempo
- [Global events](events.md) - Events that are not tied to an instrument
- Instruments - The instrument track data
- [Instruments](~/api/ChartTools.InstrumentSet.yml) - The instrument track data

### Metadata
Similar to reading a song, metadata is retrieved by reading a file:
Expand All @@ -58,16 +58,16 @@ Metadata metadata = Metadata.FromFiles(path1, path2, path3...);

When reading from multiple files, you can mix file types, and the priority of information is defined by the order of the files.

As a future-proofing method, all unsupported items can be found under UnidentifiedData. This data will only be written to the same file format as the one it was read from.
As a future-proofing method, all unsupported items can be found under [UnidentifiedData](~/api/ChartTools.Metadata.yml#ChartTools_Metadata_UnidentifiedData). This data will only be written to the same file format as the one it was read from.

### Instruments and Tracks
All instruments currently supported are represented using the generic `Instrument` class. This class contains an object of type `Track` class for every difficulty. A track can be retrieved from a song with the following code:
All instruments currently supported are represented using the generic [Instrument](~/api/ChartTools.Instrument.yml) class. This class contains an object of type [Track](~/api/ChartTools.Track.yml) class for every difficulty. A track can be retrieved from a song with the following code:

```csharp
Track<StandardChord> track = song.Instruments.LeadGuitar.Expert;
```

Notice the use of StandardChord as a generic type. Instruments are divided into four categories based on the type of chords they use. These categories are:
Notice the use of [StandardChord](~/api/ChartTools.StandardChord.yml) as a generic type. Instruments are divided into four categories based on the type of chords they use. These categories are:

- Standard - Five colored notes
- Drums - Five colored with support for double kick and cymbal flags
Expand All @@ -80,17 +80,12 @@ A track is composed of three components:
- Special phrases (star power)
- [Local events](events.md)

> **NOTE**: When setting an instrument in an `InstrumentSet` or a track in an instrument, a copy of the object is created that contains information about its identity. In order to have changes made to the object after the assignment be reflected, a reference must be re-obtained from the parent.
> **NOTE**: When setting an instrument in an [InstrumentSet](~/api/ChartTools.InstrumentSet.yml) or a track in an instrument, a copy of the object is created that contains information about its identity. In order to have changes made to the object after the assignment be reflected, a reference must be re-obtained from the parent.
Instruments can also be obtained dynamically from a song, regardless of the type. [Learn more about the dynamic syntax](dynamic-syntax.md).

### Chords and Notes
A chord is a set of notes played at the same time. All supported instruments use the generic version of the Chord class, where the generic type defines the type of notes contained. The note types are the same as the types of instruments listed in the section. The types of notes are

- `Note<StandardLane>`
- `Note<GHLLane>`
- `DrumsNote`
- `Syllable` (Vocals)
A chord is a set of notes played at the same time. For readability, most chords and notes have specific classes for each instrument type, deriving from [LaneChord<TNote, TLane, TModifiers>](~/api/ChartTools.LaneChord-3.yml) and [LaneNode\<TLane\>](~/api/ChartTools.LaneNote-1.yml).

The following adds an orange note to every chord on a track:

Expand All @@ -103,6 +98,8 @@ foreach (StandardChord chord in song.Instruments.LeadGuitar.Expert)
}
```

Unlike other instrument, [Vocals](~/api/ChartTools.Vocals.yml) contain [Phrases](~/api/ChartTools.Lyrics.Phrase.yml) and [Syllables](~/api/ChartTools.Lyrics.Syllable.yml). Although bound to chords and notes in the backend, syllables in a phrase are not all at the same position, instead storing their positions as offsets from their parent. [Learn more about vocals](lyrics.md).

## Optimizing
Although still functional, some files may contain data that slows down the reading process or, in worse cases, may result in non-functional files when saved in certain formats. ChartTools provides various utilities to fix such issues.

Expand All @@ -120,13 +117,13 @@ syncTrack.TimeSignatures.RemoveUnneeded();
ChartTools includes other utilities for various purposes. [Learn more](tools.md).

## Writing files
Finally, changes can be saved to a file using the `ToFile` method of the `Song` class, with the format determined by the file extension.
Finally, changes can be saved to a file using [Song.ToFile](~/api/ChartTools.Song.yml#ChartTools_Song_ToFile_System_String_ChartTools_IO_Chart_Configuration_ChartWritingConfiguration_), with the format determined by the file extension.

```csharp
song.ToFile("output.chart", <WritingConfiguration>);
```

Due to limitations of certain file formats, only `Song` objects can be written to a file in this manner. Format-specific operations can be accessed through the respective static class, such as `ChartFile` for `.chart`. For example, here is how to replace an instrument in a `.chart` file.
Due to limitations of certain file formats, only [Song](~/api/ChartTools.Song.yml) objects can be written to a file in this manner. Format-specific operations can be accessed through the respective static class, such as [ChartFile](~/api/ChartTools.IO.Chart.ChartFile.yml) for `.chart`. For example, here is how to replace an instrument in a `.chart` file.

```csharp
ChartFile.ReplaceInstrument("output.chart", guitar, <WritingConfiguration>);
Expand Down
Loading

0 comments on commit 553ff99

Please sign in to comment.