Basics

Guides

API Reference

Menu

Basics

Guides

API Reference

class: SaveLoadService

[23:7] extends: EngineService

Wraps FXGL's SaveLoadService (com.almasb.fxgl.profile.SaveLoadService), the engine service that coordinates registered save/load handlers and reads/writes SaveFiles to disk through the FileSystemService. Aussom users construct an Aussom-side SaveLoadHandler via fxgl.saveLoadHandler(onSaveCb, onLoadCb) and pass it to addHandler. Then save / saveAndWriteTask drives onSave on every registered handler; readAndLoadTask drives onLoad.

Methods

  • SaveLoadService (Ajo = null)

    Creates a SaveLoadService wrapper. Empty by default; the (Ajo) form wraps the running instance from fxgl.getSaveLoadService.

    • @p Ajo is an optional AussomJavaObject around a SaveLoadService.
  • adopt (object Ajo)

    Wraps an existing SaveLoadService AussomJavaObject.

    • @p Ajo is an AussomJavaObject around a SaveLoadService.
    • @r A new wrapper.
  • addHandler (object HandlerObj)

    Adds a SaveLoadHandler (typically built from fxgl.saveLoadHandler(onSave, onLoad)).

    • @p HandlerObj is an AussomJavaObject around a SaveLoadHandler.
    • @r this object
  • removeHandler (object HandlerObj)

    Removes a previously added SaveLoadHandler.

    • @p HandlerObj is an AussomJavaObject around the handler.
    • @r this object
  • save (object DataFileObj)

    Asks every registered handler to write its data into the given DataFile. Does no IO.

    • @p DataFileObj is a DataFile wrapper.
    • @r this object
  • load (object DataFileObj)

    Asks every registered handler to load its data from the given DataFile. Does no IO.

    • @p DataFileObj is a DataFile wrapper.
    • @r this object
  • saveFileExists (string SaveFileName)

    Returns whether the named save file exists on disk.

    • @p SaveFileName is the save-file name.
    • @r A bool.
  • saveAndWriteTask (string SaveFileName)

    Builds an IOTask that calls save into a fresh DataFile and writes the result to disk under the given file name.

    • @p SaveFileName is the save-file name.
    • @r An IOTask wrapper.
  • writeTask (string SaveFileName, object DataFileObj)

    Builds an IOTask that writes the given DataFile to disk under the given save-file name (no handlers invoked).

    • @p SaveFileName is the save-file name.
    • @p DataFileObj is a DataFile wrapper.
    • @r An IOTask wrapper.
  • readAndLoadTask (string SaveFileName)

    Builds an IOTask that reads the named save file then calls load on every registered handler.

    • @p SaveFileName is the save-file name.
    • @r An IOTask wrapper.
  • readTask (string SaveFileName)

    Builds an IOTask that reads the named save file and yields a SaveFile.

    • @p SaveFileName is the save-file name.
    • @r An IOTask wrapper around a SaveFile.
  • deleteSaveFileTask (string SaveFileName)

    Builds an IOTask that deletes the named save file.

    • @p SaveFileName is the save-file name.
    • @r An IOTask wrapper.
  • readLastModifiedSaveFileTask (string DirName, string SaveFileExt)

    Builds an IOTask that finds the most-recently-modified save file in DirName matching the extension.

    • @p DirName is the directory to scan.
    • @p SaveFileExt is the file extension (e.g. "sav").
    • @r An IOTask wrapper around an Optional.
  • readSaveFilesTask (string DirName, string SaveFileExt)

    Builds an IOTask that reads every save file in DirName matching the extension and returns them as a list.

    • @p DirName is the directory to scan.
    • @p SaveFileExt is the file extension.
    • @r An IOTask wrapper around a List.