xidenlz-CFG-Lib
1.0.0
dotnet add package xidenlz-CFG-Lib --version 1.0.0
NuGet\Install-Package xidenlz-CFG-Lib -Version 1.0.0
<PackageReference Include="xidenlz-CFG-Lib" Version="1.0.0" />
<PackageVersion Include="xidenlz-CFG-Lib" Version="1.0.0" />
<PackageReference Include="xidenlz-CFG-Lib" />
paket add xidenlz-CFG-Lib --version 1.0.0
#r "nuget: xidenlz-CFG-Lib, 1.0.0"
#:package xidenlz-CFG-Lib@1.0.0
#addin nuget:?package=xidenlz-CFG-Lib&version=1.0.0
#tool nuget:?package=xidenlz-CFG-Lib&version=1.0.0
Table of Contents
- Content
Introduction
A straightforward settings library designed for integration into various types of applications, Whether you're working with ImGui, a console program, or any other application requiring user settings management, this library relies on the nlohmann::json library for storage and creates a folder called MySettings in C:\Users\User\AppData\Roaming with a Settings.json file
Overview
The library has three major functions: | Function | Description | | ------------- | ------------- | | Load_CFG | Loads the configuration file when the program runs | | Save_CFG | Saves the current configuration when a button is clicked or when the function is called, This function can also be used in a thread to keep the configuration file up to date as the user makes changes | | Delete_CFG | Deletes the saved configuration file when called | | ImportSettings | Import the settings | | ExportSettings | Exports the settings |
Compatibility
- ImGui
- C++ Console Programs
- GLFW
- Qt
- wxWidgets
- Win32 Gui
| Data types support |
|---|
| bool |
| int |
| float |
| string |
| ImColor |
Usage
- Pass variables according to their definition type, For example, if you need to pass a variable of type bool, use it as shown below:
void ImportSettings(const nlohmann::json& j)
{
C_Boolean = j.at("CFG").at("C_Boolean").get<bool>();
}
nlohmann::json ExportSettings()
{
return nlohmann::json
{
{"CFG", {
// bool
{"C_Boolean", C_Boolean}
}}
};
}
And the same goes for all data types. Please read the samples:
Output
{
"CFG": {
"C_Boolean": false,
}
}
Examples
- If you are working with a console program or a GUI program, simply include the
cfg_systemin your initialization header, then create a new instance and call it with the following function as shown:
// Instance
MySettings Settings;
// Your init function
Settings.Load();
// ImGui
if (ImGui::Button("Save Settings"))
{
// And the same goes to Delete_CFG, Load_CFG
Settings.Save_CFG();
}
Data types
- Exporting bool
// bool
{"C_Boolean", C_Boolean},
- Importing bool
// bool
{"C_Boolean", C_Boolean},
- Exporting RGBA Values
{"C_ImColor", { C_ImColor.R, C_ImColor.G, C_ImColor.B, C_ImColor.A }}
- Importing RGBA Values
if (j.at("CFG").contains("C_ImColor"))
{
const auto& color = j.at("CFG").at("C_ImColor");
if (color.is_array() && color.size() == 4)
{
C_ImColor.R = color[0].get<float>();
C_ImColor.G = color[1].get<float>();
C_ImColor.B = color[2].get<float>();
C_ImColor.A = color[3].get<float>();
}
}
Installation
- Install nlohmann json via NuGet or simply include this header
- You can install the library via NuGet, download it from the releases page, or include it by adding this header
Build
- CMake
- Create a new folder.
- Open CMake and set the source folder to
CFG-Lib\Build. - Configure the project, then generate the solution.
- Visual Studio
- Navigate to the build folder.
- Open the CFG_SYS.sln file.
Buggs
If you encounter any bugs or issues, please create an issue here and describe the problem.
Support My Work
As a solo developer, your support is invaluable to me. If you find my work helpful, consider making a donation.
License
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 691 | 8/25/2024 |
Features v1.00:
Import
Export
Load
Delete
Supported Data Types
bool
int
string
ImColor
float
Compatibility
ImGui
C++ Console Programs
GLFW
Qt
wxWidgets
Win32 GUI