📄 quadmapset.java
字号:
/** * MegaMek - Copyright (C) 2000-2002 Ben Mazur (bmazur@sev.org) * * 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.AWT.widget;import java.awt.*;import java.util.*;import megamek.client.ui.AWT.widget.WidgetUtils;import megamek.client.ui.AWT.GUIPreferences;import megamek.client.ui.AWT.Messages;import megamek.common.*;/** * Very cumbersome class that handles set of polygonal areas and labels * for PicMap component to represent single mech unit in MechDisplay */public class QuadMapSet implements DisplayMapSet{ private static final String IMAGE_DIR = "data/images/widgets"; //Because of keeping all areas of single type in one array //some index offset values required private static final int REAR_AREA_OFFSET = 7; private static final int INT_STRUCTURE_OFFSET = 11; //Array of polygonal areas - parts of mech body. private PMSimplePolygonArea[] areas = new PMSimplePolygonArea[19]; //Array of fixed labels - short names of body parts private PMSimpleLabel[] labels = new PMSimpleLabel[19]; //Array of value labels to show armor and IS values private PMValueLabel[] vLabels = new PMValueLabel[20]; //Heat control area private PMPicPolygonalArea heatHotArea; //Set of Background Drawers private Vector bgDrawers = new Vector(); //Main areas group that keeps everything in itself and is passed to PicMap component private PMAreasGroup content = new PMAreasGroup(); //Reference to Component class (need to manage images and fonts) private Component comp; //Points for build hot areas (may be too heavy, think of to load from exteranl file) //Mek armor - Front private Polygon rightArm = new Polygon(new int[]{102,102,100,95,95,100,110,120,120,125}, new int[]{120,70,65,65,50,55,55,65,115,120}, 10); private Polygon leftArm = new Polygon(new int[]{0,5,5,15,25,30,30,25,23,23}, new int[]{120,115,65,55,55,50,65,65,70,120}, 10); private Polygon head = new Polygon(new int[]{50,50,55,70,75,75}, new int[]{40,25,20,20,25,40}, 6); private Polygon centralTorso = new Polygon(new int[]{50,50,75,75}, new int[]{80,40,40,80}, 4); private Polygon leftTorso = new Polygon(new int[]{50,35,30,30,35,50}, new int[]{80,80,75,45,40,40}, 6); private Polygon rightTorso = new Polygon(new int[]{75,75,90,95,95,90}, new int[]{80,40,40,45,75,80}, 6); private Polygon leftLeg = new Polygon(new int[]{30,30,35,50,50,55}, new int[]{120,85,80,80,115,120}, 6); private Polygon rightLeg = new Polygon(new int[]{70,75,75,90,95,95}, new int[]{120,115,80,80,85,120}, 6); //Mek Armor - Rear private Polygon rearLeftTorso = new Polygon(new int[] {142,142,148,139,123,123,142}, new int[] {14,43,76,76,44,17,14}, 7); private Polygon rearCentralTorso = new Polygon(new int[] {142,148,162,168,168,142}, new int[] {44,76,76,44,14,14}, 6); private Polygon rearRightTorso = new Polygon(new int[]{168,168,162,171,187,187,168}, new int[]{14,43,76,76,44,17,14},7); //Internal Structure private Polygon inStRightArm = new Polygon(new int[]{102,102,100,95,95,100,110,120,120,125}, new int[]{112+120,112+70,112+65,112+65,112+50,112+55,112+55,112+65,112+115,112+120}, 10); private Polygon inStLeftArm = new Polygon(new int[]{0,5,5,15,25,30,30,25,23,23}, new int[]{112+120,112+115,112+65,112+55,112+55,112+50,112+65,112+65,112+70,112+120}, 10); private Polygon intStHead = new Polygon(new int[]{50,50,55,70,75,75}, new int[]{112+40,112+25,112+20,112+20,112+25,112+40}, 6); private Polygon inStCentralTorso = new Polygon(new int[]{50,50,75,75}, new int[]{112+80,112+40,112+40,112+80}, 4); private Polygon inStLeftTorso = new Polygon(new int[]{50,35,30,30,35,50}, new int[]{112+80,112+80,112+75,112+45,112+40,112+40}, 6); private Polygon inStRightTorso = new Polygon(new int[]{75,75,90,95,95,90}, new int[]{112+80,112+40,112+40,112+45,112+75,112+80}, 6); private Polygon inStLeftLeg = new Polygon(new int[]{30,30,35,50,50,55}, new int[]{112+120,112+85,112+80,112+80,112+115,112+120}, 6); private Polygon inStRightLeg = new Polygon(new int[]{70,75,75,90,95,95}, new int[]{112+120,112+115,112+80,112+80,112+85,112+120}, 6); //Heat control private Polygon heatControl = new Polygon(new int[]{149,159,159,149}, new int[]{100,100,220,220},4); private Image heatImage; private static final Font FONT_LABEL = new Font("SansSerif", Font.PLAIN, GUIPreferences.getInstance().getInt("AdvancedMechDisplayArmorSmallFontSize")); //$NON-NLS-1$ private static final Font FONT_VALUE = new Font("SansSerif", Font.PLAIN, GUIPreferences.getInstance().getInt("AdvancedMechDisplayArmorLargeFontSize")); //$NON-NLS-1$ public QuadMapSet(Component c){ comp = c; setAreas(); setLabels(); setGroups(); setBackGround(); } public PMAreasGroup getContentGroup(){ return content; } public Vector getBackgroundDrawers(){ return bgDrawers; } public void setEntity(Entity e){ Mech m = (Mech) e; boolean mtHeat = false; if (e.getGame() != null && e.getGame().getOptions().booleanOption("maxtech_heat")) { mtHeat = true; } int a = 1; int a0 = 1; for (int i = 0; i< m.locations(); i++){ a = m.getArmor(i); a0 = m.getOArmor(i); vLabels[i].setValue(m.getArmorString(i)); WidgetUtils.setAreaColor(areas[i], vLabels[i], (double)a/(double)a0); if(m.hasRearArmor(i)){ a = m.getArmor(i, true); a0 = m.getOArmor(i, true); vLabels[i + REAR_AREA_OFFSET].setValue(m.getArmorString(i,true)); WidgetUtils.setAreaColor(areas[i + REAR_AREA_OFFSET], vLabels[i + REAR_AREA_OFFSET], (double)a/(double)a0); } a = m.getInternal(i); a0 = m.getOInternal(i); vLabels[i + INT_STRUCTURE_OFFSET].setValue(m.getInternalString(i)); WidgetUtils.setAreaColor(areas[i + INT_STRUCTURE_OFFSET], vLabels[i + INT_STRUCTURE_OFFSET], (double)a/(double)a0); } //heat vLabels[19].setValue(Integer.toString(m.heat));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -