-- region RangeConfigFunctions -- @type RangeConfig -- @field #string name Name of the range scenario. -- @field #boolean enable Enable the range scenario. -- @field #coalition.side benefit_coalition Benefit coalition. -- @field #RangeSubConfig[] subRange Table of sub range configurations. -- @type RangeSubConfig -- @field #string name Name of the sub range. -- @field #string[] groupsToSpawn Table of groups to spawn. -- @field #RangeStaticConfig[] staticsToSpawn Table of statics to spawn. -- @field #boolean holdFire Hold fire of the sub range. -- @field #boolean AI AI of the sub range. -- @field #boolean redAlert Red alert of the sub range. -- @field #RangeSubSubConfig[] subsubRange Table of sub sub range configurations. -- @type RangeSubSubConfig -- @field #string name Name of the sub sub range. -- @field #string[] groupsToSpawn Table of groups to spawn. -- @field #RangeStaticConfig[] staticsToSpawn Table of statics to spawn. -- @field #boolean holdFire Hold fire of the sub sub range. -- @field #boolean AI AI of the sub sub range. -- @field #boolean redAlert Red alert of the sub sub range. -- @type RangeStaticConfig -- @field #number rate Rate of the static. -- @field #string type Type of the static. -- @field #string category Category of the static. -- @field #number x X coordinate of the static. -- @field #number y Y coordinate of the static. -- @field #number heading Heading of the static. -- @field #coalition.side coalition Coalition of the static. -- @field #boolean dead Dead of the static. --- Parse a RANGE config Object. -- @param #JsonObject config Config object to parse -- @return #RangeConfig rangeConfigJson Parsed RANGE config object function ParseRangeConfigJson(config) local json = require('Scripts/json') local parser_name = "RANGE" -- ************************************************************************** -- enable -- ************************************************************************** local rangeConfigJson = {} if config.enable == true then rangeConfigJson = config else rangeConfigJson = { enable = false, } end Jtff_log.debug( string.format( "parsed RANGE config for %s, resulting config :\n%s", config.name or "", json:encode( rangeConfigJson, { indent = true } ) ), parser_name ) return rangeConfigJson end -- endregion RangeConfigFunctions -- region RangeFunctions -- endregion RangeFunctions -- ***************************************************************************** -- ** RANGES ** -- ********************************************************* RangesArray = {} local compteur = #RangesArray mainRadioMenuForRanges = {} for _k, _coalition in pairs(coalition.side) do mainRadioMenuForRanges[UTILS.GetCoalitionName(_coalition)] = MENU_COALITION:New(_coalition, "RANGES", MenuCoalition[UTILS.GetCoalitionName(_coalition)]) end for index, currentRangeConfigObject in ipairs(RangeConfig) do local rangeconfig = ParseRangeConfigJson(currentRangeConfigObject) if rangeconfig.enable == true then compteur = compteur + 1 Jtff_log.info( string.format( 'creation Range : %s...', rangeconfig.name ), "RANGE" ) RangesArray[compteur] = { customconfig = rangeconfig, RangeRootMenu = {}, SubRangeMenus = {}, } RangesArray[compteur].RangeRootMenu = MENU_COALITION:New( rangeconfig.benefit_coalition, rangeconfig.name , mainRadioMenuForRanges[UTILS.GetCoalitionName(rangeconfig.benefit_coalition)]) local radioMenuForRange = RangesArray[compteur].RangeRootMenu for indexsubRange, subRangeConfig in ipairs(rangeconfig.subRange) do RangesArray[compteur].SubRangeMenus[indexsubRange] = MENU_COALITION:New(rangeconfig.benefit_coalition, subRangeConfig.name, radioMenuForRange) local radioMenuSubRange = RangesArray[compteur].SubRangeMenus[indexsubRange] if (subRangeConfig.subsubRange ~= nil) then for indexSubSubRange, subsubRangeConfig in ipairs(subRangeConfig.subsubRange) do local radioMenuSubSubRange = MENU_COALITION:New(rangeconfig.benefit_coalition, subsubRangeConfig.name, radioMenuSubRange) AddSubRangeRadioMenus(radioMenuSubSubRange, rangeconfig, subsubRangeConfig) end else AddSubRangeRadioMenus(radioMenuSubRange, rangeconfig, subRangeConfig) end end AddWholeRangeCoalitionCommandMenus(radioMenuForRange, rangeconfig) end end if #RangesArray == 0 then for _k, _coalition in pairs(coalition.side) do mainRadioMenuForRanges[UTILS.GetCoalitionName(_coalition)]:Remove() end mainRadioMenuForRanges = {} end