Ejemplo n.º 1
0
 public InstalledDLCMod(string dlcFolderPath, Mod.MEGame game, Func <InstalledDLCMod, bool> deleteConfirmationCallback, Action notifyDeleted, bool modNamePrefersTPMI)
 {
     this.dlcFolderPath = dlcFolderPath;
     this.game          = game;
     DLCFolderName      = DLCFolderNameString = Path.GetFileName(dlcFolderPath);
     if (App.ThirdPartyIdentificationService[game.ToString()].TryGetValue(DLCFolderName.TrimStart('x'), out var tpmi))
     {
         ModName = tpmi.modname;
     }
     else
     {
         ModName = DLCFolderName;
     }
     parseInstalledBy(DLCFolderName.StartsWith('x'), modNamePrefersTPMI);
     this.deleteConfirmationCallback = deleteConfirmationCallback;
     this.notifyDeleted   = notifyDeleted;
     DeleteCommand        = new RelayCommand(DeleteDLCMod, CanDeleteDLCMod);
     EnableDisableCommand = new GenericCommand(ToggleDLC, CanToggleDLC);
 }
            private void ToggleDLC()
            {
                var source     = dlcFolderPath;
                var dlcdir     = Directory.GetParent(dlcFolderPath).FullName;
                var newdlcname = DLCFolderName.StartsWith(@"xDLC") ? DLCFolderName.TrimStart('x') : @"x" + DLCFolderName;
                var target     = Path.Combine(dlcdir, newdlcname);

                try
                {
                    Directory.Move(source, target);
                    DLCFolderName = newdlcname;
                    dlcFolderPath = target;
                }
                catch (Exception e)
                {
                    Log.Error(@"Unable to toggle DLC: " + e.Message);
                }
                //TriggerPropertyChangedFor(nameof(DLCFolderName));
            }
            private void ToggleDLC()
            {
                var source             = dlcFolderPath;
                var dlcdir             = Directory.GetParent(dlcFolderPath).FullName;
                var isBecomingDisabled = DLCFolderName.StartsWith(@"DLC"); //about to change to xDLC, so it's becoming disabled
                var newdlcname         = DLCFolderName.StartsWith(@"xDLC") ? DLCFolderName.TrimStart('x') : @"x" + DLCFolderName;
                var target             = Path.Combine(dlcdir, newdlcname);

                try
                {
                    Directory.Move(source, target);
                    DLCFolderName        = newdlcname;
                    dlcFolderPath        = target;
                    EnableDisableTooltip = M3L.GetString(isBecomingDisabled ? M3L.string_tooltip_enableDLC : M3L.string_tooltip_disableDLC);
                }
                catch (Exception e)
                {
                    Log.Error(@"Unable to toggle DLC: " + e.Message);
                }
                //TriggerPropertyChangedFor(nameof(DLCFolderName));
            }
 private bool CanToggleDLC() => (game == MEGame.ME3 || DLCFolderName.StartsWith('x')) && !Utilities.IsGameRunning(game);
 public void OnDLCFolderNameChanged()
 {
     dlcFolderPath = Path.Combine(Directory.GetParent(dlcFolderPath).FullName, DLCFolderName);
     parseMetaCmm(DLCFolderName.StartsWith('x'), false);
     TriggerPropertyChangedFor(nameof(TextColor));
 }