Sign in to follow this  
n4gix

Prepar3D v3 - Configuration Files for Add-on Developers

Recommended Posts

NOTE: The following is likely of interest only to add-on developers, freeware or payware.
 
As many (most) of us now know, P3D v3 has set up an system of configuration files where they encourage us to place our add-on products.
 
Moreover, they have even provided command line parameters we can use to automatically add our new paths to these various configuration files! Sweet!
 
Unfortunately, the SDK documentation is just as opaque as any such has ever been... clear.png:fool:
 
Since I had to do this anyway, I've put together a simple batch (.bat) file that will do all the work for you. All anyone needs to do is edit this file to update the drive letter, path, title, etc. to suit their own needs.
 
This batch file will first make backup copies of these config files:
  • simobjects.cfg
  • effects.cfg
  • fonts.cfg
  • gauges.cfg
  • sound.cfg
I suggest that this should probably be removed from the .bat file before using it in your installers. I only used them while I was testing just to verify that I had all of the parameters correct! All new entries are made at the TOP of the existing config files, so whatever is in those new folders will be seen "first" before P3D v3 looks at its default folders.
 
Here then is my batch file:
echo
:: Make backup copies of P3Dv3's .cfg files
CD \ProgramData\Lockheed Martin\Prepar3D v3
Copy simobjects.cfg  simobjects_back.cfg
Copy effects.cfg  effects_back.cfg
Copy fonts.cfg fonts_back.cfg
Copy gauges.cfg gauges_back.cfg
Copy sound.cfg sound_back.cfg
 
:: Add new path to simobjects.cfg file
CD \Program Files (x86)\Lockheed Martin\Prepar3D v3
Prepar3D.exe "-Configure: File=SimObjects, Operation=Add, Path=D:\MilvizProducts\SimObjects\Airplanes, Title=Milviz Airplanes, Required=True, Active=True"
 
:: Add new path to effects.cfg file
CD \Program Files (x86)\Lockheed Martin\Prepar3D v3
Prepar3D.exe "-Configure: File=Effects, Operation=Add, Path=D:\MilvizProducts\Effects, Title=Milviz Effects, Required=True, Active=True"
 
:: Add new path to fonts.cfg file
CD \Program Files (x86)\Lockheed Martin\Prepar3D v3
Prepar3D.exe "-Configure: File=Fonts, Operation=Add, Path=D:\MilvizProducts\Fonts, Title=Milviz Fonts, Required=True, Active=True"
 
:: Add new path to gauges.cfg file
CD \Program Files (x86)\Lockheed Martin\Prepar3D v3
Prepar3D.exe "-Configure: File=Gauges, Operation=Add, Path=D:\MilvizProducts\Gauges, Title=Milviz Gauges, Required=True, Active=True"
 
:: Add new path to sound.cfg file
CD \Program Files (x86)\Lockheed Martin\Prepar3D v3
Prepar3D.exe "-Configure: File=Sound, Operation=Add, Path=D:\MilvizProducts\Sound, Title=Milviz Sound, Required=True, Active=True"
 
pause

 

Share this post


Link to post
Help AVSIM continue to serve you!
Please donate today!

What about Texture.cfg and Scenery.cfg folder?

Some Payware Airports bring you new texture inside the Texture Root, so you have to replace it too...

Share this post


Link to post

What about Texture.cfg and Scenery.cfg folder?

Some Payware Airports bring you new texture inside the Texture Root, so you have to replace it too...

My example was aimed specifically towards aircraft developers.

 

At this time according to the P3Dv3 SDK the Scenery.cfg can NOT be handled the same way as the other .cfg files. This is described in a separate article in the SDK cleverly named: Scenery Configuration File

 

The Texture.cfg file may be added to using the same syntax as the examples I've provided in my batch file.

 

In addition, the Terrain (terrain.cfg) system supports being configured but there is not a native way of installing, uninstalling, or modifying the associated configuration file. For information on configuring terrain, please see Terrain Configuration File.

Share this post


Link to post

Fr. Bill,

 

Thanks for the post and the information you provided.  So what LM has done is to provide a quick and painless re-install provided developer's follow prescribed installation routines?  It is apparent that LM has left the door open to updating the core program without us having to perform a complete reinstall of all our addons.  I take this as a good thing as long as dev's learn the new format.

 

Regards,

 

Robert

Share this post


Link to post

Very helpful Bill.

For the benefit of others, we'll say this works as designed but, does not insure that previous addons will port with success due to individual developer techniques. :wink:

Share this post


Link to post

Playing around with a hypothetical batch file to config my Bar Harbor scenery, the user selects where to install the scenery, the batch file is included in a "Config" folder alongside the installed Scenery and Texture folders and the installer triggers it to run after copying all the files. This get's the P3D v3 path from the registry and configures the paths in the scenery.cfg and effects.cfg according to the user selected installation folder.


@echo off

:: determine if the OS is 32 bit or 64 bit and query the appropriate
:: registry key. Set the path into the variable "%p3dPath%", note the
:: path from the registry will contain a trailing slash so compose
:: commands accordingly, %p3dPath%Prepar3D.exe as opposed to %p3dPath%\Prepar3D.exe
:: which actually means "Lockheed Martin\Prepar3D v3\\Prepar3D.exe"
:: (note the double slashes, in practice they don't seem to
:: cause problems though so whatever...)


reg query HKLM\Hardware\Description\System\CentralProcessor\0 | find /i "x86" > nul
if %errorlevel% == 1 goto systemx64

