Show / Hide Table of Contents

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

Inheritance
object
Object
ScriptableObject
GlobalSettings
WeaverCoreGlobalSettings
Inherited Members
ScriptableObject.SetDirty()
ScriptableObject.CreateInstance(string)
ScriptableObject.CreateInstance(Type)
ScriptableObject.CreateInstance<T>()
Namespace: WeaverCore.Settings
Assembly: WeaverCore.dll
Syntax
public abstract class GlobalSettings : ScriptableObject

Properties

| Edit this page View Source

InPauseMenu

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
| Edit this page View Source

Selected

Whether the panel is currently selected in the weaver settings

Declaration
public bool Selected { get; }
Property Value
Type Description
bool
| Edit this page View Source

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
| Edit this page View Source

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 Source

AddButtonElement(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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

AddSpacing()

Adds a spacing element

Declaration
public SpaceElement AddSpacing()
Returns
Type Description
SpaceElement

Returns the spacing element that was just created

| Edit this page View Source

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

| Edit this page View Source

GetAllSettings()

Gets all the setting panels currently registered

Declaration
public static IEnumerable<GlobalSettings> GetAllSettings()
Returns
Type Description
IEnumerable<GlobalSettings>
| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

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

| Edit this page View Source

LoadSettings()

Loads the stored settings for this panel from disk

Declaration
public void LoadSettings()
| Edit this page View Source

OnLoad()

Called after the settings are loaded from a file

Declaration
protected virtual void OnLoad()
| Edit this page View Source

OnPanelClose()

Called when the panel gets deselected in the weaver settings

Declaration
protected virtual void OnPanelClose()
| Edit this page View Source

OnPanelOpen()

Called when the panel gets selected in the weaver settings

Declaration
protected virtual void OnPanelOpen()
| Edit this page View Source

OnRegister()

Called when the panel gets registered with the Settings Menu

Declaration
protected virtual void OnRegister()
| Edit this page View Source

OnSave()

Called right before the settings are saved to a file

Declaration
protected virtual void OnSave()
| Edit this page View Source

OnUnRegister()

Called when the panel gets unregistered from the settings menu

Declaration
protected virtual void OnUnRegister()
| Edit this page View Source

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()
| Edit this page View Source

RemoveAllElements()

Removes all elements from the settings menu

Declaration
public void RemoveAllElements()
| Edit this page View Source

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

| Edit this page View Source

SaveSettings()

Saves the stored settings for this panel to disk

Declaration
public void SaveSettings()

Extension Methods

ReflectionUtilities.ReflectCallMethod(object, string, object[], BindingFlags)
ReflectionUtilities.ReflectGetField(object, string, BindingFlags)
ReflectionUtilities.ReflectGetMethod(object, string, BindingFlags)
ReflectionUtilities.ReflectGetProperty(object, string, BindingFlags)
ReflectionUtilities.ReflectSetField(object, string, object, BindingFlags)
ReflectionUtilities.ReflectSetProperty(object, string, object, BindingFlags)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Generated by DocFX
☀
☾