Skip to content
This repository was archived by the owner on Dec 20, 2019. It is now read-only.

Action serialization

Javier Torrente edited this page Mar 23, 2014 · 2 revisions

Editor actions (see this page for more details) can be encapsulated using the SerializedEditorAction class. The structure of this class is defined in a json schema so it can be easily serialized to/from disk and/or network. The purpose of this serialized action is to support action logging for different purposes. Currently serialized actions are only used for bug reporting, but in the future it may also be used for creating macros and other stuff.

A serialized action contains the canonical name of the action launched, plus the serialized version of their arguments. There's also an extension of this class, called TimestampedEditorAction, that includes a time stamp. This is used for logging actions.

Each time a new action is created by invoking the Controller#action(String, Object...) method, Actions logs the action by pushing a new TimestampedEditorAction into the stack of serialized actions, just before the action is actually performed.

Actions also provide a method for retrieving a number of the actions on top of the stack, which is currently used by the Tracker.

Example:

This is an example of how two TimestampedEditorActions New Game and Open Game look when they are serialized to json:

[
{
	class:es.eucm.ead.editor.control.appdata.TimestampedEditorAction,
	actionClass:es.eucm.ead.editor.control.actions.NewGame,
	arguments:[
		{
			class:java.lang.String,
			value:"A folder path"
		},
		{
			class:es.eucm.ead.schema.editor.game.EditorGame,
			editScene:scene3,
			initialScene:scene0,
			modelVersion:"1",
			appVersion:"0.9",
			sceneorder:[scene0,scene1,scene3]
		}
	],
	timestamp:"1395576753833"
},
{
	class:es.eucm.ead.editor.control.appdata.TimestampedEditorAction,
	actionClass:es.eucm.ead.editor.control.actions.OpenGame,
	arguments:[
		{
			class:java.lang.String,
			value:"A folder path"
		}
	],
	timestamp:"1395576753873"
}
]

Clone this wiki locally