-------------------------------------------------------------------------------------------------------------------------------------------------------------
-- configuration file for the LotATC Export script
--
-- This configuration is tailored for a mission generated by DCS Retribution
-- see https://github.com/dcs-retribution/dcs-retribution
-------------------------------------------------------------------------------------------------------------------------------------------------------------

-- LotATC Export plugin - configuration
logger:info("DCSRetribution|LotATC Export plugin - configuration")

local function discoverLotAtcDrawingsPath()
    -- establish a search pattern into the following modes
    -- 1. Environment variable LOTATC_DRAWINGS_DIR, to support server exporting with auto load from LotATC
    -- 2. DCS saved games folder as configured in DCS Retribution

    local drawingEnvDir = os.getenv("LOTATC_DRAWINGS_DIR")
    if drawingEnvDir then
        return drawingEnvDir
    else
        return lfs.writedir()..[[\Mods\services\LotAtc\userdb\drawings\]]
    end
end

if dcsRetribution then
    logger:info("DCSRetribution|LotATC Export plugin - configuration dcsRetribution")

    local exportRedAA = true
    local exportBlueAA = false
    local exportSymbols = true

    -- retrieve specific options values
    if dcsRetribution.plugins then
        logger:info("DCSRetribution|LotATC Export plugin - configuration dcsRetribution.plugins")

        if dcsRetribution.plugins.lotatc then
            logger:info("DCSRetribution|LotATC Export plugin - dcsRetribution.plugins.lotatcExport")

            exportRedAA = dcsRetribution.plugins.lotatc.exportRedAA
            logger:info(string.format("DCSRetribution|LotATC Export plugin - exportRedAA = %s",tostring(exportRedAA)))

            exportBlueAA = dcsRetribution.plugins.lotatc.exportBlueAA
            logger:info(string.format("DCSRetribution|LotATC Export plugin - exportBlueAA = %s",tostring(exportBlueAA)))

            exportBlueAA = dcsRetribution.plugins.lotatc.exportSymbols
            logger:info(string.format("DCSRetribution|LotATC Export plugin - exportSymbols = %s",tostring(exportSymbols)))
        end
    end

    -- actual configuration code
    if LotAtcExportConfig then
        LotAtcExportConfig.exportRedAA = exportRedAA
        LotAtcExportConfig.exportBlueAA = exportBlueAA
        LotAtcExportConfig.exportSymbols = exportSymbols
        LotAtcExportConfig.drawingBasePath = discoverLotAtcDrawingsPath()

        LotatcExport()
    end
end
