# SettingsEvent

Events of this class are fired when the option settings file is saved or reloaded.

This event has the following subtypes:

- settingspresave: Fires immediately before the program saves its in-memory configuration to the settings file. This gives you a chance to save any in-memory settings to the configuration so that it'll be included in the saved file. This event can't be canceled.
- settingspostsave: Fires immediately after the settings file has been saved. This event can't be canceled.
- settingsreload: Fires immediately after the settings file is reloaded. The file is reloaded whenever the user makes any changes in the settings dialog, to ensure that all of the new settings are applied throughout the program. The event occurs after the fact, so it can't be canceled.

The event target for this event type is the optionSettings object.

## Save events

PinballY keeps a copy of the settings in memory for quick access. When something changes - say, the user activates a new filter in the wheel API - the change is recorded in the in-memory copy of the settings, but isn't immediately saved to the file. This avoids the need to constantly re-write the file every time the user presses a button, which would slow things down slightly in the UI.

Whenever a change is made to the in-memory copy of the settings, the program sets an internal flag saying that the in-memory copy is "dirty" (that is, modified relative to the file copy). From time to time, the program checks the flag and automatically saves any pending changes.

The user never has to enter an explicit "Save" command to save changes. The program saves changes any pending automatically, at various times:

- Just before quitting
- Just before launching a game
- Just before showing the Options dialog
- Any time the UI has been idle for about 15 seconds

## Reload events

The program automatically reloads the option settings file any time the user makes changes in the Settings dialog.

Reloading the settings file also requires reloading the game databases and game file lists, since changes to the settings can affect which files are included in the scans and which databases are loaded. Games that were previously loaded into the in-memory game list might be removed from memory as a result. Any GameInfo objects or game ID values that referred to such games will become invalid, so you could use this event to clear any global variables or other cached information you might be keeping on loaded games.

Any table media files (playfield videos or images, etc) currently being displayed are also reloaded.

## Properties

This event type has all of the standard event properties and methods (see the Event class), plus the following:

- succeeded: For settingspostchange events only, this is a boolean value indicating whether or not the settings file was successfully saved. true means that the save was successful, false means that an error occurred writing the file.