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

📄 randommapdialog.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        texMaxRadius = new JTextField(2);        texMaxRadius.addFocusListener(this);        labMaxCraters = new JLabel(Messages.getString("RandomMapDialog.labMaxCraters"), JLabel.LEFT); //$NON-NLS-1$        texMaxCraters = new JTextField(2);        texMaxCraters.addFocusListener(this);        texMinCraters = new JTextField(2);        texMinCraters.addFocusListener(this);        /* FX */        labProbDrought = new JLabel(Messages.getString("RandomMapDialog.labProbDrought"), JLabel.LEFT);        labProbFire = new JLabel(Messages.getString("RandomMapDialog.labProbFire"), JLabel.LEFT);        labProbFreeze = new JLabel(Messages.getString("RandomMapDialog.labProbFreeze"), JLabel.LEFT);        labProbFlood = new JLabel(Messages.getString("RandomMapDialog.labProbFlood"), JLabel.LEFT);        labFxMod = new JLabel(Messages.getString("RandomMapDialog.labFxMod"), JLabel.LEFT);        texProbDrought = new JTextField(2);        texProbFire = new JTextField(2);        texProbFreeze = new JTextField(2);        texProbFlood = new JTextField(2);        texFxMod = new JTextField(2);        /* Buildings */        labCityBlocks = new JLabel(Messages.getString("RandomMapDialog.labCityBlocks"), JLabel.LEFT);        labCityCF = new JLabel(Messages.getString("RandomMapDialog.labCityCF"), JLabel.LEFT);        labCityFloors = new JLabel(Messages.getString("RandomMapDialog.labCityFloors"), JLabel.LEFT);        labCityDensity = new JLabel(Messages.getString("RandomMapDialog.labCityDensity"), JLabel.LEFT);        labTownSize = new JLabel(Messages.getString("RandomMapDialog.labTownSize"), JLabel.LEFT);        texCityBlocks = new JTextField(2);        texCityMinCF = new JTextField(2);        texCityMaxCF = new JTextField(2);        texCityMinFloors = new JTextField(2);        texCityMaxFloors = new JTextField(2);        texCityDensity = new JTextField(2);        texTownSize = new JTextField(2);        labInvertNegative = new JLabel(Messages.getString("RandomMapDialog.labInvertNegative"), JLabel.LEFT); //$NON-NLS-1$        texInvertNegative = new JTextField(1);        /** Algorithm */        labAlgorithmToUse = new JLabel(Messages.getString("RandomMapDialog.labAlgorithmToUse"), JLabel.LEFT); //$NON-NLS-1$        texAlgorithmToUse = new JTextField(2);        slElevationAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slWoodsAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slLakesAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slPavementAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slRubbleAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slFortifiedAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slIceAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slRoughAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slRoadsAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slRiversAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slSwampAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slBoardSizeAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slCratersAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slCityAd = new SimpleLine(ADVANCED_LINE_WIDTH);        slInvertNegativeAd = new SimpleLine(ADVANCED_LINE_WIDTH);    }    private void addOption(JLabel label, JComboBox choice, SimpleLine sl) {        GridBagConstraints c = new GridBagConstraints();        c.weightx = 1;        c.weighty = 1;        c.gridwidth = 1;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(label, c);        panOptions.add(label);        c.gridwidth = 1;        c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(choice, c);        panOptions.add(choice);        c.anchor = GridBagConstraints.CENTER;        c.insets = new Insets(2, 0, 2, 0);        gridbag.setConstraints(sl, c);        panOptions.add(sl);    }    private void fillChoice(JComboBox c) {        c.addItem(NONE);        c.addItem(LOW);        c.addItem(MEDIUM);        c.addItem(HIGH);    }    private void addLabelTextField(JLabel label, JTextField text) {        GridBagConstraints c = new GridBagConstraints();        c.weightx = 1;        c.weighty = 0;        c.gridwidth = 1;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(label, c);        panOptions.add(label);        c.weightx = 0;        c.weighty = 0;        c.fill = GridBagConstraints.NONE;        c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(text, c);        panOptions.add(text);    }    private void addLabelTextField(JLabel label, JTextField text, JTextField text2, String separator) {        GridBagConstraints c = new GridBagConstraints();        c.weightx = 1;        c.weighty = 0;        c.gridwidth = 1;        c.fill = GridBagConstraints.HORIZONTAL;        c.anchor = GridBagConstraints.WEST;        gridbag.setConstraints(label, c);        panOptions.add(label);        c.weightx = 0;        c.weighty = 0;        c.gridwidth = 1;        c.fill = GridBagConstraints.NONE;        c.anchor = GridBagConstraints.EAST;        gridbag.setConstraints(text, c);        panOptions.add(text);        JLabel l = new JLabel(separator, JLabel.CENTER);        gridbag.setConstraints(l, c);        panOptions.add(l);        c.gridwidth = GridBagConstraints.REMAINDER;        gridbag.setConstraints(text2, c);        panOptions.add(text2);    }    private void addSeparator(SimpleLine sl) {        GridBagConstraints c = new GridBagConstraints();        c.gridwidth = GridBagConstraints.REMAINDER;        c.anchor = GridBagConstraints.CENTER;        c.insets = new Insets(2, 0, 2, 0);        gridbag.setConstraints(sl, c);        panOptions.add(sl);    }    private void loadValues() {        texBoardWidth.setText(Integer.toString(mapSettings.getBoardWidth()));        texBoardHeight.setText(Integer.toString(mapSettings.getBoardHeight()));        texTheme.setText(mapSettings.getTheme());        texHilliness.setText(Integer.toString(mapSettings.getHilliness()));        texRange.setText(Integer.toString(mapSettings.getRange()));        texProbInvert.setText(Integer.toString(mapSettings.getProbInvert()));        texCliffs.setText(Integer.toString(mapSettings.getCliffs()));        texMinWaterSpots.setText(Integer.toString(mapSettings.getMinWaterSpots()));        texMaxWaterSpots.setText(Integer.toString(mapSettings.getMaxWaterSpots()));        texMinWaterSize.setText(Integer.toString(mapSettings.getMinWaterSize()));        texMaxWaterSize.setText(Integer.toString(mapSettings.getMaxWaterSize()));        texMinForestSpots.setText(Integer.toString(mapSettings.getMinForestSpots()));        texMaxForestSpots.setText(Integer.toString(mapSettings.getMaxForestSpots()));        texMinForestSize.setText(Integer.toString(mapSettings.getMinForestSize()));        texMaxForestSize.setText(Integer.toString(mapSettings.getMaxForestSize()));        texMinRoughSpots.setText(Integer.toString(mapSettings.getMinRoughSpots()));        texMaxRoughSpots.setText(Integer.toString(mapSettings.getMaxRoughSpots()));        texMinRoughSize.setText(Integer.toString(mapSettings.getMinRoughSize()));        texMaxRoughSize.setText(Integer.toString(mapSettings.getMaxRoughSize()));        texMinSwampSpots.setText(Integer.toString(mapSettings.getMinSwampSpots()));        texMaxSwampSpots.setText(Integer.toString(mapSettings.getMaxSwampSpots()));        texMinSwampSize.setText(Integer.toString(mapSettings.getMinSwampSize()));        texMaxSwampSize.setText(Integer.toString(mapSettings.getMaxSwampSize()));        texMinPavementSpots.setText(Integer.toString(mapSettings.getMinPavementSpots()));        texMaxPavementSpots.setText(Integer.toString(mapSettings.getMaxPavementSpots()));        texMinPavementSize.setText(Integer.toString(mapSettings.getMinPavementSize()));        texMaxPavementSize.setText(Integer.toString(mapSettings.getMaxPavementSize()));        texMinRubbleSpots.setText(Integer.toString(mapSettings.getMinRubbleSpots()));        texMaxRubbleSpots.setText(Integer.toString(mapSettings.getMaxRubbleSpots()));        texMinRubbleSize.setText(Integer.toString(mapSettings.getMinRubbleSize()));        texMaxRubbleSize.setText(Integer.toString(mapSettings.getMaxRubbleSize()));        texMinFortifiedSpots.setText(Integer.toString(mapSettings.getMinFortifiedSpots()));        texMaxFortifiedSpots.setText(Integer.toString(mapSettings.getMaxFortifiedSpots()));        texMinFortifiedSize.setText(Integer.toString(mapSettings.getMinFortifiedSize()));        texMaxFortifiedSize.setText(Integer.toString(mapSettings.getMaxFortifiedSize()));        texMinIceSpots.setText(Integer.toString(mapSettings.getMinIceSpots()));        texMaxIceSpots.setText(Integer.toString(mapSettings.getMaxIceSpots()));        texMinIceSize.setText(Integer.toString(mapSettings.getMinIceSize()));        texMaxIceSize.setText(Integer.toString(mapSettings.getMaxIceSize()));        texProbDeep.setText(Integer.toString(mapSettings.getProbDeep()));        texProbHeavy.setText(Integer.toString(mapSettings.getProbHeavy()));        texProbRiver.setText(Integer.toString(mapSettings.getProbRiver()));        texProbRoad.setText(Integer.toString(mapSettings.getProbRoad()));        texProbCrater.setText(Integer.toString(mapSettings.getProbCrater()));        texMinRadius.setText(Integer.toString(mapSettings.getMinRadius()));        texMaxRadius.setText(Integer.toString(mapSettings.getMaxRadius()));        texMaxCraters.setText(Integer.toString(mapSettings.getMaxCraters()));        texMinCraters.setText(Integer.toString(mapSettings.getMinCraters()));        texProbDrought.setText(Integer.toString(mapSettings.getProbDrought()));        texProbFire.setText(Integer.toString(mapSettings.getProbForestFire()));        texProbFreeze.setText(Integer.toString(mapSettings.getProbFreeze()));        texProbFlood.setText(Integer.toString(mapSettings.getProbFlood()));        texFxMod.setText(Integer.toString(mapSettings.getFxMod()));        choCity.setSelectedItem(mapSettings.getCityType());        texInvertNegative.setText(Integer.toString(mapSettings.getInvertNegativeTerrain()));        texCityBlocks.setText(Integer.toString(mapSettings.getCityBlocks()));        texCityMinCF.setText(Integer.toString(mapSettings.getCityMinCF()));        texCityMaxCF.setText(Integer.toString(mapSettings.getCityMaxCF()));        texCityMinFloors.setText(Integer.toString(mapSettings.getCityMinFloors()));        texCityMaxFloors.setText(Integer.toString(mapSettings.getCityMaxFloors()));        texCityDensity.setText(Integer.toString(mapSettings.getCityDensity()));        texTownSize.setText(Integer.toString(mapSettings.getTownSize()));        texMountainPeaks.setText(Integer.toString(mapSettings.getMountainPeaks()));        texMountainStyle.setText(Integer.toString(mapSettings.getMountainStyle()));        texMountainHeightMin.setText(Integer.toString(mapSettings.getMountainHeightMin()));        texMountainHeightMax.setText(Integer.toString(mapSettings.getMountainHeightMax()));        texMountainWidthMin.setText(Integer.toString(mapSettings.getMountainHeightMin()));        texMountainWidthMax.setText(Integer.toString(mapSettings.getMountainHeightMax()));        texAlgorithmToUse.setText(Integer.toString(mapSettings.getAlgorithmToUse()));    }    private boolean applyValues() {        int boardWidth;        int boardHeight;        int hilliness, range, cliffs;        int minWaterSpots, maxWaterSpots, minWaterSize, maxWaterSize, probDeep;        int minForestSpots, maxForestSpots, minForestSize, maxForestSize, probHeavy;        int minRoughSpots, maxRoughSpots, minRoughSize, maxRoughSize;        int minPavementSpots, maxPavementSpots, minPavementSize, maxPavementSize;        int minRubbleSpots, maxRubbleSpots, minRubbleSize, maxRubbleSize;        int minFortifiedSpots, maxFortifiedSpots, minFortifiedSize, maxFortifiedSize;        int minIceSpots, maxIceSpots, minIceSize, maxIceSize;        int minSwampSpots, maxSwampSpots, minSwampSize, maxSwampSize;        int probRoad, probRiver, probInvert;        int minRadius, maxRadius, minCraters, maxCraters, probCrater;        int drought, fire, freeze, flood, fxmod;        int algorithmToUse;        String theme = "";        String cityType;        int cityBlocks = 4;        int cityMinCF = 10;        int cityMaxCF = 100;        int cityMinFloors = 1;        int cityMaxFloors = 6;        int cityDensity = 75;        int townSize = 60;        int mountainPeaks, mountainHeightMin, mountainHeightMax;        int mountainStyle, mountainWidthMin, mountainWidthMax;        int invertNegative = 0;        try {            boardWidth = Integer.parseInt(texBoardWidth.getText());            boardHeight = Integer.parseInt(texBoardHeight.getText());        } catch (NumberFormatException ex) {            JOptionPane.showMessageDialog(frame, Messages.getString("RandomMapDialog.OnlyIntegersWarn"), INVALID_SETTING, JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$            return false;        }        if (boardHeight <= 0 || boardHeight <= 0) {            JOptionPane.showMessageDialog(frame, Messages.getString("RandomMapDialog.BoardSizeWarn"), INVALID_SETTING, JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$            return false;        }        theme = texTheme.getText();        if (advanced) {            try {                hilliness = Integer.parseInt(texHilliness.getText());                range = Integer.parseInt(texRange.getText());                cliffs = Integer.parseInt(texCliffs.getText());                probInvert = Integer.parseInt(texProbInvert.getText());                minWaterSpots = Integer.parseInt(texMinWaterSpots.getText());

⌨️ 快捷键说明

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