/// <summary>
        /// Loads data required by this definition.
        /// </summary>
        /// <param name="ini">INI file to load definition from.</param>
        /// <returns>True is successful, false if an error happened.</returns>
        protected override bool OnLoad(INIFile ini)
        {
            int i;

            // [Theater] section
            DCSID               = ini.GetValue <string>("Theater", "DCSID");
            DefaultMapCenter    = ini.GetValue <Coordinates>("Theater", "DefaultMapCenter");
            RequiredModules     = ini.GetValueArray <string>("Theater", "RequiredModules");
            MagneticDeclination = ini.GetValue <float>("Theater", "MagneticDeclination");

            // [Daytime] section
            DayTime = new MinMaxI[12];
            for (i = 0; i < 12; i++)
            {
                DayTime[i] = ini.GetValue <MinMaxI>("Daytime", ((Month)i).ToString());
            }

            // [Temperature] section
            Temperature = new MinMaxI[12];
            for (i = 0; i < 12; i++)
            {
                Temperature[i] = ini.GetValue <MinMaxI>("Temperature", ((Month)i).ToString());
            }

            // [Weather] section
            Weather = new DefinitionTheaterWeather[HQTools.EnumCount <Weather>() - 1]; // -1 because we don't want "Random"
            for (i = 0; i < Weather.Length; i++)
            {
                Weather[i] = new DefinitionTheaterWeather(ini, ((Weather)i).ToString());
            }

            // [Wind] section
            Wind = new DefinitionTheaterWind[HQTools.EnumCount <Wind>() - 1]; // -1 because we don't want "Auto"
            for (i = 0; i < Wind.Length; i++)
            {
                Wind[i] = new DefinitionTheaterWind(ini, ((Wind)i).ToString());
            }

            // [Airbases] section
            Airbases = new DefinitionTheaterAirbase[ini.GetTopLevelKeysInSection("Airbases").Length];
            i        = 0;
            foreach (string k in ini.GetTopLevelKeysInSection("Airbases"))
            {
                Airbases[i] = new DefinitionTheaterAirbase(ini, k); i++;
            }

            // [SpawnPoints] section
            SpawnPoints = new DefinitionTheaterSpawnPoint[ini.GetKeysInSection("SpawnPoints").Length];
            i           = 0;
            foreach (string k in ini.GetKeysInSection("SpawnPoints"))
            {
                SpawnPoints[i] = new DefinitionTheaterSpawnPoint(ini, k); i++;
            }

            ResetUsedSpawnPoints();

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// Loads all data from Library\Settings.ini
        /// </summary>
        public LibraryCommonSettings()
        {
            int i;

            using (INIFile ini = new INIFile($"{HQTools.PATH_LIBRARY}Settings.ini"))
            {
                // Default values
                DefaultCoalitionBlue  = ini.GetValue("Defaults", "Coalition.Blue", "USA");
                DefaultCoalitionRed   = ini.GetValue("Defaults", "Coalition.Red", "Russia");
                DefaultLanguage       = ini.GetValue("Defaults", "Language", "English");
                DefaultObjective      = ini.GetValue("Defaults", "Objective", "CAP");
                DefaultPlayerAircraft = ini.GetValue("Defaults", "Aircraft.Player", "Su-25T");
                DefaultPlayerFlightGroupStartLocation = ini.GetValue("Defaults", "PlayerFlightGroup.StartLocation", PlayerFlightGroupStartLocation.FromParking);
                DefaultTheater = ini.GetValue("Defaults", "Theater", "Caucasus");

                // Common media files
                SharedOggFiles = ini.GetValueArray <string>("Shared", "OggFiles");

                AirDefense = new LibraryCommonSettingsEnemyAirDefense[HQTools.EnumCount <AmountNR>() - 1]; // -1 because we don't need "Random"
                for (i = 0; i < AirDefense.Length; i++)
                {
                    AirDefense[i] = new LibraryCommonSettingsEnemyAirDefense(ini, "EnemyAirDefense", ((AmountNR)i).ToString());
                }

                AirDefenseDistance = new LibraryCommonSettingsEnemyAirDefenseDistance[HQTools.EnumCount <AirDefenseRange>()];
                for (i = 0; i < AirDefenseDistance.Length; i++)
                {
                    AirDefenseDistance[i] = new LibraryCommonSettingsEnemyAirDefenseDistance(ini, "EnemyAirDefenseDistance", ((AirDefenseRange)i).ToString());
                }

                DistanceToObjective = new LibraryCommonSettingsDistanceToObjective[HQTools.EnumCount <AmountR>() - 1]; // -1 because we don't need "Random"
                for (i = 0; i < DistanceToObjective.Length; i++)
                {
                    DistanceToObjective[i] = new LibraryCommonSettingsDistanceToObjective(ini, "DistanceToObjective", ((AmountR)i).ToString());
                }

                EnemyCAPDistance = new LibraryCommonSettingsEnemyAirDefenseDistance(ini, "CombatAirPatrols", null);
                CAPCount         = new MinMaxI[HQTools.EnumCount <AmountNR>() - 1]; // -1 because we don't need "Random"
                for (i = 0; i < CAPCount.Length; i++)
                {
                    CAPCount[i] = ini.GetValue <MinMaxI>("CombatAirPatrols", $"Count.{((AmountNR)i).ToString()}");
                }
            }
        }
Exemplo n.º 3
0
        protected override bool OnLoad(INIFile ini)
        {
            BriefingDescription = ini.GetValue <string>("Objective", "Briefing.Description");
            BriefingRemarks     = ini.GetValueArray <string>("Objective", "Briefing.Remarks");
            BriefingTask        = ini.GetValue <string>("Objective", "Briefing.Task");

            FGTasking = ini.GetValue <DCSFlightGroupTask>("Objective", "FlightGroup.Tasking");

            IncludeLua = new string[HQTools.EnumCount <ObjectiveScriptRepetition>(), HQTools.EnumCount <ObjectiveScriptScope>()][];
            foreach (ObjectiveScriptRepetition rep in HQTools.EnumValues <ObjectiveScriptRepetition>())
            {
                foreach (ObjectiveScriptScope scope in HQTools.EnumValues <ObjectiveScriptScope>())
                {
                    IncludeLua[(int)rep, (int)scope] = ini.GetValueArray <string>("Include", $"Lua.{rep}.{scope}");
                }
            }
            IncludeOgg = ini.GetValueArray <string>("Include", "Ogg");

            SpawnPointType = ini.GetValueArray <TheaterLocationSpawnPointType>("Objective", "SpawnPoint.Type");
            if (SpawnPointType.Length == 0)
            {
                SpawnPointType = new TheaterLocationSpawnPointType[] { TheaterLocationSpawnPointType.LandMedium, TheaterLocationSpawnPointType.LandLarge }
            }
            ;

            WaypointInaccuracy = ini.GetValue <MinMaxD>("Objective", "Waypoint.Inaccuracy");
            WaypointOnGround   = ini.GetValue <bool>("Objective", "Waypoint.OnGround");

            UnitGroups = new DefinitionObjectiveUnitGroup[HQTools.EnumCount <ObjectiveUnitGroupRole>()];

            foreach (ObjectiveUnitGroupRole role in HQTools.EnumValues <ObjectiveUnitGroupRole>())
            {
                UnitGroups[(int)role] = new DefinitionObjectiveUnitGroup(ini, role.ToString());
            }

            return(true);
        }
    }