Daniel-Griffiths / dbfz-mod-manager

A mod manager for Dragon Ball FighterZ
MIT License
14 stars 8 forks source link

This PR refactors some code, adds a new way to save and access settings and automatically finds the Game Installation folder. #1

Closed covarianttensor closed 6 years ago

covarianttensor commented 6 years ago

I changed they way you were dealing with file paths. Now the application uses System.IO.Path.Combine to combine file paths. For Example, something like:

   string tempDir = gamePath + @"RED\Content\Paks\~mods" + @"\" + name + ".sig";

is now:

   string tempDir = System.IO.Path.Combine(new string[] { gamePath, "RED", "Content", "Paks", "~mods", name + ".sig" };

This is considered a best practice since it leaves the responsibility dealing with file system slashes to the dot NET run-time/Operating system. It also saves you from keeping track of all those annoying slashes that can cause bugs later on. This also makes your code more cross-platform friendly if you were to ever decide to run this, or some other c# application, on Mono (or something like Unity) on Linux or Mac OS X; as file system slashes are actually handled differently in those operating systems.

I've also added a new file called UserConfig.cs which contains two classes which auto-generate and auto-save user settings; settings are serialized into an auto-generated UserConfig.json file. Right now it only holds the game path, but more settings could easily be added. The application settings you were using previously is now only used to store default values for things.

I've also made Helper.cs store things like the active/inactive mod paths. These paths are dynamically generated based on the current game path. This file also contains some other useful functions, such as automatically finding the install path of the game by looking in the Windows registry for the install path of the steam client first; This is very much needed as people like me install all their games an a different hard drive than the C:\ drive. The less the user has to do manually, the better.

Hopefully, you find these changes useful and deemed worthy of accepting the pull request. If not, that's okay. Thanks for developing this useful app which I myself use to mod my copy of FighterZ. Cheers!

Daniel-Griffiths commented 6 years ago

Hi @covarianttensor,

Thank you so much for making this pull request! This is the first one I have ever had and it is really cool to see somebody contribute to something I have made. I am still new to C# so I really appreciate your explanation for the changes in the pull request.

I also really like your idea of getting the game directory by using the Steam registry, I didn't even know that was possible. The idea behind the mod manager was to make it as easy as possible for users to get started with DBZ mods, this extra feature will make it even simpler 😁.

Thanks again!