Class GlobalSettings
Store global information about a mod, and creates a panel in the Settings Menu where they can be changed
Inherit from this class to create a custom panel in the settings menu, then use RegisterPanel<T>() to register the panel and make it show up in the settings menu
Inherited Members
Namespace: WeaverCore.Settings
Assembly: WeaverCore.dll
Syntax
public abstract class GlobalSettings : ScriptableObject
Properties
| Edit this page View SourceInPauseMenu
If true, then the Weaver Settings Menu is being opened up in the pause menu.
If false, then the Weaver Settings Menu is being opened up in the main menu.
Declaration
public static bool InPauseMenu { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Selected
Whether the panel is currently selected in the weaver settings
Declaration
public bool Selected { get; }
Property Value
| Type | Description |
|---|---|
| bool |
TabName
The name of the tab. Tabs are the buttons on the top row that are used to select the panel in the weaver settings
Declaration
public virtual string TabName { get; }
Property Value
| Type | Description |
|---|---|
| string |
UIElements
A list of all the currently shown UI elements. Returns null if the panel is not selected
Declaration
public ReadOnlyCollection<UIElement> UIElements { get; }
Property Value
| Type | Description |
|---|---|
| ReadOnlyCollection<UIElement> |
Methods
| Edit this page View SourceAddButtonElement(Action, string, string)
Adds a button to the settings menu
Declaration
public UIElement AddButtonElement(Action onClick, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| Action | onClick | The action to call when the button is pressed |
| string | displayName | The name of the property displayed on the panel |
| string | description | The description of the property when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddButtonElement(MethodInfo)
Adds a button to the settings menu
Declaration
public UIElement AddButtonElement(MethodInfo methodInfo)
Parameters
| Type | Name | Description |
|---|---|---|
| MethodInfo | methodInfo | The method to call when the button is pressed |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddButtonElement(MethodInfo, string, string)
Adds a button to the settings menu
Declaration
public UIElement AddButtonElement(MethodInfo methodInfo, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| MethodInfo | methodInfo | The method to call when the button is pressed |
| string | displayName | The name of the property displayed on the panel |
| string | description | The description of the property when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddButtonElement(string)
Adds a button to the settings menu
Declaration
public UIElement AddButtonElement(string methodName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | methodName | The name of the method to call when the button is pressed |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddButtonElement(string, string, string)
Adds a button to the settings menu
Declaration
public UIElement AddButtonElement(string methodName, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| string | methodName | The name of the method to call when the button is pressed |
| string | displayName | The name of the property displayed on the panel |
| string | description | The description of the property when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddFieldElement(FieldInfo)
Adds a UI element to the panel for displaying the field in the settings menu.
Returns null if the Settings Menu isn't open or the field is not compatible
Declaration
public UIElement AddFieldElement(FieldInfo field)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to display |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddFieldElement(FieldInfo, string, string)
Adds a UI element to the panel for displaying the field in the settings menu.
Returns null if the Settings Menu isn't open or the field is not compatible
Declaration
public UIElement AddFieldElement(FieldInfo field, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| FieldInfo | field | The field to display |
| string | displayName | The name of the field displayed on the panel |
| string | description | The description of the field when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddFieldElement(string)
Adds a UI element to the panel for displaying the field in the settings menu.
Returns null if the Settings Menu isn't open or the field is not compatible
Declaration
public UIElement AddFieldElement(string fieldName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fieldName | The name of the field to display |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddFieldElement(string, string, string)
Adds a UI element to the panel for displaying the field in the settings menu.
Returns null if the Settings Menu isn't open or the field is not compatible
Declaration
public UIElement AddFieldElement(string fieldName, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| string | fieldName | The name of the field to display |
| string | displayName | The name of the field displayed on the panel |
| string | description | The description of the field when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddHeading(string)
Adds a header
Declaration
public HeaderElement AddHeading(string headerText)
Parameters
| Type | Name | Description |
|---|---|---|
| string | headerText | The text the header will have |
Returns
| Type | Description |
|---|---|
| HeaderElement | Returns the header element that was just created |
AddHeading(string, float)
Adds a header
Declaration
public HeaderElement AddHeading(string headerText, float fontSize)
Parameters
| Type | Name | Description |
|---|---|---|
| string | headerText | The text the header will have |
| float | fontSize | The font size the header will have. 58 is the default |
Returns
| Type | Description |
|---|---|
| HeaderElement | Returns the header element that was just created |
AddPropertyElement(PropertyInfo)
Adds a UI element to the panel for displaying the property in the settings menu.
Returns null if the Settings Menu isn't open or the property is not compatible
Declaration
public UIElement AddPropertyElement(PropertyInfo property)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfo | property | The property to display |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddPropertyElement(PropertyInfo, string, string)
Adds a UI element to the panel for displaying the property in the settings menu.
Returns null if the Settings Menu isn't open or the property is not compatible
Declaration
public UIElement AddPropertyElement(PropertyInfo property, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| PropertyInfo | property | The property to display |
| string | displayName | The name of the property displayed on the panel |
| string | description | The description of the property when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddPropertyElement(string)
Adds a UI element to the panel for displaying the property in the settings menu.
Returns null if the Settings Menu isn't open or the property is not compatible
Declaration
public UIElement AddPropertyElement(string propertyName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | The name of the property to display |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddPropertyElement(string, string, string)
Adds a UI element to the panel for displaying the property in the settings menu.
Returns null if the Settings Menu isn't open or the property is not compatible
Declaration
public UIElement AddPropertyElement(string propertyName, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| string | propertyName | The name of the property to display |
| string | displayName | The name of the property displayed on the panel |
| string | description | The description of the property when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
AddPropertyElement<T>(Func<T>, Action<T>, string, string)
Adds a custom property to the panel. Both retrieval and setting of the value can be customized
Declaration
public UIElement AddPropertyElement<T>(Func<T> getter, Action<T> setter, string displayName, string description)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<T> | getter | The getter function for getting the value |
| Action<T> | setter | The setter function for setting the value |
| string | displayName | The name of the property displayed on the panel |
| string | description | The description of the property when hovering over the element |
Returns
| Type | Description |
|---|---|
| UIElement | The UIElement that has been added to the panel |
Type Parameters
| Name | Description |
|---|---|
| T | The type of the property element |
AddSpacing()
Adds a spacing element
Declaration
public SpaceElement AddSpacing()
Returns
| Type | Description |
|---|---|
| SpaceElement | Returns the spacing element that was just created |
AddSpacing(float)
Adds a spacing element
Declaration
public SpaceElement AddSpacing(float spacing)
Parameters
| Type | Name | Description |
|---|---|---|
| float | spacing | The amount of spacing to add. 35.5 is the default |
Returns
| Type | Description |
|---|---|
| SpaceElement | Returns the spacing element that was just created |
GetAllSettings()
Gets all the setting panels currently registered
Declaration
public static IEnumerable<GlobalSettings> GetAllSettings()
Returns
| Type | Description |
|---|---|
| IEnumerable<GlobalSettings> |
GetElement(string)
Gets an element with the corresponding member name
Declaration
public UIElement GetElement(string memberName)
Parameters
| Type | Name | Description |
|---|---|---|
| string | memberName | The member name to look for |
Returns
| Type | Description |
|---|---|
| UIElement | Returns the corresponding element with the same member name, or null if no matches were found |
GetHeaderElement(string)
Gets a header element with the same title name
Declaration
public UIElement GetHeaderElement(string headerTitle)
Parameters
| Type | Name | Description |
|---|---|---|
| string | headerTitle | The header title to look for |
Returns
| Type | Description |
|---|---|
| UIElement | Returns the corresponding header element with the same title, or null if no matches were found |
GetSettings<T>()
Can be used anywhere and anytime to get a specific settings panel
Declaration
public static T GetSettings<T>() where T : GlobalSettings
Returns
| Type | Description |
|---|---|
| T | If the panel is registered, it will return a reference to the settings panel |
Type Parameters
| Name | Description |
|---|---|
| T | The type of panel to get |
LoadSettings()
Loads the stored settings for this panel from disk
Declaration
public void LoadSettings()
OnLoad()
Called after the settings are loaded from a file
Declaration
protected virtual void OnLoad()
OnPanelClose()
Called when the panel gets deselected in the weaver settings
Declaration
protected virtual void OnPanelClose()
OnPanelOpen()
Called when the panel gets selected in the weaver settings
Declaration
protected virtual void OnPanelOpen()
OnRegister()
Called when the panel gets registered with the Settings Menu
Declaration
protected virtual void OnRegister()
OnSave()
Called right before the settings are saved to a file
Declaration
protected virtual void OnSave()
OnUnRegister()
Called when the panel gets unregistered from the settings menu
Declaration
protected virtual void OnUnRegister()
RefreshAllElements()
Refreshes all UI Elements so that they are displaying the most recent version of the fields and properties of this panel
Declaration
public void RefreshAllElements()
RemoveAllElements()
Removes all elements from the settings menu
Declaration
public void RemoveAllElements()
RemoveUIElement(UIElement)
Removes a specific UI Element from the Settings Menu
Declaration
public bool RemoveUIElement(UIElement element)
Parameters
| Type | Name | Description |
|---|---|---|
| UIElement | element | The element to remove |
Returns
| Type | Description |
|---|---|
| bool | Returns whether the element has been removed or not |
SaveSettings()
Saves the stored settings for this panel to disk
Declaration
public void SaveSettings()