Saving Preferencse

From X-Plane SDK
Jump to: navigation, search

A few notes and guidelines on how to save preferences from X-Plane plugins. These are not "enforced" by the SDK - since you have access to direct file I/O routines, you can put files anywhere you want. These recommendations are designed to keep your plugin compatible with future versions of X-Plane and make life easier for users.

  • Store your preferences in X-Plane's "official" preferences directory. You can get this directory by calling XPMGetPrefsPath. You'll need to call XPLMExtractFileAndPath to remove the file name that's in the path - for historical reasons XPMGetPrefsPath always returns a file in the preferences directory. Mac users will need to convert the HFS path to a Posix path - see FilePathsAndMacho for sample code.
  • Do not store your preferences inside your fat plugin. The fat plugin should contain the "immutable" part of your plugin - art files and code - but not user's documents or preferences. If a user needs to reset all preferences, the user should not have to look through every fat plugin. In the future it is possible that the preferences folder may be writable while the plugins directory is not.
  • Do not iterate over every file in the preferences folder; most of them will not be yours. If your plugin needs to search for a range of files, create a sub-directory within the preferences folder.