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 5edabd61..5d50abb8 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 @@ -29,7 +29,7 @@ import com.minecrafttas.tasmod.virtual.VirtualMouse; /** - *

The base class of a flavor. + *

The base class of a flavor * *

All serialisation and deserialisation is broken apart into functions whenever possible,
* with the intention of allowing small changes to the existing syntax. @@ -116,6 +116,10 @@ public abstract class SerialiserFlavorBase implements Registerable { */ /** + *

Example

+ *
+	 * ##################### TASfile ####################
+	 * 
* @return The very top of the header */ protected String headerStart() { @@ -123,7 +127,11 @@ protected String headerStart() { } /** - * The end of the header, used for detecting when the header stops + *

The end of the header, used for detecting when the header stops + *

Example

+ *
+	 * ##################################################
+	 * 
* @return The end of the header */ protected String headerEnd() { @@ -131,17 +139,38 @@ protected String headerEnd() { } /** - *

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

{@link #serialiseFlavorName(List)} + *

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

Tree

*
 	 * 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
+	 *	├── {@link #headerStart()}
+	 *	├── {@link #serialiseFlavorName(List)}
+	 *	├── {@link #serialiseFileCommandNames(List)}
+	 *	├── {@link #serialiseMetadata(List)}
+	 *	│   ├── {@link #serialiseMetadataName(List, String)}
+	 *	│   └── {@link #serialiseMetadataValues(List, LinkedHashMap)}
+	 *	└── {@link #headerEnd()}
+	 * 
+ *

Example

+ *
+	 * ##################### TASfile ####################					// {@link #headerStart()}
+	 * Flavor: beta1 										// {@link #serialiseFlavorName(List)}
+	 * FileCommand-Extensions: tasmod_desyncMonitor@v1, tasmod_options@v1, tasmod_label@v1	// {@link #serialiseFileCommandNames(List)}
+	 * 
+	 * --------------------- Credits -------------------- 					// {@link #serialiseMetadataName(List, String)}
+	 * Title:Insert TAS category here 							// {@link #serialiseMetadataValues(List, LinkedHashMap)}
+	 * Author:Insert author here
+	 * Playing Time:00:00.0
+	 * Rerecords:0
+	 * 
+	 * ----------------- Start Position -----------------
+	 * x:-32.577311363268976
+	 * y:56.0
+	 * z:-4.457057187505265
+	 * pitch:29.25007
+	 * yaw:-88.80094
+	 * 
+	 * ##################################################					// {@link #headerEnd()}
 	 * 
* @return List of lines containing the header */ @@ -156,9 +185,13 @@ public List serialiseHeader() { } /** - *

How the flavor name is serialised. + *

How the flavor name is serialised *

You normally don't have to edit this,
* as the flavor name is taken from the extension name. + *

Example

+ *
+	 * Flavor: beta1
+	 * 
* * @param out The serialised lines, passed by reference */ @@ -166,6 +199,14 @@ protected void serialiseFlavorName(List out) { out.add("Flavor: " + getExtensionName()); } + /** + *

Adds the file commands that are enabled to the lines + *

Example

+ *
+	 * FileCommand-Extensions: tasmod_label@v1, tasmod_desyncMonitor@v1
+	 * 
+ * @param out The serialised lines, passed by reference + */ protected void serialiseFileCommandNames(List out) { List stringlist = new ArrayList<>(); List extensionList = TASmodAPIRegistry.PLAYBACK_FILE_COMMAND.getEnabled(); @@ -176,6 +217,25 @@ protected void serialiseFileCommandNames(List out) { out.add(""); } + /** + *

Serialises the metadata to the header of the TASfile + *

Example

+ *
+	 * --------------------- Credits --------------------
+	 * Title:Insert TAS category here
+	 * Author:Insert author here
+	 * Playing Time:00:00.0
+	 * Rerecords:0
+	 * 
+	 * ----------------- Start Position -----------------
+	 * x:-32.577311363268976
+	 * y:56.0
+	 * z:-4.457057187505265
+	 * pitch:29.25007
+	 * yaw:-88.80094
+	 * 
+ * @param out + */ protected void serialiseMetadata(List out) { if (!processExtensions) return; @@ -189,16 +249,64 @@ protected void serialiseMetadata(List out) { } } + /** + *

Serialises only the name of the metadata section + *

Example

+ *
+	 * --------------------- Credits --------------------
+	 * 
+ * @param out The lines passed in by reference + * @param name The name to process + */ protected void serialiseMetadataName(List out, String name) { out.add(createCenteredHeading(name, '-', 50)); } + /** + *

Serialises only the values of the metadata section + *

Example

+ *
+	 * Title:Insert TAS category here
+	 * Author:Insert author here
+	 * Playing Time:00:00.0
+	 * Rerecords:0
+	 * 
+ * @param out + * @param data + */ protected void serialiseMetadataValues(List out, LinkedHashMap data) { data.forEach((key, value) -> { out.add(String.format("%s:%s", key, value)); }); } + /* + ___ _____ _ _ ____ ____ _ _ ____ + / __)( _ )( \( )(_ _)( ___)( \( )(_ _) + ( (__ )(_)( ) ( )( )__) ) ( )( + \___)(_____)(_)\_) (__) (____)(_)\_) (__) + + */ + + /** + *

Serialises a list of inputs into a list of strings + *

Tree

+ *
+	 * serialise
+	 * └── {@link #serialiseContainer(BigArrayList, TickContainer)}
+	 *     ├── {@link #serialiseKeyboard(VirtualKeyboard)}
+	 *     ├── {@link #serialiseMouse(VirtualMouse)}
+	 *     ├── {@link #serialiseCameraAngle(VirtualCameraAngle)}
+	 *     ├── {@link #serialiseInlineComments(List, List)}
+	 *     │   └── {@link #serialiseFileCommandsInLine(List)}
+	 *     ├── {@link #serialiseEndlineComments(List, List)}	// Same as serialiseInlineComments
+	 *     │   └── {@link #serialiseFileCommandsEndLine(List)}	// Unused
+	 *     └── {@link #mergeInputs(BigArrayList, List, List, List, List)}
+	 * 
+ * @param inputs The inputs to serialise + * @param toTick The tick where to stop, used for partial serialisation by savestates. -1 to serialise all + * @return The list of lines + */ public BigArrayList serialise(BigArrayList inputs, long toTick) { BigArrayList out = new BigArrayList<>(); @@ -253,6 +361,10 @@ protected String serialiseFileCommandsInLine(List fileComma return String.join(" ", serialisedCommands); } + protected String serialiseFileCommandsEndLine(List fileCommands) { + return serialiseFileCommandsInLine(fileCommands); + } + protected List serialiseKeyboard(VirtualKeyboard keyboard) { List out = new ArrayList<>();