Example #1
0
        public void ReloadDresspheres()
        {
            var dresses = Dresspheres.GetDresspheres().ToList();

            dresses.RemoveAll(r => r.Special != -1 && r.Special != SelectedIndex);

            var oldSelection = _selectedDs;
            var newSelection = 0;

            Dressphere.Items.Clear();
            Dressphere.Items.Add("None");
            foreach (var dress in dresses)
            {
                Dressphere.Items.Add(new ComboBoxItem {
                    Content = dress.Name, Tag = dress.ID
                });
                if (dress.ID == oldSelection)
                {
                    newSelection = Dressphere.Items.Count - 1;
                    _selectedDs  = dress.ID;
                }
            }

            Dressphere.SelectedIndex = newSelection;
        }
Example #2
0
 public DressphereAbilities()
 {
     InitializeComponent();
     Dressphere.Items.Add("None");
     foreach (var dressphere in Dresspheres.GetDresspheres())
     {
         Dressphere.Items.Add(dressphere.Name);
     }
     Dressphere.SelectedIndex = 0;
 }
Example #3
0
        private void MasterAll_Click(object sender, RoutedEventArgs e)
        {
            if (Dressphere.SelectedIndex == 0 || _baseOffset == 0)
            {
                return;
            }
            var dressInfo = Dresspheres.GetDresspheres().FirstOrDefault(ds => ds.ID == Dressphere.SelectedIndex);

            if (dressInfo == null)
            {
                return;
            }

            var abilities = dressInfo.Abilities;

            for (int a = 0; a < 16; a++)
            {
                if (a >= abilities.Length)
                {
                    continue;
                }

                var abil = abilities[a];

                int currentAP = 0;

                if (abil.Offset == -1 || abil.ReadOnly)
                {
                    continue;
                }

                LegacyMemoryReader.WriteBytes(_baseOffset + abil.Offset, BitConverter.GetBytes((ushort)abil.MasteredAP));
            }

            RefreshAbilities(_char);
        }
Example #4
0
        private void AbilityButton_Click(object sender, RoutedEventArgs e)
        {
            if (Dressphere.SelectedIndex == 0 || _baseOffset == 0)
            {
                return;
            }
            var abilityNum = int.Parse((sender as Button).Name.Substring(7));
            var dressInfo  = Dresspheres.GetDresspheres().FirstOrDefault(ds => ds.ID == Dressphere.SelectedIndex);

            var ability = dressInfo.Abilities[abilityNum];

            var apDialog = new AbilitySlider(ability.MasteredAP, values[abilityNum]);
            var setAp    = apDialog.ShowDialog();

            if (!setAp.HasValue || setAp.Value != true)
            {
                return;
            }
            var newAp = apDialog.AP;

            LegacyMemoryReader.WriteBytes(_baseOffset + ability.Offset, BitConverter.GetBytes((ushort)newAp));

            RefreshAbilities(_char);
        }
Example #5
0
        public void RefreshAbilities(int characterIndex)
        {
            if (Dressphere.SelectedIndex == 0)
            {
                return;
            }
            _char       = characterIndex;
            _baseOffset = (int)OffsetType.AbilityBase + characterIndex * 0x6A0;
            var dressInfo = Dresspheres.GetDresspheres().FirstOrDefault(ds => ds.ID == Dressphere.SelectedIndex);

            if (dressInfo == null)
            {
                return;
            }

            var abilities = dressInfo.Abilities;

            for (int a = 0; a < 16; a++)
            {
                var button = (Button)this.FindName($"Ability{a}");
                if (button == null)
                {
                    continue;
                }

                button.Content   = string.Empty;
                button.IsEnabled = false;

                if (a >= abilities.Length)
                {
                    continue;
                }

                var abil = abilities[a];

                int currentAP = 0;

                if (abil.Offset != -1)
                {
                    currentAP = LegacyMemoryReader.ReadInt16(_baseOffset + abil.Offset);
                }

                values[a] = currentAP;

                string apText;

                if (currentAP >= abil.MasteredAP || abil.MasteredAP == 0)
                {
                    apText = " [***]";
                }
                else
                {
                    apText = $" {currentAP} / {abil.MasteredAP}";
                }

                button.Content = $"{abil.Name} {apText}";

                if (abil.ReadOnly == false)
                {
                    button.IsEnabled = true;
                }
            }
        }
Example #6
0
        public void RefreshAbilities()
        {
            var selectedId = (int)((Dressphere.SelectedItem as ComboBoxItem)?.Tag ?? 0);

            if (selectedId == 0)
            {
                return;
            }

            var dressInfo = Dresspheres.GetDresspheres().FirstOrDefault(ds => ds.ID == selectedId);

            if (dressInfo == null)
            {
                return;
            }

            // Special dresspheres always fall under Yuna's offset
            _baseOffset = (int)OffsetType.AbilityBase + (dressInfo.Special == -1 ? SelectedIndex * 0x6A0 : 0);

            var abilities = dressInfo.Abilities;

            for (int a = 0; a < 16; a++)
            {
                var button = (Button)this.FindName($"Ability{a}");
                if (button == null)
                {
                    continue;
                }

                button.Content   = string.Empty;
                button.IsEnabled = false;

                if (a >= abilities.Length)
                {
                    continue;
                }

                var abil = abilities[a];

                int currentAP = 0;

                if (abil.Offset != -1)
                {
                    currentAP = LegacyMemoryReader.ReadInt16(_baseOffset + abil.Offset);
                }

                values[a] = currentAP;

                string apText;

                if (currentAP >= abil.MasteredAP || abil.MasteredAP == 0)
                {
                    apText = " [***]";
                }
                else
                {
                    apText = $" {currentAP} / {abil.MasteredAP}";
                }

                button.Content = $"{abil.Name} {apText}";

                if (abil.ReadOnly == false)
                {
                    button.IsEnabled = true;
                }
            }
        }