Example #1
0
        //public int MovesetCount
        //{
        //    get
        //    {
        //        return _msetcount;
        //    }
        //    set
        //    {
        //        _msetcount = value;
        //    }
        //}

        public CodeEntries ConvertToCodes()
        {
            CodeEntries en = new CodeEntries();

            foreach (KeyValuePair <int, ObservableCollection <Change> > kvp in _listOfChanges)
            {
                Moveset m = Communicator.Instance.Movesets[kvp.Key];
                foreach (var cha in kvp.Value)
                {
                    if (cha is WholeMovesetChange)
                    {
                        WholeMovesetChange wmc = (WholeMovesetChange)cha;

                        if (wmc.TypeOfRef == TypeOfWhole.eAll)
                        {
                            int writeTo;
                            if (wmc.NewMset == -1)
                            {
                                writeTo = 0;
                            }
                            else
                            {
                                writeTo = Communicator.Instance.Movesets[wmc.NewMset].ANBAddress;
                            }
                            foreach (var item in m.AddressReferences)
                            {
                                en.Add(item, writeTo);
                            }
                        }
                        else
                        {
                            int writeTo;
                            if (wmc.NewMset == -1)
                            {
                                writeTo = 0;
                            }
                            else
                            {
                                writeTo = Communicator.Instance.Movesets[wmc.NewMset].ANBAddress;
                            }

                            en.Add(wmc.SingleRef, writeTo);
                        }
                        //Moveset other = Communicator.Instance.Movesets[wmc.NewMset];
                        //foreach(var item in m.AddressReferences)
                        //{
                        //    en.Add(item, other.ANBAddress);
                        //}
                    }
                    else if (cha is AnimEffectBoneChange)
                    {
                        AnimEffectBoneChange aebc = (AnimEffectBoneChange)cha;
                        Moveset oth = Communicator.Instance.Movesets[aebc.FromMset];
                        if (aebc.type == TypeOfChange.eAnimation)
                        {
                            en.Add(m.Animation.Address, oth.Animation.Value);
                        }
                        else if (aebc.type == TypeOfChange.eEffect)
                        {
                            en.Add(m.Effect.Address, oth.Effect.Value);
                        }
                        else if (aebc.type == TypeOfChange.eBoneStructure)
                        {
                            en.Add(m.Effect.BoneStructure.Address, oth.Effect.BoneStructure.Value);
                        }
                    }
                    else if (cha is EffectDataChange)
                    {
                        EffectDataChange edc = (EffectDataChange)cha;
                        en.Add(m.Effect.DataModifiers[edc.LineNumber].Address, edc.NewValue);
                    }
                }
            }
            return(en);
        }
        //public void Show(Change ch, int index)
        //{
        //    _selectedChange = ch;
        //    Show(index);
        //    if (_selectedChange is WholeMovesetChange)
        //    {
        //        stackPFromMset.Visibility = Visibility.Visible;
        //        stackPbaselinemod.Visibility = Visibility.Collapsed;
        //        stackPValue.Visibility = Visibility.Collapsed;
        //        comboSelect.SelectedIndex = 0;
        //        comboMset.SelectedIndex =
        //    }
        //}

        private void btnSave_Click(object sender, RoutedEventArgs e)
        {
            ObservableCollection <Change> testIfExists;

            Communicator.Instance.Changelog.ListOfChanges.TryGetValue(_index, out testIfExists);
            if (testIfExists == null)
            {
                Communicator.Instance.Changelog.ListOfChanges.Add(_index, new ObservableCollection <Change>());
            }

            switch (comboSelect.SelectedIndex)
            {
            case 0:
                WholeMovesetChange c = new WholeMovesetChange();
                c.ChangeNum = Communicator.Instance.Changelog.GetNextChangeId;
                c.OldMset   = _index;
                if (chkUseFAKEValue.IsChecked == true)
                {
                    c.NewMset = -1;
                }
                else
                {
                    c.NewMset = comboMset.SelectedIndex;
                }

                if (radioAll.IsChecked == true)
                {
                    c.TypeOfRef = TypeOfWhole.eAll;
                }
                else
                {
                    c.TypeOfRef = TypeOfWhole.eSingle;
                    c.SingleRef = _originalMset.AddressReferences[comboRef.SelectedIndex];
                }

                Communicator.Instance.Changelog.ListOfChanges[_index].Add(c);
                break;

            case 1:
            case 2:
            case 3:
                AnimEffectBoneChange c2 = new AnimEffectBoneChange();
                c2.ChangeNum = Communicator.Instance.Changelog.GetNextChangeId;
                c2.FromMset  = comboMset.SelectedIndex;
                if (comboSelect.SelectedIndex == 1)
                {
                    c2.type = TypeOfChange.eAnimation;
                }
                else if (comboSelect.SelectedIndex == 2)
                {
                    c2.type = TypeOfChange.eEffect;
                }
                else if (comboSelect.SelectedIndex == 3)
                {
                    c2.type = TypeOfChange.eBoneStructure;
                }
                Communicator.Instance.Changelog.ListOfChanges[_index].Add(c2);
                break;

            case 4:
                EffectDataChange c3 = new EffectDataChange();
                c3.ChangeNum  = Communicator.Instance.Changelog.GetNextChangeId;
                c3.LineNumber = comboEffectData.SelectedIndex;
                c3.NewValue   = Convert.ToInt32(txtValue.Text, 16);
                Communicator.Instance.Changelog.ListOfChanges[_index].Add(c3);
                break;
            }
            Close();
        }