albar965 / littlenavmap

Little Navmap is a free flight planner, navigation tool, moving map, airport search and airport information system for Flight Simulator X, Microsoft Flight Simulator 2020, Prepar3D and X-Plane.
https://albar965.github.io/littlenavmap.html
GNU General Public License v3.0
1.24k stars 162 forks source link

Read MSFS2020 Scenery Library #542

Closed albar965 closed 3 years ago

albar965 commented 3 years ago

Detect, traverse and read MSFS scenery. Adapt LNM to BGL file changes.

Paths

Default simulator location MS installer: C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg.opt

Default simulator location Steam installer: C:\Users\USER\AppData\Roaming\Microsoft Flight Simulator\UserCfg.opt

Get package path from there (example with default MS path): InstalledPackagesPath "C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages"

Content (not used in Little Navmap): C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Content.xml

Add-ons: C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community

Default scenery files for additional airports (no airport information): C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Official\OneStore\asobo-airport-eidl-donegal\scenery

Airports C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Official\OneStore\fs-base\scenery\0000\APX00070.bgl Airport name, city, state and country is localized and can be found in en-US.locPak for example.

Navdata C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Official\OneStore\fs-base-nav\scenery\0000\ATX00000.bgl

Approach to read scenery library

Read UserCfg.opt which is supposedly always in the same location: C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\UserCfg.opt

Get package path from there: InstalledPackagesPath "C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages"

Iterate over C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Official\OneStore and read read packages with name fs-base and fs-base-nav.

Read manifest.json and check for "content_type": "CORE" or "content_type": "SCENERY". Then read layout.json and iterate over paths: "path": "scenery/0000/ATX00000.bgl",

Then read add-on packages as above from C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages\Community

FSX/P3D/MSFS filename prefixes:

nabeelio commented 3 years ago

Hey, thanks for starting to look into some of this. I'm very interested and am also trying to figure out the paths for an app I've got; your project has been super helpful.

I've moved my scenery library to a different drive through the installer (the Packages/Official and Packages/Community paths. The path to those doesn't seem to be reflected in the registry key/settings. In fact, I can't find a reference anywhere. I don't have read permissions for C:\Program Files\WindowsApps even.

Edit: Looking at C:\Users\Nabeel\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache, in the UserCfg.opt file (ugh, I wish this was a proper json format), however at the bottom there is this:

InstalledPackagesPath "F:\Program Files\Microsoft Flight\Install"

I wonder if you have that and which path that may refer to, absolute or relative. My C:\...\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages directory is empty (presumably because it's moved)

albar965 commented 3 years ago

Hi @nabeelio Good catch. I searched through the registry and found plenty of more or less obscure references including the one I mentioned above.

UserCfg.opt says here InstalledPackagesPath "C:\Users\alex\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache\Packages"

So, did I get this right: Moving the path actually relocates only the Packages folder and C:\Users\USERNAME\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalCache remains where it is?

Unfortunatley I installed in the default. Probably have to dig out another computer for testing.

nabeelio commented 3 years ago

I'm going to see if I can install it in a VM and try to move that folder around. But I don't think so, it at least seems to follow P3D where the main configs remain in LocalAppData. .NET gives me the path to that so hopefully the IDs remain fixed.

albar965 commented 3 years ago

Sounds good. At least one place to start. I'd not try to install it in a VM. It probably refuses due to missing DX11 support anyway. Not even talking about ages to download and space consumption. 🙁

nabeelio commented 3 years ago

Looks like the Steam edition is located in AppData\Local\Packages\ Microsoft.FlightDashboard_8wekyb3d8bbwe

albar965 commented 3 years ago

That's the default path. Hmmm... maybe we should ask here: https://www.fsdeveloper.com/forum/forums/msfs2020.155/ or here https://forums.flightsimulator.com/c/self-service/sdk-discussion/164 . I'm digging through the BGL changes for now. A lot has changed. For now I can read the airports and runways (partially).

Bpendragon commented 3 years ago

Based on my experience at least for a steam install where the package location was changed, there is nothing at C:\Users\USER\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe The folder itself doesn't even exist.

However, it would appear that the UserConfig.opt and Content.xml are both located in AppData\Roaming\Microsoft Flight Simulator in my case (note roaming, not local)

albar965 commented 3 years ago

Thanks for the information. What a mess. 🙁

Bpendragon commented 3 years ago

What a mess. 🙁

Yeah, I've conversed with some friends that have the Windows Store Version. It appears that when it comes down to it relevant information will either be in Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe or Roaming\Microsoft Flight Simulator

At the very least it's just two paths to check, and it also appears (but I cannot guarantee) That you can check if the Local folder exists, and if not, jump over to the Roaming folder.

albar965 commented 3 years ago

Updated installation locations above.

albar965 commented 3 years ago

Good enough for now. #548 might follow in a minor update after the relase or during the beta cycle.