Exemplo n.º 1
0
        /// <summary>
        /// Retrieves the configuration file location for the individual controller.
        /// If using an XInput controller, pass null.
        /// </summary>
        private void GetConfigLocation(DInputController dInputController)
        {
            // Get Configuration Details
            LoaderConfigParser.Config config = LoaderConfigParser.ParseConfig();

            // Set the device type
            ConfigType = config.DirectInputConfigType;

            // If XInput/DInput
            if (DeviceType == InputDeviceType.DirectInput)
            {
                // If InstanceGUID or ProductGUID.
                if (ConfigType == DirectInputConfigType.InstanceGUID)
                {
                    ConfigurationFileLocation = LoaderPaths.GetModLoaderConfigDirectory() + "/Controllers/Instances/" +
                                                dInputController.Information.InstanceGuid + ".json";
                }

                else if (ConfigType == DirectInputConfigType.ProductGUID)
                {
                    ConfigurationFileLocation = LoaderPaths.GetModLoaderConfigDirectory() + "/Controllers/" +
                                                PathSanitizer.ForceValidFilePath(dInputController.Information.ProductName) + ".json";
                }
            }
            else if (DeviceType == InputDeviceType.XInput)
            {
                ConfigurationFileLocation = LoaderPaths.GetModLoaderConfigDirectory() + "/Controllers/XInput/" + "Controller_" + XInputPort + ".json";
            }
        }
Exemplo n.º 2
0
        /* Get resolvers. */

        /// <summary>
        /// Retrieves a summary of all updates to be performed.
        /// </summary>
        public async Task <ModUpdateSummary> GetUpdateDetails()
        {
            if (_resolversWithUpdates == null)
            {
                var resolverManagerPairs = new List <ResolverManagerModResultPair>();
                var resolverTuples       = GetResolvers();
                foreach (var resolverTuple in resolverTuples)
                {
                    var modTuple = resolverTuple.ModTuple;
                    var version  = resolverTuple.Resolver.GetCurrentVersion();

                    // Note: Since R2R Support was added, we cannot predict which DLL will be in use. Just return the config file as main file.
                    string filePath = modTuple.Path;
                    var    metadata = new AssemblyMetadata(PathSanitizer.ForceValidFilePath(modTuple.Object.ModName), version, filePath);

                    var manager      = new UpdateManager(metadata, resolverTuple.Resolver, resolverTuple.Resolver.Extractor);
                    var updateResult = await manager.CheckForUpdatesAsync();

                    if (updateResult.CanUpdate)
                    {
                        resolverManagerPairs.Add(new ResolverManagerModResultPair(resolverTuple.Resolver, manager, updateResult, modTuple));
                    }
                    else
                    {
                        resolverTuple.Resolver.PostUpdateCallback(false);
                    }
                }

                _resolversWithUpdates = resolverManagerPairs;
                return(new ModUpdateSummary(_resolversWithUpdates));
            }

            return(new ModUpdateSummary(_resolversWithUpdates));
        }