⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commonmenubar.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        // Create the Mines sub-menu.        submenu = new JMenu(Messages.getString("CommonMenuBar.DeployMinesMenu")); //$NON-NLS-1$        deployMinesConventional = createMenuItem(submenu, Messages.getString("CommonMenuBar.deployMinesConventional"), DeployMinefieldDisplay.DEPLOY_MINE_CONV); //$NON-NLS-1$        deployMinesCommand = createMenuItem(submenu, Messages.getString("CommonMenuBar.deployMinesCommand"), DeployMinefieldDisplay.DEPLOY_MINE_COM); //$NON-NLS-1$        deployMinesVibrabomb = createMenuItem(submenu, Messages.getString("CommonMenuBar.deployMinesVibrabomb"), DeployMinefieldDisplay.DEPLOY_MINE_VIBRA); //$NON-NLS-1$        // Finish off the deploy menu.        deployNext = createMenuItem(menu, Messages.getString("CommonMenuBar.deployNext"), DeploymentDisplay.DEPLOY_NEXT, KeyEvent.VK_N); //$NON-NLS-1$        deployTurn = createMenuItem(menu, Messages.getString("CommonMenuBar.deployTurn"), DeploymentDisplay.DEPLOY_TURN); //$NON-NLS-1$        deployLoad = createMenuItem(menu, Messages.getString("CommonMenuBar.deployLoad"), DeploymentDisplay.DEPLOY_LOAD); //$NON-NLS-1$        deployUnload = createMenuItem(menu, Messages.getString("CommonMenuBar.deployUnload"), DeploymentDisplay.DEPLOY_UNLOAD); //$NON-NLS-1$        deployRemove = createMenuItem(menu, Messages.getString("CommonMenuBar.deployRemove"), DeploymentDisplay.DEPLOY_REMOVE); //$NON-NLS-1$        deployAssaultDrop = createMenuItem(menu, Messages.getString("CommonMenuBar.deployAssaultDrop"), DeploymentDisplay.DEPLOY_ASSAULTDROP); //$NON-NLS-1$        menu.addSeparator();        menu.add(submenu);        // *** Create the move menu.        menu = new JMenu(Messages.getString("CommonMenuBar.MoveMenu")); //$NON-NLS-1$        menu.setMnemonic(KeyEvent.VK_M);        add(menu);        moveWalk = createMenuItem(menu, Messages.getString("CommonMenuBar.moveWalk"), MovementDisplay.MOVE_WALK, KeyEvent.VK_W); //$NON-NLS-1$        moveJump = createMenuItem(menu, Messages.getString("CommonMenuBar.moveJump"), MovementDisplay.MOVE_JUMP, KeyEvent.VK_J); //$NON-NLS-1$        moveSwim = createMenuItem(menu, Messages.getString("CommonMenuBar.moveSwim"), MovementDisplay.MOVE_SWIM, KeyEvent.VK_S); //$NON-NLS-1$        moveBackUp = createMenuItem(menu, Messages.getString("CommonMenuBar.moveBackUp"), MovementDisplay.MOVE_BACK_UP); //$NON-NLS-1$        moveGetUp = createMenuItem(menu, Messages.getString("CommonMenuBar.moveGetUp"), MovementDisplay.MOVE_GET_UP); //$NON-NLS-1$        moveGoProne = createMenuItem(menu, Messages.getString("CommonMenuBar.moveGoProne"), MovementDisplay.MOVE_GO_PRONE); //$NON-NLS-1$        moveTurn = createMenuItem(menu, Messages.getString("CommonMenuBar.moveTurn"), MovementDisplay.MOVE_TURN); //$NON-NLS-1$        moveNext = createMenuItem(menu, Messages.getString("CommonMenuBar.moveNext"), MovementDisplay.MOVE_NEXT, KeyEvent.VK_N); //$NON-NLS-1$        moveRaise = createMenuItem(menu, Messages.getString("CommonMenuBar.moveRaise"), MovementDisplay.MOVE_RAISE_ELEVATION); //$NON-NLS-1$        moveLower = createMenuItem(menu, Messages.getString("CommonMenuBar.moveLower"), MovementDisplay.MOVE_LOWER_ELEVATION); //$NON-NLS-1$        // Create the Special sub-menu.        submenu = new JMenu(Messages.getString("CommonMenuBar.SpecialMenu")); //$NON-NLS-1$        moveLoad = createMenuItem(submenu, Messages.getString("CommonMenuBar.MoveLoad"), MovementDisplay.MOVE_LOAD); //$NON-NLS-1$        moveUnload = createMenuItem(submenu, Messages.getString("CommonMenuBar.MoveUnload"), MovementDisplay.MOVE_UNLOAD); //$NON-NLS-1$        submenu.addSeparator();        moveCharge = createMenuItem(submenu, Messages.getString("CommonMenuBar.MoveCharge"), MovementDisplay.MOVE_CHARGE); //$NON-NLS-1$        moveDFA = createMenuItem(submenu, Messages.getString("CommonMenuBar.MoveDeth"), MovementDisplay.MOVE_DFA); //$NON-NLS-1$        submenu.addSeparator();        moveFlee = createMenuItem(submenu, Messages.getString("CommonMenuBar.MoveFlee"), MovementDisplay.MOVE_FLEE); //$NON-NLS-1$        moveEject = createMenuItem(submenu, Messages.getString("CommonMenuBar.MoveEject"), MovementDisplay.MOVE_EJECT); //$NON-NLS-1$        submenu.addSeparator();        moveUnjam = createMenuItem(submenu, Messages.getString("CommonMenuBar.moveUnjam"), MovementDisplay.MOVE_UNJAM); //$NON-NLS-1$        moveSearchlight = createMenuItem(submenu, Messages.getString("CommonMenuBar.moveSearchlight"), MovementDisplay.MOVE_SEARCHLIGHT); //$NON-NLS-1$        moveClear = createMenuItem(submenu, Messages.getString("CommonMenuBar.moveClear"), MovementDisplay.MOVE_CLEAR); //$NON-NLS-1$        moveHullDown = createMenuItem(submenu, Messages.getString("CommonMenuBar.moveHullDown"), MovementDisplay.MOVE_CLEAR); //$NON-NLS-1$        moveLayMine = createMenuItem(submenu, Messages.getString("CommonMenuBar.moveLayMine"), MovementDisplay.MOVE_LAY_MINE); //$NON-NLS-1$        menu.addSeparator();        menu.add(submenu);        // Add the cancel button.        menu.addSeparator();        moveNext = createMenuItem(menu, Messages.getString("CommonMenuBar.moveCancel"), MovementDisplay.MOVE_CANCEL, KeyEvent.VK_ESCAPE); //$NON-NLS-1$        // *** Create the fire menu.        menu = new JMenu(Messages.getString("CommonMenuBar.FireMenu")); //$NON-NLS-1$        menu.setMnemonic(KeyEvent.VK_I);        add(menu);        fireFire = createMenuItem(menu, Messages.getString("CommonMenuBar.fireFire"), FiringDisplay.FIRE_FIRE, KeyEvent.VK_F); //$NON-NLS-1$        fireSkip = createMenuItem(menu, Messages.getString("CommonMenuBar.fireSkip"), FiringDisplay.FIRE_SKIP, KeyEvent.VK_S); //$NON-NLS-1$        fireNextTarg = createMenuItem(menu, Messages.getString("CommonMenuBar.fireNextTarg"), FiringDisplay.FIRE_NEXT_TARG, KeyEvent.VK_T); //$NON-NLS-1$        fireNext = createMenuItem(menu, Messages.getString("CommonMenuBar.fireNext"), FiringDisplay.FIRE_NEXT, KeyEvent.VK_N); //$NON-NLS-1$        menu.addSeparator();        fireTwist = createMenuItem(menu, Messages.getString("CommonMenuBar.fireTwist"), FiringDisplay.FIRE_TWIST); //$NON-NLS-1$        fireFlipArms = createMenuItem(menu, Messages.getString("CommonMenuBar.fireFlipArms"), FiringDisplay.FIRE_FLIP_ARMS); //$NON-NLS-1$        menu.addSeparator();        fireMode = createMenuItem(menu, Messages.getString("CommonMenuBar.fireMode"), FiringDisplay.FIRE_MODE, KeyEvent.VK_O); //$NON-NLS-1$        menu.addSeparator();        fireFindClub = createMenuItem(menu, Messages.getString("CommonMenuBar.fireFindClub"), FiringDisplay.FIRE_FIND_CLUB); //$NON-NLS-1$        fireSpot = createMenuItem(menu, Messages.getString("CommonMenuBar.fireSpot"), FiringDisplay.FIRE_SPOT); //$NON-NLS-1$        fireSearchlight = createMenuItem(menu, Messages.getString("CommonMenuBar.fireSearchlight"), FiringDisplay.FIRE_SEARCHLIGHT); //$NON-NLS-1$        menu.addSeparator();        fireCancel = createMenuItem(menu, Messages.getString("CommonMenuBar.fireCancel"), FiringDisplay.FIRE_CANCEL, KeyEvent.VK_ESCAPE); //$NON-NLS-1$        // *** Create the physical menu.        menu = new JMenu(Messages.getString("CommonMenuBar.PhysicalMenu")); //$NON-NLS-1$        menu.setMnemonic(KeyEvent.VK_P);        add(menu);        physicalPunch = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalPunch"), PhysicalDisplay.PHYSICAL_PUNCH); //$NON-NLS-1$        physicalKick = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalKick"), PhysicalDisplay.PHYSICAL_KICK); //$NON-NLS-1$        physicalPush = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalPush"), PhysicalDisplay.PHYSICAL_PUSH); //$NON-NLS-1$        physicalClub = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalClub"), PhysicalDisplay.PHYSICAL_CLUB); //$NON-NLS-1$        physicalBrushOff = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalBrushOff"), PhysicalDisplay.PHYSICAL_BRUSH_OFF); //$NON-NLS-1$        physicalThrash = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalThrash"), PhysicalDisplay.PHYSICAL_THRASH); //$NON-NLS-1$        physicalProto = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalProto"), PhysicalDisplay.PHYSICAL_PROTO); //$NON-NLS-1$        physicalDodge = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalDodge"), PhysicalDisplay.PHYSICAL_DODGE); //$NON-NLS-1$        physicalNext = createMenuItem(menu, Messages.getString("CommonMenuBar.physicalNext"), PhysicalDisplay.PHYSICAL_NEXT, KeyEvent.VK_N); //$NON-NLS-1$        // *** Create the help menu.        menu = new JMenu(Messages.getString("CommonMenuBar.HelpMenu")); //$NON-NLS-1$        menu.setMnemonic(KeyEvent.VK_H);        add(menu);        item = new JMenuItem(Messages.getString("CommonMenuBar.helpContents")); //$NON-NLS-1$        item.addActionListener(this);        item.setActionCommand("helpContents"); //$NON-NLS-1$        menu.add(item);        menu.addSeparator();        item = new JMenuItem(Messages.getString("CommonMenuBar.helpAbout")); //$NON-NLS-1$        item.setActionCommand("helpAbout"); //$NON-NLS-1$        item.addActionListener(this);        menu.add(item);        // Now manage the menu items.        manageMenu();    }    private JMenuItem createMenuItem(JMenu m, String label, String command, int shortcut) {        JMenuItem mi = createMenuItem(m, label, command);        mi.setMnemonic(shortcut);        return mi;    }    private JMenuItem createMenuItem(JMenu m, String label, String command) {        JMenuItem mi = new JMenuItem(label);        mi.addActionListener(this);        mi.setActionCommand(command);        mi.setEnabled(false);        m.add(mi);        return mi;    }    /**     * Implement the <code>ActionListener</code> interface.     *     * @param event - the <code>ActionEvent</code> that spawned this call.     */    public void actionPerformed(ActionEvent event) {        // Pass the action on to each of our listeners.        Enumeration iter = actionListeners.elements();        while (iter.hasMoreElements()) {            ActionListener listener = (ActionListener) iter.nextElement();            listener.actionPerformed(event);        }    }    /**     * Register an object that wishes to be alerted when an item on this     * menu bar has been selected.     * <p/>     * Please note, the ActionCommand property of the action event  will     * inform the listener as to which menu item that has been selected.     * Not all listeners will be interested in all menu items.     *     * @param listener - the <code>ActionListener</code> that wants to     *                 register itself.     */    public synchronized void addActionListener(ActionListener listener) {        actionListeners.addElement(listener);    }    /**     * Remove an object that was being alerted when an item on this     * menu bar was selected.     *     * @param listener - the <code>ActionListener</code> that wants to     *                 be removed.     */    public synchronized void removeActionListener(ActionListener listener) {        actionListeners.removeElement(listener);    }    /**     * A helper function that will manage the enabled states of the items     * in this menu, based upon the object's current state.     */    private synchronized void manageMenu() {        // If we have a game, we can't join a new one, but we can save it.        // Also, no Game menu in the editor (where (this.hasBoard && null==this.client)).        if (game != null || hasBoard && null == client) {            fileGameNew.setEnabled(false);            fileGameOpen.setEnabled(false);            fileGameScenario.setEnabled(false);            fileGameConnectBot.setEnabled(false);            fileGameConnect.setEnabled(false);            // We can only save in certain phases of the game.            if (phase != IGame.PHASE_UNKNOWN &&                    phase != IGame.PHASE_LOUNGE &&                    phase != IGame.PHASE_SELECTION &&                    phase != IGame.PHASE_EXCHANGE &&                    phase != IGame.PHASE_VICTORY &&                    phase != IGame.PHASE_STARTING_SCENARIO) {                fileGameSave.setEnabled(true);            } else {                fileGameSave.setEnabled(false);            }        }        // If we have no game, we can't save, but we can create or join one.        else {            fileGameNew.setEnabled(true);            fileGameOpen.setEnabled(true);            fileGameSave.setEnabled(false);            fileGameScenario.setEnabled(true);            fileGameConnectBot.setEnabled(true);            fileGameConnect.setEnabled(true);        }        // can view Game Opts if we have a game        if (game != null) {            viewGameOptions.setEnabled(true);        } else {            viewGameOptions.setEnabled(false);        }        // As of 2003-09-04, we can't ever print.        filePrint.setEnabled(false);        // the Client doesn't have any board actions        if (client != null) {            fileBoardNew.setEnabled(false);            fileBoardOpen.setEnabled(false);            fileBoardSave.setEnabled(false);            fileBoardSaveAs.setEnabled(false);            fileBoardSaveAsImage.setEnabled(false);            // but the main window and map editor do        } else {            fileBoardNew.setEnabled(true);            fileBoardOpen.setEnabled(true);            fileBoardSave.setEnabled(false);            fileBoardSaveAs.setEnabled(false);            fileBoardSaveAsImage.setEnabled(false);        }        // If we have a board, we can perform board actions and view the mini map.        if (hasBoard) {            // Save boards only in BoardEditor            if (client == null) {                fileBoardSave.setEnabled(true);                fileBoardSaveAs.setEnabled(true);                fileBoardSaveAsImage.setEnabled(true);            }            viewMiniMap.setEnabled(true);            viewZoomIn.setEnabled(true);            viewZoomOut.setEnabled(true);        }        // If we don't have a board we can't view the mini map.        else {            viewMiniMap.setEnabled(false);            viewZoomIn.setEnabled(false);            viewZoomOut.setEnabled(false);        }        // If we have a unit list, and if we are in the lounge,        // then we can still perform all unit list actions.        if (hasUnitList) {            fileUnitsOpen.setEnabled(phase == IGame.PHASE_LOUNGE);            fileUnitsClear.setEnabled(phase == IGame.PHASE_LOUNGE);            fileUnitsSave.setEnabled(phase == IGame.PHASE_LOUNGE);        }        // If we don't have a unit list, but we are in the lounge,        // then we can open a unit list.        else {            fileUnitsOpen.setEnabled(phase == IGame.PHASE_LOUNGE);            fileUnitsClear.setEnabled(false);            fileUnitsSave.setEnabled(false);        }        // If an entity has been selected, we can view it.        if (entity != null) {            viewMekDisplay.setEnabled(true);        }        // If we haven't selected an entity, we can't view it.        else {            viewMekDisplay.setEnabled(false);        }        // We can only view the LOS/Range tool setting and        // the mini map in certain phases of the game.  Also        // the board editor has no LOS/Units/Player stuff        if (client == null && hasBoard) {            viewLOSSetting.setEnabled(false);            viewUnitOverview.setEnabled(false);            viewPlayerList.setEnabled(false);        }        // We're in-game.        else if (phase == IGame.PHASE_SET_ARTYAUTOHITHEXES ||                phase == IGame.PHASE_DEPLOY_MINEFIELDS ||                phase == IGame.PHASE_MOVEMENT ||                phase == IGame.PHASE_FIRING ||                phase == IGame.PHASE_PHYSICAL ||                phase == IGame.PHASE_OFFBOARD ||                phase == IGame.PHASE_TARGETING ||                phase == IGame.PHASE_DEPLOYMENT) {            viewLOSSetting.setEnabled(true);            viewMiniMap.setEnabled(true);            viewZoomIn.setEnabled(true);            viewZoomOut.setEnabled(true);            viewUnitOverview.setEnabled(true);            viewPlayerList.setEnabled(true);        }        // We're in-game, but not in a phase with map functions.        else {            viewLOSSetting.setEnabled(false);            viewMiniMap.setEnabled(false);            viewZoomIn.setEnabled(false);            viewZoomOut.setEnabled(false);            viewUnitOverview.setEnabled(false);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -