public static void SaveCurrentEnvironment(LoadedSettings loadedSettings, ListBox environmentsListBox, EnvironmentStruct environment)
        {
            var currentEnvironment = loadedSettings.Environments.First(env => env.ID == environment.ID);

            if (environment.ID == Guid.Empty) return;

            if (currentEnvironment.Name != environment.Name)
                currentEnvironment.Name = environment.Name;
            if (currentEnvironment.SubkeyValue != environment.SubkeyValue)
                currentEnvironment.SubkeyValue = environment.SubkeyValue;
            if (currentEnvironment.HotKey != environment.HotKey)
                currentEnvironment.HotKey = environment.HotKey;
            if (currentEnvironment.IconLabel != environment.IconLabel)
                currentEnvironment.IconLabel = environment.IconLabel;
            if (currentEnvironment.IconTextColor != environment.IconTextColor)
                currentEnvironment.IconTextColor = environment.IconTextColor;
            if (currentEnvironment.IconBackgroundColor != environment.IconBackgroundColor)
                currentEnvironment.IconBackgroundColor = environment.IconBackgroundColor;
            if (currentEnvironment.LoadIcon != environment.LoadIcon)
                currentEnvironment.LoadIcon = environment.LoadIcon;
            if (currentEnvironment.IconFileLocation != environment.IconFileLocation)
                currentEnvironment.IconFileLocation = environment.IconFileLocation;
            if (currentEnvironment.DisplayOnMenu != environment.DisplayOnMenu)
                currentEnvironment.DisplayOnMenu = environment.DisplayOnMenu;

            ListboxUtils.RepopulateListBox(true, environmentsListBox, loadedSettings, environment.ID);
            ListboxUtils.SetCurrentOrderFromListBoxAndSave(true, environmentsListBox, loadedSettings);

            MessageBox.Show($"{currentEnvironment.Name} {Constants.Messages.SavedSuccessfully}",
                            $"Environment {Constants.Messages.SavedSuccessfullyCaption}",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #2
0
 public void Unregister(FluentGlobalSettings settings)
 {
     if (LoadedSettings.ContainsKey(settings.Id))
     {
         LoadedSettings.Remove(settings.Id);
     }
 }
Beispiel #3
0
        public static void SetIcon(LoadedEnvironments currentLoadedEnvironment, LoadedSettings loadedSettings, NotifyIcon icon)
        {
            if (currentLoadedEnvironment.LoadIcon &&
                File.Exists(currentLoadedEnvironment.IconFileLocation) &&
                currentLoadedEnvironment.IconFileLocation.Contains(Constants.FileExtensions.IconExtension, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    var iconFromFile = new Icon(currentLoadedEnvironment.IconFileLocation, 16, 16);
                    icon.Icon = iconFromFile;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Constants.IconMessages.ErrorLoadingIcon + ex,
                                    Constants.IconMessages.ErrorLoadingIconCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    icon.Icon = Resources.Exit_16;
                }
            }
            else
            {
                Font   font = new Font(loadedSettings.General.IconFont, loadedSettings.General.IconFontSize);
                Bitmap bmp  = new Bitmap(16, 16, PixelFormat.Format32bppRgb);
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    Rectangle rectangle = new Rectangle(0, 0, 16, 16);
                    g.FillEllipse(currentLoadedEnvironment.IconBackgroundColor.ToSolidBrush(), rectangle);
                    g.DrawString(currentLoadedEnvironment.IconLabel, font, currentLoadedEnvironment.IconTextColor.ToSolidBrush(), 0, 1);
                }

                icon.Icon = Converter.BitmapToIcon(bmp);
            }
        }
        protected override void RegisterSettings(PerCharacterSettings tSettings)
        {
            if (Game.Current?.PlayerTroop?.StringId == null)
            {
                return;
            }

            if (tSettings == null || LoadedSettings.ContainsKey(tSettings.Id))
            {
                return;
            }

            LoadedSettings.Add(tSettings.Id, tSettings);

            var path = Path.Combine(RootFolder, tSettings.CharacterId, tSettings.FolderName, tSettings.SubFolder ?? "", $"{tSettings.Id}.{tSettings.Format}");

            if (AvailableSettingsFormats.ContainsKey(tSettings.Format))
            {
                AvailableSettingsFormats[tSettings.Format].Load(tSettings, path);
            }
            else
            {
                AvailableSettingsFormats["memory"].Load(tSettings, path);
            }
        }
Beispiel #5
0
        public static void SaveNewRegistryKey(LoadedSettings loadedSettings, RegistryKeyStruct registryKey)
        {
            if (GetCurrentKeyValue(registryKey) == string.Empty) // New Key is invalid.
            {
                MessageBox.Show(Constants.RegistryKeyMessages.SelectRegistryKey,
                                Constants.RegistryKeyMessages.SelectRegistryKeyCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (CurrentKeyEqualsSavedKey(loadedSettings.MonitoredRegistryKey, registryKey)) // New Key is Old Key.
            {
                return;
            }
            else // Save New Key.
            {
                var confirmMessage = MessageBox.Show(Constants.RegistryKeyMessages.OverrideRegistryKey,
                                                     Constants.RegistryKeyMessages.OverrideRegistryKeyCaption,
                                                     MessageBoxButtons.YesNo, MessageBoxIcon.Hand);

                if (confirmMessage != DialogResult.Yes)
                {
                    return;
                }

                var newRegistryKey = new MonitoredRegistryKey
                {
                    Root   = GetCurrentRoot(registryKey),
                    Subkey = registryKey.Subkey
                };
                loadedSettings.MonitoredRegistryKey = newRegistryKey;
            }
        }
        public override bool SaveSettings(BaseSettings settings)
        {
            if (Game.Current?.PlayerTroop?.StringId == null)
            {
                return(false);
            }

            if (!(settings is PerCharacterSettings tSettings) || !LoadedSettings.ContainsKey(tSettings.Id))
            {
                return(false);
            }

            var path = Path.Combine(RootFolder, tSettings.CharacterId, tSettings.FolderName, tSettings.SubFolder ?? "", $"{tSettings.Id}.{tSettings.Format}");

            if (AvailableSettingsFormats.ContainsKey(tSettings.Format))
            {
                AvailableSettingsFormats[tSettings.Format].Save(tSettings, path);
            }
            else
            {
                AvailableSettingsFormats["memory"].Save(tSettings, path);
            }

            return(true);
        }
        public override void OnGameStarted(Game game)
        {
            LoadedSettings.Clear();

            var settings = new List <PerCharacterSettings>();
            var allTypes = AppDomain.CurrentDomain
                           .GetAssemblies()
                           .Where(a => !a.IsDynamic)
                           // ignore v1 and v2 classes
                           .Where(a => !Path.GetFileNameWithoutExtension(a.Location).StartsWith("MBOptionScreen"))
                           .SelectMany(a => a.GetTypes())
                           .Where(t => t.IsClass && !t.IsAbstract)
                           .Where(t => t.GetConstructor(Type.EmptyTypes) != null)
                           .ToList();

            var mbOptionScreenSettings = allTypes
                                         .Where(t => ReflectionUtils.ImplementsOrImplementsEquivalent(t, typeof(PerCharacterSettings)))
                                         .Where(t => !ReflectionUtils.ImplementsOrImplementsEquivalent(t, typeof(EmptyPerCharacterSettings)))
                                         .Where(t => !ReflectionUtils.ImplementsOrImplementsEquivalent(t, typeof(IWrapper)))
                                         .Select(obj => BasePerCharacterSettingsWrapper.Create(Activator.CreateInstance(obj)));

            settings.AddRange(mbOptionScreenSettings);

            foreach (var setting in settings)
            {
                RegisterSettings(setting);
            }
        }
Beispiel #8
0
        public static void RepopulateListBox(bool env, ListBox currentListBox, LoadedSettings loadedSettings, Guid currentGuid)
        {
            currentListBox.Items.Clear();

            if (env)
            {
                foreach (var key in loadedSettings.Environments)
                {
                    currentListBox.Items.Add(key.Name);
                }
            }
            else
            {
                foreach (var key in loadedSettings.Tools)
                {
                    currentListBox.Items.Add(key.Name);
                }
            }


            if (currentGuid != Guid.Empty)
            {
                return;
            }

            var currentName = env
                            ? loadedSettings.Environments.FirstOrDefault(environment => environment.ID == currentGuid)?.Name
                            : loadedSettings.Tools.FirstOrDefault(tool => tool.ID == currentGuid)?.Name;

            if (currentName != null)
            {
                currentListBox.SelectedIndex = currentListBox.Items.IndexOf(currentName);
            }
        }
Beispiel #9
0
        public static void MoveItem(int direction, bool env, ListBox currentListBox, LoadedSettings loadedSettings)
        {
            // Checking selected item
            if (currentListBox.SelectedItem == null || currentListBox.SelectedIndex < 0)
            {
                return; // No selected item - nothing to do
            }
            // Calculate new index using move direction
            int newIndex = currentListBox.SelectedIndex + direction;

            // Checking bounds of the range
            if (newIndex < 0 || newIndex >= currentListBox.Items.Count)
            {
                return; // Index out of range - nothing to do
            }
            object selected = currentListBox.SelectedItem;

            // Removing removable element
            currentListBox.Items.Remove(selected);
            // Insert it in new position
            currentListBox.Items.Insert(newIndex, selected);
            // Restore selection
            currentListBox.SetSelected(newIndex, true);
            // Save changes
            SetCurrentOrderFromListBoxAndSave(env, currentListBox, loadedSettings);
        }
 public void Unregister(FluentPerCampaignSettings settings)
 {
     if (LoadedSettings.ContainsKey(settings.Id))
     {
         LoadedSettings.Remove(settings.Id);
     }
 }
Beispiel #11
0
        public static void SetIcon(LoadedEnvironments currentLoadedEnvironment, LoadedSettings loadedSettings, NotifyIcon icon)
        {
            if (currentLoadedEnvironment.LoadIcon &&
                File.Exists(currentLoadedEnvironment.IconFileLocation) &&
                currentLoadedEnvironment.IconFileLocation.Contains(Constants.FileExtensions.IconExtension, StringComparison.OrdinalIgnoreCase))
            {
                try
                {
                    var iconFromFile = new Icon(currentLoadedEnvironment.IconFileLocation, 16, 16);
                    icon.Icon = iconFromFile;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(Constants.IconMessages.ErrorLoadingIcon + ex,
                                    Constants.IconMessages.ErrorLoadingIconCaption,
                                    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    icon.Icon = Resources.Exit_16;
                }
            }
            else
            {
                Font font = new Font(loadedSettings.General.IconFont, loadedSettings.General.IconFontSize);
                Bitmap bmp = new Bitmap(16, 16, PixelFormat.Format32bppRgb);
                using (Graphics g = Graphics.FromImage(bmp))
                {
                    Rectangle rectangle = new Rectangle(0, 0, 16, 16);
                    g.FillEllipse(currentLoadedEnvironment.IconBackgroundColor.ToSolidBrush(), rectangle);
                    g.DrawString(currentLoadedEnvironment.IconLabel, font, currentLoadedEnvironment.IconTextColor.ToSolidBrush(), 0, 1);
                }

                icon.Icon = Converter.BitmapToIcon(bmp);
            }
        }
Beispiel #12
0
        public static void SaveCurrentTool(LoadedSettings loadedSettings, ListBox toolsListBox, ToolStruct tool)
        {
            var currentTool = loadedSettings.Tools.First(t => t.ID == tool.ID);

            if (tool.ID == Guid.Empty)
            {
                return;
            }

            if (currentTool.Name != tool.Name)
            {
                currentTool.Name = tool.Name;
            }
            if (currentTool.FileLocation != tool.FileLocation)
            {
                currentTool.FileLocation = tool.FileLocation;
            }
            if (currentTool.HotKey != tool.HotKey)
            {
                currentTool.HotKey = tool.HotKey;
            }

            ListboxUtils.RepopulateListBox(false, toolsListBox, loadedSettings, tool.ID);
            ListboxUtils.SetCurrentOrderFromListBoxAndSave(false, toolsListBox, loadedSettings);

            MessageBox.Show($"{currentTool.Name} {Constants.Messages.SavedSuccessfully}",
                            $"Tool {Constants.Messages.SavedSuccessfullyCaption}",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
        public static void SetNewGlobalHotkeyIfChanged(LoadedSettings loadedSettings, LoadedGlobalHotkey loadedGlobalHotkey, HotKeyManager hkManager)
        {
            if (loadedGlobalHotkey == loadedSettings.General.LoadedGlobalHotkey) return;

            UnregisterGlobalHotkey(hkManager, loadedGlobalHotkey);
            RegisterGlobalHotkey(hkManager, loadedSettings.General.LoadedGlobalHotkey);
            loadedGlobalHotkey = loadedSettings.General.LoadedGlobalHotkey;
        }
Beispiel #14
0
        public virtual bool OverrideSettings(BaseSettings settings)
        {
            if (!(settings is TSettings tSettings) || !LoadedSettings.ContainsKey(tSettings.Id))
            {
                return(false);
            }

            SettingsUtils.OverrideSettings(LoadedSettings[tSettings.Id], tSettings);
            return(true);
        }
        public static void SetNewGlobalHotkeyIfChanged(LoadedSettings loadedSettings, LoadedGlobalHotkey loadedGlobalHotkey, HotKeyManager hkManager)
        {
            if (loadedGlobalHotkey == loadedSettings.General.LoadedGlobalHotkey)
            {
                return;
            }

            UnregisterGlobalHotkey(hkManager, loadedGlobalHotkey);
            RegisterGlobalHotkey(hkManager, loadedSettings.General.LoadedGlobalHotkey);
            loadedGlobalHotkey = loadedSettings.General.LoadedGlobalHotkey;
        }
Beispiel #16
0
 public static void RemoveListBoxItem(bool env, ListBox currentListBox, LoadedSettings loadedSettings, string currentGuid)
 {
     if (currentListBox.SelectedIndex != -1)
     {
         if (env)
         {
             var allEnvironments     = loadedSettings.Environments;
             var environmentToRemove = allEnvironments.FirstOrDefault(environment => environment.ID == Guid.Parse(currentGuid));
             if (environmentToRemove?.ID != Guid.Empty)
             {
                 allEnvironments.Remove(environmentToRemove);
                 loadedSettings.Environments = allEnvironments;
             }
             else
             {
                 MessageBox.Show(Constants.EnvironmentMessages.ErrorRetrievingEnvironment,
                                 Constants.EnvironmentMessages.ErrorRetrievingEnvironmentCaption,
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             var allTools     = loadedSettings.Tools;
             var toolToRemove = allTools.FirstOrDefault(tool => tool.ID == Guid.Parse(currentGuid));
             if (toolToRemove != null && toolToRemove.ID != Guid.Empty)
             {
                 allTools.Remove(toolToRemove);
                 loadedSettings.Tools = allTools;
             }
             else
             {
                 MessageBox.Show(Constants.ToolMessages.ErrorRetrievingTool,
                                 Constants.ToolMessages.ErrorRetrievingToolCaption,
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         if (env)
         {
             MessageBox.Show(Constants.EnvironmentMessages.SelectEnvironmentToDelete,
                             Constants.EnvironmentMessages.SelectEnvironmentToDeleteCaption,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show(Constants.ToolMessages.SelectToolToDelete,
                             Constants.ToolMessages.SelectToolToDeleteCaption,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #17
0
        public static void SaveCurrentEnvironment(LoadedSettings loadedSettings, ListBox environmentsListBox, EnvironmentStruct environment)
        {
            var currentEnvironment = loadedSettings.Environments.First(env => env.ID == environment.ID);

            if (environment.ID == Guid.Empty)
            {
                return;
            }

            if (currentEnvironment.Name != environment.Name)
            {
                currentEnvironment.Name = environment.Name;
            }
            if (currentEnvironment.SubkeyValue != environment.SubkeyValue)
            {
                currentEnvironment.SubkeyValue = environment.SubkeyValue;
            }
            if (currentEnvironment.HotKey != environment.HotKey)
            {
                currentEnvironment.HotKey = environment.HotKey;
            }
            if (currentEnvironment.IconLabel != environment.IconLabel)
            {
                currentEnvironment.IconLabel = environment.IconLabel;
            }
            if (currentEnvironment.IconTextColor != environment.IconTextColor)
            {
                currentEnvironment.IconTextColor = environment.IconTextColor;
            }
            if (currentEnvironment.IconBackgroundColor != environment.IconBackgroundColor)
            {
                currentEnvironment.IconBackgroundColor = environment.IconBackgroundColor;
            }
            if (currentEnvironment.LoadIcon != environment.LoadIcon)
            {
                currentEnvironment.LoadIcon = environment.LoadIcon;
            }
            if (currentEnvironment.IconFileLocation != environment.IconFileLocation)
            {
                currentEnvironment.IconFileLocation = environment.IconFileLocation;
            }
            if (currentEnvironment.DisplayOnMenu != environment.DisplayOnMenu)
            {
                currentEnvironment.DisplayOnMenu = environment.DisplayOnMenu;
            }

            ListboxUtils.RepopulateListBox(true, environmentsListBox, loadedSettings, environment.ID);
            ListboxUtils.SetCurrentOrderFromListBoxAndSave(true, environmentsListBox, loadedSettings);

            MessageBox.Show($"{currentEnvironment.Name} {Constants.Messages.SavedSuccessfully}",
                            $"Environment {Constants.Messages.SavedSuccessfullyCaption}",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #18
0
 public static void RemoveListBoxItem(bool env, ListBox currentListBox, LoadedSettings loadedSettings, string currentGuid)
 {
     if (currentListBox.SelectedIndex != -1)
     {
         if (env)
         {
             var allEnvironments = loadedSettings.Environments;
             var environmentToRemove = allEnvironments.FirstOrDefault(environment => environment.ID == Guid.Parse(currentGuid));
             if (environmentToRemove?.ID != Guid.Empty)
             {
                 allEnvironments.Remove(environmentToRemove);
                 loadedSettings.Environments = allEnvironments;
             }
             else
             {
                 MessageBox.Show(Constants.EnvironmentMessages.ErrorRetrievingEnvironment,
                                 Constants.EnvironmentMessages.ErrorRetrievingEnvironmentCaption,
                                 MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         else
         {
             var allTools = loadedSettings.Tools;
             var toolToRemove = allTools.FirstOrDefault(tool => tool.ID == Guid.Parse(currentGuid));
             if (toolToRemove != null && toolToRemove.ID != Guid.Empty)
             {
                 allTools.Remove(toolToRemove);
                 loadedSettings.Tools = allTools;
             }
             else
             {
                 MessageBox.Show(Constants.ToolMessages.ErrorRetrievingTool,
                     Constants.ToolMessages.ErrorRetrievingToolCaption,
                     MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
     }
     else
     {
         if (env)
         {
             MessageBox.Show(Constants.EnvironmentMessages.SelectEnvironmentToDelete,
                         Constants.EnvironmentMessages.SelectEnvironmentToDeleteCaption,
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
         else
         {
             MessageBox.Show(Constants.ToolMessages.SelectToolToDelete,
                             Constants.ToolMessages.SelectToolToDeleteCaption,
                             MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Beispiel #19
0
        public static void SaveGeneralSettings(LoadedSettings loadedSettings, GeneralStruct general)
        {
            RegistryKeyUtils.SaveNewRegistryKey(loadedSettings, general.RegistryKey);
            GlobalHotkeyUtils.SaveNewGlobalHotkey(loadedSettings, general.GlobalHotkey);
            loadedSettings.General.ShowBalloonTips = general.ShowBalloonTips;
            loadedSettings.General.IconFont        = general.IconFont;
            loadedSettings.General.IconFontSize    = general.IconFontSize;
            loadedSettings.General = loadedSettings.General;

            MessageBox.Show($"Settings {Constants.Messages.SavedSuccessfully}",
                            $"Settings {Constants.Messages.SavedSuccessfullyCaption}",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #20
0
        public static void SaveGeneralSettings(LoadedSettings loadedSettings, GeneralStruct general)
        {
            RegistryKeyUtils.SaveNewRegistryKey(loadedSettings, general.RegistryKey);
            GlobalHotkeyUtils.SaveNewGlobalHotkey(loadedSettings, general.GlobalHotkey);
            loadedSettings.General.ShowBalloonTips = general.ShowBalloonTips;
            loadedSettings.General.IconFont = general.IconFont;
            loadedSettings.General.IconFontSize = general.IconFontSize;
            loadedSettings.General = loadedSettings.General;

            MessageBox.Show($"Settings {Constants.Messages.SavedSuccessfully}",
                            $"Settings {Constants.Messages.SavedSuccessfullyCaption}",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #21
0
 public void Refresh()
 {
     _settings    = new LoadedSettings(IgnoreRequireElevatedPrivileges, false);            // No default settings are loaded.
     _loadedFiles = Directory.EnumerateFiles(PluginFolderPath, "*.xml");
     foreach (var plugin in _loadedFiles)
     {
         using (var stream = new FileStream(plugin, FileMode.Open))
         {
             _settings.AddSettingsFile(stream);
         }
     }
     _windowFilter = _settings.CreateWindowFilter();
     _hideBehavior = _settings.CreateHideBehavior();
 }
Beispiel #22
0
        protected override void RegisterSettings(GlobalSettings?settings)
        {
            if (settings is null || LoadedSettings.ContainsKey(settings.Id))
            {
                return;
            }

            LoadedSettings.Add(settings.Id, settings);

            var directoryPath   = Path.Combine(RootFolder, settings.FolderName, settings.SubFolder);
            var settingsFormats = GenericServiceProvider.GetService <IEnumerable <ISettingsFormat> >() ?? Enumerable.Empty <ISettingsFormat>();
            var settingsFormat  = settingsFormats.FirstOrDefault(x => x.FormatTypes.Any(y => y == settings.FormatType));

            settingsFormat?.Load(settings, directoryPath, settings.Id);
        }
Beispiel #23
0
        /// <inheritdoc/>
        public override bool SaveSettings(BaseSettings settings)
        {
            var behavior = GenericServiceProvider.GetService <PerSaveCampaignBehavior>();

            if (behavior is null)
            {
                return(false);
            }

            if (settings is not PerSaveSettings || !LoadedSettings.ContainsKey(settings.Id))
            {
                return(false);
            }

            return(behavior.SaveSettings((PerSaveSettings)settings));
        }
        /// <summary>
        /// Load RS_ASIO Settings from the Settings File.
        /// </summary>
        public LoadSettings()
        {
            LoadedSettings.Clear();


            // Config
            LoadedSettings.Add(new Settings("Config", "EnableWasapiOutputs", 0));
            LoadedSettings.Add(new Settings("Config", "EnableWasapiInputs", 0));
            LoadedSettings.Add(new Settings("Config", "EnableAsio", 1));

            // Asio
            LoadedSettings.Add(new Settings("Asio", "BufferSizeMode", "driver"));
            LoadedSettings.Add(new Settings("Asio", "CustomBufferSize", ""));

            // Asio.Output
            LoadedSettings.Add(new Settings("Asio.Output", "Driver", ""));
            LoadedSettings.Add(new Settings("Asio.Output", "BaseChannel", 0));
            LoadedSettings.Add(new Settings("Asio.Output", "AltBaseChannel", ""));
            LoadedSettings.Add(new Settings("Asio.Output", "EnableSoftwareEndpointVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Output", "EnableSoftwareMasterVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Output", "SoftwareMasterVolumePercent", 100));

            // Asio.Input.0
            LoadedSettings.Add(new Settings("Asio.Input.0", "Driver", ""));
            LoadedSettings.Add(new Settings("Asio.Input.0", "Channel", 0));
            LoadedSettings.Add(new Settings("Asio.Input.0", "EnableSoftwareEndpointVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Input.0", "EnableSoftwareMasterVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Input.0", "SoftwareMasterVolumePercent", 100));

            // Asio.Input.1
            LoadedSettings.Add(new Settings("Asio.Input.1", "Driver", ""));
            LoadedSettings.Add(new Settings("Asio.Input.1", "Channel", 1));
            LoadedSettings.Add(new Settings("Asio.Input.1", "EnableSoftwareEndpointVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Input.1", "EnableSoftwareMasterVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Input.1", "SoftwareMasterVolumePercent", 100));

            // Asio.Input.Mic
            LoadedSettings.Add(new Settings("Asio.Input.Mic", "Driver", ""));
            LoadedSettings.Add(new Settings("Asio.Input.Mic", "Channel", 1));
            LoadedSettings.Add(new Settings("Asio.Input.Mic", "EnableSoftwareEndpointVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Input.Mic", "EnableSoftwareMasterVolumeControl", 1));
            LoadedSettings.Add(new Settings("Asio.Input.Mic", "SoftwareMasterVolumePercent", 100));

            WriteSettingsFile();
        }
Beispiel #25
0
        /// <inheritdoc/>
        protected override void RegisterSettings(PerSaveSettings?perSaveSettings)
        {
            var behavior = GenericServiceProvider.GetService <PerSaveCampaignBehavior>();

            if (behavior is null)
            {
                return;
            }

            if (perSaveSettings is null)
            {
                return;
            }

            LoadedSettings.Add(perSaveSettings.Id, perSaveSettings);

            behavior.LoadSettings(perSaveSettings);
        }
Beispiel #26
0
        private void ReloadAll()
        {
            var containerId = LegacyFluentGlobalSettings.ContainerId;

            if (AppDomain.CurrentDomain.GetData(containerId) is null)
            {
                AppDomain.CurrentDomain.SetData(containerId, new Dictionary <string, LegacyFluentGlobalSettings>());
            }

            var storage = (AppDomain.CurrentDomain.GetData(containerId) as Dictionary <string, LegacyFluentGlobalSettings>) !;

            foreach (var(id, settings) in storage)
            {
                if (!LoadedSettings.ContainsKey(id))
                {
                    RegisterSettings(new MCMv3FluentGlobalSettingsWrapper(settings));
                }
            }
        }
Beispiel #27
0
        public virtual bool SaveSettings(BaseSettings settings)
        {
            if (!(settings is TSettings tSettings) || !LoadedSettings.ContainsKey(tSettings.Id))
            {
                return(false);
            }

            var path = Path.Combine(RootFolder, tSettings.FolderName, tSettings.SubFolder ?? "", $"{tSettings.Id}.{tSettings.Format}");

            if (AvailableSettingsFormats.ContainsKey(tSettings.Format))
            {
                AvailableSettingsFormats[tSettings.Format].Save(tSettings, path);
            }
            else
            {
                AvailableSettingsFormats["memory"].Save(tSettings, path);
            }

            return(true);
        }
Beispiel #28
0
        public static void SaveCurrentTool(LoadedSettings loadedSettings, ListBox toolsListBox, ToolStruct tool)
        {
            var currentTool = loadedSettings.Tools.First(t => t.ID == tool.ID);

            if (tool.ID == Guid.Empty) return;

            if (currentTool.Name != tool.Name)
                currentTool.Name = tool.Name;
            if (currentTool.FileLocation != tool.FileLocation)
                currentTool.FileLocation = tool.FileLocation;
            if (currentTool.HotKey != tool.HotKey)
                currentTool.HotKey = tool.HotKey;

            ListboxUtils.RepopulateListBox(false, toolsListBox, loadedSettings, tool.ID);
            ListboxUtils.SetCurrentOrderFromListBoxAndSave(false, toolsListBox, loadedSettings);

            MessageBox.Show($"{currentTool.Name} {Constants.Messages.SavedSuccessfully}",
                            $"Tool {Constants.Messages.SavedSuccessfullyCaption}",
                            MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Beispiel #29
0
        protected virtual void RegisterSettings(TSettings tSettings)
        {
            if (tSettings == null || LoadedSettings.ContainsKey(tSettings.Id))
            {
                return;
            }

            LoadedSettings.Add(tSettings.Id, tSettings);

            var path = Path.Combine(RootFolder, tSettings.FolderName, tSettings.SubFolder ?? "", $"{tSettings.Id}.{tSettings.Format}");

            if (AvailableSettingsFormats.ContainsKey(tSettings.Format))
            {
                AvailableSettingsFormats[tSettings.Format].Load(tSettings, path);
            }
            else
            {
                AvailableSettingsFormats["memory"].Load(tSettings, path);
            }
        }
 public static void SaveNewGlobalHotkey(LoadedSettings loadedSettings, GlobalHotkeyStruct globalHotkey)
 {
     if (globalHotkey.FirstModifierKey == ModifierKeys.None.ToString())
     {
         MessageBox.Show(Constants.HotkeyMessages.SelectGlobalHotkeyToSave,
                         Constants.HotkeyMessages.SelectGlobalHotkeyToSaveCaption,
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (CurrentHotkeyEqualsSavedHotkey(loadedSettings, globalHotkey.Hotkey, globalHotkey.FirstModifierKey, globalHotkey.SecondModifierKey))
     {
         return;
     }
     else
     {
         loadedSettings.General.LoadedGlobalHotkey.Hotkey =
             GlobalHotkeyParser.ConvertStringToKey(globalHotkey.Hotkey);
         loadedSettings.General.LoadedGlobalHotkey.FirstModifierKey =
             GlobalHotkeyParser.ConvertStringToModifierKeys(globalHotkey.FirstModifierKey);
         loadedSettings.General.LoadedGlobalHotkey.SecondModifierKey =
             GlobalHotkeyParser.ConvertStringToModifierKeys(globalHotkey.SecondModifierKey);
     }
 }
 public static void SaveNewGlobalHotkey(LoadedSettings loadedSettings, GlobalHotkeyStruct globalHotkey)
 {
     if (globalHotkey.FirstModifierKey == ModifierKeys.None.ToString())
     {
         MessageBox.Show(Constants.HotkeyMessages.SelectGlobalHotkeyToSave,
                         Constants.HotkeyMessages.SelectGlobalHotkeyToSaveCaption,
                         MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     else if (CurrentHotkeyEqualsSavedHotkey(loadedSettings, globalHotkey.Hotkey, globalHotkey.FirstModifierKey, globalHotkey.SecondModifierKey))
     {
         return;
     }
     else
     {
         loadedSettings.General.LoadedGlobalHotkey.Hotkey =
             GlobalHotkeyParser.ConvertStringToKey(globalHotkey.Hotkey);
         loadedSettings.General.LoadedGlobalHotkey.FirstModifierKey =
             GlobalHotkeyParser.ConvertStringToModifierKeys(globalHotkey.FirstModifierKey);
         loadedSettings.General.LoadedGlobalHotkey.SecondModifierKey =
             GlobalHotkeyParser.ConvertStringToModifierKeys(globalHotkey.SecondModifierKey);
     }
 }
Beispiel #32
0
        /// <summary>
        /// Load Rocksmith Settings
        /// </summary>
        public LoadSettings()
        {
            LoadedSettings.Clear();

            // Audio
            LoadedSettings.Add(new Settings("Audio", "EnableMicrophone", 1));
            LoadedSettings.Add(new Settings("Audio", "ExclusiveMode", 1));
            LoadedSettings.Add(new Settings("Audio", "LatencyBuffer", 4));
            LoadedSettings.Add(new Settings("Audio", "ForceDefaultPlaybackDevice", ""));
            LoadedSettings.Add(new Settings("Audio", "ForceWDM", 0));
            LoadedSettings.Add(new Settings("Audio", "ForceDirectXSink", 0));
            LoadedSettings.Add(new Settings("Audio", "DumpAudioLog", 0));
            LoadedSettings.Add(new Settings("Audio", "MaxOutputBufferSize", 0));
            LoadedSettings.Add(new Settings("Audio", "RealToneCableOnly", 0));
            LoadedSettings.Add(new Settings("Audio", "Win32UltraLowLatencyMode", 1));

            // Renderer.Win32
            LoadedSettings.Add(new Settings("Renderer.Win32", "ShowGamepadUI", 0));
            LoadedSettings.Add(new Settings("Renderer.Win32", "ScreenWidth", 0));
            LoadedSettings.Add(new Settings("Renderer.Win32", "ScreenHeight", 0));
            LoadedSettings.Add(new Settings("Renderer.Win32", "Fullscreen", 2));
            LoadedSettings.Add(new Settings("Renderer.Win32", "VisualQuality", 1));
            LoadedSettings.Add(new Settings("Renderer.Win32", "RenderingWidth", 0));
            LoadedSettings.Add(new Settings("Renderer.Win32", "RenderingHeight", 0));
            LoadedSettings.Add(new Settings("Renderer.Win32", "EnablePostEffects", 1));
            LoadedSettings.Add(new Settings("Renderer.Win32", "EnableShadows", 1));
            LoadedSettings.Add(new Settings("Renderer.Win32", "EnableHighResScope", 1));
            LoadedSettings.Add(new Settings("Renderer.Win32", "EnableDepthOfField", 1));
            LoadedSettings.Add(new Settings("Renderer.Win32", "EnablePerPixelLighting", 1));
            LoadedSettings.Add(new Settings("Renderer.Win32", "MsaaSamples", 4));
            LoadedSettings.Add(new Settings("Renderer.Win32", "DisableBrowser", 0));

            // Net
            LoadedSettings.Add(new Settings("Net", "UseProxy", 1));

            WriteSettingsFile();
        }
Beispiel #33
0
        public static void MoveItem(int direction, bool env, ListBox currentListBox, LoadedSettings loadedSettings)
        {
            // Checking selected item
            if (currentListBox.SelectedItem == null || currentListBox.SelectedIndex < 0)
                return; // No selected item - nothing to do

            // Calculate new index using move direction
            int newIndex = currentListBox.SelectedIndex + direction;

            // Checking bounds of the range
            if (newIndex < 0 || newIndex >= currentListBox.Items.Count)
                return; // Index out of range - nothing to do

            object selected = currentListBox.SelectedItem;

            // Removing removable element
            currentListBox.Items.Remove(selected);
            // Insert it in new position
            currentListBox.Items.Insert(newIndex, selected);
            // Restore selection
            currentListBox.SetSelected(newIndex, true);
            // Save changes
            SetCurrentOrderFromListBoxAndSave(env, currentListBox, loadedSettings);
        }
Beispiel #34
0
 public static void SetCurrentOrderFromListBoxAndSave(bool env, ListBox currentListBox, LoadedSettings loadedSettings)
 {
     if (env)
     {
         var environmentsOrdered = (from object item
                                    in currentListBox.Items
                                    select loadedSettings.Environments.FirstOrDefault(environment => environment.Name == item.ToString()))
                                   .ToList();
         loadedSettings.Environments = environmentsOrdered;
     }
     else
     {
         var toolsOrdered = (from object item
                             in currentListBox.Items
                             select loadedSettings.Tools.FirstOrDefault(tool => tool.Name == item.ToString()))
                            .ToList();
         loadedSettings.Tools = toolsOrdered;
     }
 }
        public static void SaveNewRegistryKey(LoadedSettings loadedSettings, RegistryKeyStruct registryKey)
        {
            if (GetCurrentKeyValue(registryKey) == string.Empty) // New Key is invalid.
            {
                MessageBox.Show(Constants.RegistryKeyMessages.SelectRegistryKey,
                                Constants.RegistryKeyMessages.SelectRegistryKeyCaption,
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (CurrentKeyEqualsSavedKey(loadedSettings.MonitoredRegistryKey, registryKey)) // New Key is Old Key.
            {
                return;
            }
            else // Save New Key.
            {
                var confirmMessage = MessageBox.Show(Constants.RegistryKeyMessages.OverrideRegistryKey,
                                                     Constants.RegistryKeyMessages.OverrideRegistryKeyCaption,
                                                     MessageBoxButtons.YesNo, MessageBoxIcon.Hand);

                if (confirmMessage != DialogResult.Yes) return;

                var newRegistryKey = new MonitoredRegistryKey
                {
                    Root = GetCurrentRoot(registryKey),
                    Subkey = registryKey.Subkey
                };
                loadedSettings.MonitoredRegistryKey = newRegistryKey;
            }
        }
        public void OnGameStarted(Game game)
        {
            LoadedSettings.Clear();

            LoadSettings();
        }
Beispiel #37
0
 public static void SetCurrentOrderFromListBoxAndSave(bool env, ListBox currentListBox, LoadedSettings loadedSettings)
 {
     if (env)
     {
         var environmentsOrdered = (from object item
                                    in currentListBox.Items
                                    select loadedSettings.Environments.FirstOrDefault(environment => environment.Name == item.ToString()))
                                    .ToList();
         loadedSettings.Environments = environmentsOrdered;
     }
     else
     {
         var toolsOrdered = (from object item
                             in currentListBox.Items
                             select loadedSettings.Tools.FirstOrDefault(tool => tool.Name == item.ToString()))
                             .ToList();
         loadedSettings.Tools = toolsOrdered;
     }
 }
Beispiel #38
0
 public void OnGameEnded(Game game)
 {
     LoadedSettings.Clear();
 }
Beispiel #39
0
        public static void RepopulateListBox(bool env, ListBox currentListBox, LoadedSettings loadedSettings, Guid currentGuid)
        {
            currentListBox.Items.Clear();

            if (env)
            {
                foreach (var key in loadedSettings.Environments)
                {
                    currentListBox.Items.Add(key.Name);
                }
            }
            else
            {
                foreach (var key in loadedSettings.Tools)
                {
                    currentListBox.Items.Add(key.Name);
                }
            }

            if (currentGuid != Guid.Empty) return;

            var currentName = env
                            ? loadedSettings.Environments.FirstOrDefault(environment => environment.ID == currentGuid)?.Name
                            : loadedSettings.Tools.FirstOrDefault(tool => tool.ID == currentGuid)?.Name;

            if (currentName != null)
                currentListBox.SelectedIndex = currentListBox.Items.IndexOf(currentName);
        }
 private static bool CurrentHotkeyEqualsSavedHotkey(LoadedSettings loadedSettings, string globalHotKey, string firstModifierKey, string secondModifierKey)
 {
     return loadedSettings.General.LoadedGlobalHotkey.Hotkey.ToString() == globalHotKey &&
            loadedSettings.General.LoadedGlobalHotkey.FirstModifierKey.ToString() == firstModifierKey &&
            loadedSettings.General.LoadedGlobalHotkey.SecondModifierKey.ToString() == secondModifierKey;
 }
 public void OnGameStarted(Game game) => LoadedSettings.Clear();
Beispiel #42
0
 public virtual BaseSettings?GetSettings(string id) => LoadedSettings.TryGetValue(id, out var result) ? result : null;