LynnaLab.WarpSourceGroup.AddWarpSourceData C# (CSharp) Method

AddWarpSourceData() public method

public AddWarpSourceData ( WarpSourceData data ) : void
data WarpSourceData
return void
        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);
            }
        }

Usage Example

示例#1
0
        protected void OnAddWarpButtonClicked(object sender, EventArgs e)
        {
            WarpSourceData data = new WarpSourceData(Project,
                                                     WarpSourceData.WarpCommands[(int)WarpSourceType.StandardWarp],
                                                     WarpSourceData.DefaultValues[(int)WarpSourceType.StandardWarp],
                                                     sourceGroup.FileParser,
                                                     new List <int> {
                -1
            });

            data.Map        = map;
            data.Transition = 4;

            sourceGroup.AddWarpSourceData(data);

            SetWarpIndex((int)indexSpinButton.Adjustment.Upper + 1);
        }