public CalculatedGameSettings(Game game) {
            _game = game;
            _supportsModding = _game.SupportsMods();
            _supportsMissions = _game.SupportsMissions();
            _supportsServers = _game.SupportsServers();
            if (_supportsModding)
                _modding = _game.Modding();

            Signatures = new string[0];
            if (!Execute.InDesignMode) {
                var collectionChanged = this.WhenAnyValue(x => x.Collection)
                    .Skip(1);
                collectionChanged
                    .Subscribe(HandleModSetSwitch);

                // TODO: Ignore out of band responses, cancel previous etc...
                collectionChanged
                    .ObserveOn(ThreadPoolScheduler.Instance)
                    .Subscribe(x => UpdateSignatures());

                this.WhenAnyValue(x => x.Server)
                    .Skip(1)
                    .Subscribe(HandleServerSwitch);

                this.WhenAnyValue(x => x.Server.Mods)
                    .Skip(1)
                    .Subscribe(HandleServerModsChanged);

                this.WhenAnyValue(x => x.Mission)
                    .Skip(1)
                    .Subscribe(HandleMissionSwitch);
            }

            _first = true;
        }
Ejemplo n.º 2
0
 protected static void ProcessSynqMods(ISupportModding modding, IContentManager modList,
                                       params GameController[] controllers)
 {
     foreach (var mod in modList.Mods.Where(x => !(x is LocalMod) && !(x is CustomRepoMod)).ToArrayLocked())
     {
         ProcessSynqMod(controllers, mod);
     }
 }
Ejemplo n.º 3
0
 public bool CompatibleWith(ISupportModding game)
 {
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     return(GameMatch(game) && BuildMatch(game));
 }
Ejemplo n.º 4
0
 public Collection(Guid id, ISupportModding game) : this(id) {
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     Game   = game;
     GameId = ((Game)game).Id;
 }
Ejemplo n.º 5
0
 public void ChangeGame(Game game)
 {
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     Game   = game.Modding();
     GameId = game.Id;
 }
Ejemplo n.º 6
0
 protected GameController(ISupportContent game)
 {
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     Game     = game;
     _modding = game as ISupportModding;
 }
Ejemplo n.º 7
0
 public void LoadSettings(ISupportModding game)
 {
     if (Name.Equals("@ace", StringComparison.InvariantCultureIgnoreCase))
     {
         var aceUserconfig = new AceUserconfig(game);
         aceUserconfig.ReadAceClientSideConfig();
         UserConfig = aceUserconfig;
     }
 }
Ejemplo n.º 8
0
 public bool GameMatch(ISupportModding game)
 {
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     return(this is LocalMod ||
            game.SupportsContent(this));
 }
Ejemplo n.º 9
0
 public ModAndSynqPathsChangedEvent(ISupportModding game, ContentPaths oldPaths, ContentPaths newPaths)
 {
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     Game     = game;
     OldPaths = oldPaths;
     NewPaths = newPaths;
 }
Ejemplo n.º 10
0
        static LocalMod CreateLocalMod(string name, IAbsoluteDirectoryPath localModPath, ISupportModding game) {
            Contract.Requires<ArgumentNullException>(name != null);
            Contract.Requires<ArgumentNullException>(game != null);

            var localMod = new LocalMod(System.Guid.Empty) {
                Name = name,
                CustomPath = localModPath
            };
            localMod.Controller.UpdateState(game);
            return localMod;
        }
Ejemplo n.º 11
0
        void UpdateItems(ISupportModding game)
        {
            var repoMods = Mods
                           .Where(x => x.GameMatch(game))
                           .ToArray();

            repoMods.ForEach(x => x.Controller.UpdateState(game));
            repoMods.SyncCollection(Items);

            CollectionItems = Collections.Where(x => !x.IsHidden && x.GameMatch(game)).ToArray();
        }
