ConfigGarden
Small utility for managing configuration files.
| Last updated | 5 days ago |
| Total downloads | 35 |
| Total rating | 0 |
| Categories | Libraries |
| Dependency string | FeluciaPS-ConfigGarden-1.0.1 |
| Dependants | 1 other package depends on this package |
README
ConfigGarden
A simple modding utility to save/load json configuration files in predictable locations.
Usage
First, create a config class with all the properties you plan to use and a ModInfo class
using ConfigGarden;
using ConfigGarden.Interfaces;
class MyConfig
{
public bool Enabled { get; set; } = true;
}
class ModInfo : IModInfo
{
public string GAME_NAME => "Tiny Terry's Turbo Trip";
public string AUTHOR_NAME => "FeluciaPS";
public string MOD_NAME => "My Awesome Mod";
}
You can then create a ConfigHelper anywhere in your plugin.
public class MyPlugin
{
public static ConfigHelper<MyConfig> config;
public static void Awake() {
// Loads the config from disk, or creates it with default values if it doesn't exist
config = new ConfigHelper<MyConfig>(new ModInfo());
// You can now access the config values through the Data property
bool isEnabled = config.Data.Enabled;
// And set them
config.Data.Enabled = false;
// Just don't forget to save after making changes
config.Save();
}
}
Optional parameters
fileName: defaults toconfig.json.logger: pass any class implementingConfigGarden.Interfaces.ILoggerto have messages logged to your console.
Other
The library also contains a small WineHelper.IsWine property that you can use to detect WINE environments.
It does this by checking if wine_get_version is present on ntdll.dll which should only be the case when WINE is running.
File locations
By default, files are saved in [rootdir]/ModConfig/[GameName]/[PluginAuthor]/[PluginName].
- Windows:
[rootdir]is yourMy Documentsfolder - WINE:
[rootdir]is~/.config/(or whatever is in the user's$XDG_CONFIG_HOMEvariable)
Not all WINE forks and Linux distros have been tested, so the path may vary there.
Example: Documents/ModConfig/Tiny Terry's Turbo Trip/FeluciaPS/My Awesome Mod/
Credits
Created by FeluciaPS. Mod icon by Frutiflow.
Special thanks to Frutiflow for testing on WINE.