public void EditDictionarySyntax()
 {
     DialogResult res;
     MoveDefEventNode e = _resource as MoveDefEventNode;
     long ev = e._event;
     MoveDefEntryNode temp = new MoveDefEntryNode();
     if (MoveDefNode.EventDictionary.ContainsKey(ev))
         temp.Name = MoveDefNode.EventDictionary[ev]._syntax;
     else
         temp.Name = "";
     using (RenameDialog dlg = new RenameDialog()) { res = dlg.ShowDialog(MainForm.Instance, temp); }
     if (res == DialogResult.OK)
     {
         if (MoveDefNode.EventDictionary.ContainsKey(ev))
             MoveDefNode.EventDictionary[ev]._syntax = temp.Name;
         else
             MoveDefNode.EventDictionary.Add(ev, new ActionEventInfo() { Params = new string[_resource.Children.Count], pDescs = new string[_resource.Children.Count], _syntax = temp.Name, idNumber = ev });
         MoveDefNode._dictionaryChanged = true;
     }
     temp.Dispose();
     temp = null;
 }
 public void EditDictionaryName()
 {
     DialogResult res;
     MoveDefEventParameterNode e = _resource as MoveDefEventParameterNode;
     uint ev = (e.Parent as MoveDefEventNode)._event;
     MoveDefEntryNode temp = new MoveDefEntryNode();
     if (MoveDefNode.EventDictionary.ContainsKey(ev))
         temp.Name = MoveDefNode.EventDictionary[ev].Params[_resource.Index];
     else
         temp.Name = "";
     using (RenameDialog dlg = new RenameDialog()) { res = dlg.ShowDialog(MainForm.Instance, temp); }
     if (res == DialogResult.OK)
     {
         if (!MoveDefNode.EventDictionary.ContainsKey(ev))
             MoveDefNode.EventDictionary.Add(ev, new ActionEventInfo() { Params = new string[_resource.Parent.Children.Count], pDescs = new string[_resource.Parent.Children.Count], idNumber = ev });
         MoveDefNode.EventDictionary[ev].Params[_resource.Index] = temp.Name;
         MoveDefNode._dictionaryChanged = true;
         foreach (MoveDefEventNode n in e.Root._events[ev])
         {
             n.Children[_resource.Index].Name = temp.Name;
             n.Children[_resource.Index].HasChanged = false;
         }
     }
     temp.Dispose();
     temp = null;
 }
Exemplo n.º 3
0
        public static int Rebuild(MoveDefNode root, MoveDefEntryNode node, ref VoidPtr dataAddress, VoidPtr baseAddress)
        {
            if (node != null)
            {
                if (!(node.External && !(node._extNode is MoveDefReferenceEntryNode)))
                {
                    node.Rebuild(dataAddress, node._calcSize, true);
                    dataAddress += node._calcSize;

                    if (node._lookupOffsets.Count != node._lookupCount && !(node is MoveDefActionNode))
                        Console.WriteLine(node.TreePath + (node._lookupCount - node._lookupOffsets.Count));

                    MoveDefNode._lookupOffsets.AddRange(node._lookupOffsets.ToArray());
                }
                MoveDefEntryNode next = node;
            Top:
                //Check for random params around the file
                if (next.Parent is MoveDefDataNode)
                    if (next.Parent.Children.Count > next.Index + 1)
                        if ((next = next.Parent.Children[next.Index + 1] as MoveDefEntryNode) is MoveDefCharSpecificNode || (next is MoveDefRawDataNode && next.Children.Count > 0 && next.Children[0] is MoveDefSectionParamNode))
                        {
                            if (!(next is MoveDefRawDataNode))
                            {
                                next.Rebuild(dataAddress, next._calcSize, true);
                                MoveDefNode._lookupOffsets.AddRange(next._lookupOffsets.ToArray());
                                dataAddress += next._calcSize;

                                if (next._lookupCount != next._lookupOffsets.Count)
                                    Console.WriteLine();
                            }
                            else
                            {
                                next._entryOffset = dataAddress;
                                foreach (MoveDefSectionParamNode p in next.Children)
                                {
                                    p.Rebuild(dataAddress, p.AttributeBuffer.Length, true);
                                    dataAddress += p.AttributeBuffer.Length;
                                }
                            }
                            goto Top;
                        }
                return node._rebuildOffset;
            }
            else return 0;
        }
