Pages: 1
Author Topic: Ini Plugin Upgrade  (34,239 Views)
Offline (Unknown gender) sorlok_reaves

Contributor
Joined: Dec 2013
Posts: 260
View profile
Posted on: August 11, 2014, 02:28:13 AM
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:
https://github.com/sorlok/enigma-dev/compare/sorlok:robust_inis

A sample ini file that the plugin can load and save (mostly) verbatim:
; Comments can appear above sections.
[somesection]
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.
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #1 Posted on: August 11, 2014, 04:53:19 AM
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.
Offline (Unknown gender) sorlok_reaves

Contributor
Joined: Dec 2013
Posts: 260
View profile
Reply #2 Posted on: August 12, 2014, 12:49:15 AM
I'm happy to help; I was actually going to add this eventually for another project anyway.

There is one issue that needs to be addressed; currently in ENIGMA, we have:
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?
Offline (Unknown gender) Goombert

Developer
Joined: Jan 2013
Posts: 2,991
View profile
Reply #3 Posted on: August 12, 2014, 04:27:58 AM
Actually, they should maybe probably be var, does that seem more sensible? I am not sure, would be nice if Josh could weigh in.
Offline (Unknown gender) Josh @ Dreamland

Prince of all Goldfish
Developer
Joined: Feb 2008
Posts: 2,950
View profile
Reply #4 Posted on: August 15, 2014, 11: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.
Pages: 1