/* * Copyright 2022 Peter Han * Permission is hereby granted, free of charge, to any person obtaining a copy of this software * and associated documentation files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, modify, merge, publish, * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all copies or * substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ using System.Collections.Generic; namespace PeterHan.PLib.Options { /// /// An optional interface which can be implemented to give mods the ability to dynamically /// add new options at runtime, or to get a notification when options are updated to the /// options file. /// /// This interface is optional. There is no need to implement it to use PLib /// Options. But if one method is implemented, the other must also be. If not used, /// OnOptionsChanged should be empty, and CreateOptions should return an empty collection. /// public interface IOptions { /// /// Called to create additional options. After the options in this class have been /// read from the data file, but before the dialog is shown, this method will be /// invoked. Each return value must be of a type that implements IOptionsEntry. /// /// The options will be sorted and categorized normally as if they were present at the /// end of the property list in a regular options class. /// /// This method can be an enumerator using code like /// yield return new MyOptionsHandler(); /// /// The custom options to implement. IEnumerable CreateOptions(); /// /// Called when options are written to the file. The current object will have the same /// values as the data that was just written to the file. This call happens after the /// options have been stored to disk, but before any restart required dialog is shown /// (if [RestartRequired] is also on this class). /// void OnOptionsChanged(); } }