Exemplo n.º 4
0
        protected override void OnPopulate()
        {
            #region Populate
            if (ARCNode.SpecialName.Contains(RootNode.Name) && RootNode.Name != "Fighter")
            {
                int        commonActionFlagsCount = 0;
                int        actionFlagsCount       = 0;
                int        totalActionCount       = 0;
                List <int> ActionOffsets;

                MoveDefActionListNode subActions = new MoveDefActionListNode()
                {
                    _name = "SubAction Scripts", _parent = this
                }, actions = new MoveDefActionListNode()
                {
                    _name = "Action Scripts", _parent = this
                };

                bint *actionOffset;

                //Parse offsets first
                for (int i = 9; i < 11; i++)
                {
                    actionOffset  = (bint *)(BaseAddress + specialOffsets[i].Offset);
                    ActionOffsets = new List <int>();
                    for (int x = 0; x < specialOffsets[i].Size / 4; x++)
                    {
                        ActionOffsets.Add(actionOffset[x]);
                    }
                    actions.ActionOffsets.Add(ActionOffsets);
                }
                for (int i = 12; i < 16; i++)
                {
                    actionOffset  = (bint *)(BaseAddress + specialOffsets[i].Offset);
                    ActionOffsets = new List <int>();
                    for (int x = 0; x < specialOffsets[i].Size / 4; x++)
                    {
                        ActionOffsets.Add(actionOffset[x]);
                    }
                    subActions.ActionOffsets.Add(ActionOffsets);
                }

                if (specialOffsets[4].Size != 0)
                {
                    (misc = new MoveDefMiscNode("Misc Section")
                    {
                        offsetID = 4
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[4].Offset, 0));
                }

                int amt = 0;

                //The only way to compute the amount of extra offsets is broken by PSA.
                //Using the exact amount will work for now until REL editing is available.
                switch (RootNode.Name)
                {
                case "FitZakoBall":
                case "FitZakoBoy":
                case "FitZakoGirl":
                case "FitZakoChild":
                    amt = 1; break;

                case "FitPurin":
                    amt = 3; break;

                case "FitKoopa":
                case "FitMetaknight":
                    amt = 5; break;

                case "FitGanon":
                case "FitGKoopa":
                case "FitMarth":
                    amt = 6; break;

                case "FitPokeFushigisou":
                    amt = 7; break;

                case "FitCaptain":
                case "FitIke":
                case "FitLuigi":
                case "FitPokeLizardon":
                case "FitPokeTrainer":
                case "FitPokeZenigame":
                case "FitSonic":
                    amt = 8; break;

                case "FitDonkey":
                case "FitSheik":
                case "FitWarioMan":
                    amt = 9; break;

                case "FitMario":
                case "FitWario":
                case "FitZelda":
                    amt = 10; break;

                case "FitFalco":
                case "FitLucario":
                case "FitPikachu":
                    amt = 11; break;

                case "FitSZerosuit":
                    amt = 12; break;

                case "FitDiddy":
                case "FitFox":
                case "FitLucas":
                case "FitPikmin":
                case "FitPit":
                case "FitWolf":
                case "FitYoshi":
                    amt = 13; break;

                case "FitNess":
                case "FitPeach":
                case "FitRobot":
                    amt = 14; break;

                case "FitDedede":
                case "FitGameWatch":
                    amt = 16; break;

                case "FitPopo":
                    amt = 18; break;

                case "FitLink":
                case "FitSnake":
                case "FitToonLink":
                    amt = 20; break;

                case "FitSamus":
                    amt = 22; break;

                case "FitKirby":
                    amt = 68; break;

                default:     //Only works on movesets untouched by PSA
                    amt = (Size - 124) / 4; break;
                }

                bint *sPtr = (bint *)(BaseAddress + _offset + 124);
                for (int i = 0; i < amt; i++)
                {
                    _extraOffsets.Add(*sPtr++);
                }

                (attributes = new MoveDefAttributeNode("Attributes")
                {
                    offsetID = 2
                }).Initialize(this, new DataSource(BaseAddress + 0, 0x2E4));
                (sseAttributes = new MoveDefAttributeNode("SSE Attributes")
                {
                    offsetID = 3
                }).Initialize(this, new DataSource(BaseAddress + 0x2E4, 0x2E4));
                if (specialOffsets[5].Size != 0)
                {
                    (commonActionFlags = new MoveDefActionFlagsNode("Common Action Flags", commonActionFlagsCount = ((Unknown7 - CommonActionFlagsStart) / 16))
                    {
                        offsetID = 5
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[5].Offset, commonActionFlagsCount * 16));
                }
                if (specialOffsets[6].Size != 0)
                {
                    (actionFlags = new MoveDefActionFlagsNode("Action Flags", actionFlagsCount = ((EntryActionsStart - ActionFlagsStart) / 16))
                    {
                        offsetID = 6
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[6].Offset, actionFlagsCount * 16));
                }
                totalActionCount = commonActionFlagsCount + actionFlagsCount;
                if (specialOffsets[7].Size != 0)
                {
                    (unk7 = new MoveDefUnk7Node(totalActionCount)
                    {
                        offsetID = 7
                    }).Initialize(this, BaseAddress + specialOffsets[7].Offset, totalActionCount * 8);
                }
                if (specialOffsets[9].Size != 0 || specialOffsets[10].Size != 0)
                {
                    int count;
                    if (specialOffsets[9].Size == 0)
                    {
                        count = specialOffsets[10].Size / 4;
                    }
                    else
                    {
                        count = specialOffsets[9].Size / 4;
                    }

                    //Initialize using first offset so the node is sorted correctly
                    actions.Initialize(this, BaseAddress + specialOffsets[9].Offset, 0);

                    //Set up groups
                    for (int i = 0; i < count; i++)
                    {
                        actions.AddChild(new MoveDefActionGroupNode()
                        {
                            _name = "Action" + (i + 274)
                        }, false);
                    }

                    //Add children
                    for (int i = 0; i < 2; i++)
                    {
                        if (specialOffsets[i + 9].Size != 0)
                        {
                            PopulateActionGroup(actions, actions.ActionOffsets[i], false, i);
                        }
                    }

                    //Add to children (because the parent was set before initialization)
                    Children.Add(actions);

                    //actions.Children.Sort(MoveDefEntryNode.ActionCompare);

                    Root._actions = actions;
                }
                if (specialOffsets[11].Size != 0)
                {
                    (actionPre = new MoveDefActionPreNode(totalActionCount)).Initialize(this, new DataSource(BaseAddress + specialOffsets[11].Offset, totalActionCount * 4));
                }
                if (specialOffsets[0].Size != 0)
                {
                    (_animFlags = new MoveDefFlagsNode()
                    {
                        offsetID = 0, _parent = this
                    }).Initialize(this, BaseAddress + specialOffsets[0].Offset, specialOffsets[0].Size);
                }
                if (specialOffsets[12].Size != 0 || specialOffsets[13].Size != 0 || specialOffsets[14].Size != 0 || specialOffsets[15].Size != 0)
                {
                    string name;
                    int    count = 0;
                    for (int i = 0; i < 4; i++)
                    {
                        if (specialOffsets[i + 12].Size != 0)
                        {
                            count = specialOffsets[i + 12].Size / 4;
                            break;
                        }
                    }

                    //Initialize using first offset so the node is sorted correctly
                    subActions.Initialize(this, BaseAddress + specialOffsets[12].Offset, 0);

                    //Set up groups
                    for (int i = 0; i < count; i++)
                    {
                        if (_animFlags._names.Count > i && _animFlags._flags[i]._stringOffset > 0)
                        {
                            name = _animFlags._names[i];
                        }
                        else
                        {
                            name = "<null>";
                        }
                        subActions.AddChild(new MoveDefSubActionGroupNode()
                        {
                            _name = name, _flags = _animFlags._flags[i]._Flags, _inTransTime = _animFlags._flags[i]._InTranslationTime
                        }, false);
                    }

                    //Add children
                    for (int i = 0; i < 4; i++)
                    {
                        if (specialOffsets[i + 12].Size != 0)
                        {
                            PopulateActionGroup(subActions, subActions.ActionOffsets[i], true, i);
                        }
                    }

                    //Add to children (because the parent was set before initialization)
                    Children.Add(subActions);

                    Root._subActions = subActions;
                }
                if (specialOffsets[1].Size != 0)
                {
                    (mdlVisibility = new MoveDefModelVisibilityNode()
                    {
                        offsetID = 1
                    }).Initialize(this, BaseAddress + specialOffsets[1].Offset, 0);
                }
                if (specialOffsets[19].Size != 0)
                {
                    (boneRef2 = new MoveDefBoneRef2Node()
                    {
                        offsetID = 19
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[19].Offset, 0));
                }
                if (specialOffsets[24].Size != 0)
                {
                    (unk24 = new MoveDefUnk24Node()
                    {
                        offsetID = 24
                    }).Initialize(this, BaseAddress + specialOffsets[24].Offset, 8);
                }
                if (specialOffsets[22].Size != 0)
                {
                    (unk22 = new MoveDefUnk22Node()
                    {
                        offsetID = 22
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[22].Offset, 0));
                }
                if (specialOffsets[25].Size != 0)
                {
                    (staticArticles = new MoveDefStaticArticleGroupNode()
                    {
                        _name = "Static Articles", offsetID = 25
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[25].Offset, 8));
                }
                if (specialOffsets[26].Size != 0)
                {
                    (entryArticle = new MoveDefArticleNode()
                    {
                        Static = true, _name = "Entry Article", offsetID = 26
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[26].Offset, 0));
                }
                if (specialOffsets[8].Size != 0)
                {
                    (actionInterrupts = new MoveDefActionInterruptsNode()
                    {
                        offsetID = 8
                    }).Initialize(this, BaseAddress + specialOffsets[8].Offset, 8);
                }
                if (specialOffsets[16].Size != 0)
                {
                    (boneFloats1 = new MoveDefUnk17Node()
                    {
                        _name = "Bone Floats 1", offsetID = 16
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[16].Offset, 0));
                }
                if (specialOffsets[17].Size != 0)
                {
                    (boneFloats2 = new MoveDefUnk17Node()
                    {
                        _name = "Bone Floats 2", offsetID = 17
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[17].Offset, 0));
                }
                if (specialOffsets[23].Size != 0)
                {
                    (boneFloats3 = new MoveDefUnk17Node()
                    {
                        _name = "Bone Floats 3", offsetID = 23
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[23].Offset, 0));
                }
                if (specialOffsets[18].Size != 0)
                {
                    (boneRef1 = new MoveDefBoneIndicesNode("Bone References", (misc.BoneRefOffset - specialOffsets[18].Offset) / 4)
                    {
                        offsetID = 18
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[18].Offset, 0));
                }
                if (specialOffsets[20].Size != 0)
                {
                    (override1 = new MoveDefActionOverrideNode()
                    {
                        offsetID = 20
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[20].Offset, 0));
                }
                if (specialOffsets[21].Size != 0)
                {
                    (override2 = new MoveDefActionOverrideNode()
                    {
                        offsetID = 21
                    }).Initialize(this, new DataSource(BaseAddress + specialOffsets[21].Offset, 0));
                }

                //These offsets follow no patterns
                int y = 0;
                MoveDefExternalNode ext = null;
                foreach (int DataOffset in _extraOffsets)
                {
                    if (y == 2 && RootNode.Name == "FitPokeTrainer")
                    {
                        MoveDefSoundDatasNode p = new MoveDefSoundDatasNode()
                        {
                            isExtra = true, _name = "Sound Data 2"
                        };
                        p.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(p);
                    }
                    else if (y == 49 && RootNode.Name == "FitKirby")
                    {
                        //6 offsets
                        //that point to:
                        //2 offsets
                        //that point to:
                        //sectionparamnode
                    }
                    else if (y == 50 && RootNode.Name == "FitKirby")
                    {
                        //6 offsets
                        //that point to:
                        //offset
                        //count
                        //align to 0x10
                        //that points to list of:
                        //offset
                        //align list to 0x10
                        //that points to:
                        //offset
                        //count
                        //offset (sometimes 0)
                        //count (sometimes 0)
                        //that points to list of:
                        //offset
                        //count
                        //align list to 0x10
                        //that points to:
                        //int value
                    }
                    else if ((y == 51 || y == 52) && RootNode.Name == "FitKirby")
                    {
                        //6 offsets
                        //that point to:
                        //sectionparamnode
                    }
                    else if ((y == 7 && RootNode.Name == "FitPit") || (y == 13 && RootNode.Name == "FitRobot"))
                    {
                        Pit7Robot13Node p = new Pit7Robot13Node()
                        {
                            isExtra = true, offsetID = y
                        };
                        p.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(p);
                    }
                    else if (y == 8 && RootNode.Name == "FitLucario")
                    {
                        HitDataListOffsetNode p = new HitDataListOffsetNode()
                        {
                            isExtra = true, _name = "HitDataList" + y, offsetID = y
                        };
                        p.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(p);
                    }
                    else if (y > 9 && RootNode.Name == "FitYoshi")
                    {
                        Yoshi9 p = new Yoshi9()
                        {
                            isExtra = true, offsetID = y
                        };
                        p.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(p);
                    }
                    else if (
                        (y == 56 && RootNode.Name == "FitKirby") ||
                        (y == 7 && RootNode.Name == "FitLink") ||
                        (y == 8 && RootNode.Name == "FitPeach") ||
                        (y == 4 && RootNode.Name == "FitPit") ||
                        (y == 7 && RootNode.Name == "FitToonLink"))
                    {
                        MoveDefHitDataListNode p = new MoveDefHitDataListNode()
                        {
                            isExtra = true, _name = "HitDataList" + y, offsetID = y
                        };
                        p.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(p);
                    }
                    else if (y == 6 && RootNode.Name.StartsWith("FitWario"))
                    {
                        warioParams6 = new Wario6()
                        {
                            isExtra = true, offsetID = y
                        };
                        warioParams6.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(warioParams6);
                    }
                    else if (y == 8 && RootNode.Name.StartsWith("FitWario"))
                    {
                        Wario8 p = new Wario8()
                        {
                            isExtra = true, offsetID = y
                        };
                        p.Initialize(this, new DataSource(BaseAddress + DataOffset, 0));
                        _extraEntries.Add(p);
                    }
                    else if (y == 8 && RootNode.Name == "FitSZerosuit")
                    {
                        (zssParams8 = new SZerosuitExtraParams8Node()
                        {
                            isExtra = true, offsetID = y
                        }).Initialize(this, BaseAddress + DataOffset, 32);
                        _extraEntries.Add(zssParams8);
                    }
                    else if (y < 4 && RootNode.Name == "FitPopo")
                    {
                        _extraEntries.Add(null);

                        if (y == 0)
                        {
                            nanaSubActions = new MoveDefActionListNode()
                            {
                                _name = "Nana SubAction Scripts", isExtra = true
                            }
                        }
                        ;

                        actionOffset  = (bint *)(BaseAddress + DataOffset);
                        ActionOffsets = new List <int>();
                        for (int x = 0; x < Root.GetSize(DataOffset) / 4; x++)
                        {
                            ActionOffsets.Add(actionOffset[x]);
                        }
                        nanaSubActions.ActionOffsets.Add(ActionOffsets);

                        if (y == 3)
                        {
                            string name;
                            int    count = 0;
                            for (int i = 0; i < 4; i++)
                            {
                                if ((count = Root.GetSize(DataOffset) / 4) > 0)
                                {
                                    break;
                                }
                            }

                            //Initialize using first offset so the node is sorted correctly
                            nanaSubActions.Initialize(this, BaseAddress + _extraOffsets[0], 0);

                            //Set up groups
                            for (int i = 0; i < count; i++)
                            {
                                if (_animFlags._names.Count > i && _animFlags._flags[i]._stringOffset > 0)
                                {
                                    name = _animFlags._names[i];
                                }
                                else
                                {
                                    name = "<null>";
                                }
                                nanaSubActions.AddChild(new MoveDefSubActionGroupNode()
                                {
                                    _name = name, _flags = _animFlags._flags[i]._Flags, _inTransTime = _animFlags._flags[i]._InTranslationTime
                                }, false);
                            }

                            //Add children
                            for (int i = 0; i < 4; i++)
                            {
                                PopulateActionGroup(nanaSubActions, nanaSubActions.ActionOffsets[i], true, i);
                            }
                        }
                    }
                    else if (y == 10 && RootNode.Name == "FitPopo")
                    {
                        (nanaSoundData = new MoveDefSoundDatasNode()
                        {
                            _name = "Nana Sound Data", isExtra = true
                        }).Initialize(this, (VoidPtr)Header + 124 + y * 4, 8);
                        _extraEntries.Add(null);
                    }
                    else
                    {
                        if (DataOffset > Root.dataSize) //probably flags or float
                        {
                            continue;
                        }

                        ext = null;
                        if (DataOffset > 1480) //I don't think a count would be greater than this
                        {
                            MoveDefEntryNode entry = null;
                            if ((ext = Root.IsExternal(DataOffset)) != null)
                            {
                                if (ext.Name.StartsWith("param"))
                                {
                                    int o = 0;
                                    if (y < _extraOffsets.Count - 1 && (o = _extraOffsets[y + 1]) < 1480 && o > 1)
                                    {
                                        MoveDefRawDataNode d = new MoveDefRawDataNode("ExtraParams" + y)
                                        {
                                            offsetID = y, isExtra = true
                                        };
                                        d.Initialize(this, BaseAddress + DataOffset, 0);
                                        for (int i = 0; i < o; i++)
                                        {
                                            new MoveDefSectionParamNode()
                                            {
                                                _name = "Part" + i, _extOverride = i == 0
                                            }
                                        }
Exemplo n.º 5
0
        public static int GetSize(MoveDefEntryNode node, ref int lookupCount)
        {
            if (node != null)
            {
                int size = 0;
                if (!(node.External && !(node._extNode is MoveDefReferenceEntryNode)))
                {
                    node._lookupOffsets = new List<int>();

                    if ((node.Parent is MoveDefDataNode || node.Parent is MoveDefMiscNode) && !node.isExtra)
                        lookupCount++;

                    size = node.CalculateSize(true);
                    lookupCount += node._lookupCount;
                }
                MoveDefEntryNode next = node;
            Top:
                //Check for random params around the file
                if (next.Parent is MoveDefDataNode)
                    if (next.Parent.Children.Count > next.Index + 1)
                        if ((next = next.Parent.Children[next.Index + 1] as MoveDefEntryNode) is MoveDefCharSpecificNode || (next is MoveDefRawDataNode && next.Children.Count > 0 && next.Children[0] is MoveDefSectionParamNode))
                        {
                            if (!(next is MoveDefRawDataNode))
                            {
                                size += next.CalculateSize(true);
                                lookupCount += next._lookupCount;
                            }
                            else
                                foreach (MoveDefSectionParamNode p in next.Children)
                                    size += p.CalculateSize(true);
                            goto Top;
                        }

                return size;
            }
            else return 0;
        }