Exemplo n.º 1
0
            protected override void ShowPopupMenu(Gdk.Event ev)
            {
                Gtk.Menu menu = new Gtk.Menu();
                {
                    Gtk.MenuItem item = new Gtk.MenuItem("Add standard warp");
                    menu.Append(item);

                    item.Activated += (sender, args) => {
                        SelectedIndex = WarpGroup.AddWarp(WarpSourceType.Standard);
                    };
                }

                {
                    Gtk.MenuItem item = new Gtk.MenuItem("Add specific-position warp");
                    menu.Append(item);

                    item.Activated += (sender, args) => {
                        SelectedIndex = WarpGroup.AddWarp(WarpSourceType.Pointed);
                    };
                }

                if (HoveringIndex != -1)
                {
                    menu.Append(new Gtk.SeparatorMenuItem());

                    Gtk.MenuItem deleteItem = new Gtk.MenuItem("Delete");
                    deleteItem.Activated += (sender, args) => {
                        if (SelectedIndex != -1)
                        {
                            WarpGroup.RemoveWarp(SelectedIndex);
                        }
                    };
                    menu.Append(deleteItem);
                }

                menu.AttachToWidget(this, null);
                menu.ShowAll();
                menu.PopupAtPointer(ev);
            }
Exemplo n.º 2
0
        void OnClicked(int posX, int posY, Gdk.Event triggerEvent, uint button)
        {
            Cairo.Point p = GetGridPosition(posX, posY, scale: false, offset: false);
            if (EnableTileEditing && hoveringComponent == null)
            {
                if (!IsInBounds(posX, posY, scale: false, offset: false))
                {
                    return;
                }
                if (button == 1)   // Left-click
                {
                    RoomLayout.SetTile(p.X, p.Y, TilesetViewer.SelectedIndex);
                    draggingTile = true;
                }
                else if (button == 3)   // Right-click
                {
                    TilesetViewer.SelectedIndex = RoomLayout.GetTile(p.X, p.Y);
                }
            }
            if (DrawRoomComponents)
            {
                if (hoveringComponent != null)
                {
                    selectedComponent = hoveringComponent;
                    hoveringComponent.Select();

                    if (button == 1)   // Left click
                    {
                        draggingObject = true;
                    }
                    else if (button == 3)   // Right click
                    {
                        Gtk.Menu menu = new Gtk.Menu();

                        foreach (Gtk.MenuItem item in selectedComponent.GetRightClickMenuItems())
                        {
                            menu.Add(item);
                        }

                        RoomComponent comp = selectedComponent;

                        if (comp.Deletable)
                        {
                            if (menu.Children.Length != 0)
                            {
                                menu.Add(new Gtk.SeparatorMenuItem());
                            }

                            var deleteButton = new Gtk.MenuItem("Delete");
                            deleteButton.Activated += (sender, args) => {
                                comp.Delete();
                            };
                            menu.Add(deleteButton);
                        }

                        menu.AttachToWidget(this, null);
                        menu.ShowAll();
                        menu.PopupAtPointer(triggerEvent);
                    }
                }
            }
            QueueDraw();
        }