Skip to content

Commit

Permalink
Added new bind functionality
Browse files Browse the repository at this point in the history
derekShaheen committed Mar 10, 2024
1 parent 973062a commit a76743c
Showing 5 changed files with 32 additions and 2 deletions.
2 changes: 0 additions & 2 deletions SkToolbox/Controllers/CommandHandler.cs
Original file line number Diff line number Diff line change
@@ -455,8 +455,6 @@ public void Run(string text)
convertedArgs.Add(convertedArg);
}

//Debug.Log("Running command " + command.data.keyword);
// Invoke the method, which will expand all the arguments automagically.
try
{
command.method.Invoke(this, convertedArgs.ToArray());
30 changes: 30 additions & 0 deletions SkToolbox/Controllers/SettingsController.cs
Original file line number Diff line number Diff line change
@@ -49,6 +49,36 @@ public static void Init(ConfigFile config)
}
}

/// <summary>
/// Bind a new configuration entry to the existing config file.
/// </summary>
/// <typeparam name="T">The type of the configuration value.</typeparam>
/// <param name="section">The section under which the configuration should be placed.</param>
/// <param name="key">The key for the configuration entry.</param>
/// <param name="defaultValue">The default value for the configuration entry.</param>
/// <param name="description">The description of the configuration entry.</param>
public static void NewBind<T>(string section, string key, T defaultValue, string description = "")
{
if (_configFile == null)
{
Debug.Log("Config file not initialized.");
return;
}

// Create the configuration entry
var configEntry = _configFile.Bind(section, key, defaultValue, description);

// Add or update the configuration entry in the dictionary
if (s_config.ContainsKey(key))
{
s_config[key] = configEntry;
}
else
{
s_config.Add(key, configEntry);
}
}

/// <summary>
/// Retrieve a specific config value by name.
/// </summary>
2 changes: 2 additions & 0 deletions SkToolbox/Loaders/SkBepInExLoader.cs
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.Networking;

@@ -80,6 +81,7 @@ private void Init()
UnityEngine.Object.DontDestroyOnLoad(SkGameObject);

Console = SkGameObject.AddComponent<MainConsole>();
SkPatcher.InitPatch();

LoadAliases();
LoadBinds();
Binary file added corlib/0Harmony20.dll
Binary file not shown.
Binary file modified corlib/BepInEx.dll
Binary file not shown.

0 comments on commit a76743c

Please sign in to comment.