Exemplo n.º 1
0
        public BindableCollection <Repository> ReadRepositories(string arma3SyncPath)
        {
            BindableCollection <Repository> repositories = new BindableCollection <Repository>();

            if (!_fileAccessor.DirectoryExists(arma3SyncPath))
            {
                Logger.LogDebug("Arma3SyncService", "No valid Arma3Sync path defined, skipping reading repositories");
                return(repositories);
            }
            ;

            string[] files = _fileAccessor.GetFiles(Path.Combine(arma3SyncPath, ApplicationConfig.Arma3SyncConfigFolder));
            foreach (string file in files)
            {
                string fileName = Path.GetFileName(file);
                if (fileName != null)
                {
                    repositories.Add(new Repository
                    {
                        Name = fileName.Substring(0, fileName.IndexOf('.')),
                        Path = file
                    });
                }
            }

            Logger.LogDebug("Arma3SyncService", $"Finished reading repositories, found {repositories.Count}");

            return(repositories);
        }
Exemplo n.º 2
0
        public void Write(UserProfile profile, BindableCollection <Addon> addons, BindableCollection <LaunchParameter> parameters, LaunchSettings launchSettings)
        {
            Logger.LogDebug("ProfileService", "Writing profile to disk");

            try
            {
                ProfileFile profileFile = new ProfileFile
                {
                    Profile        = profile,
                    Addons         = addons ?? new BindableCollection <Addon>(),
                    Parameters     = parameters ?? new BindableCollection <LaunchParameter>(),
                    LaunchSettings = launchSettings ?? new LaunchSettings()
                };

                if (!_fileAccessor.DirectoryExists(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder)))
                {
                    _fileAccessor.CreateDirectory(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder));
                }

                _fileAccessor.WriteAllText(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ProfilesFolder, string.Format(ApplicationConfig.ProfileNameFormat, profile.Id)),
                                           JsonConvert.SerializeObject(profileFile, ApplicationConfig.JsonFormatting));
            }
            catch (Exception e)
            {
                Logger.LogException("ProfileService", "Error writing profile", e);
            }
        }
Exemplo n.º 3
0
        public bool SettingsExist()
        {
            var settingsExist = false;

            if (_fileAccessor.DirectoryExists(ApplicationConfig.ConfigPath))
            {
                settingsExist = _fileAccessor.FileExists(Path.Combine(ApplicationConfig.ConfigPath, ApplicationConfig.ConfigFileName));
            }

            Logger.LogDebug("SettingsService", "Checked if settings exist, result is: " + settingsExist);
            return(settingsExist);
        }
Exemplo n.º 4
0
        public void ReadMemoryAllocators(string arma3Path)
        {
            try
            {
                Logger.LogDebug("ParameterService", "Starting reading memory allocators");

                BindableCollection <ValueItem> allocators32 = new BindableCollection <ValueItem>();
                BindableCollection <ValueItem> allocators64 = new BindableCollection <ValueItem>();

                if (_fileAccessor.DirectoryExists(Path.Combine(arma3Path, ApplicationConfig.AllocatorsFolder)))
                {
                    allocators32.Add(new ValueItem("system", Resources.Strings.S_PARAMETER_MALLOC_SYSTEM));
                    allocators64.Add(new ValueItem("system", Resources.Strings.S_PARAMETER_MALLOC_SYSTEM));

                    string[] files = _fileAccessor.GetFiles(Path.Combine(arma3Path, ApplicationConfig.AllocatorsFolder), $"*{ApplicationConfig.AllocatorsPattern32}");
                    foreach (string file in files)
                    {
                        if (file.EndsWith(ApplicationConfig.AllocatorsPattern64))
                        {
                            continue;
                        }
                        var name = Path.GetFileNameWithoutExtension(file);
                        allocators32.Add(new ValueItem(name, name + " (x32)"));
                    }

                    string[] filesX64 = _fileAccessor.GetFiles(Path.Combine(arma3Path, ApplicationConfig.AllocatorsFolder), $"*{ApplicationConfig.AllocatorsPattern64}");
                    foreach (string file in filesX64)
                    {
                        var name = Path.GetFileNameWithoutExtension(file);
                        allocators64.Add(new ValueItem(name, name + " (x64)"));
                    }
                }
                else
                {
                    Logger.LogException("ParameterService", "Unable to read memory allocators, no \\Dll folder found in the game folder");
                }

                _malloc32.Values = allocators32;
                _malloc64.Values = allocators64;

                Logger.LogDebug("ParameterService", "Finished reading memory allocators");
            }
            catch (Exception e)
            {
                _malloc32.Values = new BindableCollection <ValueItem>();
                _malloc64.Values = new BindableCollection <ValueItem>();

                Logger.LogException("ParameterService", "Error reading memory allocators", e);
            }
        }