About this mod
This is a simple ini loader i made to configure my other mods
- Requirements
- Permissions and credits
i know there are already ini solutions but i wanted to make my own.
It uses a singleton design pattern, so it will only read and parse the file for the first time you call a ReadXXX data, the rest it will get it from memory. After you are done fetching data from the INI, you can call the function Dispose, which i strongly suggest you to do as it frees memory and the next time you want to read from the INI it will get a newer version of the file if it was updated.
All exceptions that could happen are handled, this adds a little overhead but is totally worth it.
All keys and sections are case insensitive
Given we have a simple ini file
You can call functions to read from the ini, all with the same parameters but for their givem return type
File: The path of the file, it starts from the data folder. example (The .ini at the end is optional): Mythic Items
Group: The section of the ini which for this mod is mandatory, example: [MagicLongSword]
Config: The key of the ini, example: AttackDamage = 25
Default: (optional parameter) if the key was not found or is empty, this value will be returned instead, example: 10.0
Here is how it would look like:
All the avaliable functions:
There is also a dispose function that must be called when you are done reading from the ini
It uses a singleton design pattern, so it will only read and parse the file for the first time you call a ReadXXX data, the rest it will get it from memory. After you are done fetching data from the INI, you can call the function Dispose, which i strongly suggest you to do as it frees memory and the next time you want to read from the INI it will get a newer version of the file if it was updated.
All exceptions that could happen are handled, this adds a little overhead but is totally worth it.
All keys and sections are case insensitive
Given we have a simple ini file
You can call functions to read from the ini, all with the same parameters but for their givem return type
File: The path of the file, it starts from the data folder. example (The .ini at the end is optional): Mythic Items
Group: The section of the ini which for this mod is mandatory, example: [MagicLongSword]
Config: The key of the ini, example: AttackDamage = 25
Default: (optional parameter) if the key was not found or is empty, this value will be returned instead, example: 10.0
Here is how it would look like:
All the avaliable functions:
There is also a dispose function that must be called when you are done reading from the ini