Constructor
# new Storage(bridge, dispatcher, params)
Create a new storage handler.
Parameters:
Name | Type | Description |
---|---|---|
bridge |
string
|
Object
|
the execution context bridge |
dispatcher |
Object
|
the custom event dispatcher |
params |
Object
|
|
register |
boolean
|
register handlers immediately or defer |
Classes
Members
string
# localStorageSettingsKey
localStorageSettingsKey - the key for settings from localstorage in the web context
Methods
# loadGameSavesFromBridge() → {void}
Load save games from emitted IPC event when running as a desktop app
void
# loadGameSavesFromLocalStorage(loader) → {void}
Load saved games from local storage when running through the browser
Parameters:
Name | Type | Description |
---|---|---|
loader |
HTMLElement
|
element to append saved games list to load from |
void
# saveGame(game) → {void}
Handle saving game to storage.
Parameters:
Name | Type | Description |
---|---|---|
game |
Object
|
the managed game instance |
void
# saveLocalStorageSettings() → {void}
Save settings to local storage when running in the browser
void
# setBridge(bridge) → {void}
Set the execution context bridg.
If the game is runing through the browser on the web, then the bridge
will simply be set to "web", otherwise it will contain the IPC event emitter
for bi-directional communication between the browser and the node runtime.
Parameters:
Name | Type | Description |
---|---|---|
bridge |
string
|
Object
|
the execution context bridge |
void
# setDifficultySettings(difficulty) → {void}
Store and set difficulty settings.
Parameters:
Name | Type | Description |
---|---|---|
difficulty |
string
|
the difficulty setting "easy", "medium", or "hard" |
void
# setGameInstanceAttached(isCreated) → {void}
Set the flag to indicate that the game is instantiated.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
isCreated |
boolean
|
false | whether or not the game is insantiated |
void
# setGodModeSettings(godmode) → {void}
Store and set god-mode setting.
Parameters:
Name | Type | Description |
---|---|---|
godmode |
boolean
|
whether or not god-mode is enabled |
void
# setSetting(key, value, persist) → {void}
Set an individual setting.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
key |
string
|
the setting object key | |
value |
string
|
number
|
boolean
|
the setting key value | |
persist |
boolean
|
false | whether or not to save the setting to storage |
void
# setSettings(settings, persist) → {void}
Set settings from storage.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
settings |
Object
|
the settings object | |
persist |
boolean
|
false | whether or not to persist settings on load |
void
# setUIState(key) → {void}
Set the UI state depending on the value of stored settings, i.e volume sliders.
Parameters:
Name | Type | Description |
---|---|---|
key |
string
|
the type of UI object to set |
void
# setVolumeSettings(volume) → {void}
Store and set volume settings.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
volume |
Object
|
null | the audio object to set |
void