Ejemplo n.º 12
0
 public static LocalMod FromLocalModInfo(LocalModInfo info, ISupportModding game)
 {
     if (info == null)
     {
         throw new ArgumentNullException(nameof(info));
     }
     if (game == null)
     {
         throw new ArgumentNullException(nameof(game));
     }
     return(CreateLocalMod(info.Name, info.Path, game));
 }
Ejemplo n.º 13
0
 public void UpdateSynqState(ISupportModding game, PackageItem package) {
     Contract.Requires<ArgumentNullException>(package != null);
     _package = package;
     SetSharedState(game);
     _isValidSixSync = false;
     _isValidSixSyncPack = false;
     _sixSyncRepoExists = false;
     _sixSyncVersionInfo = null;
     _package.UpdateCurrentVersion();
     Revision = GetSynqRevision();
     DesiredRevision = GetSynqDesiredRevision();
     LatestRevision = GetSynqLatestRevision();
     State = !ModMatchesActiveGame(game) ? ContentState.Incompatible : GetSynqModState();
     //Cheat.PublishDomainEvent(new ModInfoChangedEvent(new ModInfo(_mod)));
 }
Ejemplo n.º 14
0
        // TODO: THIS NEEDS OPTIMIZATION. WE DONT WANT TO READ FROM DISK HERE, and deifnitely dont want to download!!
        // Low prio because missions are really not used that much atm...
        public IEnumerable <Mod> GetMods(ISupportModding modding, IContentManager manager)
        {
            var controller = Controller;
            var package    = controller.GetPackageIfAvailable2();

            if (package == null)
            {
                return(Enumerable.Empty <Mod>());
            }

            var mods = package.Dependencies.Keys;

            return(mods.Any()
                ? manager.GetMods(modding, mods)
                : Enumerable.Empty <Mod>());
        }
Ejemplo n.º 15
0
        public AceUserconfig(ISupportModding game)
        {
            var profiles = game as ISupportProfiles;

            if (profiles != null)
            {
                Identities = profiles.GetProfiles().ToArray();
            }

            _game       = game;
            _acedefines = new Dictionary <string, List <object> > {
                // List<object> = value, line number, internal private variable name as string to get and set it via reflection
                { "ACE_IDENTITY", new List <object> {
                      "", -1, "Identity"
                  } },
                { "ACE_CUSTOMFACE", new List <object> {
                      "", -1, "CustomFace"
                  } },
                { "ACE_COMPASS", new List <object> {
                      false, -1, "NewCompass"
                  } },
                { "ACE_RETICLES", new List <object> {
                      false, -1, "Reticles"
                  } },
                { "ACE_NOVOICE", new List <object> {
                      false, -1, "NoVoice"
                  } },
                { "ACE_NOCROSS", new List <object> {
                      false, -1, "NoCross"
                  } },
                { "ACE_MINIMALHUD", new List <object> {
                      false, -1, "MinimalHud"
                  } },
                { "ACE_DISABLE_RUCKLESS", new List <object> {
                      false, -1, "DisableRuckless"
                  } },
                { "ACE_BALLTRACERS", new List <object> {
                      false, -1, "BallTracers"
                  } },
                { "ACE_GRENADETHROW", new List <object> {
                      false, -1, "GrenadeThrow"
                  } },
                { "ACE_NODIARYSTATISTICS", new List <object> {
                      false, -1, "NoDiaryStats"
                  } }
            };
        }
Ejemplo n.º 16
0
 public void UpdateSixSyncState(ISupportModding game) {
     SetSharedState(game);
     SetSixSyncPaths();
     _sixSyncRepoExists = DoesRepoExist();
     _isValidSixSync = IsValidSixSync();
     _isValidSixSyncPack = IsPackValidSixSync();
     _sixSyncVersionInfo = _isValidSixSync ? TryReadRepoFile(_repoYamlFile) : null;
     try {
         DesiredRevision = _mod.Version;
         LatestRevision = _mod.Version;
         Guid = GetSixSyncGuid();
         Revision = GetSixSyncRevision(false);
         State = !ModMatchesActiveGame(game) ? ContentState.Incompatible : GetSixSyncModState();
     } finally {
         _sixSyncVersionInfo = null;
     }
 }
