MaKiPL / OpenVIII-monogame

Open source Final Fantasy VIII engine implementation in C# working on Windows and Linux (Android and iOS planned too!) [Monogame]
MIT License
630 stars 58 forks source link

Refactored how location of the game is aquired to a simpler version. #180

Closed FlameHorizon closed 3 years ago

FlameHorizon commented 3 years ago

Understating how FF8Dir is created

Basic information

FF8Dir is a variable which stores root directory of Final Fantasy 8 game.

Depends on the OS, different strategy will be used to get that root directory. Now, there are two supported OSes: Windows and Linux.

Windows take on finding root directory

Algorithm first checks, if GameLocation is in array of hardcoded paths defined in HardcodedGameLocationProvider. If that is not the case, game checks into registers to find game location.

If game location wasn't found in also registers, game throws DirectoryNotFoundException.

Linux take on finding root directory

In case of Linux, game just check for hardcoded paths using HardcodedGameLocationProvider. If game location wasn't found throws DirectoryNotFoundException.

Metrics

To find a path to the game game uses following classes:

Number of lines in these classes: Name Lines
GameLocation 43
WindowsGameLocationProvider 82
IGameLocationProvider 7
LinuxGameLocationProvider 25
HardcodedGameLocationProvider 42

In total of 199 lines of code.

I think I can make it simpler.