コード例 #1
0
        private void WriteAbility(int itemSlot, int abilitySlot, int abilityId)
        {
            var offset = Offsets.GetOffset(OffsetType.EquipmentBase) + (itemSlot * EquipmentLength);

            MemoryReader.WriteBytes(offset + (int)EquipmentOffset.Ability0 + (abilitySlot * 2),
                                    BitConverter.GetBytes((ushort)abilityId));
        }
コード例 #2
0
        private void ButtonEquipmentAppearance_OnClick(object sender, RoutedEventArgs e)
        {
            var currentChara = (int)_equipmentBytes[_selectedItem * EquipmentLength + (int)EquipmentOffset.Character];

            if (currentChara > 6)
            {
                currentChara = 0;
            }

            var searchList = new List <string>();

            for (int n = 0; n < EquipAppearance.EquipAppearances.Length; n++)
            {
                searchList.Add($"{EquipAppearance.EquipAppearances[n].ID.ToString("X2")} {EquipAppearance.EquipAppearances[n].Name}");
            }

            var currentAppearance = BitConverter.ToUInt16(_equipmentBytes, _selectedItem * EquipmentLength + (int)EquipmentOffset.Appearance);

            var searchDialog   = new SearchDialog(searchList, currentAppearance.ToString("X4"), false);
            var searchComplete = searchDialog.ShowDialog();

            if (!searchComplete.Value)
            {
                return;
            }
            var searchIndex = searchDialog.ResultIndex;
            var searchItem  = EquipAppearance.EquipAppearances[searchIndex];

            MemoryReader.WriteBytes(Offsets.GetOffset(OffsetType.EquipmentBase) + _selectedItem * EquipmentLength + (int)EquipmentOffset.Appearance, BitConverter.GetBytes((ushort)searchItem.ID));
            Refresh();
        }
コード例 #3
0
        private void ButtonSelectNode_Click(object sender, RoutedEventArgs e)
        {
            var selectedNode = BitConverter.ToUInt16(MemoryReader.ReadBytes(Offsets.GetOffset(OffsetType.SphereGridCursor), 2), 0);

            currentNode = selectedNode;
            Refresh();
        }
コード例 #4
0
        private void ComboEquipmentSlots_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_refreshing)
            {
                return;
            }
            var newSlots = (sender as ComboBox).SelectedIndex;

            for (var i = 0; i < 4; i++)
            {
                var abilityButton = (AbilityPanel.Children[i] as Button);
                if (abilityButton == null)
                {
                    continue;
                }

                if (i >= newSlots)
                {
                    abilityButton.Visibility = Visibility.Collapsed;
                    WriteAbility(_selectedItem, i, 0xFF);
                }
                else
                {
                    abilityButton.Visibility = Visibility.Visible;
                }
            }
            var offset = Offsets.GetOffset(OffsetType.EquipmentBase) + (_selectedItem * EquipmentLength);

            MemoryReader.WriteBytes(offset + (int)EquipmentOffset.AbilityCount, new byte[] { (byte)newSlots });

            RefreshSelectedItem();
        }
コード例 #5
0
        public void Refresh(int characterIndex)
        {
            _characterIndex = characterIndex;
            _statsBase      = Offsets.GetOffset(OffsetType.PartyStatsBase) + StatsLength * _characterIndex;

            var statBytes = MemoryReader.ReadBytes(_statsBase, StatsLength);

            TextTotalAP.Text   = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.ApTotal).ToString();
            TextCurrentAP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.ApCurrent).ToString();

            TextCurrentHP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.CurrentHp).ToString();
            TextCurrentMP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.CurrentMp).ToString();
            TextMaxHP.Text     = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.MaxHp).ToString();
            TextMaxMP.Text     = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.MaxMp).ToString();

            TextBaseHP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.BaseHp).ToString();
            TextBaseMP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.BaseMp).ToString();

            TextSphereLevelCurrent.Text = statBytes[(int)PartyStatOffset.SphereLevelCurrent].ToString();
            TextSphereLevelTotal.Text   = BitConverter.ToUInt16(statBytes, (int)PartyStatOffset.SphereLevelTotal).ToString();

            TextBaseStrength.Text = statBytes[(int)PartyStatOffset.BaseStrength].ToString();
            TextBaseDefense.Text  = statBytes[(int)PartyStatOffset.BaseDefense].ToString();
            TextBaseMagic.Text    = statBytes[(int)PartyStatOffset.BaseMagic].ToString();
            TextBaseMagicDef.Text = statBytes[(int)PartyStatOffset.BaseMagicDefense].ToString();
            TextBaseAgility.Text  = statBytes[(int)PartyStatOffset.BaseAgility].ToString();
            TextBaseLuck.Text     = statBytes[(int)PartyStatOffset.BaseLuck].ToString();
            TextBaseEvasion.Text  = statBytes[(int)PartyStatOffset.BaseEvasion].ToString();
            TextBaseAccuracy.Text = statBytes[(int)PartyStatOffset.BaseAccuracy].ToString();
        }
