Dolphin, the GameCube and Wii emulator - Forums

Full Version: Code suggestion for android ini files
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
Not sure the official channel on how to suggest these changes, so I thought I would add it here.
I noticed that on Android the ini files are written kind of randomly.  The section headers are in reverse order, especially the WiimodeNew.ini, and the entries in the section are random.

I found the code that writes this:
In the Android\app\src\main\java\org\dolphinemu\dolphinemu\utils\SettingsFile.java file, under the saveFile function:

Code:
Set<String> keySet = sections.keySet();

for (String key : keySet)
{
SettingSection section = sections.get(key);
writeSection(writer, section);
}

I found adding in a TreeSet and looping on it instead sorts the section headers:

Code:
Set<String> keySet = sections.keySet();
[b]Set<String> sortedKeySet = new TreeSet<>(keySet);[/b]

[b]for (String key : sortedKeySet)[/b]
{
SettingSection section = sections.get(key);
writeSection(writer, section);
}

Also in the same file, the writeSection, the existing code just adds them to the file in the order they are in:

Code:
HashMap<String, Setting> settings = section.getSettings();
Set<String> keySet = settings.keySet();
 

for (String key : keySet)
{
Setting setting = settings.get(key);
String settingString = settingAsString(setting);

writer.println(settingString);
}

Adding in the same Treeset and itterating over it sorts all the entries in the list:

Code:
HashMap<String, Setting> settings = section.getSettings();
Set<String> keySet = settings.keySet();
       [b]Set<String> sortedKeySet = new TreeSet<>(keySet);[/b]


       [b]for (String key : sortedKeySet)[/b]
{
Setting setting = settings.get(key);
String settingString = settingAsString(setting);

writer.println(settingString);
}

It was a matter of adding in 2 lines and editing 2 for loops to use it.
This really helps in terms of looking for options in a file.

If there is an official way to request a feature like this with code example, please let me know.

Thanks,
Nathan
If you have working code for it, feel free to submit it at https://github.com/dolphin-emu/dolphin/pulls.
(02-16-2017, 05:26 PM)JosJuice Wrote: [ -> ]If you have working code for it, feel free to submit it at https://github.com/dolphin-emu/dolphin/pulls.

OK, I know I probably did a developer faux pas, but I pulled my project source from a clone the master instead of creating a fork, but I do know better than to just check into master.  I wasn't sure of the process since most of my projects are with small groups and we base off of master. I can save off my changes, create and re-base from a fork.  I didn't find any documentation on that part of the setup on getting started with the project.  Please let me know if that is the correct procedure.

Thanks,
Nathan
Whether you've done your work in your local master branch doesn't matter to us, since it isn't our master branch (but maybe it would be annoying to you if you want to use your local master branch for something else while the pull request is open). If you want to, you can copy over your changes to a different branch before you create a pull request, but it's not required. Just keep in mind that once the pull request is created, you can't change which branch the pull request uses.

If you haven't created a fork on GitHub yet, I think you'll need to do so. But it should be possible to push your existing changes to that fork repo instead of recreating them.

I'm not sure if I completely understand what you have done and haven't done this far, so please tell me if anything is unclear.
(02-17-2017, 01:51 AM)JosJuice Wrote: [ -> ]Whether you've done your work in your local master branch doesn't matter to us, since it isn't our master branch (but maybe it would be annoying to you if you want to use your local master branch for something else while the pull request is open). If you want to, you can copy over your changes to a different branch before you create a pull request, but it's not required. Just keep in mind that once the pull request is created, you can't change which branch the pull request uses.

If you haven't created a fork on GitHub yet, I think you'll need to do so. But it should be possible to push your existing changes to that fork repo instead of recreating them.

I'm not sure if I completely understand what you have done and haven't done this far, so please tell me if anything is unclear.

Thank you for the help, I created a fork, re-based it, put in my change for the sort and created a pull request:
Android: Sort configuration ini files #4918
(02-17-2017, 02:50 AM)nitro001 Wrote: [ -> ]Thank you for the help, I created a fork, re-based it, put in my change for the sort and created a pull request:
Android: Sort configuration ini files #4918
Corrected the re-case and consolidated commit files into new pull request:
Android: Sort configuration ini files #4919
Hey Nitro, it may be easier for you to communicate with us on IRC

freenode - #dolphin-dev