public void SetupInitialSelection(GameTarget target)
        {
            IsSelected = CheckedByDefault; //Reset
            if (Condition == AltFileCondition.COND_MANUAL)
            {
                IsSelected = CheckedByDefault;
                return;
            }
            if (Condition == AltFileCondition.COND_MANUAL)
            {
                return;
            }
            var installedDLC = MEDirectories.GetInstalledDLC(target);

            switch (Condition)
            {
            case AltFileCondition.COND_DLC_NOT_PRESENT:
                IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltFileCondition.COND_DLC_PRESENT:
                IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;
                //The following conditions don't exist right now
                //case AltFileCondition.COND_ALL_DLC_NOT_PRESENT:
                //    IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                //    break;
                //case AltFileCondition.COND_ALL_DLC_PRESENT:
                //    IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                //    break;
            }
        }
        public void SetupInitialSelection(GameTarget target)
        {
            IsSelected = false; //Reset
            if (Condition == AltDLCCondition.COND_MANUAL)
            {
                IsSelected = CheckedByDefault;
                return;
            }
            var installedDLC = MEDirectories.GetInstalledDLC(target);

            switch (Condition)
            {
            case AltDLCCondition.COND_DLC_NOT_PRESENT:
            case AltDLCCondition.COND_ANY_DLC_NOT_PRESENT:
                IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_DLC_PRESENT:
            case AltDLCCondition.COND_ANY_DLC_PRESENT:
                IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_ALL_DLC_NOT_PRESENT:
                IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_ALL_DLC_PRESENT:
                IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;
            }
        }
        public void PopulateDLCMods(Func <InstalledDLCMod, bool> deleteConfirmationCallback, Action notifyDeleted)
        {
            UIInstalledDLCMods.ClearEx();
            var dlcDir        = MEDirectories.DLCPath(this);
            var installedMods = MEDirectories.GetInstalledDLC(this).Where(x => !MEDirectories.OfficialDLC(Game).Contains(x, StringComparer.InvariantCultureIgnoreCase)).Select(x => new InstalledDLCMod(Path.Combine(dlcDir, x), Game, deleteConfirmationCallback, notifyDeleted)).ToList();

            UIInstalledDLCMods.AddRange(installedMods);
        }
示例#4
0
        public void PopulateDLCMods(bool includeDisabled, Func <InstalledDLCMod, bool> deleteConfirmationCallback = null, Action notifyDeleted = null, bool modNamePrefersTPMI = false)
        {
            var dlcDir        = MEDirectories.DLCPath(this);
            var installedMods = MEDirectories.GetInstalledDLC(this, includeDisabled).Where(x => !MEDirectories.OfficialDLC(Game).Contains(x.TrimStart('x'), StringComparer.InvariantCultureIgnoreCase));

            //Must run on UI thread
            Application.Current.Dispatcher.Invoke(delegate
            {
                UIInstalledDLCMods.ClearEx();
                UIInstalledDLCMods.AddRange(installedMods.Select(x => new InstalledDLCMod(Path.Combine(dlcDir, x), Game, deleteConfirmationCallback, notifyDeleted, modNamePrefersTPMI)).ToList().OrderBy(x => x.ModName));
            });
        }
        /// <summary>
        /// Validates this mod can install against a game target with respect to the list of RequiredDLC.
        /// </summary>
        /// <param name="gameTarget">Target to validate against</param>
        /// <returns>List of missing DLC modules, or an empty list if none</returns>
        internal List <string> ValidateRequiredModulesAreInstalled(GameTarget gameTarget)
        {
            if (gameTarget.Game != Game)
            {
                throw new Exception("Cannot validate a mod against a gametarget that is not for its game");
            }

            var requiredDLC = RequiredDLC.Select(x =>
            {
                if (Enum.TryParse(x, out ModJob.JobHeader parsedHeader) && ModJob.GetHeadersToDLCNamesMap(Game).TryGetValue(parsedHeader, out var dlcname))
                {
                    return(dlcname);
                }
                return(x);
            });
            var installedDLC = MEDirectories.GetInstalledDLC(gameTarget);

            return(requiredDLC.Except(installedDLC).ToList());
        }
        public void SetupInitialSelection(GameTarget target)
        {
            UIIsSelectable = false; //Reset
            IsSelected     = false; //Reset
            if (Condition == AltDLCCondition.COND_MANUAL)
            {
                IsSelected = CheckedByDefault;
                if (DLCRequirementsForManual != null)
                {
                    var dlc = MEDirectories.GetInstalledDLC(target);
                    UIIsSelectable = dlc.ContainsAll(DLCRequirementsForManual, StringComparer.InvariantCultureIgnoreCase);
                    CLog.Information($@" > AlternateDLC SetupInitialSelection() {FriendlyName}: UISelectable: {UIIsSelectable}, conducted DLCRequirements check.", Settings.LogModInstallation);
                }
                else //TODO: FILE LEVEL CHECKS FOR ALOV
                {
                    UIIsSelectable = true;
                }
                return;
            }
            var installedDLC = MEDirectories.GetInstalledDLC(target);

            switch (Condition)
            {
            case AltDLCCondition.COND_DLC_NOT_PRESENT:
            case AltDLCCondition.COND_ANY_DLC_NOT_PRESENT:
                IsSelected = !ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_DLC_PRESENT:
            case AltDLCCondition.COND_ANY_DLC_PRESENT:
                IsSelected = ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_ALL_DLC_NOT_PRESENT:
                IsSelected = !ConditionalDLC.Any(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_ALL_DLC_PRESENT:
                IsSelected = ConditionalDLC.All(i => installedDLC.Contains(i, StringComparer.CurrentCultureIgnoreCase));
                break;

            case AltDLCCondition.COND_SPECIFIC_SIZED_FILES:
            {
                var selected = true;
                foreach (var reqPair in RequiredSpecificFiles)
                {
                    if (selected)
                    {
                        var targetFile = Path.Combine(target.TargetPath, reqPair.Key);
                        selected &= File.Exists(targetFile) && new FileInfo(targetFile).Length == reqPair.Value;
                    }
                }

                IsSelected = selected;
            }
            break;

            case AltDLCCondition.COND_SPECIFIC_DLC_SETUP:
            {
                var selected = true;
                foreach (var condDlc in ConditionalDLC)
                {
                    if (selected)
                    {
                        bool existenceRule = condDlc.Substring(0, 1) == @"+";
                        var  dlcfoldername = condDlc.Substring(1);

                        if (existenceRule)
                        {
                            selected &= installedDLC.Contains(dlcfoldername, StringComparer.CurrentCultureIgnoreCase);
                        }
                        else
                        {
                            selected &= !installedDLC.Contains(dlcfoldername, StringComparer.CurrentCultureIgnoreCase);
                        }
                    }
                }
                IsSelected = selected;
            }
            break;
            }
            UIIsSelectable = false; //autos
                                    //IsSelected; //autos
        }