Git Product home page Git Product logo

-ror2-inlobbyconfig's Introduction

Description

This library adds an ability to edit configs for mods (that support this) inside a lobby.

For developers

Dependency attribute [BepInDependency("com.KingEnderBrine.InLobbyConfig")]

TL;DR

Easiest (but limited) way to add config based on BepInEx config is to use helper method

var configEntry = InLobbyConfig.Fields.ConfigFieldUtilities.CreateFromBepInExConfigFile(Config, "Display name");
InLobbyConfig.ModConfigCatalog.Add(configEntry);

There is a special field. If your config has a bool field called Enabled (ignored case) it will be shown next to the mod name like so:

This behavior can be disabled if you add false to parameters for CreateFromBepInExConfigFile.

Or you can create InLobbyConfig.ModConfigEntry and add fields and section manually

var configEntry = new InLobbyConfig.ModConfigEntry();
configEntry.DisplayName = "Display name";
//configEntry.EnableField = new BooleanConfigField(...);
configEntry.SectionFields.Add("Section name", new List<IConfigField>
{
    new InLobbyConfig.Fields.BooleanConfigField("display name", () => ConfigField.Value, (newValue) => ConfigField.Value = newValue),
    InLobbyConfig.Fields.ConfigFieldUtilities.CreateFromBepInExConfigEntry<int>(ConfigField)
});
InLobbyConfig.ModConfigCatalog.Add(configEntry);

Documentation

Supported field types

Type Field class
bool BooleanConfigField
enum EnumConfigField
int IntConfigField
float FloatConfigField
string StringConfigField
UnityEngine.Color ColorConfigField
Collection SelectListField

Or you can create your own ConfigField with your own prefab, for example:

Field constructor parameters description

BaseConfigField (BooleanConfigField, EnumConfigField)
  • displayName - name of a field
  • tooltip - text to display when hover over field name.
  • valueAccessor - a function which will be used to retrieve actual value of config.
BaseInputConfigField (ColorConfigField, StringConfgiField)

Same as BaseConfigFiled +

  • onValueChanged - a function which will be called when the value of a field is changed. Value in config doesn't automatically change, this is up to you what you want to do with the changed value.
  • onEndEdit - a function which will be called when a user ended changing field. Unlike onValueChange which called with every change. Value in config doesn't automatically change, this is up to you what you want to do with the changed value.
BaseNumberInputConfigField (IntConfigField, FloatConfigField)

Same as BaseInputConfigField +

  • minimum - minimum for a field value.
  • maximum - maximum for a filed value.
SelectListField

Same as BaseConfigField +

  • OnItemAddedCallback - a function which will be called when a new item added to a collection.
  • OnItemRemovedCallback - a function which will be called when an item removed from a collection.
  • OptionsAccessor - a function which will be used to retrieve options for selection.

Custom config field

Mandatory things that you need to create a custom config field:

  • Create a class that implements InLobbyConfig.Fields.IConfigField (or inherits form InLobbyConfig.Fields.BaseConfigField<T>)
  • Create a class that inherites InLobbyConfig.FieldControllers.ConfigFieldController
  • Create a prefab that has your ConfigFieldController in a root object

From this point, you can do whatever you want. For examples of how I set up fields, you can go to InLobbyConfig GitHub or ArtifactsRandomizer GitHub.

Changelog

1.3.2

  • Small inegration with ScrollableLobbyUI if it's installed

1.3.1

  • Fixed an issue when using gamepad selecting InLobbyConfig button would bug out the lobby so you couldn't select anything except difficulty/artifacts.

1.3.0

  • Removed r2api dependency

1.2.1

  • Fixed InLobbyConfig.Fields.ConfigFieldUtilities.CreateFromBepInExConfigFile() parameters

1.2.0

  • Added search for select collection dropdown.

1.1.0

  • Added select collection field prefab from ArtifactRandomizer.

1.0.2

  • Mod, section, and field name texts now have an automatic size and will be scaled down to fit more text.

1.0.1

  • Readme update

1.0.0

  • Mod release.

-ror2-inlobbyconfig's People

Contributors

kingenderbrine avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.