private List <CustomComboEntry> GetPresetList(CustomComboPreset enabledPresets)
        {
            var comboList = new List <CustomComboEntry>();

            foreach (var presetValue in Enum.GetValues(typeof(CustomComboPreset)).Cast <CustomComboPreset>())
            {
                if (presetValue == CustomComboPreset.None)
                {
                    continue;
                }

                var presetInfo = presetValue.GetAttribute <CustomComboInfoAttribute>();
                comboList.Add(new CustomComboEntry
                {
                    Preset      = presetValue,
                    Name        = presetInfo.FancyName,
                    Description = presetInfo.Description,
                    ClassJob    = presetInfo.ClassJob,
                    Icon        = Util.ClassJobToIcon(presetInfo.ClassJob),
                    IsEnabled   = enabledPresets.HasFlag(presetValue)
                });
            }

            return(comboList);
        }
        private void NextButton_Click(object sender, RoutedEventArgs e)
        {
            foreach (var customComboEntry in CustomCombos.Where(customComboEntry => customComboEntry.IsEnabled && !customComboEntry.IsCustomMessage))
            {
                EnabledPresets |= customComboEntry.Preset;
            }

            Close();
        }
        private void UpgradeToVersion4()
        {
#pragma warning disable CS0612,CS0618 // Type or member is obsolete
            PluginLog.Information("Upgrading configuration to version 4");
            foreach (LegacyCustomComboPreset legacyPreset in Enum.GetValues(typeof(LegacyCustomComboPreset)))
            {
                if (_ComboPresetsBacker.HasFlag(legacyPreset))
                {
                    int legacyPresetIndex    = (int)Math.Log((long)legacyPreset, 2);
                    CustomComboPreset preset = (CustomComboPreset)legacyPresetIndex;
                    if (Enum.IsDefined(typeof(CustomComboPreset), preset))
                    {
                        EnabledActions.Add(preset);
                    }
                }
            }
            _ComboPresetsBacker  = 0;
            _HiddenActionsBacker = null;
            Version = 4;
#pragma warning restore CS0612,CS0618 // Type or member is obsolete
        }
 public bool IsEnabled(CustomComboPreset preset) => EnabledActions.Contains(preset);
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParentComboAttribute"/> class.
 /// </summary>
 /// <param name="parentPreset">Presets that conflict with the given combo.</param>
 internal ParentComboAttribute(CustomComboPreset parentPreset)
 {
     this.ParentPreset = parentPreset;
 }
        public CustomComboSetupWindow(CustomComboPreset currentPresets)
        {
            InitializeComponent();

            ClassJobComboBox.ItemsSource = new List <ClassJobComboBoxEntry>
            {
                new ClassJobComboBoxEntry
                {
                    Name     = "Filter for job...",
                    ClassJob = 0
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Dragoon",
                    ClassJob = 22
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Summoner",
                    ClassJob = 27
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Machinist",
                    ClassJob = 31
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Bard",
                    ClassJob = 23
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Black Mage",
                    ClassJob = 25
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Red Mage",
                    ClassJob = 35
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Dancer",
                    ClassJob = 38
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Samurai",
                    ClassJob = 34
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Ninja",
                    ClassJob = 30
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Monk",
                    ClassJob = 20
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Dark Knight",
                    ClassJob = 32
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Warrior",
                    ClassJob = 21
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Gunbreaker",
                    ClassJob = 37
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Astrologian",
                    ClassJob = 33
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "Scholar",
                    ClassJob = 28
                },
                new ClassJobComboBoxEntry
                {
                    Name     = "White Mage",
                    ClassJob = 24
                }
            };

            EnabledPresets = currentPresets;

            CustomCombos = GetPresetList(currentPresets);

            CustomCombos.Add(new CustomComboEntry
            {
                ClassJob        = 0,
                Description     = "Join our discord to talk about them!",
                Name            = "Any ideas for more custom combos or features?",
                Icon            = "\uE901",
                IsCustomMessage = true
            });

            ComboListView.ItemsSource = CustomCombos;

            var view = CollectionViewSource.GetDefaultView(ComboListView.ItemsSource);

            view.Filter = ClassJobFilter;

            // We have to do this here, otherwise GetDefaultView will return null in InitializeComponent
            ClassJobComboBox.SelectionChanged += ClassJobComboBox_OnSelectionChanged;
        }