There's a way to do that, but it was added fairly recently for the internal Text plugin and is undocumented. (All the published plugin code uses the more complex config API for anything with optional values.)
This only works in Opus 12.7 and above, so make sure you test the Opus version number:
#define MAKE64BITVERSIONNUMBER(a,b,c,d) ((((DWORD64)(a))<<48) + (((DWORD64)(b))<<32) + (((DWORD64)(c))<<16) + (((DWORD64)(d))<<00))
BOOL DVP_InitEx(LPDVPINITEXDATA pInitExData)
{
DWORD64 opusVersion = pInitExData->dwOpusVerMajor;
opusVersion <<= 32;
opusVersion += pInitExData->dwOpusVerMinor;
if (opusVersion < MAKE64BITVERSIONNUMBER(12,7,0,0))
{
return FALSE;
}
}
The published DOpusPluginConfigItemW
structure is defined like this (//
comments added for clarity):
typedef struct DOpusPluginConfigItemW
{
LPCWSTR pszName;
int iType; // 32-bit
LPVOID pData;
DWORD dwDataSize;
} DOPUSPLUGINCONFIGITEMW, * LPDOPUSPLUGINCONFIGITEMW;
In 12.7 and above, that 32-bit iType
field is interpreted as a 16-bit iValType
and a 16-bit wFlags
:
typedef struct DOpusPluginConfigItemW
{
LPCWSTR pszName;
short iValType; // 16-bit
WORD wFlags; // 16-bit
LPVOID pData;
DWORD dwDataSize;
} DOPUSPLUGINCONFIGITEMW, * LPDOPUSPLUGINCONFIGITEMW;
(Since the defined type values max out at 8 currently, wFlags
is effectively zero in all code that uses the original structure.)
The new wFlags
field has one possible flag:
#define DPCIF_LeaveDefault (1 << 0)
If that is set, whatever value you put in pData
will be left as-is if nothing exists in the XML for that item. So you can set it to the default you want before calling LoadOrSaveConfigW
and the default will be left as-is if the config file doesn't mention it.
Edit: Actually, you can probably ignore everything below, unless you're making a plugin that works with both Opus 12 and earlier versions. If it's Opus 12 and above, the new and old LOGFONT types should both do the same thing. (It only matters when Opus 12 loads configs saved by earlier versions.)
Speaking of the type values, there's also an undocumented type which lets you load font settings that include a height. This was added in 12.0 as part of the high DPI support:
// Current version - define PLUGINSUPPORTVERSION when including this file to use an older version
// Verison 1 is Opus 9
// Version 2 is Opus 10
// Version 3 is Opus 11
// Version 12000 is Opus 12.0 (first version using this easier to understand numbering format)
#ifndef PLUGINSUPPORTVERSION
#define PLUGINSUPPORTVERSION 12000
#endif
enum
{
DPCITYPE_Bool,
DPCITYPE_Int,
DPCITYPE_DWORD,
DPCITYPE_LPSTR,
DPCITYPE_LPWSTR,
DPCITYPE_Binary,
DPCITYPE_LOGFONT, // In Opus 12, when loading configs saved by earlier versions, this will always load a fixed size font. (Typically 8pt or 9pt.)
DPCITYPE_Child,
#if ( PLUGINSUPPORTVERSION >= 12000 )
DPCITYPE_LOGFONTWITHHEIGHT, // Same as DPCITYPE_LOGFONT but: If doing a Load, lfHeight must be filled in by the caller and will be used when loading configs saved before Opus 12.
#endif
};