コード例 #6
0
        public void Refresh(int characterIndex)
        {
            _characterIndex = characterIndex;
            _statsBase      = Offsets.GetOffset(OffsetType.PartyStatsBase) + StatsLength * _characterIndex;
            _nameBase       = Offsets.GetOffset(OffsetType.AeonNames) + Offsets.AeonNames[_characterIndex - 8];
            var statBytes = MemoryReader.ReadBytes(_statsBase, StatsLength);
            var nameBytes = MemoryReader.ReadBytes(_nameBase, 8);

            TextAeonName.Text = StringConverter.ToString(nameBytes);

            TextBaseHP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.BaseHp).ToString();
            TextBaseMP.Text = BitConverter.ToUInt32(statBytes, (int)PartyStatOffset.BaseMp).ToString();

            TextOverdrive.Text    = statBytes[(int)PartyStatOffset.OverdriveLevel].ToString();
            TextOverdriveMax.Text = statBytes[(int)PartyStatOffset.OverdriveMax].ToString();

            TextBaseStrength.Text = statBytes[(int)PartyStatOffset.BaseStrength].ToString();
            TextBaseDefense.Text  = statBytes[(int)PartyStatOffset.BaseDefense].ToString();
            TextBaseMagic.Text    = statBytes[(int)PartyStatOffset.BaseMagic].ToString();
            TextBaseMagicDef.Text = statBytes[(int)PartyStatOffset.BaseMagicDefense].ToString();
            TextBaseAgility.Text  = statBytes[(int)PartyStatOffset.BaseAgility].ToString();
            TextBaseLuck.Text     = statBytes[(int)PartyStatOffset.BaseLuck].ToString();
            TextBaseEvasion.Text  = statBytes[(int)PartyStatOffset.BaseEvasion].ToString();
            TextBaseAccuracy.Text = statBytes[(int)PartyStatOffset.BaseAccuracy].ToString();
        }
コード例 #7
0
        public static SphereGridNode ReadNode(int nodeIndex)
        {
            var offsetNode = Offsets.GetOffset(OffsetType.SphereGridNodes) + nodeIndex * 40;
            var nodeBytes  = MemoryReader.ReadBytes(offsetNode, 40);

            return(new SphereGridNode()
            {
                Type = NodeTypes.First(node => node.ID == nodeBytes[(int)NodeOffset.NodeType]),
                ActivatedBy = nodeBytes[(int)NodeOffset.ActivatedBy]
            });
        }
コード例 #8
0
        private void ComboEquipmentType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_refreshing)
            {
                return;
            }

            var offset = Offsets.GetOffset(OffsetType.EquipmentBase) + _selectedItem * EquipmentLength + (int)EquipmentOffset.Type;

            MemoryReader.WriteBytes(offset, new byte[] { (byte)ComboEquipmentType.SelectedIndex });

            Refresh();
        }
コード例 #9
0
        private void SphereGridActivation_Changed(object sender, RoutedEventArgs e)
        {
            if (_refreshing)
            {
                return;
            }
            var senderBox   = sender as CheckBox;
            var senderIndex = PanelNodeActivatedBy.Children.IndexOf(senderBox);

            var byteOffset = Offsets.GetOffset(OffsetType.SphereGridNodes) + currentNode * 40 + NodeOffset.ActivatedBy;
            var actBytes   = MemoryReader.ReadByte((int)byteOffset);

            actBytes = BitHelper.ToggleBit(actBytes, senderIndex);

            MemoryReader.WriteByte((int)byteOffset, actBytes);
            Refresh();
        }
