-- DAWS_Package for DCSW
local MainVersion = "2"
local SubVersion = "3"
local Build = "2351"

-- THANKS TO (cronological order):
	-- Rider (AMVI)
	-- Grimes (ED community)
	-- MBot (ED community)
	-- xcom (ED community)
	-- Ian (ED community)
	-- vicx (ED community)
	-- Pikey (ED community)
	-- ESAC_Matador (ED community)
	-- uboats (ED community)

-- ################################################################################################################################
-- ################################################################################################################################
-- ################################################################################################################################
-- ################################################################################################################################
-- ################################################################################################################################
-- ################################################################################################################################
-- ################################################################################################################################

-- local main start variables
local Activate_SaveMission 		= true
local Activate_AIenhancement 	= true


-- local function copy
local base 						= _G
local require 					= base.require
local table 					= base.table
local math 						= base.math
local pairs 					= base.pairs
local ipairs 					= base.ipairs
local print 					= base.print
local io 						= base.io
local lfs 						= base.lfs
local os 						= base.os
local zip 						= minizip
local loadstring 				= base.loadstring
local loadlib					= base.loadlib
minizip 						= require('minizip')	

-- local check variables
local debugProcess 				= true
DAWSdebugProcess				= debugProcess -- global variable for quick on/off debug feature
mistdirectoryDP					= lfs.writedir() .. "AMVI/Common/Code/"
moddirectorySM 					= lfs.writedir() .. "AMVI/SaveMission/"
moddirectoryAE					= lfs.writedir() .. "AMVI/AIEnhancement/"
debugdirectorySM				= lfs.writedir() .. "AMVI/SaveMission/Debug/"
debugdirectoryAE				= lfs.writedir() .. "AMVI/AIEnhancement/Debug/"
missionfilesdirectoryDP 		= lfs.writedir() .. "Missions/"
logsdirectoryDP					= lfs.writedir() .. "Logs/"

-- create DAWS repository if not there
if not DAWS then
	DAWS = {}
	if debugProcess == true then
		env.info(("DAWS not found, void table created"))
	end				
end
--]]--

-- load mist if not already loaded
if not mist then
	if debugProcess == true then
		env.info(("mist not found, will load at mission start"))
	end
	
	local actiMist = function()
		if not mist then
			env.info(("DAWS: mist still not there -> loading mist"))
			dofile(lfs.writedir() .. "AMVI/Common/Code/" .. "mist.lua")
			if debugProcess == true then
				env.info(("mist loaded"))
			end
		end
	end
	timer.scheduleFunction(actiMist, {}, timer.getTime() + 0.01)   --   
	
end		
--]]--

-- add options code
dofile(lfs.writedir().."Config/".."options.lua")
CreateStaticsDP 					= options["plugins"]["AMVI"]["CreateStatics"]
HiddenStaticsDP 					= options["plugins"]["AMVI"]["HiddenStatics"]
MapObjectPersitenceDP 				= options["plugins"]["AMVI"]["MapObjectPersitence"]
KeepGroupsRoutesDP 					= options["plugins"]["AMVI"]["KeepGroupsRoutes"]
AirUnitTrackedDP 					= options["plugins"]["AMVI"]["AirUnitTracked"]
TrackAddedGroupsDP 					= options["plugins"]["AMVI"]["TrackAddedGroups"]
TrackAddedInfantryDP 				= options["plugins"]["AMVI"]["TrackAddedInfantry"]
timer_optionsDP 					= options["plugins"]["AMVI"]["timer_options"]  -- 1 is KeepContinousMission, 2 is UpdateSceneryDate
theMessageStateDP 					= options["plugins"]["AMVI"]["theMessageState"]
RadioMenuVariableDP 				= options["plugins"]["AMVI"]["RadioMenuVariable"]
RadioMenuSingleGroupDP				= options["plugins"]["AMVI"]["RadioMenuSingleGroup"]
AutoSaveEnableDP 					= options["plugins"]["AMVI"]["AutoSaveEnable"]
--UseFixedPathDP 						= options["plugins"]["AMVI"]["UseFixedPath"]
AIEsuppressionDP					= options["plugins"]["AMVI"]["AIEsuppression"]	
--AIEvehicledamageDP 					= options["plugins"]["AMVI"]["AIEvehicledamage"]
--AIEinfantryCarrierDP 				= options["plugins"]["AMVI"]["AIEinfantryCarrier"]
--AIEinfantryCarrierPercDP			= options["plugins"]["AMVI"]["AIEinfantryCarrierPerc"]
AIEautoartilleryDP 					= options["plugins"]["AMVI"]["AIEautoartillery"]
--AIEbaseIADSDP 						= options["plugins"]["AMVI"]["AIEbaseIADS"]	
AIElogisticDP 						= options["plugins"]["AMVI"]["AIElogistic"]
KeepContinousMissionDP 				= nil
UpdateSceneryDateDP					= nil
FixedPathDP							= nil		

-- adjust options multiple values
if timer_optionsDP == 1 then -- timer_options == "default" or 
	KeepContinousMissionDP = true
	UpdateSceneryDateDP = false
	DAWS_SM_TimerSetting = "KeepContinousMission"
else
	KeepContinousMissionDP = false
	UpdateSceneryDateDP = true
	DAWS_SM_TimerSetting = "UpdateSceneryDate"
end
--]]--

env.info(("DAWS mission time is: " .. timer.getAbsTime()))

if DAWS then

	if Activate_SaveMission == true then
		if debugProcess == true then
			env.info(("DAWS: loading Save Mission"))
		end

		dofile(moddirectorySM .. "DAWS_saveMission.lua")
	
		if debugProcess == true then
			env.info(("DAWS: Save Mission load done"))
		end
	end
	
	if Activate_AIenhancement == true then
		if debugProcess == true then
			env.info(("DAWS: loading AI enhancement"))
		end						

		dofile(moddirectoryAE .. "DAWS_AIenhancement.lua")

		if debugProcess == true then
			env.info(("DAWS: AI enhancement load done"))
		end
	end
end

env.info(("DAWS Package version: " .. MainVersion .. "." .. SubVersion .. "." .. Build .. " loaded"))
	
	
	
	
	
	
	
	
	
	
	
	