Beispiel #1
0
 public void InitFromIniSection(IniSection iniSection)
 {
     UIName                   = iniSection.GetStringValue(nameof(UIName), UIName);
     UIEnabledOption          = iniSection.GetStringValue(nameof(UIEnabledOption), UIEnabledOption);
     UIDisabledOption         = iniSection.GetStringValue(nameof(UIDisabledOption), UIDisabledOption);
     DisableOptionFreeUnlock  = iniSection.GetBooleanValue(nameof(DisableOptionFreeUnlock), DisableOptionFreeUnlock);
     HideIfNotEnabledUnlocked = iniSection.GetBooleanValue(nameof(HideIfNotEnabledUnlocked), HideIfNotEnabledUnlocked);
 }
Beispiel #2
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);
        }
        /// <summary>
        /// Reads the properties of this DirectDrawWrapper from an INI section.
        /// </summary>
        /// <param name="section">The INI section.</param>
        private void Parse(IniSection section)
        {
            if (section == null)
            {
                throw new ArgumentException("Configuration for renderer '" + InternalName + "' not found!");
            }

            UIName         = section.GetStringValue("UIName", "Unnamed renderer");
            IsDxWnd        = section.GetBooleanValue("IsDxWnd", false);
            ddrawDLLPath   = section.GetStringValue("DLLName", string.Empty);
            configFileName = section.GetStringValue("ConfigFileName", string.Empty);

            filesToCopy = section.GetStringValue("AdditionalFiles", string.Empty).Split(
                new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            string[] disallowedOSs = section.GetStringValue("DisallowedOperatingSystems", string.Empty).Split(
                new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string os in disallowedOSs)
            {
                OSVersion disallowedOS = (OSVersion)Enum.Parse(typeof(OSVersion), os.Trim());
                disallowedOSList.Add(disallowedOS);
            }

            if (!string.IsNullOrEmpty(ddrawDLLPath) &&
                !File.Exists(ProgramConstants.GetBaseResourcePath() + ddrawDLLPath))
            {
                throw new FileNotFoundException("File specified in DLLPath= for renderer '" + InternalName + "' does not exist!");
            }

            if (!string.IsNullOrEmpty(configFileName) &&
                !File.Exists(ProgramConstants.GetBaseResourcePath() + configFileName))
            {
                throw new FileNotFoundException("File specified in ConfigFileName= for renderer '" + InternalName + "' does not exist!");
            }

            foreach (var file in filesToCopy)
            {
                if (!File.Exists(ProgramConstants.GetBaseResourcePath() + file))
                {
                    throw new FileNotFoundException("Additional file '" + file + "' for renderer '" + InternalName + "' does not exist!");
                }
            }
        }
Beispiel #4
0
        /// <summary>
        /// Reads the properties of this DirectDrawWrapper from an INI section.
        /// </summary>
        /// <param name="section">The INI section.</param>
        private void Parse(IniSection section)
        {
            if (section == null)
            {
                Logger.Log("DirectDrawWrapper: Configuration for renderer '" + InternalName + "' not found!");
                return;
            }

            UIName = section.GetStringValue("UIName", "Unnamed renderer");

            if (section.GetBooleanValue("IsDxWnd", false))
            {
                // For backwards compatibility with previous client versions
                WindowedModeSection       = "DxWnd";
                WindowedModeKey           = "RunInWindow";
                BorderlessWindowedModeKey = "NoWindowFrame";
            }

            WindowedModeSection                 = section.GetStringValue("WindowedModeSection", WindowedModeSection);
            WindowedModeKey                     = section.GetStringValue("WindowedModeKey", WindowedModeKey);
            BorderlessWindowedModeKey           = section.GetStringValue("BorderlessWindowedModeKey", BorderlessWindowedModeKey);
            IsBorderlessWindowedModeKeyReversed = section.GetBooleanValue("IsBorderlessWindowedModeKeyReversed",
                                                                          IsBorderlessWindowedModeKeyReversed);

            if (BorderlessWindowedModeKey != null && WindowedModeSection == null)
            {
                throw new DirectDrawWrapperConfigurationException(
                          "BorderlessWindowedModeKey= is defined for renderer" +
                          $" {InternalName} but WindowedModeSection= is not!");
            }

            Hidden             = section.GetBooleanValue("Hidden", false);
            UseQres            = section.GetBooleanValue("UseQres", UseQres);
            SingleCoreAffinity = section.GetBooleanValue("SingleCoreAffinity", SingleCoreAffinity);
            ddrawDLLPath       = section.GetStringValue("DLLName", string.Empty);
            ConfigFileName     = section.GetStringValue("ConfigFileName", string.Empty);
            resConfigFileName  = section.GetStringValue("ResConfigFileName", ConfigFileName);

            filesToCopy = section.GetStringValue("AdditionalFiles", string.Empty).Split(
                new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

            string[] disallowedOSs = section.GetStringValue("DisallowedOperatingSystems", string.Empty).Split(
                new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string os in disallowedOSs)
            {
                OSVersion disallowedOS = (OSVersion)Enum.Parse(typeof(OSVersion), os.Trim());
                disallowedOSList.Add(disallowedOS);
            }

            if (!string.IsNullOrEmpty(ddrawDLLPath) &&
                !File.Exists(ProgramConstants.GetBaseResourcePath() + ddrawDLLPath))
            {
                Logger.Log("DirectDrawWrapper: File specified in DLLPath= for renderer '" + InternalName + "' does not exist!");
            }

            if (!string.IsNullOrEmpty(resConfigFileName) &&
                !File.Exists(ProgramConstants.GetBaseResourcePath() + resConfigFileName))
            {
                Logger.Log("DirectDrawWrapper: File specified in ConfigFileName= for renderer '" + InternalName + "' does not exist!");
            }

            foreach (var file in filesToCopy)
            {
                if (!File.Exists(ProgramConstants.GetBaseResourcePath() + file))
                {
                    Logger.Log("DirectDrawWrapper: Additional file '" + file + "' for renderer '" + InternalName + "' does not exist!");
                }
            }
        }