diff --git a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java index 82284888..5edabd61 100644 --- a/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java +++ b/src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java @@ -19,6 +19,7 @@ import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer; import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension; import com.minecrafttas.tasmod.playback.metadata.PlaybackMetadata; +import com.minecrafttas.tasmod.playback.tasfile.PlaybackSerialiser; import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackLoadException; import com.minecrafttas.tasmod.registries.TASmodAPIRegistry; import com.minecrafttas.tasmod.virtual.Subtickable; @@ -33,32 +34,54 @@ *

All serialisation and deserialisation is broken apart into functions whenever possible,
* with the intention of allowing small changes to the existing syntax. * - *

Adding functionality to playback should be made via {@link PlaybackFileCommand PlaybackFileCommands} instead of creating a new syntax
- * and adding new information to the header should be made via {@link PlaybackMetadata} + *

Adding functionality to playback should be made via {@link PlaybackFileCommand PlaybackFileCommands}
+ * instead of creating a new syntax and adding new information to the header should be made via {@link PlaybackMetadata} * *

Sections

- *

The TASfile has 2 main sections: + *

The TASfile has 2 main sections, which are called seperately by the {@link PlaybackSerialiser}: * *

    *
  1. - * {@link #serialiseHeader() Header}: Contains metadata about this TAS, like credits and start position,
    + * Header
    + * Contains metadata about this TAS, like credits and start position,
    * but also a list of enabled extensions and the name of the flavor that was used to encode the file. *
  2. *
  3. - * {@link #serialise(BigArrayList, long) Content}: Contains the actual inputs per tick, inputs in a subtick (a.k.a in a frame), comments and other extensions. + * Content
    + * Contains the actual inputs per tick, inputs in a subtick (a.k.a in a frame), comments and other extensions. *
  4. *
* + * Both sections have serialise and deserialise methods: + * + * + * * Clicking on either of these will lead you to a breakdown in their respective javadocs * * @author Scribble */ public abstract class SerialiserFlavorBase implements Registerable { + /** + * The current line that is being serialised or deserialised. Used for debugging + */ protected long currentLine = 1; /** - * The current tick that is being serialised or deserialised + * The current tick that is being serialised or deserialised. Used for debugging */ protected long currentTick = 0; @@ -108,7 +131,18 @@ protected String headerEnd() { } /** - * + *

Serialises the flavor of this file, the enabled file commands and other metadata. + *

{@link #serialiseFlavorName(List)} + *

+	 * serialiseHeader
+	 *	├── {@link #headerStart()}	// The start of the header
+	 *	├── {@link #serialiseFlavorName(List)}	// The name of the flavor
+	 *	├── {@link #serialiseFileCommandNames(List)}	// The names of the enabled file commands
+	 *	├── {@link #serialiseMetadata(List)}	// The metadata of this movie
+	 *	│   ├── {@link #serialiseMetadataName(List, String)}	// The metadata extension name
+	 *	│   └── {@link #serialiseMetadataValues(List, LinkedHashMap)}	// All values in the extension
+	 *	└── {@link #headerEnd()}	// The end of the header
+	 * 
* @return List of lines containing the header */ public List serialiseHeader() { @@ -121,6 +155,13 @@ public List serialiseHeader() { return out; } + /** + *

How the flavor name is serialised. + *

You normally don't have to edit this,
+ * as the flavor name is taken from the extension name. + * + * @param out The serialised lines, passed by reference + */ protected void serialiseFlavorName(List out) { out.add("Flavor: " + getExtensionName()); } @@ -143,7 +184,7 @@ protected void serialiseMetadata(List out) { for (PlaybackMetadata metadata : metadataList) { serialiseMetadataName(out, metadata.getExtensionName()); - serialiseMetadataValue(out, metadata.getData()); + serialiseMetadataValues(out, metadata.getData()); out.add(""); } } @@ -152,7 +193,7 @@ protected void serialiseMetadataName(List out, String name) { out.add(createCenteredHeading(name, '-', 50)); } - protected void serialiseMetadataValue(List out, LinkedHashMap data) { + protected void serialiseMetadataValues(List out, LinkedHashMap data) { data.forEach((key, value) -> { out.add(String.format("%s:%s", key, value)); });