Ejemplo n.º 17
0
        public ModLibrarySetup(ModLibraryViewModel library, Game game, IContentManager contentList,
                               UserSettings settings, IEventAggregator eventBus)
        {
            if (!(game.SupportsMods()))
            {
                throw new ArgumentException("game.SupportsMods()");
            }
            _library     = library;
            _game        = game;
            _modding     = game.Modding();
            _settings    = settings;
            _eventBus    = eventBus;
            _contentList = contentList;
            OnlineGroup  = new ModLibraryGroupViewModel(library, "Repositories", "add repo",
                                                        SixIconFont.withSIX_icon_Cloud)
            {
                IsRoot = true, SortOrder = 13
            };
            LocalGroup = new ModLibraryGroupViewModel(library, "Local", "add folder",
                                                      SixIconFont.withSIX_icon_System)
            {
                IsRoot = true, SortOrder = 12
            };
            CollectionsGroup = new ModLibraryGroupViewModel(library, "Collections", "new collection",
                                                            SixIconFont.withSIX_icon_Folder)
            {
                IsRoot = true, SortOrder = 11
            };
            BuiltInGroup = new ModLibraryGroupViewModel(library, null)
            {
                IsRoot = true, SortOrder = 0
            };

            Groups = new LibraryGroupViewModel <ModLibraryViewModel>[] {
                null, BuiltInGroup, CollectionsGroup, LocalGroup,
                OnlineGroup
            };
            _aIa = new BrowseContentLibraryItemViewModel <BuiltInContentContainer>(library,
                                                                                   new BuiltInContentContainer("AllInArma"), @group: LocalGroup, isFeatured: true);

            SetupItems();
            Items.AddRange(Groups.Where(x => x != null && x != BuiltInGroup));
            CreateItemsView();
            _eventBus.Subscribe(this);
        }
Ejemplo n.º 18
0
 public void UpdateSixSyncState(ISupportModding game)
 {
     SetSharedState(game);
     SetSixSyncPaths();
     _sixSyncRepoExists  = DoesRepoExist();
     _isValidSixSync     = IsValidSixSync();
     _isValidSixSyncPack = IsPackValidSixSync();
     _sixSyncVersionInfo = _isValidSixSync ? TryReadRepoFile(_repoYamlFile) : null;
     try {
         DesiredRevision = _mod.Version;
         LatestRevision  = _mod.Version;
         Guid            = GetSixSyncGuid();
         Revision        = GetSixSyncRevision(false);
         State           = !ModMatchesActiveGame(game) ? ContentState.Incompatible : GetSixSyncModState();
     } finally {
         _sixSyncVersionInfo = null;
     }
 }
Ejemplo n.º 19
0
        public static LocalMod FromStringIfValid(string modPath, ISupportModding game) {
            Contract.Requires<ArgumentNullException>(!string.IsNullOrWhiteSpace(modPath));
            Contract.Requires<ArgumentNullException>(game != null);

            if (modPath.IsValidAbsoluteFilePath()) {
                var filePath = modPath.ToAbsoluteFilePath();
                return CreateLocalMod(filePath.FileName, filePath.ParentDirectoryPath, game);
            }

            if (modPath.IsValidAbsoluteDirectoryPath()) {
                var dirPath = modPath.ToAbsoluteDirectoryPath();
                return CreateLocalMod(dirPath.DirectoryName, dirPath.ParentDirectoryPath, game);
            }

            if (!FileNameValidator.IsValidName(modPath))
                return null;

            // TODO: Horrible non-determinism; is it a file, is it a folder, is it located in the game or mod dir?
            var modPaths = game.ModPaths;
            if (modPaths.IsValid) {
                try {
                    if (modPaths.Path.GetChildDirectoryWithName(modPath).Exists)
                        return CreateLocalMod(modPath, modPaths.Path, game);
                } catch (Exception) {}
                try {
                    if (modPaths.Path.GetChildFileWithName(modPath).Exists)
                        return CreateLocalMod(modPath, modPaths.Path, game);
                } catch (Exception) {}
            }

            var installedState = game.InstalledState;
            if (installedState.IsInstalled) {
                try {
                    if (installedState.Directory.GetChildDirectoryWithName(modPath).Exists)
                        return CreateLocalMod(modPath, installedState.Directory, game);
                } catch (Exception) {}
                try {
                    if (installedState.Directory.GetChildFileWithName(modPath).Exists)
                        return CreateLocalMod(modPath, installedState.Directory, game);
                } catch (Exception) {}
            }

            return CreateLocalMod(modPath, null, game);
        }
