LethalSettings
A centralized place for configuring mods from in-game
Date uploaded | 10 months ago |
Version | 1.3.0 |
Download link | willis81808-LethalSettings-1.3.0.zip |
Downloads | 309080 |
Dependency string | willis81808-LethalSettings-1.3.0 |
This mod requires the following mods to function
BepInEx-BepInExPack
BepInEx pack for Mono Unity games. Preconfigured and ready to use.
Preferred version: 5.4.2100README
LethalSettings
This utility provides a centralized framework through which other Lethal Company mods can register and display custom configuration/settings through a new "Mod Settings" button added to the existing in-game Settings menu.
Usage
It is simple to create and register a custom settings panel for your mod, you must simply provide your mod's basic details and a collection of MenuComponents
which LethalSettings will use to construct your UI.
Here is a basic example:
ModMenu.RegisterMod(new ModMenu.ModSettingsConfig
{
Name = "Example Mod",
Id = "com.willis.lc.examplemod",
Version = "0.0.1",
Description = "This is an example mod registration showing how easy it can be to give your mod configuration a vanilla-like feel!",
MenuComponents = new MenuComponent[]
{
new ButtonComponent
{
Text = "This is yet another test button!",
OnClick = (self) => Logger.LogInfo("You clicked the second test button!")
},
new HorizontalComponent
{
Children = new MenuComponent[]
{
new ToggleComponent
{
Text = "Toggle me!",
OnValueChanged = (self, value) => Logger.LogInfo($"New value: {value}")
},
new SliderComponent
{
Value = 30,
MinValue = 10,
MaxValue = 50,
Text = "Example Slider",
OnValueChanged = (self, value) => Logger.LogInfo($"New value: {value}")
}
}
},
new LabelComponent
{
Text = "Hello, World!"
}
}
});
This example will end up being rendered like so:
Extending LethalSettings
You can create custom UI elements that are compatible with LethalSettings by simply extending the base MenuComponent
class.
Menu Components are required to have a Construct
method, which accepts the parent UI element as input and must return the newly constructed UI element.
The built-in LabelComponent
serves as a simple example:
public class LabelComponent : MenuComponent
{
public string Text { internal get; set; } = "Label Text";
public float FontSize { internal get; set; } = 23f;
public TextAlignmentOptions Alignment { internal get; set; } = TextAlignmentOptions.MidlineLeft;
public override GameObject Construct(GameObject root)
{
return GameObject.Instantiate(Assets.LabelPrefab, root.transform).Initialize(this);
}
}
Contributing
Contributions are welcome. Please submit a pull request with your proposed changes.
License
This project is licensed under the terms of the MIT license.
CHANGELOG
1.4.1
- Fixed bug where mod settings menu is opened by default the first time the game settigns are accessed
1.4.0
- Updated components to use a new font map generated from an extended Unicode character set
1.2.2
- Fixed the
SliderComponent
initial value defect frfr - Started adding documentation to significant properties on the built-in menu components
1.2.1
- Corrected a defect in
SliderComponent
that caused the incorrect initial value to be displayed due to an execution order issue with the initial and max value properties
1.2.0 BREAKING
- Layout should be much more stable and predictable now
- Standardized the built-in menu component callback naming convention to
OnValueChanged
- Changed all built-in menu components that previously had separate
CurrentValue
andValue
properties into a singleValue
property that supports dynamic updates as well as setting the initial value
1.1.0
- Added
InputComponent
for arbitrary text input - Added
DropdownComponent
for selecting from predefined options - Mod Settings list now sort mods in alphabetical order by name
- (Nearly) all built-in menu components now output their current value and support dynamic updates to their properties