Skip to content

Commit 96a2ad4

Browse files
committed
[Flavor] Start on documentation
1 parent fac5bda commit 96a2ad4

File tree

1 file changed

+50
-9
lines changed

1 file changed

+50
-9
lines changed

src/main/java/com/minecrafttas/tasmod/playback/tasfile/flavor/SerialiserFlavorBase.java

+50-9
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandContainer;
2020
import com.minecrafttas.tasmod.playback.filecommands.PlaybackFileCommand.PlaybackFileCommandExtension;
2121
import com.minecrafttas.tasmod.playback.metadata.PlaybackMetadata;
22+
import com.minecrafttas.tasmod.playback.tasfile.PlaybackSerialiser;
2223
import com.minecrafttas.tasmod.playback.tasfile.exception.PlaybackLoadException;
2324
import com.minecrafttas.tasmod.registries.TASmodAPIRegistry;
2425
import com.minecrafttas.tasmod.virtual.Subtickable;
@@ -33,32 +34,54 @@
3334
* <p>All serialisation and deserialisation is broken apart into functions whenever possible,<br>
3435
* with the intention of allowing small changes to the existing syntax.
3536
*
36-
* <p>Adding functionality to playback should be made via {@link PlaybackFileCommand PlaybackFileCommands} instead of creating a new syntax<br>
37-
* and adding new information to the header should be made via {@link PlaybackMetadata}
37+
* <p>Adding functionality to playback should be made via {@link PlaybackFileCommand PlaybackFileCommands}<br>
38+
* instead of creating a new syntax and adding new information to the header should be made via {@link PlaybackMetadata}
3839
*
3940
* <h2>Sections</h2>
40-
* <p>The TASfile has 2 main sections:
41+
* <p>The TASfile has 2 main sections, which are called seperately by the {@link PlaybackSerialiser}:
4142
*
4243
* <ol>
4344
* <li>
44-
* {@link #serialiseHeader() Header}: Contains metadata about this TAS, like credits and start position,<br>
45+
* <strong>Header</strong><br>
46+
* Contains metadata about this TAS, like credits and start position,<br>
4547
* but also a list of enabled extensions and the name of the flavor that was used to encode the file.
4648
* </li>
4749
* <li>
48-
* {@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.
50+
* <strong>Content</strong><br>
51+
* Contains the actual inputs per tick, inputs in a subtick (a.k.a in a frame), comments and other extensions.
4952
* </li>
5053
* </ol>
5154
*
55+
* Both sections have serialise and deserialise methods:
56+
*
57+
* <ul>
58+
* <li>Serialisation
59+
* <ul>
60+
* <li>{@link #serialiseHeader()}</li>
61+
* <li>{@link #serialise(BigArrayList, long)}</li>
62+
* </ul>
63+
* </li>
64+
* <li>Deserialisation
65+
* <ul>
66+
* <li>{@link #deserialiseHeader(List)}</li>
67+
* <li>{@link #deserialise(BigArrayList, long)}</li>
68+
* </ul>
69+
* </li>
70+
* </ul>
71+
*
5272
* Clicking on either of these will lead you to a breakdown in their respective javadocs
5373
*
5474
* @author Scribble
5575
*/
5676
public abstract class SerialiserFlavorBase implements Registerable {
5777

78+
/**
79+
* The current line that is being serialised or deserialised. Used for debugging
80+
*/
5881
protected long currentLine = 1;
5982

6083
/**
61-
* The current tick that is being serialised or deserialised
84+
* The current tick that is being serialised or deserialised. Used for debugging
6285
*/
6386
protected long currentTick = 0;
6487

@@ -108,7 +131,18 @@ protected String headerEnd() {
108131
}
109132

110133
/**
111-
*
134+
* <p>Serialises the flavor of this file, the enabled file commands and other metadata.
135+
* <p>{@link #serialiseFlavorName(List)}
136+
* <pre>
137+
* serialiseHeader
138+
* ├── {@link #headerStart()} // The start of the header
139+
* ├── {@link #serialiseFlavorName(List)} // The name of the flavor
140+
* ├── {@link #serialiseFileCommandNames(List)} // The names of the enabled file commands
141+
* ├── {@link #serialiseMetadata(List)} // The metadata of this movie
142+
* │ ├── {@link #serialiseMetadataName(List, String)} // The metadata extension name
143+
* │ └── {@link #serialiseMetadataValues(List, LinkedHashMap)} // All values in the extension
144+
* └── {@link #headerEnd()} // The end of the header
145+
* </pre>
112146
* @return List of lines containing the header
113147
*/
114148
public List<String> serialiseHeader() {
@@ -121,6 +155,13 @@ public List<String> serialiseHeader() {
121155
return out;
122156
}
123157

158+
/**
159+
* <p>How the flavor name is serialised.
160+
* <p>You normally don't have to edit this,<br>
161+
* as the flavor name is taken from the extension name.
162+
*
163+
* @param out The serialised lines, passed by reference
164+
*/
124165
protected void serialiseFlavorName(List<String> out) {
125166
out.add("Flavor: " + getExtensionName());
126167
}
@@ -143,7 +184,7 @@ protected void serialiseMetadata(List<String> out) {
143184

144185
for (PlaybackMetadata metadata : metadataList) {
145186
serialiseMetadataName(out, metadata.getExtensionName());
146-
serialiseMetadataValue(out, metadata.getData());
187+
serialiseMetadataValues(out, metadata.getData());
147188
out.add("");
148189
}
149190
}
@@ -152,7 +193,7 @@ protected void serialiseMetadataName(List<String> out, String name) {
152193
out.add(createCenteredHeading(name, '-', 50));
153194
}
154195

155-
protected void serialiseMetadataValue(List<String> out, LinkedHashMap<String, String> data) {
196+
protected void serialiseMetadataValues(List<String> out, LinkedHashMap<String, String> data) {
156197
data.forEach((key, value) -> {
157198
out.add(String.format("%s:%s", key, value));
158199
});

0 commit comments

Comments
 (0)