Ejemplo n.º 20
0
 public void UpdateSynqState(ISupportModding game, PackageItem package)
 {
     if (package == null)
     {
         throw new ArgumentNullException(nameof(package));
     }
     _package = package;
     SetSharedState(game);
     _isValidSixSync     = false;
     _isValidSixSyncPack = false;
     _sixSyncRepoExists  = false;
     _sixSyncVersionInfo = null;
     _package.UpdateCurrentVersion();
     Revision        = GetSynqRevision();
     DesiredRevision = GetSynqDesiredRevision();
     LatestRevision  = GetSynqLatestRevision();
     State           = !ModMatchesActiveGame(game) ? ContentState.Incompatible : GetSynqModState();
     //Cheat.PublishDomainEvent(new ModInfoChangedEvent(new ModInfo(_mod)));
 }
Ejemplo n.º 21
0
        public AceUserconfig(ISupportModding game) {
            var profiles = game as ISupportProfiles;
            if (profiles != null)
                Identities = profiles.GetProfiles().ToArray();

            _game = game;
            _acedefines = new Dictionary<string, List<object>> {
                // List<object> = value, line number, internal private variable name as string to get and set it via reflection
                {"ACE_IDENTITY", new List<object> {"", -1, "Identity"}},
                {"ACE_CUSTOMFACE", new List<object> {"", -1, "CustomFace"}},
                {"ACE_COMPASS", new List<object> {false, -1, "NewCompass"}},
                {"ACE_RETICLES", new List<object> {false, -1, "Reticles"}},
                {"ACE_NOVOICE", new List<object> {false, -1, "NoVoice"}},
                {"ACE_NOCROSS", new List<object> {false, -1, "NoCross"}},
                {"ACE_MINIMALHUD", new List<object> {false, -1, "MinimalHud"}},
                {"ACE_DISABLE_RUCKLESS", new List<object> {false, -1, "DisableRuckless"}},
                {"ACE_BALLTRACERS", new List<object> {false, -1, "BallTracers"}},
                {"ACE_GRENADETHROW", new List<object> {false, -1, "GrenadeThrow"}},
                {"ACE_NODIARYSTATISTICS", new List<object> {false, -1, "NoDiaryStats"}}
            };
        }
Ejemplo n.º 22
0
        public CalculatedGameSettings(Game game)
        {
            _game             = game;
            _supportsModding  = _game.SupportsMods();
            _supportsMissions = _game.SupportsMissions();
            _supportsServers  = _game.SupportsServers();
            if (_supportsModding)
            {
                _modding = _game.Modding();
            }

            Signatures = new string[0];
            if (!Execute.InDesignMode)
            {
                var collectionChanged = this.WhenAnyValue(x => x.Collection)
                                        .Skip(1);
                collectionChanged
                .Subscribe(HandleModSetSwitch);

                // TODO: Ignore out of band responses, cancel previous etc...
                collectionChanged
                .ObserveOn(ThreadPoolScheduler.Instance)
                .Subscribe(x => UpdateSignatures());

                this.WhenAnyValue(x => x.Server)
                .Skip(1)
                .Subscribe(HandleServerSwitch);

                this.WhenAnyValue(x => x.Server.Mods)
                .Skip(1)
                .Subscribe(HandleServerModsChanged);

                this.WhenAnyValue(x => x.Mission)
                .Skip(1)
                .Subscribe(HandleMissionSwitch);
            }

            _first = true;
        }
