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

📄 custombattlearmordialog.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
/* * MechSelectorDialog.java - Copyright (C) 2002,2004 Josh Yockey *  *  This program is free software; you can redistribute it and/or modify it  *  under the terms of the GNU General Public License as published by the Free  *  Software Foundation; either version 2 of the License, or (at your option)  *  any later version. *  *  This program is distributed in the hope that it will be useful, but  *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY  *  or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License  *  for more details. */package megamek.client.ui.swing;import megamek.client.Client;import megamek.common.BattleArmor;import megamek.common.Entity;import megamek.common.EquipmentType;import megamek.common.IEntityMovementMode;import megamek.common.Infantry;import megamek.common.LocationFullException;import megamek.common.TechConstants;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JComboBox;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JRadioButton;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.event.DocumentEvent;import javax.swing.event.DocumentListener;import java.awt.BorderLayout;import java.awt.FlowLayout;import java.awt.Font;import java.awt.GridLayout;import java.awt.Point;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.ItemEvent;import java.awt.event.ItemListener;import java.awt.event.KeyEvent;import java.awt.event.KeyListener;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import java.util.ArrayList;import java.util.Iterator;/*  * Allows a user to sort through a list of MechSummaries and select one */public class CustomBattleArmorDialog        extends JDialog implements ActionListener, ItemListener, KeyListener,        Runnable, DocumentListener, WindowListener {    private Client m_client;    private ClientGUI m_clientgui;    private JPanel m_pLeft = new JPanel();    private JPanel m_pParams = new JPanel();    private JLabel m_labelBAName = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelBAName"), JLabel.RIGHT);    private JTextField m_tfBAName = new JTextField();    private JLabel m_labelMenPerSquad = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelMenPerSquad"), JLabel.RIGHT);    private JComboBox m_chMenPerSquad = new JComboBox();    private JLabel m_labelTechBase = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelTechBase"), JLabel.RIGHT);    private JComboBox m_chTechBase = new JComboBox();    private JLabel m_labelChassisType = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelChassisType"), JLabel.RIGHT);    private JComboBox m_chChassisType = new JComboBox();    private JLabel m_labelWeightClass = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelWeightClass"), JLabel.RIGHT);    private JComboBox m_chWeightClass = new JComboBox();    private JLabel m_labelGroundMP = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelGroundMP"), JLabel.RIGHT);    private JComboBox m_chGroundMP = new JComboBox();    private ButtonGroup m_cbgJumpType = new ButtonGroup();    private JRadioButton m_cbJumpQuery = new JRadioButton(Messages.getString("CustomBattleArmorDialog.m_jumpQuery"), true);    private JRadioButton m_cbVTOLQuery = new JRadioButton(Messages.getString("CustomBattleArmorDialog.m_VTOLQuery"), false);    private JRadioButton m_cbUMUQuery = new JRadioButton(Messages.getString("CustomBattleArmorDialog.m_UMUQuery"), false);    private JLabel m_labelJumpValue = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelJumpValue"), JLabel.RIGHT);    private JComboBox m_chJumpValue = new JComboBox();    private JLabel m_labelArmorType = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelArmorType"), JLabel.RIGHT);    private JComboBox m_chArmorType = new JComboBox();    private JLabel m_labelArmorValue = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelArmorValue"), JLabel.RIGHT);    private JComboBox m_chArmorValue = new JComboBox();    private JLabel m_labelLeftManipulator = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelLeftManipulator"), JLabel.RIGHT);    private JComboBox m_chLeftManipulator = new JComboBox();    private JLabel m_labelRightManipulator = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelRightManipulator"), JLabel.RIGHT);    private JComboBox m_chRightManipulator = new JComboBox();    private JLabel m_labelTorsoEquipment = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelTorsoEquipment"), JLabel.RIGHT);    private JComboBox m_chTorsoEquipment = new JComboBox();    private JButton m_buttonAddTorso = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonAdd"));    private JLabel m_labelRightArmEquipment = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelRightArmEquipment"), JLabel.RIGHT);    private JComboBox m_chRightArmEquipment = new JComboBox();    private JButton m_buttonAddRightArm = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonAdd"));    private JLabel m_labelLeftArmEquipment = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelLeftArmEquipment"), JLabel.RIGHT);    private JComboBox m_chLeftArmEquipment = new JComboBox();    private JButton m_buttonAddLeftArm = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonAdd"));    private JLabel m_labelTorsoCurrentEquipment = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelCurrentTorsoEquipment"), JLabel.RIGHT);    private JComboBox m_chTorsoCurrentEquipment = new JComboBox();    private JButton m_buttonRemoveTorso = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonRemove"));    private JLabel m_labelRightArmCurrentEquipment = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelCurrentRightArmEquipment"), JLabel.RIGHT);    private JComboBox m_chRightArmCurrentEquipment = new JComboBox();    private JButton m_buttonRemoveRightArm = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonRemove"));    private JLabel m_labelLeftArmCurrentEquipment = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelCurrentLeftArmEquipment"), JLabel.RIGHT);    private JComboBox m_chLeftArmCurrentEquipment = new JComboBox();    private JButton m_buttonRemoveLeftArm = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonRemove"));    private JPanel m_pButtons = new JPanel();    private JButton m_bPick = new JButton(Messages.getString("CustomBattleArmorDialog.m_bPick"));    private JButton m_bPickClose = new JButton(Messages.getString("CustomBattleArmorDialog.m_bPickClose"));    private JButton m_bCancel = new JButton(Messages.getString("CustomBattleArmorDialog.m_bClose"));    private JButton m_buttonReset = new JButton(Messages.getString("CustomBattleArmorDialog.m_buttonReset"));    private JLabel m_labelPlayer = new JLabel(Messages.getString("CustomBattleArmorDialog.m_labelPlayer"), JLabel.RIGHT);    private JComboBox m_chPlayer = new JComboBox();    private JTextArea m_BAView = new JTextArea("", 18, 25);    private String invalidReason = null;    private int stateMenPerSquad = 1;    private int stateTechBase = 0;    private int stateChassisType = 0;    private int stateWeightClass = 0;    private int stateArmorType = 0;    private int stateArmorValue = 0;    private int stateJumpType = 0;    private int stateJumpMP = 0;    private int stateGroundMP = 1;    private int stateCurrentWeight = 0;    private int stateMinWeight = 0;    private int stateMaxWeight = 400;    private int stateManipulatorTypeLeft = 0;    private int stateManipulatorTypeRight = 0;    private int stateConflictFlags = 0;    private ArrayList leftArmEquipment = null;    private ArrayList rightArmEquipment = null;    private ArrayList torsoEquipment = null;    private static ArrayList equipmentTypes = null;    private static ArrayList equipmentNames = null;    private static final int TECH_BASE_IS = 0;    private static final int TECH_BASE_CLAN = 1;    private static final int TECH_BASE_BOTH = 2;    private static final int CHASSIS_TYPE_BIPED = 0;    private static final int CHASSIS_TYPE_QUAD = 1;    private static final int WEIGHT_CLASS_PAL = 0;    private static final int WEIGHT_CLASS_LIGHT = 1;    private static final int WEIGHT_CLASS_MEDIUM = 2;    private static final int WEIGHT_CLASS_HEAVY = 3;    private static final int WEIGHT_CLASS_ASSAULT = 4;    private static final int JUMP_TYPE_JUMP = 0;    private static final int JUMP_TYPE_VTOL = 1;    private static final int JUMP_TYPE_UMU = 2;    private static int EQUIPMENT_TYPE_WEAPON = 0;    private static int EQUIPMENT_TYPE_WEAPON_AP = 1;    private static int EQUIPMENT_TYPE_PREPROCESS = 2;    private static int EQUIPMENT_TYPE_AMMO = 3;    private static int EQUIPMENT_TYPE_OTHER = 4;    private static final int[][] ARMOR_TYPE_WEIGHT = {{50, 40, 100, 55, 100, 60, 60, 0, 50},                                                      {25, 0, 0, 30, 0, 35, 35, 30, 0}};    private static final int[] ARMOR_TYPE_SLOTS = {0, 5, 4, 3, 4, 4, 5, 5, 5};    private static final int[] ARMOR_TYPE_COSTS = {10000,                                                   12500,                                                   10000,                                                   12000,                                                   50000,                                                   15000,                                                   20000,                                                   10000,                                                   15000};    private static final String[] ARMOR_TYPE_STRINGS = {"Standard",                                                        "Advanced",                                                        "Prototype",                                                        "Basic Stealth",                                                        "Prototype Stealth",                                                        "Standard Stealth",                                                        "Improved Stealth",                                                        "Fire Resistant",                                                        "Mimetic"};    private static final int[] GROUND_MP_WEIGHT = {25, 30, 40, 80, 160};    private static final int[][] JUMP_MP_LIMITS = {{3, 3, 3, 2, 2},                                                   {7, 6, 5, 0, 0},                                                   {5, 5, 4, 3, 2}};    private static final int[][] JUMP_MP_WEIGHT = {{25, 25, 50, 125, 250},                                                   {30, 40, 60, 0, 0},                                                   {45, 45, 85, 160, 250}};    private static final int[][] JUMP_MP_COST = {{50000, 50000, 75000, 150000, 300000},                                                 {50000, 50000, 100000, 0, 0},                                                 {50000, 50000, 75000, 100000, 150000}};    private static final int[] MANIPULATOR_TYPE_WEIGHT = {0,                                                          0,                                                          0,                                                          15,                                                          15,                                                          35,                                                          50,                                                          20,                                                          60,                                                          30,                                                          30,                                                          30};    private static final int[] MANIPULATOR_TYPE_COSTS = {0,                                                         2500,                                                         5000,                                                         7500,                                                         10000,                                                         12500,                                                         15000,                                                         25000,                                                         30000,                                                         500,                                                         2500};    private static final int[] ARM_MAX_SLOTS = {2, 2, 3, 3, 4};    private static final int[] TORSO_MAX_SLOTS = {2, 4, 4, 6, 8};    private static final int[] QUAD_MAX_SLOTS = {0, 5, 7, 9, 11};    private static final int LOCATION_ALLOWED_ANY = 0;    private static final int LOCATION_ALLOWED_TORSO = 1;    private static final int LOCATION_ALLOWED_ARM = 2;    private static final int F_CONFLICT_JUMP_GEAR = 0x00000001;    public CustomBattleArmorDialog(ClientGUI cl) {        super(cl.frame, Messages.getString("CustomBattleArmorDialog.title"), true);        m_client = cl.getClient();        m_clientgui = cl;        updatePlayerChoice();        GridLayout gl = new GridLayout();        gl.setColumns(1);        gl.setRows(0);        m_pParams.setLayout(gl);        GridLayout tmpGL = new GridLayout(1, 2);        JPanel tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelBAName);        m_tfBAName.getDocument().addDocumentListener(this);        tmpP.add(m_tfBAName);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelMenPerSquad);        m_chMenPerSquad.addItemListener(this);        tmpP.add(m_chMenPerSquad);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelTechBase);        m_chTechBase.addItemListener(this);        tmpP.add(m_chTechBase);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelChassisType);        m_chChassisType.addItemListener(this);        tmpP.add(m_chChassisType);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelWeightClass);        m_chWeightClass.addItemListener(this);        tmpP.add(m_chWeightClass);        m_pParams.add(tmpP);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        tmpP.add(m_labelGroundMP);        m_chGroundMP.addItemListener(this);        tmpP.add(m_chGroundMP);        m_pParams.add(tmpP);        tmpGL = new GridLayout(1, 3);        tmpP = new JPanel();        tmpP.setLayout(tmpGL);        m_cbJumpQuery.addItemListener(this);        tmpP.add(m_cbJumpQuery);

⌨️ 快捷键说明

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