General fluff => General ENIGMA => Topic started by: sorlok_reaves on August 10, 2014, 09:28:13 pm

Title: Ini Plugin Upgrade
Post by: sorlok_reaves on August 10, 2014, 09:28:13 pm
Hello all,

A while back I started working on some fixes to the ini plugin (which affects OSX and Linux users --Windows has its own approach). I had 3 goals:
  1) Provide basically the same behavior as GM:S (excluding obvious flaws). So, all the ini_* functions (including ini_write_*).
  2) Extend that to support saving and loading comments verbatim --now you can comment your ini files without ENIGMA eating the comments.
  3) Replacing that horribly ugly ini Extension icon.

I originally lost interest, but at Robert's request, I have polished up my branch and stabilized it. You can try it out here:

A sample ini file that the plugin can load and save (mostly) verbatim:
Code: [Select]
; Comments can appear above sections.
test = hi ;..also after vars
test2 = " hi "

;Var quote
test3 = " hi " ;quotes are used to preserve spaces in values.
test4 = hi ;test
test5 = hi
test6 = hi ;tset
test7 = "hi;" ;...quotes also help if the comment character is inside your value
test8 = "newvar;"

;A comment at the end of the file

Please let me know your thoughts on this. I'm still debugging weird edge cases, but once it's stable I'll prepare a pull request.
Title: Re: Ini Plugin Upgrade
Post by: Goombert on August 10, 2014, 11:53:19 pm
Yes I hate to pressure you into this sorlok, but what you have is clearly better than what is currently in the repository, eg. better than nothing. And this has also been a highly requested feature for *nix as well. I am also astonished with your progress and commits as well, you're a very good contributor and I and the project are eternally grateful.
Title: Re: Ini Plugin Upgrade
Post by: sorlok_reaves on August 11, 2014, 07:49:15 pm
I'm happy to help; I was actually going to add this eventually for another project (https://www.youtube.com/watch?v=i2jOIybusV0) anyway.

There is one issue that needs to be addressed; currently in ENIGMA, we have:
Code: [Select]
int ini_read_real(std::string section, std::string key, int defaultValue);
void ini_write_real(std::string section, std::string key, int value);

In reality, GM:S typically reads and writes floats (or maybe doubles), not ints. Hence the name, ini_read/write_real. These are globally defined in PFini.h.

If I change these to return floats, will that mess up anything in the Windows ini bindings?
Title: Re: Ini Plugin Upgrade
Post by: Goombert on August 11, 2014, 11:27:58 pm
Actually, they should maybe probably be var, does that seem more sensible? I am not sure, would be nice if Josh could weigh in.
Title: Re: Ini Plugin Upgrade
Post by: Josh @ Dreamland on August 15, 2014, 06:45:38 pm
Exciting; I like the new feature set. Though it could make the functions less efficient, so I'd be careful. Probably not an issue; INI just isn't a great format to begin with.

Anyway, no, if you know that the type is real, then using var is pointless. I don't care if you overload it for integer types and float types. I'm inclined to agree that real implies float/double. A solution that can't *break* Windows is to overload both. However, if you do have multiple overloads, you'll have to overload for const var/variant&, otherwise the call will be ambiguous.