Ejemplo n.º 23
0
        // TODO: Domain events should be raised by the domain, not by the application layer,
        // however it is very difficult in the current setup to detect if modpaths were changed due to a profile change or due to a settings change...
        void HandleNewModPaths(ISupportModding game, ContentPaths newPaths, ContentPaths oldPaths)
        {
            if (!newPaths.IsValid || !oldPaths.IsValid)
            {
                return;
            }

            if (!oldPaths.EqualPath(newPaths))
            {
                if (!oldPaths.EqualRepositoryPath(newPaths))
                {
                    Cheat.PublishDomainEvent(new ModAndSynqPathsChangedEvent(game, oldPaths, newPaths));
                }
                else
                {
                    Cheat.PublishDomainEvent(new ModPathChangedEvent(game, oldPaths, newPaths));
                }
            }
            else if (!oldPaths.EqualRepositoryPath(newPaths))
            {
                Cheat.PublishDomainEvent(new SynqPathChangedEvent(game, oldPaths, newPaths));
            }
        }
Ejemplo n.º 24
0
 void SetPaths(ISupportModding game)
 {
     _rootPath = GetModRootPath(game);
     Path      = _rootPath != null?_rootPath.GetChildDirectoryWithName(_mod.Name) : null;
 }
Ejemplo n.º 25
0
 protected AdvancedCollection(Guid id, ISupportModding game) : base(id, game) {}
Ejemplo n.º 26
0
 protected GameController(ISupportContent game) {
     Contract.Requires<ArgumentNullException>(game != null);
     Game = game;
     _modding = game as ISupportModding;
 }
Ejemplo n.º 27
0
        public static LocalMod FromStringIfValid(string modPath, ISupportModding game)
        {
            if (!(!string.IsNullOrWhiteSpace(modPath)))
            {
                throw new ArgumentNullException("!string.IsNullOrWhiteSpace(modPath)");
            }
            if (game == null)
            {
                throw new ArgumentNullException(nameof(game));
            }

            if (modPath.IsValidAbsoluteFilePath())
            {
                var filePath = modPath.ToAbsoluteFilePath();
                return(CreateLocalMod(filePath.FileName, filePath.ParentDirectoryPath, game));
            }

            if (modPath.IsValidAbsoluteDirectoryPath())
            {
                var dirPath = modPath.ToAbsoluteDirectoryPath();
                return(CreateLocalMod(dirPath.DirectoryName, dirPath.ParentDirectoryPath, game));
            }

            if (!FileNameValidator.IsValidName(modPath))
            {
                return(null);
            }

            // TODO: Horrible non-determinism; is it a file, is it a folder, is it located in the game or mod dir?
            var modPaths = game.ModPaths;

            if (modPaths.IsValid)
            {
                try {
                    if (modPaths.Path.GetChildDirectoryWithName(modPath).Exists)
                    {
                        return(CreateLocalMod(modPath, modPaths.Path, game));
                    }
                } catch (Exception) {}
                try {
                    if (modPaths.Path.GetChildFileWithName(modPath).Exists)
                    {
                        return(CreateLocalMod(modPath, modPaths.Path, game));
                    }
                } catch (Exception) {}
            }

            var installedState = game.InstalledState;

            if (installedState.IsInstalled)
            {
                try {
                    if (installedState.Directory.GetChildDirectoryWithName(modPath).Exists)
                    {
                        return(CreateLocalMod(modPath, installedState.Directory, game));
                    }
                } catch (Exception) {}
                try {
                    if (installedState.Directory.GetChildFileWithName(modPath).Exists)
                    {
                        return(CreateLocalMod(modPath, installedState.Directory, game));
                    }
                } catch (Exception) {}
            }

            return(CreateLocalMod(modPath, null, game));
        }
