用户登录
|忘记密码

新用户注册

登录

其他登陆



举报

BepInEx 插件/Mod管理 + GUI 汉化版(Plugin / mod configuration manager)

BepInEx  插件/Mod管理 + GUI 汉化版(Plugin / mod configuration manager)
BepInEx  插件/Mod管理 + GUI 汉化版(Plugin / mod configuration manager)
原作者:BepInEx
汉化:◕小莫◕
发布日期:2021-01-28 13:10:03
更新时间:2021-01-28 13:10:03
◕小莫◕ 3DM Mod组
喜欢,那就点个关注吧~

本Mod由3DM原创作者“◕小莫◕”汉化,未经允许,禁止任何人以任何形式转载!

作者:BepInEx  

汉化:小莫

源码:https://github.com/BepInEx/BepInEx.ConfigurationManager



一个简单的工具,无需自己制作,直接你的插件/Mod 配置一个GUI,用户可以更改你公开的任何设置,包括键盘快捷键;


默认按F1打开管理界面,这个按键可以根据自己的习惯修改;


安装方法:

 - 安装BepInEx  :https://mod.3dmgame.com/mod/172563

 - 将“ConfigurationManager.dll”和“ConfigurationManager.xml”放入“\BepInEx\plugins”目录

 - 如果没有“plugins”就自己新建一个

- 进游戏按F1打开菜单


为你的Mod制作GUI:

ConfigurationManager 会自动将插件的配置内容显示出来;

ConfigurationManager 将使用所有元素(例如:说明,范围)向用户展示;

在大多数情况下,您不必引用ConfigurationManager.dll或对其进行特殊的数据处理;


只需确保添加尽可能多的参数(这样可以帮助玩家更好的进行修改)。别忘了添加描述、键名、值范围。


为你的Mod添加范围滑块:

创建时,请指定 AcceptableValueRange ,如果范围是0f-1f,或0-100,则滑块将显示百分比%。

CaptureWidth = Config.AddSetting("Section", "Key", 1, new ConfigDescription("Description", new AcceptableValueRange<int>(0, 100)));


为你的Mod添加下拉选项:

创建时,请指定 AcceptableValueList ,如果使用枚举,则无需指定 AcceptableValueList ,将会显示所有的枚举值。


注意:你可以将 System.ComponentModel.DescriptionAttribute 添加到枚举项目中,以覆盖其显示的名称,如:

public enum MyEnum
{
    // Entry1 将在下拉框中 显示 Entry1
    Entry1,
    [Description("Entry2 将在下拉框中显示该字符串")]
    Entry2
}


为你的Mod添加自定义按键:

创建类型为 KeyboardShortcut ,可以使用Update()函数 + IsDown 来监听用户是否按下;

KeyboardShortcut 支持Shift、Ctrl、Alt的修饰键,并且这些按键也得到了合适的处理,避免了一些常见的问题;

例如   K+Shift+Ctrl 时会触发 K+Shift 的问题。(这个问题不会出现了)

private ConfigEntry<KeyboardShortcut> ShowCounter { get; set; }

public Constructor()
{
    ShowCounter = Config.AddSetting("Hotkeys", "Show FPS counter", new KeyboardShortcut(KeyCode.U, KeyCode.LeftShift));
}

private void Update()
{
    if (ShowCounter.Value.IsDown())
    {
        // 处理按键
    }
}


覆盖Configuration Manager的默认行为:

You can change how a setting is shown inside the configuration manager window by passing an instance of a special class as a tag of the setting. The special class code can be downloaded here. Simply download the .cs file and drag it into your project.


You do not have to reference ConfigurationManager.dll for this to work.

The class will work as long as name of the class and declarations of its fields remain unchanged.

Avoid making the class public to prevent conflicts with other plugins. If you want to share it between your plugins either give each a copy, or move it to your custom namespace.

If the ConfigurationManager plugin is not installed in the game, this class will be safely ignored and your plugin will work as normal.

Here's an example of overriding order of settings and marking one of the settings as advanced:


// Override IsAdvanced and Order
Config.AddSetting("X", "1", 1, new ConfigDescription("", null, new ConfigurationManagerAttributes { IsAdvanced = true, Order = 3 }));
// Override only Order, IsAdvanced stays as the default value assigned by ConfigManager
Config.AddSetting("X", "2", 2, new ConfigDescription("", null, new ConfigurationManagerAttributes { Order = 1 }));
Config.AddSetting("X", "3", 3, new ConfigDescription("", null, new ConfigurationManagerAttributes { Order = 2 }));

How to make a custom editor for my setting?

If you are using a setting type that is not supported by ConfigurationManager, you can add a drawer Action for it. The Action will be executed inside OnGUI, use GUILayout to draw your setting as shown in the example below.


To use a custom seting drawer for an individual setting, use the CustomDrawer field in the attribute class. See above for more info on the attribute class.


void Start()
{
    // Add the drawer as a tag to this setting.
    Config.AddSetting("Section", "Key", "Some value" 
        new ConfigDescription("Desc", null, new ConfigurationManagerAttributes{ CustomDrawer = MyDrawer });
}


static void MyDrawer(BepInEx.Configuration.ConfigEntryBase entry)
{
    // Make sure to use GUILayout.ExpandWidth(true) to use all available space
    GUILayout.Label(entry.BoxedValue, GUILayout.ExpandWidth(true));
}

Add a custom editor globally

You can specify a drawer for all settings of a setting type. Do this by using ConfigurationManager.RegisterCustomSettingDrawer(Type, Action<SettingEntryBase>).


Warning: This requires you to reference ConfigurationManager.dll in your project and is not recommended unless you are sure all users will have it installed. It's usually better to use the above method to add the custom drawer to each setting individually instead.


void Start()
{
    ConfigurationManager.RegisterCustomSettingDrawer(typeof(MyType), CustomDrawer);
}
static void CustomDrawer(SettingEntryBase entry)
{
    GUILayout.Label((MyType)entry.Get(), GUILayout.ExpandWidth(true));
}









原贴地址
1.版本号: 1.016.1   更新时间: 2021-01-28 13:09:52

2.版本号: 1.016.1   更新时间: 2021-01-28 13:09:59

选择快速回复类型:
  • 感谢
  • 支持
  • 疑问
  • 卖萌
  • 关心
  • 傲娇
评论


    作者精品
    logo

    BepInEx 插件/Mod管理 + GUI 汉化版(Plugin / mod configuration manager)


    Mod大小:40.70KB
    上传时间:2021-01-28 13:10:04

    Mod简介:

    暂无更多介绍

    本地下载
    选择快速回复类型:
    • 感谢
    • 支持
    • 疑问
    • 卖萌
    • 关心
    • 傲娇
    回复

    ◕小莫◕ 3DM Mod组
    喜欢,那就点个关注吧~

    点击上方“关注”按钮即可收到作者的更新提醒哦~

    closeAD