예제 #1
0
파일: EventForm.cs 프로젝트: jgke/MLLE
        private void ButtonOK_Click(object sender, EventArgs e)
        {
            SafeToCalculate = false;
            if (version == Version.AGA)
            {
                WorkingEvent       = new AGAEvent(0);
                WorkingEvent.ID    = CurrentEventID;
                WriteCycledStrings = WriteCycledValues = 0;
                for (byte i = 0; i < 10; i++)
                {
                    WorkingEvent.Bits[i] = BitBoxes[i].Checked;
                }
                for (byte i = 0; CurrentEvent.Length - 5 > i; i++)
                {
                    if (i < WorkingEvent.Strings.Length)
                    {
                        WorkingEvent.Strings[i] = "";
                    }
                    switch (ParameterInputType[i])
                    {
                    case InputControlType.Textbox:
                        WorkingEvent.Strings[WriteCycledStrings] = ParamTextboxes[i].Text;
                        WriteCycledStrings++;
                        break;

                    case InputControlType.DropdownUsedForStrings:
                        WorkingEvent.Strings[WriteCycledStrings] = (string)ParamDropdowns[i].SelectedItem;
                        WriteCycledStrings++;
                        break;

                    default:
                        WorkingEvent.Longs[WriteCycledValues] = GetParamValue(i);
                        WriteCycledValues++;
                        break;
                    }
                }
                SourceForm.SelectReturnAGAEvent = WorkingEvent;
            }
            else
            {
                var outputEvent = CalculateOutputEvent();
                if (outputEvent != 0)
                { //not a strictly necessary check, I guess, but it feels a little silly keeping track of event 0
                    while (LastUsedEvents.Remove(outputEvent))
                    {
                    }                                              //no duplicates
                    LastUsedEvents.Insert(0, outputEvent);
                    while (LastUsedEvents.Count > 10)
                    {
                        LastUsedEvents.RemoveAt(10);
                    }
                }
                SourceForm.SelectReturnAGAEvent = new AGAEvent(outputEvent);
            }
            Close();
        }
예제 #2
0
파일: EventForm.cs 프로젝트: jgke/MLLE
        public EventForm(Mainframe parent, TreeNode[] nodes, Version theVersion, AGAEvent inputevent, string[][] eventStrings)
        {
            WorkingEvent = inputevent;
            SourceForm   = parent;
            parent.SelectReturnAGAEvent = null;
            version = theVersion;
            LevelSpecificEventStringList = eventStrings;
            InitializeComponent();
            int arrayLength = (version == Version.AGA) ? 24 : 6;

            ParamBoxes = new NumericUpDown[arrayLength]; ParamBoxes[0] = numericUpDown1;
            ParamSoundPlayerButtons = new Button[arrayLength]; ParamSoundPlayerButtons[0] = button1; button1.Tag = numericUpDown1;
            ParamLabels             = new Label[arrayLength]; ParamLabels[0] = label1;
            ParamCheckboxes         = new CheckBox[arrayLength]; ParamCheckboxes[0] = checkBox1;
            ParamDropdowns          = new ComboBox[arrayLength]; ParamDropdowns[0] = comboBox1;
            if (version == Version.AGA)
            {
                BitBoxes       = new CheckBox[] { BitBox1, BitBox2, BitBox3, BitBox4, BitBox5, BitBox6, BitBox7, BitBox8, BitBox9, BitBox10 };
                ParamTextboxes = new TextBox[24]; ParamTextboxes[0] = textBox1;
            }
            else
            {
                textBox1.Dispose();
            }
            CombosPointingToCombos = new Dictionary <ComboBox, List <ComboBox> > {
                { comboBox1, new List <ComboBox>() }
            };
            Tree.Nodes.Add("0", "(none)"); //always present
            Tree.Nodes.AddRange(nodes);
            Tree.Sort();
            if (version != Version.AGA)
            {
                Tree.Sorted = false; //add new things freely in arbitary orders
                if (LastUsedEvents.Count > 0)
                {
                    var recentNodes = new TreeNode("[Recent]");
                    foreach (UInt32 lastEvent in LastUsedEvents)
                    {
                        var node = new TreeNode(SourceForm.NameEvent(lastEvent, "(unknown)"));
                        node.Tag = lastEvent;
                        recentNodes.Nodes.Add(node);
                    }
                    Tree.Nodes.Add(recentNodes);
                }
            }
            ListBox.Size  = Tree.Size;
            FlatEventList = SourceForm.FlatEventLists[SourceForm.J2L.VersionType];
        }