コード例 #10
0
        private void ToggleSkill(AbilityType type, int buttonIndex)
        {
            if (_characterIndex == -1)
            {
                return;
            }

            Ability skill = null;

            switch (type)
            {
            case AbilityType.Skill:
                skill = _skills[buttonIndex];
                break;

            case AbilityType.Special:
                skill = _specials[buttonIndex];
                break;

            case AbilityType.WhiteMagic:
                skill = _wMagic[buttonIndex];
                break;

            case AbilityType.BlackMagic:
                skill = _bMagic[buttonIndex];
                break;

            default:
                return;
            }

            var byteIndex = skill.BitOffset / 8;
            var bitIndex  = skill.BitOffset % 8;
            var offset    = Offsets.GetOffset(OffsetType.PartyStatsBase) + 0x94 * _characterIndex +
                            (int)PartyStatOffset.SkillFlags;
            var skillBytes =
                MemoryReader.ReadBytes(offset, 0x0C);

            var newByte = BitHelper.ToggleBit(skillBytes[byteIndex], bitIndex);

            skillBytes[byteIndex] = newByte;

            MemoryReader.WriteBytes(offset, skillBytes);
        }
コード例 #11
0
        public void Refresh(int characterIndex)
        {
            _characterIndex = characterIndex;
            if (_characterIndex == -1)
            {
                return;
            }
            var skillBytes =
                MemoryReader.ReadBytes(Offsets.GetOffset(OffsetType.PartyStatsBase) + 0x94 * characterIndex + (int)PartyStatOffset.SkillFlags,
                                       0x0D);
            var skillArray = BitHelper.GetBitArray(skillBytes);

            for (int i = 0; i < _skills.Length; i++)
            {
                var button = (Button)_gridSkill.GridBase.Children[i];
                button.Foreground = skillArray[_skills[i].BitOffset] ? _trueAbilityBrush : _falseAbilityBrush;
                button.Content    = _skills[i].Name;
            }


            for (int i = 0; i < _specials.Length; i++)
            {
                var button = (Button)_gridSpecial.GridBase.Children[i];
                button.Foreground = skillArray[_specials[i].BitOffset] ? _trueAbilityBrush : _falseAbilityBrush;
                button.Content    = _specials[i].Name;
            }


            for (int i = 0; i < _wMagic.Length; i++)
            {
                var button = (Button)_gridWhiteMagic.GridBase.Children[i];
                button.Foreground = skillArray[_wMagic[i].BitOffset] ? _trueAbilityBrush : _falseAbilityBrush;
                button.Content    = _wMagic[i].Name;
            }


            for (int i = 0; i < _bMagic.Length; i++)
            {
                var button = (Button)_gridBlackMagic.GridBase.Children[i];
                button.Foreground = skillArray[_bMagic[i].BitOffset] ? _trueAbilityBrush : _falseAbilityBrush;
                button.Content    = _bMagic[i].Name;
            }
        }
コード例 #12
0
        private void ButtonEquipmentName_OnClick(object sender, RoutedEventArgs e)
        {
            var currentChara = (int)_equipmentBytes[_selectedItem * EquipmentLength + (int)EquipmentOffset.Character];

            if (currentChara > 6)
            {
                currentChara = 0;
            }

            var searchList = new List <string>();

            for (int n = 0; n < EquipName.EquipNames[currentChara].Length; n++)
            {
                searchList.Add($"{n.ToString("X2")} {EquipName.EquipNames[currentChara][n]}");
            }

            var currentName = (int)_equipmentBytes[_selectedItem * EquipmentLength + (int)EquipmentOffset.Name];
            var nameString  = string.Empty;

            if (currentChara < 7)
            {
                nameString = EquipName.EquipNames[currentChara][currentName];
            }

            var searchDialog   = new SearchDialog(searchList, nameString, false);
            var searchComplete = searchDialog.ShowDialog();

            if (!searchComplete.Value)
            {
                return;
            }
            var searchIndex = searchDialog.ResultIndex;

            MemoryReader.WriteByte(Offsets.GetOffset(OffsetType.EquipmentBase) + _selectedItem * EquipmentLength, (byte)searchIndex);

            Refresh();
        }