:systemx86
for /f "tokens=1-2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Lockheed Martin\Prepar3D v3" /v SetupPath ^| find "REG_SZ"') do set p3dPath=%%c
goto check_path

:systemx64
for /f "tokens=1-2*" %%a in ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Lockheed Martin\Prepar3D v3" /v SetupPath ^| find "REG_SZ"') do set p3dPath=%%c



:: make sure Prepare3D.exe exists at the path found else abort

:check_path
if not exist "%p3dPath%Prepar3D.exe" goto abort



:: make backups of the existing scenery.cfg and effects.cfg but
:: only if the backup files don't already exist (don't overwrite
:: the initial backup if setup_KBHB.bat gets run more than once)

if not exist "%programdata%\Lockheed Martin\Prepar3D v3\backup_scenery.cfg.kbhb" >nul copy "%programdata%\Lockheed Martin\Prepar3D v3\scenery.cfg" "%programdata%\Lockheed Martin\Prepar3D v3\backup_scenery.cfg.kbhb"
if not exist "%programdata%\Lockheed Martin\Prepar3D v3\backup_effects.cfg.kbhb" >nul copy "%programdata%\Lockheed Martin\Prepar3D v3\effects.cfg" "%programdata%\Lockheed Martin\Prepar3D v3\backup_effects.cfg.kbhb"



:: Add the two areas to the scenery.cfg. I want the landclass
:: beneath the scenery in the scenery library so adding that first
::
:: I want the user to be able to choose where he/she installs the
:: scenery and that will determine which directory the batch file
:: runs from as well as Local= in the scenery.cfg so I use %CD%
:: (current directory) in the Path= option. First cd up two
:: levels to get out of the KBHB Bar Harbor\Config folder

cd ..\..\

"%p3dPath%Prepar3D.exe" "-Configure: File=Scenery, Operation=Add, Path=%cd%\KBHB_Landclass, Title=KBHB_Landclass, Required=False, Active=True"

"%p3dPath%Prepar3D.exe" "-Configure: File=Scenery, Operation=Add, Path=%cd%\KBHB Bar Harbor, Title=KBHB Bar Harbor, Required=False, Active=True"



:: Add the KBHB effects folder to the effects.cfg

"%p3dPath%Prepar3D.exe" "-Configure: File=Effects, Operation=Add, Path=%cd%\KBHB Bar Harbor\effects, Title=KBHB Effects, Required=False, Active=True"



:: and when support for editing the terrain.cfg is eventually added I suspect the command might look something like this

::"%p3dPath%Prepar3D.exe" "-Configure: File=Terrain, Operation=Add, AppendFile=KBHB Bar Harbor\Config\terrain_cfg_KBHB_Shorelines.txt"



:: report success for 5 seconds and get out before the user sees the abort screen

cls
echo.
echo.
echo   Bar Harbor has been successfully installed!
echo   Start Prepar3D, go to airport: KBHB and enjoy!
>nul timeout /t 5
exit



:abort
cls
echo.
echo.
echo   There was a problem finding Prepar3D in your registry. Running one of the
echo   commonly available registry repair tools may fix the problem.
echo.
echo   Press a key to abort now...
>nul pause
exit

Here's the result in the scenery.cfg, "the user" selected to install the scenery into "D:\P3Dv3 Addon Content\Addon Scenery" in this case:

[Area.161]
Title=KBHB_Landclass
Local=D:\P3Dv3 Addon Content\Addon Scenery\KBHB_Landclass
Layer=161
Active=TRUE
Required=FALSE

[Area.162]
Title=KBHB Bar Harbor
Local=D:\P3Dv3 Addon Content\Addon Scenery\KBHB Bar Harbor
Layer=162
Active=TRUE
Required=FALSE

...and the effects.cfg:

[Entry.0]
PATH=D:\P3Dv3 Addon Content\Addon Scenery\KBHB Bar Harbor\effects
TITLE=KBHB Effects
ACTIVE=true
REQUIRED=true
[Entry.1]
PATH=D:\P3Dv3 Addon Content\Effects
TITLE=SimObject Effects
ACTIVE=true
REQUIRED=true
[Entry.2]
PATH=Effects
TITLE=Default Effects
ACTIVE=true
REQUIRED=true

Jim

Share this post


Link to post

Understood now. You have to check your scenery.cfg file is heading too.

 

Thanks Jim!

Share this post


Link to post

Many thanks to Bill and Jim for sharing these helpful "worked examples" ! :smile:

 

GaryGB

Share this post


Link to post

Very cool Y'all! Jim, is that "super-user" batch coding? Does batch coding allow for input? Or does take something like VB? Chas

Share this post


Link to post

Yeah you can get (some limited) user input if you want or need it but if you mean giving the user an option of where to install the scenery, that's taken care of by the installer's browse button, then the batch file runs from the installed directory afterwards and takes care of detecting/setting the correct paths on it's own.

 

Jim

Share this post


Link to post

Jim I have w10 and there is no Lockheed Martin entry in HKLM, its only in KKCU .V3 and V2.5, and its AppPath not SetupPath...

'REG QUERY "HKCU\SOFTWARE\Lockheed Martin\Prepar3D v3" /v  AppPath' I made a .bat with both queries SetupPath in HKLM and appPath in HKCU..

 

Jorge

Share this post


Link to post

Ideally LM would set an environment variable %P3Dpath% or similar upon installation of v3 so we don't have to deal with flogging through the registry at all. Orbx did it, gmax does it...

Share this post


Link to post

and people like me with both 2.5 and 3 ... gets messy the same...

 

Jorge

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this