Exemple #1
0
        public Mission(IniSection iniSection, bool isCampaignMission)
        {
            InternalName = iniSection.SectionName;
            Side         = iniSection.GetIntValue(nameof(Side), 0);
            Scenario     = iniSection.GetStringValue(nameof(Scenario), string.Empty);
            GUIName      = iniSection.GetStringValue("Description", "Undefined mission");
            if (iniSection.KeyExists("UIName"))
            {
                GUIName = iniSection.GetStringValue("UIName", GUIName);
            }

            IconPath         = iniSection.GetStringValue(nameof(IconPath), string.Empty);
            GUIDescription   = iniSection.GetStringValue("LongDescription", string.Empty);
            PreviewImagePath = iniSection.GetStringValue(nameof(PreviewImagePath), string.Empty);
            RequiredAddon    = iniSection.GetBooleanValue(nameof(RequiredAddon), false);
            Enabled          = iniSection.GetBooleanValue(nameof(Enabled), true);
            BuildOffAlly     = iniSection.GetBooleanValue(nameof(BuildOffAlly), false);
            WarnOnHardWithoutMediumPlayed  = iniSection.GetBooleanValue(nameof(WarnOnHardWithoutMediumPlayed), WarnOnHardWithoutMediumPlayed);
            PlayerAlwaysOnNormalDifficulty = iniSection.GetBooleanValue(nameof(PlayerAlwaysOnNormalDifficulty), false);

            if (iniSection.KeyExists("DifficultyLabels"))
            {
                DifficultyLabels = iniSection.GetListValue("DifficultyLabels", ',', s => s).ToArray();

                if (DifficultyLabels.Length != DifficultyLabelCount)
                {
                    throw new NotSupportedException($"Invalid number of DifficultyLabels= specified for mission { InternalName }: " +
                                                    $"{DifficultyLabels.Length}, expected {DifficultyLabelCount}");
                }
            }

            CampaignInternalName  = iniSection.GetStringValue(nameof(CampaignInternalName), null);
            RequiresUnlocking     = iniSection.GetBooleanValue(nameof(RequiresUnlocking), isCampaignMission);
            UnlockMissions        = iniSection.GetStringValue(nameof(UnlockMissions), string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            UsedGlobalVariables   = iniSection.GetStringValue(nameof(UsedGlobalVariables), string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            UnlockGlobalVariables = iniSection.GetStringValue(nameof(UnlockGlobalVariables), string.Empty).Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            // Parse conditional mission unlocks
            int i = 0;

            while (true)
            {
                string conditionalMissionUnlockData = iniSection.GetStringValue("ConditionalMissionUnlock" + i, null);
                if (string.IsNullOrWhiteSpace(conditionalMissionUnlockData))
                {
                    break;
                }

                var conditionalMissionUnlock = ConditionalMissionUnlock.FromString(conditionalMissionUnlockData);
                if (conditionalMissionUnlock != null)
                {
                    ConditionalMissionUnlocks.Add(conditionalMissionUnlock);
                }

                i++;
            }

            GUIDescription = GUIDescription.Replace("@", Environment.NewLine);
        }
Exemple #2
0
        public Mission(IniFile iniFile, string sectionName)
        {
            CD             = iniFile.GetIntValue(sectionName, "CD", 0);
            Side           = iniFile.GetIntValue(sectionName, "Side", 0);
            Scenario       = iniFile.GetStringValue(sectionName, "Scenario", string.Empty);
            GUIName        = iniFile.GetStringValue(sectionName, "Description", "Undefined mission");
            IconPath       = iniFile.GetStringValue(sectionName, "SideName", string.Empty);
            GUIDescription = iniFile.GetStringValue(sectionName, "LongDescription", string.Empty);
            FinalMovie     = iniFile.GetStringValue(sectionName, "FinalMovie", "none");
            RequiredAddon  = iniFile.GetBooleanValue(sectionName, "RequiredAddon", false);
            Enabled        = iniFile.GetBooleanValue(sectionName, "Enabled", true);
            BuildOffAlly   = iniFile.GetBooleanValue(sectionName, "BuildOffAlly", false);

            GUIDescription = GUIDescription.Replace("@", Environment.NewLine);
        }
        public Mission(IniFile iniFile, string sectionName)
        {
            CD             = iniFile.GetIntValue(sectionName, nameof(CD), 0);
            Side           = iniFile.GetIntValue(sectionName, nameof(Side), 0);
            Scenario       = iniFile.GetStringValue(sectionName, nameof(Scenario), string.Empty);
            GUIName        = iniFile.GetStringValue(sectionName, "Description", "Undefined mission");
            IconPath       = iniFile.GetStringValue(sectionName, "SideName", string.Empty);
            GUIDescription = iniFile.GetStringValue(sectionName, "LongDescription", string.Empty);
            FinalMovie     = iniFile.GetStringValue(sectionName, nameof(FinalMovie), "none");
            RequiredAddon  = iniFile.GetBooleanValue(sectionName, nameof(RequiredAddon), false);
            Enabled        = iniFile.GetBooleanValue(sectionName, nameof(Enabled), true);
            BuildOffAlly   = iniFile.GetBooleanValue(sectionName, nameof(BuildOffAlly), false);
            PlayerAlwaysOnNormalDifficulty = iniFile.GetBooleanValue(sectionName, nameof(PlayerAlwaysOnNormalDifficulty), false);

            GUIDescription = GUIDescription.Replace("@", Environment.NewLine);
        }