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

📄 custombattlearmordialog.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        m_cbVTOLQuery.addItemListener(this);        tmpP.add(m_cbVTOLQuery);        m_cbUMUQuery.addItemListener(this);        tmpP.add(m_cbUMUQuery);        m_pParams.add(tmpP);        m_cbgJumpType.add(m_cbJumpQuery);        m_cbgJumpType.add(m_cbVTOLQuery);        m_cbgJumpType.add(m_cbUMUQuery);        tmpGL = new GridLayout(1, 2);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelJumpValue);        m_chJumpValue.addItemListener(this);        tmpP.add(m_chJumpValue);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelArmorType);        m_chArmorType.addItemListener(this);        tmpP.add(m_chArmorType);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelArmorValue);        m_chArmorValue.addItemListener(this);        tmpP.add(m_chArmorValue);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelLeftManipulator);        m_chLeftManipulator.addItemListener(this);        tmpP.add(m_chLeftManipulator);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelRightManipulator);        m_chRightManipulator.addItemListener(this);        tmpP.add(m_chRightManipulator);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelTorsoEquipment);        tmpP.add(m_chTorsoEquipment);        m_buttonAddTorso.addActionListener(this);        tmpP.add(m_buttonAddTorso);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelRightArmEquipment);        tmpP.add(m_chRightArmEquipment);        m_buttonAddRightArm.addActionListener(this);        tmpP.add(m_buttonAddRightArm);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelLeftArmEquipment);        tmpP.add(m_chLeftArmEquipment);        m_buttonAddLeftArm.addActionListener(this);        tmpP.add(m_buttonAddLeftArm);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelTorsoCurrentEquipment);        tmpP.add(m_chTorsoCurrentEquipment);        m_buttonRemoveTorso.addActionListener(this);        tmpP.add(m_buttonRemoveTorso);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelRightArmCurrentEquipment);        tmpP.add(m_chRightArmCurrentEquipment);        m_buttonRemoveRightArm.addActionListener(this);        tmpP.add(m_buttonRemoveRightArm);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelLeftArmCurrentEquipment);        tmpP.add(m_chLeftArmCurrentEquipment);        m_buttonRemoveLeftArm.addActionListener(this);        tmpP.add(m_buttonRemoveLeftArm);        m_pParams.add(tmpP);        m_pButtons.setLayout(new FlowLayout(FlowLayout.CENTER));        m_pButtons.add(m_bPick);        m_pButtons.add(m_bPickClose);        m_pButtons.add(m_buttonReset);        m_pButtons.add(m_bCancel);        m_pButtons.add(m_labelPlayer);        m_pButtons.add(m_chPlayer);        m_pLeft.setLayout(new BorderLayout());        m_pLeft.add(m_pParams, BorderLayout.CENTER);        m_pLeft.add(m_pButtons, BorderLayout.SOUTH);        getContentPane().setLayout(new BorderLayout());        getContentPane().add(m_pLeft, BorderLayout.WEST);        m_BAView.setFont(new Font("Monospaced", Font.PLAIN, 12));        getContentPane().add(new JScrollPane(m_BAView), BorderLayout.CENTER);        setSize(800, 450);        setLocation(computeDesiredLocation());        new BattleArmorEquipment().initialize();        populateChoices();        m_bPick.addActionListener(this);        m_bPickClose.addActionListener(this);        m_buttonReset.addActionListener(this);        m_bCancel.addActionListener(this);        addWindowListener(this);        updateWidgetEnablements();        previewBA();    }    private void resetState() {        restoreDefaultStates();        populateChoices();        previewBA();    }    private void restoreDefaultStates() {        m_tfBAName.setText("");        invalidReason = null;        stateMenPerSquad = 1;        stateTechBase = 0;        stateChassisType = 0;        stateWeightClass = 0;        stateArmorType = 0;        stateArmorValue = 0;        stateJumpType = 0;        stateJumpMP = 0;        stateGroundMP = 1;        stateCurrentWeight = 0;        stateMinWeight = 0;        stateMaxWeight = 400;        stateManipulatorTypeLeft = 0;        stateManipulatorTypeRight = 0;        stateConflictFlags = 0;        leftArmEquipment = null;        rightArmEquipment = null;        torsoEquipment = null;    }    private void updatePlayerChoice() {        String lastChoice = (String) m_chPlayer.getSelectedItem();        m_chPlayer.removeAll();        m_chPlayer.setEnabled(true);        m_chPlayer.addItem(m_clientgui.getClient().getName());        for (Iterator i = m_clientgui.getBots().values().iterator(); i.hasNext();) {            m_chPlayer.addItem(((Client) i.next()).getName());        }        if (m_chPlayer.getItemCount() == 1) {            m_chPlayer.setEnabled(false);        } else {            m_chPlayer.setSelectedItem(lastChoice);        }    }    public void run() {        // I don't think we actually need to do anything here.        // In fact, does this need to be a thread?...    }    private void populateChoices() {        // Only two tech base choices: IS and Clan.        m_chTechBase.addItem("Inner Sphere");        m_chTechBase.addItem("Clan");        m_chTechBase.setSelectedIndex(0);        // How many guys in a squad of these things?        m_chMenPerSquad.addItem("1");        m_chMenPerSquad.addItem("2");        m_chMenPerSquad.addItem("3");        m_chMenPerSquad.addItem("4");        m_chMenPerSquad.addItem("5");        m_chMenPerSquad.setSelectedIndex(0);        // Again, only two chassis types: Quad and Biped.        m_chChassisType.addItem("Biped");        m_chChassisType.addItem("Quad");        m_chChassisType.setSelectedIndex(0);        // At least initially, we'll have 5 weight classes:        // PA(L), light, medium, heavy, assault.        m_chWeightClass.addItem("PA(L)");        m_chWeightClass.addItem("Light");        m_chWeightClass.addItem("Medium");        m_chWeightClass.addItem("Heavy");        m_chWeightClass.addItem("Assault");        m_chWeightClass.setSelectedIndex(0);        // Ground MP range depends on chassis and weight class.        // We'll start with biped PA(L), the default chassis/weight.        m_chGroundMP.addItem("1");        m_chGroundMP.addItem("2");        m_chGroundMP.addItem("3");        m_chGroundMP.setSelectedIndex(0);        // Max Jump/VTOL/UMU MP depends on weight class and chosen movement mode.        // We'll default to jump MP for PA(L), the default values.        m_chJumpValue.addItem("0");        m_chJumpValue.addItem("1");        m_chJumpValue.addItem("2");        m_chJumpValue.addItem("3");        m_chJumpValue.setSelectedIndex(0);        // Available armor types depends on tech base.        // We'll start with IS armor types, since we default to IS tech base.        m_chArmorType.addItem("Standard");        m_chArmorType.addItem("Advanced");        m_chArmorType.addItem("Prototype");        m_chArmorType.addItem("Basic Stealth");        m_chArmorType.addItem("Prototype Stealth");        m_chArmorType.addItem("Standard Stealth");        m_chArmorType.addItem("Improved Stealth");        m_chArmorType.addItem("Fire Resistant");        m_chArmorType.addItem("Mimetic");        m_chArmorType.setSelectedIndex(0);        // Next we populate the manipulator choicees.        for (int x = 0; x < BattleArmor.MANIPULATOR_TYPE_STRINGS.length; x++) {            m_chLeftManipulator.addItem(BattleArmor.MANIPULATOR_TYPE_STRINGS[x]);            m_chRightManipulator.addItem(BattleArmor.MANIPULATOR_TYPE_STRINGS[x]);        }        m_chLeftManipulator.setSelectedIndex(0);        m_chRightManipulator.setSelectedIndex(0);        // Max armor value depends on weight class.        // We'll default to that for PA(L), the default weight class.        m_chArmorValue.addItem("0");        m_chArmorValue.addItem("1");        m_chArmorValue.addItem("2");        m_chArmorValue.setSelectedIndex(0);        // Populate the equipment choices.        updateEquipmentChoices();    }    private void updateEquipmentChoices() {        String value = (String) m_chTorsoEquipment.getSelectedItem();        m_chTorsoEquipment.removeAll();        Object[] tmpE = equipmentTypes.toArray();        for (int x = 0; x < tmpE.length; x++) {            BattleArmorEquipment tmpBAE = (BattleArmorEquipment) (tmpE[x]);            if (((tmpBAE.techBase == TECH_BASE_BOTH)                    || (tmpBAE.techBase == stateTechBase))                    && !(hasConflictFlag(tmpBAE.conflictFlag))                    && ((tmpBAE.allowedLocation == LOCATION_ALLOWED_ANY)                    || (tmpBAE.allowedLocation == LOCATION_ALLOWED_TORSO))) {                m_chTorsoEquipment.addItem(tmpBAE.name);            }        }        m_chTorsoEquipment.setSelectedItem(value);        value = (String) m_chRightArmEquipment.getSelectedItem();        m_chRightArmEquipment.removeAll();        if (stateChassisType != CHASSIS_TYPE_QUAD) {            tmpE = equipmentTypes.toArray();            for (int x = 0; x < tmpE.length; x++) {                BattleArmorEquipment tmpBAE = (BattleArmorEquipment) (tmpE[x]);                if (((tmpBAE.techBase == TECH_BASE_BOTH)                        || (tmpBAE.techBase == stateTechBase))                        && !(hasConflictFlag(tmpBAE.conflictFlag))                        && ((tmpBAE.allowedLocation == LOCATION_ALLOWED_ANY)                        || (tmpBAE.allowedLocation == LOCATION_ALLOWED_ARM))) {                    m_chRightArmEquipment.addItem(tmpBAE.name);                }            }        }        m_chRightArmEquipment.setSelectedItem(value);        value = (String) m_chLeftArmEquipment.getSelectedItem();        m_chLeftArmEquipment.removeAll();        if (stateChassisType != CHASSIS_TYPE_QUAD) {            tmpE = equipmentTypes.toArray();            for (int x = 0; x < tmpE.length; x++) {                BattleArmorEquipment tmpBAE = (BattleArmorEquipment) (tmpE[x]);                if (((tmpBAE.techBase == TECH_BASE_BOTH)                        || (tmpBAE.techBase == stateTechBase))                        && !(hasConflictFlag(tmpBAE.conflictFlag))                        && ((tmpBAE.allowedLocation == LOCATION_ALLOWED_ANY)                        || (tmpBAE.allowedLocation == LOCATION_ALLOWED_ARM))) {                    m_chLeftArmEquipment.addItem(tmpBAE.name);                }            }        }

⌨️ 快捷键说明

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