예제 #3
0
        private bool ApplyChanges()
        {
            newrectangle = null;
            lock (DataSource)
            {
                if (DataSource.Width != WidthBox.Value || DataSource.Height != HeightBox.Value)
                {
                    newrectangle = LayerAlign.Show(CurrentLayer, (int)WidthBox.Value - (int)DataSource.Width, (int)HeightBox.Value - (int)DataSource.Height);
                    if (newrectangle == null)
                    {
                        return(false);
                    }
                    SourceForm.Undoable = new Stack <MLLE.Mainframe.LayerAndSpecificTiles>(SourceForm.Undoable.Where(action => action.Layer != DataSource));
                    SourceForm.Redoable = new Stack <MLLE.Mainframe.LayerAndSpecificTiles>(SourceForm.Redoable.Where(action => action.Layer != DataSource));
                }

                DataSource.Width  = (uint)WidthBox.Value;
                DataSource.Height = (uint)HeightBox.Value;
                if (TileWidth.Checked)
                {
                    switch (DataSource.Width % 4)
                    {
                    case 0: DataSource.RealWidth = DataSource.Width; break;

                    case 2: DataSource.RealWidth = DataSource.Width * 2; break;

                    default: DataSource.RealWidth = DataSource.Width * 4; break;
                    }
                }
                else
                {
                    DataSource.RealWidth = DataSource.Width;
                }

                if (newrectangle != null)
                {
                    ArrayMap <ushort> newTileMap = new ArrayMap <ushort>(DataSource.Width, DataSource.Height);
                    for (ushort x = 0; x < DataSource.Width; x++)
                    {
                        for (ushort y = 0; y < DataSource.Height; y++)
                        {
                            newTileMap[x, y] = (
                                x >= -newrectangle[2] &&
                                newrectangle[2] + x < DataSource.TileMap.GetLength(0) &&
                                y >= -newrectangle[0] &&
                                newrectangle[0] + y < DataSource.TileMap.GetLength(1)
                                )
                                ? DataSource.TileMap[newrectangle[2] + x, newrectangle[0] + y]
                                : (ushort)0;
                        }
                    }

                    if (DataSource.id == J2LFile.SpriteLayerID) //sprite layer, i.e. events are associated with this one
                    {
                        if (SourceForm.J2L.VersionType == Version.AGA)
                        {
                            AGAEvent[,] newAGAMap = new AGAEvent[DataSource.Width, DataSource.Height];
                            for (ushort x = 0; x < DataSource.Width; x++)
                            {
                                for (ushort y = 0; y < DataSource.Height; y++)
                                {
                                    newAGAMap[x, y] = (
                                        x >= -newrectangle[2] &&
                                        newrectangle[2] + x < DataSource.TileMap.GetLength(0) &&
                                        y >= -newrectangle[0] &&
                                        newrectangle[0] + y < DataSource.TileMap.GetLength(1)
                                        )
                                        ? SourceForm.J2L.AGA_EventMap[newrectangle[2] + x, newrectangle[0] + y]
                                        : new AGAEvent();
                                }
                            }
                            SourceForm.J2L.AGA_EventMap = newAGAMap;
                        }
                        else
                        {
                            var oldEventMap = SourceForm.J2L.EventMap;
                            uint[,] newEventMap = new uint[DataSource.Width, DataSource.Height];

                            PlusPropertyList rememberPlusEventBasedSettings = new PlusPropertyList(null);
                            rememberPlusEventBasedSettings.ReadFromEventMap(oldEventMap);
                            rememberPlusEventBasedSettings.WriteToEventMap(newEventMap);

                            int oldEventMapRightColumn = oldEventMap.GetLength(0) - 1;
                            int oldEventMapBottomRow   = oldEventMap.GetLength(1) - 1;

                            for (ushort x = 0; x < DataSource.Width; x++)
                            {
                                for (ushort y = 0; y < DataSource.Height - 1; y++)                                           //-1 because events in the bottom row don't work, except for a few events parsed by JJ2+ that were handled above
                                {
                                    newEventMap[x, y] = (
                                        x >= -newrectangle[2] &&
                                        newrectangle[2] + x <= oldEventMapRightColumn &&
                                        y >= -newrectangle[0] &&
                                        newrectangle[0] + y < oldEventMapBottomRow
                                        )
                                        ? oldEventMap[newrectangle[2] + x, newrectangle[0] + y]
                                        : (ushort)0;
                                }
                            }
                            SourceForm.J2L.EventMap = newEventMap;
                        }
                    }
                    DataSource.TileMap = newTileMap;
                }

                DataSource.TileWidth  = TileWidth.Checked;
                DataSource.TileHeight = TileHeight.Checked;
                Single.TryParse(XSpeed.Text, out DataSource.XSpeed);
                Single.TryParse(YSpeed.Text, out DataSource.YSpeed);
                Single.TryParse(AutoXSpeed.Text, out DataSource.AutoXSpeed);
                Single.TryParse(AutoYSpeed.Text, out DataSource.AutoYSpeed);
                Single.TryParse(XOffset.Text, out DataSource.WaveX);
                Single.TryParse(YOffset.Text, out DataSource.WaveY);
                DataSource.LimitVisibleRegion = LimitVisibleRegion.Checked;
                DataSource.IsTextured         = TextureMode.Checked;
                DataSource.HasStars           = Stars.Checked;
                DataSource.TexturParam1       = (byte)Param1.Value;
                DataSource.TexturParam2       = (byte)Param2.Value;
                DataSource.TexturParam3       = (byte)Param3.Value;
                DataSource.TextureMode        = (byte)TextureModeSelect.SelectedIndex;
                DataSource.Name                     = NameBox.Text;
                DataSource.Hidden                   = Hidden.Checked;
                DataSource.SpriteMode               = (byte)SpriteMode.SelectedIndex;
                DataSource.SpriteParam              = (byte)SpriteParam.Value;
                DataSource.RotationAngle            = (int)RotationAngle.Value;
                DataSource.RotationRadiusMultiplier = (int)RotationRadiusMultiplier.Value;
                SourceForm.LevelHasBeenModified     = true;
            }

            return(true);
        }