InsertComponentAfter() public method

public InsertComponentAfter ( FileComponent refComponent, FileComponent newComponent, string comment = "" ) : bool
refComponent FileComponent
newComponent FileComponent
comment string
return bool
示例#1
0
        public void InsertObject(int index, ObjectType type)
        {
            if (GetNumObjects() == 0 && !IsIsolated())
            {
                // If this map is sharing data with other maps (as when "blank"), need to make
                // a unique section for this map.

                parser.RemoveLabel(Identifier);

                parser.InsertParseableTextAfter(null, new String[] { "" }); // Newline
                parser.InsertComponentAfter(null, new Label(parser, Identifier));

                ObjectData endData = new ObjectData(Project,
                                                    ObjectCommands[(int)ObjectType.End],
                                                    null,
                                                    parser,
                                                    new string[] { "\t" }, // Tab at start of line
                                                    ObjectType.End);
                parser.InsertComponentAfter(null, endData);
                objectDataList[0] = endData;
            }

            ObjectData data = new ObjectData(Project,
                                             ObjectCommands[(int)type],
                                             null,
                                             parser,
                                             new string[] { "\t" }, // Tab at start of line
                                             type);

            ValueReference.InitializeDataValues(data, data.GetValueReferences());

            if (type >= ObjectType.Pointer && type <= ObjectType.AntiBossPointer)
            {
                data.SetValue(0, "objectData4000"); // Compileable default pointer
            }
            data.InsertIntoParserBefore(objectDataList[index]);
            objectDataList.Insert(index, data);
        }
示例#2
0
        public bool SetNextWarp(WarpSourceData next)
        {
            if (!FileParser.InsertComponentAfter(this, next))
            {
                return(false);
            }

            this.Opcode &= ~0x80;
            if (next.GetNextWarp() == null)
            {
                next.Opcode |= 0x80;
            }
            else
            {
                next.Opcode &= 0x80;
            }
            return(true);
        }
示例#3
0
        // Adds the given data to the end of the group and inserts the data
        // into the FileParser.
        public void AddWarpSourceData(WarpSourceData data)
        {
            if (warpSourceDataList.Contains(data))
            {
                return;
            }

            // Assumes the last element of warpSourceDataList is always the
            // m_WarpSourcesEnd command
            fileParser.InsertComponentBefore(EndData, data);
            warpSourceDataList.Insert(warpSourceDataList.Count - 1, data);

            if (data.WarpSourceType == WarpSourceType.PointerWarp && data.PointerString == ".")
            {
                // Create a unique pointer after m_WarpSourcesEnd
                int    nameIndex = 0;
                string name;
                do
                {
                    name = "customWarpSource" + nameIndex.ToString("d2");
                    nameIndex++;
                }while (Project.HasLabel(name));

                data.PointerString = name;

                Label newLabel = new Label(FileParser, name);
                // Insert label after m_WarpSourcesEnd
                FileParser.InsertComponentAfter(EndData, newLabel);

                // Create a blank PointedData to go after this label
                WarpSourceData pointedData = new WarpSourceData(Project,
                                                                WarpSourceData.WarpCommands[(int)WarpSourceType.PointedWarp],
                                                                WarpSourceData.DefaultValues[(int)WarpSourceType.PointedWarp],
                                                                FileParser,
                                                                new List <int> {
                    -1
                });
                pointedData.Opcode     = 0x80;
                pointedData.Transition = 4;
                FileParser.InsertComponentAfter(newLabel, pointedData);
            }
        }
示例#4
0
        // Adds a new WarpDestData to the end of the group, returns the index
        public WarpDestData AddDestData()
        {
            WarpDestData newData = new WarpDestData(Project,
                                                    WarpDestData.WarpCommand,
                                                    null,
                                                    fileParser, new List <int> {
                -1
            });

            ValueReference.InitializeDataValues(newData, newData.GetValueReferences());

            newData.Transition = 1;

            newData.DestGroup = this;
            newData.DestIndex = warpDestDataList.Count;

            fileParser.InsertComponentAfter(warpDestDataList[warpDestDataList.Count - 1], newData);
            warpDestDataList.Add(newData);

            return(newData);
        }