I've worked quite extensively on this over the past days and refined my original design further. Here is the current status.
This is the definition of a settings schema for a Beatport Tag Source and needs to be stored in a *.settings file, e.g.,
Beatport by &stevehero v6#SETTINGS.settings
and will be referenced in, e.g.,
Beatport by &stevehero v6_Release Search.inc
via a new key
[Settings]=Beatport by &stevehero v6#SETTINGS.settings
to make the settings available to the WS.
{
"key": "beatport",
"title": "Beatport Settings",
"settings": [
{
"type": "string",
"key": "dateFormat",
"title": "DATE Format",
"description": "Format used for the DATE field.",
"choices": [
"YYYY-MM-DD",
"MMDD",
"DDMM"
],
"default": "YYYY-MM-DD"
},
{
"type": "string",
"key": "yearFormat",
"title": "YEAR Format",
"description": "Format used for the YEAR field.",
"choices": [
"YYYY-MM-DD",
"DD-MM-YYYY",
"YYYY"
],
"default": "YYYY-MM-DD"
},
{
"type": "bool",
"key": "genreRename",
"title": "Rename Genres",
"description": "'Progressive House' => 'House Progressive', 'Electro House' => 'House Electro', etc.",
"default": true
},
{
"type": "bool",
"key": "initialkeyAddPadding",
"title": "Add Padding to INITIALKEY",
"description": "8A => 08A, 7B => 07B, etc.",
"default": true
},
{
"type": "string",
"key": "initialkeyFormat",
"title": "INITIALKEY Format",
"description": "Format used for the INITIALKEY field.",
"choices": [
"camelot",
"musical"
],
"default": "camelot"
},
{
"type": "bool",
"key": "totaltracksAddPadding",
"title": "Add Padding to TOTALTRACKS",
"default": true
},
{
"type": "bool",
"key": "trackAddPadding",
"title": "Add Padding to TRACK",
"default": true
},
{
"type": "bool",
"key": "trackTotaltracksAppend",
"title": "Append TOTALTRACKS to TRACK",
"description": "1/10, 2/10, 3/10 etc.",
"default": true
}
]
}
To configure the settings, the user would use the dedicated menu item that is created at the end of the Tag Sources menu, separated from the actual Tag Sources. The example name Beatport by &stevehero v6#SETTINGS.settings results in a menu item SETTINGS in the Beatport by &stevehero v6 submenu.
Choosing this menu item shows a dedicated dialog that is generated based on the individual settings schema.
The actual values that are configured by the user are stored in a separate file settings.json as simple key-value pairs, e.g.,
{
"beatport": {
"dateFormat": "MMDD",
"genreRename": false
"yearFormat": "YYYY"
}
}
Note, that this settings file is used for the user settings of all Tag Sources. The individual objects use the key from the respective settings schema definition.
This ensures that you can add new configuration options with future versions of the WS without the need to ask users to copy the additions to their settings file. It would just use the default if there is no value for the added key in the settings.json file.
A dedicated function is used to access the individual settings in the WS, where the key is used to access the setting which is compared to the given value.
IfVar "key" "value"
IfNotVar "key" "value"
With the examples above, you'd use
IfVar "genreRename" "true"
...
Else
...
Endif
or
IfNotVar "dateFormat" "MMDD"
...
Else
...
Endif