Ejemplo n.º 28
0
 IAbsoluteDirectoryPath GetModRootPath(ISupportModding game) => _mod.CustomPath ?? game.ModPaths.Path;
Ejemplo n.º 29
0
 public SubscribedCollection(Guid collectionID, Guid subscribedAccountId, ISupportModding game)
     : base(Guid.NewGuid(), game) {
     _collectionID = collectionID;
     _subscribedAccountId = subscribedAccountId;
 }
Ejemplo n.º 30
0
 IMod CreateLocalMod(LocalModInfo lm, ISupportModding game) => Game.Lists.Mods.FirstOrDefault(y => y.Name.Equals(lm.Name, StringComparison.OrdinalIgnoreCase))
 ?? Game.Lists.Mods.FirstOrDefault(y => y.Aliases.Contains(lm.Name, StringComparer.OrdinalIgnoreCase))
 ?? LocalMod.FromLocalModInfo(lm, game);
Ejemplo n.º 31
0
 public void UpdateState(ISupportModding game)
 {
     Game = game;
     UpdateState();
 }
Ejemplo n.º 32
0
 void SetSharedState(ISupportModding game) {
     SetPaths(game);
     SetExistsState();
 }
Ejemplo n.º 33
0
 public BuiltInCollection(ISupportModding game) : base(Guid.Empty, game)
 {
 }
Ejemplo n.º 34
0
 public CustomCollection(Guid id, ISupportModding game) : base(id, game)
 {
 }
Ejemplo n.º 35
0
 public bool GameMatch(ISupportModding game) => GameMatch((Game)game);
Ejemplo n.º 36
0
 void SetPaths(ISupportModding game) {
     _rootPath = GetModRootPath(game);
     Path = _rootPath != null ? _rootPath.GetChildDirectoryWithName(_mod.Name) : null;
 }
Ejemplo n.º 37
0
 bool ModMatchesActiveGame(ISupportModding game) => game != null && _mod.GameMatch(game);
Ejemplo n.º 38
0
        static LocalMod CreateLocalMod(string name, IAbsoluteDirectoryPath localModPath, ISupportModding game)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (game == null)
            {
                throw new ArgumentNullException(nameof(game));
            }

            var localMod = new LocalMod(System.Guid.Empty)
            {
                Name       = name,
                CustomPath = localModPath
            };

            localMod.Controller.UpdateState(game);
            return(localMod);
        }
Ejemplo n.º 39
0
 IAbsoluteDirectoryPath GetModRootPath(ISupportModding game) => _mod.CustomPath ?? game.ModPaths.Path;
Ejemplo n.º 40
0
 public static LocalMod FromLocalModInfo(LocalModInfo info, ISupportModding game) {
     Contract.Requires<ArgumentNullException>(info != null);
     Contract.Requires<ArgumentNullException>(game != null);
     return CreateLocalMod(info.Name, info.Path, game);
 }
Ejemplo n.º 41
0
 public void UpdateLocalModState(ISupportModding game) {
     _package = null;
     SetSharedState(game);
 }
Ejemplo n.º 42
0
 public void UpdateLocalModState(ISupportModding game)
 {
     _package = null;
     SetSharedState(game);
 }
Ejemplo n.º 43
0
 public void UpdateState(ISupportModding game) {
     Game = game;
     UpdateState();
 }
Ejemplo n.º 44
0
 public void Reset(IContentManager contentList, ISupportModding game)
 {
     UpdateModSets(contentList);
     UpdateMods(contentList.Mods);
     UpdateItems(game);
 }
Ejemplo n.º 45
0
 bool ModMatchesActiveGame(ISupportModding game) => game != null && _mod.GameMatch(game);
Ejemplo n.º 46
0
 protected AdvancedCollection(Guid id, ISupportModding game) : base(id, game)
 {
 }