コード例 #13
0
        public void Refresh()
        {
            _refreshing = true;

            _equipmentBytes = MemoryReader.ReadBytes(Offsets.GetOffset(OffsetType.EquipmentBase), EquipmentSlots * EquipmentLength);

            for (int equipmentSlot = 0; equipmentSlot < EquipmentSlots; equipmentSlot++)
            {
                var listItem = (ListViewItem)ListEquipment.Items[equipmentSlot];
                // Copy item data to array
                var itemOffset = equipmentSlot * EquipmentLength;

                var equipmentItem = (ListViewItem)ListEquipment.Items[equipmentSlot];

                // TODO: implement equipment icon

                var nameIndex = _equipmentBytes[itemOffset + (int)EquipmentOffset.Name];
                var itemChara = (Characters)_equipmentBytes[itemOffset + (int)EquipmentOffset.Character];

                var itemType = _equipmentBytes[itemOffset + (int)EquipmentOffset.Type];



                if (nameIndex == 0xFF)
                {
                    equipmentItem.Content = "<EMPTY>";
                }
                else if (equipmentSlot >= 0x0C && equipmentSlot <= 0x21) // hide aeon gear
                {
                    listItem.Visibility = Visibility.Collapsed;
                    continue;
                }
                else
                {
                    Image  itemIcon = null;
                    string itemText = string.Empty;

                    if ((int)itemChara < 7)
                    {
                        itemIcon = new Image
                        {
                            Source =
                                new BitmapImage(
                                    new Uri("pack://application:,,,/FFX/Resources/MenuIcons/equip_" + (int)itemChara +
                                            "_" + itemType + ".png")),
                            Width  = 24,
                            Height = 24
                        };
                        itemText = EquipName.EquipNames[(int)itemChara][nameIndex];
                    }
                    else
                    {
                        itemIcon = new Image
                        {
                            Width  = 24,
                            Height = 24
                        };
                        itemText = "????";
                    }

                    equipmentItem.Content =
                        new DockPanel()
                    {
                        Margin   = new Thickness(0),
                        Children =
                        {
                            itemIcon,
                            new TextBlock()
                            {
                                Text = itemText,
                                VerticalAlignment = VerticalAlignment.Center,
                                Margin            = new Thickness(2)
                            }
                        }
                    };
                }
            }

            if (ListEquipment.SelectedIndex == -1)
            {
                ListEquipment.SelectedIndex = 0;
            }
            RefreshSelectedItem();

            _refreshing = false;
        }
コード例 #14
0
        private void RefreshSelectedItem()
        {
            _refreshing     = true;
            _equipmentBytes = MemoryReader.ReadBytes(Offsets.GetOffset(OffsetType.EquipmentBase), EquipmentSlots * EquipmentLength);

            if (_selectedItem == -1)
            {
                _selectedItem = 0;
            }
            var itemOffset = _selectedItem * EquipmentLength;

            // read item data
            var itemName       = _equipmentBytes[itemOffset + (int)EquipmentOffset.Name];
            var itemChara      = _equipmentBytes[itemOffset + (int)EquipmentOffset.Character];
            var itemType       = _equipmentBytes[itemOffset + (int)EquipmentOffset.Type];
            var itemAppearance = BitConverter.ToUInt16(_equipmentBytes, itemOffset + (int)EquipmentOffset.Appearance);

            var itemAbilityCount = _equipmentBytes[itemOffset + (int)EquipmentOffset.AbilityCount];
            var abilities        = new ushort[4];

            for (int a = 0; a < 4; a++)
            {
                abilities[a] = BitConverter.ToUInt16(_equipmentBytes, itemOffset + (int)EquipmentOffset.Ability0 + (2 * a));
            }

            // update controls
            var itemNameString = "????";

            if (itemChara < 7)
            {
                itemNameString = EquipName.EquipNames[(int)itemChara][itemName];
            }

            var appearance       = EquipAppearance.FromID(itemAppearance);
            var appearanceString = string.Empty;

            if (appearance != null)
            {
                appearanceString = appearance.Name;
            }

            GroupEquipmentEditor.Header           = itemNameString;
            ButtonEquipmentName.Content           = itemNameString;
            ButtonEquipmentAppearance.Content     = appearanceString;
            ComboEquipmentCharacter.SelectedIndex = itemChara;
            ComboEquipmentType.SelectedIndex      = itemType;
            ComboEquipmentSlots.SelectedIndex     = itemAbilityCount;

            // update abilities
            for (int ability = 0; ability < 4; ability++)
            {
                var abilityButton = (AbilityPanel.Children[ability] as Button);
                if (abilityButton == null)
                {
                    continue;
                }

                if (ability >= itemAbilityCount)
                {
                    abilityButton.Visibility = Visibility.Collapsed;
                }
                else
                {
                    abilityButton.Visibility = Visibility.Visible;

                    if (abilities[ability] == 0xFF)
                    {
                        // Empty slot
                        abilityButton.Content = string.Empty;
                    }
                    else
                    {
                        var abilityName = AutoAbility.AutoAbilities.First(a => a.ID == abilities[ability]).Name;
                        abilityButton.Content = abilityName;
                    }
                }
            }
            _refreshing = false;
        }
コード例 #15
0
        private void ComboNodeType_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var byteOffset = Offsets.GetOffset(OffsetType.SphereGridNodes) + currentNode * 40 + NodeOffset.NodeType;

            MemoryReader.WriteByte((int)byteOffset, (byte)SphereGridNode.NodeTypes[ComboNodeType.SelectedIndex].ID);
        }