add extension to write to cba_settings.sqf file
When merged this pull request will:
- title
It would be super convenient if settings could be written by the game to the settings files directly. So I wanted to have an extension for that. Pardon my poor C++, I have no idea what's going on, lol
READ -> reads setting value & force lvl
WRITE -> overwrites setting with given value & force lvl
CLEAR -> empties cba_settings.sqf
PARSE -> gives a parseSimpleArray'able super array of all settings, value, force lvl triplets. Since extension callback is limited by like 17k chars, this comes in batches of 10k. The idea is to append the 10k batches in SQF before using PSA.
Currently only works for the main game userconfig, not for missions (need to figure out the system path).
I would
struct settingEntry { uint8_t force; std::string settingValue; }
std::unordered_map<std::string, settingEntry> settings;
on parse then clear map and parse entries into it. on update you just update the entry, and write out all others. No need to reparse file.
write(setValue) is settings[...] = ... + write append is settings[...] = ... + write clear is settings.clear() + write read is return settings[...] then you have one parse function that parses file and fills the map and one function that writes the file from map contents that is called by write/append/clear
also then no need for append vs write, as duplicate entries don't make sense anyway?
Since extension callback is limited by like 17k chars,
is it? I thought callbacks were unlimited
is it? I thought callbacks were unlimited
It only gave me that long a string (17 something k characters) when I tried how large a settings file I can get.
I would unordered_map
But what if I edit the file while the game is running?
But what if I edit the file while the game is running?
store file change date of last parse/write. Then when reading check file change date, if it was edited you need to reload. If not then not.