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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="xidenlz-CFG-Lib" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="xidenlz-CFG-Lib" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="xidenlz-CFG-Lib" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add xidenlz-CFG-Lib --version 1.0.0
                    
#r "nuget: xidenlz-CFG-Lib, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package xidenlz-CFG-Lib@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=xidenlz-CFG-Lib&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=xidenlz-CFG-Lib&version=1.0.0
                    
Install as a Cake Tool

License GitHub release issues - CFG-Library NuGet - CFG-Library v1.00

Quilty - Built with Highly Optimized C++

Table of Contents

  1. 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_system in 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

  1. Install nlohmann json via NuGet or simply include this header
  2. You can install the library via NuGet, download it from the releases page, or include it by adding this header

Build

  • CMake
  1. Create a new folder.
  2. Open CMake and set the source folder to CFG-Lib\Build.
  3. Configure the project, then generate the solution.
  • Visual Studio
  1. Navigate to the build folder.
  2. 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.

Donate - Bitcoin Donate - Monero Donate - USDT

License

Released under MIT by @xidenlz.

There are no supported framework assets in this package.

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