private void BTN_pEvent_Click(object sender, EventArgs e)
        {
            Int32 Index = -1;

            if (r0.Checked) Index = 0;
            else if (r1.Checked) Index = 1;
            else if (r2.Checked) Index = 2;

            PeventEditor dlg = new PeventEditor(tiles[Index].pEvent, ressources.Sprites, ressources.Classes);
            dlg.ReadOnly();
            dlg.ShowDialog();
        }
Esempio n. 2
0
        private void EditEvent(Int32 X, Int32 Y)
        {
            if (!(X < PN_Map.Width - 1 && X > 0 && Y < PN_Map.Height - 1 && Y > 0)) return;

            Int32 l = CurrentLayer;
            Int32 x = X / Prefs.Map.TileSize.Width;
            Int32 y = Y / Prefs.Map.TileSize.Width;

            if (CurrentMap.Tiles[l, x, y].pEvent == null)
            {
                if (DraggingPevent != null)
                {
                    CurrentMap.Tiles[l, x, y].pEvent = DraggingPevent.Clone() as Pevent;
                    if (!((Control.ModifierKeys & Keys.Control) > 0)) CurrentMap.Tiles[l, DraggingPevent.Position.X, DraggingPevent.Position.Y].pEvent = null;

                    CurrentMap.Tiles[l, x, y].pEvent.Position = new System.Drawing.Point(x, y);
                }
                else
                {
                    PeventEditor dlg = new PeventEditor(new System.Drawing.Point(x, y), Project.Ressources.Sprites, Project.Ressources.Classes, new System.Drawing.Size(MapSize.Width, MapSize.Height));
                    dlg.ShowDialog();

                    if (dlg.HasAccepted)
                    {
                        CurrentMap.Tiles[l, x, y].pEvent = dlg.pEvent;
                    }
                    else if (dlg.HasDeleted)
                    {
                        CurrentMap.Tiles[l, x, y].pEvent = null;
                    }
                }
            }
            else
            {
                if (DraggingPevent != null && DraggingPevent.Position == CurrentMap.Tiles[l, x, y].pEvent.Position) DraggingPevent = null;

                if (DraggingPevent != null)
                {
                    CurrentMap.Tiles[l, DraggingPevent.Position.X, DraggingPevent.Position.Y].pEvent = CurrentMap.Tiles[l, x, y].pEvent.Clone() as Pevent;
                    CurrentMap.Tiles[l, DraggingPevent.Position.X, DraggingPevent.Position.Y].pEvent.Position = new System.Drawing.Point(DraggingPevent.Position.X, DraggingPevent.Position.Y);

                    CurrentMap.Tiles[l, x, y].pEvent = DraggingPevent.Clone() as Pevent;
                    CurrentMap.Tiles[l, x, y].pEvent.Position = new System.Drawing.Point(x, y);
                }
                else
                {
                    PeventEditor dlg = new PeventEditor(CurrentMap.Tiles[l, x, y].pEvent, Project.Ressources.Sprites, Project.Ressources.Classes);
                    dlg.ShowDialog();

                    if (dlg.HasAccepted) CurrentMap.Tiles[l, x, y].pEvent = dlg.pEvent.Clone() as Pevent;
                    else if (dlg.HasDeleted) CurrentMap.Tiles[l, x, y].pEvent = null;
                }
            }

            DraggingPevent = null;
            Refresh();
            DrawMap();
        }