Pre-release
AdventureJS Docs Downloads
Score: 0 Moves: 0

Class:SaveManager

Defined in: adventure/SaveManager.js, line 9

Todos: Save to adventurejs.com web server.

SaveManager manages the job of saving games. It contains all the methods needed to create the Save pop-up screen. SaveManager can save a game to a local save file, to browser cookies, or to the adventurejs.com web server.

SaveManager is created automatically by Game. This is an internal class that authors should not need to construct or modify. However, if you'd like to try, you can find styles for the Save & Restore pop-ups in adventurejs.css. All relevant styles are prefixed with '.save_' or '.restore_'.

Private Constructor:

var foo = new adventurejs.SaveManager(game)

Parameters:

  • game Game
    A reference to the game instance.
Inherited Overrides

Methods Collapse all  |  Expand all

clickClose()

Defined in: adventure/SaveManager.js, line 403

Function that gets called by the Close button.
clickSubmit()

Defined in: adventure/SaveManager.js, line 417

Save.
closeDialog()

Defined in: adventure/SaveManager.js, line 369

Close the Save modal dialog.
openDialog()

Defined in: adventure/SaveManager.js, line 332

Open the Save modal dialog.
sanitizeInputFileName()

Defined in: adventure/SaveManager.js, line 550

Sanitize input file name. Permitted characters are a-z, A-Z, 0-9, accented vowels áéíóúñü, _underscore, and -hyphen.
saveToBrowser()

Defined in: adventure/SaveManager.js, line 485

Save game to browser cookie.

Player can name their save however they want. However, we always prepend the game name because local storage applies to all pages on a given domain, meaning that all saves for all games played at, i.e., adventurejs.com will be saved in the same local storage. And, local storage appears not to have any method for nesting data, so we can't have a parent object or 'folder'. Instead, we need to name them in such a way that we can identify them by game.
saveToFile()

Defined in: adventure/SaveManager.js, line 442

Todos: Investigate FileSaver.js

Save to file.
saveToServer()

Defined in: adventure/SaveManager.js, line 523

Todos: Everything.

Save game to server.
set(props) → {adventurejs.SaveManager}

Defined in: adventure/SaveManager.js, line 570

Parameters:

  • props Object
    A generic object containing properties to copy to the DisplayObject instance.
Provides a chainable shortcut method for setting a number of properties on the instance.

Returns:

adventurejs.SaveManager Returns the instance the method is called on (useful for chaining calls.)

Properties  | 

game :Object

Defined in: adventure/SaveManager.js, line 36

Default value: {}

A reference back to the main Game object.
restore_cancel :HTMLElement

Defined in: adventure/RestoreManager.js, line 353

Default value: {}

Button element to dispel the Restore dialog.
save_dialog :HTMLElement

Defined in: adventure/SaveManager.js, line 51

Default value: {}

Div element to contain the Save dialog.
saveButtons :Array

Defined in: adventure/SaveManager.js, line 43

Default value: []

Collection of HTML elements: the action buttons for the different save methods.
saveCancel :HTMLElement

Defined in: adventure/SaveManager.js, line 280

Default value: {}

Button element to dispel the Save dialog.
saveRowInput :HTMLElement

Defined in: adventure/SaveManager.js, line 309

Default value: {}

Div element to contain the Save row input.