Skip to content

Conversation

rwf-rr
Copy link
Owner

@rwf-rr rwf-rr commented Jan 11, 2025

This is the SettingsExporter, to be added on top of the Settings refactoring openrails#1030.

New Contrib.SettingsExporter command-line executable.

C:\Users\roger\source\repos\rwf-openrails\Program>Contrib.SettingsExporter /help

Usage: Contrib.SettingsExporter <from> <to>
  <from>     Specify the source to load settings from. It may be:
               INI  : use the default INI file OpenRails.ini.
               REG  : use the default registry key SOFTWARE\OpenRails\ORTS.
               path : a specific INI file, relative to the OpenRails main folder. Must end with ".ini".
               key  : a specific registry key, relative to the HKEY_CURRENT_USER key.
  <to>       Specify the destination to save the settings to. Similar to <from>.
  /h, /help  Show this help.

This utility reads the Settings (Options) from one location, and exports them to another location.
It creates a backup of any settings that will be overwritten. Example:
  <installfolder>\OpenRails.ini.bak
  HKEY_CURRENT_USER\SOFTWARE\OpenRails\ORTS-Backup
This utility is intended to:
- Create an INI file that has the same settings as what is in the registry.
  Example: Contrib.SettingsExporter REG INI
- Copy the settings from an INI file back into the registry, so that other installations
  use the same settings.
  Example: Contrib.SettingsExporter INI REG
- Backup the settings, before making temporary changes (and restore afterwards).
  Example: Contrib.SettingsExporter REG SOFTWARE\OpenRails-Saved\ORTS

Exporting from the Registry, when OpenRails.ini already exists.

C:\Users\roger\source\repos\rwf-openrails\Program>Contrib.SettingsExporter REG INI
Info: Loading from SOFTWARE\OpenRails\ORTS.
Info: Successfully loaded settings from HKEY_CURRENT_USER\SOFTWARE\OpenRails\ORTS.
Info: Backed up existing INI file as C:\Users\roger\source\repos\rwf-openrails\Program\OpenRails.ini.bak.
Info: Saving to C:\Users\roger\source\repos\rwf-openrails\Program\OpenRails.ini.
Info: Successfully saved to C:\Users\roger\source\repos\rwf-openrails\Program\OpenRails.ini.

The actual output includes a list of UserSettings names. These are printed by the following code in UserSettings.Save():

            foreach (var property in GetProperties())
                if (property.GetCustomAttributes(typeof(DoNotSaveAttribute), false).Length == 0)
                {
                    Console.WriteLine(property.Name, property.PropertyType);
                    Save(property.Name, property.PropertyType);
                }

I am not sure why that Console.WriteLine is there. The other settings classes don't have it.

pzgulyas and others added 30 commits December 5, 2023 20:11
… battery switch when service retention is cancelled

(usable only when the battery relay is controlled by push buttons)
… as the C# signal scripts (compatible with current scripts)
sweiland-openrails and others added 30 commits April 26, 2025 11:06
…orm: "Cancel: changes made in the 'Manually Installed' tab will not be saved, are you sure?". Saving will only be done when pressing the Ok button.
Update Mode texts now have more room for length Russian translations
Russian localization up to 2025 Jan 3-rd
…ich the route name is the same as an "Auto Installed" route, the manual name is changed by adding (1), (2) etc.
…me clashes can occur with local routes. This update renames the manual added route appending (1), (2) etc. This update does the same when automatic routes are added.
…location

Refactor settings, in prep for settings exporter
Content Manager: Add axle count, and lowest derail force
…an-text2

arranges Options > System tab for longer texts
Re-organise document storage and access
Fix a NullReferenceException in TCS scripts
Default PowerSupply script for steam locomotives
Included manual resolution of conflict in Source/ORTS.sln.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.