Esempio n. 1
0
        private void toggleDropdownMenu()
        {
            if (dropdownMenu == null) {
                dropdownMenu = new PopupMenu(new Vector2(rect.x + PADDING + getPosition(dropdownMenuButton).x, rect.y + rect.height + BUTTON_SPACING));

                bool regularEntriesEnabled = rectLocked && buttonOrderLocked;

                Button visibleButtonsButton = Button.createMenuOption("Configure Visible Buttons...");
                visibleButtonsButton.command.Enabled = regularEntriesEnabled && (visibleButtonsSelector == null);
                visibleButtonsButton.OnClick += (e) => {
                    toggleVisibleButtonsSelector();
                };
                dropdownMenu += visibleButtonsButton;

                dropdownMenu += Separator.Instance;

                Button toggleRectLockButton = Button.createMenuOption(rectLocked ? "Unlock Position and Size" : "Lock Position and Size");
                toggleRectLockButton.OnClick += (e) => {
                    rectLocked = !rectLocked;
                    draggable.Enabled = !rectLocked;
                    resizable.Enabled = !rectLocked;

                    if (rectLocked) {
                        fireChange();
                    } else {
                        autoHide = false;
                        foreach (Toolbar folder in folders.Values) {
                            folder.Visible = false;
                        }
                        if (visibleButtonsSelector != null) {
                            visibleButtonsSelector.destroy();
                        }
                    }
                };
                toggleRectLockButton.command.Enabled = buttonOrderLocked;
                dropdownMenu += toggleRectLockButton;

                Button toggleButtonOrderLockButton = Button.createMenuOption(buttonOrderLocked ? "Unlock Button Order" : "Lock Button Order");
                toggleButtonOrderLockButton.OnClick += (e) => {
                    buttonOrderLocked = !buttonOrderLocked;

                    hookButtonOrderDraggables(!buttonOrderLocked);

                    if (buttonOrderLocked) {
                        fireChange();
                    } else {
                        autoHide = false;
                    }
                    foreach (Toolbar folder in folders.Values) {
                        folder.Enabled = buttonOrderLocked;
                    }
                    if (visibleButtonsSelector != null) {
                        visibleButtonsSelector.destroy();
                    }
                };
                toggleButtonOrderLockButton.command.Enabled = rectLocked;
                dropdownMenu += toggleButtonOrderLockButton;

                Button toggleAutoHideButton = Button.createMenuOption(autoHide ? "Deactivate Auto-Hide at Screen Edge" : "Activate Auto-Hide at Screen Edge");
                toggleAutoHideButton.OnClick += (e) => {
                    autoHide = !autoHide;
                    fireChange();
                };
                toggleAutoHideButton.command.Enabled = regularEntriesEnabled && (autoHide || AtScreenEdge);
                dropdownMenu += toggleAutoHideButton;

                Button toggleDrawBorderButton = Button.createMenuOption(showBorder ? "Hide Border" : "Show Border");
                toggleDrawBorderButton.OnClick += (e) => {
                    showBorder = !showBorder;
                    foreach (Toolbar folder in folders.Values) {
                        folder.showBorder = showBorder;
                    }
                    fireChange();
                };
                toggleDrawBorderButton.command.Enabled = regularEntriesEnabled;
                dropdownMenu += toggleDrawBorderButton;

                Button toggleKSPSkinButton = Button.createMenuOption(UseKSPSkin ? "Use Unity 'Smoke' Skin" : "Use KSP Skin");
                toggleKSPSkinButton.OnClick += (e) => {
                    UseKSPSkin = !UseKSPSkin;
                    foreach (Toolbar folder in folders.Values) {
                        folder.UseKSPSkin = UseKSPSkin;
                    }
                    fireChange();
                };
                toggleKSPSkinButton.command.Enabled = regularEntriesEnabled;
                dropdownMenu += toggleKSPSkinButton;

                dropdownMenu += Separator.Instance;

                Button createFolderButton = Button.createMenuOption("Create New Folder...");
                createFolderButton.OnClick += (e) => createFolder();
                createFolderButton.command.Enabled = regularEntriesEnabled;
                dropdownMenu += createFolderButton;

                dropdownMenu += Separator.Instance;

                Button createToolbarButton = Button.createMenuOption("Create New Toolbar");
                createToolbarButton.OnClick += (e) => createToolbar();
                createToolbarButton.command.Enabled = regularEntriesEnabled;
                dropdownMenu += createToolbarButton;

                Button deleteToolbarButton = Button.createMenuOption("Delete Toolbar...");
                deleteToolbarButton.OnClick += (e) => deleteToolbar();
                deleteToolbarButton.command.Enabled = regularEntriesEnabled && (ToolbarManager.InternalInstance.ToolbarsCount > 1);
                dropdownMenu += deleteToolbarButton;

                dropdownMenu += Separator.Instance;

                Button aboutButton = Button.createMenuOption("About the Toolbar Plugin...");
                aboutButton.OnClick += (e) => Application.OpenURL(ToolbarManager.FORUM_THREAD_URL);
                dropdownMenu += aboutButton;

                dropdownMenu.OnAnyOptionClicked += () => {
                    dropdownMenu.destroy();
                    dropdownMenu = null;
                };
            } else {
                dropdownMenu.destroy();
                dropdownMenu = null;
            }
        }
Esempio n. 2
0
        private void openFolderButtonDropdownMenu(Toolbar folder, Vector2 pos)
        {
            dropdownMenu = new PopupMenu(pos);

            Button editButton = Button.createMenuOption("Edit Folder Settings");
            editButton.OnClick += (e) => editFolder(folder);
            dropdownMenu += editButton;

            Button deleteButton = Button.createMenuOption("Delete Folder");
            deleteButton.OnClick += (e) => deleteFolder(folder);
            dropdownMenu += deleteButton;

            dropdownMenu.OnAnyOptionClicked += () => {
                dropdownMenu.destroy();
                dropdownMenu = null;
            };
        }